Rev 1986 | Rev 2997 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1246 | serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include "radeon_drm.h" |
||
5 | #include "radeon.h" |
||
6 | #include "radeon_object.h" |
||
7 | #include "display.h" |
||
8 | #include "drm_fb_helper.h" |
||
1986 | serge | 9 | |
1246 | serge | 10 | |
1986 | serge | 11 | struct drm_fb_helper helper; |
12 | struct radeon_framebuffer rfb; |
||
13 | struct list_head fbdev_list; |
||
14 | struct radeon_device *rdev; |
||
15 | }; |
||
16 | |||
1246 | serge | 17 | |
1986 | serge | 18 | |
19 | |||
20 | |||
1246 | serge | 21 | static void __stdcall move_cursor_kms(cursor_t *cursor, int x, int y); |
22 | |||
23 | |||
24 | |||
25 | |||
1313 | serge | 26 | |
27 | |||
1246 | serge | 28 | { |
29 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
||
30 | struct radeon_device *rdev = crtc->dev->dev_private; |
||
31 | |||
32 | |||
2004 | serge | 33 | WREG32(RADEON_MM_INDEX, EVERGREEN_CUR_CONTROL + radeon_crtc->crtc_offset); |
34 | WREG32(RADEON_MM_DATA, EVERGREEN_CURSOR_EN | |
||
35 | EVERGREEN_CURSOR_MODE(EVERGREEN_CURSOR_24_8_PRE_MULT)); |
||
36 | } else if (ASIC_IS_AVIVO(rdev)) { |
||
37 | WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL + radeon_crtc->crtc_offset); |
||
1246 | serge | 38 | WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | |
39 | (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); |
||
40 | } else { |
||
41 | switch (radeon_crtc->crtc_id) { |
||
42 | case 0: |
||
43 | WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); |
||
44 | break; |
||
45 | case 1: |
||
46 | WREG32(RADEON_MM_INDEX, RADEON_CRTC2_GEN_CNTL); |
||
47 | break; |
||
48 | default: |
||
49 | return; |
||
50 | } |
||
51 | |||
52 | |||
53 | (RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)), |
||
54 | ~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK)); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | |||
59 | { |
||
60 | struct radeon_device *rdev = crtc->dev->dev_private; |
||
61 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
||
62 | uint32_t cur_lock; |
||
63 | |||
64 | |||
2004 | serge | 65 | cur_lock = RREG32(EVERGREEN_CUR_UPDATE + radeon_crtc->crtc_offset); |
66 | if (lock) |
||
67 | cur_lock |= EVERGREEN_CURSOR_UPDATE_LOCK; |
||
68 | else |
||
69 | cur_lock &= ~EVERGREEN_CURSOR_UPDATE_LOCK; |
||
70 | WREG32(EVERGREEN_CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock); |
||
71 | } else if (ASIC_IS_AVIVO(rdev)) { |
||
72 | cur_lock = RREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset); |
||
1246 | serge | 73 | if (lock) |
74 | cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK; |
||
75 | else |
||
76 | cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK; |
||
77 | WREG32(AVIVO_D1CUR_UPDATE + radeon_crtc->crtc_offset, cur_lock); |
||
78 | } else { |
||
79 | cur_lock = RREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset); |
||
80 | if (lock) |
||
81 | cur_lock |= RADEON_CUR_LOCK; |
||
82 | else |
||
83 | cur_lock &= ~RADEON_CUR_LOCK; |
||
84 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, cur_lock); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | |||
89 | { |
||
90 | struct radeon_device *rdev; |
||
91 | struct radeon_crtc *radeon_crtc; |
||
92 | cursor_t *old; |
||
93 | uint32_t gpu_addr; |
||
94 | |||
95 | |||
96 | radeon_crtc = to_radeon_crtc(rdisplay->crtc); |
||
97 | |||
98 | |||
99 | |||
100 | |||
101 | gpu_addr = radeon_bo_gpu_offset(cursor->robj); |
||
1404 | serge | 102 | |
1246 | serge | 103 | |
2004 | serge | 104 | WREG32(EVERGREEN_CUR_SURFACE_ADDRESS_HIGH + radeon_crtc->crtc_offset, |
105 | 0); |
||
106 | WREG32(EVERGREEN_CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
||
107 | gpu_addr); |
||
108 | } else if (ASIC_IS_AVIVO(rdev)) { |
||
109 | if (rdev->family >= CHIP_RV770) |
||
110 | WREG32(R700_D1CUR_SURFACE_ADDRESS_HIGH, 0); |
||
111 | WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, gpu_addr); |
||
1246 | serge | 112 | } |
2004 | serge | 113 | else { |
1246 | serge | 114 | radeon_crtc->legacy_cursor_offset = gpu_addr - rdev->mc.vram_start; |
1430 | serge | 115 | /* offset is from DISP(2)_BASE_ADDRESS */ |
1246 | serge | 116 | WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset); |
117 | } |
||
118 | |||
119 | |||
120 | }; |
||
121 | |||
122 | |||
123 | { |
||
124 | struct radeon_device *rdev; |
||
125 | rdev = (struct radeon_device *)rdisplay->ddev->dev_private; |
||
126 | struct drm_crtc *crtc = rdisplay->crtc; |
||
127 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
||
128 | |||
129 | |||
130 | int hot_y = cursor->hot_y; |
||
131 | int w = 32; |
||
2004 | serge | 132 | |
1246 | serge | 133 | |
134 | |||
135 | |||
2004 | serge | 136 | WREG32(EVERGREEN_CUR_POSITION + radeon_crtc->crtc_offset, |
137 | (x << 16) | y); |
||
138 | WREG32(EVERGREEN_CUR_HOT_SPOT + radeon_crtc->crtc_offset, |
||
139 | (hot_x << 16) | hot_y); |
||
140 | WREG32(EVERGREEN_CUR_SIZE + radeon_crtc->crtc_offset, |
||
141 | ((w - 1) << 16) | 31); |
||
142 | } else if (ASIC_IS_AVIVO(rdev)) { |
||
143 | WREG32(AVIVO_D1CUR_POSITION + radeon_crtc->crtc_offset, |
||
1246 | serge | 144 | (x << 16) | y); |
145 | WREG32(AVIVO_D1CUR_HOT_SPOT + radeon_crtc->crtc_offset, |
||
146 | (hot_x << 16) | hot_y); |
||
147 | WREG32(AVIVO_D1CUR_SIZE + radeon_crtc->crtc_offset, |
||
148 | ((w - 1) << 16) | 31); |
||
149 | } else { |
||
150 | if (crtc->mode.flags & DRM_MODE_FLAG_DBLSCAN) |
||
151 | y *= 2; |
||
152 | |||
153 | |||
1404 | serge | 154 | int xorg =0, yorg=0; |
155 | |||
156 | |||
157 | y = y - hot_y; |
||
158 | |||
159 | |||
160 | { |
||
161 | xorg = -x + 1; |
||
162 | x = 0; |
||
163 | } |
||
164 | |||
165 | |||
166 | { |
||
167 | yorg = -hot_y + 1; |
||
168 | y = 0; |
||
169 | }; |
||
170 | |||
171 | |||
172 | (RADEON_CUR_LOCK | (xorg << 16) | yorg )); |
||
173 | WREG32(RADEON_CUR_HORZ_VERT_POSN, |
||
174 | (RADEON_CUR_LOCK | (x << 16) | y)); |
||
1246 | serge | 175 | |
176 | |||
1404 | serge | 177 | |
178 | |||
1246 | serge | 179 | WREG32(RADEON_CUR_OFFSET, |
1404 | serge | 180 | (gpu_addr - rdev->mc.vram_start + (yorg * 256))); |
1430 | serge | 181 | } |
1246 | serge | 182 | radeon_lock_cursor_kms(crtc, false); |
183 | } |
||
184 | |||
185 | |||
186 | { |
||
187 | static char name[4]; |
||
188 | |||
189 | |||
190 | name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
||
191 | name[2] = (x[1] & 0x1F) + '@'; |
||
192 | name[3] = 0; |
||
193 | |||
194 | |||
195 | } |
||
196 | |||
197 | |||
198 | videomode_t *reqmode, bool strict) |
||
1403 | serge | 199 | { |
1246 | serge | 200 | struct drm_display_mode *mode = NULL, *tmpmode; |
201 | |||
202 | |||
1986 | serge | 203 | |
204 | |||
205 | |||
206 | |||
207 | |||
1246 | serge | 208 | |
209 | |||
210 | |||
211 | |||
212 | reqmode->width, reqmode->height, reqmode->freq); |
||
213 | |||
214 | |||
215 | { |
||
216 | if( (drm_mode_width(tmpmode) == reqmode->width) && |
||
217 | (drm_mode_height(tmpmode) == reqmode->height) && |
||
218 | (drm_mode_vrefresh(tmpmode) == reqmode->freq) ) |
||
219 | { |
||
220 | mode = tmpmode; |
||
221 | goto do_set; |
||
222 | } |
||
223 | }; |
||
224 | |||
225 | |||
226 | { |
||
227 | list_for_each_entry(tmpmode, &connector->modes, head) |
||
228 | { |
||
229 | if( (drm_mode_width(tmpmode) == reqmode->width) && |
||
230 | (drm_mode_height(tmpmode) == reqmode->height) ) |
||
231 | { |
||
232 | mode = tmpmode; |
||
233 | goto do_set; |
||
234 | } |
||
235 | }; |
||
236 | }; |
||
237 | |||
238 | |||
239 | |||
240 | |||
241 | { |
||
242 | struct drm_framebuffer *fb; |
||
243 | struct drm_encoder *encoder; |
||
244 | struct drm_crtc *crtc; |
||
245 | |||
246 | |||
247 | char *con_name; |
||
248 | char *enc_name; |
||
249 | |||
250 | |||
251 | crtc = encoder->crtc; |
||
252 | |||
253 | |||
1963 | serge | 254 | // struct drm_framebuffer, filp_head); |
255 | |||
1246 | serge | 256 | |
257 | |||
258 | |||
259 | // manufacturer_name(con_edid + 0x08), |
||
260 | // (unsigned short)(con_edid[0x0A] + (con_edid[0x0B] << 8)), |
||
261 | // (unsigned int)(con_edid[0x0C] + (con_edid[0x0D] << 8) |
||
262 | // + (con_edid[0x0E] << 16) + (con_edid[0x0F] << 24))); |
||
263 | |||
264 | |||
265 | enc_name = drm_get_encoder_name(encoder); |
||
266 | |||
267 | |||
268 | reqmode->width, reqmode->height, con_name, enc_name); |
||
269 | |||
270 | |||
1986 | serge | 271 | |
272 | |||
1246 | serge | 273 | fb->height = reqmode->height; |
274 | fb->pitch = radeon_align_pitch(dev->dev_private, reqmode->width, 32, false) * ((32 + 1) / 8); |
||
275 | fb->bits_per_pixel = 32; |
||
1986 | serge | 276 | |
1246 | serge | 277 | |
278 | crtc->enabled = true; |
||
279 | rdisplay->crtc = crtc; |
||
280 | |||
281 | |||
282 | |||
283 | |||
284 | radeon_show_cursor_kms(crtc); |
||
285 | |||
286 | |||
287 | { |
||
288 | rdisplay->width = fb->width; |
||
289 | rdisplay->height = fb->height; |
||
290 | rdisplay->pitch = fb->pitch; |
||
291 | rdisplay->vrefresh = drm_mode_vrefresh(mode); |
||
292 | |||
293 | |||
294 | |||
295 | |||
296 | fb->width, fb->height, fb->pitch); |
||
297 | } |
||
298 | else |
||
299 | DRM_ERROR("failed to set mode %d_%d on crtc %p\n", |
||
300 | fb->width, fb->height, crtc); |
||
301 | } |
||
302 | |||
303 | |||
304 | return ret; |
||
305 | }; |
||
306 | |||
307 | |||
308 | { |
||
309 | struct drm_display_mode *mode; |
||
310 | int count = 0; |
||
311 | |||
312 | |||
313 | { |
||
314 | count++; |
||
315 | }; |
||
316 | return count; |
||
317 | }; |
||
318 | |||
319 | |||
320 | { |
||
321 | struct drm_connector *connector; |
||
322 | struct drm_connector_helper_funcs *connector_funcs; |
||
1963 | serge | 323 | |
324 | |||
1246 | serge | 325 | |
326 | |||
327 | { |
||
328 | struct drm_encoder *encoder; |
||
329 | struct drm_crtc *crtc; |
||
330 | |||
331 | |||
332 | continue; |
||
333 | |||
334 | |||
1963 | serge | 335 | encoder = connector_funcs->best_encoder(connector); |
336 | if( encoder == NULL) |
||
1246 | serge | 337 | continue; |
338 | |||
339 | |||
1963 | serge | 340 | |
341 | |||
1246 | serge | 342 | |
1963 | serge | 343 | |
1986 | serge | 344 | connector, connector->base.id, |
345 | connector->status, connector->encoder, |
||
346 | crtc); |
||
347 | |||
1246 | serge | 348 | |
1986 | serge | 349 | // continue; |
350 | |||
351 | |||
1246 | serge | 352 | |
1986 | serge | 353 | |
1246 | serge | 354 | }; |
355 | |||
356 | |||
357 | }; |
||
358 | |||
359 | |||
1986 | serge | 360 | |
361 | |||
1403 | serge | 362 | { |
1246 | serge | 363 | struct drm_device *dev; |
364 | |||
365 | |||
366 | bool retval = false; |
||
367 | u32_t ifl; |
||
368 | |||
369 | |||
1986 | serge | 370 | struct drm_fb_helper *fb_helper; |
371 | |||
372 | |||
373 | |||
374 | |||
1246 | serge | 375 | |
376 | |||
377 | |||
378 | |||
379 | |||
380 | |||
381 | { |
||
382 | list_for_each_entry(cursor, &rdisplay->cursors, list) |
||
383 | { |
||
384 | init_cursor(cursor); |
||
385 | }; |
||
386 | }; |
||
387 | safe_sti(ifl); |
||
388 | |||
389 | |||
1986 | serge | 390 | |
391 | |||
392 | fb_helper = &rfbdev->helper; |
||
393 | |||
394 | |||
395 | |||
396 | // { |
||
397 | struct drm_mode_set *mode_set = &fb_helper->crtc_info[0].mode_set; |
||
398 | struct drm_crtc *crtc; |
||
399 | struct drm_display_mode *mode; |
||
400 | |||
401 | |||
402 | |||
403 | |||
404 | // continue; |
||
405 | |||
406 | |||
407 | |||
408 | |||
409 | crtc->base.id, |
||
410 | drm_mode_width(mode), drm_mode_height(mode), |
||
411 | drm_mode_vrefresh(mode)); |
||
412 | // } |
||
413 | |||
414 | |||
415 | |||
1246 | serge | 416 | if( rdisplay->connector == 0 ) |
417 | { |
||
418 | dbgprintf("no active connectors\n"); |
||
419 | return false; |
||
420 | }; |
||
421 | |||
422 | |||
1986 | serge | 423 | |
424 | |||
425 | |||
1246 | serge | 426 | |
427 | |||
1268 | serge | 428 | rdisplay->width, rdisplay->height, rdisplay->vrefresh); |
429 | dbgprintf("user mode mode %d x %d x %d\n", |
||
430 | usermode->width, usermode->height, usermode->freq); |
||
431 | |||
432 | |||
1246 | serge | 433 | (usermode->height != 0) && |
434 | ( (usermode->width != rdisplay->width) || |
||
435 | (usermode->height != rdisplay->height) || |
||
436 | (usermode->freq != rdisplay->vrefresh) ) ) |
||
437 | { |
||
438 | |||
439 | |||
440 | } |
||
441 | |||
442 | |||
443 | { |
||
444 | rdisplay->restore_cursor(0,0); |
||
445 | rdisplay->init_cursor = init_cursor; |
||
446 | rdisplay->select_cursor = select_cursor_kms; |
||
447 | rdisplay->show_cursor = NULL; |
||
448 | rdisplay->move_cursor = move_cursor_kms; |
||
449 | rdisplay->restore_cursor = restore_cursor; |
||
450 | rdisplay->disable_mouse = disable_mouse; |
||
1313 | serge | 451 | |
1268 | serge | 452 | |
453 | radeon_show_cursor_kms(rdisplay->crtc); |
||
1246 | serge | 454 | }; |
455 | safe_sti(ifl); |
||
456 | |||
457 | |||
458 | |||
459 | |||
460 | }; |
||
461 | |||
462 | |||
1403 | serge | 463 | { |
1246 | serge | 464 | int err = -1; |
465 | |||
466 | |||
467 | |||
468 | |||
469 | |||
470 | |||
471 | { |
||
472 | *count = rdisplay->supported_modes; |
||
473 | err = 0; |
||
474 | } |
||
475 | else if( mode != NULL ) |
||
476 | { |
||
477 | struct drm_display_mode *drmmode; |
||
478 | int i = 0; |
||
479 | |||
480 | |||
481 | *count = rdisplay->supported_modes; |
||
482 | |||
483 | |||
484 | { |
||
485 | if( i < *count) |
||
486 | { |
||
487 | mode->width = drm_mode_width(drmmode); |
||
488 | mode->height = drm_mode_height(drmmode); |
||
489 | mode->bpp = 32; |
||
490 | mode->freq = drm_mode_vrefresh(drmmode); |
||
491 | i++; |
||
492 | mode++; |
||
493 | } |
||
494 | else break; |
||
495 | }; |
||
496 | *count = i; |
||
497 | err = 0; |
||
498 | }; |
||
499 | LEAVE(); |
||
500 | return err; |
||
501 | } |
||
502 | |||
503 | |||
1403 | serge | 504 | { |
1246 | serge | 505 | int err = -1; |
506 | |||
507 | |||
508 | |||
509 | |||
510 | mode->width, mode->height, mode->freq); |
||
511 | |||
512 | |||
513 | (mode->height != 0) && |
||
514 | (mode->freq != 0 ) && |
||
515 | ( (mode->width != rdisplay->width) || |
||
516 | (mode->height != rdisplay->height) || |
||
517 | (mode->freq != rdisplay->vrefresh) ) ) |
||
518 | { |
||
519 | if( set_mode(rdisplay->ddev, rdisplay->connector, mode, true) ) |
||
520 | err = 0; |
||
521 | }; |
||
522 | |||
523 | |||
524 | return err; |
||
525 | }; |
||
526 | |||
527 | |||
1986 | serge | 528 | |
529 | |||
530 | struct drm_mode_fb_cmd *mode_cmd, |
||
531 | struct drm_gem_object **gobj_p) |
||
532 | { |
||
1404 | serge | 533 | struct radeon_device *rdev = rfbdev->rdev; |
1986 | serge | 534 | struct drm_gem_object *gobj = NULL; |
535 | struct radeon_bo *rbo = NULL; |
||
536 | bool fb_tiled = false; /* useful for testing */ |
||
537 | u32 tiling_flags = 0; |
||
538 | int ret; |
||
539 | int aligned_size, size; |
||
540 | int height = mode_cmd->height; |
||
541 | |||
1404 | serge | 542 | |
1986 | serge | 543 | static struct drm_mm_node vm_node; |
544 | |||
545 | |||
546 | mode_cmd->pitch = radeon_align_pitch(rdev, mode_cmd->width, mode_cmd->bpp, fb_tiled) * ((mode_cmd->bpp + 1) / 8); |
||
547 | |||
548 | |||
549 | height = ALIGN(mode_cmd->height, 8); |
||
550 | size = mode_cmd->pitch * height; |
||
551 | aligned_size = ALIGN(size, PAGE_SIZE); |
||
552 | |||
553 | |||
554 | if (unlikely(ret)) { |
||
555 | return ret; |
||
556 | } |
||
1404 | serge | 557 | |
558 | |||
1986 | serge | 559 | kos_bo.gem_base.driver_private = NULL; |
560 | kos_bo.surface_reg = -1; |
||
561 | kos_bo.domain = RADEON_GEM_DOMAIN_VRAM; |
||
562 | |||
563 | |||
564 | |||
565 | |||
566 | rbo = gem_to_radeon_bo(gobj); |
||
567 | |||
568 | |||
569 | tiling_flags = RADEON_TILING_MACRO; |
||
570 | |||
571 | |||
572 | rbo->tiling_flags = tiling_flags | RADEON_TILING_SURFACE; |
||
573 | rbo->pitch = mode_cmd->pitch; |
||
574 | } |
||
1404 | serge | 575 | |
576 | |||
1986 | serge | 577 | vm_node.start = 0; |
578 | vm_node.mm = NULL; |
||
579 | |||
580 | |||
581 | rbo->tbo.offset = rbo->tbo.vm_node->start << PAGE_SHIFT; |
||
582 | rbo->tbo.offset += (u64)rbo->rdev->mc.vram_start; |
||
583 | rbo->kptr = (void*)0xFE000000; |
||
584 | rbo->pin_count = 1; |
||
585 | |||
586 | |||
587 | // radeon_bo_check_tiling(rbo, 0, 0); |
||
588 | |||
589 | |||
590 | return 0; |
||
591 | }><>>>><>><>><>><>><>><>><>>>><>><>><>><>><>><>><>><> |
||
1404 | serge | 592 |