fbfcd747cd1299785fb75d7119694e8f4fbeb6b9
[oweals/openwrt.git] /
1 From ebb8a4e93e242311d319098ea56e4ef4d92c4d19 Mon Sep 17 00:00:00 2001
2 From: James Hughes <james.hughes@raspberrypi.org>
3 Date: Wed, 16 Oct 2019 14:49:23 +0100
4 Subject: [PATCH] drm:vc4 Added calls for firmware display
5  blank/unblank
6
7 Requires new display power mailbox call to be present.
8
9 Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
10 ---
11  drivers/gpu/drm/vc4/vc4_firmware_kms.c     | 25 ++++++++++++++++++++++
12  include/soc/bcm2835/raspberrypi-firmware.h |  2 +-
13  2 files changed, 26 insertions(+), 1 deletion(-)
14
15 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
16 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
17 @@ -91,6 +91,12 @@ struct mailbox_blank_display {
18         u32 blank;
19  };
20  
21 +struct mailbox_display_pwr {
22 +       struct rpi_firmware_property_tag_header tag1;
23 +       u32 display;
24 +       u32 state;
25 +};
26 +
27  struct mailbox_get_edid {
28         struct rpi_firmware_property_tag_header tag1;
29         u32 block;
30 @@ -272,6 +278,7 @@ struct vc4_fkms_encoder {
31         struct drm_encoder base;
32         bool hdmi_monitor;
33         bool rgb_range_selectable;
34 +       int display_num;
35  };
36  
37  static inline struct vc4_fkms_encoder *
38 @@ -1613,13 +1620,29 @@ static const struct drm_encoder_funcs vc
39         .destroy = vc4_fkms_encoder_destroy,
40  };
41  
42 +static void vc4_fkms_display_power(struct drm_encoder *encoder, bool power)
43 +{
44 +       struct vc4_fkms_encoder *vc4_encoder = to_vc4_fkms_encoder(encoder);
45 +       struct vc4_dev *vc4 = to_vc4_dev(encoder->dev);
46 +
47 +       struct mailbox_display_pwr pwr = {
48 +               .tag1 = {RPI_FIRMWARE_SET_DISPLAY_POWER, 8, 0, },
49 +               .display = vc4_encoder->display_num,
50 +               .state = power ? 1 : 0,
51 +       };
52 +
53 +       rpi_firmware_property_list(vc4->firmware, &pwr, sizeof(pwr));
54 +}
55 +
56  static void vc4_fkms_encoder_enable(struct drm_encoder *encoder)
57  {
58 +       vc4_fkms_display_power(encoder, true);
59         DRM_DEBUG_KMS("Encoder_enable\n");
60  }
61  
62  static void vc4_fkms_encoder_disable(struct drm_encoder *encoder)
63  {
64 +       vc4_fkms_display_power(encoder, false);
65         DRM_DEBUG_KMS("Encoder_disable\n");
66  }
67  
68 @@ -1695,6 +1718,8 @@ static int vc4_fkms_create_screen(struct
69         if (!vc4_encoder)
70                 return -ENOMEM;
71         vc4_crtc->encoder = &vc4_encoder->base;
72 +
73 +       vc4_encoder->display_num = display_ref;
74         vc4_encoder->base.possible_crtcs |= drm_crtc_mask(crtc) ;
75  
76         drm_encoder_init(drm, &vc4_encoder->base, &vc4_fkms_encoder_funcs,
77 --- a/include/soc/bcm2835/raspberrypi-firmware.h
78 +++ b/include/soc/bcm2835/raspberrypi-firmware.h
79 @@ -155,7 +155,7 @@ enum rpi_firmware_property_tag {
80         RPI_FIRMWARE_GET_DISPLAY_TIMING =                     0x00040017,
81         RPI_FIRMWARE_SET_TIMING =                             0x00048017,
82         RPI_FIRMWARE_GET_DISPLAY_CFG =                        0x00040018,
83 -
84 +       RPI_FIRMWARE_SET_DISPLAY_POWER =                      0x00048019,
85         RPI_FIRMWARE_GET_COMMAND_LINE =                       0x00050001,
86         RPI_FIRMWARE_GET_DMA_CHANNELS =                       0x00060001,
87  };