summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-02-01 14:33:34 +0100
committerSimon Ser <contact@emersion.fr>2022-07-02 20:13:29 +0000
commit50f8d517733d24fce6693ffae552f9833e2e6aa9 (patch)
tree4ea0b222a2ea19f8b1894528ec82e1cec41c3cc9
parentf7828dc180ba3427b5e405fab25e9846c07322bc (diff)
downloadlibdrm-50f8d517733d24fce6693ffae552f9833e2e6aa9.tar.gz
libdrm-50f8d517733d24fce6693ffae552f9833e2e6aa9.tar.bz2
libdrm-50f8d517733d24fce6693ffae552f9833e2e6aa9.zip
xf86drmMode: introduce drmModeGetConnectorTypeName
User-space often needs to print the name of a connector type. When a new connector type is added, all user-space programs need to be updated to support the new connector type. Expose a function to get a connector type name in libdrm. The names are taken from the kernel [1]. [1]: https://cgit.freedesktop.org/drm/drm/tree/drivers/gpu/drm/drm_connector.c?h=4fc8cb47fcfdc93e274a1291757e478df4f9c39b#n83 Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r--core-symbols.txt1
-rw-r--r--xf86drmMode.c53
-rw-r--r--xf86drmMode.h9
3 files changed, 63 insertions, 0 deletions
diff --git a/core-symbols.txt b/core-symbols.txt
index 31bbcf8f..dcf90018 100644
--- a/core-symbols.txt
+++ b/core-symbols.txt
@@ -126,6 +126,7 @@ drmModeFreePropertyBlob
drmModeFreeResources
drmModeGetConnector
drmModeGetConnectorCurrent
+drmModeGetConnectorTypeName
drmModeGetCrtc
drmModeGetEncoder
drmModeGetFB
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 6b79d768..6d636dcc 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1747,3 +1747,56 @@ drm_public void drmModeFreeFB2(drmModeFB2Ptr ptr)
{
drmFree(ptr);
}
+
+drm_public const char *
+drmModeGetConnectorTypeName(uint32_t connector_type)
+{
+ /* Keep the strings in sync with the kernel's drm_connector_enum_list in
+ * drm_connector.c. */
+ switch (connector_type) {
+ case DRM_MODE_CONNECTOR_Unknown:
+ return "Unknown";
+ case DRM_MODE_CONNECTOR_VGA:
+ return "VGA";
+ case DRM_MODE_CONNECTOR_DVII:
+ return "DVI-I";
+ case DRM_MODE_CONNECTOR_DVID:
+ return "DVI-D";
+ case DRM_MODE_CONNECTOR_DVIA:
+ return "DVI-A";
+ case DRM_MODE_CONNECTOR_Composite:
+ return "Composite";
+ case DRM_MODE_CONNECTOR_SVIDEO:
+ return "SVIDEO";
+ case DRM_MODE_CONNECTOR_LVDS:
+ return "LVDS";
+ case DRM_MODE_CONNECTOR_Component:
+ return "Component";
+ case DRM_MODE_CONNECTOR_9PinDIN:
+ return "DIN";
+ case DRM_MODE_CONNECTOR_DisplayPort:
+ return "DP";
+ case DRM_MODE_CONNECTOR_HDMIA:
+ return "HDMI-A";
+ case DRM_MODE_CONNECTOR_HDMIB:
+ return "HDMI-B";
+ case DRM_MODE_CONNECTOR_TV:
+ return "TV";
+ case DRM_MODE_CONNECTOR_eDP:
+ return "eDP";
+ case DRM_MODE_CONNECTOR_VIRTUAL:
+ return "Virtual";
+ case DRM_MODE_CONNECTOR_DSI:
+ return "DSI";
+ case DRM_MODE_CONNECTOR_DPI:
+ return "DPI";
+ case DRM_MODE_CONNECTOR_WRITEBACK:
+ return "Writeback";
+ case DRM_MODE_CONNECTOR_SPI:
+ return "SPI";
+ case DRM_MODE_CONNECTOR_USB:
+ return "USB";
+ default:
+ return NULL;
+ }
+}
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 08557642..46dc80a2 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -475,6 +475,15 @@ extern drmModeObjectListPtr drmModeGetLease(int fd);
extern int drmModeRevokeLease(int fd, uint32_t lessee_id);
+/**
+ * Get a string describing a connector type.
+ *
+ * NULL is returned if the connector type is unsupported. Callers should handle
+ * this gracefully, e.g. by falling back to "Unknown" or printing the raw value.
+ */
+extern const char *
+drmModeGetConnectorTypeName(uint32_t connector_type);
+
#if defined(__cplusplus)
}
#endif