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
This commit is contained in:
Vlad Zahorodnii 2022-08-15 13:45:23 +03:00
parent f764861157
commit f881bdf51b
2 changed files with 6 additions and 32 deletions

View file

@ -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)

View file

@ -143,39 +143,13 @@ bool DrmConnector::isConnected() const
return !m_driverModes.empty() && m_conn && m_conn->connection == DRM_MODE_CONNECTED;
}
static QHash<int, QByteArray> 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