[PATCH v4 23/37] drm/vkms: Properly render plane using their zpos

Louis Chauvet
2026-04-22T16:49:56Z

Currently planes are rendered in creation order. This is not an issue, but
with the introduction of new zpos configuration, it is required to
properly render planes.

Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_crtc.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 35ddc553a5e6..faaa13f8b31e 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -142,14 +142,20 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
return -ENOMEM;
vkms_state->num_active_planes = i;

- i = 0;
+ ret = drm_atomic_normalize_zpos(crtc->dev, state);
+ if (ret)
+ return ret;
+
drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
plane_state = drm_atomic_get_new_plane_state(crtc_state->state, plane);

if (!plane_state->visible)
continue;

- vkms_state->active_planes[i++] =
+ // Order planes according to their normalized_zpos
+ // After drm_atomic_normalize_zpos, the possible values are 0..n_planes-1
+ // so store them using this index
+ vkms_state->active_planes[plane_state->normalized_zpos] =
to_vkms_plane_state(plane_state);
}

--
2.54.0