kmssink: fallback to universal planes if no overlay plane is found
authorJavier Martinez Canillas <javier@osg.samsung.com>
Tue, 28 Jun 2016 20:07:43 +0000 (16:07 -0400)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Thu, 30 Jun 2016 09:54:37 +0000 (11:54 +0200)
Without setting the DRM_CLIENT_CAP_UNIVERSAL_PLANES capability bit, only
overlay planes are made available for compatibility with legacy clients.

But if a CRTC doesn't have an overlay plane associated, then kmssink is
not able to find a plane for the CRTC and the pipeline will fail, i.e:

ERROR                kmssink gstkmssink.c:482:gst_kms_sink_start:<kmssink0> Could not find a plane for crtc

If no overlay planes were found for a given CRTC, fallback to universal
planes so DRM will also return primary planes that can be used instead.

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
sys/kms/gstkmssink.c

index 3c1c954..6790ad6 100644 (file)
@@ -352,9 +352,11 @@ gst_kms_sink_start (GstBaseSink * bsink)
   drmModeCrtc *crtc;
   drmModePlaneRes *pres;
   drmModePlane *plane;
+  gboolean universal_planes;
   gboolean ret;
 
   self = GST_KMS_SINK (bsink);
+  universal_planes = FALSE;
   ret = FALSE;
   res = NULL;
   conn = NULL;
@@ -388,6 +390,11 @@ gst_kms_sink_start (GstBaseSink * bsink)
   if (!crtc)
     goto crtc_failed;
 
+retry_find_plane:
+  if (universal_planes &&
+      drmSetClientCap (self->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1))
+    goto set_cap_failed;
+
   pres = drmModeGetPlaneResources (self->fd);
   if (!pres)
     goto plane_resources_failed;
@@ -472,6 +479,12 @@ crtc_failed:
     goto bail;
   }
 
+set_cap_failed:
+  {
+    GST_ERROR_OBJECT (self, "Could not set universal planes capability bit");
+    goto bail;
+  }
+
 plane_resources_failed:
   {
     GST_ERROR_OBJECT (self, "drmModeGetPlaneResources failed: %s (%d)",
@@ -481,8 +494,13 @@ plane_resources_failed:
 
 plane_failed:
   {
-    GST_ERROR_OBJECT (self, "Could not find a plane for crtc");
-    goto bail;
+    if (universal_planes) {
+      GST_ERROR_OBJECT (self, "Could not find a plane for crtc");
+      goto bail;
+    } else {
+      universal_planes = TRUE;
+      goto retry_find_plane;
+    }
   }
 }