From bd587a7f431e53764d5e8051f2717d32d4c62b69 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 8 Jul 2022 22:04:20 +0200 Subject: backend/drm: use drmModeGetConnectorTypeName No need to manually maintain this table now. The wlroots names and the libdrm (= kernel) names all match. References: https://gitlab.freedesktop.org/mesa/drm/-/commit/50f8d517733d24fce6693ffae552f9833e2e6aa9 --- backend/drm/drm.c | 9 +++++++-- backend/drm/util.c | 31 ------------------------------- include/backend/drm/util.h | 2 -- meson.build | 2 +- 4 files changed, 8 insertions(+), 36 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 262a533e..660477b6 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1250,9 +1250,14 @@ void scan_drm_connectors(struct wlr_drm_backend *drm, wlr_conn->status = WLR_DRM_CONN_DISCONNECTED; wlr_conn->id = drm_conn->connector_id; + const char *conn_name = + drmModeGetConnectorTypeName(drm_conn->connector_type); + if (conn_name == NULL) { + conn_name = "Unknown"; + } + snprintf(wlr_conn->name, sizeof(wlr_conn->name), - "%s-%"PRIu32, conn_get_name(drm_conn->connector_type), - drm_conn->connector_type_id); + "%s-%"PRIu32, conn_name, drm_conn->connector_type_id); wl_list_insert(drm->outputs.prev, &wlr_conn->link); wlr_log(WLR_INFO, "Found connector '%s'", wlr_conn->name); diff --git a/backend/drm/util.c b/backend/drm/util.c index d56eee38..2083e617 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -121,37 +121,6 @@ void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data) } } -const char *conn_get_name(uint32_t type_id) { - switch (type_id) { - 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"; -#ifdef DRM_MODE_CONNECTOR_SPI - case DRM_MODE_CONNECTOR_SPI: return "SPI"; -#endif -#ifdef DRM_MODE_CONNECTOR_USB - case DRM_MODE_CONNECTOR_USB: return "USB"; -#endif - default: return "Unknown"; - } -} - static bool is_taken(size_t n, const uint32_t arr[static n], uint32_t key) { for (size_t i = 0; i < n; ++i) { if (arr[i] == key) { diff --git a/include/backend/drm/util.h b/include/backend/drm/util.h index 323894b5..fc632e12 100644 --- a/include/backend/drm/util.h +++ b/include/backend/drm/util.h @@ -11,8 +11,6 @@ struct wlr_drm_connector; int32_t calculate_refresh_rate(const drmModeModeInfo *mode); // Populates the make/model/phys_{width,height} of output from the edid data void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data); -// Returns the string representation of a DRM output type -const char *conn_get_name(uint32_t type_id); // Part of match_obj enum { diff --git a/meson.build b/meson.build index 944dfa3e..d04d3c16 100644 --- a/meson.build +++ b/meson.build @@ -107,7 +107,7 @@ wayland_server = dependency('wayland-server', ) drm = dependency('libdrm', - version: '>=2.4.109', + version: '>=2.4.112', fallback: 'libdrm', default_options: [ 'libkms=false', -- cgit v1.2.3