mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 05:12:15 +00:00
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:
parent
e21f839776
commit
10a840c92d
@ -675,34 +675,43 @@ process_crtc_color_updates (MetaKmsImplDevice *impl_device,
|
||||
if (color_update->gamma.has_update)
|
||||
{
|
||||
MetaGammaLut *gamma = color_update->gamma.state;
|
||||
g_autofree struct drm_color_lut *drm_color_lut = NULL;
|
||||
size_t color_lut_size;
|
||||
int i;
|
||||
uint32_t color_lut_blob_id;
|
||||
uint32_t color_lut_blob_id = 0;
|
||||
|
||||
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++)
|
||||
if (gamma && gamma->size > 0)
|
||||
{
|
||||
drm_color_lut[i].red = gamma->red[i];
|
||||
drm_color_lut[i].green = gamma->green[i];
|
||||
drm_color_lut[i].blue = gamma->blue[i];
|
||||
g_autofree struct drm_color_lut *drm_color_lut = NULL;
|
||||
size_t color_lut_size;
|
||||
int i;
|
||||
|
||||
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++)
|
||||
{
|
||||
drm_color_lut[i].red = gamma->red[i];
|
||||
drm_color_lut[i].green = gamma->green[i];
|
||||
drm_color_lut[i].blue = gamma->blue[i];
|
||||
}
|
||||
|
||||
color_lut_blob_id = store_new_blob (impl_device,
|
||||
blob_ids,
|
||||
drm_color_lut,
|
||||
color_lut_size,
|
||||
error);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
color_lut_blob_id = store_new_blob (impl_device,
|
||||
blob_ids,
|
||||
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);
|
||||
|
||||
if (!add_crtc_property (impl_device,
|
||||
crtc, req,
|
||||
|
@ -516,18 +516,33 @@ process_crtc_color_updates (MetaKmsImplDevice *impl_device,
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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),
|
||||
|
Loading…
Reference in New Issue
Block a user