f98002e99cdd8985925d29038689817631b71abc
[openwrt/staging/981213.git] /
1 From 23ed834712dfc0d25451f16b46ae9c19abb675b5 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 18 Sep 2019 15:49:13 +0100
4 Subject: [PATCH] drm/vc4: Correct handling of rotation parameter in
5 fkms
6
7 One bit within DRM_MODE_ROTATE_MASK will always be set to
8 determine the base rotation 0/90/180/270, and then REFLECT_X
9 and REFLECT_Y are on top.
10
11 Correct the handling which was assuming that REFLECT_[X|Y]
12 was instead of ROTATE_x.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
15 ---
16 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 37 ++++++++++----------------
17 1 file changed, 14 insertions(+), 23 deletions(-)
18
19 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
20 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
21 @@ -82,11 +82,6 @@ struct set_plane {
22 #define TRANSFORM_FLIP_HRIZ BIT(16)
23 #define TRANSFORM_FLIP_VERT BIT(17)
24
25 -#define SUPPORTED_ROTATIONS (DRM_MODE_ROTATE_0 | \
26 - DRM_MODE_ROTATE_180 | \
27 - DRM_MODE_REFLECT_X | \
28 - DRM_MODE_REFLECT_Y)
29 -
30 struct mailbox_set_plane {
31 struct rpi_firmware_property_tag_header tag;
32 struct set_plane plane;
33 @@ -525,7 +520,7 @@ static int vc4_plane_to_mb(struct drm_pl
34 const struct vc_image_format *vc_fmt =
35 vc4_get_vc_image_fmt(drm_fmt->format);
36 int num_planes = fb->format->num_planes;
37 - unsigned int rotation = SUPPORTED_ROTATIONS;
38 + unsigned int rotation;
39
40 mb->plane.vc_image_type = vc_fmt->vc_image;
41 mb->plane.width = fb->width;
42 @@ -546,23 +541,16 @@ static int vc4_plane_to_mb(struct drm_pl
43 mb->plane.is_vu = vc_fmt->is_vu;
44 mb->plane.planes[0] = bo->paddr + fb->offsets[0];
45
46 - rotation = drm_rotation_simplify(state->rotation, rotation);
47 -
48 - switch (rotation) {
49 - default:
50 - case DRM_MODE_ROTATE_0:
51 - mb->plane.transform = TRANSFORM_NO_ROTATE;
52 - break;
53 - case DRM_MODE_ROTATE_180:
54 - mb->plane.transform = TRANSFORM_ROTATE_180;
55 - break;
56 - case DRM_MODE_REFLECT_X:
57 - mb->plane.transform = TRANSFORM_FLIP_HRIZ;
58 - break;
59 - case DRM_MODE_REFLECT_Y:
60 - mb->plane.transform = TRANSFORM_FLIP_VERT;
61 - break;
62 - }
63 + rotation = drm_rotation_simplify(state->rotation,
64 + DRM_MODE_ROTATE_0 |
65 + DRM_MODE_REFLECT_X |
66 + DRM_MODE_REFLECT_Y);
67 +
68 + mb->plane.transform = TRANSFORM_NO_ROTATE;
69 + if (rotation & DRM_MODE_REFLECT_X)
70 + mb->plane.transform |= TRANSFORM_FLIP_HRIZ;
71 + if (rotation & DRM_MODE_REFLECT_Y)
72 + mb->plane.transform |= TRANSFORM_FLIP_VERT;
73
74 vc4_fkms_margins_adj(state, &mb->plane);
75
76 @@ -803,7 +791,10 @@ static struct drm_plane *vc4_fkms_plane_
77
78 drm_plane_create_alpha_property(plane);
79 drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
80 - SUPPORTED_ROTATIONS);
81 + DRM_MODE_ROTATE_0 |
82 + DRM_MODE_ROTATE_180 |
83 + DRM_MODE_REFLECT_X |
84 + DRM_MODE_REFLECT_Y);
85 drm_plane_create_color_properties(plane,
86 BIT(DRM_COLOR_YCBCR_BT601) |
87 BIT(DRM_COLOR_YCBCR_BT709) |