fd376007fa98180805e74a0230b9266f94068965
[oweals/openwrt.git] /
1 From fa064d93f7bc7e0dd05a4af2d0512c0a9d19fe1f Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Tue, 9 Apr 2019 14:00:07 +0100
4 Subject: [PATCH 599/782] drm/vc4: Set the display number when querying the
5  display resolution
6
7 Without this the two displays got set to the same resolution.
8 (Requires a firmware bug fix to work).
9
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
11 ---
12  drivers/gpu/drm/vc4/vc4_firmware_kms.c | 37 +++++++++++++++++++-------
13  1 file changed, 27 insertions(+), 10 deletions(-)
14
15 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
16 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
17 @@ -75,6 +75,13 @@ struct mailbox_blank_display {
18         u32 blank;
19  };
20  
21 +struct mailbox_get_width_height {
22 +       struct rpi_firmware_property_tag_header tag1;
23 +       u32 display;
24 +       struct rpi_firmware_property_tag_header tag2;
25 +       u32 wh[2];
26 +};
27 +
28  static const struct vc_image_format {
29         u32 drm;        /* DRM_FORMAT_* */
30         u32 vc_image;   /* VC_IMAGE_* */
31 @@ -192,6 +199,7 @@ struct vc4_fkms_connector {
32          * hook.
33          */
34         struct drm_encoder *encoder;
35 +       u32 display_idx;
36  };
37  
38  static inline struct vc4_fkms_connector *
39 @@ -723,21 +731,27 @@ vc4_fkms_connector_detect(struct drm_con
40  static int vc4_fkms_connector_get_modes(struct drm_connector *connector)
41  {
42         struct drm_device *dev = connector->dev;
43 +       struct vc4_fkms_connector *fkms_connector =
44 +               to_vc4_fkms_connector(connector);
45         struct vc4_dev *vc4 = to_vc4_dev(dev);
46 -       u32 wh[2] = {0, 0};
47 -       int ret;
48         struct drm_display_mode *mode;
49 +       struct mailbox_get_width_height wh = {
50 +               .tag1 = {RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM, 4, 0, },
51 +               .display = fkms_connector->display_idx,
52 +               .tag2 = { RPI_FIRMWARE_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT,
53 +                         8, 0, },
54 +       };
55 +       int ret;
56 +
57 +       ret = rpi_firmware_property_list(vc4->firmware, &wh, sizeof(wh));
58  
59 -       ret = rpi_firmware_property(vc4->firmware,
60 -                                   RPI_FIRMWARE_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT,
61 -                                   &wh, sizeof(wh));
62         if (ret) {
63                 DRM_ERROR("Failed to get screen size: %d (0x%08x 0x%08x)\n",
64 -                         ret, wh[0], wh[1]);
65 +                         ret, wh.wh[0], wh.wh[1]);
66                 return 0;
67         }
68  
69 -       mode = drm_cvt_mode(dev, wh[0], wh[1], 60 /* vrefresh */,
70 +       mode = drm_cvt_mode(dev, wh.wh[0], wh.wh[1], 60 /* vrefresh */,
71                             0, 0, false);
72         drm_mode_probed_add(connector, mode);
73  
74 @@ -772,8 +786,9 @@ static const struct drm_connector_helper
75         .best_encoder = vc4_fkms_connector_best_encoder,
76  };
77  
78 -static struct drm_connector *vc4_fkms_connector_init(struct drm_device *dev,
79 -                                                    struct drm_encoder *encoder)
80 +static struct drm_connector *
81 +vc4_fkms_connector_init(struct drm_device *dev, struct drm_encoder *encoder,
82 +                       u32 display_idx)
83  {
84         struct drm_connector *connector = NULL;
85         struct vc4_fkms_connector *fkms_connector;
86 @@ -788,6 +803,7 @@ static struct drm_connector *vc4_fkms_co
87         connector = &fkms_connector->base;
88  
89         fkms_connector->encoder = encoder;
90 +       fkms_connector->display_idx = display_idx;
91  
92         drm_connector_init(dev, connector, &vc4_fkms_connector_funcs,
93                            DRM_MODE_CONNECTOR_HDMIA);
94 @@ -904,7 +920,8 @@ static int vc4_fkms_create_screen(struct
95         drm_encoder_helper_add(&vc4_encoder->base,
96                                &vc4_fkms_encoder_helper_funcs);
97  
98 -       vc4_crtc->connector = vc4_fkms_connector_init(drm, &vc4_encoder->base);
99 +       vc4_crtc->connector = vc4_fkms_connector_init(drm, &vc4_encoder->base,
100 +                                                     display_idx);
101         if (IS_ERR(vc4_crtc->connector)) {
102                 ret = PTR_ERR(vc4_crtc->connector);
103                 goto err_destroy_encoder;