backends/drm: also set legacy gamma after VT switches

Just like with modes, the gamma state is unknown after VT switches, and has
to be explicitly set again to ensure it's correct
This commit is contained in:
Xaver Hugl 2024-03-06 22:08:00 +01:00
parent d1bc39a6ea
commit e4349536a3
2 changed files with 17 additions and 5 deletions

View file

@ -151,6 +151,7 @@ private:
// legacy only
Error presentLegacy();
Error legacyModeset();
Error setLegacyGamma();
Error applyPendingChangesLegacy();
bool setCursorLegacy();
static Error commitPipelinesLegacy(const QList<DrmPipeline *> &pipelines, CommitMode mode, const QList<DrmObject *> &unusedObjects);

View file

@ -42,6 +42,7 @@ DrmPipeline::Error DrmPipeline::presentLegacy()
void DrmPipeline::forceLegacyModeset()
{
legacyModeset();
setLegacyGamma();
}
DrmPipeline::Error DrmPipeline::legacyModeset()
@ -132,12 +133,10 @@ DrmPipeline::Error DrmPipeline::applyPendingChangesLegacy()
return err;
}
}
if (m_pending.gamma && m_currentLegacyGamma != m_pending.gamma) {
if (drmModeCrtcSetGamma(gpu()->fd(), m_pending.crtc->id(), m_pending.gamma->lut().size(), m_pending.gamma->lut().red(), m_pending.gamma->lut().green(), m_pending.gamma->lut().blue()) != 0) {
qCWarning(KWIN_DRM) << "Setting gamma failed!" << strerror(errno);
return errnoToError();
if (m_pending.gamma != m_currentLegacyGamma) {
if (Error err = setLegacyGamma(); err != Error::None) {
return err;
}
m_currentLegacyGamma = m_pending.gamma;
}
if (m_connector->contentType.isValid()) {
m_connector->contentType.setEnumLegacy(m_pending.contentType);
@ -151,6 +150,18 @@ DrmPipeline::Error DrmPipeline::applyPendingChangesLegacy()
return Error::None;
}
DrmPipeline::Error DrmPipeline::setLegacyGamma()
{
if (m_pending.gamma) {
if (drmModeCrtcSetGamma(gpu()->fd(), m_pending.crtc->id(), m_pending.gamma->lut().size(), m_pending.gamma->lut().red(), m_pending.gamma->lut().green(), m_pending.gamma->lut().blue()) != 0) {
qCWarning(KWIN_DRM) << "Setting gamma failed!" << strerror(errno);
return errnoToError();
}
m_currentLegacyGamma = m_pending.gamma;
}
return DrmPipeline::Error::None;
}
bool DrmPipeline::setCursorLegacy()
{
const auto bo = cursorLayer()->currentBuffer();