Rev 1239 | Rev 1268 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1239 | Rev 1246 | ||
---|---|---|---|
Line 4... | Line 4... | ||
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 | 8 | #include "display.h" |
|
- | 9 | ||
Line 9... | Line 10... | ||
9 | #define CURSOR_WIDTH 64 |
10 | display_t *rdisplay; |
10 | #define CURSOR_HEIGHT 64 |
- | |
Line 11... | Line -... | ||
11 | - | ||
12 | typedef struct tag_object kobj_t; |
- | |
13 | typedef struct tag_display display_t; |
- | |
14 | - | ||
15 | struct tag_object |
- | |
16 | { |
- | |
17 | uint32_t magic; |
- | |
18 | void *destroy; |
- | |
19 | kobj_t *fd; |
- | |
20 | kobj_t *bk; |
- | |
21 | uint32_t pid; |
- | |
22 | }; |
- | |
23 | - | ||
24 | typedef struct |
- | |
25 | { |
- | |
26 | kobj_t header; |
- | |
27 | - | ||
28 | uint32_t *data; |
- | |
29 | uint32_t hot_x; |
- | |
30 | uint32_t hot_y; |
- | |
31 | - | ||
32 | struct list_head list; |
- | |
33 | struct radeon_object *robj; |
- | |
34 | }cursor_t; |
- | |
35 | - | ||
36 | int init_cursor(cursor_t *cursor); |
11 | |
37 | cursor_t* __stdcall select_cursor(cursor_t *cursor); |
12 | static cursor_t* __stdcall select_cursor(cursor_t *cursor); |
38 | void __stdcall move_cursor(cursor_t *cursor, int x, int y); |
- | |
39 | void __stdcall restore_cursor(int x, int y); |
- | |
40 | - | ||
41 | struct tag_display |
- | |
42 | { |
- | |
43 | int x; |
- | |
44 | int y; |
- | |
45 | int width; |
- | |
46 | int height; |
- | |
47 | int bpp; |
- | |
48 | int vrefresh; |
- | |
49 | int pitch; |
- | |
50 | int lfb; |
- | |
51 | - | ||
52 | int supported_modes; |
- | |
53 | struct drm_device *ddev; |
- | |
54 | struct drm_connector *connector; |
- | |
55 | struct drm_crtc *crtc; |
- | |
56 | - | ||
57 | struct list_head cursors; |
- | |
58 | - | ||
59 | cursor_t *cursor; |
- | |
60 | int (*init_cursor)(cursor_t*); |
- | |
61 | cursor_t* (__stdcall *select_cursor)(cursor_t*); |
- | |
62 | void (*show_cursor)(int show); |
- | |
63 | void (__stdcall *move_cursor)(cursor_t *cursor, int x, int y); |
- | |
64 | void (__stdcall *restore_cursor)(int x, int y); |
- | |
65 | - | ||
66 | }; |
- | |
67 | - | ||
68 | int radeon_align_pitch(struct radeon_device *rdev, int width, int bpp, bool tiled); |
- | |
69 | - | ||
70 | static display_t *rdisplay; |
- | |
71 | - | ||
72 | - | ||
73 | void set_crtc(struct drm_crtc *crtc) |
- | |
74 | { |
- | |
75 | ENTER(); |
- | |
76 | rdisplay->crtc = crtc; |
- | |
77 | LEAVE(); |
- | |
Line 78... | Line 13... | ||
78 | } |
13 | static void __stdcall move_cursor(cursor_t *cursor, int x, int y); |
79 | 14 | ||
80 | int init_cursor(cursor_t *cursor) |
15 | int init_cursor(cursor_t *cursor) |
Line 96... | Line 31... | ||
96 | 31 | ||
Line 97... | Line 32... | ||
97 | if (unlikely(r != 0)) |
32 | if (unlikely(r != 0)) |
98 | return r; |
33 | return r; |
Line 99... | Line 34... | ||
99 | 34 | ||
Line 100... | Line 35... | ||
100 | radeon_object_pin(cursor->robj, RADEON_GEM_DOMAIN_VRAM, NULL); |
35 | radeon_object_pin(cursor->robj, TTM_PL_FLAG_VRAM, NULL); |
101 | 36 | ||
102 | r = radeon_object_kmap(cursor->robj, &bits); |
37 | r = radeon_object_kmap(cursor->robj, &bits); |
103 | if (r) { |
38 | if (r) { |
Line 121... | Line 56... | ||
121 | 56 | ||
Line 122... | Line 57... | ||
122 | return 0; |
57 | return 0; |
123 | }; |
58 | }; |
Line 124... | Line 59... | ||
124 | 59 | ||
125 | static void radeon_show_cursor(struct drm_crtc *crtc) |
60 | static void radeon_show_cursor() |
126 | { |
- | |
127 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
61 | { |
Line 128... | Line 62... | ||
128 | struct radeon_device *rdev = crtc->dev->dev_private; |
62 | struct radeon_device *rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
129 | 63 | ||
130 | if (ASIC_IS_AVIVO(rdev)) { |
64 | if (ASIC_IS_AVIVO(rdev)) { |
131 | WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL + radeon_crtc->crtc_offset); |
65 | WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL); |
132 | WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | |
66 | WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | |
133 | (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); |
- | |
134 | } else { |
- | |
135 | switch (radeon_crtc->crtc_id) { |
67 | (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); |
136 | case 0: |
- | |
137 | WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); |
- | |
138 | break; |
- | |
139 | case 1: |
- | |
140 | WREG32(RADEON_MM_INDEX, RADEON_CRTC2_GEN_CNTL); |
- | |
141 | break; |
- | |
142 | default: |
- | |
143 | return; |
- | |
144 | } |
68 | } else { |
145 | 69 | WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); |
|
146 | WREG32_P(RADEON_MM_DATA, (RADEON_CRTC_CUR_EN | |
70 | WREG32_P(RADEON_MM_DATA, (RADEON_CRTC_CUR_EN | |
147 | (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)), |
71 | (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)), |
148 | ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK)); |
72 | ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK)); |
Line 149... | Line -... | ||
149 | } |
- | |
150 | } |
- | |
151 | - | ||
152 | - | ||
153 | static void radeon_lock_cursor(struct drm_crtc *crtc, bool lock) |
- | |
154 | { |
- | |
155 | struct radeon_device *rdev = crtc->dev->dev_private; |
- | |
156 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
- | |
157 | uint32_t cur_lock; |
- | |
158 | - | ||
159 | if (ASIC_IS_AVIVO(rdev)) { |
- | |
160 | cur_lock = RREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset); |
- | |
161 | if (lock) |
- | |
162 | cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK; |
- | |
163 | else |
- | |
164 | cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK; |
- | |
165 | WREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock); |
- | |
166 | } else { |
- | |
167 | cur_lock = RREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset); |
- | |
168 | if (lock) |
- | |
169 | cur_lock |= RADEON_CUR_LOCK; |
- | |
170 | else |
- | |
171 | cur_lock &= ~RADEON_CUR_LOCK; |
- | |
172 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, cur_lock); |
- | |
173 | } |
73 | } |
174 | } |
74 | } |
175 | 75 | ||
176 | cursor_t* __stdcall select_cursor(cursor_t *cursor) |
- | |
177 | { |
76 | cursor_t* __stdcall select_cursor(cursor_t *cursor) |
178 | struct radeon_device *rdev; |
77 | { |
Line 179... | Line 78... | ||
179 | struct radeon_crtc *radeon_crtc; |
78 | struct radeon_device *rdev; |
180 | cursor_t *old; |
- | |
Line 181... | Line 79... | ||
181 | uint32_t gpu_addr; |
79 | cursor_t *old; |
Line 182... | Line 80... | ||
182 | 80 | uint32_t gpu_addr; |
|
183 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
81 | |
Line 184... | Line 82... | ||
184 | radeon_crtc = to_radeon_crtc(rdisplay->crtc); |
82 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
185 | 83 | ||
186 | old = rdisplay->cursor; |
84 | old = rdisplay->cursor; |
187 | - | ||
188 | rdisplay->cursor = cursor; |
- | |
189 | gpu_addr = cursor->robj->gpu_addr; |
85 | |
190 | 86 | rdisplay->cursor = cursor; |
|
Line 191... | Line 87... | ||
191 | if (ASIC_IS_AVIVO(rdev)) |
87 | gpu_addr = cursor->robj->gpu_addr; |
192 | WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, gpu_addr); |
88 | |
Line -... | Line 89... | ||
- | 89 | if (ASIC_IS_AVIVO(rdev)) |
|
- | 90 | WREG32(AVIVO_D1CUR_SURFACE_ADDRESS, gpu_addr); |
|
- | 91 | else { |
|
- | 92 | WREG32(RADEON_CUR_OFFSET, gpu_addr - rdev->mc.vram_location); |
|
- | 93 | } |
|
- | 94 | ||
- | 95 | return old; |
|
- | 96 | }; |
|
- | 97 | ||
- | 98 | static void radeon_lock_cursor(bool lock) |
|
- | 99 | { |
|
- | 100 | struct radeon_device *rdev; |
|
- | 101 | ||
- | 102 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
|
- | 103 | ||
- | 104 | uint32_t cur_lock; |
|
- | 105 | ||
- | 106 | if (ASIC_IS_AVIVO(rdev)) { |
|
- | 107 | cur_lock = RREG32(AVIVO_D1CUR_UPDATE); |
|
- | 108 | if (lock) |
|
- | 109 | cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK; |
|
- | 110 | else |
|
- | 111 | cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK; |
|
- | 112 | WREG32(AVIVO_D1CUR_UPDATE, cur_lock); |
|
- | 113 | } else { |
|
Line 193... | Line 114... | ||
193 | else { |
114 | cur_lock = RREG32(RADEON_CUR_OFFSET); |
194 | radeon_crtc->legacy_cursor_offset = gpu_addr - radeon_crtc->legacy_display_base_addr; |
115 | if (lock) |
195 | /* offset is from DISP(2)_BASE_ADDRESS */ |
116 | cur_lock |= RADEON_CUR_LOCK; |
196 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset); |
117 | else |
197 | } |
- | |
198 | - | ||
Line 199... | Line 118... | ||
199 | return old; |
118 | cur_lock &= ~RADEON_CUR_LOCK; |
200 | }; |
119 | WREG32(RADEON_CUR_OFFSET, cur_lock); |
Line 201... | Line 120... | ||
201 | 120 | } |
|
202 | 121 | } |
|
203 | void __stdcall move_cursor(cursor_t *cursor, int x, int y) |
122 | |
204 | { |
123 | |
205 | struct radeon_device *rdev; |
124 | void __stdcall move_cursor(cursor_t *cursor, int x, int y) |
206 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
- | |
Line 207... | Line -... | ||
207 | struct drm_crtc *crtc = rdisplay->crtc; |
- | |
208 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
- | |
209 | - | ||
210 | int hot_x = cursor->hot_x; |
- | |
211 | int hot_y = cursor->hot_y; |
- | |
212 | - | ||
213 | radeon_lock_cursor(crtc, true); |
- | |
214 | if (ASIC_IS_AVIVO(rdev)) |
- | |
215 | { |
- | |
216 | int w = 32; |
- | |
217 | int i = 0; |
- | |
218 | struct drm_crtc *crtc_p; |
- | |
219 | - | ||
220 | /* avivo cursor are offset into the total surface */ |
- | |
221 | // x += crtc->x; |
- | |
222 | // y += crtc->y; |
- | |
223 | - | ||
224 | // DRM_DEBUG("x %d y %d c->x %d c->y %d\n", x, y, crtc->x, crtc->y); |
- | |
225 | #if 0 |
- | |
226 | /* avivo cursor image can't end on 128 pixel boundry or |
- | |
227 | * go past the end of the frame if both crtcs are enabled |
- | |
228 | */ |
- | |
229 | list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) { |
- | |
230 | if (crtc_p->enabled) |
- | |
231 | i++; |
- | |
232 | } |
- | |
233 | if (i > 1) { |
- | |
234 | int cursor_end, frame_end; |
- | |
235 | - | ||
236 | cursor_end = x + w; |
- | |
237 | frame_end = crtc->x + crtc->mode.crtc_hdisplay; |
125 | { |
238 | if (cursor_end >= frame_end) { |
- | |
239 | w = w - (cursor_end - frame_end); |
126 | struct radeon_device *rdev; |
240 | if (!(frame_end & 0x7f)) |
- | |
241 | w--; |
127 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
242 | } else { |
- | |
243 | if (!(cursor_end & 0x7f)) |
128 | |
244 | w--; |
- | |
245 | } |
129 | int hot_x = cursor->hot_x; |
Line 246... | Line 130... | ||
246 | if (w <= 0) |
130 | int hot_y = cursor->hot_y; |
247 | w = 1; |
131 | |
248 | } |
132 | radeon_lock_cursor(true); |
249 | #endif |
133 | if (ASIC_IS_AVIVO(rdev)) |
Line -... | Line 134... | ||
- | 134 | { |
|
- | 135 | int w = 32; |
|
250 | WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, |
136 | int i = 0; |
251 | (x << 16) | y); |
137 | |
252 | WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset, |
138 | WREG32(AVIVO_D1CUR_POSITION, (x << 16) | y); |
253 | (hot_x << 16) | hot_y); |
139 | WREG32(AVIVO_D1CUR_HOT_SPOT, (hot_x << 16) | hot_y); |
254 | WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset, |
140 | WREG32(AVIVO_D1CUR_SIZE, ((w - 1) << 16) | 31); |
255 | ((w - 1) << 16) | 31); |
141 | } else { |
Line 256... | Line 142... | ||
256 | } else { |
142 | uint32_t gpu_addr; |
257 | if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN) |
143 | |
258 | y *= 2; |
144 | WREG32(RADEON_CUR_HORZ_VERT_OFF, |
Line 259... | Line -... | ||
259 | - | ||
260 | WREG32(RADEON_CUR_HORZ_VERT_OFF + radeon_crtc->crtc_offset, |
- | |
261 | (RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16))); |
- | |
262 | WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset, |
- | |
263 | (RADEON_CUR_LOCK | (x << 16) | y)); |
- | |
264 | - | ||
265 | /* offset is from DISP(2)_BASE_ADDRESS */ |
- | |
266 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, |
- | |
267 | (radeon_crtc->legacy_cursor_offset + (hot_y * 256))); |
- | |
268 | } |
- | |
269 | radeon_lock_cursor(crtc, false); |
- | |
270 | } |
- | |
271 | - | ||
272 | void __stdcall restore_cursor(int x, int y) |
- | |
273 | { |
- | |
274 | }; |
- | |
275 | - | ||
276 | static char *manufacturer_name(unsigned char *x) |
- | |
277 | { |
- | |
278 | static char name[4]; |
- | |
279 | - | ||
280 | name[0] = ((x[0] & 0x7C) >> 2) + '@'; |
- | |
281 | name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
- | |
282 | name[2] = (x[1] & 0x1F) + '@'; |
- | |
283 | name[3] = 0; |
- | |
284 | - | ||
285 | return name; |
- | |
286 | } |
- | |
287 | - | ||
288 | bool set_mode(struct drm_device *dev, struct drm_connector *connector, |
- | |
289 | mode_t *reqmode, bool strict) |
- | |
290 | { |
- | |
291 | struct drm_display_mode *mode = NULL, *tmpmode; |
- | |
292 | - | ||
293 | bool ret = false; |
- | |
294 | - | ||
295 | ENTER(); |
- | |
296 | - | ||
297 | list_for_each_entry(tmpmode, &connector->modes, head) |
- | |
298 | { |
- | |
299 | if( (drm_mode_width(tmpmode) == reqmode->width) && |
- | |
300 | (drm_mode_height(tmpmode) == reqmode->height) && |
- | |
301 | (drm_mode_vrefresh(tmpmode) == reqmode->freq) ) |
- | |
302 | { |
- | |
303 | mode = tmpmode; |
- | |
304 | break; |
- | |
305 | } |
- | |
306 | }; |
- | |
307 | - | ||
308 | if( (mode == NULL) && (strict == false) ) |
- | |
309 | { |
- | |
310 | list_for_each_entry(tmpmode, &connector->modes, head) |
- | |
311 | { |
- | |
312 | if( (drm_mode_width(tmpmode) == reqmode->width) && |
- | |
313 | (drm_mode_height(tmpmode) == reqmode->height) ) |
- | |
314 | { |
- | |
315 | mode = tmpmode; |
- | |
316 | break; |
- | |
317 | } |
- | |
318 | }; |
- | |
319 | }; |
- | |
320 | - | ||
321 | if( mode != NULL ) |
- | |
322 | { |
- | |
323 | struct drm_framebuffer *fb; |
- | |
324 | struct drm_encoder *encoder; |
- | |
325 | struct drm_crtc *crtc; |
- | |
326 | - | ||
327 | char con_edid[128]; |
- | |
328 | char *con_name; |
- | |
329 | char *enc_name; |
- | |
330 | - | ||
331 | encoder = connector->encoder; |
- | |
332 | crtc = encoder->crtc; |
- | |
333 | - | ||
334 | fb = list_first_entry(&dev->mode_config.fb_kernel_list, |
- | |
335 | struct drm_framebuffer, filp_head); |
- | |
336 | - | ||
337 | memcpy(con_edid, connector->edid_blob_ptr->data, 128); |
- | |
338 | - | ||
339 | dbgprintf("Manufacturer: %s Model %x Serial Number %u\n", |
- | |
340 | manufacturer_name(con_edid + 0x08), |
- | |
341 | (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)), |
- | |
342 | (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8) |
- | |
343 | + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24))); |
- | |
344 | - | ||
345 | - | ||
346 | con_name = drm_get_connector_name(connector); |
- | |
347 | enc_name = drm_get_encoder_name(encoder); |
- | |
348 | - | ||
349 | dbgprintf("set mode %d %d connector %s encoder %s\n", |
- | |
350 | reqmode->width, reqmode->height, con_name, enc_name); |
- | |
351 | - | ||
352 | fb->width = reqmode->width; |
- | |
353 | fb->height = reqmode->height; |
- | |
354 | fb->pitch = radeon_align_pitch(dev->dev_private, reqmode->width, 32, false) * ((32 + 1) / 8); |
- | |
355 | - | ||
356 | crtc->fb = fb; |
- | |
357 | crtc->enabled = true; |
- | |
358 | rdisplay->crtc = crtc; |
- | |
359 | - | ||
360 | ret = drm_crtc_helper_set_mode(crtc, mode, 0, 0, fb); |
- | |
361 | - | ||
362 | if (ret == true) |
- | |
363 | { |
- | |
364 | rdisplay->width = fb->width; |
- | |
365 | rdisplay->height = fb->height; |
- | |
366 | rdisplay->pitch = fb->pitch; |
- | |
367 | rdisplay->vrefresh = drm_mode_vrefresh(mode); |
- | |
368 | - | ||
369 | sysSetScreen(fb->width, fb->height, fb->pitch); |
- | |
370 | - | ||
371 | dbgprintf("new mode %d x %d pitch %d\n", |
- | |
372 | fb->width, fb->height, fb->pitch); |
- | |
373 | } |
- | |
374 | else |
- | |
375 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
- | |
376 | fb->width, fb->height, crtc); |
- | |
377 | } |
- | |
378 | - | ||
379 | LEAVE(); |
- | |
380 | return ret; |
- | |
381 | }; |
- | |
382 | - | ||
383 | static int count_connector_modes(struct drm_connector* connector) |
- | |
384 | { |
- | |
385 | struct drm_display_mode *mode; |
- | |
386 | int count = 0; |
- | |
387 | - | ||
388 | list_for_each_entry(mode, &connector->modes, head) |
- | |
389 | { |
- | |
390 | count++; |
- | |
391 | }; |
- | |
392 | return count; |
- | |
393 | }; |
- | |
394 | - | ||
395 | static struct drm_connector* get_def_connector(struct drm_device *dev) |
- | |
396 | { |
- | |
397 | struct drm_connector *connector; |
- | |
398 | struct drm_connector *def_connector = NULL; |
- | |
399 | - | ||
400 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
- | |
401 | { |
- | |
402 | struct drm_encoder *encoder; |
- | |
403 | struct drm_crtc *crtc; |
- | |
404 | - | ||
405 | if( connector->status != connector_status_connected) |
- | |
406 | continue; |
- | |
407 | - | ||
408 | encoder = connector->encoder; |
- | |
409 | if( encoder == NULL) |
- | |
410 | continue; |
- | |
411 | - | ||
412 | if( encoder->encoder_type == DRM_MODE_ENCODER_TVDAC ) |
- | |
Line 413... | Line 145... | ||
413 | { |
145 | (RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16))); |
414 | dbgprintf("skip tvdac encoder %s connector %s\n", |
146 | WREG32(RADEON_CUR_HORZ_VERT_POSN, |
415 | drm_get_encoder_name(encoder), |
147 | (RADEON_CUR_LOCK | (x << 16) | y)); |
- | 148 | ||
416 | drm_get_connector_name(connector)); |
149 | gpu_addr = cursor->robj->gpu_addr; |
417 | continue; |
150 | |
- | 151 | /* offset is from DISP(2)_BASE_ADDRESS */ |
|
Line 418... | Line 152... | ||
418 | }; |
152 | WREG32(RADEON_CUR_OFFSET, |
Line 419... | Line 153... | ||
419 | 153 | (gpu_addr - rdev->mc.vram_location + (hot_y * 256))); |
|
Line 420... | Line 154... | ||
420 | crtc = encoder->crtc; |
154 | } |
Line -... | Line 155... | ||
- | 155 | radeon_lock_cursor(false); |
|
- | 156 | } |
|
421 | if(crtc == NULL) |
157 | |
422 | continue; |
158 | void __stdcall restore_cursor(int x, int y) |
423 | 159 | { |
|
424 | def_connector = connector; |
160 | }; |
425 | break; |
- | |
426 | }; |
- | |
427 | - | ||
428 | return def_connector; |
- | |
429 | }; |
- | |
430 | - | ||
431 | bool init_display(struct radeon_device *rdev, mode_t *usermode) |
- | |
432 | { |
- | |
433 | struct drm_device *dev; |
- | |
434 | cursor_t *cursor; |
- | |
435 | bool retval = false; |
- | |
436 | - | ||
437 | ENTER(); |
- | |
438 | - | ||
439 | rdisplay = GetDisplay(); |
- | |
440 | - | ||
441 | dev = rdisplay->ddev = rdev->ddev; |
- | |
442 | - | ||
443 | list_for_each_entry(cursor, &rdisplay->cursors, list) |
- | |
444 | { |
- | |
445 | init_cursor(cursor); |
- | |
446 | }; |
- | |
447 | 161 | ||
- | 162 | ||
Line 448... | Line 163... | ||
448 | rdisplay->connector = get_def_connector(dev); |
163 | bool init_display(struct radeon_device *rdev, mode_t *usermode) |
- | 164 | { |
|
449 | 165 | struct drm_device *dev; |
|
450 | if( rdisplay->connector == 0 ) |
- | |
451 | return false; |
166 | |
452 | 167 | cursor_t *cursor; |
|
453 | rdisplay->supported_modes = count_connector_modes(rdisplay->connector); |
168 | bool retval = false; |
454 | 169 | u32_t ifl; |
|
455 | if( (usermode->width != 0) && |
170 | |
Line 456... | Line -... | ||
456 | (usermode->height != 0) ) |
- | |
457 | { |
- | |
458 | retval = set_mode(dev, rdisplay->connector, usermode, false); |
- | |
459 | } |
- | |
460 | else |
- | |
461 | { |
- | |
462 | mode_t mode; |
- | |
463 | mode.width = rdisplay->width; |
- | |
464 | mode.height = rdisplay->height; |
- | |
465 | mode.bpp = 32; |
- | |
466 | mode.freq = 60; |
- | |
467 | - | ||
468 | retval = set_mode(dev, rdisplay->connector, &mode, false); |
- | |
469 | }; |
- | |
470 | - | ||
471 | select_cursor(rdisplay->cursor); |
- | |
472 | radeon_show_cursor(rdisplay->crtc); |
- | |
473 | - | ||
474 | rdisplay->init_cursor = init_cursor; |
- | |
475 | rdisplay->select_cursor = select_cursor; |
- | |
476 | rdisplay->show_cursor = NULL; |
- | |
477 | rdisplay->move_cursor = move_cursor; |
- | |
478 | rdisplay->restore_cursor = restore_cursor; |
- | |
479 | - | ||
480 | LEAVE(); |
- | |
481 | - | ||
482 | return retval; |
- | |
483 | }; |
- | |
484 | - | ||
485 | static int my_atoi(char **cmd) |
- | |
486 | { |
- | |
487 | char* p = *cmd; |
- | |
488 | int val = 0; |
- | |
489 | - | ||
490 | for (;; *p++) { |
- | |
491 | switch (*p) { |
171 | ENTER(); |
492 | case '0' ... '9': |
- | |
493 | val = 10*val+(*p-'0'); |
- | |
494 | break; |
- | |
495 | default: |
- | |
496 | *cmd = p; |
172 | |
497 | return val; |
- | |
498 | } |
- | |
499 | } |
- | |
500 | } |
- | |
501 | - | ||
502 | char* parse_mode(char *p, mode_t *mode) |
- | |
503 | { |
- | |
504 | char c; |
- | |
505 | - | ||
506 | while( (c = *p++) == ' '); |
- | |
507 | - | ||
508 | if( c ) |
- | |
509 | { |
- | |
510 | p--; |
- | |
511 | - | ||
512 | mode->width = my_atoi(&p); |
- | |
513 | if(*p == 'x') p++; |
- | |
514 | - | ||
515 | mode->height = my_atoi(&p); |
- | |
516 | if(*p == 'x') p++; |
- | |
517 | - | ||
518 | mode->bpp = 32; |
- | |
519 | - | ||
520 | mode->freq = my_atoi(&p); |
- | |
521 | - | ||
522 | if( mode->freq == 0 ) |
- | |
523 | mode->freq = 60; |
- | |
524 | } |
- | |
525 | - | ||
526 | return p; |
- | |
527 | }; |
- | |
528 | - | ||
529 | char* parse_path(char *p, char *log) |
- | |
530 | { |
- | |
531 | char c; |
- | |
532 | - | ||
533 | while( (c = *p++) == ' '); |
- | |
534 | p--; |
- | |
535 | while( (c = *log++ = *p++) && (c != ' ')); |
- | |
536 | *log = 0; |
- | |
537 | - | ||
538 | return p; |
- | |
539 | }; |
- | |
540 | 173 | rdisplay = GetDisplay(); |
|
- | 174 | ||
Line 541... | Line -... | ||
541 | void parse_cmdline(char *cmdline, mode_t *mode, char *log) |
- | |
542 | { |
- | |
543 | char *p = cmdline; |
- | |
544 | - | ||
545 | char c = *p++; |
- | |
546 | - | ||
547 | while( c ) |
- | |
548 | { |
- | |
549 | if( c == '-') |
- | |
550 | { |
- | |
551 | switch(*p++) |
- | |
552 | { |
- | |
553 | case 'm': |
- | |
554 | p = parse_mode(p, mode); |
- | |
555 | break; |
- | |
556 | - | ||
557 | case 'l': |
- | |
558 | p = parse_path(p, log); |
- | |
559 | break; |
- | |
560 | }; |
- | |
561 | }; |
- | |
562 | c = *p++; |
- | |
563 | }; |
- | |
564 | }; |
- | |
565 | - | ||
566 | - | ||
567 | int get_modes(mode_t *mode, int *count) |
- | |
568 | { |
- | |
569 | int err = -1; |
- | |
570 | - | ||
571 | ENTER(); |
- | |
572 | - | ||
573 | dbgprintf("mode %x count %d\n", mode, *count); |
- | |
574 | - | ||
575 | if( *count == 0 ) |
- | |
576 | { |
- | |
577 | *count = rdisplay->supported_modes; |
- | |
578 | err = 0; |
- | |
579 | } |
175 | dev = rdisplay->ddev = rdev->ddev; |
580 | else if( mode != NULL ) |
- | |
581 | { |
- | |
Line -... | Line 176... | ||
- | 176 | ||
- | 177 | ifl = safe_cli(); |
|
Line 582... | Line -... | ||
582 | struct drm_display_mode *drmmode; |
- | |
583 | int i = 0; |
- | |
584 | - | ||
Line 585... | Line -... | ||
585 | if( *count > rdisplay->supported_modes) |
- | |
586 | *count = rdisplay->supported_modes; |
- | |
587 | - | ||
588 | list_for_each_entry(drmmode, &rdisplay->connector->modes, head) |
- | |
589 | { |
- | |
590 | if( i < *count) |
- | |
591 | { |
- | |
Line 592... | Line -... | ||
592 | mode->width = drm_mode_width(drmmode); |
- | |
593 | mode->height = drm_mode_height(drmmode); |
- |