summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@armlinux.org.uk>2018-06-28 10:20:24 +0100
committerRussell King <rmk@armlinux.org.uk>2018-07-13 18:14:06 +0100
commitd23965029ea0e82e0978a2bdd398ad259ebbfa05 (patch)
tree5e2a675551be0ea90c7744644082da2260ef3aeb
parentd2ce88ab3f42d5ce74b81bc45ee19f2b64c0296d (diff)
src: simplify common_drm_conn_set_property()
Move the search for the property out, which allows us to clean up the code a little. This functionality will also be needed for common_drm_conn_get_property(). Signed-off-by: Russell King <rmk@armlinux.org.uk>
-rw-r--r--src/common_drm.c94
1 files changed, 60 insertions, 34 deletions
diff --git a/src/common_drm.c b/src/common_drm.c
index b7b37e0..ef4f5f5 100644
--- a/src/common_drm.c
+++ b/src/common_drm.c
@@ -336,51 +336,77 @@ static DisplayModePtr common_drm_conn_get_modes(xf86OutputPtr output)
}
#ifdef RANDR_12_INTERFACE
+static struct common_drm_property *common_drm_conn_find_prop(
+ struct common_conn_info *conn, Atom property)
+{
+ int i;
+
+ for (i = 0; i < conn->nprops; i++) {
+ struct common_drm_property *p = &conn->props[i];
+
+ if (p->atoms && p->atoms[0] == property)
+ return p;
+ }
+ return NULL;
+}
+
static Bool common_drm_conn_set_property(xf86OutputPtr output, Atom property,
RRPropertyValuePtr value)
{
struct common_conn_info *conn = output->driver_private;
- int i;
+ struct common_drm_property *prop;
+ drmModePropertyPtr dprop;
+ uint64_t val;
- for (i = 0; i < conn->nprops; i++) {
- struct common_drm_property *prop = &conn->props[i];
- drmModePropertyPtr dprop;
+ prop = common_drm_conn_find_prop(conn, property);
+ /* If we didn't recognise this property, just report success
+ * in order to allow the set to continue, otherwise we break
+ * setting of common properties like EDID.
+ */
+ if (!prop)
+ return TRUE;
- if (!prop->atoms || prop->atoms[0] != property)
- continue;
+ dprop = prop->mode_prop;
+ if (dprop->flags & DRM_MODE_PROP_RANGE) {
+ if (value->type != XA_INTEGER ||
+ value->format != 32 ||
+ value->size != 1)
+ return FALSE;
- dprop = prop->mode_prop;
- if (dprop->flags & DRM_MODE_PROP_RANGE) {
- if (value->type != XA_INTEGER || value->format != 32 || value->size != 1)
- return FALSE;
+ val = *(uint32_t *)value->data;
+ drmModeConnectorSetProperty(conn->drm_fd, conn->drm_id,
+ dprop->prop_id, val);
- drmModeConnectorSetProperty(conn->drm_fd, conn->drm_id,
- dprop->prop_id, (uint64_t)*(uint32_t *)value->data);
+ return TRUE;
+ } else if (dprop->flags & DRM_MODE_PROP_ENUM) {
+ Atom atom;
+ const char *name;
+ int j;
+
+ if (value->type != XA_ATOM ||
+ value->format != 32 ||
+ value->size != 1)
+ return FALSE;
- return TRUE;
- } else if (dprop->flags & DRM_MODE_PROP_ENUM) {
- Atom atom;
- const char *name;
- int j;
-
- if (value->type != XA_ATOM || value->format != 32 || value->size != 1)
- return FALSE;
-
- memcpy(&atom, value->data, sizeof(atom));
- name = NameForAtom(atom);
- if (name == NULL)
- return FALSE;
-
- for (j = 0; j < dprop->count_enums; j++) {
- if (!strcmp(dprop->enums[j].name, name)) {
- drmModeConnectorSetProperty(conn->drm_fd,
- conn->drm_id, dprop->prop_id,
- dprop->enums[j].value);
- return TRUE;
- }
- }
+ memcpy(&atom, value->data, sizeof(atom));
+ name = NameForAtom(atom);
+ if (name == NULL)
return FALSE;
+
+ for (j = 0; j < dprop->count_enums; j++) {
+ if (!strcmp(dprop->enums[j].name, name)) {
+ val = dprop->enums[j].value;
+ break;
+ }
}
+
+ if (j >= dprop->count_enums)
+ return FALSE;
+
+ drmModeConnectorSetProperty(conn->drm_fd, conn->drm_id,
+ dprop->prop_id, val);
+
+ return TRUE;
}
return TRUE;
}