kmssink: add sync support for secondary pipes
authorPhilipp Zabel <p.zabel@pengutronix.de>
Thu, 14 Apr 2016 10:46:58 +0000 (12:46 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 19 Apr 2016 09:10:49 +0000 (11:10 +0200)
The vblank event request must specify the crtc for which to request
the event. This fixes kmssink synchronisation for crtcs other than
the first.

https://bugzilla.gnome.org/show_bug.cgi?id=765064

sys/kms/gstkmssink.c
sys/kms/gstkmssink.h

index 11f0185..9c849a3 100644 (file)
@@ -125,7 +125,8 @@ find_plane_for_crtc (int fd, drmModeRes * res, drmModePlaneRes * pres,
 }
 
 static drmModeCrtc *
-find_crtc_for_connector (int fd, drmModeRes * res, drmModeConnector * conn)
+find_crtc_for_connector (int fd, drmModeRes * res, drmModeConnector * conn,
+    guint * pipe)
 {
   int i;
   int crtc_id;
@@ -151,8 +152,11 @@ find_crtc_for_connector (int fd, drmModeRes * res, drmModeConnector * conn)
   for (i = 0; i < res->count_crtcs; i++) {
     crtc = drmModeGetCrtc (fd, res->crtcs[i]);
     if (crtc) {
-      if (crtc_id == crtc->crtc_id)
+      if (crtc_id == crtc->crtc_id) {
+        if (pipe)
+          *pipe = i;
         return crtc;
+      }
       drmModeFreeCrtc (crtc);
     }
   }
@@ -167,7 +171,7 @@ connector_is_used (int fd, drmModeRes * res, drmModeConnector * conn)
   drmModeCrtc *crtc;
 
   result = FALSE;
-  crtc = find_crtc_for_connector (fd, res, conn);
+  crtc = find_crtc_for_connector (fd, res, conn, NULL);
   if (crtc) {
     result = crtc->buffer_id != 0;
     drmModeFreeCrtc (crtc);
@@ -376,7 +380,7 @@ gst_kms_sink_start (GstBaseSink * bsink)
   if (!conn)
     goto connector_failed;
 
-  crtc = find_crtc_for_connector (self->fd, res, conn);
+  crtc = find_crtc_for_connector (self->fd, res, conn, &self->pipe);
   if (!crtc)
     goto crtc_failed;
 
@@ -794,6 +798,11 @@ gst_kms_sink_sync (GstKMSSink * self)
         },
   };
 
+  if (self->pipe == 1)
+    vbl.request.type |= DRM_VBLANK_SECONDARY;
+  else if (self->pipe > 1)
+    vbl.request.type |= self->pipe << DRM_VBLANK_HIGH_CRTC_SHIFT;
+
   waiting = TRUE;
   if (!self->has_async_page_flip) {
     ret = drmWaitVBlank (self->fd, &vbl);
index 317afbc..494f440 100644 (file)
@@ -52,6 +52,7 @@ struct _GstKMSSink {
   gint conn_id;
   gint crtc_id;
   gint plane_id;
+  guint pipe;
 
   /* crtc data */
   guint16 hdisplay, vdisplay;