Rev 1230 | Rev 1239 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1221 | serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include "radeon_drm.h" |
||
6 | #include "radeon.h" |
||
7 | #include "radeon_object.h" |
||
8 | |||
9 | |||
10 | #define CURSOR_HEIGHT 64 |
||
11 | |||
12 | |||
13 | typedef struct tag_display display_t; |
||
14 | |||
15 | |||
16 | { |
||
17 | uint32_t magic; |
||
18 | void *destroy; |
||
19 | kobj_t *fd; |
||
20 | kobj_t *bk; |
||
21 | uint32_t pid; |
||
22 | }; |
||
23 | |||
24 | |||
25 | { |
||
26 | kobj_t header; |
||
27 | |||
28 | |||
29 | uint32_t hot_x; |
||
30 | uint32_t hot_y; |
||
31 | |||
32 | |||
33 | struct radeon_object *robj; |
||
34 | }cursor_t; |
||
35 | |||
36 | |||
1230 | serge | 37 | 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 | |||
1221 | serge | 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 | |||
53 | struct drm_crtc *crtc; |
||
54 | |||
55 | |||
56 | |||
57 | |||
58 | int (*init_cursor)(cursor_t*); |
||
59 | cursor_t* (__stdcall *select_cursor)(cursor_t*); |
||
1230 | serge | 60 | void (*show_cursor)(int show); |
1221 | serge | 61 | void (__stdcall *move_cursor)(cursor_t *cursor, int x, int y); |
1230 | serge | 62 | void (__stdcall *restore_cursor)(int x, int y); |
63 | |||
64 | |||
1221 | serge | 65 | |
66 | |||
1233 | serge | 67 | |
1221 | serge | 68 | |
1230 | serge | 69 | |
1221 | serge | 70 | |
1230 | serge | 71 | |
72 | { |
||
73 | ENTER(); |
||
74 | rdisplay->crtc = crtc; |
||
75 | LEAVE(); |
||
76 | } |
||
77 | |||
78 | |||
1221 | serge | 79 | { |
80 | struct radeon_device *rdev; |
||
81 | |||
82 | |||
83 | uint32_t *src; |
||
84 | |||
85 | |||
86 | int r; |
||
87 | |||
88 | |||
89 | |||
90 | |||
91 | false, |
||
92 | RADEON_GEM_DOMAIN_VRAM, |
||
93 | false, &cursor->robj); |
||
94 | |||
95 | |||
96 | return r; |
||
97 | |||
98 | |||
99 | |||
100 | |||
101 | if (r) { |
||
102 | DRM_ERROR("radeon: failed to map cursor (%d).\n", r); |
||
103 | return r; |
||
104 | }; |
||
105 | |||
106 | |||
107 | |||
108 | |||
109 | { |
||
110 | for(j = 0; j < 32; j++) |
||
111 | *bits++ = *src++; |
||
112 | for(j = 32; j < CURSOR_WIDTH; j++) |
||
1230 | serge | 113 | *bits++ = 0; |
1221 | serge | 114 | } |
115 | for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++) |
||
116 | *bits++ = 0; |
||
117 | |||
118 | |||
119 | |||
120 | |||
121 | }; |
||
122 | |||
123 | |||
1230 | serge | 124 | { |
1221 | serge | 125 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
1230 | serge | 126 | struct radeon_device *rdev = crtc->dev->dev_private; |
127 | |||
128 | |||
129 | WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL + radeon_crtc->crtc_offset); |
||
130 | WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | |
||
131 | (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); |
||
132 | } else { |
||
133 | switch (radeon_crtc->crtc_id) { |
||
134 | case 0: |
||
135 | WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); |
||
136 | break; |
||
137 | case 1: |
||
138 | WREG32(RADEON_MM_INDEX, RADEON_CRTC2_GEN_CNTL); |
||
139 | break; |
||
140 | default: |
||
141 | return; |
||
142 | } |
||
143 | |||
144 | |||
145 | (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)), |
||
146 | ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK)); |
||
147 | } |
||
148 | } |
||
149 | |||
150 | |||
1221 | serge | 151 | |
152 | { |
||
153 | struct radeon_device *rdev = crtc->dev->dev_private; |
||
154 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
||
155 | uint32_t cur_lock; |
||
156 | |||
157 | |||
158 | cur_lock = RREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset); |
||
159 | if (lock) |
||
160 | cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK; |
||
161 | else |
||
162 | cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK; |
||
163 | WREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock); |
||
164 | } else { |
||
165 | cur_lock = RREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset); |
||
166 | if (lock) |
||
167 | cur_lock |= RADEON_CUR_LOCK; |
||
168 | else |
||
169 | cur_lock &= ~RADEON_CUR_LOCK; |
||
170 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, cur_lock); |
||
171 | } |
||
172 | } |
||
173 | |||
174 | |||
1230 | serge | 175 | { |
1221 | serge | 176 | struct radeon_device *rdev; |
177 | struct radeon_crtc *radeon_crtc; |
||
178 | cursor_t *old; |
||
179 | uint32_t gpu_addr; |
||
180 | |||
181 | |||
182 | radeon_crtc = to_radeon_crtc(rdisplay->crtc); |
||
183 | |||
184 | |||
1230 | serge | 185 | |
1221 | serge | 186 | |
1230 | serge | 187 | gpu_addr = cursor->robj->gpu_addr; |
1221 | serge | 188 | |
189 | |||
190 | WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, gpu_addr); |
||
191 | else { |
||
192 | radeon_crtc->legacy_cursor_offset = gpu_addr - radeon_crtc->legacy_display_base_addr; |
||
193 | /* offset is from DISP(2)_BASE_ADDRESS */ |
||
194 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset); |
||
195 | } |
||
196 | |||
1230 | serge | 197 | |
1221 | serge | 198 | }; |
199 | |||
200 | |||
201 | |||
1230 | serge | 202 | { |
1221 | serge | 203 | struct radeon_device *rdev; |
1230 | serge | 204 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
205 | struct drm_crtc *crtc = rdisplay->crtc; |
||
1221 | serge | 206 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
207 | |||
208 | |||
1230 | serge | 209 | int hot_y = cursor->hot_y; |
210 | |||
1221 | serge | 211 | |
212 | if (ASIC_IS_AVIVO(rdev)) |
||
213 | { |
||
214 | int w = 32; |
||
215 | int i = 0; |
||
216 | struct drm_crtc *crtc_p; |
||
217 | |||
218 | |||
219 | // x += crtc->x; |
||
1230 | serge | 220 | // y += crtc->y; |
221 | |||
1221 | serge | 222 | |
223 | #if 0 |
||
224 | /* avivo cursor image can't end on 128 pixel boundry or |
||
225 | * go past the end of the frame if both crtcs are enabled |
||
226 | */ |
||
227 | list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) { |
||
228 | if (crtc_p->enabled) |
||
229 | i++; |
||
230 | } |
||
231 | if (i > 1) { |
||
232 | int cursor_end, frame_end; |
||
233 | |||
234 | |||
235 | frame_end = crtc->x + crtc->mode.crtc_hdisplay; |
||
236 | if (cursor_end >= frame_end) { |
||
237 | w = w - (cursor_end - frame_end); |
||
238 | if (!(frame_end & 0x7f)) |
||
239 | w--; |
||
240 | } else { |
||
241 | if (!(cursor_end & 0x7f)) |
||
242 | w--; |
||
243 | } |
||
244 | if (w <= 0) |
||
245 | w = 1; |
||
246 | } |
||
247 | #endif |
||
248 | WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, |
||
249 | (x << 16) | y); |
||
250 | WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset, |
||
251 | (hot_x << 16) | hot_y); |
||
1230 | serge | 252 | WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset, |
1221 | serge | 253 | ((w - 1) << 16) | 31); |
254 | } else { |
||
255 | if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN) |
||
256 | y *= 2; |
||
257 | |||
258 | |||
259 | (RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16))); |
||
260 | WREG32(RADEON_CUR_HORZ_VERT_POSN + radeon_crtc->crtc_offset, |
||
261 | (RADEON_CUR_LOCK | (x << 16) | y)); |
||
262 | |||
263 | |||
264 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, |
||
265 | (radeon_crtc->legacy_cursor_offset + (hot_y * 256))); |
||
266 | } |
||
267 | radeon_lock_cursor(crtc, false); |
||
268 | } |
||
269 | |||
270 | |||
1230 | serge | 271 | { |
272 | }; |
||
273 | |||
1221 | serge | 274 | |
1233 | serge | 275 | { |
276 | static char name[4]; |
||
277 | |||
278 | |||
279 | name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
||
280 | name[2] = (x[1] & 0x1F) + '@'; |
||
281 | name[3] = 0; |
||
282 | |||
283 | |||
284 | } |
||
285 | |||
286 | |||
287 | { |
||
288 | struct drm_connector *connector; |
||
289 | |||
290 | |||
291 | |||
292 | |||
293 | |||
294 | |||
295 | { |
||
296 | struct drm_display_mode *mode; |
||
297 | |||
298 | |||
299 | struct drm_crtc *crtc; |
||
300 | |||
301 | |||
302 | continue; |
||
303 | |||
304 | |||
305 | if( encoder == NULL) |
||
306 | continue; |
||
307 | |||
308 | |||
309 | |||
310 | |||
311 | continue; |
||
312 | |||
313 | |||
314 | { |
||
315 | char *con_name, *enc_name; |
||
316 | |||
317 | |||
318 | |||
319 | |||
320 | drm_mode_height(mode) == height) |
||
321 | { |
||
322 | char con_edid[128]; |
||
323 | |||
324 | |||
325 | struct drm_framebuffer, filp_head); |
||
326 | |||
327 | |||
328 | |||
329 | |||
330 | manufacturer_name(con_edid + 0x08), |
||
331 | (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)), |
||
332 | (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8) |
||
333 | + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24))); |
||
334 | |||
335 | |||
336 | |||
337 | enc_name = drm_get_encoder_name(encoder); |
||
338 | |||
339 | |||
340 | width, height, con_name, enc_name); |
||
341 | |||
342 | |||
343 | fb->height = height; |
||
344 | fb->pitch = radeon_align_pitch(dev->dev_private, width, 32, false) * ((32 + 1) / 8); |
||
345 | |||
346 | |||
347 | crtc->enabled = true; |
||
348 | rdisplay->crtc = crtc; |
||
349 | |||
350 | |||
351 | |||
352 | |||
353 | rdisplay->height = fb->height; |
||
354 | rdisplay->pitch = fb->pitch; |
||
355 | |||
356 | |||
357 | |||
358 | |||
359 | { |
||
360 | dbgprintf("new mode %d %d pitch %d\n",fb->width, fb->height, fb->pitch); |
||
361 | } |
||
362 | else |
||
363 | { |
||
364 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
||
365 | fb->width, fb->height, crtc); |
||
366 | }; |
||
367 | |||
368 | |||
369 | |||
370 | |||
371 | }; |
||
372 | } |
||
373 | }; |
||
374 | LEAVE(); |
||
375 | return ret; |
||
376 | }; |
||
377 | |||
378 | |||
379 | |||
380 | { |
||
381 | cursor_t *cursor; |
||
382 | |||
383 | |||
384 | |||
385 | |||
386 | |||
387 | |||
388 | |||
389 | |||
390 | { |
||
391 | init_cursor(cursor); |
||
392 | }; |
||
393 | |||
394 | |||
395 | (usermode->height != 0) ) |
||
396 | { |
||
397 | set_mode(rdev->ddev, usermode->width, usermode->height); |
||
398 | } |
||
399 | else |
||
400 | set_mode(rdev->ddev, 800, 600); |
||
401 | |||
402 | |||
403 | radeon_show_cursor(rdisplay->crtc); |
||
404 | |||
405 | |||
406 | rdisplay->select_cursor = select_cursor; |
||
407 | rdisplay->show_cursor = NULL; |
||
408 | rdisplay->move_cursor = move_cursor; |
||
409 | rdisplay->restore_cursor = restore_cursor; |
||
410 | |||
411 | |||
412 | |||
413 | |||
414 | }; |
||
415 | |||
416 | |||
417 | { |
||
418 | char* p = *cmd; |
||
419 | int val = 0; |
||
420 | |||
421 | |||
422 | switch (*p) { |
||
423 | case '0' ... '9': |
||
424 | val = 10*val+(*p-'0'); |
||
425 | break; |
||
426 | default: |
||
427 | *cmd = p; |
||
428 | return val; |
||
429 | } |
||
430 | } |
||
431 | } |
||
432 | |||
433 | |||
434 | { |
||
435 | char c; |
||
436 | |||
437 | |||
438 | |||
439 | |||
440 | { |
||
441 | p--; |
||
442 | |||
443 | |||
444 | p++; |
||
445 | |||
446 | |||
447 | p++; |
||
448 | |||
449 | |||
450 | } |
||
451 | |||
452 | |||
453 | }; |
||
454 | |||
455 | |||
456 | { |
||
457 | char c; |
||
458 | |||
459 | |||
460 | p--; |
||
461 | while( (c = *log++ = *p++) && (c != ' ')); |
||
462 | *log = 0; |
||
463 | |||
464 | |||
465 | }; |
||
466 | |||
467 | |||
468 | { |
||
469 | char *p = cmdline; |
||
470 | |||
471 | |||
472 | |||
473 | |||
474 | { |
||
475 | if( c == '-') |
||
476 | { |
||
477 | switch(*p++) |
||
478 | { |
||
479 | case 'm': |
||
480 | p = parse_mode(p, mode); |
||
481 | break; |
||
482 | |||
483 | |||
484 | p = parse_path(p, log); |
||
485 | break; |
||
486 | }; |
||
487 | }; |
||
488 | c = *p++; |
||
489 | }; |
||
490 | };><>><>><>><>><>><>><>><>><>><>><>=>><>><>>>>> |
||
491 |