Rev 5060 | Rev 5367 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5060 | Rev 5354 | ||
---|---|---|---|
1 | #define iowrite32(v, addr) writel((v), (addr)) |
1 | #define iowrite32(v, addr) writel((v), (addr)) |
2 | 2 | ||
3 | #include |
3 | #include |
4 | #include |
4 | #include |
5 | #include "i915_drv.h" |
5 | #include "i915_drv.h" |
6 | #include "intel_drv.h" |
6 | #include "intel_drv.h" |
7 | #include |
7 | #include |
8 | #include |
- | |
9 | #include |
8 | #include |
10 | #include |
9 | #include |
11 | #include |
- | |
12 | 10 | ||
13 | #include |
11 | #include |
14 | 12 | ||
15 | #include "bitmap.h" |
13 | #include "bitmap.h" |
16 | 14 | #include |
|
- | 15 | ||
17 | typedef struct |
- | |
18 | { |
- | |
19 | kobj_t header; |
- | |
20 | - | ||
21 | uint32_t *data; |
- | |
22 | uint32_t hot_x; |
- | |
23 | uint32_t hot_y; |
- | |
24 | - | ||
25 | struct list_head list; |
- | |
26 | struct drm_i915_gem_object *cobj; |
- | |
27 | }cursor_t; |
- | |
28 | - | ||
29 | #define KMS_CURSOR_WIDTH 64 |
- | |
30 | #define KMS_CURSOR_HEIGHT 64 |
- | |
31 | - | ||
32 | - | ||
33 | struct tag_display |
- | |
34 | { |
- | |
35 | int x; |
- | |
36 | int y; |
- | |
37 | int width; |
- | |
38 | int height; |
- | |
39 | int bpp; |
- | |
40 | int vrefresh; |
- | |
41 | int pitch; |
- | |
42 | int lfb; |
- | |
43 | - | ||
44 | int supported_modes; |
- | |
45 | struct drm_device *ddev; |
- | |
46 | struct drm_connector *connector; |
- | |
47 | struct drm_crtc *crtc; |
- | |
48 | - | ||
49 | struct list_head cursors; |
- | |
50 | - | ||
51 | cursor_t *cursor; |
- | |
52 | int (*init_cursor)(cursor_t*); |
- | |
53 | cursor_t* (__stdcall *select_cursor)(cursor_t*); |
- | |
54 | void (*show_cursor)(int show); |
- | |
55 | void (__stdcall *move_cursor)(cursor_t *cursor, int x, int y); |
- | |
56 | void (__stdcall *restore_cursor)(int x, int y); |
- | |
57 | void (*disable_mouse)(void); |
- | |
58 | u32 mask_seqno; |
- | |
59 | u32 check_mouse; |
- | |
60 | u32 check_m_pixel; |
- | |
61 | }; |
- | |
62 | - | ||
63 | 16 | ||
64 | static display_t *os_display; |
17 | display_t *os_display; |
65 | struct drm_i915_gem_object *main_fb_obj; |
18 | struct drm_i915_gem_object *main_fb_obj; |
66 | 19 | ||
67 | u32_t cmd_buffer; |
20 | u32 cmd_buffer; |
68 | u32_t cmd_offset; |
21 | u32 cmd_offset; |
69 | 22 | ||
70 | void init_render(); |
23 | void init_render(); |
71 | int sna_init(); |
24 | int sna_init(); |
72 | 25 | ||
73 | int init_cursor(cursor_t *cursor); |
- | |
74 | static cursor_t* __stdcall select_cursor_kms(cursor_t *cursor); |
26 | static cursor_t* __stdcall select_cursor_kms(cursor_t *cursor); |
75 | static void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y); |
27 | static void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y); |
76 | 28 | ||
77 | void __stdcall restore_cursor(int x, int y) |
29 | void __stdcall restore_cursor(int x, int y) |
78 | {}; |
30 | {}; |
79 | 31 | ||
80 | void disable_mouse(void) |
32 | void disable_mouse(void) |
81 | {}; |
33 | {}; |
82 | 34 | ||
83 | 35 | ||
84 | static char *manufacturer_name(unsigned char *x) |
36 | static char *manufacturer_name(unsigned char *x) |
85 | { |
37 | { |
86 | static char name[4]; |
38 | static char name[4]; |
87 | 39 | ||
88 | name[0] = ((x[0] & 0x7C) >> 2) + '@'; |
40 | name[0] = ((x[0] & 0x7C) >> 2) + '@'; |
89 | name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
41 | name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
90 | name[2] = (x[1] & 0x1F) + '@'; |
42 | name[2] = (x[1] & 0x1F) + '@'; |
91 | name[3] = 0; |
43 | name[3] = 0; |
92 | 44 | ||
93 | return name; |
45 | return name; |
94 | } |
46 | } |
95 | 47 | ||
96 | static int set_mode(struct drm_device *dev, struct drm_connector *connector, |
48 | static int set_mode(struct drm_device *dev, struct drm_connector *connector, |
97 | struct drm_crtc *crtc, videomode_t *reqmode, bool strict) |
49 | struct drm_crtc *crtc, videomode_t *reqmode, bool strict) |
98 | { |
50 | { |
99 | struct drm_i915_private *dev_priv = dev->dev_private; |
51 | struct drm_i915_private *dev_priv = dev->dev_private; |
100 | 52 | ||
101 | struct drm_mode_config *config = &dev->mode_config; |
53 | struct drm_mode_config *config = &dev->mode_config; |
102 | struct drm_display_mode *mode = NULL, *tmpmode; |
54 | struct drm_display_mode *mode = NULL, *tmpmode; |
103 | struct drm_framebuffer *fb = NULL; |
55 | struct drm_framebuffer *fb = NULL; |
104 | struct drm_mode_set set; |
56 | struct drm_mode_set set; |
105 | const char *con_name; |
57 | const char *con_name; |
106 | unsigned hdisplay, vdisplay; |
58 | unsigned hdisplay, vdisplay; |
107 | int stride; |
59 | int stride; |
108 | int ret; |
60 | int ret; |
109 | 61 | ||
110 | drm_modeset_lock_all(dev); |
62 | drm_modeset_lock_all(dev); |
111 | 63 | ||
112 | list_for_each_entry(tmpmode, &connector->modes, head) |
64 | list_for_each_entry(tmpmode, &connector->modes, head) |
113 | { |
65 | { |
114 | if( (tmpmode->hdisplay == reqmode->width) && |
66 | if( (tmpmode->hdisplay == reqmode->width) && |
115 | (tmpmode->vdisplay == reqmode->height) && |
67 | (tmpmode->vdisplay == reqmode->height) && |
116 | (drm_mode_vrefresh(tmpmode) == reqmode->freq) ) |
68 | (drm_mode_vrefresh(tmpmode) == reqmode->freq) ) |
117 | { |
69 | { |
118 | mode = tmpmode; |
70 | mode = tmpmode; |
119 | goto do_set; |
71 | goto do_set; |
120 | } |
72 | } |
121 | }; |
73 | }; |
122 | 74 | ||
123 | if( (mode == NULL) && (strict == false) ) |
75 | if( (mode == NULL) && (strict == false) ) |
124 | { |
76 | { |
125 | list_for_each_entry(tmpmode, &connector->modes, head) |
77 | list_for_each_entry(tmpmode, &connector->modes, head) |
126 | { |
78 | { |
127 | if( (tmpmode->hdisplay == reqmode->width) && |
79 | if( (tmpmode->hdisplay == reqmode->width) && |
128 | (tmpmode->vdisplay == reqmode->height) ) |
80 | (tmpmode->vdisplay == reqmode->height) ) |
129 | { |
81 | { |
130 | mode = tmpmode; |
82 | mode = tmpmode; |
131 | goto do_set; |
83 | goto do_set; |
132 | } |
84 | } |
133 | }; |
85 | }; |
134 | }; |
86 | }; |
135 | 87 | ||
136 | DRM_ERROR("%s failed\n", __FUNCTION__); |
88 | DRM_ERROR("%s failed\n", __FUNCTION__); |
137 | 89 | ||
138 | return -1; |
90 | return -1; |
139 | 91 | ||
140 | do_set: |
92 | do_set: |
141 | 93 | ||
142 | con_name = connector->name; |
94 | con_name = connector->name; |
143 | 95 | ||
144 | DRM_DEBUG_KMS("set mode %d %d: crtc %d connector %s\n", |
96 | DRM_DEBUG_KMS("set mode %d %d: crtc %d connector %s\n", |
145 | reqmode->width, reqmode->height, crtc->base.id, |
97 | reqmode->width, reqmode->height, crtc->base.id, |
146 | con_name); |
98 | con_name); |
147 | 99 | ||
148 | drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); |
100 | drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); |
149 | 101 | ||
150 | hdisplay = mode->hdisplay; |
102 | hdisplay = mode->hdisplay; |
151 | vdisplay = mode->vdisplay; |
103 | vdisplay = mode->vdisplay; |
152 | 104 | ||
153 | if (crtc->invert_dimensions) |
105 | if (crtc->invert_dimensions) |
154 | swap(hdisplay, vdisplay); |
106 | swap(hdisplay, vdisplay); |
155 | 107 | ||
156 | fb = crtc->primary->fb; |
108 | fb = crtc->primary->fb; |
157 | 109 | ||
158 | fb->width = reqmode->width; |
110 | fb->width = reqmode->width; |
159 | fb->height = reqmode->height; |
111 | fb->height = reqmode->height; |
160 | 112 | ||
161 | main_fb_obj->tiling_mode = I915_TILING_X; |
113 | main_fb_obj->tiling_mode = I915_TILING_X; |
162 | 114 | ||
163 | if( main_fb_obj->tiling_mode == I915_TILING_X) |
115 | if( main_fb_obj->tiling_mode == I915_TILING_X) |
164 | { |
116 | { |
165 | if(IS_GEN3(dev)) |
117 | if(IS_GEN3(dev)) |
166 | for (stride = 512; stride < reqmode->width * 4; stride <<= 1); |
118 | for (stride = 512; stride < reqmode->width * 4; stride <<= 1); |
167 | else |
119 | else |
168 | stride = ALIGN(reqmode->width * 4, 512); |
120 | stride = ALIGN(reqmode->width * 4, 512); |
169 | } |
121 | } |
170 | else |
122 | else |
171 | { |
123 | { |
172 | stride = ALIGN(reqmode->width * 4, 64); |
124 | stride = ALIGN(reqmode->width * 4, 64); |
173 | } |
125 | } |
174 | 126 | ||
175 | fb->pitches[0] = |
127 | fb->pitches[0] = |
176 | fb->pitches[1] = |
128 | fb->pitches[1] = |
177 | fb->pitches[2] = |
129 | fb->pitches[2] = |
178 | fb->pitches[3] = stride; |
130 | fb->pitches[3] = stride; |
179 | 131 | ||
180 | main_fb_obj->stride = stride; |
132 | main_fb_obj->stride = stride; |
181 | 133 | ||
182 | fb->bits_per_pixel = 32; |
134 | fb->bits_per_pixel = 32; |
183 | fb->depth = 24; |
135 | fb->depth = 24; |
184 | 136 | ||
185 | crtc->enabled = true; |
137 | crtc->enabled = true; |
186 | os_display->crtc = crtc; |
138 | os_display->crtc = crtc; |
187 | 139 | ||
188 | // i915_gem_object_unpin_fence(main_fb_obj); |
140 | // i915_gem_object_unpin_fence(main_fb_obj); |
189 | i915_gem_object_put_fence(main_fb_obj); |
141 | i915_gem_object_put_fence(main_fb_obj); |
190 | 142 | ||
191 | set.crtc = crtc; |
143 | set.crtc = crtc; |
192 | set.x = 0; |
144 | set.x = 0; |
193 | set.y = 0; |
145 | set.y = 0; |
194 | set.mode = mode; |
146 | set.mode = mode; |
195 | set.connectors = &connector; |
147 | set.connectors = &connector; |
196 | set.num_connectors = 1; |
148 | set.num_connectors = 1; |
197 | set.fb = fb; |
149 | set.fb = fb; |
198 | 150 | ||
199 | ret = drm_mode_set_config_internal(&set); |
151 | ret = drm_mode_set_config_internal(&set); |
200 | 152 | ||
201 | drm_modeset_unlock_all(dev); |
153 | drm_modeset_unlock_all(dev); |
202 | 154 | ||
203 | if ( !ret ) |
155 | if ( !ret ) |
204 | { |
156 | { |
205 | os_display->width = fb->width; |
157 | os_display->width = fb->width; |
206 | os_display->height = fb->height; |
158 | os_display->height = fb->height; |
207 | os_display->vrefresh = drm_mode_vrefresh(mode); |
159 | os_display->vrefresh = drm_mode_vrefresh(mode); |
208 | 160 | ||
209 | sysSetScreen(fb->width, fb->height, fb->pitches[0]); |
161 | sysSetScreen(fb->width, fb->height, fb->pitches[0]); |
210 | 162 | ||
211 | DRM_DEBUG_KMS("new mode %d x %d pitch %d\n", |
163 | DRM_DEBUG_KMS("new mode %d x %d pitch %d\n", |
212 | fb->width, fb->height, fb->pitches[0]); |
164 | fb->width, fb->height, fb->pitches[0]); |
213 | } |
165 | } |
214 | else |
166 | else |
215 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
167 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
216 | fb->width, fb->height, crtc); |
168 | fb->width, fb->height, crtc); |
217 | 169 | ||
218 | return ret; |
170 | return ret; |
219 | } |
171 | } |
220 | 172 | ||
221 | static int count_connector_modes(struct drm_connector* connector) |
173 | static int count_connector_modes(struct drm_connector* connector) |
222 | { |
174 | { |
223 | struct drm_display_mode *mode; |
175 | struct drm_display_mode *mode; |
224 | int count = 0; |
176 | int count = 0; |
225 | 177 | ||
226 | list_for_each_entry(mode, &connector->modes, head) |
178 | list_for_each_entry(mode, &connector->modes, head) |
227 | { |
179 | { |
228 | count++; |
180 | count++; |
229 | }; |
181 | }; |
230 | return count; |
182 | return count; |
231 | }; |
183 | }; |
232 | 184 | ||
233 | static struct drm_crtc *get_possible_crtc(struct drm_device *dev, struct drm_encoder *encoder) |
185 | static struct drm_crtc *get_possible_crtc(struct drm_device *dev, struct drm_encoder *encoder) |
234 | { |
186 | { |
235 | struct drm_crtc *tmp_crtc; |
187 | struct drm_crtc *tmp_crtc; |
236 | int crtc_mask = 1; |
188 | int crtc_mask = 1; |
237 | 189 | ||
238 | list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head) |
190 | list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head) |
239 | { |
191 | { |
240 | if (encoder->possible_crtcs & crtc_mask) |
192 | if (encoder->possible_crtcs & crtc_mask) |
241 | { |
193 | { |
242 | encoder->crtc = tmp_crtc; |
194 | encoder->crtc = tmp_crtc; |
243 | DRM_DEBUG_KMS("use CRTC %p ID %d\n", tmp_crtc, tmp_crtc->base.id); |
195 | DRM_DEBUG_KMS("use CRTC %p ID %d\n", tmp_crtc, tmp_crtc->base.id); |
244 | return tmp_crtc; |
196 | return tmp_crtc; |
245 | }; |
197 | }; |
246 | crtc_mask <<= 1; |
198 | crtc_mask <<= 1; |
247 | }; |
199 | }; |
248 | return NULL; |
200 | return NULL; |
249 | }; |
201 | }; |
250 | 202 | ||
251 | static int choose_config(struct drm_device *dev, struct drm_connector **boot_connector, |
203 | static int choose_config(struct drm_device *dev, struct drm_connector **boot_connector, |
252 | struct drm_crtc **boot_crtc) |
204 | struct drm_crtc **boot_crtc) |
253 | { |
205 | { |
254 | struct drm_connector_helper_funcs *connector_funcs; |
206 | struct drm_connector_helper_funcs *connector_funcs; |
255 | struct drm_connector *connector; |
207 | struct drm_connector *connector; |
256 | struct drm_encoder *encoder; |
208 | struct drm_encoder *encoder; |
257 | struct drm_crtc *crtc; |
209 | struct drm_crtc *crtc; |
258 | 210 | ||
259 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
211 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
260 | { |
212 | { |
261 | if( connector->status != connector_status_connected) |
213 | if( connector->status != connector_status_connected) |
262 | continue; |
214 | continue; |
263 | 215 | ||
264 | encoder = connector->encoder; |
216 | encoder = connector->encoder; |
265 | 217 | ||
266 | if(encoder == NULL) |
218 | if(encoder == NULL) |
267 | { |
219 | { |
268 | connector_funcs = connector->helper_private; |
220 | connector_funcs = connector->helper_private; |
269 | encoder = connector_funcs->best_encoder(connector); |
221 | encoder = connector_funcs->best_encoder(connector); |
270 | 222 | ||
271 | if( encoder == NULL) |
223 | if( encoder == NULL) |
272 | { |
224 | { |
273 | DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n", |
225 | DRM_DEBUG_KMS("CONNECTOR %x ID: %d no active encoders\n", |
274 | connector, connector->base.id); |
226 | connector, connector->base.id); |
275 | continue; |
227 | continue; |
276 | }; |
228 | }; |
277 | } |
229 | } |
278 | 230 | ||
279 | crtc = encoder->crtc; |
231 | crtc = encoder->crtc; |
280 | if(crtc == NULL) |
232 | if(crtc == NULL) |
281 | crtc = get_possible_crtc(dev, encoder); |
233 | crtc = get_possible_crtc(dev, encoder); |
282 | 234 | ||
283 | if(crtc != NULL) |
235 | if(crtc != NULL) |
284 | { |
236 | { |
285 | *boot_connector = connector; |
237 | *boot_connector = connector; |
286 | *boot_crtc = crtc; |
238 | *boot_crtc = crtc; |
287 | 239 | ||
288 | DRM_DEBUG_KMS("CONNECTOR %p ID:%d status:%d ENCODER %p ID: %d CRTC %p ID:%d\n", |
240 | DRM_DEBUG_KMS("CONNECTOR %p ID:%d status:%d ENCODER %p ID: %d CRTC %p ID:%d\n", |
289 | connector, connector->base.id, connector->status, |
241 | connector, connector->base.id, connector->status, |
290 | encoder, encoder->base.id, crtc, crtc->base.id ); |
242 | encoder, encoder->base.id, crtc, crtc->base.id ); |
291 | return 0; |
243 | return 0; |
292 | } |
244 | } |
293 | else |
245 | else |
294 | DRM_DEBUG_KMS("No CRTC for encoder %d\n", encoder->base.id); |
246 | DRM_DEBUG_KMS("No CRTC for encoder %d\n", encoder->base.id); |
295 | 247 | ||
296 | }; |
248 | }; |
297 | 249 | ||
298 | return -ENOENT; |
250 | return -ENOENT; |
299 | }; |
251 | }; |
300 | 252 | ||
301 | static int get_boot_mode(struct drm_connector *connector, videomode_t *usermode) |
253 | static int get_boot_mode(struct drm_connector *connector, videomode_t *usermode) |
302 | { |
254 | { |
303 | struct drm_display_mode *mode; |
255 | struct drm_display_mode *mode; |
304 | 256 | ||
305 | list_for_each_entry(mode, &connector->modes, head) |
257 | list_for_each_entry(mode, &connector->modes, head) |
306 | { |
258 | { |
307 | DRM_DEBUG_KMS("check mode w:%d h:%d %dHz\n", |
259 | DRM_DEBUG_KMS("check mode w:%d h:%d %dHz\n", |
308 | mode->hdisplay, mode->vdisplay, |
260 | mode->hdisplay, mode->vdisplay, |
309 | drm_mode_vrefresh(mode)); |
261 | drm_mode_vrefresh(mode)); |
310 | 262 | ||
311 | if( os_display->width == mode->hdisplay && |
263 | if( os_display->width == mode->hdisplay && |
312 | os_display->height == mode->vdisplay && |
264 | os_display->height == mode->vdisplay && |
313 | drm_mode_vrefresh(mode) == 60) |
265 | drm_mode_vrefresh(mode) == 60) |
314 | { |
266 | { |
315 | usermode->width = os_display->width; |
267 | usermode->width = os_display->width; |
316 | usermode->height = os_display->height; |
268 | usermode->height = os_display->height; |
317 | usermode->freq = 60; |
269 | usermode->freq = 60; |
318 | return 1; |
270 | return 1; |
319 | } |
271 | } |
320 | } |
272 | } |
321 | return 0; |
273 | return 0; |
322 | } |
274 | } |
323 | 275 | ||
324 | int init_display_kms(struct drm_device *dev, videomode_t *usermode) |
276 | int init_display_kms(struct drm_device *dev, videomode_t *usermode) |
325 | { |
277 | { |
326 | struct drm_connector_helper_funcs *connector_funcs; |
278 | struct drm_connector_helper_funcs *connector_funcs; |
327 | struct drm_connector *connector = NULL; |
279 | struct drm_connector *connector = NULL; |
328 | struct drm_crtc *crtc = NULL; |
280 | struct drm_crtc *crtc = NULL; |
329 | struct drm_framebuffer *fb; |
281 | struct drm_framebuffer *fb; |
330 | 282 | ||
331 | cursor_t *cursor; |
283 | cursor_t *cursor; |
332 | u32_t ifl; |
284 | u32 ifl; |
333 | int ret; |
285 | int ret; |
334 | 286 | ||
335 | mutex_lock(&dev->mode_config.mutex); |
287 | mutex_lock(&dev->mode_config.mutex); |
336 | 288 | ||
337 | ret = choose_config(dev, &connector, &crtc); |
289 | ret = choose_config(dev, &connector, &crtc); |
338 | if(ret) |
290 | if(ret) |
339 | { |
291 | { |
340 | DRM_DEBUG_KMS("No active connectors!\n"); |
292 | DRM_DEBUG_KMS("No active connectors!\n"); |
341 | mutex_unlock(&dev->mode_config.mutex); |
293 | mutex_unlock(&dev->mode_config.mutex); |
342 | return -1; |
294 | return -1; |
343 | }; |
295 | }; |
344 | 296 | ||
345 | mutex_lock(&dev->object_name_lock); |
297 | mutex_lock(&dev->object_name_lock); |
346 | idr_preload(GFP_KERNEL); |
298 | idr_preload(GFP_KERNEL); |
347 | 299 | ||
348 | if (!main_fb_obj->base.name) { |
300 | if (!main_fb_obj->base.name) { |
349 | ret = idr_alloc(&dev->object_name_idr, &main_fb_obj->base, 1, 0, GFP_NOWAIT); |
301 | ret = idr_alloc(&dev->object_name_idr, &main_fb_obj->base, 1, 0, GFP_NOWAIT); |
350 | 302 | ||
351 | main_fb_obj->base.name = ret; |
303 | main_fb_obj->base.name = ret; |
352 | 304 | ||
353 | /* Allocate a reference for the name table. */ |
305 | /* Allocate a reference for the name table. */ |
354 | drm_gem_object_reference(&main_fb_obj->base); |
306 | drm_gem_object_reference(&main_fb_obj->base); |
355 | 307 | ||
356 | DRM_DEBUG_KMS("%s allocate fb name %d\n", __FUNCTION__, main_fb_obj->base.name ); |
308 | DRM_DEBUG_KMS("%s allocate fb name %d\n", __FUNCTION__, main_fb_obj->base.name ); |
357 | } |
309 | } |
358 | 310 | ||
359 | idr_preload_end(); |
311 | idr_preload_end(); |
360 | mutex_unlock(&dev->object_name_lock); |
312 | mutex_unlock(&dev->object_name_lock); |
361 | drm_gem_object_unreference(&main_fb_obj->base); |
313 | drm_gem_object_unreference(&main_fb_obj->base); |
362 | 314 | ||
363 | os_display = GetDisplay(); |
315 | os_display = GetDisplay(); |
364 | os_display->ddev = dev; |
316 | os_display->ddev = dev; |
365 | os_display->connector = connector; |
317 | os_display->connector = connector; |
366 | os_display->crtc = crtc; |
318 | os_display->crtc = crtc; |
367 | 319 | ||
368 | os_display->supported_modes = count_connector_modes(connector); |
320 | os_display->supported_modes = count_connector_modes(connector); |
369 | 321 | ||
370 | ifl = safe_cli(); |
322 | ifl = safe_cli(); |
371 | { |
323 | { |
372 | list_for_each_entry(cursor, &os_display->cursors, list) |
324 | list_for_each_entry(cursor, &os_display->cursors, list) |
373 | { |
325 | { |
374 | init_cursor(cursor); |
326 | init_cursor(cursor); |
375 | }; |
327 | }; |
376 | 328 | ||
377 | os_display->restore_cursor(0,0); |
329 | os_display->restore_cursor(0,0); |
378 | os_display->init_cursor = init_cursor; |
330 | os_display->init_cursor = init_cursor; |
379 | os_display->select_cursor = select_cursor_kms; |
331 | os_display->select_cursor = select_cursor_kms; |
380 | os_display->show_cursor = NULL; |
332 | os_display->show_cursor = NULL; |
381 | os_display->move_cursor = move_cursor_kms; |
333 | os_display->move_cursor = move_cursor_kms; |
382 | os_display->restore_cursor = restore_cursor; |
334 | os_display->restore_cursor = restore_cursor; |
383 | os_display->disable_mouse = disable_mouse; |
335 | os_display->disable_mouse = disable_mouse; |
384 | 336 | ||
385 | crtc->cursor_x = os_display->width/2; |
337 | crtc->cursor_x = os_display->width/2; |
386 | crtc->cursor_y = os_display->height/2; |
338 | crtc->cursor_y = os_display->height/2; |
387 | 339 | ||
388 | select_cursor_kms(os_display->cursor); |
340 | select_cursor_kms(os_display->cursor); |
389 | }; |
341 | }; |
390 | safe_sti(ifl); |
342 | safe_sti(ifl); |
391 | 343 | ||
392 | if( (usermode->width == 0) || |
344 | if( (usermode->width == 0) || |
393 | (usermode->height == 0)) |
345 | (usermode->height == 0)) |
394 | { |
346 | { |
395 | if( !get_boot_mode(connector, usermode)) |
347 | if( !get_boot_mode(connector, usermode)) |
396 | { |
348 | { |
397 | struct drm_display_mode *mode; |
349 | struct drm_display_mode *mode; |
398 | 350 | ||
399 | mode = list_entry(connector->modes.next, typeof(*mode), head); |
351 | mode = list_entry(connector->modes.next, typeof(*mode), head); |
400 | usermode->width = mode->hdisplay; |
352 | usermode->width = mode->hdisplay; |
401 | usermode->height = mode->vdisplay; |
353 | usermode->height = mode->vdisplay; |
402 | usermode->freq = drm_mode_vrefresh(mode); |
354 | usermode->freq = drm_mode_vrefresh(mode); |
403 | }; |
355 | }; |
404 | }; |
356 | }; |
405 | 357 | ||
406 | mutex_unlock(&dev->mode_config.mutex); |
358 | mutex_unlock(&dev->mode_config.mutex); |
407 | 359 | ||
408 | set_mode(dev, os_display->connector, os_display->crtc, usermode, false); |
360 | set_mode(dev, os_display->connector, os_display->crtc, usermode, false); |
409 | 361 | ||
410 | #ifdef __HWA__ |
362 | #ifdef __HWA__ |
411 | err = init_bitmaps(); |
363 | err = init_bitmaps(); |
412 | #endif |
364 | #endif |
413 | 365 | ||
414 | LEAVE(); |
366 | LEAVE(); |
415 | 367 | ||
416 | return 0; |
368 | return 0; |
417 | }; |
369 | }; |
418 | 370 | ||
419 | 371 | ||
420 | int get_videomodes(videomode_t *mode, int *count) |
372 | int get_videomodes(videomode_t *mode, int *count) |
421 | { |
373 | { |
422 | int err = -1; |
374 | int err = -1; |
423 | 375 | ||
424 | // dbgprintf("mode %x count %d\n", mode, *count); |
376 | // dbgprintf("mode %x count %d\n", mode, *count); |
425 | 377 | ||
426 | if( *count == 0 ) |
378 | if( *count == 0 ) |
427 | { |
379 | { |
428 | *count = os_display->supported_modes; |
380 | *count = os_display->supported_modes; |
429 | err = 0; |
381 | err = 0; |
430 | } |
382 | } |
431 | else if( mode != NULL ) |
383 | else if( mode != NULL ) |
432 | { |
384 | { |
433 | struct drm_display_mode *drmmode; |
385 | struct drm_display_mode *drmmode; |
434 | int i = 0; |
386 | int i = 0; |
435 | 387 | ||
436 | if( *count > os_display->supported_modes) |
388 | if( *count > os_display->supported_modes) |
437 | *count = os_display->supported_modes; |
389 | *count = os_display->supported_modes; |
438 | 390 | ||
439 | list_for_each_entry(drmmode, &os_display->connector->modes, head) |
391 | list_for_each_entry(drmmode, &os_display->connector->modes, head) |
440 | { |
392 | { |
441 | if( i < *count) |
393 | if( i < *count) |
442 | { |
394 | { |
443 | mode->width = drmmode->hdisplay; |
395 | mode->width = drmmode->hdisplay; |
444 | mode->height = drmmode->vdisplay; |
396 | mode->height = drmmode->vdisplay; |
445 | mode->bpp = 32; |
397 | mode->bpp = 32; |
446 | mode->freq = drm_mode_vrefresh(drmmode); |
398 | mode->freq = drm_mode_vrefresh(drmmode); |
447 | i++; |
399 | i++; |
448 | mode++; |
400 | mode++; |
449 | } |
401 | } |
450 | else break; |
402 | else break; |
451 | }; |
403 | }; |
452 | *count = i; |
404 | *count = i; |
453 | err = 0; |
405 | err = 0; |
454 | }; |
406 | }; |
455 | return err; |
407 | return err; |
456 | }; |
408 | }; |
457 | 409 | ||
458 | int set_user_mode(videomode_t *mode) |
410 | int set_user_mode(videomode_t *mode) |
459 | { |
411 | { |
460 | 412 | ||
461 | // dbgprintf("width %d height %d vrefresh %d\n", |
413 | // dbgprintf("width %d height %d vrefresh %d\n", |
462 | // mode->width, mode->height, mode->freq); |
414 | // mode->width, mode->height, mode->freq); |
463 | 415 | ||
464 | if( (mode->width != 0) && |
416 | if( (mode->width != 0) && |
465 | (mode->height != 0) && |
417 | (mode->height != 0) && |
466 | (mode->freq != 0 ) && |
418 | (mode->freq != 0 ) && |
467 | ( (mode->width != os_display->width) || |
419 | ( (mode->width != os_display->width) || |
468 | (mode->height != os_display->height) || |
420 | (mode->height != os_display->height) || |
469 | (mode->freq != os_display->vrefresh) ) ) |
421 | (mode->freq != os_display->vrefresh) ) ) |
470 | { |
422 | { |
471 | return set_mode(os_display->ddev, os_display->connector, os_display->crtc, mode, true); |
423 | return set_mode(os_display->ddev, os_display->connector, os_display->crtc, mode, true); |
472 | }; |
424 | }; |
473 | 425 | ||
474 | return -1; |
426 | return -1; |
475 | }; |
427 | }; |
476 | 428 | ||
477 | void i915_dpms(struct drm_device *dev, int mode) |
429 | void i915_dpms(struct drm_device *dev, int mode) |
478 | { |
430 | { |
479 | const struct drm_connector_funcs *f = os_display->connector->funcs; |
431 | const struct drm_connector_funcs *f = os_display->connector->funcs; |
480 | 432 | ||
481 | f->dpms(os_display->connector, mode); |
433 | f->dpms(os_display->connector, mode); |
482 | }; |
434 | }; |
483 | 435 | ||
484 | void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor) |
436 | void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor) |
485 | { |
437 | { |
486 | list_del(&cursor->list); |
438 | struct drm_i915_gem_object *obj = cursor->cobj; |
- | 439 | list_del(&cursor->list); |
|
487 | 440 | ||
488 | i915_gem_object_ggtt_unpin(cursor->cobj); |
441 | i915_gem_object_ggtt_unpin(cursor->cobj); |
489 | 442 | ||
490 | mutex_lock(&main_device->struct_mutex); |
443 | mutex_lock(&main_device->struct_mutex); |
491 | drm_gem_object_unreference(&cursor->cobj->base); |
444 | drm_gem_object_unreference(&obj->base); |
492 | mutex_unlock(&main_device->struct_mutex); |
445 | mutex_unlock(&main_device->struct_mutex); |
493 | 446 | ||
494 | __DestroyObject(cursor); |
447 | __DestroyObject(cursor); |
495 | }; |
448 | }; |
496 | 449 | ||
497 | int init_cursor(cursor_t *cursor) |
450 | int init_cursor(cursor_t *cursor) |
498 | { |
451 | { |
499 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
452 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
500 | struct drm_i915_gem_object *obj; |
453 | struct drm_i915_gem_object *obj; |
501 | uint32_t *bits; |
454 | uint32_t *bits; |
502 | uint32_t *src; |
455 | uint32_t *src; |
503 | void *mapped; |
456 | void *mapped; |
504 | 457 | ||
505 | int i,j; |
458 | int i,j; |
506 | int ret; |
459 | int ret; |
507 | 460 | ||
508 | if (dev_priv->info.cursor_needs_physical) |
461 | if (dev_priv->info.cursor_needs_physical) |
509 | { |
462 | { |
510 | bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
463 | bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
511 | if (unlikely(bits == NULL)) |
464 | if (unlikely(bits == NULL)) |
512 | return ENOMEM; |
465 | return ENOMEM; |
513 | cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits); |
466 | cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits); |
514 | } |
467 | } |
515 | else |
468 | else |
516 | { |
469 | { |
517 | obj = i915_gem_alloc_object(os_display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
470 | obj = i915_gem_alloc_object(os_display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
518 | if (unlikely(obj == NULL)) |
471 | if (unlikely(obj == NULL)) |
519 | return -ENOMEM; |
472 | return -ENOMEM; |
520 | 473 | ||
521 | ret = i915_gem_obj_ggtt_pin(obj, 0,PIN_MAPPABLE | PIN_NONBLOCK); |
474 | ret = i915_gem_obj_ggtt_pin(obj, 0,PIN_MAPPABLE | PIN_NONBLOCK); |
522 | if (ret) { |
475 | if (ret) { |
523 | drm_gem_object_unreference(&obj->base); |
476 | drm_gem_object_unreference(&obj->base); |
524 | return ret; |
477 | return ret; |
525 | } |
478 | } |
526 | 479 | ||
527 | ret = i915_gem_object_set_to_gtt_domain(obj, true); |
480 | ret = i915_gem_object_set_to_gtt_domain(obj, true); |
528 | if (ret) |
481 | if (ret) |
529 | { |
482 | { |
530 | i915_gem_object_ggtt_unpin(obj); |
483 | i915_gem_object_ggtt_unpin(obj); |
531 | drm_gem_object_unreference(&obj->base); |
484 | drm_gem_object_unreference(&obj->base); |
532 | return ret; |
485 | return ret; |
533 | } |
486 | } |
534 | /* You don't need to worry about fragmentation issues. |
487 | /* You don't need to worry about fragmentation issues. |
535 | * GTT space is continuous. I guarantee it. */ |
488 | * GTT space is continuous. I guarantee it. */ |
536 | 489 | ||
537 | mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj), |
490 | mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj), |
538 | KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW); |
491 | KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW); |
539 | 492 | ||
540 | if (unlikely(bits == NULL)) |
493 | if (unlikely(bits == NULL)) |
541 | { |
494 | { |
542 | i915_gem_object_ggtt_unpin(obj); |
495 | i915_gem_object_ggtt_unpin(obj); |
543 | drm_gem_object_unreference(&obj->base); |
496 | drm_gem_object_unreference(&obj->base); |
544 | return -ENOMEM; |
497 | return -ENOMEM; |
545 | }; |
498 | }; |
546 | cursor->cobj = obj; |
499 | cursor->cobj = obj; |
547 | }; |
500 | }; |
548 | 501 | ||
549 | src = cursor->data; |
502 | src = cursor->data; |
550 | 503 | ||
551 | for(i = 0; i < 32; i++) |
504 | for(i = 0; i < 32; i++) |
552 | { |
505 | { |
553 | for(j = 0; j < 32; j++) |
506 | for(j = 0; j < 32; j++) |
554 | *bits++ = *src++; |
507 | *bits++ = *src++; |
555 | for(j = 32; j < KMS_CURSOR_WIDTH; j++) |
508 | for(j = 32; j < KMS_CURSOR_WIDTH; j++) |
556 | *bits++ = 0; |
509 | *bits++ = 0; |
557 | } |
510 | } |
558 | for(i = 0; i < KMS_CURSOR_WIDTH*(KMS_CURSOR_HEIGHT-32); i++) |
511 | for(i = 0; i < KMS_CURSOR_WIDTH*(KMS_CURSOR_HEIGHT-32); i++) |
559 | *bits++ = 0; |
512 | *bits++ = 0; |
560 | 513 | ||
561 | FreeKernelSpace(mapped); |
514 | FreeKernelSpace(mapped); |
562 | 515 | ||
563 | // release old cursor |
516 | // release old cursor |
564 | 517 | ||
565 | KernelFree(cursor->data); |
518 | KernelFree(cursor->data); |
566 | 519 | ||
567 | cursor->data = bits; |
520 | cursor->data = bits; |
568 | 521 | ||
569 | cursor->header.destroy = destroy_cursor; |
522 | cursor->header.destroy = destroy_cursor; |
570 | 523 | ||
571 | return 0; |
524 | return 0; |
572 | } |
525 | } |
573 | 526 | ||
574 | 527 | ||
575 | void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y) |
528 | void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y) |
576 | { |
529 | { |
577 | struct drm_crtc *crtc = os_display->crtc; |
530 | struct drm_crtc *crtc = os_display->crtc; |
578 | x-= cursor->hot_x; |
531 | x-= cursor->hot_x; |
579 | y-= cursor->hot_y; |
532 | y-= cursor->hot_y; |
580 | 533 | ||
581 | crtc->cursor_x = x; |
534 | crtc->cursor_x = x; |
582 | crtc->cursor_y = y; |
535 | crtc->cursor_y = y; |
583 | 536 | ||
584 | intel_crtc_update_cursor(crtc, 1); |
537 | intel_crtc_update_cursor(crtc, 1); |
585 | 538 | ||
586 | // if (crtc->funcs->cursor_move) |
539 | // if (crtc->funcs->cursor_move) |
587 | // crtc->funcs->cursor_move(crtc, x, y); |
540 | // crtc->funcs->cursor_move(crtc, x, y); |
588 | 541 | ||
589 | }; |
542 | }; |
590 | 543 | ||
591 | 544 | ||
592 | cursor_t* __stdcall select_cursor_kms(cursor_t *cursor) |
545 | cursor_t* __stdcall select_cursor_kms(cursor_t *cursor) |
593 | { |
546 | { |
594 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
547 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
595 | struct drm_crtc *crtc = os_display->crtc; |
548 | struct drm_crtc *crtc = os_display->crtc; |
596 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
549 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
597 | 550 | ||
598 | cursor_t *old; |
551 | cursor_t *old; |
599 | 552 | ||
600 | old = os_display->cursor; |
553 | old = os_display->cursor; |
601 | os_display->cursor = cursor; |
554 | os_display->cursor = cursor; |
602 | 555 | ||
603 | intel_crtc->cursor_bo = cursor->cobj; |
556 | intel_crtc->cursor_bo = cursor->cobj; |
604 | 557 | ||
605 | if (!dev_priv->info.cursor_needs_physical) |
558 | if (!dev_priv->info.cursor_needs_physical) |
606 | intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj); |
559 | intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj); |
607 | else |
560 | else |
608 | intel_crtc->cursor_addr = (addr_t)cursor->cobj; |
561 | intel_crtc->cursor_addr = (addr_t)cursor->cobj; |
609 | 562 | ||
610 | intel_crtc->cursor_width = 64; |
563 | intel_crtc->cursor_width = 64; |
611 | intel_crtc->cursor_height = 64; |
564 | intel_crtc->cursor_height = 64; |
612 | 565 | ||
613 | move_cursor_kms(cursor, crtc->cursor_x, crtc->cursor_y); |
566 | move_cursor_kms(cursor, crtc->cursor_x, crtc->cursor_y); |
614 | return old; |
567 | return old; |
615 | }; |
568 | }; |
616 | 569 | ||
617 | int i915_fbinfo(struct drm_i915_fb_info *fb) |
570 | int i915_fbinfo(struct drm_i915_fb_info *fb) |
618 | { |
571 | { |
619 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
572 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
620 | struct intel_crtc *crtc = to_intel_crtc(os_display->crtc); |
573 | struct intel_crtc *crtc = to_intel_crtc(os_display->crtc); |
621 | 574 | ||
622 | struct drm_i915_gem_object *obj = get_fb_obj(); |
575 | struct drm_i915_gem_object *obj = get_fb_obj(); |
623 | 576 | ||
624 | fb->name = obj->base.name; |
577 | fb->name = obj->base.name; |
625 | fb->width = os_display->width; |
578 | fb->width = os_display->width; |
626 | fb->height = os_display->height; |
579 | fb->height = os_display->height; |
627 | fb->pitch = obj->stride; |
580 | fb->pitch = obj->stride; |
628 | fb->tiling = obj->tiling_mode; |
581 | fb->tiling = obj->tiling_mode; |
629 | fb->crtc = crtc->base.base.id; |
582 | fb->crtc = crtc->base.base.id; |
630 | fb->pipe = crtc->pipe; |
583 | fb->pipe = crtc->pipe; |
631 | 584 | ||
632 | return 0; |
585 | return 0; |
633 | } |
586 | } |
634 | 587 | ||
635 | 588 | ||
636 | typedef struct |
589 | typedef struct |
637 | { |
590 | { |
638 | int left; |
591 | int left; |
639 | int top; |
592 | int top; |
640 | int right; |
593 | int right; |
641 | int bottom; |
594 | int bottom; |
642 | }rect_t; |
595 | }rect_t; |
643 | 596 | ||
644 | 597 | ||
645 | #define CURRENT_TASK (0x80003000) |
598 | #define CURRENT_TASK (0x80003000) |
646 | 599 | ||
647 | static u32_t get_display_map() |
- | |
648 | { |
- | |
649 | u32_t addr; |
- | |
650 | - | ||
651 | addr = (u32_t)os_display; |
- | |
652 | addr+= sizeof(display_t); /* shoot me */ |
- | |
653 | return *(u32_t*)addr; |
- | |
654 | } |
- | |
655 | - | ||
656 | void FASTCALL GetWindowRect(rect_t *rc)__asm__("GetWindowRect"); |
600 | void FASTCALL GetWindowRect(rect_t *rc)__asm__("GetWindowRect"); |
657 | 601 | ||
658 | int i915_mask_update(struct drm_device *dev, void *data, |
602 | int i915_mask_update(struct drm_device *dev, void *data, |
659 | struct drm_file *file) |
603 | struct drm_file *file) |
660 | { |
604 | { |
661 | struct drm_i915_mask *mask = data; |
605 | struct drm_i915_mask *mask = data; |
662 | struct drm_gem_object *obj; |
606 | struct drm_gem_object *obj; |
663 | static unsigned int mask_seqno[256]; |
607 | static unsigned int mask_seqno[256]; |
664 | rect_t winrc; |
608 | rect_t winrc; |
665 | u32 slot; |
609 | u32 slot; |
666 | int ret=0; |
610 | int ret=0; |
667 | 611 | ||
668 | obj = drm_gem_object_lookup(dev, file, mask->handle); |
612 | obj = drm_gem_object_lookup(dev, file, mask->handle); |
669 | if (obj == NULL) |
613 | if (obj == NULL) |
670 | return -ENOENT; |
614 | return -ENOENT; |
671 | 615 | ||
672 | if (!obj->filp) { |
616 | if (!obj->filp) { |
673 | drm_gem_object_unreference_unlocked(obj); |
617 | drm_gem_object_unreference_unlocked(obj); |
674 | return -EINVAL; |
618 | return -EINVAL; |
675 | } |
619 | } |
676 | 620 | ||
677 | GetWindowRect(&winrc); |
621 | GetWindowRect(&winrc); |
678 | { |
622 | { |
679 | // static warn_count; |
623 | // static warn_count; |
680 | 624 | ||
681 | mask->width = winrc.right - winrc.left + 1; |
625 | mask->width = winrc.right - winrc.left + 1; |
682 | mask->height = winrc.bottom - winrc.top + 1; |
626 | mask->height = winrc.bottom - winrc.top + 1; |
683 | mask->bo_pitch = (mask->width+15) & ~15; |
627 | mask->bo_pitch = (mask->width+15) & ~15; |
684 | 628 | ||
685 | #if 0 |
629 | #if 0 |
686 | if(warn_count < 1) |
630 | if(warn_count < 1) |
687 | { |
631 | { |
688 | printf("left %d top %d right %d bottom %d\n", |
632 | printf("left %d top %d right %d bottom %d\n", |
689 | winrc.left, winrc.top, winrc.right, winrc.bottom); |
633 | winrc.left, winrc.top, winrc.right, winrc.bottom); |
690 | printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_map); |
634 | printf("mask pitch %d data %p\n", mask->bo_pitch, mask->bo_map); |
691 | warn_count++; |
635 | warn_count++; |
692 | }; |
636 | }; |
693 | #endif |
637 | #endif |
694 | 638 | ||
695 | }; |
639 | }; |
696 | 640 | ||
697 | 641 | ||
698 | slot = *((u8*)CURRENT_TASK); |
642 | slot = *((u8*)CURRENT_TASK); |
699 | 643 | ||
700 | if( mask_seqno[slot] != os_display->mask_seqno) |
644 | if( mask_seqno[slot] != os_display->mask_seqno) |
701 | { |
645 | { |
702 | u8* src_offset; |
646 | u8* src_offset; |
703 | u8* dst_offset; |
647 | u8* dst_offset; |
704 | u32 ifl; |
648 | u32 ifl; |
705 | 649 | ||
706 | ret = i915_mutex_lock_interruptible(dev); |
650 | ret = i915_mutex_lock_interruptible(dev); |
707 | if (ret) |
651 | if (ret) |
708 | goto err1; |
652 | goto err1; |
709 | 653 | ||
710 | ret = i915_gem_object_set_to_cpu_domain(to_intel_bo(obj), true); |
654 | ret = i915_gem_object_set_to_cpu_domain(to_intel_bo(obj), true); |
711 | if(ret != 0 ) |
655 | if(ret != 0 ) |
712 | { |
656 | { |
713 | dbgprintf("%s: i915_gem_object_set_to_cpu_domain failed\n", __FUNCTION__); |
657 | dbgprintf("%s: i915_gem_object_set_to_cpu_domain failed\n", __FUNCTION__); |
714 | goto err2; |
658 | goto err2; |
715 | }; |
659 | }; |
716 | 660 | ||
717 | // printf("width %d height %d\n", winrc.right, winrc.bottom); |
661 | // printf("width %d height %d\n", winrc.right, winrc.bottom); |
718 | 662 | ||
719 | // slot = 0x01; |
663 | // slot = 0x01; |
720 | 664 | ||
- | 665 | src_offset = os_display->win_map; |
|
- | 666 | src_offset+= winrc.top*os_display->width + winrc.left; |
|
721 | - | ||
722 | src_offset = (u8*)( winrc.top*os_display->width + winrc.left); |
- | |
723 | src_offset+= get_display_map(); |
667 | |
724 | dst_offset = (u8*)mask->bo_map; |
668 | dst_offset = (u8*)mask->bo_map; |
725 | 669 | ||
726 | u32_t tmp_h = mask->height; |
670 | u32 tmp_h = mask->height; |
727 | 671 | ||
728 | ifl = safe_cli(); |
672 | ifl = safe_cli(); |
729 | { |
673 | { |
730 | mask_seqno[slot] = os_display->mask_seqno; |
674 | mask_seqno[slot] = os_display->mask_seqno; |
731 | 675 | ||
732 | slot|= (slot<<8)|(slot<<16)|(slot<<24); |
676 | slot|= (slot<<8)|(slot<<16)|(slot<<24); |
733 | 677 | ||
734 | __asm__ __volatile__ ( |
678 | __asm__ __volatile__ ( |
735 | "movd %[slot], %%xmm6 \n" |
679 | "movd %[slot], %%xmm6 \n" |
736 | "punpckldq %%xmm6, %%xmm6 \n" |
680 | "punpckldq %%xmm6, %%xmm6 \n" |
737 | "punpcklqdq %%xmm6, %%xmm6 \n" |
681 | "punpcklqdq %%xmm6, %%xmm6 \n" |
738 | :: [slot] "m" (slot) |
682 | :: [slot] "m" (slot) |
739 | :"xmm6"); |
683 | :"xmm6"); |
740 | 684 | ||
741 | while( tmp_h--) |
685 | while( tmp_h--) |
742 | { |
686 | { |
743 | int tmp_w = mask->width; |
687 | int tmp_w = mask->width; |
744 | 688 | ||
745 | u8* tmp_src = src_offset; |
689 | u8* tmp_src = src_offset; |
746 | u8* tmp_dst = dst_offset; |
690 | u8* tmp_dst = dst_offset; |
747 | 691 | ||
748 | src_offset+= os_display->width; |
692 | src_offset+= os_display->width; |
749 | dst_offset+= mask->bo_pitch; |
693 | dst_offset+= mask->bo_pitch; |
750 | 694 | ||
751 | while(tmp_w >= 64) |
695 | while(tmp_w >= 64) |
752 | { |
696 | { |
753 | __asm__ __volatile__ ( |
697 | __asm__ __volatile__ ( |
754 | "movdqu (%0), %%xmm0 \n" |
698 | "movdqu (%0), %%xmm0 \n" |
755 | "movdqu 16(%0), %%xmm1 \n" |
699 | "movdqu 16(%0), %%xmm1 \n" |
756 | "movdqu 32(%0), %%xmm2 \n" |
700 | "movdqu 32(%0), %%xmm2 \n" |
757 | "movdqu 48(%0), %%xmm3 \n" |
701 | "movdqu 48(%0), %%xmm3 \n" |
758 | "pcmpeqb %%xmm6, %%xmm0 \n" |
702 | "pcmpeqb %%xmm6, %%xmm0 \n" |
759 | "pcmpeqb %%xmm6, %%xmm1 \n" |
703 | "pcmpeqb %%xmm6, %%xmm1 \n" |
760 | "pcmpeqb %%xmm6, %%xmm2 \n" |
704 | "pcmpeqb %%xmm6, %%xmm2 \n" |
761 | "pcmpeqb %%xmm6, %%xmm3 \n" |
705 | "pcmpeqb %%xmm6, %%xmm3 \n" |
762 | "movdqa %%xmm0, (%%edi) \n" |
706 | "movdqa %%xmm0, (%%edi) \n" |
763 | "movdqa %%xmm1, 16(%%edi) \n" |
707 | "movdqa %%xmm1, 16(%%edi) \n" |
764 | "movdqa %%xmm2, 32(%%edi) \n" |
708 | "movdqa %%xmm2, 32(%%edi) \n" |
765 | "movdqa %%xmm3, 48(%%edi) \n" |
709 | "movdqa %%xmm3, 48(%%edi) \n" |
766 | 710 | ||
767 | :: "r" (tmp_src), "D" (tmp_dst) |
711 | :: "r" (tmp_src), "D" (tmp_dst) |
768 | :"xmm0","xmm1","xmm2","xmm3"); |
712 | :"xmm0","xmm1","xmm2","xmm3"); |
769 | tmp_w -= 64; |
713 | tmp_w -= 64; |
770 | tmp_src += 64; |
714 | tmp_src += 64; |
771 | tmp_dst += 64; |
715 | tmp_dst += 64; |
772 | } |
716 | } |
773 | 717 | ||
774 | if( tmp_w >= 32 ) |
718 | if( tmp_w >= 32 ) |
775 | { |
719 | { |
776 | __asm__ __volatile__ ( |
720 | __asm__ __volatile__ ( |
777 | "movdqu (%0), %%xmm0 \n" |
721 | "movdqu (%0), %%xmm0 \n" |
778 | "movdqu 16(%0), %%xmm1 \n" |
722 | "movdqu 16(%0), %%xmm1 \n" |
779 | "pcmpeqb %%xmm6, %%xmm0 \n" |
723 | "pcmpeqb %%xmm6, %%xmm0 \n" |
780 | "pcmpeqb %%xmm6, %%xmm1 \n" |
724 | "pcmpeqb %%xmm6, %%xmm1 \n" |
781 | "movdqa %%xmm0, (%%edi) \n" |
725 | "movdqa %%xmm0, (%%edi) \n" |
782 | "movdqa %%xmm1, 16(%%edi) \n" |
726 | "movdqa %%xmm1, 16(%%edi) \n" |
783 | 727 | ||
784 | :: "r" (tmp_src), "D" (tmp_dst) |
728 | :: "r" (tmp_src), "D" (tmp_dst) |
785 | :"xmm0","xmm1"); |
729 | :"xmm0","xmm1"); |
786 | tmp_w -= 32; |
730 | tmp_w -= 32; |
787 | tmp_src += 32; |
731 | tmp_src += 32; |
788 | tmp_dst += 32; |
732 | tmp_dst += 32; |
789 | } |
733 | } |
790 | 734 | ||
791 | if( tmp_w >= 16 ) |
735 | if( tmp_w >= 16 ) |
792 | { |
736 | { |
793 | __asm__ __volatile__ ( |
737 | __asm__ __volatile__ ( |
794 | "movdqu (%0), %%xmm0 \n" |
738 | "movdqu (%0), %%xmm0 \n" |
795 | "pcmpeqb %%xmm6, %%xmm0 \n" |
739 | "pcmpeqb %%xmm6, %%xmm0 \n" |
796 | "movdqa %%xmm0, (%%edi) \n" |
740 | "movdqa %%xmm0, (%%edi) \n" |
797 | :: "r" (tmp_src), "D" (tmp_dst) |
741 | :: "r" (tmp_src), "D" (tmp_dst) |
798 | :"xmm0"); |
742 | :"xmm0"); |
799 | tmp_w -= 16; |
743 | tmp_w -= 16; |
800 | tmp_src += 16; |
744 | tmp_src += 16; |
801 | tmp_dst += 16; |
745 | tmp_dst += 16; |
802 | } |
746 | } |
803 | 747 | ||
804 | if( tmp_w >= 8 ) |
748 | if( tmp_w >= 8 ) |
805 | { |
749 | { |
806 | __asm__ __volatile__ ( |
750 | __asm__ __volatile__ ( |
807 | "movq (%0), %%xmm0 \n" |
751 | "movq (%0), %%xmm0 \n" |
808 | "pcmpeqb %%xmm6, %%xmm0 \n" |
752 | "pcmpeqb %%xmm6, %%xmm0 \n" |
809 | "movq %%xmm0, (%%edi) \n" |
753 | "movq %%xmm0, (%%edi) \n" |
810 | :: "r" (tmp_src), "D" (tmp_dst) |
754 | :: "r" (tmp_src), "D" (tmp_dst) |
811 | :"xmm0"); |
755 | :"xmm0"); |
812 | tmp_w -= 8; |
756 | tmp_w -= 8; |
813 | tmp_src += 8; |
757 | tmp_src += 8; |
814 | tmp_dst += 8; |
758 | tmp_dst += 8; |
815 | } |
759 | } |
816 | if( tmp_w >= 4 ) |
760 | if( tmp_w >= 4 ) |
817 | { |
761 | { |
818 | __asm__ __volatile__ ( |
762 | __asm__ __volatile__ ( |
819 | "movd (%0), %%xmm0 \n" |
763 | "movd (%0), %%xmm0 \n" |
820 | "pcmpeqb %%xmm6, %%xmm0 \n" |
764 | "pcmpeqb %%xmm6, %%xmm0 \n" |
821 | "movd %%xmm0, (%%edi) \n" |
765 | "movd %%xmm0, (%%edi) \n" |
822 | :: "r" (tmp_src), "D" (tmp_dst) |
766 | :: "r" (tmp_src), "D" (tmp_dst) |
823 | :"xmm0"); |
767 | :"xmm0"); |
824 | tmp_w -= 4; |
768 | tmp_w -= 4; |
825 | tmp_src += 4; |
769 | tmp_src += 4; |
826 | tmp_dst += 4; |
770 | tmp_dst += 4; |
827 | } |
771 | } |
828 | while(tmp_w--) |
772 | while(tmp_w--) |
829 | *tmp_dst++ = (*tmp_src++ == (u8)slot) ? 0xFF:0x00; |
773 | *tmp_dst++ = (*tmp_src++ == (u8)slot) ? 0xFF:0x00; |
830 | }; |
774 | }; |
831 | }; |
775 | }; |
832 | safe_sti(ifl); |
776 | safe_sti(ifl); |
833 | 777 | ||
834 | ret = i915_gem_object_set_to_gtt_domain(to_intel_bo(obj), false); |
778 | ret = i915_gem_object_set_to_gtt_domain(to_intel_bo(obj), false); |
835 | } |
779 | } |
836 | 780 | ||
837 | err2: |
781 | err2: |
838 | mutex_unlock(&dev->struct_mutex); |
782 | mutex_unlock(&dev->struct_mutex); |
839 | err1: |
783 | err1: |
840 | drm_gem_object_unreference(obj); |
784 | drm_gem_object_unreference(obj); |
841 | 785 | ||
842 | return ret; |
786 | return ret; |
843 | } |
787 | } |
844 | 788 | ||
845 | int i915_mask_update_ex(struct drm_device *dev, void *data, |
789 | int i915_mask_update_ex(struct drm_device *dev, void *data, |
846 | struct drm_file *file) |
790 | struct drm_file *file) |
847 | { |
791 | { |
848 | struct drm_i915_mask_update *mask = data; |
792 | struct drm_i915_mask_update *mask = data; |
849 | struct drm_gem_object *obj; |
793 | struct drm_gem_object *obj; |
850 | static unsigned int mask_seqno[256]; |
794 | static unsigned int mask_seqno[256]; |
851 | static warn_count; |
795 | static warn_count; |
852 | 796 | ||
853 | rect_t win; |
797 | rect_t win; |
854 | u32 winw,winh; |
798 | u32 winw,winh; |
855 | u32 ml,mt,mr,mb; |
799 | u32 ml,mt,mr,mb; |
856 | u32 slot; |
800 | u32 slot; |
857 | int ret = 0; |
801 | int ret = 0; |
858 | slot = *((u8*)CURRENT_TASK); |
802 | slot = *((u8*)CURRENT_TASK); |
859 | 803 | ||
860 | if( mask_seqno[slot] == os_display->mask_seqno) |
804 | if( mask_seqno[slot] == os_display->mask_seqno) |
861 | return 0; |
805 | return 0; |
862 | 806 | ||
863 | GetWindowRect(&win); |
807 | GetWindowRect(&win); |
864 | win.right+= 1; |
808 | win.right+= 1; |
865 | win.bottom+= 1; |
809 | win.bottom+= 1; |
866 | 810 | ||
867 | winw = win.right - win.left; |
811 | winw = win.right - win.left; |
868 | winh = win.bottom - win.top; |
812 | winh = win.bottom - win.top; |
869 | 813 | ||
870 | if(mask->dx >= winw || |
814 | if(mask->dx >= winw || |
871 | mask->dy >= winh) |
815 | mask->dy >= winh) |
872 | return 1; |
816 | return 1; |
873 | 817 | ||
874 | ml = win.left + mask->dx; |
818 | ml = win.left + mask->dx; |
875 | mt = win.top + mask->dy; |
819 | mt = win.top + mask->dy; |
876 | mr = ml + mask->width; |
820 | mr = ml + mask->width; |
877 | mb = mt + mask->height; |
821 | mb = mt + mask->height; |
878 | 822 | ||
879 | if( ml >= win.right || mt >= win.bottom || |
823 | if( ml >= win.right || mt >= win.bottom || |
880 | mr < win.left || mb < win.top ) |
824 | mr < win.left || mb < win.top ) |
881 | return 1; |
825 | return 1; |
882 | 826 | ||
883 | if( mr > win.right ) |
827 | if( mr > win.right ) |
884 | mr = win.right; |
828 | mr = win.right; |
885 | 829 | ||
886 | if( mb > win.bottom ) |
830 | if( mb > win.bottom ) |
887 | mb = win.bottom; |
831 | mb = win.bottom; |
888 | 832 | ||
889 | mask->width = mr - ml; |
833 | mask->width = mr - ml; |
890 | mask->height = mb - mt; |
834 | mask->height = mb - mt; |
891 | 835 | ||
892 | if( mask->width == 0 || |
836 | if( mask->width == 0 || |
893 | mask->height== 0 ) |
837 | mask->height== 0 ) |
894 | return 1; |
838 | return 1; |
895 | 839 | ||
896 | obj = drm_gem_object_lookup(dev, file, mask->handle); |
840 | obj = drm_gem_object_lookup(dev, file, mask->handle); |
897 | if (obj == NULL) |
841 | if (obj == NULL) |
898 | return -ENOENT; |
842 | return -ENOENT; |
899 | 843 | ||
900 | if (!obj->filp) { |
844 | if (!obj->filp) { |
901 | drm_gem_object_unreference_unlocked(obj); |
845 | drm_gem_object_unreference_unlocked(obj); |
902 | return -EINVAL; |
846 | return -EINVAL; |
903 | } |
847 | } |
904 | 848 | ||
905 | #if 0 |
849 | #if 0 |
906 | if(warn_count < 1000) |
850 | if(warn_count < 1000) |
907 | { |
851 | { |
908 | printf("left %d top %d right %d bottom %d\n", |
852 | printf("left %d top %d right %d bottom %d\n", |
909 | ml, mt, mr, mb); |
853 | ml, mt, mr, mb); |
910 | warn_count++; |
854 | warn_count++; |
911 | }; |
855 | }; |
912 | #endif |
856 | #endif |
913 | 857 | ||
914 | 858 | ||
915 | #if 1 |
859 | #if 1 |
916 | 860 | ||
917 | { |
861 | { |
918 | u8* src_offset; |
862 | u8* src_offset; |
919 | u8* dst_offset; |
863 | u8* dst_offset; |
920 | u32 ifl; |
864 | u32 ifl; |
921 | 865 | ||
922 | ret = i915_mutex_lock_interruptible(dev); |
866 | ret = i915_mutex_lock_interruptible(dev); |
923 | if (ret) |
867 | if (ret) |
924 | goto err1; |
868 | goto err1; |
925 | 869 | ||
926 | i915_gem_object_set_to_cpu_domain(to_intel_bo(obj), true); |
870 | i915_gem_object_set_to_cpu_domain(to_intel_bo(obj), true); |
927 | 871 | ||
928 | src_offset = (u8*)( mt*os_display->width + ml); |
872 | src_offset = os_display->win_map; |
929 | src_offset+= get_display_map(); |
873 | src_offset+= mt*os_display->width + ml; |
930 | dst_offset = (u8*)mask->bo_map; |
874 | dst_offset = (u8*)mask->bo_map; |
931 | 875 | ||
932 | u32_t tmp_h = mask->height; |
876 | u32 tmp_h = mask->height; |
933 | 877 | ||
934 | ifl = safe_cli(); |
878 | ifl = safe_cli(); |
935 | { |
879 | { |
936 | mask_seqno[slot] = os_display->mask_seqno; |
880 | mask_seqno[slot] = os_display->mask_seqno; |
937 | 881 | ||
938 | slot|= (slot<<8)|(slot<<16)|(slot<<24); |
882 | slot|= (slot<<8)|(slot<<16)|(slot<<24); |
939 | 883 | ||
940 | __asm__ __volatile__ ( |
884 | __asm__ __volatile__ ( |
941 | "movd %[slot], %%xmm6 \n" |
885 | "movd %[slot], %%xmm6 \n" |
942 | "punpckldq %%xmm6, %%xmm6 \n" |
886 | "punpckldq %%xmm6, %%xmm6 \n" |
943 | "punpcklqdq %%xmm6, %%xmm6 \n" |
887 | "punpcklqdq %%xmm6, %%xmm6 \n" |
944 | :: [slot] "m" (slot) |
888 | :: [slot] "m" (slot) |
945 | :"xmm6"); |
889 | :"xmm6"); |
946 | 890 | ||
947 | while( tmp_h--) |
891 | while( tmp_h--) |
948 | { |
892 | { |
949 | int tmp_w = mask->width; |
893 | int tmp_w = mask->width; |
950 | 894 | ||
951 | u8* tmp_src = src_offset; |
895 | u8* tmp_src = src_offset; |
952 | u8* tmp_dst = dst_offset; |
896 | u8* tmp_dst = dst_offset; |
953 | 897 | ||
954 | src_offset+= os_display->width; |
898 | src_offset+= os_display->width; |
955 | dst_offset+= mask->bo_pitch; |
899 | dst_offset+= mask->bo_pitch; |
956 | 900 | ||
957 | while(tmp_w >= 64) |
901 | while(tmp_w >= 64) |
958 | { |
902 | { |
959 | __asm__ __volatile__ ( |
903 | __asm__ __volatile__ ( |
960 | "movdqu (%0), %%xmm0 \n" |
904 | "movdqu (%0), %%xmm0 \n" |
961 | "movdqu 16(%0), %%xmm1 \n" |
905 | "movdqu 16(%0), %%xmm1 \n" |
962 | "movdqu 32(%0), %%xmm2 \n" |
906 | "movdqu 32(%0), %%xmm2 \n" |
963 | "movdqu 48(%0), %%xmm3 \n" |
907 | "movdqu 48(%0), %%xmm3 \n" |
964 | "pcmpeqb %%xmm6, %%xmm0 \n" |
908 | "pcmpeqb %%xmm6, %%xmm0 \n" |
965 | "pcmpeqb %%xmm6, %%xmm1 \n" |
909 | "pcmpeqb %%xmm6, %%xmm1 \n" |
966 | "pcmpeqb %%xmm6, %%xmm2 \n" |
910 | "pcmpeqb %%xmm6, %%xmm2 \n" |
967 | "pcmpeqb %%xmm6, %%xmm3 \n" |
911 | "pcmpeqb %%xmm6, %%xmm3 \n" |
968 | "movdqa %%xmm0, (%%edi) \n" |
912 | "movdqa %%xmm0, (%%edi) \n" |
969 | "movdqa %%xmm1, 16(%%edi) \n" |
913 | "movdqa %%xmm1, 16(%%edi) \n" |
970 | "movdqa %%xmm2, 32(%%edi) \n" |
914 | "movdqa %%xmm2, 32(%%edi) \n" |
971 | "movdqa %%xmm3, 48(%%edi) \n" |
915 | "movdqa %%xmm3, 48(%%edi) \n" |
972 | 916 | ||
973 | :: "r" (tmp_src), "D" (tmp_dst) |
917 | :: "r" (tmp_src), "D" (tmp_dst) |
974 | :"xmm0","xmm1","xmm2","xmm3"); |
918 | :"xmm0","xmm1","xmm2","xmm3"); |
975 | tmp_w -= 64; |
919 | tmp_w -= 64; |
976 | tmp_src += 64; |
920 | tmp_src += 64; |
977 | tmp_dst += 64; |
921 | tmp_dst += 64; |
978 | } |
922 | } |
979 | 923 | ||
980 | if( tmp_w >= 32 ) |
924 | if( tmp_w >= 32 ) |
981 | { |
925 | { |
982 | __asm__ __volatile__ ( |
926 | __asm__ __volatile__ ( |
983 | "movdqu (%0), %%xmm0 \n" |
927 | "movdqu (%0), %%xmm0 \n" |
984 | "movdqu 16(%0), %%xmm1 \n" |
928 | "movdqu 16(%0), %%xmm1 \n" |
985 | "pcmpeqb %%xmm6, %%xmm0 \n" |
929 | "pcmpeqb %%xmm6, %%xmm0 \n" |
986 | "pcmpeqb %%xmm6, %%xmm1 \n" |
930 | "pcmpeqb %%xmm6, %%xmm1 \n" |
987 | "movdqa %%xmm0, (%%edi) \n" |
931 | "movdqa %%xmm0, (%%edi) \n" |
988 | "movdqa %%xmm1, 16(%%edi) \n" |
932 | "movdqa %%xmm1, 16(%%edi) \n" |
989 | 933 | ||
990 | :: "r" (tmp_src), "D" (tmp_dst) |
934 | :: "r" (tmp_src), "D" (tmp_dst) |
991 | :"xmm0","xmm1"); |
935 | :"xmm0","xmm1"); |
992 | tmp_w -= 32; |
936 | tmp_w -= 32; |
993 | tmp_src += 32; |
937 | tmp_src += 32; |
994 | tmp_dst += 32; |
938 | tmp_dst += 32; |
995 | } |
939 | } |
996 | 940 | ||
997 | if( tmp_w >= 16 ) |
941 | if( tmp_w >= 16 ) |
998 | { |
942 | { |
999 | __asm__ __volatile__ ( |
943 | __asm__ __volatile__ ( |
1000 | "movdqu (%0), %%xmm0 \n" |
944 | "movdqu (%0), %%xmm0 \n" |
1001 | "pcmpeqb %%xmm6, %%xmm0 \n" |
945 | "pcmpeqb %%xmm6, %%xmm0 \n" |
1002 | "movdqa %%xmm0, (%%edi) \n" |
946 | "movdqa %%xmm0, (%%edi) \n" |
1003 | :: "r" (tmp_src), "D" (tmp_dst) |
947 | :: "r" (tmp_src), "D" (tmp_dst) |
1004 | :"xmm0"); |
948 | :"xmm0"); |
1005 | tmp_w -= 16; |
949 | tmp_w -= 16; |
1006 | tmp_src += 16; |
950 | tmp_src += 16; |
1007 | tmp_dst += 16; |
951 | tmp_dst += 16; |
1008 | } |
952 | } |
1009 | 953 | ||
1010 | if( tmp_w >= 8 ) |
954 | if( tmp_w >= 8 ) |
1011 | { |
955 | { |
1012 | __asm__ __volatile__ ( |
956 | __asm__ __volatile__ ( |
1013 | "movq (%0), %%xmm0 \n" |
957 | "movq (%0), %%xmm0 \n" |
1014 | "pcmpeqb %%xmm6, %%xmm0 \n" |
958 | "pcmpeqb %%xmm6, %%xmm0 \n" |
1015 | "movq %%xmm0, (%%edi) \n" |
959 | "movq %%xmm0, (%%edi) \n" |
1016 | :: "r" (tmp_src), "D" (tmp_dst) |
960 | :: "r" (tmp_src), "D" (tmp_dst) |
1017 | :"xmm0"); |
961 | :"xmm0"); |
1018 | tmp_w -= 8; |
962 | tmp_w -= 8; |
1019 | tmp_src += 8; |
963 | tmp_src += 8; |
1020 | tmp_dst += 8; |
964 | tmp_dst += 8; |
1021 | } |
965 | } |
1022 | if( tmp_w >= 4 ) |
966 | if( tmp_w >= 4 ) |
1023 | { |
967 | { |
1024 | __asm__ __volatile__ ( |
968 | __asm__ __volatile__ ( |
1025 | "movd (%0), %%xmm0 \n" |
969 | "movd (%0), %%xmm0 \n" |
1026 | "pcmpeqb %%xmm6, %%xmm0 \n" |
970 | "pcmpeqb %%xmm6, %%xmm0 \n" |
1027 | "movd %%xmm0, (%%edi) \n" |
971 | "movd %%xmm0, (%%edi) \n" |
1028 | :: "r" (tmp_src), "D" (tmp_dst) |
972 | :: "r" (tmp_src), "D" (tmp_dst) |
1029 | :"xmm0"); |
973 | :"xmm0"); |
1030 | tmp_w -= 4; |
974 | tmp_w -= 4; |
1031 | tmp_src += 4; |
975 | tmp_src += 4; |
1032 | tmp_dst += 4; |
976 | tmp_dst += 4; |
1033 | } |
977 | } |
1034 | while(tmp_w--) |
978 | while(tmp_w--) |
1035 | *tmp_dst++ = (*tmp_src++ == (u8)slot) ? 0xFF:0x00; |
979 | *tmp_dst++ = (*tmp_src++ == (u8)slot) ? 0xFF:0x00; |
1036 | }; |
980 | }; |
1037 | }; |
981 | }; |
1038 | safe_sti(ifl); |
982 | safe_sti(ifl); |
1039 | 983 | ||
1040 | i915_gem_object_set_to_gtt_domain(to_intel_bo(obj), false); |
984 | i915_gem_object_set_to_gtt_domain(to_intel_bo(obj), false); |
1041 | } |
985 | } |
1042 | #endif |
986 | #endif |
1043 | 987 | ||
1044 | err2: |
988 | err2: |
1045 | mutex_unlock(&dev->struct_mutex); |
989 | mutex_unlock(&dev->struct_mutex); |
1046 | err1: |
990 | err1: |
1047 | drm_gem_object_unreference(obj); |
991 | drm_gem_object_unreference(obj); |
1048 | 992 | ||
1049 | return ret; |
993 | return ret; |
1050 | } |
994 | } |
1051 | 995 | ||
1052 | 996 | ||
1053 | 997 | ||
1054 | 998 | ||
1055 | 999 | ||
1056 | 1000 | ||
1057 | 1001 | ||
1058 | 1002 | ||
1059 | 1003 | ||
1060 | 1004 | ||
1061 | 1005 | ||
1062 | #define NSEC_PER_SEC 1000000000L |
1006 | #define NSEC_PER_SEC 1000000000L |
1063 | 1007 | ||
1064 | void getrawmonotonic(struct timespec *ts) |
1008 | void getrawmonotonic(struct timespec *ts) |
1065 | { |
1009 | { |
1066 | u32 tmp = GetTimerTicks(); |
1010 | u32 tmp = GetTimerTicks(); |
1067 | 1011 | ||
1068 | ts->tv_sec = tmp/100; |
1012 | ts->tv_sec = tmp/100; |
1069 | ts->tv_nsec = (tmp - ts->tv_sec*100)*10000000; |
1013 | ts->tv_nsec = (tmp - ts->tv_sec*100)*10000000; |
1070 | } |
1014 | } |
1071 | 1015 | ||
1072 | void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec) |
1016 | void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec) |
1073 | { |
1017 | { |
1074 | while (nsec >= NSEC_PER_SEC) { |
1018 | while (nsec >= NSEC_PER_SEC) { |
1075 | /* |
1019 | /* |
1076 | * The following asm() prevents the compiler from |
1020 | * The following asm() prevents the compiler from |
1077 | * optimising this loop into a modulo operation. See |
1021 | * optimising this loop into a modulo operation. See |
1078 | * also __iter_div_u64_rem() in include/linux/time.h |
1022 | * also __iter_div_u64_rem() in include/linux/time.h |
1079 | */ |
1023 | */ |
1080 | asm("" : "+rm"(nsec)); |
1024 | asm("" : "+rm"(nsec)); |
1081 | nsec -= NSEC_PER_SEC; |
1025 | nsec -= NSEC_PER_SEC; |
1082 | ++sec; |
1026 | ++sec; |
1083 | } |
1027 | } |
1084 | while (nsec < 0) { |
1028 | while (nsec < 0) { |
1085 | asm("" : "+rm"(nsec)); |
1029 | asm("" : "+rm"(nsec)); |
1086 | nsec += NSEC_PER_SEC; |
1030 | nsec += NSEC_PER_SEC; |
1087 | --sec; |
1031 | --sec; |
1088 | } |
1032 | } |
1089 | ts->tv_sec = sec; |
1033 | ts->tv_sec = sec; |
1090 | ts->tv_nsec = nsec; |
1034 | ts->tv_nsec = nsec; |
1091 | } |
1035 | } |
1092 | 1036 | ||
1093 | void |
1037 | void |
1094 | prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state) |
1038 | prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state) |
1095 | { |
1039 | { |
1096 | unsigned long flags; |
1040 | unsigned long flags; |
1097 | 1041 | ||
1098 | // wait->flags &= ~WQ_FLAG_EXCLUSIVE; |
1042 | // wait->flags &= ~WQ_FLAG_EXCLUSIVE; |
1099 | spin_lock_irqsave(&q->lock, flags); |
1043 | spin_lock_irqsave(&q->lock, flags); |
1100 | if (list_empty(&wait->task_list)) |
1044 | if (list_empty(&wait->task_list)) |
1101 | __add_wait_queue(q, wait); |
1045 | __add_wait_queue(q, wait); |
1102 | spin_unlock_irqrestore(&q->lock, flags); |
1046 | spin_unlock_irqrestore(&q->lock, flags); |
1103 | } |
1047 | } |
1104 | 1048 | ||
1105 | /** |
1049 | /** |
1106 | * finish_wait - clean up after waiting in a queue |
1050 | * finish_wait - clean up after waiting in a queue |
1107 | * @q: waitqueue waited on |
1051 | * @q: waitqueue waited on |
1108 | * @wait: wait descriptor |
1052 | * @wait: wait descriptor |
1109 | * |
1053 | * |
1110 | * Sets current thread back to running state and removes |
1054 | * Sets current thread back to running state and removes |
1111 | * the wait descriptor from the given waitqueue if still |
1055 | * the wait descriptor from the given waitqueue if still |
1112 | * queued. |
1056 | * queued. |
1113 | */ |
1057 | */ |
1114 | void finish_wait(wait_queue_head_t *q, wait_queue_t *wait) |
1058 | void finish_wait(wait_queue_head_t *q, wait_queue_t *wait) |
1115 | { |
1059 | { |
1116 | unsigned long flags; |
1060 | unsigned long flags; |
1117 | 1061 | ||
1118 | // __set_current_state(TASK_RUNNING); |
1062 | // __set_current_state(TASK_RUNNING); |
1119 | /* |
1063 | /* |
1120 | * We can check for list emptiness outside the lock |
1064 | * We can check for list emptiness outside the lock |
1121 | * IFF: |
1065 | * IFF: |
1122 | * - we use the "careful" check that verifies both |
1066 | * - we use the "careful" check that verifies both |
1123 | * the next and prev pointers, so that there cannot |
1067 | * the next and prev pointers, so that there cannot |
1124 | * be any half-pending updates in progress on other |
1068 | * be any half-pending updates in progress on other |
1125 | * CPU's that we haven't seen yet (and that might |
1069 | * CPU's that we haven't seen yet (and that might |
1126 | * still change the stack area. |
1070 | * still change the stack area. |
1127 | * and |
1071 | * and |
1128 | * - all other users take the lock (ie we can only |
1072 | * - all other users take the lock (ie we can only |
1129 | * have _one_ other CPU that looks at or modifies |
1073 | * have _one_ other CPU that looks at or modifies |
1130 | * the list). |
1074 | * the list). |
1131 | */ |
1075 | */ |
1132 | if (!list_empty_careful(&wait->task_list)) { |
1076 | if (!list_empty_careful(&wait->task_list)) { |
1133 | spin_lock_irqsave(&q->lock, flags); |
1077 | spin_lock_irqsave(&q->lock, flags); |
1134 | list_del_init(&wait->task_list); |
1078 | list_del_init(&wait->task_list); |
1135 | spin_unlock_irqrestore(&q->lock, flags); |
1079 | spin_unlock_irqrestore(&q->lock, flags); |
1136 | } |
1080 | } |
1137 | 1081 | ||
1138 | DestroyEvent(wait->evnt); |
1082 | DestroyEvent(wait->evnt); |
1139 | } |
1083 | } |
1140 | 1084 | ||
1141 | int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key) |
1085 | int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key) |
1142 | { |
1086 | { |
1143 | list_del_init(&wait->task_list); |
1087 | list_del_init(&wait->task_list); |
1144 | return 1; |
1088 | return 1; |
1145 | } |
1089 | }>24); |
1146 | 1090 | ||
1147 | unsigned int hweight16(unsigned int w) |
- | |
1148 | { |
- | |
1149 | unsigned int res = w - ((w >> 1) & 0x5555); |
- | |
1150 | res = (res & 0x3333) + ((res >> 2) & 0x3333); |
- | |
1151 | res = (res + (res >> 4)) & 0x0F0F; |
- | |
1152 | return (res + (res >> 8)) & 0x00FF; |
- | |
1153 | } |
- | |
1154 | - | ||
1155 | - | ||
1156 | unsigned long round_jiffies_up_relative(unsigned long j) |
- | |
1157 | { |
- | |
1158 | unsigned long j0 = GetTimerTicks(); |
- | |
1159 | - | ||
1160 | /* Use j0 because jiffies might change while we run */ |
- | |
1161 | return round_jiffies_common(j + j0, true) - j0; |
- | |
1162 | }>24); |
- | |
1163 | 1091 | ><24); |
|
1164 | ><24); |
1092 | |
1165 | 1093 | >16)|(slot<<24); |
|
1166 | >16)|(slot<<24); |
1094 | |
1167 | 1095 | ><16)|(slot<<24); |
|
1168 | ><16)|(slot<<24); |
1096 | |
1169 | 1097 | >8)|(slot<<16)|(slot<<24); |
|
1170 | >8)|(slot<<16)|(slot<<24); |
1098 | |
1171 | 1099 | ><8)|(slot<<16)|(slot<<24); |
|
1172 | ><8)|(slot<<16)|(slot<<24); |
1100 | |
1173 | 1101 | >>>>24); |
|
1174 | >>>>24); |
1102 | |
1175 | 1103 | ><24); |
|
1176 | ><24); |
1104 | |
1177 | 1105 | >16)|(slot<<24); |
|
1178 | >16)|(slot<<24); |
1106 | |
1179 | 1107 | ><16)|(slot<<24); |
|
1180 | ><16)|(slot<<24); |
1108 | |
1181 | 1109 | >8)|(slot<<16)|(slot<<24); |
|
1182 | >8)|(slot<<16)|(slot<<24); |
1110 | |
1183 | 1111 | ><8)|(slot<<16)|(slot<<24); |
|
1184 | ><8)|(slot<<16)|(slot<<24); |
1112 | |
1185 | 1113 | >>>>>>>=><=>=><=>>><> |
|
1186 | >>>>>>>=><=>=><=>>><> |
- |