Skip to content

Commit 55de292

Browse files
Shirish SHarry Wentland
authored andcommitted
drm/atomic: Add new reverse iterator over all plane state (V2)
Add reverse iterator for_each_oldnew_plane_in_state_reverse to compliment the for_each_oldnew_plane_in_state way or reading plane states. The plane states are required to be read in reverse order for amd drivers, cause the z order convention followed in linux is opposite to how the planes are supposed to be presented to DC engine, which is in common to both windows and linux. V2: fix compile time errors due to -Werror flag. Signed-off-by: Shirish S <[email protected]> Signed-off-by: Pratik Vishwakarma <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Harry Wentland <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 100bc0d commit 55de292

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/drm/drm_atomic.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,28 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
753753
(old_plane_state) = (__state)->planes[__i].old_state,\
754754
(new_plane_state) = (__state)->planes[__i].new_state, 1))
755755

756+
/**
757+
* for_each_oldnew_plane_in_state_reverse - iterate over all planes in an atomic
758+
* update in reverse order
759+
* @__state: &struct drm_atomic_state pointer
760+
* @plane: &struct drm_plane iteration cursor
761+
* @old_plane_state: &struct drm_plane_state iteration cursor for the old state
762+
* @new_plane_state: &struct drm_plane_state iteration cursor for the new state
763+
* @__i: int iteration cursor, for macro-internal use
764+
*
765+
* This iterates over all planes in an atomic update in reverse order,
766+
* tracking both old and new state. This is useful in places where the
767+
* state delta needs to be considered, for example in atomic check functions.
768+
*/
769+
#define for_each_oldnew_plane_in_state_reverse(__state, plane, old_plane_state, new_plane_state, __i) \
770+
for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1); \
771+
(__i) >= 0; \
772+
(__i)--) \
773+
for_each_if ((__state)->planes[__i].ptr && \
774+
((plane) = (__state)->planes[__i].ptr, \
775+
(old_plane_state) = (__state)->planes[__i].old_state,\
776+
(new_plane_state) = (__state)->planes[__i].new_state, 1))
777+
756778
/**
757779
* for_each_old_plane_in_state - iterate over all planes in an atomic update
758780
* @__state: &struct drm_atomic_state pointer

0 commit comments

Comments
 (0)