As done for plane colorops by commit 2e235e2a2784b ("drm/atomic: track
individual colorop updates"), make drm_atomic_set_colorop_for_crtc()
report whether the CRTC color pipeline changed and set
CRTC color_mgmt_changed flag accordingly.

Signed-off-by: Melissa Wen <[email protected]>

---
v3:
- new patch: set color_mgmt_changed when the CRTC COLOR_PIPELINE value
  changes, as commit 2e235e2a2784 does for planes
---
 drivers/gpu/drm/drm_atomic_uapi.c | 12 ++++++++++--
 include/drm/drm_atomic_uapi.h     |  2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
b/drivers/gpu/drm/drm_atomic_uapi.c
index 9c3889ebda2b..183716cf0db9 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -301,13 +301,18 @@ EXPORT_SYMBOL(drm_atomic_set_colorop_for_plane);
  *
  * Helper function to select the color pipeline on a crtc by setting
  * it to the first drm_colorop element of the pipeline.
+ *
+ * Return: true if CRTC color pipeline value changed, false otherwise.
  */
-void
+bool
 drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
                                 struct drm_colorop *colorop)
 {
        struct drm_crtc *crtc = crtc_state->crtc;
 
+       if (crtc_state->color_pipeline == colorop)
+               return false;
+
        if (colorop)
                drm_dbg_atomic(crtc->dev,
                               "Set [COLOROP:%d] for [CRTC:%d:%s] state %p\n",
@@ -319,6 +324,8 @@ drm_atomic_set_colorop_for_crtc(struct drm_crtc_state 
*crtc_state,
                               crtc->base.id, crtc->name, crtc_state);
 
        crtc_state->color_pipeline = colorop;
+
+       return true;
 }
 EXPORT_SYMBOL(drm_atomic_set_colorop_for_crtc);
 
@@ -449,7 +456,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc 
*crtc,
                if (val && !colorop)
                        return -EACCES;
 
-               drm_atomic_set_colorop_for_crtc(state, colorop);
+               state->color_mgmt_changed |=
+                       drm_atomic_set_colorop_for_crtc(state, colorop);
        } else if (property == config->prop_mode_id) {
                struct drm_property_blob *mode =
                        drm_property_lookup_blob(dev, val);
diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h
index 90e5c207a53b..04fb32eccd0f 100644
--- a/include/drm/drm_atomic_uapi.h
+++ b/include/drm/drm_atomic_uapi.h
@@ -54,7 +54,7 @@ void drm_atomic_set_fb_for_plane(struct drm_plane_state 
*plane_state,
                                 struct drm_framebuffer *fb);
 bool drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
                                      struct drm_colorop *colorop);
-void drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
+bool drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
                                     struct drm_colorop *colorop);
 int __must_check
 drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
-- 
2.53.0

Reply via email to