diff options
author | Simon Ser <contact@emersion.fr> | 2021-01-13 00:33:19 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-01-17 12:42:25 +0100 |
commit | cb6f58449683f7b30a6a8718bac5475c39b291d8 (patch) | |
tree | 05b4b44053c64ec0b4c8f496cf23b69ef0d769e8 /backend/drm/properties.c | |
parent | 6af748171a3f21c48847b53337df792576750a18 (diff) |
backend/drm: add support for the subconnector property
The subconnector property indicates the connector sub-type. This is
useful because that usually indicates what kind of connector the user
has plugged in to their monitor, e.g. a DisplayPort-to-DVI cable will
indicate a DVI subconnector. Also some laptops have non-DP connectors
that are internally linked to a DP port on the GPU.
Set the output description accordingly.
See https://drmdb.emersion.fr/properties/3233857728/subconnector
Diffstat (limited to 'backend/drm/properties.c')
-rw-r--r-- | backend/drm/properties.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/backend/drm/properties.c b/backend/drm/properties.c index de51a3de..5581a130 100644 --- a/backend/drm/properties.c +++ b/backend/drm/properties.c @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 200809L #include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -24,6 +25,7 @@ static const struct prop_info connector_info[] = { { "EDID", INDEX(edid) }, { "PATH", INDEX(path) }, { "link-status", INDEX(link_status) }, + { "subconnector", INDEX(subconnector) }, { "vrr_capable", INDEX(vrr_capable) }, #undef INDEX }; @@ -151,3 +153,27 @@ void *get_drm_prop_blob(int fd, uint32_t obj, uint32_t prop, size_t *ret_len) { drmModeFreePropertyBlob(blob); return ptr; } + +char *get_drm_prop_enum(int fd, uint32_t obj, uint32_t prop_id) { + uint64_t value; + if (!get_drm_prop(fd, obj, prop_id, &value)) { + return NULL; + } + + drmModePropertyRes *prop = drmModeGetProperty(fd, prop_id); + if (!prop) { + return NULL; + } + + char *str = NULL; + for (int i = 0; i < prop->count_enums; i++) { + if (prop->enums[i].value == value) { + str = strdup(prop->enums[i].name); + break; + } + } + + drmModeFreeProperty(prop); + + return str; +} |