intel_dp_add_properties() attaches HDR_OUTPUT_METADATA only when the
encoder can send a gamut metadata DIP, so pre-ICL eDP panels on port A
never expose it even when their EDID advertises HDR.

Those panels do not use a DIP at all: the metadata is programmed through
the Intel AUX HDR interface, and the TCON capability is already known
because intel_edp_backlight_setup() runs before intel_dp_add_properties().

Factor the whole decision into intel_dp_hdr_metadata_supported() and let
it accept eDP panels whose TCON advertises PQ (ST2084) decoding through
the Intel AUX HDR backlight interface.

Since no DIP is transmitted in that case, skip computing the infoframe
when the encoder has no gamut metadata DIP, so that the computed state
matches what is actually programmed.

Reviewed-by: Ville Syrjälä <[email protected]>
Signed-off-by: Yitian Shao <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_dp.c       | 31 +++++++++++++++++--
 .../drm/i915/display/intel_dp_aux_backlight.c |  5 +++
 .../drm/i915/display/intel_dp_aux_backlight.h |  3 ++
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 2736a78..eeead26 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -70,6 +70,7 @@
 #include "intel_display_types.h"
 #include "intel_dp.h"
 #include "intel_dp_aux.h"
+#include "intel_dp_aux_backlight.h"
 #include "intel_dp_hdcp.h"
 #include "intel_dp_link_training.h"
 #include "intel_dp_mst.h"
@@ -3085,9 +3086,17 @@ intel_dp_compute_hdr_metadata_infoframe_sdp(struct 
intel_dp *intel_dp,
                                            const struct drm_connector_state 
*conn_state)
 {
        struct intel_display *display = to_intel_display(intel_dp);
+       struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
        int ret;
        struct hdmi_drm_infoframe *drm_infoframe = 
&crtc_state->infoframes.drm.drm;
 
+       /*
+        * Without a gamut metadata DIP there is nothing to program here; on
+        * pre-ICL eDP the metadata goes through the AUX HDR interface instead.
+        */
+       if (!intel_dp_has_gamut_metadata_dip(encoder))
+               return;
+
        if (!conn_state->hdr_output_metadata)
                return;
 
@@ -6685,6 +6694,24 @@ intel_dp_has_gamut_metadata_dip(struct intel_encoder 
*encoder)
        return false;
 }
 
+static bool intel_dp_hdr_metadata_supported(struct intel_dp *intel_dp,
+                                            struct intel_connector *connector)
+{
+       struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
+
+       /* LSPCON attaches the property itself in intel_dp_connector_register() 
*/
+       if (intel_bios_encoder_is_lspcon(encoder->devdata))
+               return false;
+
+       if (intel_dp_has_gamut_metadata_dip(encoder))
+               return true;
+
+       /* Pre-ICL eDP programs the metadata via the AUX HDR interface */
+       return intel_dp_is_edp(intel_dp) &&
+              intel_dp_aux_is_hdr_backlight(connector) &&
+              connector->panel.backlight.edp.intel_cap.supports_2084_decode;
+}
+
 static void
 intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector 
*_connector)
 {
@@ -6712,9 +6739,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct 
drm_connector *_connec
                intel_attach_dp_colorspace_property(&connector->base);
        }
 
-       /* LSPCON attaches the property itself in intel_dp_connector_register() 
*/
-       if 
(!intel_bios_encoder_is_lspcon(dp_to_dig_port(intel_dp)->base.devdata) &&
-           intel_dp_has_gamut_metadata_dip(&dp_to_dig_port(intel_dp)->base))
+       if (intel_dp_hdr_metadata_supported(intel_dp, connector))
                
drm_connector_attach_hdr_output_metadata_property(&connector->base);
 
        if (HAS_VRR(display))
diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c 
b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
index eb05ef4..8c7fd99 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
@@ -630,6 +630,11 @@ static const struct intel_panel_bl_funcs 
intel_dp_hdr_bl_funcs = {
        .get = intel_dp_aux_hdr_get_backlight,
 };
 
+bool intel_dp_aux_is_hdr_backlight(const struct intel_connector *connector)
+{
+       return connector->panel.backlight.funcs == &intel_dp_hdr_bl_funcs;
+}
+
 static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = {
        .setup = intel_dp_aux_vesa_setup_backlight,
        .enable = intel_dp_aux_vesa_enable_backlight,
diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.h 
b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.h
index ed60c28..1fa1b93 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.h
@@ -6,8 +6,11 @@
 #ifndef __INTEL_DP_AUX_BACKLIGHT_H__
 #define __INTEL_DP_AUX_BACKLIGHT_H__
 
+#include <linux/types.h>
+
 struct intel_connector;
 
 int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
+bool intel_dp_aux_is_hdr_backlight(const struct intel_connector *connector);
 
 #endif /* __INTEL_DP_AUX_BACKLIGHT_H__ */
-- 
2.53.0

Reply via email to