[PATCH xf86-video-amdgpu 2/4] Make amdgpu_do_pageflip take a pixmap instead of a BO
Michel Dänzer
michel at daenzer.net
Wed Feb 24 09:49:15 UTC 2016
From: Michel Dänzer <michel.daenzer at amd.com>
(inspired by radeon commit 7b4fc4a677d252d01c2bf80d162bc35814059eaa)
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/amdgpu_dri2.c | 8 +++-----
src/amdgpu_present.c | 18 +++---------------
src/drmmode_display.c | 30 ++++++++++--------------------
src/drmmode_display.h | 2 +-
4 files changed, 17 insertions(+), 41 deletions(-)
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 230e8ba..d974cb8 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -595,7 +595,6 @@ amdgpu_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client,
{
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
struct dri2_buffer_priv *back_priv;
- struct amdgpu_buffer *bo = NULL;
DRI2FrameEventPtr flip_info;
/* Main crtc for this drawable shall finally deliver pageflip event. */
xf86CrtcPtr crtc = amdgpu_dri2_drawable_crtc(draw, FALSE);
@@ -618,10 +617,9 @@ amdgpu_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client,
/* Page flip the full screen buffer */
back_priv = back->driverPrivate;
- bo = amdgpu_get_pixmap_bo(back_priv->pixmap);
-
- if (amdgpu_do_pageflip(scrn, client, bo, AMDGPU_DRM_QUEUE_ID_DEFAULT,
- flip_info, ref_crtc_hw_id,
+ if (amdgpu_do_pageflip(scrn, client, back_priv->pixmap,
+ AMDGPU_DRM_QUEUE_ID_DEFAULT, flip_info,
+ ref_crtc_hw_id,
amdgpu_dri2_flip_event_handler,
amdgpu_dri2_flip_event_abort)) {
info->drmmode.dri2_flipping = TRUE;
diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 07d7ef7..73ebb4c 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -294,16 +294,11 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
struct amdgpu_present_vblank_event *event;
xf86CrtcPtr xf86_crtc = crtc->devPrivate;
int crtc_id = xf86_crtc ? drmmode_get_crtc_id(xf86_crtc) : -1;
- struct amdgpu_buffer *bo;
Bool ret;
if (!amdgpu_present_check_flip(crtc, screen->root, pixmap, sync_flip))
return FALSE;
- bo = amdgpu_get_pixmap_bo(pixmap);
- if (!bo)
- return FALSE;
-
event = calloc(1, sizeof(struct amdgpu_present_vblank_event));
if (!event)
return FALSE;
@@ -311,8 +306,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
event->event_id = event_id;
event->crtc = xf86_crtc;
- ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, bo,
- event_id, event, crtc_id,
+ ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
+ pixmap, event_id, event, crtc_id,
amdgpu_present_flip_event,
amdgpu_present_flip_abort);
if (!ret)
@@ -334,18 +329,11 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
struct amdgpu_present_vblank_event *event;
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
- struct amdgpu_buffer *bo;
int i;
if (!amdgpu_present_check_flip(NULL, screen->root, pixmap, TRUE))
goto modeset;
- bo = amdgpu_get_pixmap_bo(pixmap);
- if (!bo) {
- ErrorF("%s: amdgpu_get_pixmap_bo failed, display might freeze\n", __func__);
- goto modeset;
- }
-
event = calloc(1, sizeof(struct amdgpu_present_vblank_event));
if (!event) {
ErrorF("%s: calloc failed, display might freeze\n", __func__);
@@ -354,7 +342,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
event->event_id = event_id;
- if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, bo,
+ if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, pixmap,
event_id, event, -1, amdgpu_present_flip_event,
amdgpu_present_flip_abort))
return;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 896b9d2..658eb90 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2307,7 +2307,7 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
}
Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
- struct amdgpu_buffer *new_front, uint64_t id, void *data,
+ PixmapPtr new_front, uint64_t id, void *data,
int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
amdgpu_drm_abort_proc abort)
{
@@ -2315,27 +2315,16 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0]->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- unsigned int pitch;
int i;
- int height;
drmmode_flipdata_ptr flipdata = NULL;
drmmode_flipevtcarrier_ptr flipcarrier = NULL;
struct amdgpu_drm_queue_entry *drm_queue = NULL;
- union gbm_bo_handle bo_handle;
- uint32_t handle;
+ uint32_t new_front_handle;
- if (new_front->flags & AMDGPU_BO_FLAGS_GBM) {
- pitch = gbm_bo_get_stride(new_front->bo.gbm);
- height = gbm_bo_get_height(new_front->bo.gbm);
- bo_handle = gbm_bo_get_handle(new_front->bo.gbm);
- handle = bo_handle.u32;
- } else {
- pitch = scrn->displayWidth;
- height = scrn->virtualY;
- if (amdgpu_bo_export(new_front->bo.amdgpu,
- amdgpu_bo_handle_type_kms,
- &handle))
- goto error;
+ if (!amdgpu_pixmap_get_handle(new_front, &new_front_handle)) {
+ xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+ "flip queue: data alloc failed.\n");
+ return FALSE;
}
flipdata = calloc(1, sizeof(drmmode_flipdata_rec));
@@ -2349,9 +2338,10 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
* Create a new handle for the back buffer
*/
flipdata->old_fb_id = drmmode->fb_id;
- if (drmModeAddFB(pAMDGPUEnt->fd, scrn->virtualX, height,
- scrn->depth, scrn->bitsPerPixel, pitch,
- handle, &drmmode->fb_id))
+ if (drmModeAddFB(pAMDGPUEnt->fd, new_front->drawable.width,
+ new_front->drawable.height, scrn->depth,
+ scrn->bitsPerPixel, new_front->devKind,
+ new_front_handle, &drmmode->fb_id))
goto error;
/*
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index f1e6dc3..92b7457 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -144,7 +144,7 @@ extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
extern int drmmode_get_crtc_id(xf86CrtcPtr crtc);
extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe);
Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
- struct amdgpu_buffer *new_front, uint64_t id, void *data,
+ PixmapPtr new_front, uint64_t id, void *data,
int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
amdgpu_drm_abort_proc abort);
int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
--
2.7.0
More information about the xorg-driver-ati
mailing list