Use DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags when available
PATCH 1/1 Use DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags when available
From: Michel Dänzer <[email protected]>
(Ported from radeon commit 1106b2f773ad0611c729b27f4c192a26b43ef1e7)
--- src/amdgpu_dri2.c | 3 +- src/amdgpu_kms.c | 16 ++++----- src/amdgpu_present.c | 5 +-- src/amdgpu_probe.h | 1 + src/drmmode_display.c | 99 +++++++++++++++++++++++++++++++++++++++++++++------ src/drmmode_display.h | 11 +++++- 6 files changed, 110 insertions(+), 25 deletions(-)
src/amdgpu_dri2.c +2 -1
@@ -563,7 +563,8 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client, AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info, ref_crtc_hw_id, amdgpu_dri2_flip_event_handler, - amdgpu_dri2_flip_event_abort, FLIP_VSYNC)) { + amdgpu_dri2_flip_event_abort,FLIP_VSYNC , + target_msc - amdgpu_get_msc_delta(draw, crtc))) { info->drmmode.dri2_flipping = TRUE;return TRUE; }
src/amdgpu_kms.c +6 -10
@@ -701,9 +701,8 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)return ; } -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc,0 , + drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;
@@ -949,8 +948,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info, xf86CrtcPtr xf86_crtc) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; -ScrnInfoPtr scrn; -AMDGPUEntPtr pAMDGPUEnt; +ScrnInfoPtr scrn = xf86_crtc->scrn; +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);uintptr_t drm_queue_seq;unsigned scanout_id;
@@ -961,7 +960,6 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,if (!amdgpu_scanout_do_update (xf86_crtc, scanout_id))return ; - scrn = xf86_crtc->scrn; drm_queue_seq = amdgpu_drm_queue_alloc(xf86_crtc, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, AMDGPU_DRM_QUEUE_ID_DEFAULT,
@@ -973,10 +971,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,return ; } - pAMDGPUEnt =AMDGPUEntPriv (scrn); -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc,0 , + drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;
src/amdgpu_present.c +3 -2
@@ -329,7 +329,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, pixmap, event_id, event, crtc_id, amdgpu_present_flip_event, amdgpu_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
@@ -366,7 +367,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)if (amdgpu_do_pageflip (scrn,AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , pixmap, event_id, event,-1 , amdgpu_present_flip_event, - amdgpu_present_flip_abort,FLIP_VSYNC )) + amdgpu_present_flip_abort,FLIP_VSYNC ,0 ))return ; modeset:
src/amdgpu_probe.h +1 -0
@@ -56,6 +56,7 @@ extern DriverRec AMDGPU; typedef struct { Bool HasCRTC2; /* All cards except original Radeon */ + Bool has_page_flip_target; amdgpu_device_handle pDev;
src/drmmode_display.c +88 -11
142 lines not on this page · raw message
src/drmmode_display.h +10 -1
@@ -130,6 +130,14 @@ enum drmmode_flip_sync { }; +extern int drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc); +extern int drmmode_page_flip_target_relative (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc);extern Bool drmmode_pre_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int cpp);extern void drmmode_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode);extern void drmmode_fini (ScrnInfoPtr pScrn,drmmode_ptr drmmode);
@@ -153,7 +161,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_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);
Signature · 6 lines
2.10.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20161122075819.27641-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Alex Deucher
Reviewed-byQuoted 5 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
(Ported from radeon commit
1106b2f773ad0611c729b27f4c192a26b43ef1e7)Signed-off-by Michel Dänzer <[email protected]>
Quoted 291 lines
--- src/amdgpu_dri2.c | 3 +- src/amdgpu_kms.c | 16 ++++----- src/amdgpu_present.c | 5 +-- src/amdgpu_probe.h | 1 + src/drmmode_display.c | 99 +++++++++++++++++++++++++++++++++++++++++++++------ src/drmmode_display.h | 11 +++++- 6 files changed, 110 insertions(+), 25 deletions(-)src/amdgpu_dri2.c +2
-1@@ -563,7 +563,8 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client, AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info, ref_crtc_hw_id, amdgpu_dri2_flip_event_handler, - amdgpu_dri2_flip_event_abort, FLIP_VSYNC)) { + amdgpu_dri2_flip_event_abort,FLIP_VSYNC , + target_msc - amdgpu_get_msc_delta(draw, crtc))) { info->drmmode.dri2_flipping = TRUE;return TRUE; }src/amdgpu_kms.c +6
-10@@ -701,9 +701,8 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)return ; } -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc,0 , + drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;@@ -949,8 +948,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info, xf86CrtcPtr xf86_crtc) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; -ScrnInfoPtr scrn; -AMDGPUEntPtr pAMDGPUEnt; +ScrnInfoPtr scrn = xf86_crtc->scrn; +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);uintptr_t drm_queue_seq;unsigned scanout_id;@@ -961,7 +960,6 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,if (!amdgpu_scanout_do_update (xf86_crtc, scanout_id))return ; - scrn = xf86_crtc->scrn; drm_queue_seq = amdgpu_drm_queue_alloc(xf86_crtc, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, AMDGPU_DRM_QUEUE_ID_DEFAULT,@@ -973,10 +971,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,return ; } - pAMDGPUEnt =AMDGPUEntPriv (scrn); -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc,0 , + drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;src/amdgpu_present.c +3
-2@@ -329,7 +329,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, pixmap, event_id, event, crtc_id, amdgpu_present_flip_event, amdgpu_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 @@ -366,7 +367,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)if (amdgpu_do_pageflip (scrn,AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , pixmap, event_id, event,-1 , amdgpu_present_flip_event, - amdgpu_present_flip_abort,FLIP_VSYNC )) + amdgpu_present_flip_abort,FLIP_VSYNC ,0 ))return ; modeset:src/amdgpu_probe.h +1
-0@@ -56,6 +56,7 @@ extern DriverRec AMDGPU; typedef struct { Bool HasCRTC2; /* All cards except original Radeon */ + Bool has_page_flip_target; amdgpu_device_handle pDev;src/drmmode_display.c +88
-11@@ -2132,6 +2132,71 @@ static void drm_wakeup_handler(pointer data, int err, pointer p) }#endif +static Bool drmmode_probe_page_flip_target (AMDGPUEntPtr pAMDGPUEnt) +{ +#ifdef DRM_CAP_PAGE_FLIP_TARGET +uint64_t cap_value; + +return drmGetCap (pAMDGPUEnt->fd,DRM_CAP_PAGE_FLIP_TARGET , + &cap_value) ==0 && cap_value !=0 ; +#else +return FALSE; +#endif +} + +static int +drmmode_page_flip (AMDGPUEntPtr pAMDGPUEnt,drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq) +{ +drmmode_ptr drmmode = drmmode_crtc->drmmode; + + flags |=DRM_MODE_PAGE_FLIP_EVENT ; +return drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, + drmmode->fb_id, flags, (void *)drm_queue_seq); +} + +int +drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc) +{ +#ifdef DRM_MODE_PAGE_FLIP_TARGET +if (pAMDGPUEnt->has_page_flip_target) { +drmmode_ptr drmmode = drmmode_crtc->drmmode; + + flags |=DRM_MODE_PAGE_FLIP_EVENT |DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE ; +return drmModePageFlipTarget (pAMDGPUEnt->fd, + drmmode_crtc->mode_crtc->crtc_id, + drmmode->fb_id, flags, + (void *)drm_queue_seq, target_msc); + } +#endif + +return drmmode_page_flip (pAMDGPUEnt, drmmode_crtc, flags, drm_queue_seq); +} + +int +drmmode_page_flip_target_relative (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc) +{ +#ifdef DRM_MODE_PAGE_FLIP_TARGET +if (pAMDGPUEnt->has_page_flip_target) { +drmmode_ptr drmmode = drmmode_crtc->drmmode; + + flags |=DRM_MODE_PAGE_FLIP_EVENT |DRM_MODE_PAGE_FLIP_TARGET_RELATIVE ; +return drmModePageFlipTarget (pAMDGPUEnt->fd, + drmmode_crtc->mode_crtc->crtc_id, + drmmode->fb_id, flags, + (void *)drm_queue_seq, target_msc); + } +#endif + +return drmmode_page_flip (pAMDGPUEnt, drmmode_crtc, flags, drm_queue_seq); +} +Bool drmmode_pre_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int cpp) {AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (pScrn);@@ -2198,6 +2263,8 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) drmmode->event_context.vblank_handler = amdgpu_drm_queue_handler; drmmode->event_context.page_flip_handler = amdgpu_drm_queue_handler; + pAMDGPUEnt->has_page_flip_target =drmmode_probe_page_flip_target (pAMDGPUEnt); +drmModeFreeResources (mode_res);return TRUE; }@@ -2535,7 +2602,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_drm_abort_proc abort, - enum drmmode_flip_sync flip_sync) + enum drmmode_flip_sync flip_sync, + uint32_t target_msc) { AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);xf86CrtcConfigPtr config =XF86_CRTC_CONFIG_PTR (scrn);@@ -2543,7 +2611,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0 ]->driver_private;drmmode_ptr drmmode = drmmode_crtc->drmmode;int i; -uint32_t flip_flags =DRM_MODE_PAGE_FLIP_EVENT ; +uint32_t flip_flags = flip_sync ==FLIP_ASYNC ?DRM_MODE_PAGE_FLIP_ASYNC :0 ;drmmode_flipdata_ptr flipdata;uintptr_t drm_queue_seq =0 ;uint32_t new_front_handle;@@ -2585,9 +2653,6 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata->handler = handler; flipdata->abort = abort; -if (flip_sync ==FLIP_ASYNC ) - flip_flags |=DRM_MODE_PAGE_FLIP_ASYNC ; -for (i =0 ; i < config->num_crtc; i++) { crtc = config->crtc[i];@@ -2613,13 +2678,21 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, goto error; } -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode->fb_id, flip_flags, - (void *)drm_queue_seq)) { -xf86DrvMsg (scrn->scrnIndex,X_WARNING , -"flip queue failed: %s\n" ,strerror (errno)); - goto error; +if (drmmode_crtc->hw_id == ref_crtc_hw_id) { +if (drmmode_page_flip_target_absolute (pAMDGPUEnt, + drmmode_crtc, + flip_flags, + drm_queue_seq, + target_msc) !=0 ) + goto flip_error; + }else { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, + drmmode_crtc, + flip_flags, + drm_queue_seq,0 ) !=0 ) + goto flip_error; } + drmmode_crtc->flip_pending = TRUE; drm_queue_seq =0 ; }@@ -2627,6 +2700,10 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,if (flipdata->flip_count >0 )return TRUE; +flip_error: +xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed: %s\n" , +strerror (errno)); + error:if (flipdata && flipdata->flip_count <=1 ) {drmModeRmFB (pAMDGPUEnt->fd, drmmode->fb_id);src/drmmode_display.h +10
-2@@ -130,6 +130,14 @@ enum drmmode_flip_sync { }; +extern int drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc); +extern int drmmode_page_flip_target_relative (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc);extern Bool drmmode_pre_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int cpp);extern void drmmode_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode);extern void drmmode_fini (ScrnInfoPtr pScrn,drmmode_ptr drmmode);@@ -153,7 +161,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_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); --2.10.2
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Michel,
Quoted 7 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
(Ported from radeon commit
1106b2f773ad0611c729b27f4c192a26b43ef1e7)Signed-off-by Michel Dänzer <[email protected]>---
src/drmmode_display.c static void drm_wakeup_handler(pointer data, int err, pointer p) · line 2144
Quoted 10 lines
src/drmmode_display.c +10
-0+static Bool drmmode_probe_page_flip_target (AMDGPUEntPtr pAMDGPUEnt) +{ +#ifdef DRM_CAP_PAGE_FLIP_TARGET +uint64_t cap_value; + +return drmGetCap (pAMDGPUEnt->fd,DRM_CAP_PAGE_FLIP_TARGET , + &cap_value) ==0 && cap_value !=0 ; +#else +return FALSE; +#endif
Since the ABI is already set, it would be better to add a fallback define and always use drmGetCap. The latter will (should?) return != 0, thus things will work as expected.
Atm there's a hidden dependency on DRM_CAP_PAGE_FLIP_TARGET aware libdrm(?). Without the above one will need to rebuild the DDX after updating libdrm.
Quoted 11 lines
src/drmmode_display.c +11
-0+} + +static int +drmmode_page_flip (AMDGPUEntPtr pAMDGPUEnt,drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq) +{ +drmmode_ptr drmmode = drmmode_crtc->drmmode; + + flags |=DRM_MODE_PAGE_FLIP_EVENT ; +return drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, + drmmode->fb_id, flags, (void *)drm_queue_seq);
src/drmmode_display.c static void drm_wakeup_handler(pointer data, int err, pointer p) · line 2165
Quoted 10 lines
src/drmmode_display.c +10
-0+} + +int +drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +uint32_t flags,uintptr_t drm_queue_seq, +uint32_t target_msc) +{ +#ifdef DRM_MODE_PAGE_FLIP_TARGET +if (pAMDGPUEnt->has_page_flip_target) {
With the above in mind - here (and in *relative) you can drop the guards.
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 10 lines · Emil Velikov
Hi Michel,
Quoted 6 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
(Ported from radeon commit
1106b2f773ad0611c729b27f4c192a26b43ef1e7)Signed-off-by Michel Dänzer <[email protected]>---
Quoted 16 lines
src/drmmode_display.c static void drm_wakeup_handler(pointer data, int err, pointer p) · line 2144
Quoted 10 lines
src/drmmode_display.c +10
-0+static Bool drmmode_probe_page_flip_target (AMDGPUEntPtr pAMDGPUEnt) +{ +#ifdef DRM_CAP_PAGE_FLIP_TARGET +uint64_t cap_value; + +return drmGetCap (pAMDGPUEnt->fd,DRM_CAP_PAGE_FLIP_TARGET , + &cap_value) ==0 && cap_value !=0 ; +#else +return FALSE; +#endif Since the ABI is already set, it would be better to add a fallback define and always use drmGetCap. The latter will (should?) return != 0, thus things will work as expected.
Atm there's a hidden dependency onDRM_CAP_PAGE_FLIP_TARGETaware libdrm(?). Without the above one will need to rebuild the DDX after updating libdrm.
Thanks for your suggestions. Actually, xf86-video-amdgpu already requires libdrm >= 2.4.72 at build time, so I can just drop the preprocessor guards in this patch. I might apply your suggestions to xf86-video-ati though (or I might just bump the libdrm requirement there as well).
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/1 Use DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags when available
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
(Ported from radeon commits 1106b2f773ad0611c729b27f4c192a26b43ef1e7 and 5fea5ef2f07eee4a0f94baab427010b936f1d4b4)
v2:
* Squash in radeon fix for TearFree regression
* Remove preprocessor guards for compatibility with libdrm < 2.4.72 (Emil Velikov)
--- src/amdgpu_dri2.c | 3 +- src/amdgpu_kms.c | 18 +++++------ src/amdgpu_present.c | 5 +-- src/amdgpu_probe.h | 1 + src/drmmode_display.c | 89 ++++++++++++++++++++++++++++++++++++++++++++------- src/drmmode_display.h | 13 +++++++- 6 files changed, 104 insertions(+), 25 deletions(-)
src/amdgpu_dri2.c +2 -1
@@ -563,7 +563,8 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client, AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info, ref_crtc_hw_id, amdgpu_dri2_flip_event_handler, - amdgpu_dri2_flip_event_abort, FLIP_VSYNC)) { + amdgpu_dri2_flip_event_abort,FLIP_VSYNC , + target_msc - amdgpu_get_msc_delta(draw, crtc))) { info->drmmode.dri2_flipping = TRUE;return TRUE; }
src/amdgpu_kms.c +8 -10
@@ -701,9 +701,9 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)return ; } -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc, + drmmode_crtc->scanout[scanout_id].fb_id, +0 , drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;
@@ -949,8 +949,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info, xf86CrtcPtr xf86_crtc) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; -ScrnInfoPtr scrn; -AMDGPUEntPtr pAMDGPUEnt; +ScrnInfoPtr scrn = xf86_crtc->scrn; +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);uintptr_t drm_queue_seq;unsigned scanout_id;
@@ -961,7 +961,6 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,if (!amdgpu_scanout_do_update (xf86_crtc, scanout_id))return ; - scrn = xf86_crtc->scrn; drm_queue_seq = amdgpu_drm_queue_alloc(xf86_crtc, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, AMDGPU_DRM_QUEUE_ID_DEFAULT,
@@ -973,10 +972,9 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,return ; } - pAMDGPUEnt =AMDGPUEntPriv (scrn); -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc, + drmmode_crtc->scanout[scanout_id].fb_id, +0 , drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;
src/amdgpu_present.c +3 -2
@@ -329,7 +329,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, pixmap, event_id, event, crtc_id, amdgpu_present_flip_event, amdgpu_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
@@ -366,7 +367,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)if (amdgpu_do_pageflip (scrn,AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , pixmap, event_id, event,-1 , amdgpu_present_flip_event, - amdgpu_present_flip_abort,FLIP_VSYNC )) + amdgpu_present_flip_abort,FLIP_VSYNC ,0 ))return ; modeset:
src/amdgpu_probe.h +1 -0
@@ -56,6 +56,7 @@ extern DriverRec AMDGPU; typedef struct { Bool HasCRTC2; /* All cards except original Radeon */ + Bool has_page_flip_target; amdgpu_device_handle pDev;
src/drmmode_display.c +78 -11
132 lines not on this page · raw message
src/drmmode_display.h +12 -1
@@ -130,6 +130,16 @@ enum drmmode_flip_sync { }; +extern int drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags, +uintptr_t drm_queue_seq, +uint32_t target_msc); +extern int drmmode_page_flip_target_relative (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags, +uintptr_t drm_queue_seq, +uint32_t target_msc);extern Bool drmmode_pre_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int cpp);extern void drmmode_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode);extern void drmmode_fini (ScrnInfoPtr pScrn,drmmode_ptr drmmode);
@@ -153,7 +163,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_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);
Signature · 6 lines
2.10.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20161125094117.26511-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Alex Deucher
Reviewed-byQuoted 11 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
(Ported from radeon commits
1106b2f773ad0611c729b27f4c192a26b43ef1e7and5fea5ef2f07eee4a0f94baab427010b936f1d4b4)v2:
* Squash in radeon fix for TearFree regression
* Remove preprocessor guards for compatibility with libdrm < 2.4.72 (Emil Velikov)Signed-off-by Michel Dänzer <[email protected]>
Quoted 285 lines
--- src/amdgpu_dri2.c | 3 +- src/amdgpu_kms.c | 18 +++++------ src/amdgpu_present.c | 5 +-- src/amdgpu_probe.h | 1 + src/drmmode_display.c | 89 ++++++++++++++++++++++++++++++++++++++++++++------- src/drmmode_display.h | 13 +++++++- 6 files changed, 104 insertions(+), 25 deletions(-)src/amdgpu_dri2.c +2
-1@@ -563,7 +563,8 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client, AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info, ref_crtc_hw_id, amdgpu_dri2_flip_event_handler, - amdgpu_dri2_flip_event_abort, FLIP_VSYNC)) { + amdgpu_dri2_flip_event_abort,FLIP_VSYNC , + target_msc - amdgpu_get_msc_delta(draw, crtc))) { info->drmmode.dri2_flipping = TRUE;return TRUE; }src/amdgpu_kms.c +8
-10@@ -701,9 +701,9 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)return ; } -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc, + drmmode_crtc->scanout[scanout_id].fb_id, +0 , drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;@@ -949,8 +949,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info, xf86CrtcPtr xf86_crtc) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; -ScrnInfoPtr scrn; -AMDGPUEntPtr pAMDGPUEnt; +ScrnInfoPtr scrn = xf86_crtc->scrn; +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);uintptr_t drm_queue_seq;unsigned scanout_id;@@ -961,7 +961,6 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,if (!amdgpu_scanout_do_update (xf86_crtc, scanout_id))return ; - scrn = xf86_crtc->scrn; drm_queue_seq = amdgpu_drm_queue_alloc(xf86_crtc, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, AMDGPU_DRM_QUEUE_ID_DEFAULT,@@ -973,10 +972,9 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,return ; } - pAMDGPUEnt =AMDGPUEntPriv (scrn); -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode_crtc->scanout[scanout_id].fb_id, -DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, drmmode_crtc, + drmmode_crtc->scanout[scanout_id].fb_id, +0 , drm_queue_seq,0 ) !=0 ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , __func__,strerror (errno));return ;src/amdgpu_present.c +3
-2@@ -329,7 +329,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, pixmap, event_id, event, crtc_id, amdgpu_present_flip_event, amdgpu_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 @@ -366,7 +367,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)if (amdgpu_do_pageflip (scrn,AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , pixmap, event_id, event,-1 , amdgpu_present_flip_event, - amdgpu_present_flip_abort,FLIP_VSYNC )) + amdgpu_present_flip_abort,FLIP_VSYNC ,0 ))return ; modeset:src/amdgpu_probe.h +1
-0@@ -56,6 +56,7 @@ extern DriverRec AMDGPU; typedef struct { Bool HasCRTC2; /* All cards except original Radeon */ + Bool has_page_flip_target; amdgpu_device_handle pDev;src/drmmode_display.c +78
-11@@ -2132,6 +2132,59 @@ static void drm_wakeup_handler(pointer data, int err, pointer p) }#endif +static Bool drmmode_probe_page_flip_target (AMDGPUEntPtr pAMDGPUEnt) +{ +uint64_t cap_value; + +return drmGetCap (pAMDGPUEnt->fd,DRM_CAP_PAGE_FLIP_TARGET , + &cap_value) ==0 && cap_value !=0 ; +} + +static int +drmmode_page_flip (AMDGPUEntPtr pAMDGPUEnt,drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags,uintptr_t drm_queue_seq) +{ + flags |=DRM_MODE_PAGE_FLIP_EVENT ; +return drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, + fb_id, flags, (void *)drm_queue_seq); +} + +int +drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags, +uintptr_t drm_queue_seq,uint32_t target_msc) +{ +if (pAMDGPUEnt->has_page_flip_target) { + flags |=DRM_MODE_PAGE_FLIP_EVENT |DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE ; +return drmModePageFlipTarget (pAMDGPUEnt->fd, + drmmode_crtc->mode_crtc->crtc_id, + fb_id, flags, (void *)drm_queue_seq, + target_msc); + } + +return drmmode_page_flip (pAMDGPUEnt, drmmode_crtc, fb_id, flags, + drm_queue_seq); +} + +int +drmmode_page_flip_target_relative (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags, +uintptr_t drm_queue_seq,uint32_t target_msc) +{ +if (pAMDGPUEnt->has_page_flip_target) { + flags |=DRM_MODE_PAGE_FLIP_EVENT |DRM_MODE_PAGE_FLIP_TARGET_RELATIVE ; +return drmModePageFlipTarget (pAMDGPUEnt->fd, + drmmode_crtc->mode_crtc->crtc_id, + fb_id, flags, (void *)drm_queue_seq, + target_msc); + } + +return drmmode_page_flip (pAMDGPUEnt, drmmode_crtc, fb_id, flags, + drm_queue_seq); +} +Bool drmmode_pre_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int cpp) {AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (pScrn);@@ -2198,6 +2251,8 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) drmmode->event_context.vblank_handler = amdgpu_drm_queue_handler; drmmode->event_context.page_flip_handler = amdgpu_drm_queue_handler; + pAMDGPUEnt->has_page_flip_target =drmmode_probe_page_flip_target (pAMDGPUEnt); +drmModeFreeResources (mode_res);return TRUE; }@@ -2535,7 +2590,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_drm_abort_proc abort, - enum drmmode_flip_sync flip_sync) + enum drmmode_flip_sync flip_sync, + uint32_t target_msc) { AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);xf86CrtcConfigPtr config =XF86_CRTC_CONFIG_PTR (scrn);@@ -2543,7 +2599,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0 ]->driver_private;drmmode_ptr drmmode = drmmode_crtc->drmmode;int i; -uint32_t flip_flags =DRM_MODE_PAGE_FLIP_EVENT ; +uint32_t flip_flags = flip_sync ==FLIP_ASYNC ?DRM_MODE_PAGE_FLIP_ASYNC :0 ;drmmode_flipdata_ptr flipdata;uintptr_t drm_queue_seq =0 ;uint32_t new_front_handle;@@ -2585,9 +2641,6 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata->handler = handler; flipdata->abort = abort; -if (flip_sync ==FLIP_ASYNC ) - flip_flags |=DRM_MODE_PAGE_FLIP_ASYNC ; -for (i =0 ; i < config->num_crtc; i++) { crtc = config->crtc[i];@@ -2613,13 +2666,23 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, goto error; } -if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - drmmode->fb_id, flip_flags, - (void *)drm_queue_seq)) { -xf86DrvMsg (scrn->scrnIndex,X_WARNING , -"flip queue failed: %s\n" ,strerror (errno)); - goto error; +if (drmmode_crtc->hw_id == ref_crtc_hw_id) { +if (drmmode_page_flip_target_absolute (pAMDGPUEnt, + drmmode_crtc, + drmmode->fb_id, + flip_flags, + drm_queue_seq, + target_msc) !=0 ) + goto flip_error; + }else { +if (drmmode_page_flip_target_relative (pAMDGPUEnt, + drmmode_crtc, + drmmode->fb_id, + flip_flags, + drm_queue_seq,0 ) !=0 ) + goto flip_error; } + drmmode_crtc->flip_pending = TRUE; drm_queue_seq =0 ; }@@ -2627,6 +2690,10 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,if (flipdata->flip_count >0 )return TRUE; +flip_error: +xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed: %s\n" , +strerror (errno)); + error:if (flipdata && flipdata->flip_count <=1 ) {drmModeRmFB (pAMDGPUEnt->fd, drmmode->fb_id);src/drmmode_display.h +12
-2@@ -130,6 +130,16 @@ enum drmmode_flip_sync { }; +extern int drmmode_page_flip_target_absolute (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags, +uintptr_t drm_queue_seq, +uint32_t target_msc); +extern int drmmode_page_flip_target_relative (AMDGPUEntPtr pAMDGPUEnt, +drmmode_crtc_private_ptr drmmode_crtc, +int fb_id,uint32_t flags, +uintptr_t drm_queue_seq, +uint32_t target_msc);extern Bool drmmode_pre_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int cpp);extern void drmmode_init (ScrnInfoPtr pScrn,drmmode_ptr drmmode);extern void drmmode_fini (ScrnInfoPtr pScrn,drmmode_ptr drmmode);@@ -153,7 +163,8 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_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); --2.10.2
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx