Add CRTC ID to vblank event

When using the atomic API, one request can span multiple CRTCs, however
one event is generated per CRTC. As we cannot disambiguate the CRTC with
user data (since we only have one piece of user data to pass in), newer
kernels can include the CRTC ID in the page flip event.

Add a new vfunc to dispatch vblank events carrying a CRTC ID to clients
who negotiate a higher interface version.

[daniels: Rebased, include new cap, call page_flip_handler if it is set
          but page_flip_handler2 isn't even on newer contexts, write a
	  commit message.]

v2: Split into separate commit.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@intel.com>
main
Ander Conselvan de Oliveira 2015-08-17 16:21:24 +03:00 committed by Daniel Stone
parent e379c6a137
commit 890d43a6a8
2 changed files with 24 additions and 9 deletions

View File

@ -728,7 +728,7 @@ extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
extern int drmSetMaster(int fd); extern int drmSetMaster(int fd);
extern int drmDropMaster(int fd); extern int drmDropMaster(int fd);
#define DRM_EVENT_CONTEXT_VERSION 2 #define DRM_EVENT_CONTEXT_VERSION 3
typedef struct _drmEventContext { typedef struct _drmEventContext {
@ -748,6 +748,13 @@ typedef struct _drmEventContext {
unsigned int tv_usec, unsigned int tv_usec,
void *user_data); void *user_data);
void (*page_flip_handler2)(int fd,
unsigned int sequence,
unsigned int tv_sec,
unsigned int tv_usec,
unsigned int crtc_id,
void *user_data);
} drmEventContext, *drmEventContextPtr; } drmEventContext, *drmEventContextPtr;
extern int drmHandleEvent(int fd, drmEventContextPtr evctx); extern int drmHandleEvent(int fd, drmEventContextPtr evctx);

View File

@ -889,6 +889,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
int len, i; int len, i;
struct drm_event *e; struct drm_event *e;
struct drm_event_vblank *vblank; struct drm_event_vblank *vblank;
void *user_data;
/* The DRM read semantics guarantees that we always get only /* The DRM read semantics guarantees that we always get only
* complete events. */ * complete events. */
@ -915,15 +916,22 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
U642VOID (vblank->user_data)); U642VOID (vblank->user_data));
break; break;
case DRM_EVENT_FLIP_COMPLETE: case DRM_EVENT_FLIP_COMPLETE:
if (evctx->version < 2 ||
evctx->page_flip_handler == NULL)
break;
vblank = (struct drm_event_vblank *) e; vblank = (struct drm_event_vblank *) e;
evctx->page_flip_handler(fd, user_data = U642VOID (vblank->user_data);
vblank->sequence,
vblank->tv_sec, if (evctx->version >= 3 && evctx->page_flip_handler2)
vblank->tv_usec, evctx->page_flip_handler2(fd,
U642VOID (vblank->user_data)); vblank->sequence,
vblank->tv_sec,
vblank->tv_usec,
vblank->crtc_id,
user_data);
else if (evctx->version >= 2 && evctx->page_flip_handler)
evctx->page_flip_handler(fd,
vblank->sequence,
vblank->tv_sec,
vblank->tv_usec,
user_data);
break; break;
default: default:
break; break;