Userspace sees a single CRTC color management model: the colorop pipeline if DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE is set, or CRTC color properties otherwise. When the other model is hidden, CRTC still holds its previous property settings and, without visibility, the userspace cannot clear it anymore.
Reset the hidden model to its default value on every CRTC included in an atomic commit: clear blobs if colorop pipeline, and set COLOR_PIPELINE to Bypass if CRTC color properties are in place. Colorop values aren't touched, so re-selecting a pipeline later restores them. Only set color_mgmt_changed flag when something was actually reset. Signed-off-by: Melissa Wen <[email protected]> --- v3: - new patch, as for planes, drivers now decide from crtc_state->color_pipeline between colorop or CRTC color properties and the core sets the properties of the model hidden from the client to their defaults. --- drivers/gpu/drm/drm_atomic_uapi.c | 28 ++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 6 ++++-- include/uapi/drm/drm.h | 4 ++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 0a597b9e8005..ca711353fc48 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1695,6 +1695,32 @@ static void complete_signaling(struct drm_device *dev, kfree(fence_state); } +static void +reset_crtc_color_mgmt_props(struct drm_atomic_commit *state, + struct drm_file *file_priv, + bool async_flip) +{ + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + bool changed; + int i; + + /* Async page flip doesn't change properties */ + if (async_flip) + return; + + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { + if (file_priv->crtc_color_pipeline) { + changed = drm_property_replace_blob(&crtc_state->degamma_lut, NULL); + changed |= drm_property_replace_blob(&crtc_state->ctm, NULL); + changed |= drm_property_replace_blob(&crtc_state->gamma_lut, NULL); + } else { + changed = drm_atomic_set_colorop_for_crtc(crtc_state, NULL); + } + crtc_state->color_mgmt_changed |= changed; + } +} + static void set_async_flip(struct drm_atomic_commit *state) { @@ -1853,6 +1879,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, drm_mode_object_put(obj); } + reset_crtc_color_mgmt_props(state, file_priv, async_flip); + ret = prepare_signaling(dev, state, arg, file_priv, &fence_state, &num_fences); if (ret) diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index aba579cef6b6..166e80284bdf 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -277,8 +277,10 @@ struct drm_crtc_state { /** * @color_pipeline: * - * The first colorop of the active color pipeline, or NULL, if no - * color pipeline is active. + * The first colorop of the active color pipeline, or NULL, if no color + * pipeline is active. Drivers program CRTC color management from this + * pipeline when it is set, and from @degamma_lut, @ctm and @gamma_lut + * properties otherwise. */ struct drm_colorop *color_pipeline; diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 514c8f4b3aaf..08bd616774a4 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -915,6 +915,10 @@ struct drm_get_cap { * - DEGAMMA_LUT * - CTM * + * Userspace can only see one CRTC color management model. On every CRTC + * included in an atomic commit, the DRM core resets CRTC color properties of + * the hidden model to default values. + * * The client must enable &DRM_CLIENT_CAP_ATOMIC first. * * This client cap can only be set if the driver sets the corresponding driver -- 2.53.0
