drm/i915/sdvo: Do ELD hardware readout
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 24 Jan 2023 14:46:24 +0000 (16:46 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 25 Jan 2023 10:23:48 +0000 (12:23 +0200)
Read out the ELD from the hw so the state checker can verify it.

v2: Check the "ELD valid" bit separately
v3: Fix ELD tx rate handling during readout

Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Jani Nikula <jani.nikula@intel.com> #v1
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230124144628.4649-10-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_sdvo.c

index 68e5c7be21351bc8faec84abf9f27f62babf6c59..c469ec3e6042ea56e5739f40ba607234714e92f9 100644 (file)
@@ -1069,7 +1069,8 @@ static ssize_t intel_sdvo_read_infoframe(struct intel_sdvo *intel_sdvo,
                                  &tx_rate, 1))
                return -ENXIO;
 
-       if (tx_rate == SDVO_HBUF_TX_DISABLED)
+       /* TX_DISABLED doesn't mean disabled for ELD */
+       if (if_index != SDVO_HBUF_INDEX_ELD && tx_rate == SDVO_HBUF_TX_DISABLED)
                return 0;
 
        if (!intel_sdvo_get_hbuf_size(intel_sdvo, &hbuf_size))
@@ -1186,6 +1187,28 @@ static void intel_sdvo_get_avi_infoframe(struct intel_sdvo *intel_sdvo,
                              frame->any.type, HDMI_INFOFRAME_TYPE_AVI);
 }
 
+static void intel_sdvo_get_eld(struct intel_sdvo *intel_sdvo,
+                              struct intel_crtc_state *crtc_state)
+{
+       struct drm_i915_private *i915 = to_i915(intel_sdvo->base.base.dev);
+       ssize_t len;
+       u8 val;
+
+       if (!crtc_state->has_audio)
+               return;
+
+       if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_AUDIO_STAT, &val, 1))
+               return;
+
+       if ((val & SDVO_AUDIO_ELD_VALID) == 0)
+               return;
+
+       len = intel_sdvo_read_infoframe(intel_sdvo, SDVO_HBUF_INDEX_ELD,
+                                       crtc_state->eld, sizeof(crtc_state->eld));
+       if (len < 0)
+               drm_dbg_kms(&i915->drm, "failed to read ELD\n");
+}
+
 static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo,
                                     const struct drm_connector_state *conn_state)
 {
@@ -1743,6 +1766,8 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
        }
 
        intel_sdvo_get_avi_infoframe(intel_sdvo, pipe_config);
+
+       intel_sdvo_get_eld(intel_sdvo, pipe_config);
 }
 
 static void intel_sdvo_disable_audio(struct intel_sdvo *intel_sdvo)