Subversion Repositories Kolibri OS

Rev

Rev 3031 | Rev 4104 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3031 serge 1
/**
2
 * \file drm_stub.h
3
 * Stub support
4
 *
5
 * \author Rickard E. (Rik) Faith 
6
 */
7
 
8
/*
9
 * Created: Fri Jan 19 10:48:35 2001 by faith@acm.org
10
 *
11
 * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
12
 * All Rights Reserved.
13
 *
14
 * Permission is hereby granted, free of charge, to any person obtaining a
15
 * copy of this software and associated documentation files (the "Software"),
16
 * to deal in the Software without restriction, including without limitation
17
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
 * and/or sell copies of the Software, and to permit persons to whom the
19
 * Software is furnished to do so, subject to the following conditions:
20
 *
21
 * The above copyright notice and this permission notice (including the next
22
 * paragraph) shall be included in all copies or substantial portions of the
23
 * Software.
24
 *
25
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
28
 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31
 * DEALINGS IN THE SOFTWARE.
32
 */
33
 
34
#include 
35
 
36
#include 
37
#include 
38
 
39
struct va_format {
40
    const char *fmt;
41
    va_list *va;
42
};
43
 
44
unsigned int drm_debug = 0;	/* 1 to enable debug output */
45
EXPORT_SYMBOL(drm_debug);
46
 
47
unsigned int drm_vblank_offdelay = 5000;    /* Default to 5000 msecs. */
48
EXPORT_SYMBOL(drm_vblank_offdelay);
49
 
50
unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
51
EXPORT_SYMBOL(drm_timestamp_precision);
52
 
53
int drm_err(const char *func, const char *format, ...)
54
{
55
	struct va_format vaf;
56
	va_list args;
57
	int r;
58
 
59
	va_start(args, format);
60
 
61
	vaf.fmt = format;
62
	vaf.va = &args;
63
 
64
	r = printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* %pV", func, &vaf);
65
 
66
	va_end(args);
67
 
68
	return r;
69
}
70
EXPORT_SYMBOL(drm_err);
71
 
72
void drm_ut_debug_printk(unsigned int request_level,
73
			 const char *prefix,
74
			 const char *function_name,
75
			 const char *format, ...)
76
{
77
	va_list args;
78
 
79
//   if (drm_debug & request_level) {
80
//       if (function_name)
81
//           printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
82
//       va_start(args, format);
83
//       vprintk(format, args);
84
//       va_end(args);
85
//   }
86
}
87
EXPORT_SYMBOL(drm_ut_debug_printk);
88
 
89
/**
90
 * Compute size order.  Returns the exponent of the smaller power of two which
91
 * is greater or equal to given number.
92
 *
93
 * \param size size.
94
 * \return order.
95
 *
96
 * \todo Can be made faster.
97
 */
98
int drm_order(unsigned long size)
99
{
100
    int order;
101
    unsigned long tmp;
102
 
103
    for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ;
104
 
105
    if (size & (size - 1))
106
        ++order;
107
 
108
    return order;
109
}
3260 Serge 110
 
111
extern int x86_clflush_size;
112
 
113
static inline void clflush(volatile void *__p)
114
{
115
    asm volatile("clflush %0" : "+m" (*(volatile char*)__p));
116
}
117
 
118
void
119
drm_clflush_virt_range(char *addr, unsigned long length)
120
{
121
    char *end = addr + length;
122
    mb();
123
    for (; addr < end; addr += x86_clflush_size)
124
        clflush(addr);
125
    clflush(end - 1);
126
    mb();
127
    return;
128
}
129