Re-enable proper gamma ramps with AMS

Instead of downgrading everyone else to legacy gamma, only exclude
the huge and buggy gamma ramp of Intel TIgerLake hardware.
This commit is contained in:
Xaver Hugl 2021-09-28 22:31:11 +02:00
parent eb62728f1f
commit 4206046f12
3 changed files with 8 additions and 1 deletions

View file

@ -353,7 +353,8 @@ void ColorDevice::update()
uint16_t *blueChannel = gammaRamp.blue();
for (uint32_t i = 0; i < gammaRamp.size(); ++i) {
const uint16_t index = (i * 0xffff) / (gammaRamp.size() - 1);
// ensure 64 bit calculation to prevent overflows
const uint16_t index = (static_cast<uint64_t>(i) * 0xffff) / (gammaRamp.size() - 1);
const uint16_t in[3] = { index, index, index };
uint16_t out[3] = { 0 };

View file

@ -24,6 +24,7 @@ DrmCrtc::DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex, DrmPlane *primaryP
PropertyDefinition(QByteArrayLiteral("ACTIVE"), Requirement::Required),
PropertyDefinition(QByteArrayLiteral("VRR_ENABLED"), Requirement::Optional),
PropertyDefinition(QByteArrayLiteral("GAMMA_LUT"), Requirement::Optional),
PropertyDefinition(QByteArrayLiteral("GAMMA_LUT_SIZE"), Requirement::Optional)
}, DRM_MODE_OBJECT_CRTC)
, m_crtc(drmModeGetCrtc(gpu->fd(), crtcId))
, m_pipeIndex(pipeIndex)
@ -81,6 +82,10 @@ void DrmCrtc::setNext(const QSharedPointer<DrmBuffer> &buffer)
int DrmCrtc::gammaRampSize() const
{
// limit atomic gamma ramp to 4096 to work around https://gitlab.freedesktop.org/drm/intel/-/issues/3916
if (auto prop = getProp(PropertyIndex::Gamma_LUT_Size); prop && prop->current() <= 4096) {
return prop->current();
}
return m_crtc->gamma_size;
}

View file

@ -34,6 +34,7 @@ public:
Active,
VrrEnabled,
Gamma_LUT,
Gamma_LUT_Size,
Count
};