summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2016-03-18 17:18:00 +0900
committerMichel Dänzer <michel@daenzer.net>2016-03-23 18:58:26 +0900
commitb9d00fa7aaf946d985897380bfa42faafbf1b3fb (patch)
treec5af283703ec553fba494609135108952fac793d
parente0ed26151bfeadf309da53d001751c0a014dbd24 (diff)
Make DRM event queue xf86CrtcPtr based instead of ScrnInfoPtr based
This allows for a minor simplification of the code. (Ported from radeon commit f5d968cbba3c9b7ec202161f2157d8d64778c817) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/amdgpu_dri2.c42
-rw-r--r--src/amdgpu_drm_queue.c14
-rw-r--r--src/amdgpu_drm_queue.h8
-rw-r--r--src/amdgpu_drv.h2
-rw-r--r--src/amdgpu_kms.c21
-rw-r--r--src/amdgpu_present.c18
-rw-r--r--src/drmmode_display.c86
-rw-r--r--src/drmmode_display.h6
8 files changed, 86 insertions, 111 deletions
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 6867959..5778268 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -524,19 +524,20 @@ xf86CrtcPtr amdgpu_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled)
}
static void
-amdgpu_dri2_flip_event_abort(ScrnInfoPtr scrn, void *event_data)
+amdgpu_dri2_flip_event_abort(xf86CrtcPtr crtc, void *event_data)
{
- AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+ AMDGPUInfoPtr info = AMDGPUPTR(crtc->scrn);
info->drmmode.dri2_flipping = FALSE;
free(event_data);
}
static void
-amdgpu_dri2_flip_event_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec,
+amdgpu_dri2_flip_event_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec,
void *event_data)
{
DRI2FrameEventPtr flip = event_data;
+ ScrnInfoPtr scrn = crtc->scrn;
unsigned tv_sec, tv_usec;
DrawablePtr drawable;
ScreenPtr screen;
@@ -548,9 +549,7 @@ amdgpu_dri2_flip_event_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec,
if (status != Success)
goto abort;
- if (!flip->crtc)
- goto abort;
- frame += amdgpu_get_msc_delta(drawable, flip->crtc);
+ frame += amdgpu_get_msc_delta(drawable, crtc);
screen = scrn->pScreen;
pixmap = screen->GetScreenPixmap(screen);
@@ -589,21 +588,20 @@ amdgpu_dri2_flip_event_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec,
}
abort:
- amdgpu_dri2_flip_event_abort(scrn, event_data);
+ amdgpu_dri2_flip_event_abort(crtc, event_data);
}
static Bool
-amdgpu_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client,
+amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,
DrawablePtr draw, DRI2BufferPtr front,
DRI2BufferPtr back, DRI2SwapEventPtr func,
void *data, unsigned int target_msc)
{
+ ScrnInfoPtr scrn = crtc->scrn;
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
struct dri2_buffer_priv *back_priv;
DRI2FrameEventPtr flip_info;
- /* Main crtc for this drawable shall finally deliver pageflip event. */
- xf86CrtcPtr crtc = amdgpu_dri2_drawable_crtc(draw, FALSE);
- int ref_crtc_hw_id = crtc ? drmmode_get_crtc_id(crtc) : -1;
+ int ref_crtc_hw_id = drmmode_get_crtc_id(crtc);
flip_info = calloc(1, sizeof(DRI2FrameEventRec));
if (!flip_info)
@@ -752,7 +750,7 @@ amdgpu_dri2_exchange_buffers(DrawablePtr draw, DRI2BufferPtr front,
DamageRegionProcessPending(&front_priv->pixmap->drawable);
}
-static void amdgpu_dri2_frame_event_abort(ScrnInfoPtr scrn, void *event_data)
+static void amdgpu_dri2_frame_event_abort(xf86CrtcPtr crtc, void *event_data)
{
DRI2FrameEventPtr event = event_data;
@@ -763,30 +761,28 @@ static void amdgpu_dri2_frame_event_abort(ScrnInfoPtr scrn, void *event_data)
free(event);
}
-static void amdgpu_dri2_frame_event_handler(ScrnInfoPtr scrn, uint32_t seq,
+static void amdgpu_dri2_frame_event_handler(xf86CrtcPtr crtc, uint32_t seq,
uint64_t usec, void *event_data)
{
DRI2FrameEventPtr event = event_data;
+ ScrnInfoPtr scrn = crtc->scrn;
DrawablePtr drawable;
int status;
int swap_type;
BoxRec box;
RegionRec region;
- if (!event->crtc)
- goto cleanup;
-
status = dixLookupDrawable(&drawable, event->drawable_id, serverClient,
M_ANY, DixWriteAccess);
if (status != Success)
goto cleanup;
- seq += amdgpu_get_msc_delta(drawable, event->crtc);
+ seq += amdgpu_get_msc_delta(drawable, crtc);
switch (event->type) {
case DRI2_FLIP:
if (can_flip(scrn, drawable, event->front, event->back) &&
- amdgpu_dri2_schedule_flip(scrn,
+ amdgpu_dri2_schedule_flip(crtc,
event->client,
drawable,
event->front,
@@ -833,7 +829,7 @@ static void amdgpu_dri2_frame_event_handler(ScrnInfoPtr scrn, uint32_t seq,
}
cleanup:
- amdgpu_dri2_frame_event_abort(scrn, event_data);
+ amdgpu_dri2_frame_event_abort(crtc, event_data);
}
drmVBlankSeqType amdgpu_populate_vbl_request_type(xf86CrtcPtr crtc)
@@ -990,7 +986,7 @@ CARD32 amdgpu_dri2_deferred_event(OsTimerPtr timer, CARD32 now, pointer data)
amdgpu_drm_queue_handler(pAMDGPUEnt->fd, 0, 0, 0,
event_info->drm_queue);
else
- amdgpu_dri2_frame_event_handler(scrn, 0, 0, data);
+ amdgpu_dri2_frame_event_handler(crtc, 0, 0, data);
return 0;
}
/*
@@ -1006,7 +1002,7 @@ CARD32 amdgpu_dri2_deferred_event(OsTimerPtr timer, CARD32 now, pointer data)
amdgpu_drm_queue_handler(pAMDGPUEnt->fd, frame, drm_now / 1000000,
drm_now % 1000000, event_info->drm_queue);
else
- amdgpu_dri2_frame_event_handler(scrn, frame, drm_now, data);
+ amdgpu_dri2_frame_event_handler(crtc, frame, drm_now, data);
return 0;
}
@@ -1091,7 +1087,7 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
current_msc = vbl.reply.sequence + msc_delta;
current_msc &= 0xffffffff;
- wait = amdgpu_drm_queue_alloc(scrn, client, AMDGPU_DRM_QUEUE_ID_DEFAULT,
+ wait = amdgpu_drm_queue_alloc(crtc, client, AMDGPU_DRM_QUEUE_ID_DEFAULT,
wait_info, amdgpu_dri2_frame_event_handler,
amdgpu_dri2_frame_event_abort);
if (!wait) {
@@ -1239,7 +1235,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
swap_info->back = back;
swap_info->crtc = crtc;
- swap = amdgpu_drm_queue_alloc(scrn, client, AMDGPU_DRM_QUEUE_ID_DEFAULT,
+ swap = amdgpu_drm_queue_alloc(crtc, client, AMDGPU_DRM_QUEUE_ID_DEFAULT,
swap_info, amdgpu_dri2_frame_event_handler,
amdgpu_dri2_frame_event_abort);
if (!swap) {
diff --git a/src/amdgpu_drm_queue.c b/src/amdgpu_drm_queue.c
index b5aead2..11b74a0 100644
--- a/src/amdgpu_drm_queue.c
+++ b/src/amdgpu_drm_queue.c
@@ -42,7 +42,7 @@ struct amdgpu_drm_queue_entry {
uint64_t id;
void *data;
ClientPtr client;
- ScrnInfoPtr scrn;
+ xf86CrtcPtr crtc;
amdgpu_drm_handler_proc handler;
amdgpu_drm_abort_proc abort;
};
@@ -65,11 +65,11 @@ amdgpu_drm_queue_handler(int fd, unsigned int frame, unsigned int sec,
if (e == user_data) {
xorg_list_del(&e->list);
if (e->handler)
- e->handler(e->scrn, frame,
+ e->handler(e->crtc, frame,
(uint64_t)sec * 1000000 + usec,
e->data);
else
- e->abort(e->scrn, e->data);
+ e->abort(e->crtc, e->data);
free(e);
break;
}
@@ -81,7 +81,7 @@ amdgpu_drm_queue_handler(int fd, unsigned int frame, unsigned int sec,
* appears, we've got data to pass to the handler from here
*/
struct amdgpu_drm_queue_entry *
-amdgpu_drm_queue_alloc(ScrnInfoPtr scrn, ClientPtr client,
+amdgpu_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
uint64_t id, void *data,
amdgpu_drm_handler_proc handler,
amdgpu_drm_abort_proc abort)
@@ -93,7 +93,7 @@ amdgpu_drm_queue_alloc(ScrnInfoPtr scrn, ClientPtr client,
return NULL;
e->client = client;
- e->scrn = scrn;
+ e->crtc = crtc;
e->id = id;
e->data = data;
e->handler = handler;
@@ -113,7 +113,7 @@ static void
amdgpu_drm_abort_one(struct amdgpu_drm_queue_entry *e)
{
xorg_list_del(&e->list);
- e->abort(e->scrn, e->data);
+ e->abort(e->crtc, e->data);
free(e);
}
@@ -181,7 +181,7 @@ amdgpu_drm_queue_close(ScrnInfoPtr scrn)
struct amdgpu_drm_queue_entry *e, *tmp;
xorg_list_for_each_entry_safe(e, tmp, &amdgpu_drm_queue, list) {
- if (e->scrn == scrn)
+ if (e->crtc->scrn == scrn)
amdgpu_drm_abort_one(e);
}
diff --git a/src/amdgpu_drm_queue.h b/src/amdgpu_drm_queue.h
index 96841f6..892ba13 100644
--- a/src/amdgpu_drm_queue.h
+++ b/src/amdgpu_drm_queue.h
@@ -29,19 +29,21 @@
#ifndef _AMDGPU_DRM_QUEUE_H_
#define _AMDGPU_DRM_QUEUE_H_
+#include <xf86Crtc.h>
+
#define AMDGPU_DRM_QUEUE_CLIENT_DEFAULT serverClient
#define AMDGPU_DRM_QUEUE_ID_DEFAULT ~0ULL
struct amdgpu_drm_queue_entry;
-typedef void (*amdgpu_drm_handler_proc)(ScrnInfoPtr scrn, uint32_t seq,
+typedef void (*amdgpu_drm_handler_proc)(xf86CrtcPtr crtc, uint32_t seq,
uint64_t usec, void *data);
-typedef void (*amdgpu_drm_abort_proc)(ScrnInfoPtr scrn, void *data);
+typedef void (*amdgpu_drm_abort_proc)(xf86CrtcPtr crtc, void *data);
void amdgpu_drm_queue_handler(int fd, unsigned int frame,
unsigned int tv_sec, unsigned int tv_usec,
void *user_ptr);
-struct amdgpu_drm_queue_entry *amdgpu_drm_queue_alloc(ScrnInfoPtr scrn,
+struct amdgpu_drm_queue_entry *amdgpu_drm_queue_alloc(xf86CrtcPtr crtc,
ClientPtr client,
uint64_t id,
void *data,
diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index 0e7b3b5..3b074fc 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -282,7 +282,7 @@ typedef struct {
Bool amdgpu_dri3_screen_init(ScreenPtr screen);
/* amdgpu_kms.c */
-void amdgpu_scanout_update_handler(ScrnInfoPtr scrn, uint32_t frame,
+void amdgpu_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame,
uint64_t usec, void *event_data);
/* amdgpu_present.c */
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index e6e3d5f..be8c2bf 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -309,21 +309,20 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id)
}
static void
-amdgpu_scanout_update_abort(ScrnInfoPtr scrn, void *event_data)
+amdgpu_scanout_update_abort(xf86CrtcPtr crtc, void *event_data)
{
- xf86CrtcPtr xf86_crtc = event_data;
- drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
+ drmmode_crtc_private_ptr drmmode_crtc = event_data;
drmmode_crtc->scanout_update_pending = FALSE;
}
void
-amdgpu_scanout_update_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec,
+amdgpu_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec,
void *event_data)
{
- amdgpu_scanout_do_update(event_data, 0);
+ amdgpu_scanout_do_update(crtc, 0);
- amdgpu_scanout_update_abort(scrn, event_data);
+ amdgpu_scanout_update_abort(crtc, event_data);
}
static void
@@ -360,9 +359,10 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc)
return;
scrn = xf86_crtc->scrn;
- drm_queue_entry = amdgpu_drm_queue_alloc(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
+ drm_queue_entry = amdgpu_drm_queue_alloc(xf86_crtc,
+ AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
AMDGPU_DRM_QUEUE_ID_DEFAULT,
- xf86_crtc,
+ drmmode_crtc,
amdgpu_scanout_update_handler,
amdgpu_scanout_update_abort);
if (!drm_queue_entry) {
@@ -388,7 +388,7 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc)
}
static void
-amdgpu_scanout_flip_abort(ScrnInfoPtr scrn, void *event_data)
+amdgpu_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)
{
drmmode_crtc_private_ptr drmmode_crtc = event_data;
@@ -413,7 +413,8 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
return;
scrn = xf86_crtc->scrn;
- drm_queue_entry = amdgpu_drm_queue_alloc(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
+ drm_queue_entry = amdgpu_drm_queue_alloc(xf86_crtc,
+ AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
AMDGPU_DRM_QUEUE_ID_DEFAULT,
drmmode_crtc, NULL,
amdgpu_scanout_flip_abort);
diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c
index 73ebb4c..5de1d19 100644
--- a/src/amdgpu_present.c
+++ b/src/amdgpu_present.c
@@ -50,7 +50,7 @@
struct amdgpu_present_vblank_event {
uint64_t event_id;
- xf86CrtcPtr crtc;
+ Bool unflip;
};
static uint32_t crtc_select(int crtc_id)
@@ -125,7 +125,7 @@ amdgpu_present_flush_drm_events(ScreenPtr screen)
* Called when the queued vblank event has occurred
*/
static void
-amdgpu_present_vblank_handler(ScrnInfoPtr scrn, unsigned int msc,
+amdgpu_present_vblank_handler(xf86CrtcPtr crtc, unsigned int msc,
uint64_t usec, void *data)
{
struct amdgpu_present_vblank_event *event = data;
@@ -138,7 +138,7 @@ amdgpu_present_vblank_handler(ScrnInfoPtr scrn, unsigned int msc,
* Called when the queued vblank is aborted
*/
static void
-amdgpu_present_vblank_abort(ScrnInfoPtr scrn, void *data)
+amdgpu_present_vblank_abort(xf86CrtcPtr crtc, void *data)
{
struct amdgpu_present_vblank_event *event = data;
@@ -166,7 +166,7 @@ amdgpu_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
if (!event)
return BadAlloc;
event->event_id = event_id;
- queue = amdgpu_drm_queue_alloc(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
+ queue = amdgpu_drm_queue_alloc(xf86_crtc, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
event_id, event,
amdgpu_present_vblank_handler,
amdgpu_present_vblank_abort);
@@ -257,12 +257,12 @@ amdgpu_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap,
* extension code telling it when that happened
*/
static void
-amdgpu_present_flip_event(ScrnInfoPtr scrn, uint32_t msc, uint64_t ust, void *pageflip_data)
+amdgpu_present_flip_event(xf86CrtcPtr crtc, uint32_t msc, uint64_t ust, void *pageflip_data)
{
- AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+ AMDGPUInfoPtr info = AMDGPUPTR(crtc->scrn);
struct amdgpu_present_vblank_event *event = pageflip_data;
- if (!event->crtc)
+ if (event->unflip)
info->drmmode.present_flipping = FALSE;
present_event_notify(event->event_id, ust, msc);
@@ -273,7 +273,7 @@ amdgpu_present_flip_event(ScrnInfoPtr scrn, uint32_t msc, uint64_t ust, void *pa
* The flip has been aborted, free the structure
*/
static void
-amdgpu_present_flip_abort(ScrnInfoPtr scrn, void *pageflip_data)
+amdgpu_present_flip_abort(xf86CrtcPtr crtc, void *pageflip_data)
{
struct amdgpu_present_vblank_event *event = pageflip_data;
@@ -304,7 +304,6 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,
return FALSE;
event->event_id = event_id;
- event->crtc = xf86_crtc;
ret = amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
pixmap, event_id, event, crtc_id,
@@ -341,6 +340,7 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)
}
event->event_id = event_id;
+ event->unflip = TRUE;
if (amdgpu_do_pageflip(scrn, AMDGPU_DRM_QUEUE_CLIENT_DEFAULT, pixmap,
event_id, event, -1, amdgpu_present_flip_event,
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 7316226..2ce9f3d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -698,7 +698,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
fb_id = drmmode_crtc->scanout[0].fb_id;
x = y = 0;
- amdgpu_scanout_update_handler(pScrn, 0, 0, crtc);
+ amdgpu_scanout_update_handler(crtc, 0, 0, drmmode_crtc);
amdgpu_glamor_finish(pScrn);
}
}
@@ -1855,55 +1855,43 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
};
static void
-drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier)
+drmmode_flip_abort(xf86CrtcPtr crtc, void *event_data)
{
- drmmode_flipdata_ptr flipdata = flipcarrier->flipdata;
+ drmmode_flipdata_ptr flipdata = event_data;
- free(flipcarrier);
-
- if (--flipdata->flip_count > 0)
- return;
-
- free(flipdata);
-}
-
-static void
-drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data)
-{
- drmmode_flipevtcarrier_ptr flipcarrier = event_data;
- drmmode_flipdata_ptr flipdata = flipcarrier->flipdata;
-
- if (flipdata->flip_count == 1)
- flipdata->abort(scrn, flipdata->event_data);
-
- drmmode_flip_free(flipcarrier);
+ if (--flipdata->flip_count == 0) {
+ if (flipdata->fe_crtc)
+ crtc = flipdata->fe_crtc;
+ flipdata->abort(crtc, flipdata->event_data);
+ free(flipdata);
+ }
}
static void
-drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *event_data)
+drmmode_flip_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec, void *event_data)
{
- drmmode_flipevtcarrier_ptr flipcarrier = event_data;
- drmmode_flipdata_ptr flipdata = flipcarrier->flipdata;
+ AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
+ drmmode_flipdata_ptr flipdata = event_data;
/* Is this the event whose info shall be delivered to higher level? */
- if (flipcarrier->dispatch_me) {
+ if (crtc == flipdata->fe_crtc) {
/* Yes: Cache msc, ust for later delivery. */
flipdata->fe_frame = frame;
flipdata->fe_usec = usec;
}
- if (flipdata->flip_count == 1) {
+ if (--flipdata->flip_count == 0) {
/* Deliver cached msc, ust from reference crtc to flip event handler */
- if (flipdata->event_data)
- flipdata->handler(scrn, flipdata->fe_frame,
- flipdata->fe_usec,
- flipdata->event_data);
+ if (flipdata->fe_crtc)
+ crtc = flipdata->fe_crtc;
+ flipdata->handler(crtc, flipdata->fe_frame, flipdata->fe_usec,
+ flipdata->event_data);
/* Release framebuffer */
- drmModeRmFB(flipdata->fd, flipdata->old_fb_id);
- }
+ drmModeRmFB(pAMDGPUEnt->fd, flipdata->old_fb_id);
- drmmode_flip_free(flipcarrier);
+ free(flipdata);
+ }
}
static void drm_wakeup_handler(pointer data, int err, pointer p)
@@ -2340,11 +2328,11 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
{
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CrtcPtr crtc = NULL;
drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0]->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
int i;
- drmmode_flipdata_ptr flipdata = NULL;
- drmmode_flipevtcarrier_ptr flipcarrier = NULL;
+ drmmode_flipdata_ptr flipdata;
struct amdgpu_drm_queue_entry *drm_queue = NULL;
uint32_t new_front_handle;
@@ -2382,33 +2370,26 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
*/
flipdata->event_data = data;
- flipdata->fd = pAMDGPUEnt->fd;
flipdata->handler = handler;
flipdata->abort = abort;
for (i = 0; i < config->num_crtc; i++) {
- if (!config->crtc[i]->enabled)
+ crtc = config->crtc[i];
+
+ if (!crtc->enabled)
continue;
flipdata->flip_count++;
- drmmode_crtc = config->crtc[i]->driver_private;
-
- flipcarrier = calloc(1, sizeof(drmmode_flipevtcarrier_rec));
- if (!flipcarrier) {
- xf86DrvMsg(scrn->scrnIndex, X_WARNING,
- "flip queue: carrier alloc failed.\n");
- goto error;
- }
+ drmmode_crtc = crtc->driver_private;
/* Only the reference crtc will finally deliver its page flip
* completion event. All other crtc's events will be discarded.
*/
- flipcarrier->dispatch_me =
- (drmmode_crtc->hw_id == ref_crtc_hw_id);
- flipcarrier->flipdata = flipdata;
+ if (drmmode_crtc->hw_id == ref_crtc_hw_id)
+ flipdata->fe_crtc = crtc;
- drm_queue = amdgpu_drm_queue_alloc(scrn, client, id,
- flipcarrier,
+ drm_queue = amdgpu_drm_queue_alloc(crtc, client, id,
+ flipdata,
drmmode_flip_handler,
drmmode_flip_abort);
if (!drm_queue) {
@@ -2424,7 +2405,6 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
"flip queue failed: %s\n", strerror(errno));
goto error;
}
- flipcarrier = NULL;
drm_queue = NULL;
}
@@ -2439,8 +2419,8 @@ error:
if (drm_queue)
amdgpu_drm_abort_entry(drm_queue);
- else if (flipcarrier)
- drmmode_flip_abort(scrn, flipcarrier);
+ else if (crtc)
+ drmmode_flip_abort(crtc, flipdata);
else if (flipdata && flipdata->flip_count <= 1)
free(flipdata);
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 92b7457..e5e5de6 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -65,15 +65,11 @@ typedef struct {
void *event_data;
unsigned int fe_frame;
uint64_t fe_usec;
+ xf86CrtcPtr fe_crtc;
amdgpu_drm_handler_proc handler;
amdgpu_drm_abort_proc abort;
} drmmode_flipdata_rec, *drmmode_flipdata_ptr;
-typedef struct {
- drmmode_flipdata_ptr flipdata;
- Bool dispatch_me;
-} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr;
-
struct drmmode_scanout {
struct amdgpu_buffer *bo;
PixmapPtr pixmap;