Porting outstanding changes from amdgpu
cover Porting outstanding changes from amdgpu
From: Michel Dänzer <[email protected]>
These are the outstanding applicable changes ported from xf86-video-amdgpu.
Michel Dänzer (13):
Detect and fix up non-premultiplied cursor data
Skip gamma correction of cursor data if premultiplied R/G/B > alpha
glamor: Can work at depth >= 15 with current xserver Git master Use drm_abort_one in drm_queue_handler
Explicitly keep track of whether a DRM event is for a flip or not Move deferred vblank events to separate drm_vblank_deferred list Perform scanout buffer update immediately if drmmode_wait_vblank fails Cancel pending scanout update in drmmode_crtc_scanout_update Automatically try re-enabling TearFree after a flip failed Drop RADEONInfoRec::cursor_bo array
Use drmIoctl in drmmode_show_cursor
Update cursor position in drmmode_show_cursor if hotspot changed Use two HW cursor buffers per CRTC
src/drmmode_display.c | 225 +++++++++++++++++++++++++++-------------- src/drmmode_display.h | 18 +++- src/radeon.h | 1 - src/radeon_bo_helper.c | 2 + src/radeon_dri2.c | 4 +- src/radeon_drm_queue.c | 110 +++++++++++--------- src/radeon_drm_queue.h | 3 +- src/radeon_glamor.c | 9 +- src/radeon_kms.c | 147 +++++++++++++++++++-------- src/radeon_present.c | 3 +- 10 files changed, 353 insertions(+), 169 deletions(-)
Signature · 6 lines
2.20.1 _______________________________________________ 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): 20181221174907.29920-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
PATCH 1/13 Detect and fix up non-premultiplied cursor data
From: Michel Dänzer <[email protected]>
X server >= 1.18 already had code for this, but it only caught cases where some pixels have 0 for alpha and non-0 for a non-alpha component. Turns out some apps (e.g. the Civilization VI game) use non-premultiplied cursor data which doesn't have such pixels, but can still result in visual artifacts.
This uses the method suggested by Kamil in
https://bugs.freedesktop.org/92309#c19: check for pixels where any colour component value is larger than the alpha value, which isn't possible with premultiplied alpha.
There can still be non-premultiplied data which won't be caught by this, but that should result in slightly incorrect colours and/or blending at the worst, not wildly incorrect colours such as shown in the bug report below.
Bugzilla: https://bugs.freedesktop.org/108355
(Ported from amdgpu commits ad6dfb0124860cf67730bde85867f81d9258c84d &
426f9a49655f01863cf4d898f525e5f95984e0c4)
--- src/drmmode_display.c | 81 ++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 20 deletions(-)
src/drmmode_display.c +61 -20
@@ -1049,29 +1049,52 @@ drmmode_cursor_src_offset(Rotation rotation, int width, int height,#endif -static uint32_t -drmmode_cursor_gamma (xf86CrtcPtr crtc,uint32_t argb) +static Bool +drmmode_cursor_pixel (xf86CrtcPtr crtc,uint32_t *argb,Bool premultiplied, +Bool apply_gamma) { -uint32_t alpha = argb >>24 ; +uint32_t alpha = *argb >>24 ;uint32_t rgb[3 ];int i; -if (!alpha) -return 0 ; +if (premultiplied) { +#if XORG_VERSION_CURRENT <XORG_VERSION_NUMERIC (1 ,18 ,4 ,0 ,0 ) +if (alpha ==0 && (*argb &0xffffff ) !=0 ) +/* Doesn't look like premultiplied alpha */ +return FALSE; +#endif -if (crtc->scrn->depth !=24 && crtc->scrn->depth !=32 ) -return argb; +if (!apply_gamma) +return TRUE; + } -/* Un-premultiply alpha */ +if (!alpha) { + *argb =0 ; +return TRUE; + } + +/* Extract RGB */ for (i =0 ; i <3 ; i++) - rgb[i] = ((argb >> (i *8 )) &0xff ) *0xff / alpha; + rgb[i] = (*argb >> (i *8 )) &0xff ; + +if (premultiplied) { +/* Un-premultiply alpha */ +for (i =0 ; i <3 ; i++) + rgb[i] = rgb[i] *0xff / alpha; + } + +if (apply_gamma) { + rgb[0 ] = crtc->gamma_blue[rgb[0 ]] >>8 ; + rgb[1 ] = crtc->gamma_green[rgb[1 ]] >>8 ; + rgb[2 ] = crtc->gamma_red[rgb[2 ]] >>8 ; + } -/* Apply gamma correction and pre-multiply alpha */ - rgb[0 ] = (crtc->gamma_blue[rgb[0 ]] >>8 ) * alpha /0xff ; - rgb[1 ] = (crtc->gamma_green[rgb[1 ]] >>8 ) * alpha /0xff ; - rgb[2 ] = (crtc->gamma_red[rgb[2 ]] >>8 ) * alpha /0xff ; +/* Premultiply alpha */ +for (i =0 ; i <3 ; i++) + rgb[i] = rgb[i] * alpha /0xff ; -return alpha <<24 | rgb[2 ] <<16 | rgb[1 ] <<8 | rgb[0 ]; + *argb = alpha <<24 | rgb[2 ] <<16 | rgb[1 ] <<8 | rgb[0 ]; +return TRUE; } static void
@@ -1080,27 +1103,37 @@ drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)ScrnInfoPtr pScrn = crtc->scrn;RADEONInfoPtr info =RADEONPTR (pScrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +Bool premultiplied = TRUE; +Bool apply_gamma = TRUE; +uint32_t argb;uint32_t *ptr;/* cursor should be mapped already */ ptr = (uint32_t *)(drmmode_crtc->cursor_bo->ptr); +if (crtc->scrn->depth !=24 && crtc->scrn->depth !=32 ) + apply_gamma = FALSE; +#if XF86_CRTC_VERSION <7 if (crtc->driverIsPerformingTransform) {uint32_t cursor_w = info->cursor_w, cursor_h = info->cursor_h;int dstx, dsty;int srcoffset; +retry_transform:for (dsty =0 ; dsty < cursor_h; dsty++) {for (dstx =0 ; dstx < cursor_w; dstx++) { srcoffset =drmmode_cursor_src_offset (crtc->rotation, cursor_w, cursor_h, dstx, dsty); - - ptr[dsty * info->cursor_w + dstx] = -cpu_to_le32 (drmmode_cursor_gamma (crtc, - image[srcoffset])); + argb = image[srcoffset]; +if (!drmmode_cursor_pixel (crtc, &argb, premultiplied, + apply_gamma)) { + premultiplied = FALSE; + goto retry_transform; + } + ptr[dsty * info->cursor_w + dstx] =cpu_to_le32 (argb); } } }else
@@ -1109,8 +1142,16 @@ drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)uint32_t cursor_size = info->cursor_w * info->cursor_h;int i; -for (i =0 ; i < cursor_size; i++) - ptr[i] =cpu_to_le32 (drmmode_cursor_gamma (crtc, image[i])); +retry: +for (i =0 ; i < cursor_size; i++) { + argb = image[i]; +if (!drmmode_cursor_pixel (crtc, &argb, premultiplied, + apply_gamma)) { + premultiplied = FALSE; + goto retry; + } + ptr[i] =cpu_to_le32 (argb); + } } }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/13 Skip gamma correction of cursor data if premultiplied R/G/B > alpha
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
The un-premultiplied R/G/B values would overflow the gamma LUT, so just pass through the data unchanged, and leave it up to the HW how to interpret such weird premultiplied alpha pixels.
Bugzilla: https://bugs.freedesktop.org/108355
(Ported from amdgpu commit 13c94a373b4858a2d2aa14c22b5f98d53c84c0d9)
--- src/drmmode_display.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
src/drmmode_display.c +21 -13
@@ -1050,8 +1050,8 @@ drmmode_cursor_src_offset(Rotation rotation, int width, int height,#endif static Bool -drmmode_cursor_pixel (xf86CrtcPtr crtc,uint32_t *argb,Bool premultiplied, -Bool apply_gamma) +drmmode_cursor_pixel (xf86CrtcPtr crtc,uint32_t *argb,Bool *premultiplied, +Bool *apply_gamma) {uint32_t alpha = *argb >>24 ;uint32_t rgb[3 ];
@@ -1059,13 +1059,23 @@ drmmode_cursor_pixel(xf86CrtcPtr crtc, uint32_t *argb, Bool premultiplied,if (premultiplied) {#if XORG_VERSION_CURRENT <XORG_VERSION_NUMERIC (1 ,18 ,4 ,0 ,0 ) -if (alpha ==0 && (*argb &0xffffff ) !=0 ) +if (alpha ==0 && (*argb &0xffffff ) !=0 ) {/* Doesn't look like premultiplied alpha */ + *premultiplied = FALSE;return FALSE; + }#endif -if (!apply_gamma) +if (!(*apply_gamma))return TRUE; + +if (*argb > (alpha | alpha <<8 | alpha <<16 | alpha <<24 )) { +/* Un-premultiplied R/G/B would overflow gamma LUT, +* don't apply gamma correction +*/ + *apply_gamma = FALSE; +return FALSE; + } }if (!alpha) {
@@ -1083,7 +1093,7 @@ drmmode_cursor_pixel(xf86CrtcPtr crtc, uint32_t *argb, Bool premultiplied, rgb[i] = rgb[i] *0xff / alpha; } -if (apply_gamma) { +if (*apply_gamma) { rgb[0 ] = crtc->gamma_blue[rgb[0 ]] >>8 ; rgb[1 ] = crtc->gamma_green[rgb[1 ]] >>8 ; rgb[2 ] = crtc->gamma_red[rgb[2 ]] >>8 ;
@@ -1128,11 +1138,10 @@ retry_transform: cursor_h, dstx, dsty); argb = image[srcoffset]; -if (!drmmode_cursor_pixel (crtc, &argb, premultiplied, - apply_gamma)) { - premultiplied = FALSE; +if (!drmmode_cursor_pixel (crtc, &argb, &premultiplied, + &apply_gamma)) goto retry_transform; - } + ptr[dsty * info->cursor_w + dstx] =cpu_to_le32 (argb); } }
@@ -1145,11 +1154,10 @@ retry_transform: retry:for (i =0 ; i < cursor_size; i++) { argb = image[i]; -if (!drmmode_cursor_pixel (crtc, &argb, premultiplied, - apply_gamma)) { - premultiplied = FALSE; +if (!drmmode_cursor_pixel (crtc, &argb, &premultiplied, + &apply_gamma)) goto retry; - } + ptr[i] =cpu_to_le32 (argb); } }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/13 glamor: Can work at depth >= 15 with current xserver Git master
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
(Ported from amdgpu commit 0734cdf544ffd3f2ac8749ad0e4bf43f8a5cea50)
--- src/radeon_bo_helper.c | 2 ++ src/radeon_glamor.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
src/radeon_bo_helper.c +2 -0
@@ -39,6 +39,8 @@ radeon_get_gbm_format(int depth, int bitsPerPixel)case 8 :return GBM_FORMAT_R8 ;#endif +case 15 : +return GBM_FORMAT_ARGB1555 ;case 16 :return GBM_FORMAT_RGB565 ;case 32 :
src/radeon_glamor.c +7 -2
@@ -109,9 +109,14 @@ radeon_glamor_pre_init(ScrnInfoPtr scrn) "glamor may not work (well) with GPUs < RV515.\n"); } +#if XORG_VERSION_CURRENT <XORG_VERSION_NUMERIC (1 ,20 ,99 ,0 ,0 )if (scrn->depth <24 ) { -xf86DrvMsg (scrn->scrnIndex, s ?X_ERROR :X_WARNING , -"glamor requires depth >= 24, disabling.\n" ); +#else +if (scrn->depth <15 ) { +#endif +xf86DrvMsg (scrn->scrnIndex,X_ERROR , +"Depth %d not supported with glamor, disabling\n" , + scrn->depth);return FALSE; }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/13 Use drm_abort_one in drm_queue_handler
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
At this point, we've already established that e->handler is NULL, no need to check again in drm_queue_handle_one. This also makes it clearer what's happening.
(Ported from amdgpu commit eda571222f5a6be47f8897e82d85199bb9d95251)
--- src/radeon_drm_queue.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
src/radeon_drm_queue.c +14 -14
@@ -72,6 +72,19 @@ radeon_drm_queue_handle_one(struct radeon_drm_queue_entry *e)free (e); } +/* +* Abort one queued DRM entry, removing it +* from the list, calling the abort function and +* freeing the memory +*/ +static void +radeon_drm_abort_one (struct radeon_drm_queue_entry *e) +{ +xorg_list_del (&e->list); + e->abort (e->crtc, e->data); +free (e); +} +static void radeon_drm_queue_handler (struct xorg_list *signalled,unsigned int frame,unsigned int sec,unsigned int usec,void *user_ptr)
@@ -82,7 +95,7 @@ radeon_drm_queue_handler(struct xorg_list *signalled, unsigned int frame,xorg_list_for_each_entry_safe (e, tmp, &radeon_drm_queue, list) {if (e->seq == seq) {if (!e->handler) { -radeon_drm_queue_handle_one (e); +radeon_drm_abort_one (e);break ; }
@@ -173,19 +186,6 @@ radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,return e->seq; } -/* -* Abort one queued DRM entry, removing it -* from the list, calling the abort function and -* freeing the memory -*/ -static void -radeon_drm_abort_one (struct radeon_drm_queue_entry *e) -{ -xorg_list_del (&e->list); - e->abort (e->crtc, e->data); -free (e); -} -/* * Abort drm queue entries for a client *
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/13 Explicitly keep track of whether a DRM event is for a flip or not
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
When an async flip is performed, and TearFree is enabled on the CRTC used for timing, we schedule a vblank event for completing the page flip. The DRM event queuing code treated this event like a vblank event, but it needs to be treated like a page flip event.
(Ported from amdgpu commit e2c7369cae65069aa93eed1c0b678f975ce5c274)
--- src/drmmode_display.c | 3 ++- src/radeon_dri2.c | 4 ++-- src/radeon_drm_queue.c | 39 +++++++++++---------------------------- src/radeon_drm_queue.h | 3 ++- src/radeon_kms.c | 10 ++++++---- src/radeon_present.c | 3 ++- 6 files changed, 25 insertions(+), 37 deletions(-)
src/drmmode_display.c +2 -1
@@ -3397,7 +3397,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue_seq =radeon_drm_queue_alloc (crtc, client, id, flipdata, drmmode_flip_handler, - drmmode_flip_abort); + drmmode_flip_abort, + TRUE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM queue event entry failed.\n" );
src/radeon_dri2.c +2 -2
@@ -1076,7 +1076,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, drm_queue_seq =radeon_drm_queue_alloc (crtc, client,RADEON_DRM_QUEUE_ID_DEFAULT , wait_info, radeon_dri2_frame_event_handler, - radeon_dri2_frame_event_abort); + radeon_dri2_frame_event_abort, FALSE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM queue event entry failed.\n" );
@@ -1215,7 +1215,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, drm_queue_seq =radeon_drm_queue_alloc (crtc, client,RADEON_DRM_QUEUE_ID_DEFAULT , swap_info, radeon_dri2_frame_event_handler, - radeon_dri2_frame_event_abort); + radeon_dri2_frame_event_abort, FALSE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM queue entry failed.\n" );
src/radeon_drm_queue.c +11 -28
@@ -48,6 +48,7 @@ struct radeon_drm_queue_entry {xf86CrtcPtr crtc;radeon_drm_handler_proc handler;radeon_drm_abort_proc abort; +Bool is_flip;unsigned int frame; };
@@ -86,8 +87,8 @@ radeon_drm_abort_one(struct radeon_drm_queue_entry *e) }static void -radeon_drm_queue_handler (struct xorg_list *signalled,unsigned int frame, -unsigned int sec,unsigned int usec,void *user_ptr) +radeon_drm_queue_handler (int fd,unsigned int frame,unsigned int sec, +unsigned int usec,void *user_ptr) {uintptr_t seq = (uintptr_t )user_ptr;struct radeon_drm_queue_entry *e, *tmp;
@@ -102,34 +103,14 @@ radeon_drm_queue_handler(struct xorg_list *signalled, unsigned int frame,xorg_list_del (&e->list); e->usec = (uint64_t )sec *1000000 + usec; e->frame = frame; -xorg_list_append (&e->list, signalled); +xorg_list_append (&e->list, e->is_flip ? + &radeon_drm_flip_signalled : + &radeon_drm_vblank_signalled);break ; } } } -/* -* Signal a DRM page flip event -*/ -static void -radeon_drm_page_flip_handler (int fd,unsigned int frame,unsigned int sec, -unsigned int usec,void *user_ptr) -{ -radeon_drm_queue_handler (&radeon_drm_flip_signalled, frame, sec, usec, - user_ptr); -} - -/* -* Signal a DRM vblank event -*/ -static void -radeon_drm_vblank_handler (int fd,unsigned int frame,unsigned int sec, -unsigned int usec,void *user_ptr) -{ -radeon_drm_queue_handler (&radeon_drm_vblank_signalled, frame, sec, usec, - user_ptr); -} -/* * Handle deferred DRM vblank events *
@@ -162,7 +143,8 @@ uintptr_t radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client, uint64_t id, void *data, radeon_drm_handler_proc handler, - radeon_drm_abort_proc abort) + radeon_drm_abort_proc abort, + Bool is_flip) { struct radeon_drm_queue_entry *e;
@@ -180,6 +162,7 @@ radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client, e->data = data; e->handler = handler; e->abort = abort; + e->is_flip = is_flip;xorg_list_append (&e->list, &radeon_drm_queue);
@@ -306,8 +289,8 @@ radeon_drm_queue_init(ScrnInfoPtr scrn)drmmode_ptr drmmode = &info->drmmode; drmmode->event_context.version =2 ; - drmmode->event_context.vblank_handler = radeon_drm_vblank_handler; - drmmode->event_context.page_flip_handler = radeon_drm_page_flip_handler; + drmmode->event_context.vblank_handler = radeon_drm_queue_handler; + drmmode->event_context.page_flip_handler = radeon_drm_queue_handler;if (radeon_drm_queue_refcnt++)return ;
src/radeon_drm_queue.h +2 -1
@@ -44,7 +44,8 @@ void radeon_drm_queue_handle_deferred(xf86CrtcPtr crtc);uintptr_t radeon_drm_queue_alloc (xf86CrtcPtr crtc,ClientPtr client,uint64_t id,void *data,radeon_drm_handler_proc handler, -radeon_drm_abort_proc abort); +radeon_drm_abort_proc abort, +Bool is_flip);void radeon_drm_abort_client (ClientPtr client);void radeon_drm_abort_entry (uintptr_t seq);void radeon_drm_abort_id (uint64_t id);
src/radeon_kms.c +6 -4
@@ -769,7 +769,8 @@ radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty)RADEON_DRM_QUEUE_CLIENT_DEFAULT ,RADEON_DRM_QUEUE_ID_DEFAULT ,NULL , radeon_prime_scanout_update_handler, - radeon_prime_scanout_update_abort); + radeon_prime_scanout_update_abort, + FALSE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"radeon_drm_queue_alloc failed for PRIME update\n" );
@@ -817,7 +818,7 @@ radeon_prime_scanout_flip(PixmapDirtyUpdatePtr ent)RADEON_DRM_QUEUE_ID_DEFAULT ,NULL , radeon_scanout_flip_handler, - radeon_scanout_flip_abort); + radeon_scanout_flip_abort, TRUE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM event queue entry failed for PRIME flip.\n" );
@@ -1053,7 +1054,8 @@ radeon_scanout_update(xf86CrtcPtr xf86_crtc)RADEON_DRM_QUEUE_ID_DEFAULT , drmmode_crtc, radeon_scanout_update_handler, - radeon_scanout_update_abort); + radeon_scanout_update_abort, + FALSE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"radeon_drm_queue_alloc failed for scanout update\n" );
@@ -1102,7 +1104,7 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info,RADEON_DRM_QUEUE_ID_DEFAULT ,NULL , radeon_scanout_flip_handler, - radeon_scanout_flip_abort); + radeon_scanout_flip_abort, TRUE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM event queue entry failed.\n" );
src/radeon_present.c +2 -1
@@ -157,7 +157,8 @@ radeon_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)RADEON_DRM_QUEUE_CLIENT_DEFAULT , event_id, event, radeon_present_vblank_handler, - radeon_present_vblank_abort); + radeon_present_vblank_abort, + FALSE);if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {free (event);return BadAlloc;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/13 Move deferred vblank events to separate drm_vblank_deferred list
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
It was still possible for nested xorg_list_for_each_entry_safe loops to occur over the drm_vblank_signalled list, which could mess up that list. Moving deferred events to a separate list allows processing the drm_vblank_signalled list without xorg_list_for_each_entry_safe.
Bugzilla: https://bugs.freedesktop.org/108600
(Ported from amdgpu commit 51ba6dddee40c3688d4c7b12eabeab516ed153b7)
--- src/radeon_drm_queue.c | 57 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 11 deletions(-)
src/radeon_drm_queue.c +46 -11
@@ -56,6 +56,7 @@ static int radeon_drm_queue_refcnt;static struct xorg_list radeon_drm_queue;static struct xorg_list radeon_drm_flip_signalled;static struct xorg_list radeon_drm_vblank_signalled; +static struct xorg_list radeon_drm_vblank_deferred;static uintptr_t radeon_drm_queue_seq;
@@ -111,6 +112,31 @@ radeon_drm_queue_handler(int fd, unsigned int frame, unsigned int sec, } } +/* +* Handle signalled vblank events. If we're waiting for a flip event, +* put events for that CRTC in the vblank_deferred list. +*/ +static void +radeon_drm_handle_vblank_signalled (void ) +{ +drmmode_crtc_private_ptr drmmode_crtc; +struct radeon_drm_queue_entry *e; + +while (!xorg_list_is_empty (&radeon_drm_vblank_signalled)) { + e =xorg_list_first_entry (&radeon_drm_vblank_signalled, + struct radeon_drm_queue_entry, list); + drmmode_crtc = e->crtc->driver_private; + +if (drmmode_crtc->wait_flip_nesting_level ==0 ) { +radeon_drm_queue_handle_one (e); +continue ; + } + +xorg_list_del (&e->list); +xorg_list_append (&e->list, &radeon_drm_vblank_deferred); + } +} +/* * Handle deferred DRM vblank events *
@@ -127,12 +153,18 @@ radeon_drm_queue_handle_deferred(xf86CrtcPtr crtc) --drmmode_crtc->wait_flip_nesting_level > 0) return; -xorg_list_for_each_entry_safe (e, tmp, &radeon_drm_vblank_signalled, list) { -drmmode_crtc_private_ptr drmmode_crtc = e->crtc->driver_private; +/* Put previously deferred vblank events for this CRTC back in the +* signalled queue +*/ +xorg_list_for_each_entry_safe (e, tmp, &radeon_drm_vblank_deferred, list) { +if (e->crtc != crtc) +continue ; -if (drmmode_crtc->wait_flip_nesting_level ==0 ) -radeon_drm_queue_handle_one (e); +xorg_list_del (&e->list); +xorg_list_append (&e->list, &radeon_drm_vblank_signalled); } + +radeon_drm_handle_vblank_signalled (); }/*
@@ -205,6 +237,13 @@ radeon_drm_abort_entry(uintptr_t seq) } } +xorg_list_for_each_entry_safe (e, tmp, &radeon_drm_vblank_deferred, list) { +if (e->seq == seq) { +radeon_drm_abort_one (e); +return ; + } + } +xorg_list_for_each_entry_safe (e, tmp, &radeon_drm_queue, list) {if (e->seq == seq) {radeon_drm_abort_one (e);
@@ -235,7 +274,7 @@ radeon_drm_abort_id(uint64_t id)int radeon_drm_handle_event (int fd,drmEventContext *event_context) { -struct radeon_drm_queue_entry *e, *tmp; +struct radeon_drm_queue_entry *e;int r; r =drmHandleEvent (fd, event_context);
@@ -246,12 +285,7 @@ radeon_drm_handle_event(int fd, drmEventContext *event_context)radeon_drm_queue_handle_one (e); } -xorg_list_for_each_entry_safe (e, tmp, &radeon_drm_vblank_signalled, list) { -drmmode_crtc_private_ptr drmmode_crtc = e->crtc->driver_private; - -if (drmmode_crtc->wait_flip_nesting_level ==0 ) -radeon_drm_queue_handle_one (e); - } +radeon_drm_handle_vblank_signalled ();return r; }
@@ -298,6 +332,7 @@ radeon_drm_queue_init(ScrnInfoPtr scrn)xorg_list_init (&radeon_drm_queue);xorg_list_init (&radeon_drm_flip_signalled);xorg_list_init (&radeon_drm_vblank_signalled); +xorg_list_init (&radeon_drm_vblank_deferred); }/*
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/13 Perform scanout buffer update immediately if drmmode_wait_vblank fails
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Otherwise the damaged screen contents may never be displayed in that case.
(Ported from amdgpu commit 500fadb16285146e91f62fce3a0ce1360ca684ba)
--- src/radeon_kms.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
src/radeon_kms.c +19 -10
@@ -752,6 +752,7 @@ radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty) {ScreenPtr screen = dirty->slave_dst->drawable.pScreen;ScrnInfoPtr scrn =xf86ScreenToScrn (screen); +RADEONEntPtr pRADEONEnt =RADEONEntPriv (scrn);xf86CrtcPtr xf86_crtc =radeon_prime_dirty_to_crtc (dirty);drmmode_crtc_private_ptr drmmode_crtc;uintptr_t drm_queue_seq;
@@ -774,19 +775,23 @@ radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty)if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"radeon_drm_queue_alloc failed for PRIME update\n" ); +radeon_prime_scanout_update_handler (xf86_crtc,0 ,0 ,NULL );return ; } + drmmode_crtc->scanout_update_pending = drm_queue_seq; +if (!drmmode_wait_vblank (xf86_crtc,DRM_VBLANK_RELATIVE |DRM_VBLANK_EVENT ,1 , drm_queue_seq,NULL ,NULL )) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"drmmode_wait_vblank failed for PRIME update: %s\n" ,strerror (errno)); -radeon_drm_abort_entry (drm_queue_seq); -return ; + drmmode_crtc->drmmode->event_context.vblank_handler (pRADEONEnt->fd, +0 ,0 ,0 , + (void *)drm_queue_seq); + drmmode_crtc->wait_flip_nesting_level++; +radeon_drm_queue_handle_deferred (xf86_crtc); } - - drmmode_crtc->scanout_update_pending = drm_queue_seq; } static void
@@ -1022,8 +1027,9 @@ static void radeon_scanout_update(xf86CrtcPtr xf86_crtc) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; +ScrnInfoPtr scrn = xf86_crtc->scrn; +RADEONEntPtr pRADEONEnt =RADEONEntPriv (scrn);uintptr_t drm_queue_seq; -ScrnInfoPtr scrn;DamagePtr pDamage;RegionPtr pRegion;BoxRec extents;
@@ -1048,7 +1054,6 @@ radeon_scanout_update(xf86CrtcPtr xf86_crtc)return ; } - scrn = xf86_crtc->scrn; drm_queue_seq = radeon_drm_queue_alloc(xf86_crtc, RADEON_DRM_QUEUE_CLIENT_DEFAULT, RADEON_DRM_QUEUE_ID_DEFAULT,
@@ -1059,19 +1064,23 @@ radeon_scanout_update(xf86CrtcPtr xf86_crtc)if (drm_queue_seq ==RADEON_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"radeon_drm_queue_alloc failed for scanout update\n" ); +radeon_scanout_update_handler (xf86_crtc,0 ,0 , drmmode_crtc);return ; } + drmmode_crtc->scanout_update_pending = drm_queue_seq; +if (!drmmode_wait_vblank (xf86_crtc,DRM_VBLANK_RELATIVE |DRM_VBLANK_EVENT ,1 , drm_queue_seq,NULL ,NULL )) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"drmmode_wait_vblank failed for scanout update: %s\n" ,strerror (errno)); -radeon_drm_abort_entry (drm_queue_seq); -return ; + drmmode_crtc->drmmode->event_context.vblank_handler (pRADEONEnt->fd, +0 ,0 ,0 , + (void *)drm_queue_seq); + drmmode_crtc->wait_flip_nesting_level++; +radeon_drm_queue_handle_deferred (xf86_crtc); } - - drmmode_crtc->scanout_update_pending = drm_queue_seq; } static void
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/13 Cancel pending scanout update in drmmode_crtc_scanout_update
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
drmmode_crtc_scanout_update does the equivalent of a scanout update, so no need to do it again. This might also avoid issues if there's a pending scanout update at this point.
(Ported from amdgpu commit 4e7a24ac5a64e402146953ec5850d13c05742116)
--- src/drmmode_display.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
src/drmmode_display.c +11 -5
@@ -781,11 +781,17 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode, *fb =radeon_pixmap_get_fb (drmmode_crtc->scanout[scanout_id].pixmap); *x = *y =0 ; -radeon_scanout_do_update (crtc, scanout_id, - screen->GetWindowPixmap (screen->root), - extents); -RegionEmpty (DamageRegion (drmmode_crtc->scanout_damage)); -radeon_finish (scrn, drmmode_crtc->scanout[scanout_id].bo); +if (radeon_scanout_do_update (crtc, scanout_id, + screen->GetWindowPixmap (screen->root), + extents)) { +RegionEmpty (DamageRegion (drmmode_crtc->scanout_damage)); +radeon_glamor_finish (scrn); + +if (!drmmode_crtc->flip_pending) { +radeon_drm_abort_entry (drmmode_crtc-> + scanout_update_pending); + } + } } }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/13 Automatically try re-enabling TearFree after a flip failed
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Specifically, after both the page flip and vblank ioctls failed, but then the vblank ioctl started working again. This can happen intermittently e.g. when hotplugging a DP display. Previously, TearFree would stay disabled in that case until a modeset was triggered somehow.
Bugzilla: https://bugs.freedesktop.org/103791
(Ported from amdgpu commit bcfa6c258fdf41a9928f8a3c78fc528d0fafee25)
--- src/drmmode_display.h | 7 ++++ src/radeon_kms.c | 75 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 11 deletions(-)
src/drmmode_display.h +7 -0
@@ -71,6 +71,12 @@ struct drmmode_fb {uint32_t handle; }; +enum drmmode_scanout_status { +DRMMODE_SCANOUT_OK , +DRMMODE_SCANOUT_FLIP_FAILED =1u <<0 , +DRMMODE_SCANOUT_VBLANK_FAILED =1u <<1 , +}; +struct drmmode_scanout {struct radeon_buffer *bo;PixmapPtr pixmap;
@@ -90,6 +96,7 @@ typedef struct {unsigned scanout_id;uintptr_t scanout_update_pending;Bool tear_free; +enum drmmode_scanout_status scanout_status;PixmapPtr prime_scanout_pixmap;
src/radeon_kms.c +64 -11
121 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/13 Drop RADEONInfoRec::cursor_bo array
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Not needed or even useful for anything.
(Ported from amdgpu commit e95044e45350870fa7e237860e89ade91ac03550)
--- src/drmmode_display.c | 9 --------- src/drmmode_display.h | 1 - src/radeon.h | 1 - src/radeon_kms.c | 21 +++++++++++---------- 4 files changed, 11 insertions(+), 21 deletions(-)
src/drmmode_display.c +0 -9
@@ -2967,15 +2967,6 @@ miPointerSpriteFuncRec drmmode_sprite_funcs = { }; -void drmmode_set_cursor (ScrnInfoPtr scrn,drmmode_ptr drmmode,int id,struct radeon_bo *bo) -{ -xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (scrn); -xf86CrtcPtr crtc = xf86_config->crtc[id]; -drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; - - drmmode_crtc->cursor_bo = bo; -} -void drmmode_adjust_frame (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int x,int y) {xf86CrtcConfigPtr config =XF86_CRTC_CONFIG_PTR (pScrn);
src/drmmode_display.h +0 -1
@@ -213,7 +213,6 @@ 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);extern Bool drmmode_set_bufmgr (ScrnInfoPtr pScrn,drmmode_ptr drmmode,struct radeon_bo_manager *bufmgr); -extern void drmmode_set_cursor (ScrnInfoPtr scrn,drmmode_ptr drmmode,int id,struct radeon_bo *bo);void drmmode_adjust_frame (ScrnInfoPtr pScrn,drmmode_ptr drmmode,int x,int y);extern Bool drmmode_set_desired_modes (ScrnInfoPtr pScrn,drmmode_ptr drmmode,Bool set_hw);
src/radeon.h +0 -1
@@ -572,7 +572,6 @@ typedef struct {struct radeon_cs_manager *csm;struct radeon_cs *cs; -struct radeon_bo *cursor_bo[32 ];uint64_t vram_size;uint64_t gart_size;drmmode_rec drmmode;
src/radeon_kms.c +11 -10
@@ -2760,21 +2760,20 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen) cursor_size = info->cursor_w * info->cursor_h *4 ; cursor_size =RADEON_ALIGN (cursor_size,RADEON_GPU_PAGE_SIZE );for (c =0 ; c < xf86_config->num_crtc; c++) { -/* cursor objects */ -if (!info->cursor_bo[c]) { - info->cursor_bo[c] =radeon_bo_open (info->bufmgr,0 , - cursor_size,0 , -RADEON_GEM_DOMAIN_VRAM ,0 ); -if (!info->cursor_bo[c]) { +drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[c]->driver_private; + +if (!drmmode_crtc->cursor_bo) { + drmmode_crtc->cursor_bo =radeon_bo_open (info->bufmgr,0 , + cursor_size,0 , +RADEON_GEM_DOMAIN_VRAM ,0 ); +if (!(drmmode_crtc->cursor_bo)) {ErrorF ("Failed to allocate cursor buffer memory\n" );return FALSE; } -if (radeon_bo_map (info->cursor_bo[c],1 )) { +if (radeon_bo_map (drmmode_crtc->cursor_bo,1 )) {ErrorF ("Failed to map cursor buffer memory\n" ); } - -drmmode_set_cursor (pScrn, &info->drmmode, c, info->cursor_bo[c]); } } }
@@ -2840,7 +2839,9 @@ void radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, uint32_t new_fb_size)int c;for (c =0 ; c < xf86_config->num_crtc; c++) { -if (info->cursor_bo[c]) +drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[c]->driver_private; + +if (drmmode_crtc->cursor_bo) new_fb_size += (64 *4 *64 ); }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/13 Use drmIoctl in drmmode_show_cursor
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
This should be functionally equivalent to what drmModeSetCursor(2) do behind the scenes, but allows for new tricks in following changes.
(Ported from amdgpu commit b344e1559e936046ef02c777fc4f6bcefa3830bc)
--- src/drmmode_display.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
src/drmmode_display.c +14 -7
@@ -1202,8 +1202,16 @@ drmmode_show_cursor (xf86CrtcPtr crtc)RADEONInfoPtr info =RADEONPTR (pScrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;RADEONEntPtr pRADEONEnt =RADEONEntPriv (pScrn); -uint32_t handle = drmmode_crtc->cursor_bo->handle;static Bool use_set_cursor2 = TRUE; +struct drm_mode_cursor2 arg; + +memset (&arg,0 ,sizeof (arg)); + + arg.handle = drmmode_crtc->cursor_bo->handle; + arg.flags =DRM_MODE_CURSOR_BO ; + arg.crtc_id = drmmode_crtc->mode_crtc->crtc_id; + arg.width = info->cursor_w; + arg.height = info->cursor_h;if (use_set_cursor2) {xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (crtc->scrn);
@@ -1240,18 +1248,17 @@ drmmode_show_cursor (xf86CrtcPtr crtc) } } - ret = -drmModeSetCursor2 (pRADEONEnt->fd, drmmode_crtc->mode_crtc->crtc_id, - handle, info->cursor_w, info->cursor_h, - xhot, yhot); + arg.hot_x = xhot; + arg.hot_y = yhot; + + ret =drmIoctl (pRADEONEnt->fd,DRM_IOCTL_MODE_CURSOR2 , &arg);if (ret == -EINVAL ) use_set_cursor2 = FALSE;else return ; } -drmModeSetCursor (pRADEONEnt->fd, drmmode_crtc->mode_crtc->crtc_id, handle, - info->cursor_w, info->cursor_h); +drmIoctl (pRADEONEnt->fd,DRM_IOCTL_MODE_CURSOR , &arg); }/* Xorg expects a non-NULL return value from drmmode_crtc_shadow_allocate, and
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/13 Update cursor position in drmmode_show_cursor if hotspot changed
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
The cursor position is updated to be consistent with the new hotspot in the same ioctl call.
(Ported from amdgpu commit b04697de5270e8e45744a7025c24df1f454a4cf0)
--- src/drmmode_display.c | 75 +++++++++++++++++++++++++------------------ src/drmmode_display.h | 5 +++ 2 files changed, 48 insertions(+), 32 deletions(-)
src/drmmode_display.c +43 -32
@@ -1017,6 +1017,9 @@ drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y) }#endif + drmmode_crtc->cursor_x = x; + drmmode_crtc->cursor_y = y; +drmModeMoveCursor (pRADEONEnt->fd, drmmode_crtc->mode_crtc->crtc_id, x, y); }
@@ -1202,6 +1205,10 @@ drmmode_show_cursor (xf86CrtcPtr crtc)RADEONInfoPtr info =RADEONPTR (pScrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;RADEONEntPtr pRADEONEnt =RADEONEntPriv (pScrn); +xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (pScrn); +CursorPtr cursor = xf86_config->cursor; +int xhot = cursor->bits->xhot; +int yhot = cursor->bits->yhot;static Bool use_set_cursor2 = TRUE;struct drm_mode_cursor2 arg;
@@ -1213,41 +1220,45 @@ drmmode_show_cursor (xf86CrtcPtr crtc) arg.width = info->cursor_w; arg.height = info->cursor_h; +if (crtc->rotation != RR_Rotate_0 && + crtc->rotation != (RR_Rotate_180 | RR_Reflect_X | + RR_Reflect_Y)) { +int t; + +/* Reflect & rotate hotspot position */ +if (crtc->rotation & RR_Reflect_X) + xhot = info->cursor_w - xhot -1 ; +if (crtc->rotation & RR_Reflect_Y) + yhot = info->cursor_h - yhot -1 ; + +switch (crtc->rotation &0xf ) { +case RR_Rotate_90: + t = xhot; + xhot = yhot; + yhot = info->cursor_w - t -1 ; +break ; +case RR_Rotate_180: + xhot = info->cursor_w - xhot -1 ; + yhot = info->cursor_h - yhot -1 ; +break ; +case RR_Rotate_270: + t = xhot; + xhot = info->cursor_h - yhot -1 ; + yhot = t; + } + } + +if (xhot != drmmode_crtc->cursor_xhot || yhot != drmmode_crtc->cursor_yhot) { + arg.flags |=DRM_MODE_CURSOR_MOVE ; + arg.x = drmmode_crtc->cursor_x += drmmode_crtc->cursor_xhot - xhot; + arg.y = drmmode_crtc->cursor_y += drmmode_crtc->cursor_yhot - yhot; + drmmode_crtc->cursor_xhot = xhot; + drmmode_crtc->cursor_yhot = yhot; + } +if (use_set_cursor2) { -xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (crtc->scrn); -CursorPtr cursor = xf86_config->cursor; -int xhot = cursor->bits->xhot; -int yhot = cursor->bits->yhot;int ret; -if (crtc->rotation != RR_Rotate_0 && - crtc->rotation != (RR_Rotate_180 | RR_Reflect_X | - RR_Reflect_Y)) { -int t; - -/* Reflect & rotate hotspot position */ -if (crtc->rotation & RR_Reflect_X) - xhot = info->cursor_w - xhot -1 ; -if (crtc->rotation & RR_Reflect_Y) - yhot = info->cursor_h - yhot -1 ; - -switch (crtc->rotation &0xf ) { -case RR_Rotate_90: - t = xhot; - xhot = yhot; - yhot = info->cursor_w - t -1 ; -break ; -case RR_Rotate_180: - xhot = info->cursor_w - xhot -1 ; - yhot = info->cursor_h - yhot -1 ; -break ; -case RR_Rotate_270: - t = xhot; - xhot = info->cursor_h - yhot -1 ; - yhot = t; - } - } - arg.hot_x = xhot; arg.hot_y = yhot;
src/drmmode_display.h +5 -0
@@ -87,6 +87,11 @@ typedef struct {drmmode_ptr drmmode;drmModeCrtcPtr mode_crtc;int hw_id; + +int cursor_x; +int cursor_y; +int cursor_xhot; +int cursor_yhot;struct radeon_bo *cursor_bo;struct drmmode_scanout rotate;struct drmmode_scanout scanout[2 ];
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/13 Use two HW cursor buffers per CRTC
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Switch to the other buffer when xf86_config->cursor changes. Avoids these issues possible when re-using the same buffer:
* The HW may intermittently display a mix of the old and new cursor images.
* If the hotspot changes, the HW may intermittently display the new cursor image at the location corresponding to the old image's hotspot.
Bugzilla: https://bugs.freedesktop.org/108832
(Ported from amdgpu commit 0d60233d26ec70d4e1faa343b438e33829c6d5e4)
--- src/drmmode_display.c | 18 +++++++++++++++--- src/drmmode_display.h | 5 ++++- src/radeon_kms.c | 34 ++++++++++++++++++---------------- 3 files changed, 37 insertions(+), 20 deletions(-)
src/drmmode_display.c +15 -3
@@ -1122,13 +1122,18 @@ drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)ScrnInfoPtr pScrn = crtc->scrn;RADEONInfoPtr info =RADEONPTR (pScrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +unsigned id = drmmode_crtc->cursor_id;Bool premultiplied = TRUE;Bool apply_gamma = TRUE;uint32_t argb;uint32_t *ptr; +if (drmmode_crtc->cursor && +XF86_CRTC_CONFIG_PTR (pScrn)->cursor != drmmode_crtc->cursor) + id ^=1 ; +/* cursor should be mapped already */ - ptr = (uint32_t *)(drmmode_crtc->cursor_bo->ptr); + ptr = (uint32_t *)(drmmode_crtc->cursor_bo[id]->ptr);if (crtc->scrn->depth !=24 && crtc->scrn->depth !=32 ) apply_gamma = FALSE;
@@ -1170,6 +1175,11 @@ retry: ptr[i] =cpu_to_le32 (argb); } } + +if (id != drmmode_crtc->cursor_id) { + drmmode_crtc->cursor_id = id; + crtc->funcs->show_cursor (crtc); + } }#if XORG_VERSION_CURRENT >=XORG_VERSION_NUMERIC (1 ,15 ,99 ,903 ,0 )
@@ -1195,7 +1205,7 @@ drmmode_hide_cursor (xf86CrtcPtr crtc)drmModeSetCursor (pRADEONEnt->fd, drmmode_crtc->mode_crtc->crtc_id,0 , info->cursor_w, info->cursor_h); - + drmmode_crtc->cursor =NULL ; } static void
@@ -1212,9 +1222,11 @@ drmmode_show_cursor (xf86CrtcPtr crtc)static Bool use_set_cursor2 = TRUE;struct drm_mode_cursor2 arg; + drmmode_crtc->cursor = xf86_config->cursor; +memset (&arg,0 ,sizeof (arg)); - arg.handle = drmmode_crtc->cursor_bo->handle; + arg.handle = drmmode_crtc->cursor_bo[drmmode_crtc->cursor_id]->handle; arg.flags =DRM_MODE_CURSOR_BO ; arg.crtc_id = drmmode_crtc->mode_crtc->crtc_id; arg.width = info->cursor_w;
src/drmmode_display.h +4 -1
@@ -88,11 +88,14 @@ typedef struct {drmModeCrtcPtr mode_crtc;int hw_id; +CursorPtr cursor;int cursor_x;int cursor_y;int cursor_xhot;int cursor_yhot; -struct radeon_bo *cursor_bo; +unsigned cursor_id; +struct radeon_bo *cursor_bo[2 ]; +struct drmmode_scanout rotate;struct drmmode_scanout scanout[2 ];DamagePtr scanout_damage;
src/radeon_kms.c +18 -16
@@ -2755,27 +2755,29 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen) {int cursor_size; -int c; +int c, i; cursor_size = info->cursor_w * info->cursor_h *4 ; cursor_size =RADEON_ALIGN (cursor_size,RADEON_GPU_PAGE_SIZE );for (c =0 ; c < xf86_config->num_crtc; c++) {drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[c]->driver_private; -if (!drmmode_crtc->cursor_bo) { - drmmode_crtc->cursor_bo =radeon_bo_open (info->bufmgr,0 , - cursor_size,0 , -RADEON_GEM_DOMAIN_VRAM ,0 ); -if (!(drmmode_crtc->cursor_bo)) { -ErrorF ("Failed to allocate cursor buffer memory\n" ); -return FALSE; - } - -if (radeon_bo_map (drmmode_crtc->cursor_bo,1 )) { -ErrorF ("Failed to map cursor buffer memory\n" ); - } - } - } +for (i =0 ; i <2 ; i++) { +if (!drmmode_crtc->cursor_bo[i]) { + drmmode_crtc->cursor_bo[i] = +radeon_bo_open (info->bufmgr,0 , cursor_size,0 , +RADEON_GEM_DOMAIN_VRAM ,0 ); + +if (!(drmmode_crtc->cursor_bo[i])) { +ErrorF ("Failed to allocate cursor buffer memory\n" ); +return FALSE; + } + +if (radeon_bo_map (drmmode_crtc->cursor_bo[i],1 )) +ErrorF ("Failed to map cursor buffer memory\n" ); + } + } + } }if (!info->front_buffer) {
@@ -2841,7 +2843,7 @@ void radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, uint32_t new_fb_size)for (c =0 ; c < xf86_config->num_crtc; c++) {drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[c]->driver_private; -if (drmmode_crtc->cursor_bo) +if (drmmode_crtc->cursor_bo[0 ]) new_fb_size += (64 *4 *64 ); }
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx