HDMI 2.0 section 6.1.3.1 specifies that after enabling
Scrambling_Enable and starting scrambled video transmission, the source
should poll Scrambling_Status until it reads 1 or until a timeout of
200 ms expires.

Add a polling step after enabling the HDMI port to check the scrambling
status when HDMI scrambling is enabled.

On some HDMI 2.0 sinks, omitting this check can result in 4K@60Hz
(594 MHz) failing to come up correctly because the sink has not yet
finished its scrambling setup. In practice, waiting for the scrambling
status here fixes such sinks.

While this synchronous polling is not itself explicitly required for
correct modeset sequencing, HDMI 2.0 section 6.1.3.1 does recommend it
as the way for the source to verify that the TMDS link is functioning
correctly with scrambling enabled.

v3:
 - Add explicit HDMI 2.0 section reference in code comment
 - Clarify commit message around the observed sink fix

v2:
 - Poll TMDS_Scrambler_Status for up to 200 ms instead of using a fixed
   delay

Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6868
Signed-off-by: Jerome Tollet <[email protected]>
Signed-off-by: Ankit Nautiyal <[email protected]>
Reviewed-by: Arun R Murthy <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_ddi.c  |  2 ++
 drivers/gpu/drm/i915/display/intel_hdmi.c | 26 +++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_hdmi.h |  2 ++
 3 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c 
b/drivers/gpu/drm/i915/display/intel_ddi.c
index ebefa889bc8c..8659d1861c2a 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -3505,6 +3505,8 @@ static void intel_ddi_enable_hdmi(struct 
intel_atomic_state *state,
        }
 
        intel_ddi_buf_enable(encoder, buf_ctl);
+
+       intel_hdmi_poll_for_scrambling_enable(crtc_state, connector);
 }
 
 static void intel_ddi_enable(struct intel_atomic_state *state,
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c 
b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 05e898d10a2b..234866310c14 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -2693,6 +2693,32 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, 
struct drm_connector *_
                drm_connector_attach_max_bpc_property(&connector->base, 8, 12);
 }
 
+/*
+ * HDMI 2.0 spec, section 6.1.3.1 (Scrambling Control): after
+ * enabling Scrambling_Enable and starting scrambled video
+ * transmission, poll Scrambling_Status for up to 200 ms.
+ */
+void
+intel_hdmi_poll_for_scrambling_enable(const struct intel_crtc_state 
*crtc_state,
+                                     struct drm_connector *_connector)
+{
+       struct intel_connector *connector = to_intel_connector(_connector);
+       struct intel_display *display = to_intel_display(crtc_state);
+       bool scrambling_enabled = false;
+       int ret;
+
+       if (!crtc_state->hdmi_scrambling)
+               return;
+
+       /* Poll for a max of 200 msec as per HDMI spec */
+       ret = poll_timeout_us(scrambling_enabled = 
drm_scdc_get_scrambling_status(&connector->base),
+                             scrambling_enabled, 1000, 200 * 1000, false);
+       if (ret)
+               drm_dbg_kms(display->drm,
+                           "[CONNECTOR:%d:%s] Timed out waiting for scrambling 
enable\n",
+                           connector->base.base.id, connector->base.name);
+}
+
 /*
  * intel_hdmi_handle_sink_scrambling: handle sink scrambling/clock ratio setup
  * @encoder: intel_encoder
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.h 
b/drivers/gpu/drm/i915/display/intel_hdmi.h
index be2fad57e4ad..0fa3661568e8 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.h
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.h
@@ -70,5 +70,7 @@ void hsw_read_infoframe(struct intel_encoder *encoder,
                        const struct intel_crtc_state *crtc_state,
                        unsigned int type,
                        void *frame, ssize_t len);
+void intel_hdmi_poll_for_scrambling_enable(const struct intel_crtc_state 
*crtc_state,
+                                          struct drm_connector *_connector);
 
 #endif /* __INTEL_HDMI_H__ */
-- 
2.54.0

Reply via email to