Rev 3260 | Rev 5060 | 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 |
||
4104 | Serge | 38 | #include |
3031 | serge | 39 | |
40 | struct va_format { |
||
41 | const char *fmt; |
||
42 | va_list *va; |
||
43 | }; |
||
44 | |||
45 | unsigned int drm_debug = 0; /* 1 to enable debug output */ |
||
46 | EXPORT_SYMBOL(drm_debug); |
||
47 | |||
4104 | Serge | 48 | unsigned int drm_rnodes = 0; /* 1 to enable experimental render nodes API */ |
49 | EXPORT_SYMBOL(drm_rnodes); |
||
50 | |||
3031 | serge | 51 | unsigned int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */ |
52 | EXPORT_SYMBOL(drm_vblank_offdelay); |
||
53 | |||
54 | unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ |
||
55 | EXPORT_SYMBOL(drm_timestamp_precision); |
||
56 | |||
4104 | Serge | 57 | struct idr drm_minors_idr; |
3031 | serge | 58 | int drm_err(const char *func, const char *format, ...) |
59 | { |
||
60 | struct va_format vaf; |
||
61 | va_list args; |
||
62 | int r; |
||
63 | |||
64 | va_start(args, format); |
||
65 | |||
66 | vaf.fmt = format; |
||
67 | vaf.va = &args; |
||
68 | |||
69 | r = printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* %pV", func, &vaf); |
||
70 | |||
71 | va_end(args); |
||
72 | |||
73 | return r; |
||
74 | } |
||
75 | EXPORT_SYMBOL(drm_err); |
||
76 | |||
77 | void drm_ut_debug_printk(unsigned int request_level, |
||
78 | const char *prefix, |
||
79 | const char *function_name, |
||
80 | const char *format, ...) |
||
81 | { |
||
82 | va_list args; |
||
83 | |||
84 | // if (drm_debug & request_level) { |
||
85 | // if (function_name) |
||
86 | // printk(KERN_DEBUG "[%s:%s], ", prefix, function_name); |
||
87 | // va_start(args, format); |
||
88 | // vprintk(format, args); |
||
89 | // va_end(args); |
||
90 | // } |
||
91 | } |
||
92 | EXPORT_SYMBOL(drm_ut_debug_printk); |
||
93 | |||
4104 | Serge | 94 | int drm_fill_in_dev(struct drm_device *dev, |
95 | const struct pci_device_id *ent, |
||
96 | struct drm_driver *driver) |
||
97 | { |
||
98 | int retcode; |
||
99 | |||
100 | INIT_LIST_HEAD(&dev->filelist); |
||
101 | INIT_LIST_HEAD(&dev->ctxlist); |
||
102 | INIT_LIST_HEAD(&dev->vmalist); |
||
103 | INIT_LIST_HEAD(&dev->maplist); |
||
104 | INIT_LIST_HEAD(&dev->vblank_event_list); |
||
105 | |||
106 | spin_lock_init(&dev->count_lock); |
||
107 | spin_lock_init(&dev->event_lock); |
||
108 | mutex_init(&dev->struct_mutex); |
||
109 | mutex_init(&dev->ctxlist_mutex); |
||
110 | |||
111 | // if (drm_ht_create(&dev->map_hash, 12)) { |
||
112 | // return -ENOMEM; |
||
113 | // } |
||
114 | |||
115 | dev->driver = driver; |
||
116 | |||
117 | if (driver->driver_features & DRIVER_GEM) { |
||
118 | retcode = drm_gem_init(dev); |
||
119 | if (retcode) { |
||
120 | DRM_ERROR("Cannot initialize graphics execution " |
||
121 | "manager (GEM)\n"); |
||
122 | goto error_out_unreg; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | return 0; |
||
127 | |||
128 | error_out_unreg: |
||
129 | // drm_lastclose(dev); |
||
130 | return retcode; |
||
131 | } |
||
132 | EXPORT_SYMBOL(drm_fill_in_dev); |
||
3031 | serge | 133 | /** |
134 | * Compute size order. Returns the exponent of the smaller power of two which |
||
135 | * is greater or equal to given number. |
||
136 | * |
||
137 | * \param size size. |
||
138 | * \return order. |
||
139 | * |
||
140 | * \todo Can be made faster. |
||
141 | */ |
||
142 | int drm_order(unsigned long size) |
||
143 | { |
||
144 | int order; |
||
145 | unsigned long tmp; |
||
146 | |||
147 | for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ; |
||
148 | |||
149 | if (size & (size - 1)) |
||
150 | ++order; |
||
151 | |||
152 | return order; |
||
153 | } |
||
3260 | Serge | 154 | |
155 | extern int x86_clflush_size; |
||
156 | |||
157 | static inline void clflush(volatile void *__p) |
||
158 | { |
||
159 | asm volatile("clflush %0" : "+m" (*(volatile char*)__p)); |
||
160 | } |
||
161 | |||
162 | void |
||
163 | drm_clflush_virt_range(char *addr, unsigned long length) |
||
164 | { |
||
165 | char *end = addr + length; |
||
166 | mb(); |
||
167 | for (; addr < end; addr += x86_clflush_size) |
||
168 | clflush(addr); |
||
169 | clflush(end - 1); |
||
170 | mb(); |
||
171 | return; |
||
172 | }> |
||
173 |