kms/impl-device: Handle NULL gamma updates

We should not ever get one right now, but if we do, a NULL update means
we bypass the gamma LUT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3309>
This commit is contained in:
Sebastian Wick 2023-10-04 18:15:40 +02:00 committed by Marge Bot
parent e21f839776
commit 10a840c92d
2 changed files with 60 additions and 36 deletions

View File

@ -675,12 +675,15 @@ process_crtc_color_updates (MetaKmsImplDevice *impl_device,
if (color_update->gamma.has_update)
{
MetaGammaLut *gamma = color_update->gamma.state;
uint32_t color_lut_blob_id = 0;
if (gamma && gamma->size > 0)
{
g_autofree struct drm_color_lut *drm_color_lut = NULL;
size_t color_lut_size;
int i;
uint32_t color_lut_blob_id;
color_lut_size = sizeof (struct drm_color_lut) * gamma->size;
color_lut_size = sizeof(struct drm_color_lut) * gamma->size;
drm_color_lut = g_malloc (color_lut_size);
for (i = 0; i < gamma->size; i++)
@ -695,14 +698,20 @@ process_crtc_color_updates (MetaKmsImplDevice *impl_device,
drm_color_lut,
color_lut_size,
error);
if (!color_lut_blob_id)
return FALSE;
meta_topic (META_DEBUG_KMS,
"[atomic] Setting CRTC (%u, %s) gamma, size: %zu",
meta_kms_crtc_get_id (crtc),
meta_kms_impl_device_get_path (impl_device),
gamma->size);
}
else
{
meta_topic (META_DEBUG_KMS,
"[atomic] Setting CRTC (%u, %s) gamma to bypass",
meta_kms_crtc_get_id (crtc),
meta_kms_impl_device_get_path (impl_device));
}
if (!add_crtc_property (impl_device,
crtc, req,

View File

@ -516,18 +516,33 @@ process_crtc_color_updates (MetaKmsImplDevice *impl_device,
int fd;
int ret;
fd = meta_kms_impl_device_get_fd (impl_device);
if (gamma)
{
meta_topic (META_DEBUG_KMS,
"[simple] Setting CRTC %u (%s) gamma, size: %zu",
meta_kms_crtc_get_id (crtc),
meta_kms_impl_device_get_path (impl_device),
gamma->size);
fd = meta_kms_impl_device_get_fd (impl_device);
ret = drmModeCrtcSetGamma (fd, meta_kms_crtc_get_id (crtc),
gamma->size,
gamma->red,
gamma->green,
gamma->blue);
}
else
{
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);
}
if (ret != 0)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret),