From c8849b83c165b2002b59f1a48f0122544efe6c0d Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sat, 5 Oct 2024 00:33:03 +0200 Subject: [PATCH] backends/drm: work around HDR screens being stupid about the minimum luminance Apparently some HDR screens only show the minimum luminance if you send them a value of zero, instead of the minimum luminance they report in the EDID. To work around that, assume the minimum value of the transfer function instead of what the screen reports as the minimum. BUG: 494128 --- src/backends/drm/drm_output.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index 4a841fecf8..cc57cd11be 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -394,7 +394,9 @@ ColorDescription DrmOutput::createColorDescription(const std::shared_ptrmaxPeakBrightnessOverride.value_or(m_state.maxPeakBrightnessOverride).value_or(m_connector->edid()->desiredMaxLuminance().value_or(800)) : 200; const double referenceLuminance = effectiveHdr ? props->referenceLuminance.value_or(m_state.referenceLuminance) : maxPeakBrightness; const auto transferFunction = TransferFunction{effectiveHdr ? TransferFunction::PerceptualQuantizer : TransferFunction::gamma22}.relativeScaledTo(referenceLuminance); - const double minBrightness = effectiveHdr ? props->minBrightnessOverride.value_or(m_state.minBrightnessOverride).value_or(m_connector->edid()->desiredMinLuminance()) : transferFunction.minLuminance; + // HDR screens are weird, sending them the min. luminance from the EDID does *not* make all of them present the darkest luminance the display can show + // to work around that, (unless overridden by the user), assume the min. luminance of the transfer function instead + const double minBrightness = effectiveHdr ? props->minBrightnessOverride.value_or(m_state.minBrightnessOverride).value_or(TransferFunction::defaultMinLuminanceFor(TransferFunction::PerceptualQuantizer)) : transferFunction.minLuminance; return ColorDescription(containerColorimetry, transferFunction, referenceLuminance, minBrightness, maxAverageBrightness, maxPeakBrightness, masteringColorimetry, sdrColorimetry); }