diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2016-07-06 15:25:33 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2016-08-03 18:46:21 +0900 |
commit | fc884a8af25345c32bd4104c864ecfeb9bb3db9b (patch) | |
tree | 82d321d276aad04d38a758e5d6308869ac7cb6cc | |
parent | 9a1afbf61fbb2827c86bd86d295fa0848980d60b (diff) |
-rw-r--r-- | src/drmmode_display.c | 43 | ||||
-rw-r--r-- | src/drmmode_display.h | 3 | ||||
-rw-r--r-- | src/radeon_dri2.c | 3 | ||||
-rw-r--r-- | src/radeon_kms.c | 21 | ||||
-rw-r--r-- | src/radeon_present.c | 5 | ||||
-rw-r--r-- | src/radeon_probe.h | 1 |
6 files changed, 69 insertions, 7 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index b39651cc..3ed86b49 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2255,6 +2255,18 @@ drm_wakeup_handler(pointer data, int err, pointer p) } } +static Bool drmmode_probe_page_flip_target(drmmode_ptr drmmode) +{ +#ifdef DRM_CAP_PAGE_FLIP_TARGET + uint64_t cap_value; + + return drmGetCap(drmmode->fd, DRM_CAP_PAGE_FLIP_TARGET, + &cap_value) == 0 && cap_value != 0; +#else + return FALSE; +#endif +} + Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) { RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); @@ -2320,6 +2332,8 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) drmmode->event_context.vblank_handler = radeon_drm_queue_handler; drmmode->event_context.page_flip_handler = radeon_drm_queue_handler; + pRADEONEnt->has_page_flip_target = drmmode_probe_page_flip_target(drmmode); + drmModeFreeResources(mode_res); return TRUE; } @@ -2714,8 +2728,12 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, uint32_t new_front_handle, uint64_t id, void *data, int ref_crtc_hw_id, radeon_drm_handler_proc handler, radeon_drm_abort_proc abort, - enum drmmode_flip_sync flip_sync) + enum drmmode_flip_sync flip_sync, + uint32_t target_msc) { +#ifdef DRM_MODE_PAGE_FLIP_TARGET_RELATIVE + RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn); +#endif RADEONInfoPtr info = RADEONPTR(scrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcPtr crtc = NULL; @@ -2799,6 +2817,29 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, goto error; } +#ifdef DRM_MODE_PAGE_FLIP_TARGET + if (pRADEONEnt->has_page_flip_target) { + uint32_t target_flip_flags = flip_flags; + + if (drmmode_crtc->hw_id == ref_crtc_hw_id) + target_flip_flags |= DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE; + else + target_flip_flags |= DRM_MODE_PAGE_FLIP_TARGET_RELATIVE; + + if (drmModePageFlipTarget(drmmode->fd, + drmmode_crtc->mode_crtc->crtc_id, + drmmode->fb_id, + target_flip_flags, + (void*)drm_queue_seq, + drmmode_crtc->hw_id == ref_crtc_hw_id ? + target_msc : 0) != 0) { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "flip queue failed: %s\n", + strerror(errno)); + goto error; + } + } else +#endif if (drmModePageFlip(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, drmmode->fb_id, flip_flags, (void*)drm_queue_seq)) { diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 83c64820..cc65b13a 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -158,7 +158,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, uint32_t new_front_handle, uint64_t id, void *data, int ref_crtc_hw_id, radeon_drm_handler_proc handler, radeon_drm_abort_proc abort, - enum drmmode_flip_sync flip_sync); + enum drmmode_flip_sync flip_sync, + uint32_t target_msc); int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); int drmmode_get_current_ust(int drm_fd, CARD64 *ust); diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index c55e6ee8..c9b11f16 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -737,7 +737,8 @@ radeon_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client, RADEON_DRM_QUEUE_ID_DEFAULT, flip_info, ref_crtc_hw_id, radeon_dri2_flip_event_handler, - radeon_dri2_flip_event_abort, FLIP_VSYNC)) { + radeon_dri2_flip_event_abort, FLIP_VSYNC, + target_msc - radeon_get_msc_delta(draw, crtc))) { info->drmmode.dri2_flipping = TRUE; return TRUE; } diff --git a/src/radeon_kms.c b/src/radeon_kms.c index da11358a..8af35e9f 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -623,7 +623,10 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info, xf86CrtcPtr xf86_crtc) { drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; - ScrnInfoPtr scrn; + ScrnInfoPtr scrn = xf86_crtc->scrn; +#ifdef DRM_MODE_PAGE_FLIP_TARGET_RELATIVE + RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn); +#endif uintptr_t drm_queue_seq; unsigned scanout_id; @@ -634,7 +637,6 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info, if (!radeon_scanout_do_update(xf86_crtc, scanout_id)) return; - scrn = xf86_crtc->scrn; drm_queue_seq = radeon_drm_queue_alloc(xf86_crtc, RADEON_DRM_QUEUE_CLIENT_DEFAULT, RADEON_DRM_QUEUE_ID_DEFAULT, @@ -646,6 +648,21 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info, return; } +#ifdef DRM_MODE_PAGE_FLIP_TARGET_RELATIVE + if (pRADEONEnt->has_page_flip_target) { + if (drmModePageFlipTarget(drmmode_crtc->drmmode->fd, + drmmode_crtc->mode_crtc->crtc_id, + drmmode_crtc->scanout[scanout_id].fb_id, + DRM_MODE_PAGE_FLIP_EVENT | + DRM_MODE_PAGE_FLIP_TARGET_RELATIVE, + (void*)drm_queue_seq, 0)) { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "flip queue failed in %s: %s\n", + __func__, strerror(errno)); + return; + } + } else +#endif if (drmModePageFlip(drmmode_crtc->drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, drmmode_crtc->scanout[scanout_id].fb_id, DRM_MODE_PAGE_FLIP_EVENT, (void*)drm_queue_seq)) { diff --git a/src/radeon_present.c b/src/radeon_present.c index 52943fb9..84eb298f 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -336,7 +336,8 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, event_id, event, crtc_id, radeon_present_flip_event, radeon_present_flip_abort, - sync_flip ? FLIP_VSYNC : FLIP_ASYNC); + sync_flip ? FLIP_VSYNC : FLIP_ASYNC, + target_msc); if (!ret) xf86DrvMsg(scrn->scrnIndex, X_ERROR, "present flip failed\n"); else @@ -379,7 +380,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) if (radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle, event_id, event, -1, radeon_present_flip_event, - radeon_present_flip_abort, FLIP_VSYNC)) + radeon_present_flip_abort, FLIP_VSYNC, 0)) return; modeset: diff --git a/src/radeon_probe.h b/src/radeon_probe.h index 258c7be1..e6655f32 100644 --- a/src/radeon_probe.h +++ b/src/radeon_probe.h @@ -133,6 +133,7 @@ typedef struct { typedef struct { Bool HasCRTC2; /* All cards except original Radeon */ + Bool has_page_flip_target; int fd; /* for sharing across zaphod heads */ int fd_ref; |