summaryrefslogtreecommitdiff
path: root/src
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 /src
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>
Diffstat (limited to 'src')
-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
5 files changed, 43 insertions, 34 deletions
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,