1 From c8a76985213abda828a2098c3d6ce8a49b5f9766 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Fri, 5 Feb 2021 14:07:12 +0000
4 Subject: [PATCH] drm/vc4: Add connector check to trigger mode_change
5 when hdr metadata changes
7 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
9 drivers/gpu/drm/vc4/vc4_hdmi.c | 40 ++++++++++++++++++++++++++++++++++
10 1 file changed, 40 insertions(+)
12 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
13 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
14 @@ -224,6 +224,45 @@ static int vc4_hdmi_connector_get_modes(
18 +static bool hdr_metadata_equal(const struct drm_connector_state *old_state,
19 + const struct drm_connector_state *new_state)
21 + struct drm_property_blob *old_blob = old_state->hdr_output_metadata;
22 + struct drm_property_blob *new_blob = new_state->hdr_output_metadata;
24 + if (!old_blob || !new_blob)
25 + return old_blob == new_blob;
27 + if (old_blob->length != new_blob->length)
30 + return !memcmp(old_blob->data, new_blob->data, old_blob->length);
33 +static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector,
34 + struct drm_atomic_state *state)
36 + struct drm_connector_state *old_state =
37 + drm_atomic_get_old_connector_state(state, connector);
38 + struct drm_connector_state *new_state =
39 + drm_atomic_get_new_connector_state(state, connector);
40 + struct drm_crtc *crtc = new_state->crtc;
41 + struct drm_crtc_state *crtc_state;
46 + if (!hdr_metadata_equal(old_state, new_state)) {
47 + crtc_state = drm_atomic_get_crtc_state(state, crtc);
48 + if (IS_ERR(crtc_state))
49 + return PTR_ERR(crtc_state);
51 + crtc_state->mode_changed = true;
57 static void vc4_hdmi_connector_reset(struct drm_connector *connector)
59 struct vc4_hdmi_connector_state *old_state =
60 @@ -273,6 +312,7 @@ static const struct drm_connector_funcs
62 static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = {
63 .get_modes = vc4_hdmi_connector_get_modes,
64 + .atomic_check = vc4_hdmi_connector_atomic_check,
67 static int vc4_hdmi_connector_init(struct drm_device *dev,