From 8f21337c6c84497ca078e0c36079685ba9a94137 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 25 Aug 2022 10:29:34 +0200 Subject: Fix new TMDS-clock obeying EDID mode adding logic --- src/xprivate.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/xprivate.cpp b/src/xprivate.cpp index f040199..eb1cf59 100644 --- a/src/xprivate.cpp +++ b/src/xprivate.cpp @@ -465,6 +465,7 @@ void XPrivate::addMissingModesFromDtd(XRRScreenResources *res, RROutput outputId if (data[17] & 0x80) { m.modeFlags |= RR_Interlace; } + RRMode modeId = 0; // More special case B/S: So, X11 mysteriously ignores a couple of resolutions, sometimes. // Curiously, this happens with a Philips TV, but not an LG TV. EDID dump looks very similar // on both. More curiously, in Xorg.log, the first time the modelines for the Philips TV get dumped, @@ -473,32 +474,33 @@ void XPrivate::addMissingModesFromDtd(XRRScreenResources *res, RROutput outputId // resolution is in the list. Just not the first time. However, the resolutions never get added to // the TV. if (m.dotClock > maxClockMhz * 1000000) { - bool found = false; for (int mode = 0; mode < res->nmode; ++mode) { if (res->modes[mode].width == m.width && res->modes[mode].height == m.height && res->modes[mode].dotClock <= maxClockMhz * 1000000) { - found = true; + modeId = res->modes[mode].id; break; } } - if (found) { + if (modeId != 0) { qDebug() << "Not creating/adding" << m.width << "x" << m.height << "because pixel clock > TMDS and resolution already exists with different clock"; - return; - } - refresh = 30; - m.dotClock = refresh * m.hTotal * m.vTotal; - if (m.dotClock > maxClockMhz * 1000000) { - refresh = 24; + } else { + refresh = 30; m.dotClock = refresh * m.hTotal * m.vTotal; + if (m.dotClock > maxClockMhz * 1000000) { + refresh = 24; + m.dotClock = refresh * m.hTotal * m.vTotal; + } + qDebug() << "Capping to" << refresh << "Hz, " << (m.dotClock / 1000000) << "MHz"; } - qDebug() << "Capping to" << refresh << "Hz, " << (m.dotClock / 1000000) << "MHz"; } // See if we should add this mode - RRMode modeId = 0; - for (int mode = 0; mode < res->nmode; ++mode) { - if (modeEqual(&res->modes[mode], &m)) { - modeId = res->modes[mode].id; - break; + if (modeId == 0) { + for (int mode = 0; mode < res->nmode; ++mode) { + if (modeEqual(&res->modes[mode], &m)) { + // Identical modeline already known to X + modeId = res->modes[mode].id; + break; + } } } if (modeId == 0) { @@ -510,6 +512,8 @@ void XPrivate::addMissingModesFromDtd(XRRScreenResources *res, RROutput outputId if (modeId != 0) { qDebug() << "Adding mode for output" << outputId << m.width << "x" << m.height << "@" << (m.dotClock / 1000000); XRRAddOutputMode(_display, outputId, modeId); + } else { + qDebug() << "Failed to add" << buf << "to" << outputId << "- mode not found/created"; } } -- cgit v1.2.3-55-g7522