Add the state of every CRTC colorop to the duplicated state, active or
not, so their settings persist on a reset cycle.

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

---
v3:
- new patch
- Note: if "drm/atomic: duplicate state of all colorops" for colorop
  planes [1] lands first, the plane and CRTC loops can be merged into a
  single pass over all colorops.
  [1] https://lore.kernel.org/dri-devel/[email protected]/
---
 drivers/gpu/drm/drm_atomic_helper.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index ccfe3840d505..da908f0266bf 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3730,6 +3730,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
        struct drm_connector_list_iter conn_iter;
        struct drm_plane *plane;
        struct drm_crtc *crtc;
+       struct drm_colorop *colorop;
        int err = 0;
 
        state = drm_atomic_commit_alloc(dev);
@@ -3749,6 +3750,23 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
                }
        }
 
+       /*
+        * Add all CRTC colorops, active or not, so their settings survive the
+        * colorop reset done on resume.
+        */
+       drm_for_each_colorop(colorop, dev) {
+               struct drm_colorop_state *colorop_state;
+
+               if (!colorop->crtc)
+                       continue;
+
+               colorop_state = drm_atomic_get_colorop_state(state, colorop);
+               if (IS_ERR(colorop_state)) {
+                       err = PTR_ERR(colorop_state);
+                       goto free;
+               }
+       }
+
        drm_for_each_plane(plane, dev) {
                struct drm_plane_state *plane_state;
 
-- 
2.53.0

Reply via email to