[plasma/kwin/Plasma/6.7] src: utils/edid: fix hexadecimal strings in output names

Nate Graham <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 0b02b631adc81ea47c656a2188ab3d2521a34fb5 by Nate Graham.
Committed on 05/08/2026 at 15:13.
Pushed by ngraham into branch 'Plasma/6.7'.

utils/edid: fix hexadecimal strings in output names

KWin uses libdisplay-info to decode EDID data. di_info_get_model() and
di_info_get_serial() fall back to hexadecimal values when no Display
Product Name or Serial Number descriptor is found.

This patch stops using those helpers and instead implements a direct
descriptor parser, similar to libkscreen's decoder: we still fall back
to a decimal value for the serial number,  but not for the model, so
m_monitorName is left empty if no name descriptor exists.

To avoid showing "unknown" when m_monitorName is empty,
DrmConnector::modelName() now skips empty values instead of
concatenating them (similar to libkscreen).

Note: if necessary a decimal fallback for the model (m_monitorName)
could be added later in the same way. Currently, the model falls back
to a hexadecimal representation,  but libkscreen has none either, so
this patch leaves it out for now.

BUG: 523181
FIXED-IN: 6.6.7


(cherry picked from commit 495d442585e255e7bb7f3e2d570ff2a881d53ce5)

2d916723 utils/edid: fix hexadecimal strings in output names
65a24935 drm_connector: avoid showing "unknown" when m_monitorName is empty

Co-authored-by: David Wild <[email protected]>

M  +3    -0    src/backends/drm/drm_connector.cpp
M  +19   -4    src/utils/edid.cpp

https://invent.kde.org/plasma/kwin/-/commit/0b02b631adc81ea47c656a2188ab3d2521a34fb5

diff --git a/src/backends/drm/drm_connector.cpp b/src/backends/drm/drm_connector.cpp
index 55a5f1f8c06..c2a2c0210f7 100644
--- a/src/backends/drm/drm_connector.cpp
+++ b/src/backends/drm/drm_connector.cpp
@@ -200,6 +200,9 @@ QString DrmConnector::connectorName() const
 
 QString DrmConnector::modelName() const
 {
+    if (m_edid.monitorName().isEmpty() && m_edid.serialNumber().isEmpty()) {
+        return connectorName(); // just use the connector name
+    }
     if (m_edid.serialNumber().isEmpty()) {
         return connectorName() + QLatin1Char('-') + m_edid.nameString();
     } else {
diff --git a/src/utils/edid.cpp b/src/utils/edid.cpp
index a2a0d11f362..8204a24ea99 100644
--- a/src/utils/edid.cpp
+++ b/src/utils/edid.cpp
@@ -77,6 +77,20 @@ static QByteArray parseEisaId(const uint8_t *data)
     return parsePnpId(data);
 }
 
+static QByteArray parseDescriptorString(const di_edid *edid, di_edid_display_descriptor_tag wantedTag)
+{
+    const di_edid_display_descriptor *const *descriptors = di_edid_get_display_descriptors(edid);
+    for (; *descriptors != nullptr; descriptors++) {
+        if (di_edid_display_descriptor_get_tag(*descriptors) != wantedTag) {
+            continue;
+        }
+        if (const char *str = di_edid_display_descriptor_get_string(*descriptors); str && str[0] != '\0') {
+            return QByteArray(str).trimmed();
+        }
+    }
+    return {};
+}
+
 static QByteArray parseVendor(const uint8_t *data)
 {
     const auto pnpId = parsePnpId(data);
@@ -167,10 +181,11 @@ Edid::Edid(QByteArrayView data)
     m_physicalSize = determineScreenPhysicalSizeMm(edid);
     m_eisaId = parseEisaId(bytes);
     m_pnpId = parsePnpId(bytes);
-    UniqueCPtr<char> monitorName{di_info_get_model(info)};
-    m_monitorName = QByteArray(monitorName.get());
-    UniqueCPtr<char> serial{di_info_get_serial(info)};
-    m_serialNumber = QByteArray(serial.get());
+    m_monitorName = parseDescriptorString(edid, DI_EDID_DISPLAY_DESCRIPTOR_PRODUCT_NAME);
+    m_serialNumber = parseDescriptorString(edid, DI_EDID_DISPLAY_DESCRIPTOR_PRODUCT_SERIAL);
+    if (m_serialNumber.isEmpty() && productInfo->serial != 0) {
+        m_serialNumber = QByteArray::number(productInfo->serial); // fallback to decimal value
+    }
     m_vendor = parseVendor(bytes);
 
     m_identifier = QByteArray(productInfo->manufacturer, 3) + " " + QByteArray::number(productInfo->product) + " " + QByteArray::number(productInfo->serial) + " "
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.