kmssink: Generalize setting DRM object properties

https://bugzilla.gnome.org/show_bug.cgi?id=797027
This commit is contained in:
Nicolas Dufresne 2018-08-27 15:07:47 -04:00
parent 71ab97cba6
commit 203b41b510

View file

@ -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,18 +616,33 @@ 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)
{
@ -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