brcm2708: update linux 4.4 patches to latest version
[oweals/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0280-drm-vc4-Fix-which-value-is-being-used-for-source-ima.patch
1 From dd89447cbae60a723e7192f4c176eb62672dfb2b Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Mon, 28 Dec 2015 14:45:25 -0800
4 Subject: [PATCH] drm/vc4: Fix which value is being used for source image size.
5
6 This doesn't matter yet since we only allow 1:1 scaling, but the
7 comment clearly says we should be using the source size.
8
9 Signed-off-by: Eric Anholt <eric@anholt.net>
10 (cherry picked from commit f863e356013d628fa65b1cd89aa298eed26fc936)
11 ---
12  drivers/gpu/drm/vc4/vc4_plane.c | 23 ++++++++++++++---------
13  1 file changed, 14 insertions(+), 9 deletions(-)
14
15 --- a/drivers/gpu/drm/vc4/vc4_plane.c
16 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
17 @@ -47,6 +47,8 @@ struct vc4_plane_state {
18  
19         /* Clipped coordinates of the plane on the display. */
20         int crtc_x, crtc_y, crtc_w, crtc_h;
21 +       /* Clipped size of the area scanned from in the FB. */
22 +       u32 src_w, src_h;
23  
24         /* Offset to start scanning out from the start of the plane's
25          * BO.
26 @@ -186,11 +188,6 @@ static int vc4_plane_setup_clipping_and_
27  
28         vc4_state->offset = fb->offsets[0];
29  
30 -       vc4_state->crtc_x = state->crtc_x;
31 -       vc4_state->crtc_y = state->crtc_y;
32 -       vc4_state->crtc_w = state->crtc_w;
33 -       vc4_state->crtc_h = state->crtc_h;
34 -
35         if (state->crtc_w << 16 != state->src_w ||
36             state->crtc_h << 16 != state->src_h) {
37                 /* We don't support scaling yet, which involves
38 @@ -201,17 +198,25 @@ static int vc4_plane_setup_clipping_and_
39                 return -EINVAL;
40         }
41  
42 +       vc4_state->src_w = state->src_w >> 16;
43 +       vc4_state->src_h = state->src_h >> 16;
44 +
45 +       vc4_state->crtc_x = state->crtc_x;
46 +       vc4_state->crtc_y = state->crtc_y;
47 +       vc4_state->crtc_w = state->crtc_w;
48 +       vc4_state->crtc_h = state->crtc_h;
49 +
50         if (vc4_state->crtc_x < 0) {
51                 vc4_state->offset += (drm_format_plane_cpp(fb->pixel_format,
52                                                            0) *
53                                       -vc4_state->crtc_x);
54 -               vc4_state->crtc_w += vc4_state->crtc_x;
55 +               vc4_state->src_w += vc4_state->crtc_x;
56                 vc4_state->crtc_x = 0;
57         }
58  
59         if (vc4_state->crtc_y < 0) {
60                 vc4_state->offset += fb->pitches[0] * -vc4_state->crtc_y;
61 -               vc4_state->crtc_h += vc4_state->crtc_y;
62 +               vc4_state->src_h += vc4_state->crtc_y;
63                 vc4_state->crtc_y = 0;
64         }
65  
66 @@ -260,8 +265,8 @@ static int vc4_plane_mode_set(struct drm
67                                       SCALER_POS2_ALPHA_MODE_PIPELINE :
68                                       SCALER_POS2_ALPHA_MODE_FIXED,
69                                       SCALER_POS2_ALPHA_MODE) |
70 -                       VC4_SET_FIELD(vc4_state->crtc_w, SCALER_POS2_WIDTH) |
71 -                       VC4_SET_FIELD(vc4_state->crtc_h, SCALER_POS2_HEIGHT));
72 +                       VC4_SET_FIELD(vc4_state->src_w, SCALER_POS2_WIDTH) |
73 +                       VC4_SET_FIELD(vc4_state->src_h, SCALER_POS2_HEIGHT));
74  
75         /* Position Word 3: Context.  Written by the HVS. */
76         vc4_dlist_write(vc4_state, 0xc0c0c0c0);