1 From c470db2240fa76293025852533ae8bf1c5679bfb Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Mon, 22 Mar 2021 19:43:48 +0000
4 Subject: [PATCH] vc4/drm: Fix source offsets with DRM_FORMAT_P030
6 Spec says: bits [31:4] of the given address should point to
7 the 128-bit word containing the desired starting pixel,
8 and bits[3:0] should be between 0 and 11, indicating which
9 of the 12-pixels in that 128-bit word is the first pixel to be used
11 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
13 drivers/gpu/drm/vc4/vc4_plane.c | 24 ++++++++++++++++--------
14 1 file changed, 16 insertions(+), 8 deletions(-)
16 --- a/drivers/gpu/drm/vc4/vc4_plane.c
17 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
18 @@ -822,9 +822,20 @@ static int vc4_plane_mode_set(struct drm
19 u32 tile_w, tile, x_off, pix_per_tile;
21 if (fb->format->format == DRM_FORMAT_P030) {
23 + * Spec says: bits [31:4] of the given address should point to
24 + * the 128-bit word containing the desired starting pixel,
25 + * and bits[3:0] should be between 0 and 11, indicating which
26 + * of the 12-pixels in that 128-bit word is the first pixel to be used
28 + u32 aligned = vc4_state->src_x / 12;
29 + u32 last_bits = vc4_state->src_x % 12;
31 + x_off = aligned * 16 + last_bits;
32 hvs_format = HVS_PIXEL_FORMAT_YCBCR_10BIT;
33 tiling = SCALER_CTL0_TILING_128B;
38 hvs_format = HVS_PIXEL_FORMAT_H264;
40 @@ -844,17 +855,16 @@ static int vc4_plane_mode_set(struct drm
44 + pix_per_tile = tile_w / fb->format->cpp[0];
45 + x_off = (vc4_state->src_x % pix_per_tile) /
46 + (i ? h_subsample : 1) * fb->format->cpp[i];
48 if (param > SCALER_TILE_HEIGHT_MASK) {
49 DRM_DEBUG_KMS("SAND height too large (%d)\n",
54 - pix_per_tile = tile_w / fb->format->cpp[0];
55 tile = vc4_state->src_x / pix_per_tile;
56 - x_off = vc4_state->src_x % pix_per_tile;
58 /* Adjust the base pointer to the first pixel to be scanned
61 @@ -870,9 +880,7 @@ static int vc4_plane_mode_set(struct drm
62 vc4_state->offsets[i] += src_y /
63 (i ? v_subsample : 1) *
65 - vc4_state->offsets[i] += x_off /
66 - (i ? h_subsample : 1) *
68 + vc4_state->offsets[i] += x_off & ~(i ? 1 : 0);
71 pitch0 = VC4_SET_FIELD(param, SCALER_TILE_HEIGHT);