drm/vc4: Fix FKMS for when the YUV chroma planes are different buffers
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Thu, 30 Mar 2023 16:18:36 +0000 (17:18 +0100)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:34:53 +0000 (11:34 +0000)
The code was assuming that it was a single buffer with offsets,
when kmstest uses separate buffers and 0 offsets for each plane.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_firmware_kms.c

index e420e005cd1f735e4f6f8fd1ae71526b3cee7e92..8541e50f03f3077add28255ff350750658cc807d 100644 (file)
@@ -519,7 +519,7 @@ static int vc4_plane_to_mb(struct drm_plane *plane,
                           struct drm_plane_state *state)
 {
        struct drm_framebuffer *fb = state->fb;
-       struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, 0);
+       struct drm_gem_dma_object *bo;
        const struct drm_format_info *drm_fmt = fb->format;
        const struct vc_image_format *vc_fmt =
                                        vc4_get_vc_image_fmt(drm_fmt->format);
@@ -543,6 +543,7 @@ static int vc4_plane_to_mb(struct drm_plane *plane,
                                        state->normalized_zpos : -127;
        mb->plane.num_planes = num_planes;
        mb->plane.is_vu = vc_fmt->is_vu;
+       bo = drm_fb_dma_get_gem_obj(fb, 0);
        mb->plane.planes[0] = bo->dma_addr + fb->offsets[0];
 
        rotation = drm_rotation_simplify(state->rotation,
@@ -563,11 +564,14 @@ static int vc4_plane_to_mb(struct drm_plane *plane,
                /* Makes assumptions on the stride for the chroma planes as we
                 * can't easily plumb in non-standard pitches.
                 */
+               bo = drm_fb_dma_get_gem_obj(fb, 1);
                mb->plane.planes[1] = bo->dma_addr + fb->offsets[1];
-               if (num_planes > 2)
+               if (num_planes > 2) {
+                       bo = drm_fb_dma_get_gem_obj(fb, 2);
                        mb->plane.planes[2] = bo->dma_addr + fb->offsets[2];
-               else
+               } else {
                        mb->plane.planes[2] = 0;
+               }
 
                /* Special case the YUV420 with U and V as line interleaved
                 * planes as we have special handling for that case.