summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2018-08-27 15:07:47 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2018-08-29 11:57:37 -0400
commit203b41b51006b3e04a16755d488a0103c169f89d (patch)
treed9f9bc11ba83df52c0cb86476f9237bbcb97e7ce
parent71ab97cba64f2ce128d1cf08ba9f34b439c8c47c (diff)
kmssink: Generalize setting DRM object properties
https://bugzilla.gnome.org/show_bug.cgi?id=797027
-rw-r--r--sys/kms/gstkmssink.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
index 075efc9bb..041eda500 100644
--- a/sys/kms/gstkmssink.c
+++ b/sys/kms/gstkmssink.c
@@ -587,10 +587,13 @@ typedef struct
{
GstKMSSink *self;
drmModeObjectPropertiesPtr properties;
+ guint obj_id;
+ guint obj_type;
+ const gchar *obj_type_str;
} SetPropsIter;
static gboolean
-set_connector_prop (GQuark field_id, const GValue * value, gpointer user_data)
+set_obj_prop (GQuark field_id, const GValue * value, gpointer user_data)
{
SetPropsIter *iter = user_data;
GstKMSSink *self = iter->self;
@@ -613,19 +616,34 @@ set_connector_prop (GQuark field_id, const GValue * value, gpointer user_data)
return TRUE;
}
- if (set_drm_property (self->fd, self->conn_id, DRM_MODE_OBJECT_CONNECTOR,
+ if (set_drm_property (self->fd, iter->obj_id, iter->obj_type,
iter->properties, name, v)) {
GST_DEBUG_OBJECT (self,
- "Set connector property '%s' to %" G_GUINT64_FORMAT, name, v);
+ "Set %s property '%s' to %" G_GUINT64_FORMAT,
+ iter->obj_type_str, name, v);
} else {
GST_WARNING_OBJECT (self,
- "Failed to set connector property '%s' to %" G_GUINT64_FORMAT, name, v);
+ "Failed to set %s property '%s' to %" G_GUINT64_FORMAT,
+ iter->obj_type_str, name, v);
}
return TRUE;
}
static void
+gst_kms_sink_update_properties (SetPropsIter * iter, GstStructure * props)
+{
+ GstKMSSink *self = iter->self;
+
+ iter->properties = drmModeObjectGetProperties (self->fd, iter->obj_id,
+ iter->obj_type);
+
+ gst_structure_foreach (props, set_obj_prop, iter);
+
+ drmModeFreeObjectProperties (iter->properties);
+}
+
+static void
gst_kms_sink_update_connector_properties (GstKMSSink * self)
{
SetPropsIter iter;
@@ -634,13 +652,14 @@ gst_kms_sink_update_connector_properties (GstKMSSink * self)
return;
iter.self = self;
- iter.properties =
- drmModeObjectGetProperties (self->fd, self->conn_id,
- DRM_MODE_OBJECT_CONNECTOR);
+ iter.obj_id = self->conn_id;
+ iter.obj_type = DRM_MODE_OBJECT_CONNECTOR;
+ iter.obj_type_str = "connector";
+
+ gst_kms_sink_update_properties (&iter, self->connector_props);
+}
- gst_structure_foreach (self->connector_props, set_connector_prop, &iter);
- drmModeFreeObjectProperties (iter.properties);
}
static gboolean