8c8bb69e772cb7628974aeab7be3363785fb3472
[openwrt/staging/linusw.git] /
1 From a8af2085e26bcefad8fb65e2b44d12777a84e219 Mon Sep 17 00:00:00 2001
2 From: Boris Brezillon <boris.brezillon@bootlin.com>
3 Date: Fri, 7 Dec 2018 09:36:05 +0100
4 Subject: [PATCH] drm/vc4: Fix negative X/Y positioning on SAND planes
5
6 Commit 8e75d582db02bcb171d65ec71eecbd3072a5fd3a upstream.
7
8 Commit 3e407417b192 ("drm/vc4: Fix X/Y positioning of planes using
9 T_TILES modifier") fixed the problem with T_TILES format, but left
10 things in a non-working state for SAND formats. Address that now.
11
12 Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
13 Reviewed-by: Eric Anholt <eric@anholt.net>
14 Link: https://patchwork.freedesktop.org/patch/msgid/20181207083606.15449-1-boris.brezillon@bootlin.com
15 ---
16 drivers/gpu/drm/vc4/vc4_plane.c | 21 +++++++++++++++++++++
17 1 file changed, 21 insertions(+)
18
19 --- a/drivers/gpu/drm/vc4/vc4_plane.c
20 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
21 @@ -684,6 +684,7 @@ static int vc4_plane_mode_set(struct drm
22 case DRM_FORMAT_MOD_BROADCOM_SAND128:
23 case DRM_FORMAT_MOD_BROADCOM_SAND256: {
24 uint32_t param = fourcc_mod_broadcom_param(fb->modifier);
25 + u32 tile_w, tile, x_off, pix_per_tile;
26
27 /* Column-based NV12 or RGBA.
28 */
29 @@ -703,12 +704,15 @@ static int vc4_plane_mode_set(struct drm
30 switch (base_format_mod) {
31 case DRM_FORMAT_MOD_BROADCOM_SAND64:
32 tiling = SCALER_CTL0_TILING_64B;
33 + tile_w = 64;
34 break;
35 case DRM_FORMAT_MOD_BROADCOM_SAND128:
36 tiling = SCALER_CTL0_TILING_128B;
37 + tile_w = 128;
38 break;
39 case DRM_FORMAT_MOD_BROADCOM_SAND256:
40 tiling = SCALER_CTL0_TILING_256B_OR_T;
41 + tile_w = 256;
42 break;
43 default:
44 break;
45 @@ -719,6 +723,23 @@ static int vc4_plane_mode_set(struct drm
46 return -EINVAL;
47 }
48
49 + pix_per_tile = tile_w / fb->format->cpp[0];
50 + tile = vc4_state->src_x / pix_per_tile;
51 + x_off = vc4_state->src_x % pix_per_tile;
52 +
53 + /* Adjust the base pointer to the first pixel to be scanned
54 + * out.
55 + */
56 + for (i = 0; i < num_planes; i++) {
57 + vc4_state->offsets[i] += param * tile_w * tile;
58 + vc4_state->offsets[i] += vc4_state->src_y /
59 + (i ? v_subsample : 1) *
60 + tile_w;
61 + vc4_state->offsets[i] += x_off /
62 + (i ? h_subsample : 1) *
63 + fb->format->cpp[i];
64 + }
65 +
66 pitch0 = VC4_SET_FIELD(param, SCALER_TILE_HEIGHT);
67 break;
68 }