Rev 7144 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7144 | Rev 7173 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | #include "i915_drv.h" |
2 | #include "i915_drv.h" |
3 | #include "intel_drv.h" |
3 | #include "intel_drv.h" |
4 | #include |
4 | #include |
5 | #include |
5 | #include |
6 | 6 | ||
7 | static struct mutex cursor_lock; |
7 | static struct mutex cursor_lock; |
8 | 8 | ||
9 | static void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y) |
9 | static void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y) |
10 | { |
10 | { |
11 | struct drm_crtc *crtc = os_display->crtc; |
11 | struct drm_crtc *crtc = os_display->crtc; |
12 | struct drm_plane_state *cursor_state = crtc->cursor->state; |
12 | struct drm_plane_state *cursor_state = crtc->cursor->state; |
13 | 13 | ||
14 | x-= cursor->hot_x; |
14 | x-= cursor->hot_x; |
15 | y-= cursor->hot_y; |
15 | y-= cursor->hot_y; |
16 | 16 | ||
17 | crtc->cursor_x = x; |
17 | crtc->cursor_x = x; |
18 | crtc->cursor_y = y; |
18 | crtc->cursor_y = y; |
19 | 19 | ||
20 | cursor_state->crtc_x = x; |
20 | cursor_state->crtc_x = x; |
21 | cursor_state->crtc_y = y; |
21 | cursor_state->crtc_y = y; |
22 | 22 | ||
23 | intel_crtc_update_cursor(crtc, cursor_state); |
23 | intel_crtc_update_cursor(crtc, cursor_state); |
24 | }; |
24 | }; |
25 | 25 | ||
26 | static cursor_t* __stdcall select_cursor_kms(cursor_t *cursor) |
26 | static cursor_t* __stdcall select_cursor_kms(cursor_t *cursor) |
27 | { |
27 | { |
28 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
28 | struct drm_i915_private *dev_priv = os_display->ddev->dev_private; |
29 | struct drm_crtc *crtc = os_display->crtc; |
29 | struct drm_crtc *crtc = os_display->crtc; |
30 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
30 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
31 | struct drm_plane *cursor_plane = crtc->cursor; |
31 | struct drm_plane *cursor_plane = crtc->cursor; |
32 | struct intel_plane_state *cursor_state = to_intel_plane_state(cursor_plane->state); |
32 | struct intel_plane_state *cursor_state = to_intel_plane_state(cursor_plane->state); |
33 | 33 | ||
34 | cursor_t *old; |
34 | cursor_t *old; |
35 | 35 | ||
36 | old = os_display->cursor; |
36 | old = os_display->cursor; |
37 | 37 | ||
38 | mutex_lock(&cursor_lock); |
38 | mutex_lock(&cursor_lock); |
39 | 39 | ||
40 | os_display->cursor = cursor; |
40 | os_display->cursor = cursor; |
41 | 41 | ||
42 | if (!dev_priv->info.cursor_needs_physical) |
42 | if (!dev_priv->info.cursor_needs_physical) |
43 | intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj); |
43 | intel_crtc->cursor_addr = i915_gem_obj_ggtt_offset(cursor->cobj); |
44 | else |
44 | else |
45 | intel_crtc->cursor_addr = (addr_t)cursor->cobj; |
45 | intel_crtc->cursor_addr = (addr_t)cursor->cobj; |
46 | 46 | ||
47 | cursor_state->visible = 1; |
47 | cursor_state->visible = 1; |
48 | 48 | ||
49 | cursor_plane->state->crtc_w = 64; |
49 | cursor_plane->state->crtc_w = 64; |
50 | cursor_plane->state->crtc_h = 64; |
50 | cursor_plane->state->crtc_h = 64; |
51 | cursor_plane->state->rotation = 0; |
51 | cursor_plane->state->rotation = 0; |
52 | 52 | ||
53 | mutex_unlock(&cursor_lock); |
53 | mutex_unlock(&cursor_lock); |
54 | 54 | ||
55 | move_cursor_kms(cursor, crtc->cursor_x, crtc->cursor_y); |
55 | move_cursor_kms(cursor, crtc->cursor_x, crtc->cursor_y); |
56 | return old; |
56 | return old; |
57 | }; |
57 | }; |
58 | 58 | ||
59 | static void __stdcall restore_cursor(int x, int y){}; |
59 | static void __stdcall restore_cursor(int x, int y){}; |
60 | static void disable_mouse(void){}; |
60 | static void disable_mouse(void){}; |
61 | 61 | ||
62 | static void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor) |
62 | static void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor) |
63 | { |
63 | { |
- | 64 | struct drm_i915_private *dev_priv = main_device->dev_private; |
|
64 | struct drm_i915_gem_object *obj = cursor->cobj; |
65 | struct drm_i915_gem_object *obj = cursor->cobj; |
- | 66 | u32 ifl; |
|
- | 67 | ||
- | 68 | ifl = safe_cli(); |
|
65 | list_del(&cursor->list); |
69 | list_del(&cursor->list); |
- | 70 | safe_sti(ifl); |
|
- | 71 | ||
- | 72 | if (!dev_priv->info.cursor_needs_physical) |
|
66 | 73 | { |
|
67 | i915_gem_object_ggtt_unpin(cursor->cobj); |
74 | i915_gem_object_ggtt_unpin(cursor->cobj); |
68 | 75 | ||
69 | mutex_lock(&main_device->struct_mutex); |
76 | mutex_lock(&main_device->struct_mutex); |
70 | drm_gem_object_unreference(&obj->base); |
77 | drm_gem_object_unreference(&obj->base); |
71 | mutex_unlock(&main_device->struct_mutex); |
78 | mutex_unlock(&main_device->struct_mutex); |
- | 79 | } |
|
- | 80 | else |
|
- | 81 | { |
|
- | 82 | addr_t page = (addr_t)obj; |
|
- | 83 | for(addr_t i = 0; i < (KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*8)/4096; i+=4096) |
|
- | 84 | FreePage(page+i); |
|
- | 85 | } |
|
72 | 86 | ||
73 | __DestroyObject(cursor); |
87 | __DestroyObject(cursor); |
74 | }; |
88 | }; |
75 | 89 | ||
76 | static int init_cursor(cursor_t *cursor) |
90 | static int init_cursor(cursor_t *cursor) |
77 | { |
91 | { |
78 | display_t *display = GetDisplay(); |
92 | display_t *display = GetDisplay(); |
79 | struct drm_device *dev = display->ddev; |
93 | struct drm_device *dev = display->ddev; |
80 | struct drm_i915_private *dev_priv = dev->dev_private; |
94 | struct drm_i915_private *dev_priv = dev->dev_private; |
81 | struct drm_i915_gem_object *obj; |
95 | struct drm_i915_gem_object *obj; |
82 | uint32_t *bits; |
96 | uint32_t *bits; |
83 | uint32_t *src; |
97 | uint32_t *src; |
84 | void *mapped; |
98 | void *mapped; |
85 | 99 | ||
86 | int i,j; |
100 | int i,j; |
87 | int ret; |
101 | int ret; |
88 | 102 | ||
89 | mutex_lock(&dev->struct_mutex); |
103 | mutex_lock(&dev->struct_mutex); |
90 | 104 | ||
91 | if (dev_priv->info.cursor_needs_physical) |
105 | if (dev_priv->info.cursor_needs_physical) |
92 | { |
106 | { |
93 | bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*8); |
107 | mapped = bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*8); |
94 | if (unlikely(bits == NULL)) |
108 | if (unlikely(bits == NULL)) |
95 | { |
109 | { |
96 | ret = -ENOMEM; |
110 | ret = -ENOMEM; |
97 | goto unlock; |
111 | goto unlock; |
98 | }; |
112 | }; |
99 | cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits); |
113 | cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits); |
100 | } |
114 | } |
101 | else |
115 | else |
102 | { |
116 | { |
103 | obj = i915_gem_alloc_object(display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
117 | obj = i915_gem_alloc_object(display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
104 | if (unlikely(obj == NULL)) |
118 | if (unlikely(obj == NULL)) |
105 | { |
119 | { |
106 | ret = -ENOMEM; |
120 | ret = -ENOMEM; |
107 | goto unlock; |
121 | goto unlock; |
108 | }; |
122 | }; |
109 | 123 | ||
110 | ret = i915_gem_object_ggtt_pin(obj, &i915_ggtt_view_normal, 128*1024, PIN_GLOBAL); |
124 | ret = i915_gem_object_ggtt_pin(obj, &i915_ggtt_view_normal, 128*1024, PIN_GLOBAL); |
111 | if (ret) |
125 | if (ret) |
112 | goto unref; |
126 | goto unref; |
113 | 127 | ||
114 | ret = i915_gem_object_set_to_gtt_domain(obj, true); |
128 | ret = i915_gem_object_set_to_gtt_domain(obj, true); |
115 | if (ret) |
129 | if (ret) |
116 | goto unpin; |
130 | goto unpin; |
117 | 131 | ||
118 | /* You don't need to worry about fragmentation issues. |
132 | /* You don't need to worry about fragmentation issues. |
119 | * GTT space is continuous. I guarantee it. */ |
133 | * GTT space is continuous. I guarantee it. */ |
120 | 134 | ||
121 | mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj), |
135 | mapped = bits = (u32*)MapIoMem(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj), |
122 | KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW); |
136 | KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4, PG_SW); |
123 | 137 | ||
124 | if (unlikely(bits == NULL)) |
138 | if (unlikely(bits == NULL)) |
125 | { |
139 | { |
126 | ret = -ENOMEM; |
140 | ret = -ENOMEM; |
127 | goto unpin; |
141 | goto unpin; |
128 | }; |
142 | }; |
129 | cursor->cobj = obj; |
143 | cursor->cobj = obj; |
130 | }; |
144 | }; |
131 | 145 | ||
132 | mutex_unlock(&dev->struct_mutex); |
146 | mutex_unlock(&dev->struct_mutex); |
133 | 147 | ||
134 | src = cursor->data; |
148 | src = cursor->data; |
135 | 149 | ||
136 | for(i = 0; i < 32; i++) |
150 | for(i = 0; i < 32; i++) |
137 | { |
151 | { |
138 | for(j = 0; j < 32; j++) |
152 | for(j = 0; j < 32; j++) |
139 | *bits++ = *src++; |
153 | *bits++ = *src++; |
140 | for(j = 32; j < KMS_CURSOR_WIDTH; j++) |
154 | for(j = 32; j < KMS_CURSOR_WIDTH; j++) |
141 | *bits++ = 0; |
155 | *bits++ = 0; |
142 | } |
156 | } |
143 | for(i = 0; i < KMS_CURSOR_WIDTH*(KMS_CURSOR_HEIGHT-32); i++) |
157 | for(i = 0; i < KMS_CURSOR_WIDTH*(KMS_CURSOR_HEIGHT-32); i++) |
144 | *bits++ = 0; |
158 | *bits++ = 0; |
145 | 159 | ||
146 | FreeKernelSpace(mapped); |
160 | FreeKernelSpace(mapped); |
147 | KernelFree(cursor->data); |
161 | KernelFree(cursor->data); |
148 | cursor->data = bits; |
162 | cursor->data = bits; |
149 | cursor->header.destroy = destroy_cursor; |
163 | cursor->header.destroy = destroy_cursor; |
150 | 164 | ||
151 | return 0; |
165 | return 0; |
152 | 166 | ||
153 | unpin: |
167 | unpin: |
154 | i915_gem_object_ggtt_unpin(obj); |
168 | i915_gem_object_ggtt_unpin(obj); |
155 | unref: |
169 | unref: |
156 | drm_gem_object_unreference(&obj->base); |
170 | drm_gem_object_unreference(&obj->base); |
157 | unlock: |
171 | unlock: |
158 | mutex_unlock(&dev->struct_mutex); |
172 | mutex_unlock(&dev->struct_mutex); |
159 | return ret; |
173 | return ret; |
160 | } |
174 | } |
161 | 175 | ||
162 | void init_system_cursors(struct drm_device *dev) |
176 | void init_system_cursors(struct drm_device *dev) |
163 | { |
177 | { |
164 | cursor_t *cursor; |
178 | cursor_t *cursor; |
165 | display_t *display; |
179 | display_t *display; |
166 | u32 ifl; |
180 | u32 ifl; |
167 | 181 | ||
168 | display = GetDisplay(); |
182 | display = GetDisplay(); |
169 | 183 | ||
170 | mutex_init(&cursor_lock); |
184 | mutex_init(&cursor_lock); |
171 | 185 | ||
172 | ifl = safe_cli(); |
186 | ifl = safe_cli(); |
173 | { |
187 | { |
174 | list_for_each_entry(cursor, &display->cursors, list) |
188 | list_for_each_entry(cursor, &display->cursors, list) |
175 | { |
189 | { |
176 | init_cursor(cursor); |
190 | init_cursor(cursor); |
177 | }; |
191 | }; |
178 | 192 | ||
179 | display->restore_cursor(0,0); |
193 | display->restore_cursor(0,0); |
180 | display->init_cursor = init_cursor; |
194 | display->init_cursor = init_cursor; |
181 | display->select_cursor = select_cursor_kms; |
195 | display->select_cursor = select_cursor_kms; |
182 | display->show_cursor = NULL; |
196 | display->show_cursor = NULL; |
183 | display->move_cursor = move_cursor_kms; |
197 | display->move_cursor = move_cursor_kms; |
184 | display->restore_cursor = restore_cursor; |
198 | display->restore_cursor = restore_cursor; |
185 | display->disable_mouse = disable_mouse; |
199 | display->disable_mouse = disable_mouse; |
186 | display->crtc->cursor_x = display->width/2; |
200 | display->crtc->cursor_x = display->width/2; |
187 | display->crtc->cursor_y = display->height/2; |
201 | display->crtc->cursor_y = display->height/2; |
188 | 202 | ||
189 | select_cursor_kms(display->cursor); |
203 | select_cursor_kms(display->cursor); |
190 | }; |
204 | }; |
191 | safe_sti(ifl); |
205 | safe_sti(ifl); |
192 | }>>>> |
206 | }>>>>> |