1 From 82a5aa1df1b04efef46c7be82a7d71ea5300ce92 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 2 Dec 2020 18:36:24 +0000
4 Subject: [PATCH] drm/vc4: Add HDR metadata property to the VC5 HDMI
7 Now that we can export deeper colour depths, add in the signalling
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
12 drivers/gpu/drm/vc4/vc4_hdmi.c | 28 ++++++++++++++++++++++++++++
13 drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +++
14 2 files changed, 31 insertions(+)
16 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
17 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
18 @@ -309,6 +309,10 @@ static int vc4_hdmi_connector_init(struc
19 connector->doublescan_allowed = 0;
20 connector->stereo_allowed = 1;
22 + if (vc4_hdmi->variant->supports_hdr)
23 + drm_object_attach_property(&connector->base,
24 + connector->dev->mode_config.hdr_output_metadata_property, 0);
26 drm_connector_attach_encoder(connector, encoder);
29 @@ -448,6 +452,25 @@ static void vc4_hdmi_set_audio_infoframe
30 vc4_hdmi_write_infoframe(encoder, &frame);
33 +static void vc4_hdmi_set_hdr_infoframe(struct drm_encoder *encoder)
35 + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
36 + struct drm_connector *connector = &vc4_hdmi->connector;
37 + struct drm_connector_state *conn_state = connector->state;
38 + union hdmi_infoframe frame;
40 + if (!vc4_hdmi->variant->supports_hdr)
43 + if (!conn_state->hdr_output_metadata)
46 + if (drm_hdmi_infoframe_set_hdr_metadata(&frame.drm, conn_state))
49 + vc4_hdmi_write_infoframe(encoder, &frame);
52 static void vc4_hdmi_set_infoframes(struct drm_encoder *encoder)
54 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
55 @@ -460,6 +483,8 @@ static void vc4_hdmi_set_infoframes(stru
57 if (vc4_hdmi->audio.streaming)
58 vc4_hdmi_set_audio_infoframe(encoder);
60 + vc4_hdmi_set_hdr_infoframe(encoder);
63 static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder,
64 @@ -2282,6 +2307,7 @@ static const struct vc4_hdmi_variant bcm
65 .phy_rng_enable = vc4_hdmi_phy_rng_enable,
66 .phy_rng_disable = vc4_hdmi_phy_rng_disable,
67 .channel_map = vc4_hdmi_channel_map,
68 + .supports_hdr = false,
71 static const struct vc4_hdmi_variant bcm2711_hdmi0_variant = {
72 @@ -2309,6 +2335,7 @@ static const struct vc4_hdmi_variant bcm
73 .phy_rng_enable = vc5_hdmi_phy_rng_enable,
74 .phy_rng_disable = vc5_hdmi_phy_rng_disable,
75 .channel_map = vc5_hdmi_channel_map,
76 + .supports_hdr = true,
79 static const struct vc4_hdmi_variant bcm2711_hdmi1_variant = {
80 @@ -2336,6 +2363,7 @@ static const struct vc4_hdmi_variant bcm
81 .phy_rng_enable = vc5_hdmi_phy_rng_enable,
82 .phy_rng_disable = vc5_hdmi_phy_rng_disable,
83 .channel_map = vc5_hdmi_channel_map,
84 + .supports_hdr = true,
87 static const struct of_device_id vc4_hdmi_dt_match[] = {
88 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h
89 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
90 @@ -99,6 +99,9 @@ struct vc4_hdmi_variant {
92 /* Callback to get channel map */
93 u32 (*channel_map)(struct vc4_hdmi *vc4_hdmi, u32 channel_mask);
95 + /* Enables HDR metadata */
99 /* HDMI audio information */