1 From e99a60f018524bf7b1ba382e3994c22ebcdbafe6 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
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.
11 Correct the handling which was assuming that REFLECT_[X|Y]
12 was instead of ROTATE_x.
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
16 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 37 ++++++++++----------------
17 1 file changed, 14 insertions(+), 23 deletions(-)
19 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
20 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
21 @@ -79,11 +79,6 @@ struct set_plane {
22 #define TRANSFORM_FLIP_HRIZ BIT(16)
23 #define TRANSFORM_FLIP_VERT BIT(17)
25 -#define SUPPORTED_ROTATIONS (DRM_MODE_ROTATE_0 | \
26 - DRM_MODE_ROTATE_180 | \
27 - DRM_MODE_REFLECT_X | \
30 struct mailbox_set_plane {
31 struct rpi_firmware_property_tag_header tag;
32 struct set_plane plane;
33 @@ -523,7 +518,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;
40 mb->plane.vc_image_type = vc_fmt->vc_image;
41 mb->plane.width = fb->width;
42 @@ -544,23 +539,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];
46 - rotation = drm_rotation_simplify(state->rotation, rotation);
50 - case DRM_MODE_ROTATE_0:
51 - mb->plane.transform = TRANSFORM_NO_ROTATE;
53 - case DRM_MODE_ROTATE_180:
54 - mb->plane.transform = TRANSFORM_ROTATE_180;
56 - case DRM_MODE_REFLECT_X:
57 - mb->plane.transform = TRANSFORM_FLIP_HRIZ;
59 - case DRM_MODE_REFLECT_Y:
60 - mb->plane.transform = TRANSFORM_FLIP_VERT;
63 + rotation = drm_rotation_simplify(state->rotation,
65 + DRM_MODE_REFLECT_X |
66 + DRM_MODE_REFLECT_Y);
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;
74 vc4_fkms_margins_adj(state, &mb->plane);
76 @@ -772,7 +760,10 @@ static struct drm_plane *vc4_fkms_plane_
78 drm_plane_create_alpha_property(plane);
79 drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
80 - SUPPORTED_ROTATIONS);
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) |