32112f949bd8c1caeda1af7af64cc0fcb0758b04
[openwrt/staging/neocturne.git] /
1 From 6ab30a5dd3fb2ccbd918f147e91eb9bfe9849970 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 16 Oct 2023 12:13:38 +0100
4 Subject: [PATCH] drm/vc4: Correct address offset for planes with src_[xy]
5 offsets
6
7 11cf37e741b4 switched to using drm_fb_dma_get_gem_addr instead of
8 drm_fb_dma_get_gem_obj and adding fb->offset[].
9
10 However the tiled formats need to compute the offset in a more
11 involved manner than drm_fb_dma_get_gem_addr applies, and we
12 were ending up with the offset for src_[xy] being applied twice.
13
14 Switch back to using drm_fb_dma_get_gem_obj and fully computing
15 the offsets ourselves.
16
17 Fixes: 11cf37e741b4 ("drm/vc4: Move the buffer offset out of the vc4_plane_state")
18 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
19 ---
20 drivers/gpu/drm/vc4/vc4_plane.c | 9 ++++-----
21 1 file changed, 4 insertions(+), 5 deletions(-)
22
23 --- a/drivers/gpu/drm/vc4/vc4_plane.c
24 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
25 @@ -1447,9 +1447,9 @@ static int vc4_plane_mode_set(struct drm
26 vc4_state->ptr0_offset[0] = vc4_state->dlist_count;
27
28 for (i = 0; i < num_planes; i++) {
29 - dma_addr_t paddr = drm_fb_dma_get_gem_addr(fb, state, i);
30 + struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, i);
31
32 - vc4_dlist_write(vc4_state, paddr + offsets[i]);
33 + vc4_dlist_write(vc4_state, bo->dma_addr + fb->offsets[i] + offsets[i]);
34 }
35
36 /* Pointer Context Word 0/1/2: Written by the HVS */
37 @@ -1842,9 +1842,8 @@ static int vc6_plane_mode_set(struct drm
38 * TODO: This only covers Raster Scan Order planes
39 */
40 for (i = 0; i < num_planes; i++) {
41 - dma_addr_t paddr = drm_fb_dma_get_gem_addr(fb, state, i);
42 -
43 - paddr += offsets[i];
44 + struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, i);
45 + dma_addr_t paddr = bo->dma_addr + fb->offsets[i] + offsets[i];
46
47 /* Pointer Word 0 */
48 vc4_state->ptr0_offset[i] = vc4_state->dlist_count;