Rev 1275 | Rev 1403 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1275 | Rev 1313 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
4 | #include |
4 | #include |
5 | #include "radeon_drm.h" |
5 | #include "radeon_drm.h" |
6 | #include "radeon.h" |
6 | #include "radeon.h" |
7 | #include "radeon_object.h" |
7 | #include "radeon_object.h" |
8 | #include "display.h" |
8 | #include "display.h" |
9 | 9 | ||
10 | display_t *rdisplay; |
10 | display_t *rdisplay; |
11 | 11 | ||
12 | static cursor_t* __stdcall select_cursor(cursor_t *cursor); |
12 | static cursor_t* __stdcall select_cursor(cursor_t *cursor); |
13 | static void __stdcall move_cursor(cursor_t *cursor, int x, int y); |
13 | static void __stdcall move_cursor(cursor_t *cursor, int x, int y); |
14 | 14 | ||
- | 15 | extern void destroy_cursor(void); |
|
- | 16 | ||
- | 17 | void disable_mouse(void) |
|
- | 18 | {}; |
|
- | 19 | ||
15 | int init_cursor(cursor_t *cursor) |
20 | int init_cursor(cursor_t *cursor) |
16 | { |
21 | { |
17 | struct radeon_device *rdev; |
22 | struct radeon_device *rdev; |
18 | 23 | ||
19 | uint32_t *bits; |
24 | uint32_t *bits; |
20 | uint32_t *src; |
25 | uint32_t *src; |
21 | 26 | ||
22 | int i,j; |
27 | int i,j; |
23 | int r; |
28 | int r; |
24 | 29 | ||
25 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
30 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
26 | 31 | ||
27 | r = radeon_object_create(rdev, NULL, CURSOR_WIDTH*CURSOR_HEIGHT*4, |
32 | r = radeon_object_create(rdev, NULL, CURSOR_WIDTH*CURSOR_HEIGHT*4, |
28 | false, |
33 | false, |
29 | RADEON_GEM_DOMAIN_VRAM, |
34 | RADEON_GEM_DOMAIN_VRAM, |
30 | false, &cursor->robj); |
35 | false, &cursor->robj); |
31 | 36 | ||
32 | if (unlikely(r != 0)) |
37 | if (unlikely(r != 0)) |
33 | return r; |
38 | return r; |
34 | 39 | ||
35 | radeon_object_pin(cursor->robj, TTM_PL_FLAG_VRAM, NULL); |
40 | radeon_object_pin(cursor->robj, TTM_PL_FLAG_VRAM, NULL); |
36 | 41 | ||
37 | r = radeon_object_kmap(cursor->robj, &bits); |
42 | r = radeon_object_kmap(cursor->robj, &bits); |
38 | if (r) { |
43 | if (r) { |
39 | DRM_ERROR("radeon: failed to map cursor (%d).\n", r); |
44 | DRM_ERROR("radeon: failed to map cursor (%d).\n", r); |
40 | return r; |
45 | return r; |
41 | }; |
46 | }; |
42 | 47 | ||
43 | src = cursor->data; |
48 | src = cursor->data; |
44 | 49 | ||
45 | for(i = 0; i < 32; i++) |
50 | for(i = 0; i < 32; i++) |
46 | { |
51 | { |
47 | for(j = 0; j < 32; j++) |
52 | for(j = 0; j < 32; j++) |
48 | *bits++ = *src++; |
53 | *bits++ = *src++; |
49 | for(j = 32; j < CURSOR_WIDTH; j++) |
54 | for(j = 32; j < CURSOR_WIDTH; j++) |
50 | *bits++ = 0; |
55 | *bits++ = 0; |
51 | } |
56 | } |
52 | for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++) |
57 | for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++) |
53 | *bits++ = 0; |
58 | *bits++ = 0; |
54 | 59 | ||
55 | radeon_object_kunmap(cursor->robj); |
60 | radeon_object_kunmap(cursor->robj); |
56 | 61 | ||
- | 62 | cursor->header.destroy = destroy_cursor; |
|
- | 63 | ||
57 | return 0; |
64 | return 0; |
58 | }; |
65 | }; |
59 | 66 | ||
- | 67 | void fini_cursor(cursor_t *cursor) |
|
- | 68 | { |
|
- | 69 | list_del(&cursor->list); |
|
- | 70 | radeon_object_unpin(cursor->robj); |
|
- | 71 | KernelFree(cursor->data); |
|
- | 72 | __DestroyObject(cursor); |
|
- | 73 | }; |
|
- | 74 | ||
- | 75 | ||
60 | static void radeon_show_cursor() |
76 | static void radeon_show_cursor() |
61 | { |
77 | { |
62 | struct radeon_device *rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
78 | struct radeon_device *rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
63 | 79 | ||
64 | if (ASIC_IS_AVIVO(rdev)) { |
80 | if (ASIC_IS_AVIVO(rdev)) { |
65 | WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL); |
81 | WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL); |
66 | WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | |
82 | WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | |
67 | (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); |
83 | (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); |
68 | } else { |
84 | } else { |
69 | WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); |
85 | WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); |
70 | WREG32_P(RADEON_MM_DATA, (RADEON_CRTC_CUR_EN | |
86 | WREG32_P(RADEON_MM_DATA, (RADEON_CRTC_CUR_EN | |
71 | (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)), |
87 | (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)), |
72 | ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK)); |
88 | ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK)); |
73 | } |
89 | } |
74 | } |
90 | } |
75 | 91 | ||
76 | cursor_t* __stdcall select_cursor(cursor_t *cursor) |
92 | cursor_t* __stdcall select_cursor(cursor_t *cursor) |
77 | { |
93 | { |
78 | struct radeon_device *rdev; |
94 | struct radeon_device *rdev; |
79 | cursor_t *old; |
95 | cursor_t *old; |
80 | uint32_t gpu_addr; |
96 | uint32_t gpu_addr; |
81 | 97 | ||
82 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
98 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
83 | 99 | ||
84 | old = rdisplay->cursor; |
100 | old = rdisplay->cursor; |
85 | 101 | ||
86 | rdisplay->cursor = cursor; |
102 | rdisplay->cursor = cursor; |
87 | gpu_addr = cursor->robj->gpu_addr; |
103 | gpu_addr = cursor->robj->gpu_addr; |
88 | 104 | ||
89 | if (ASIC_IS_AVIVO(rdev)) |
105 | if (ASIC_IS_AVIVO(rdev)) |
90 | WREG32(AVIVO_D1CUR_SURFACE_ADDRESS, gpu_addr); |
106 | WREG32(AVIVO_D1CUR_SURFACE_ADDRESS, gpu_addr); |
91 | else { |
107 | else { |
92 | WREG32(RADEON_CUR_OFFSET, gpu_addr - rdev->mc.vram_location); |
108 | WREG32(RADEON_CUR_OFFSET, gpu_addr - rdev->mc.vram_location); |
93 | } |
109 | } |
94 | 110 | ||
95 | return old; |
111 | return old; |
96 | }; |
112 | }; |
97 | 113 | ||
98 | static void radeon_lock_cursor(bool lock) |
114 | static void radeon_lock_cursor(bool lock) |
99 | { |
115 | { |
100 | struct radeon_device *rdev; |
116 | struct radeon_device *rdev; |
101 | 117 | ||
102 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
118 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
103 | 119 | ||
104 | uint32_t cur_lock; |
120 | uint32_t cur_lock; |
105 | 121 | ||
106 | if (ASIC_IS_AVIVO(rdev)) { |
122 | if (ASIC_IS_AVIVO(rdev)) { |
107 | cur_lock = RREG32(AVIVO_D1CUR_UPDATE); |
123 | cur_lock = RREG32(AVIVO_D1CUR_UPDATE); |
108 | if (lock) |
124 | if (lock) |
109 | cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK; |
125 | cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK; |
110 | else |
126 | else |
111 | cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK; |
127 | cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK; |
112 | WREG32(AVIVO_D1CUR_UPDATE, cur_lock); |
128 | WREG32(AVIVO_D1CUR_UPDATE, cur_lock); |
113 | } else { |
129 | } else { |
114 | cur_lock = RREG32(RADEON_CUR_OFFSET); |
130 | cur_lock = RREG32(RADEON_CUR_OFFSET); |
115 | if (lock) |
131 | if (lock) |
116 | cur_lock |= RADEON_CUR_LOCK; |
132 | cur_lock |= RADEON_CUR_LOCK; |
117 | else |
133 | else |
118 | cur_lock &= ~RADEON_CUR_LOCK; |
134 | cur_lock &= ~RADEON_CUR_LOCK; |
119 | WREG32(RADEON_CUR_OFFSET, cur_lock); |
135 | WREG32(RADEON_CUR_OFFSET, cur_lock); |
120 | } |
136 | } |
121 | } |
137 | } |
122 | 138 | ||
123 | 139 | ||
124 | void __stdcall move_cursor(cursor_t *cursor, int x, int y) |
140 | void __stdcall move_cursor(cursor_t *cursor, int x, int y) |
125 | { |
141 | { |
126 | struct radeon_device *rdev; |
142 | struct radeon_device *rdev; |
127 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
143 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
128 | 144 | ||
129 | int hot_x = cursor->hot_x; |
145 | int hot_x = cursor->hot_x; |
130 | int hot_y = cursor->hot_y; |
146 | int hot_y = cursor->hot_y; |
131 | 147 | ||
132 | radeon_lock_cursor(true); |
148 | radeon_lock_cursor(true); |
133 | if (ASIC_IS_AVIVO(rdev)) |
149 | if (ASIC_IS_AVIVO(rdev)) |
134 | { |
150 | { |
135 | int w = 32; |
151 | int w = 32; |
136 | int i = 0; |
152 | int i = 0; |
137 | 153 | ||
138 | WREG32(AVIVO_D1CUR_POSITION, (x << 16) | y); |
154 | WREG32(AVIVO_D1CUR_POSITION, (x << 16) | y); |
139 | WREG32(AVIVO_D1CUR_HOT_SPOT, (hot_x << 16) | hot_y); |
155 | WREG32(AVIVO_D1CUR_HOT_SPOT, (hot_x << 16) | hot_y); |
140 | WREG32(AVIVO_D1CUR_SIZE, ((w - 1) << 16) | 31); |
156 | WREG32(AVIVO_D1CUR_SIZE, ((w - 1) << 16) | 31); |
141 | } else { |
157 | } else { |
142 | uint32_t gpu_addr; |
158 | uint32_t gpu_addr; |
143 | 159 | ||
144 | WREG32(RADEON_CUR_HORZ_VERT_OFF, |
160 | WREG32(RADEON_CUR_HORZ_VERT_OFF, |
145 | (RADEON_CUR_LOCK | (hot_x << 16) | hot_y )); |
161 | (RADEON_CUR_LOCK | (hot_x << 16) | hot_y )); |
146 | WREG32(RADEON_CUR_HORZ_VERT_POSN, |
162 | WREG32(RADEON_CUR_HORZ_VERT_POSN, |
147 | (RADEON_CUR_LOCK | (x << 16) | y)); |
163 | (RADEON_CUR_LOCK | (x << 16) | y)); |
148 | 164 | ||
149 | gpu_addr = cursor->robj->gpu_addr; |
165 | gpu_addr = cursor->robj->gpu_addr; |
150 | 166 | ||
151 | /* offset is from DISP(2)_BASE_ADDRESS */ |
167 | /* offset is from DISP(2)_BASE_ADDRESS */ |
152 | WREG32(RADEON_CUR_OFFSET, |
168 | WREG32(RADEON_CUR_OFFSET, |
153 | (gpu_addr - rdev->mc.vram_location + (hot_y * 256))); |
169 | (gpu_addr - rdev->mc.vram_location + (hot_y * 256))); |
154 | } |
170 | } |
155 | radeon_lock_cursor(false); |
171 | radeon_lock_cursor(false); |
156 | } |
172 | } |
157 | 173 | ||
158 | void __stdcall restore_cursor(int x, int y) |
174 | void __stdcall restore_cursor(int x, int y) |
159 | { |
175 | { |
160 | }; |
176 | }; |
161 | 177 | ||
162 | 178 | ||
163 | bool init_display(struct radeon_device *rdev, mode_t *usermode) |
179 | bool init_display(struct radeon_device *rdev, mode_t *usermode) |
164 | { |
180 | { |
165 | struct drm_device *dev; |
181 | struct drm_device *dev; |
166 | 182 | ||
167 | cursor_t *cursor; |
183 | cursor_t *cursor; |
168 | bool retval = true; |
184 | bool retval = true; |
169 | u32_t ifl; |
185 | u32_t ifl; |
170 | 186 | ||
171 | ENTER(); |
187 | ENTER(); |
172 | 188 | ||
173 | rdisplay = GetDisplay(); |
189 | rdisplay = GetDisplay(); |
174 | 190 | ||
175 | dev = rdisplay->ddev = rdev->ddev; |
191 | dev = rdisplay->ddev = rdev->ddev; |
176 | 192 | ||
177 | ifl = safe_cli(); |
193 | ifl = safe_cli(); |
178 | { |
194 | { |
179 | list_for_each_entry(cursor, &rdisplay->cursors, list) |
195 | list_for_each_entry(cursor, &rdisplay->cursors, list) |
180 | { |
196 | { |
181 | init_cursor(cursor); |
197 | init_cursor(cursor); |
182 | }; |
198 | }; |
183 | 199 | ||
184 | rdisplay->restore_cursor(0,0); |
200 | rdisplay->restore_cursor(0,0); |
185 | rdisplay->init_cursor = init_cursor; |
201 | rdisplay->init_cursor = init_cursor; |
186 | rdisplay->select_cursor = select_cursor; |
202 | rdisplay->select_cursor = select_cursor; |
187 | rdisplay->show_cursor = NULL; |
203 | rdisplay->show_cursor = NULL; |
188 | rdisplay->move_cursor = move_cursor; |
204 | rdisplay->move_cursor = move_cursor; |
189 | rdisplay->restore_cursor = restore_cursor; |
205 | rdisplay->restore_cursor = restore_cursor; |
190 | 206 | rdisplay->disable_mouse = disable_mouse; |
|
- | 207 | ||
191 | select_cursor(rdisplay->cursor); |
208 | select_cursor(rdisplay->cursor); |
192 | radeon_show_cursor(); |
209 | radeon_show_cursor(); |
193 | }; |
210 | }; |
194 | safe_sti(ifl); |
211 | safe_sti(ifl); |
195 | 212 | ||
196 | LEAVE(); |
213 | LEAVE(); |
197 | 214 | ||
198 | return retval; |
215 | return retval; |
199 | };><>><>><>><>><>><>><>>>>> |
216 | };><>><>><>><>><>><>><>>>>> |