drm/vc4: hdmi: Signal the proper colorimetry info in the infoframe
authorMaxime Ripard <maxime@cerno.tech>
Fri, 9 Apr 2021 15:16:42 +0000 (17:16 +0200)
committerpopcornmix <popcornmix@gmail.com>
Mon, 12 Apr 2021 17:08:50 +0000 (18:08 +0100)
Our driver while supporting HDR didn't send the proper colorimetry info
in the AVI infoframe.

Let's add the property needed so that the userspace can let us know what
the colorspace is supposed to be.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/vc4/vc4_hdmi.c

index 507eff9..2816a1d 100644 (file)
@@ -539,7 +539,8 @@ static int vc4_hdmi_connector_atomic_check(struct drm_connector *connector,
        if (!crtc)
                return 0;
 
-       if (!drm_connector_atomic_hdr_metadata_equal(old_state, new_state)) {
+       if (old_state->colorspace != new_state->colorspace ||
+           !drm_connector_atomic_hdr_metadata_equal(old_state, new_state)) {
                struct drm_crtc_state *crtc_state;
 
                crtc_state = drm_atomic_get_crtc_state(state, crtc);
@@ -629,6 +630,11 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
        if (ret)
                return ret;
 
+       ret = drm_mode_create_hdmi_colorspace_property(connector);
+       if (ret)
+               return ret;
+
+       drm_connector_attach_colorspace_property(connector);
        drm_connector_attach_tv_margin_properties(connector);
        drm_connector_attach_max_bpc_property(connector, 8, 12);
 
@@ -743,7 +749,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
                                           vc4_encoder->limited_rgb_range ?
                                           HDMI_QUANTIZATION_RANGE_LIMITED :
                                           HDMI_QUANTIZATION_RANGE_FULL);
-
+       drm_hdmi_avi_infoframe_colorspace(&frame.avi, cstate);
        drm_hdmi_avi_infoframe_bars(&frame.avi, cstate);
 
        vc4_hdmi_write_infoframe(encoder, &frame);