From: Wang Jiang <[email protected]>

EDID without SAD left stale AZ descriptors; emulated ATI ELD faked
audio capability. Clear them.

The legacy implementation refers to ce9778b7a027,
"ALSA: hda/hdmi: Consider ELD invalid when no SAD is present".

Signed-off-by: Wang Jiang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++++++-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c  | 7 ++++++-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c  | 6 +++++-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index f2977fe6d824..f967ee505271 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -1341,8 +1341,13 @@ static void dce_v10_0_audio_write_sad_regs(struct 
drm_encoder *encoder)
        sad_count = drm_edid_to_sad(drm_edid_raw(amdgpu_connector->edid), 
&sads);
        if (sad_count < 0)
                DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
-       if (sad_count <= 0)
+       if (sad_count <= 0) {
+               /* sink has no audio capability: clear stale descriptors */
+               for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++)
+                       WREG32_AUDIO_ENDPT(dig->afmt->pin->offset,
+                                          eld_reg_to_type[i][0], 0);
                return;
+       }
        BUG_ON(!sads);
 
        for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c68de0fe1d7d..18c171c533de 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1320,8 +1320,13 @@ static void dce_v6_0_audio_write_sad_regs(struct 
drm_encoder *encoder)
        sad_count = drm_edid_to_sad(drm_edid_raw(amdgpu_connector->edid), 
&sads);
        if (sad_count < 0)
                DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
-       if (sad_count <= 0)
+       if (sad_count <= 0) {
+               /* sink has no audio capability: clear stale descriptors */
+               for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++)
+                       WREG32_AUDIO_ENDPT(dig->afmt->pin->offset,
+                                          eld_reg_to_type[i][0], 0);
                return;
+       }
 
        for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
                u32 value = 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index c3906270f25e..62922736d569 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -1313,8 +1313,12 @@ static void dce_v8_0_audio_write_sad_regs(struct 
drm_encoder *encoder)
        sad_count = drm_edid_to_sad(drm_edid_raw(amdgpu_connector->edid), 
&sads);
        if (sad_count < 0)
                DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
-       if (sad_count <= 0)
+       if (sad_count <= 0) {
+               /* sink has no audio capability: clear stale descriptors */
+               for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++)
+                       WREG32_AUDIO_ENDPT(offset, eld_reg_to_type[i][0], 0);
                return;
+       }
        BUG_ON(!sads);
 
        for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
-- 
2.25.1

Reply via email to