From f881bdf51b55b0ace76e9919b812ba87c8a8f040 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 15 Aug 2022 13:45:23 +0300 Subject: [PATCH] backends/drm: Use drmModeGetConnectorTypeName() It ensures that connector type naming is consistent across compositors and saves us some work adding string mappings. drmModeGetConnectorTypeName() uses the same naming scheme as the drm backend so the client side should be unaffected by this change. CCBUG: 385135 --- CMakeLists.txt | 2 +- src/backends/drm/drm_connector.cpp | 36 +++++------------------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 649aa7fea6..61cdf2eaad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,7 +247,7 @@ set_package_properties(UDev PROPERTIES PURPOSE "Required for input handling on Wayland." ) -find_package(Libdrm 2.4.108) +find_package(Libdrm 2.4.112) set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.") find_package(gbm) diff --git a/src/backends/drm/drm_connector.cpp b/src/backends/drm/drm_connector.cpp index 524fe9aa43..2acb35ca9d 100644 --- a/src/backends/drm/drm_connector.cpp +++ b/src/backends/drm/drm_connector.cpp @@ -143,39 +143,13 @@ bool DrmConnector::isConnected() const return !m_driverModes.empty() && m_conn && m_conn->connection == DRM_MODE_CONNECTED; } -static QHash s_connectorNames = { - {DRM_MODE_CONNECTOR_Unknown, QByteArrayLiteral("Unknown")}, - {DRM_MODE_CONNECTOR_VGA, QByteArrayLiteral("VGA")}, - {DRM_MODE_CONNECTOR_DVII, QByteArrayLiteral("DVI-I")}, - {DRM_MODE_CONNECTOR_DVID, QByteArrayLiteral("DVI-D")}, - {DRM_MODE_CONNECTOR_DVIA, QByteArrayLiteral("DVI-A")}, - {DRM_MODE_CONNECTOR_Composite, QByteArrayLiteral("Composite")}, - {DRM_MODE_CONNECTOR_SVIDEO, QByteArrayLiteral("SVIDEO")}, - {DRM_MODE_CONNECTOR_LVDS, QByteArrayLiteral("LVDS")}, - {DRM_MODE_CONNECTOR_Component, QByteArrayLiteral("Component")}, - {DRM_MODE_CONNECTOR_9PinDIN, QByteArrayLiteral("DIN")}, - {DRM_MODE_CONNECTOR_DisplayPort, QByteArrayLiteral("DP")}, - {DRM_MODE_CONNECTOR_HDMIA, QByteArrayLiteral("HDMI-A")}, - {DRM_MODE_CONNECTOR_HDMIB, QByteArrayLiteral("HDMI-B")}, - {DRM_MODE_CONNECTOR_TV, QByteArrayLiteral("TV")}, - {DRM_MODE_CONNECTOR_eDP, QByteArrayLiteral("eDP")}, - {DRM_MODE_CONNECTOR_VIRTUAL, QByteArrayLiteral("Virtual")}, - {DRM_MODE_CONNECTOR_DSI, QByteArrayLiteral("DSI")}, - {DRM_MODE_CONNECTOR_DPI, QByteArrayLiteral("DPI")}, -#ifdef DRM_MODE_CONNECTOR_WRITEBACK - {DRM_MODE_CONNECTOR_WRITEBACK, QByteArrayLiteral("Writeback")}, -#endif -#ifdef DRM_MODE_CONNECTOR_SPI - {DRM_MODE_CONNECTOR_SPI, QByteArrayLiteral("SPI")}, -#endif -#ifdef DRM_MODE_CONNECTOR_USB - {DRM_MODE_CONNECTOR_USB, QByteArrayLiteral("USB")}, -#endif -}; - QString DrmConnector::connectorName() const { - return s_connectorNames.value(m_conn->connector_type, QByteArrayLiteral("Unknown")) + QStringLiteral("-") + QString::number(m_conn->connector_type_id); + const char *connectorName = drmModeGetConnectorTypeName(m_conn->connector_type); + if (!connectorName) { + connectorName = "Unknown"; + } + return QStringLiteral("%1-%2").arg(connectorName).arg(m_conn->connector_type_id); } QString DrmConnector::modelName() const