kmssink: check scaleable when set_caps

when video size is same as display resolution, show frame will not do
retry because the setplane will never fail. But the scale result is not
correct. We can do this check by set a fake plane.

Upstream-Status: Inappropriate [i.MX specific]
diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
index 7adb7d1..e35028a 100644
--- a/sys/kms/gstkmssink.c
+++ b/sys/kms/gstkmssink.c
@@ -412,6 +412,42 @@
   return TRUE;
 }
 
+static void
+check_scaleable (GstKMSSink * self)
+{
+  gint result;
+  guint32 fb_id;
+  guint32 width, height;
+  GstKMSMemory *kmsmem = NULL;
+
+  if (!self->can_scale)
+    return;
+
+  if (self->conn_id < 0)
+    return;
+
+  kmsmem = (GstKMSMemory *) gst_kms_allocator_bo_alloc (self->allocator, &self->vinfo);
+  if (!kmsmem)
+    return;
+
+  fb_id = kmsmem->fb_id;
+
+  GST_INFO_OBJECT (self, "checking scaleable");
+
+  width = GST_VIDEO_INFO_WIDTH (&self->vinfo);
+  height = GST_VIDEO_INFO_HEIGHT (&self->vinfo);
+
+  result = drmModeSetPlane (self->ctrl_fd, self->plane_id, self->crtc_id, fb_id, 0,
+      0, 0, width/2, height/2,
+      0, 0, width << 16, height << 16);
+  if (result) {
+    self->can_scale = FALSE;
+    GST_INFO_OBJECT (self, "scale is not support");
+  }
+
+  g_clear_pointer (&kmsmem, gst_memory_unref);
+}
+
 static gboolean
 configure_mode_setting (GstKMSSink * self, GstVideoInfo * vinfo)
 {
@@ -1054,6 +1090,8 @@
 
   self->vinfo = vinfo;
 
+  check_scaleable (self);
+
   GST_OBJECT_LOCK (self);
   if (self->reconfigure) {
     self->reconfigure = FALSE;