kmssink: add global alpha setting for mscale
upstream status: i.mx specific
diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
index 7c3b3ee..f0f5c0e 100644
--- a/sys/kms/gstkmssink.c
+++ b/sys/kms/gstkmssink.c
@@ -1372,6 +1372,58 @@
return TRUE;
}
+static void
+gst_kms_sink_set_primary_alpha (GstKMSSink * self, guint alpha)
+{
+ drmModeRes *res = NULL;
+ drmModePlaneRes *pres = NULL;
+ drmModePlane *plane = NULL;
+ drmModeObjectPropertiesPtr props = NULL;
+ drmModePropertyPtr prop = NULL;
+ guint i;
+
+ res = drmModeGetResources (self->fd);
+ if (!res)
+ goto out;
+
+ drmSetClientCap (self->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+
+ pres = drmModeGetPlaneResources (self->fd);
+ if (!pres)
+ goto out;
+
+ plane = find_plane_for_crtc (self->fd, res, pres, self->crtc_id);
+ if (!plane)
+ goto out;
+
+ props = drmModeObjectGetProperties (self->fd, plane->plane_id, DRM_MODE_OBJECT_PLANE);
+ for (i = 0; i < props->count_props; ++i) {
+ prop = drmModeGetProperty(self->fd, props->props[i]);
+ if (!strcmp(prop->name, "alpha"))
+ break;
+ drmModeFreeProperty (prop);
+ prop = NULL;
+ }
+
+ if (prop) {
+ GST_DEBUG ("set global alpha %d to primary plane %d property %d",
+ alpha, plane->plane_id, prop->prop_id);
+ drmModeObjectSetProperty (self->ctrl_fd, plane->plane_id, DRM_MODE_OBJECT_PLANE, prop->prop_id, alpha);
+ drmModeFreeProperty (prop);
+ }
+
+out:
+ if (res)
+ drmModeFreeResources (res);
+ if (pres)
+ drmModeFreePlaneResources (pres);
+ if (plane)
+ drmModeFreePlane (plane);
+ if (props)
+ drmModeFreeObjectProperties (props);
+ drmSetClientCap (self->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
+}
+
static GstStateChangeReturn
gst_kms_sink_change_state (GstElement * element, GstStateChange transition)
{
@@ -1386,6 +1438,7 @@
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
+ self->is_alpha_set = FALSE;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
@@ -1407,6 +1460,7 @@
}
case GST_STATE_CHANGE_PAUSED_TO_READY:
{
+ gst_kms_sink_set_primary_alpha (self, 255);
break;
}
case GST_STATE_CHANGE_READY_TO_NULL:
@@ -1579,6 +1633,11 @@
GST_TRACE_OBJECT (self, "displaying fb %d", fb_id);
+ if (!self->is_alpha_set) {
+ gst_kms_sink_set_primary_alpha (self, 0);
+ self->is_alpha_set = TRUE;
+ }
+
GST_OBJECT_LOCK (self);
if (self->modesetting_enabled) {
self->buffer_id = fb_id;
diff --git a/sys/kms/gstkmssink.h b/sys/kms/gstkmssink.h
index 22d1967..671d824 100644
--- a/sys/kms/gstkmssink.h
+++ b/sys/kms/gstkmssink.h
@@ -69,6 +69,9 @@
gboolean has_async_page_flip;
gboolean can_scale;
+ /* global alpha */
+ gboolean is_alpha_set;
+
gboolean modesetting_enabled;
GstVideoInfo vinfo;