Rev 4104 | 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 |
||
4560 | Serge | 35 | #include |
3031 | serge | 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 | { |
||
4560 | Serge | 82 | struct va_format vaf; |
3031 | serge | 83 | va_list args; |
84 | |||
85 | // if (drm_debug & request_level) { |
||
86 | // if (function_name) |
||
87 | // printk(KERN_DEBUG "[%s:%s], ", prefix, function_name); |
||
88 | // va_start(args, format); |
||
89 | // vprintk(format, args); |
||
90 | // va_end(args); |
||
91 | // } |
||
92 | } |
||
93 | EXPORT_SYMBOL(drm_ut_debug_printk); |
||
94 | |||
4104 | Serge | 95 | int drm_fill_in_dev(struct drm_device *dev, |
96 | const struct pci_device_id *ent, |
||
97 | struct drm_driver *driver) |
||
98 | { |
||
99 | int retcode; |
||
100 | |||
101 | INIT_LIST_HEAD(&dev->filelist); |
||
102 | INIT_LIST_HEAD(&dev->ctxlist); |
||
103 | INIT_LIST_HEAD(&dev->vmalist); |
||
104 | INIT_LIST_HEAD(&dev->maplist); |
||
105 | INIT_LIST_HEAD(&dev->vblank_event_list); |
||
106 | |||
107 | spin_lock_init(&dev->count_lock); |
||
108 | spin_lock_init(&dev->event_lock); |
||
109 | mutex_init(&dev->struct_mutex); |
||
110 | mutex_init(&dev->ctxlist_mutex); |
||
111 | |||
112 | // if (drm_ht_create(&dev->map_hash, 12)) { |
||
113 | // return -ENOMEM; |
||
114 | // } |
||
115 | |||
116 | dev->driver = driver; |
||
117 | |||
118 | if (driver->driver_features & DRIVER_GEM) { |
||
119 | retcode = drm_gem_init(dev); |
||
120 | if (retcode) { |
||
121 | DRM_ERROR("Cannot initialize graphics execution " |
||
122 | "manager (GEM)\n"); |
||
123 | goto error_out_unreg; |
||
124 | } |
||
125 | } |
||
126 | |||
127 | return 0; |
||
128 | |||
129 | error_out_unreg: |
||
130 | // drm_lastclose(dev); |
||
131 | return retcode; |
||
132 | } |
||
133 | EXPORT_SYMBOL(drm_fill_in_dev); |
||
3031 | serge | 134 | /** |
135 | * Compute size order. Returns the exponent of the smaller power of two which |
||
136 | * is greater or equal to given number. |
||
137 | * |
||
138 | * \param size size. |
||
139 | * \return order. |
||
140 | * |
||
141 | * \todo Can be made faster. |
||
142 | */ |
||
143 | int drm_order(unsigned long size) |
||
144 | { |
||
145 | int order; |
||
146 | unsigned long tmp; |
||
147 | |||
148 | for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ; |
||
149 | |||
150 | if (size & (size - 1)) |
||
151 | ++order; |
||
152 | |||
153 | return order; |
||
154 | } |
||
3260 | Serge | 155 | |
156 | extern int x86_clflush_size; |
||
157 | |||
158 | static inline void clflush(volatile void *__p) |
||
159 | { |
||
160 | asm volatile("clflush %0" : "+m" (*(volatile char*)__p)); |
||
161 | } |
||
162 | |||
163 | void |
||
164 | drm_clflush_virt_range(char *addr, unsigned long length) |
||
165 | { |
||
166 | char *end = addr + length; |
||
167 | mb(); |
||
168 | for (; addr < end; addr += x86_clflush_size) |
||
169 | clflush(addr); |
||
170 | clflush(end - 1); |
||
171 | mb(); |
||
172 | return; |
||
173 | }> |
||
174 |