kms/impl-device/simple: Handle NULL gamma LUTs for passthrough

The kernel doesn't let us set gamma to passthrough with the legacy API
so we have to trick a bit and create an identity LUT, and also when we
read the KMS state, detect when an identity LUT is active.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
This commit is contained in:
Sebastian Wick 2024-01-29 20:58:39 +01:00 committed by Marge Bot
parent a55e2e5af2
commit b083ad67df
2 changed files with 12 additions and 1 deletions

View File

@ -180,6 +180,9 @@ read_crtc_legacy_gamma (MetaKmsCrtc *crtc,
crtc_state->gamma.value->red,
crtc_state->gamma.value->green,
crtc_state->gamma.value->blue);
if (meta_gamma_lut_is_identity (crtc_state->gamma.value))
g_clear_pointer (&crtc_state->gamma.value, meta_gamma_lut_free);
}
static void

View File

@ -534,13 +534,21 @@ process_crtc_color_updates (MetaKmsImplDevice *impl_device,
}
else
{
const MetaKmsCrtcState *crtc_state =
meta_kms_crtc_get_current_state (crtc);
g_autoptr (MetaGammaLut) identity_lut =
meta_gamma_lut_new_identity (crtc_state->gamma.size);
meta_topic (META_DEBUG_KMS,
"[simple] Setting CRTC (%u, %s) gamma to bypass",
meta_kms_crtc_get_id (crtc),
meta_kms_impl_device_get_path (impl_device));
ret = drmModeCrtcSetGamma (fd, meta_kms_crtc_get_id (crtc),
0, NULL, NULL, NULL);
identity_lut->size,
identity_lut->red,
identity_lut->green,
identity_lut->blue);
}
if (ret != 0)