]> Gentwo Git Trees - linux/.git/commitdiff
drm/colorop: define a new macro for_each_new_colorop_in_state
authorAlex Hung <alex.hung@amd.com>
Sat, 15 Nov 2025 00:01:49 +0000 (17:01 -0700)
committerSimon Ser <contact@emersion.fr>
Wed, 26 Nov 2025 22:03:34 +0000 (23:03 +0100)
Create a new macro for_each_new_colorop_in_state to access new
drm_colorop_state updated from uapi.

Reviewed-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Link: https://patch.msgid.link/20251115000237.3561250-25-alex.hung@amd.com
include/drm/drm_atomic.h

index e65ea288cb8be82b23c07e4be23d034455cea1b0..43783891d3594be1031e5ba5bde7b02545e08592 100644 (file)
@@ -1089,6 +1089,26 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
                              (old_colorop_state) = (__state)->colorops[__i].old_state,\
                              (new_colorop_state) = (__state)->colorops[__i].new_state, 1))
 
+/**
+ * for_each_new_colorop_in_state - iterate over all colorops in an atomic update
+ * @__state: &struct drm_atomic_state pointer
+ * @colorop: &struct drm_colorop iteration cursor
+ * @new_colorop_state: &struct drm_colorop_state iteration cursor for the new state
+ * @__i: int iteration cursor, for macro-internal use
+ *
+ * This iterates over all colorops in an atomic update, tracking new state. This is
+ * useful in places where the state delta needs to be considered, for example in
+ * atomic check functions.
+ */
+#define for_each_new_colorop_in_state(__state, colorop, new_colorop_state, __i) \
+       for ((__i) = 0;                                                 \
+            (__i) < (__state)->dev->mode_config.num_colorop;           \
+            (__i)++)                                                   \
+               for_each_if ((__state)->colorops[__i].ptr &&            \
+                            ((colorop) = (__state)->colorops[__i].ptr, \
+                             (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \
+                             (new_colorop_state) = (__state)->colorops[__i].new_state, 1))
+
 /**
  * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update
  * @__state: &struct drm_atomic_state pointer