summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2015-10-26 15:33:27 +0000
committerRussell King <rmk@arm.linux.org.uk>2015-10-26 19:38:57 +0000
commit16786f7d7b37c8df49d506ec0565da5afc8e4324 (patch)
treea21b6f3b8f23cfe1dfd617d203cb8af2c5251519
parentef389167b5a505b75bf89aa85bd57bc651f0aa74 (diff)
src: prepare to convert to 64-bit msc
Prepare conversion to 64-bit MSC support. Signed-off-by: Russell King <rmk@arm.linux.org.uk>
-rw-r--r--etnaviv/etnaviv_dri2.c42
-rw-r--r--src/common_drm.c39
-rw-r--r--src/common_drm.h4
-rw-r--r--src/common_drm_dri2.c28
-rw-r--r--src/common_drm_dri2.h2
-rw-r--r--src/common_drm_helper.h4
-rw-r--r--vivante/vivante_dri2.c42
7 files changed, 81 insertions, 80 deletions
diff --git a/etnaviv/etnaviv_dri2.c b/etnaviv/etnaviv_dri2.c
index 97bfc34..ba88636 100644
--- a/etnaviv/etnaviv_dri2.c
+++ b/etnaviv/etnaviv_dri2.c
@@ -119,7 +119,7 @@ static void etnaviv_dri2_CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
}
static void etnaviv_dri2_blit(ClientPtr client, DrawablePtr draw,
- DRI2BufferPtr front, DRI2BufferPtr back, unsigned frame,
+ DRI2BufferPtr front, DRI2BufferPtr back, uint64_t msc,
unsigned tv_sec, unsigned tv_usec, DRI2SwapEventPtr func, void *data)
{
RegionRec region;
@@ -133,24 +133,24 @@ static void etnaviv_dri2_blit(ClientPtr client, DrawablePtr draw,
etnaviv_dri2_CopyRegion(draw, &region, front, back);
- DRI2SwapComplete(client, draw, frame, tv_sec, tv_usec,
+ DRI2SwapComplete(client, draw, msc, tv_sec, tv_usec,
DRI2_BLIT_COMPLETE, func, data);
}
static void etnaviv_dri2_swap(struct common_dri2_wait *wait, DrawablePtr draw,
- unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
etnaviv_dri2_blit(wait->client, draw, wait->front, wait->back,
- frame, tv_sec, tv_usec,
+ msc, tv_sec, tv_usec,
wait->client ? wait->swap_func : NULL,
wait->swap_data);
common_dri2_wait_free(wait);
}
static void etnaviv_dri2_flip_complete(struct common_dri2_wait *wait,
- DrawablePtr draw, unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ DrawablePtr draw, uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
- DRI2SwapComplete(wait->client, draw, frame, tv_sec, tv_usec,
+ DRI2SwapComplete(wait->client, draw, msc, tv_sec, tv_usec,
DRI2_FLIP_COMPLETE,
wait->client ? wait->swap_func : NULL,
wait->swap_data);
@@ -186,13 +186,13 @@ static Bool etnaviv_dri2_ScheduleFlip(DrawablePtr drawable,
}
static void etnaviv_dri2_flip(struct common_dri2_wait *wait, DrawablePtr draw,
- unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
if (common_dri2_can_flip(draw, wait) &&
etnaviv_dri2_ScheduleFlip(draw, wait))
return;
- etnaviv_dri2_swap(wait, draw, frame, tv_sec, tv_usec);
+ etnaviv_dri2_swap(wait, draw, msc, tv_sec, tv_usec);
}
static int etnaviv_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
@@ -201,8 +201,7 @@ static int etnaviv_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(draw->pScreen);
struct common_dri2_wait *wait;
- drmVBlank vbl;
- CARD64 cur_msc;
+ CARD64 cur_msc, cur_ust, tgt_msc;
xf86CrtcPtr crtc;
int ret;
@@ -229,12 +228,9 @@ static int etnaviv_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
common_dri2_buffer_reference(front);
common_dri2_buffer_reference(back);
- ret = common_drm_vblank_get(pScrn, crtc, &vbl, __FUNCTION__);
- if (ret)
+ if (common_drm_get_msc(crtc, &cur_ust, &cur_msc) != Success)
goto blit_free;
- cur_msc = vbl.reply.sequence;
-
/* Flips need to be submitted one frame before */
if (common_dri2_can_flip(draw, wait)) {
wait->event_func = etnaviv_dri2_flip;
@@ -269,9 +265,9 @@ static int etnaviv_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
if (cur_msc > *target_msc)
*target_msc = cur_msc;
- vbl.request.sequence = *target_msc;
+ tgt_msc = *target_msc;
} else {
- vbl.request.sequence = cur_msc - (cur_msc % divisor) + remainder;
+ tgt_msc = cur_msc - (cur_msc % divisor) + remainder;
/*
* If the calculated deadline sequence is smaller than or equal
@@ -284,21 +280,21 @@ static int etnaviv_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
* DRM_VBLANK_NEXTONMISS delay if we are blitting/exchanging
* instead of flipping.
*/
- if (vbl.request.sequence <= cur_msc)
- vbl.request.sequence += divisor;
+ if (tgt_msc <= cur_msc)
+ tgt_msc += divisor;
- /* Account for 1 frame extra pageflip delay if flip > 0 */
- if (wait->type == DRI2_FLIP)
- vbl.request.sequence -= 1;
+ /* Account for 1 frame extra pageflip delay if flip > 0 */
+ if (wait->type == DRI2_FLIP)
+ tgt_msc -= 1;
}
- ret = common_drm_vblank_queue_event(pScrn, crtc, &vbl, __FUNCTION__,
+ ret = common_drm_queue_msc_event(pScrn, crtc, &tgt_msc, __FUNCTION__,
wait->type != DRI2_FLIP,
&wait->base);
if (ret)
goto blit_free;
- *target_msc = vbl.reply.sequence + (wait->type == DRI2_FLIP);
+ *target_msc = tgt_msc + (wait->type == DRI2_FLIP);
wait->frame = *target_msc;
return TRUE;
diff --git a/src/common_drm.c b/src/common_drm.c
index db71134..b641a14 100644
--- a/src/common_drm.c
+++ b/src/common_drm.c
@@ -112,6 +112,16 @@ static void drmmode_ConvertFromKMode(ScrnInfoPtr pScrn,
xf86SetModeCrtc (mode, pScrn->adjustFlags);
}
+static uint64_t common_drm_frame_to_msc(xf86CrtcPtr crtc, uint32_t seq)
+{
+ return seq;
+}
+
+static uint32_t common_drm_msc_to_frame(xf86CrtcPtr crtc, uint64_t msc)
+{
+ return msc;
+}
+
static drmModePropertyPtr common_drm_conn_find_property(
struct common_conn_info *conn, const char *name, uint32_t *blob)
{
@@ -726,8 +736,9 @@ static void common_drm_event(int fd, unsigned int frame, unsigned int tv_sec,
unsigned int tv_usec, void *event_data)
{
struct common_drm_event *event = event_data;
+ uint64_t msc = common_drm_frame_to_msc(event->crtc, frame);
- event->handler(event, frame, tv_sec, tv_usec);
+ event->handler(event, msc, tv_sec, tv_usec);
}
Bool common_drm_init_mode_resources(ScrnInfoPtr pScrn,
@@ -783,12 +794,12 @@ Bool common_drm_init_mode_resources(ScrnInfoPtr pScrn,
}
static void common_drm_flip_handler(struct common_drm_event *event,
- unsigned int frame, unsigned int tv_sec, unsigned int tv_usec)
+ uint64_t msc, unsigned int tv_sec, unsigned int tv_usec)
{
struct common_drm_info *drm = event->drm;
if (drm->flip_ref_crtc == event->crtc) {
- drm->flip_frame = frame;
+ drm->flip_msc = msc;
drm->flip_tv_sec = tv_sec;
drm->flip_tv_usec = tv_usec;
}
@@ -803,7 +814,7 @@ static void common_drm_flip_handler(struct common_drm_event *event,
/* Now pass the event on to the flip complete event handler */
event = drm->flip_event;
if (event)
- event->handler(event, drm->flip_frame, drm->flip_tv_sec,
+ event->handler(event, drm->flip_msc, drm->flip_tv_sec,
drm->flip_tv_usec);
}
@@ -863,7 +874,7 @@ Bool common_drm_flip(ScrnInfoPtr pScrn, PixmapPtr pixmap,
if (drm->flip_count) {
drm->flip_event = event;
drm->flip_ref_crtc = ref_crtc;
- drm->flip_frame = 0;
+ drm->flip_msc = 0;
drm->flip_tv_sec = 0;
drm->flip_tv_usec = 0;
drm->flip_old_fb_id = old_fb_id;
@@ -1389,31 +1400,35 @@ int common_drm_get_msc(xf86CrtcPtr crtc, uint64_t *ust, uint64_t *msc)
return BadMatch;
*ust = ((CARD64)vbl.reply.tval_sec * 1000000) + vbl.reply.tval_usec;
- *msc = vbl.reply.sequence;
+ *msc = common_drm_frame_to_msc(crtc, vbl.reply.sequence);
return Success;
}
_X_EXPORT
-int common_drm_vblank_queue_event(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
- drmVBlank *vbl, const char *func, Bool nextonmiss,
+int common_drm_queue_msc_event(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
+ uint64_t *msc, const char *func, Bool nextonmiss,
struct common_drm_event *event)
{
struct common_drm_info *drm = GET_DRM_INFO(pScrn);
+ drmVBlank vbl;
int ret;
- vbl->request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT |
+ vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT |
req_crtc(crtc);
- vbl->request.signal = (unsigned long)event;
+ vbl.request.sequence = common_drm_msc_to_frame(crtc, *msc);
+ vbl.request.signal = (unsigned long)event;
if (nextonmiss)
- vbl->request.type |= DRM_VBLANK_NEXTONMISS;
+ vbl.request.type |= DRM_VBLANK_NEXTONMISS;
- ret = drmWaitVBlank(drm->fd, vbl);
+ ret = drmWaitVBlank(drm->fd, &vbl);
if (ret)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"%s: %s failed: %s\n", func,
__FUNCTION__, strerror(errno));
+ else
+ *msc = common_drm_frame_to_msc(crtc, vbl.reply.sequence);
return ret;
}
diff --git a/src/common_drm.h b/src/common_drm.h
index 647ed1b..f187c32 100644
--- a/src/common_drm.h
+++ b/src/common_drm.h
@@ -34,9 +34,9 @@ struct common_drm_info {
struct common_drm_event *flip_event;
xf86CrtcPtr flip_ref_crtc;
unsigned int flip_count;
- unsigned int flip_frame;
unsigned int flip_tv_sec;
unsigned int flip_tv_usec;
+ uint64_t flip_msc;
uint32_t flip_old_fb_id;
Bool has_hw_cursor;
@@ -59,7 +59,7 @@ struct common_drm_info {
struct common_drm_event {
struct common_drm_info *drm;
xf86CrtcPtr crtc;
- void (*handler)(struct common_drm_event *, unsigned int frame,
+ void (*handler)(struct common_drm_event *, uint64_t msc,
unsigned int tv_sec, unsigned int tv_usec);
};
diff --git a/src/common_drm_dri2.c b/src/common_drm_dri2.c
index 95f44f5..30fbf80 100644
--- a/src/common_drm_dri2.c
+++ b/src/common_drm_dri2.c
@@ -64,7 +64,7 @@ static Bool common_dri2_add_reslist(XID id, RESTYPE type,
return TRUE;
}
-static void common_dri2_event(struct common_drm_event *event, unsigned frame,
+static void common_dri2_event(struct common_drm_event *event, uint64_t msc,
unsigned tv_sec, unsigned tv_usec)
{
struct common_dri2_wait *wait = container_of(event, struct common_dri2_wait, base);
@@ -74,7 +74,7 @@ static void common_dri2_event(struct common_drm_event *event, unsigned frame,
dixLookupDrawable(&draw, wait->drawable_id, serverClient, M_ANY,
DixWriteAccess) == Success) {
if (wait->event_func) {
- wait->event_func(wait, draw, frame, tv_sec, tv_usec);
+ wait->event_func(wait, draw, msc, tv_sec, tv_usec);
return;
}
@@ -282,10 +282,10 @@ int common_dri2_GetMSC(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
}
static void common_dri2_waitmsc(struct common_dri2_wait *wait,
- DrawablePtr draw, unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ DrawablePtr draw, uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
if (wait->client)
- DRI2WaitMSCComplete(wait->client, draw, frame, tv_sec, tv_usec);
+ DRI2WaitMSCComplete(wait->client, draw, msc, tv_sec, tv_usec);
common_dri2_wait_free(wait);
}
@@ -296,8 +296,7 @@ Bool common_dri2_ScheduleWaitMSC(ClientPtr client, DrawablePtr draw,
ScrnInfoPtr pScrn = xf86ScreenToScrn(draw->pScreen);
xf86CrtcPtr crtc;
struct common_dri2_wait *wait;
- drmVBlank vbl;
- CARD64 cur_msc;
+ CARD64 cur_msc, cur_ust;
int ret;
/*
@@ -319,12 +318,9 @@ Bool common_dri2_ScheduleWaitMSC(ClientPtr client, DrawablePtr draw,
wait->event_func = common_dri2_waitmsc;
/* Get current count */
- ret = common_drm_vblank_get(pScrn, crtc, &vbl, __FUNCTION__);
- if (ret)
+ if (common_drm_get_msc(crtc, &cur_ust, &cur_msc) != Success)
goto del_wait;
- cur_msc = vbl.reply.sequence;
-
/*
* If the divisor is zero, or cur_msc is smaller than target_msc, we
* just need to make sure target_msc passes before waking up the client.
@@ -332,15 +328,13 @@ Bool common_dri2_ScheduleWaitMSC(ClientPtr client, DrawablePtr draw,
if (divisor == 0 || cur_msc < target_msc) {
if (cur_msc >= target_msc)
target_msc = cur_msc;
-
- vbl.request.sequence = target_msc;
} else {
/*
* If we get here, target_msc has already passed or we
* don't have one, so queue an event that will satisfy
* the divisor/remainder equation.
*/
- vbl.request.sequence = cur_msc - (cur_msc % divisor) + remainder;
+ target_msc = cur_msc - (cur_msc % divisor) + remainder;
/*
* If calculated remainder is larger than requested
@@ -349,15 +343,15 @@ Bool common_dri2_ScheduleWaitMSC(ClientPtr client, DrawablePtr draw,
* the next time that will happen.
*/
if ((cur_msc & divisor) >= remainder)
- vbl.request.sequence += divisor;
+ target_msc += divisor;
}
- ret = common_drm_vblank_queue_event(pScrn, crtc, &vbl, __FUNCTION__,
- FALSE, &wait->base);
+ ret = common_drm_queue_msc_event(pScrn, crtc, &target_msc, __FUNCTION__,
+ FALSE, &wait->base);
if (ret)
goto del_wait;
- wait->frame = vbl.reply.sequence;
+ wait->frame = target_msc;
DRI2BlockClient(client, draw);
return TRUE;
diff --git a/src/common_drm_dri2.h b/src/common_drm_dri2.h
index 2495269..4ca1d6c 100644
--- a/src/common_drm_dri2.h
+++ b/src/common_drm_dri2.h
@@ -33,7 +33,7 @@ struct common_dri2_wait {
struct common_dri2_wait *next;
void (*event_func)(struct common_dri2_wait *wait, DrawablePtr draw,
- unsigned frame, unsigned tv_sec, unsigned tv_usec);
+ uint64_t msc, unsigned tv_sec, unsigned tv_usec);
enum common_dri2_event_type type;
int frame;
diff --git a/src/common_drm_helper.h b/src/common_drm_helper.h
index 7b59033..e8704c6 100644
--- a/src/common_drm_helper.h
+++ b/src/common_drm_helper.h
@@ -15,8 +15,8 @@ int common_drm_vblank_get(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
int common_drm_get_msc(xf86CrtcPtr crtc, uint64_t *ust, uint64_t *msc);
-int common_drm_vblank_queue_event(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
- drmVBlank *vbl, const char *func, Bool nextonmiss,
+int common_drm_queue_msc_event(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
+ uint64_t *msc, const char *func, Bool nextonmiss,
struct common_drm_event *event);
int common_drm_vblank_wait(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
diff --git a/vivante/vivante_dri2.c b/vivante/vivante_dri2.c
index c5429ae..9c64256 100644
--- a/vivante/vivante_dri2.c
+++ b/vivante/vivante_dri2.c
@@ -122,9 +122,9 @@ vivante_dri2_CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
}
static void vivante_dri2_flip_complete(struct common_dri2_wait *wait,
- DrawablePtr draw, unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ DrawablePtr draw, uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
- DRI2SwapComplete(wait->client, draw, frame, tv_sec, tv_usec,
+ DRI2SwapComplete(wait->client, draw, msc, tv_sec, tv_usec,
DRI2_FLIP_COMPLETE,
wait->client ? wait->swap_func : NULL,
wait->swap_data);
@@ -161,7 +161,7 @@ static Bool vivante_dri2_ScheduleFlip(DrawablePtr drawable,
static void
vivante_dri2_blit(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
- DRI2BufferPtr back, unsigned frame, unsigned tv_sec, unsigned tv_usec,
+ DRI2BufferPtr back, uint64_t msc, unsigned tv_sec, unsigned tv_usec,
DRI2SwapEventPtr func, void *data)
{
RegionRec region;
@@ -175,28 +175,28 @@ vivante_dri2_blit(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
vivante_dri2_CopyRegion(draw, &region, front, back);
- DRI2SwapComplete(client, draw, frame, tv_sec, tv_usec,
+ DRI2SwapComplete(client, draw, msc, tv_sec, tv_usec,
DRI2_BLIT_COMPLETE, func, data);
}
static void vivante_dri2_swap(struct common_dri2_wait *wait, DrawablePtr draw,
- unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
vivante_dri2_blit(wait->client, draw, wait->front, wait->back,
- frame, tv_sec, tv_usec,
+ msc, tv_sec, tv_usec,
wait->client ? wait->swap_func : NULL,
wait->swap_data);
common_dri2_wait_free(wait);
}
static void vivante_dri2_flip(struct common_dri2_wait *wait, DrawablePtr draw,
- unsigned frame, unsigned tv_sec, unsigned tv_usec)
+ uint64_t msc, unsigned tv_sec, unsigned tv_usec)
{
if (common_dri2_can_flip(draw, wait) &&
vivante_dri2_ScheduleFlip(draw, wait))
return;
- vivante_dri2_swap(wait, draw, frame, tv_sec, tv_usec);
+ vivante_dri2_swap(wait, draw, msc, tv_sec, tv_usec);
}
static int
@@ -207,8 +207,7 @@ vivante_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
ScrnInfoPtr pScrn = xf86ScreenToScrn(draw->pScreen);
struct common_dri2_wait *wait;
xf86CrtcPtr crtc;
- drmVBlank vbl;
- CARD64 cur_msc;
+ CARD64 cur_msc, cur_ust, tgt_msc;
int ret;
crtc = common_drm_drawable_covering_crtc(draw);
@@ -234,12 +233,9 @@ vivante_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
common_dri2_buffer_reference(front);
common_dri2_buffer_reference(back);
- ret = common_drm_vblank_get(pScrn, crtc, &vbl, __FUNCTION__);
- if (ret)
+ if (common_drm_get_msc(crtc, &cur_ust, &cur_msc) != Success)
goto blit_free;
- cur_msc = vbl.reply.sequence;
-
/* Flips need to be submitted one frame before */
if (common_dri2_can_flip(draw, wait)) {
wait->event_func = vivante_dri2_flip;
@@ -274,9 +270,9 @@ vivante_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
if (cur_msc > *target_msc)
*target_msc = cur_msc;
- vbl.request.sequence = *target_msc;
+ tgt_msc = *target_msc;
} else {
- vbl.request.sequence = cur_msc - (cur_msc % divisor) + remainder;
+ tgt_msc = cur_msc - (cur_msc % divisor) + remainder;
/*
* If the calculated deadline sequence is smaller than or equal
@@ -289,21 +285,21 @@ vivante_dri2_ScheduleSwap(ClientPtr client, DrawablePtr draw,
* DRM_VBLANK_NEXTONMISS delay if we are blitting/exchanging
* instead of flipping.
*/
- if (vbl.request.sequence <= cur_msc)
- vbl.request.sequence += divisor;
+ if (tgt_msc <= cur_msc)
+ tgt_msc += divisor;
- /* Account for 1 frame extra pageflip delay if flip > 0 */
- if (wait->type == DRI2_FLIP)
- vbl.request.sequence -= 1;
+ /* Account for 1 frame extra pageflip delay if flip > 0 */
+ if (wait->type == DRI2_FLIP)
+ tgt_msc -= 1;
}
- ret = common_drm_vblank_queue_event(pScrn, crtc, &vbl, __FUNCTION__,
+ ret = common_drm_queue_msc_event(pScrn, crtc, &tgt_msc, __FUNCTION__,
wait->type != DRI2_FLIP,
&wait->base);
if (ret)
goto blit_free;
- *target_msc = vbl.reply.sequence + (wait->type == DRI2_FLIP);
+ *target_msc = tgt_msc + (wait->type == DRI2_FLIP);
wait->frame = *target_msc;
return TRUE;