d9aa85785654ab64f53ef7f6000984fe41850763
[openwrt/staging/stintel.git] /
1 From aa5ba5fd06cffacf4831fe6e9aef65081287924e Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Mon, 15 Mar 2021 13:28:06 +0000
4 Subject: [PATCH] vc4/drm: vc4_plane: Remove subpixel positioning check
5
6 There is little harm in ignoring fractional coordinates
7 (they just get truncated).
8
9 Without this:
10 modetest -M vc4 -F tiles,gradient -s 32:1920x1080-60 -P89@74:1920x1080*.1.1@XR24
11
12 is rejected. We have the same issue in Kodi when trying to
13 use zoom options on video.
14
15 Note: even if all coordinates are fully integer. e.g.
16 src:[0,0,1920,1080] dest:[-10,-10,1940,1100]
17
18 it will still get rejected as drm_atomic_helper_check_plane_state
19 uses drm_rect_clip_scaled which transforms this to fractional src coords
20
21 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
22 ---
23 drivers/gpu/drm/vc4/vc4_plane.c | 21 ++++++++-------------
24 1 file changed, 8 insertions(+), 13 deletions(-)
25
26 --- a/drivers/gpu/drm/vc4/vc4_plane.c
27 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
28 @@ -339,7 +339,6 @@ static int vc4_plane_setup_clipping_and_
29 struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
30 struct drm_framebuffer *fb = state->fb;
31 struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
32 - u32 subpixel_src_mask = (1 << 16) - 1;
33 int num_planes = fb->format->num_planes;
34 struct drm_crtc_state *crtc_state;
35 u32 h_subsample = fb->format->hsub;
36 @@ -361,18 +360,14 @@ static int vc4_plane_setup_clipping_and_
37 for (i = 0; i < num_planes; i++)
38 vc4_state->offsets[i] = bo->paddr + fb->offsets[i];
39
40 - /* We don't support subpixel source positioning for scaling. */
41 - if ((state->src.x1 & subpixel_src_mask) ||
42 - (state->src.x2 & subpixel_src_mask) ||
43 - (state->src.y1 & subpixel_src_mask) ||
44 - (state->src.y2 & subpixel_src_mask)) {
45 - return -EINVAL;
46 - }
47 -
48 - vc4_state->src_x = state->src.x1 >> 16;
49 - vc4_state->src_y = state->src.y1 >> 16;
50 - vc4_state->src_w[0] = (state->src.x2 - state->src.x1) >> 16;
51 - vc4_state->src_h[0] = (state->src.y2 - state->src.y1) >> 16;
52 + /* We don't support subpixel source positioning for scaling,
53 + * but fractional coordinates can be generated by clipping
54 + * so just round for now
55 + */
56 + vc4_state->src_x = DIV_ROUND_CLOSEST(state->src.x1, 1<<16);
57 + vc4_state->src_y = DIV_ROUND_CLOSEST(state->src.y1, 1<<16);
58 + vc4_state->src_w[0] = DIV_ROUND_CLOSEST(state->src.x2, 1<<16) - vc4_state->src_x;
59 + vc4_state->src_h[0] = DIV_ROUND_CLOSEST(state->src.y2, 1<<16) - vc4_state->src_y;
60
61 vc4_state->crtc_x = state->dst.x1;
62 vc4_state->crtc_y = state->dst.y1;