From 8ebebb20ef5825a4183c09e65cb90d6f2d5db0a6 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 6 May 2022 13:57:12 +0300 Subject: [PATCH] drm-backend: add color_outcome / HDR metadata serial Output color profile may be changed in flight. Output basic color characteristics and EOTF mode cannot yet be changed in flight, but it is reasonable to assume they could in the future. Therefore the color outcome data may change in flight as well, which is the basis for HDR metadata, which needs to be updated as well. Track the changes to color outcome data with a serial number. DRM-backend checks the serial number to see if it needs to re-create the HDR metadata blob. This allows the changes to propagate all the way to KMS. The code added here is more of a reminder of what should happen than a tested path. Signed-off-by: Pekka Paalanen --- include/libweston/libweston.h | 1 + libweston/backend-drm/drm-internal.h | 1 + libweston/backend-drm/kms-color.c | 7 ++++++- libweston/compositor.c | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index ceaca6a9..c361d76a 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -534,6 +534,7 @@ struct weston_output { struct weston_color_characteristics color_characteristics; struct weston_output_color_outcome *color_outcome; + uint64_t color_outcome_serial; int (*enable)(struct weston_output *output); int (*disable)(struct weston_output *output); diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 87049de5..1afbaf52 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -551,6 +551,7 @@ struct drm_output { uint32_t gbm_bo_flags; uint32_t hdr_output_metadata_blob_id; + uint64_t ackd_color_outcome_serial; /* Plane being displayed directly on the CRTC */ struct drm_plane *scanout_plane; diff --git a/libweston/backend-drm/kms-color.c b/libweston/backend-drm/kms-color.c index 8219c94c..476480d5 100644 --- a/libweston/backend-drm/kms-color.c +++ b/libweston/backend-drm/kms-color.c @@ -113,7 +113,8 @@ drm_output_ensure_hdr_output_metadata_blob(struct drm_output *output) uint32_t blob_id = 0; int ret; - if (output->hdr_output_metadata_blob_id) + if (output->hdr_output_metadata_blob_id && + output->ackd_color_outcome_serial == output->base.color_outcome_serial) return 0; src = weston_output_get_hdr_metadata_type1(&output->base); @@ -167,7 +168,11 @@ drm_output_ensure_hdr_output_metadata_blob(struct drm_output *output) return -1; } + drmModeDestroyPropertyBlob(output->backend->drm.fd, + output->hdr_output_metadata_blob_id); + output->hdr_output_metadata_blob_id = blob_id; + output->ackd_color_outcome_serial = output->base.color_outcome_serial; return 0; } diff --git a/libweston/compositor.c b/libweston/compositor.c index c532414e..45502e18 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -6537,6 +6537,7 @@ weston_output_set_color_outcome(struct weston_output *output) weston_output_color_outcome_destroy(&output->color_outcome); output->color_outcome = colorout; + output->color_outcome_serial++; output->from_blend_to_output_by_backend = false;