mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Panpan Ren <renpanpan@kylinos.cn>
To: alexander.deucher@amd.com, christian.koenig@amd.com, simona@ffwll.ch
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	tzimmermann@suse.de, timur.kristof@gmail.com, lijo.lazar@amd.com,
	renpanpan <renpanpan@kylinos.cn>
Subject: [PATCH v3] drm/amdgpu: Only enable HDMI audio if display supports it
Date: Tue,  3 Nov 2026 14:11:47 +0800	[thread overview]
Message-ID: <20261103061147.25827-1-renpanpan@kylinos.cn> (raw)

From: renpanpan <renpanpan@kylinos.cn>

The amdgpu legacy DCE audio path (dce_v6/v8/v10) unconditionally calls
audio_enable(pin, true) at the end of afmt_setmode(), regardless of
whether the connected display advertises audio support in its EDID.

This causes a phantom HDMI audio output to appear for displays that
have no audio capability (no basic audio bit, no Audio Data Block in
EDID), because the GPU sets the AUDIO_ENABLED register bit, which
drives the HDA codec's ELDV pin sense, making the codec report the
jack as audio-available.

The radeon, nouveau, and dw-hdmi drivers all gate audio enablement on
the display's audio capability. Apply the same check to amdgpu's DCE
afmt_setmode functions, while still respecting the AMDGPU_AUDIO_ENABLE
override for users who explicitly force audio on.

Fixes: e2cdf640cbb5 ("drm/amdgpu: add display controller implementation for si v10")
Cc: stable@vger.kernel.org
Signed-off-by: renpanpan <renpanpan@kylinos.cn>
---
Changes in v3:
- Also gate the initial audio_enable(pin, false) to avoid touching a
  potentially shared audio pin when the display has no audio support

Changes in v2:
- Respect AMDGPU_AUDIO_ENABLE override for users who force audio on
- Add Fixes tag and Cc: stable@vger.kernel.org for stable backport

 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 12 ++++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c  | 12 ++++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c  | 12 ++++++++----
 3 files changed, 24 insertions(+), 12 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..a8f5eb2394c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -1555,9 +1555,11 @@ static void dce_v10_0_afmt_setmode(struct drm_encoder *encoder,
 		bpc = amdgpu_crtc->bpc;
 	}
 
-	/* disable audio prior to setting up hw */
+	/* disable audio prior to setting up hw, unless the display has no audio */
 	dig->afmt->pin = dce_v10_0_audio_get_pin(adev);
-	dce_v10_0_audio_enable(adev, dig->afmt->pin, false);
+	if (connector->display_info.has_audio ||
+	    to_amdgpu_connector(connector)->audio == AMDGPU_AUDIO_ENABLE)
+		dce_v10_0_audio_enable(adev, dig->afmt->pin, false);
 
 	dce_v10_0_audio_set_dto(encoder, mode->clock);
 
@@ -1705,8 +1707,10 @@ static void dce_v10_0_afmt_setmode(struct drm_encoder *encoder,
 	WREG32(mmAFMT_RAMP_CONTROL2 + dig->afmt->offset, 0x00000001);
 	WREG32(mmAFMT_RAMP_CONTROL3 + dig->afmt->offset, 0x00000001);
 
-	/* enable audio after to setting up hw */
-	dce_v10_0_audio_enable(adev, dig->afmt->pin, true);
+	/* Only enable audio if the display supports it or is forced on */
+	if (connector->display_info.has_audio ||
+	    to_amdgpu_connector(connector)->audio == AMDGPU_AUDIO_ENABLE)
+		dce_v10_0_audio_enable(adev, dig->afmt->pin, true);
 }
 
 static void dce_v10_0_afmt_enable(struct drm_encoder *encoder, bool enable)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c68de0fe1d7d..3cd9f1bb3a70 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1724,8 +1724,10 @@ static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder,
 		bpc = amdgpu_crtc->bpc;
 	}
 
-	/* disable audio before setting up hw */
-	dce_v6_0_audio_enable(adev, dig->afmt->pin, false);
+	/* disable audio before setting up hw, unless the display has no audio */
+	if (connector->display_info.has_audio ||
+	    amdgpu_connector->audio == AMDGPU_AUDIO_ENABLE)
+		dce_v6_0_audio_enable(adev, dig->afmt->pin, false);
 
 	dce_v6_0_audio_set_mute(encoder, true);
 	dce_v6_0_audio_write_speaker_allocation(encoder);
@@ -1748,8 +1750,10 @@ static void dce_v6_0_afmt_setmode(struct drm_encoder *encoder,
 		dce_v6_0_audio_dp_enable(encoder, 1);
 	}
 
-	/* enable audio after setting up hw */
-	dce_v6_0_audio_enable(adev, dig->afmt->pin, true);
+	/* Only enable audio if the display supports it or is forced on */
+	if (connector->display_info.has_audio ||
+	    amdgpu_connector->audio == AMDGPU_AUDIO_ENABLE)
+		dce_v6_0_audio_enable(adev, dig->afmt->pin, true);
 }
 
 static void dce_v6_0_afmt_enable(struct drm_encoder *encoder, bool enable)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index c3906270f25e..eb1fcf0b39cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -1523,9 +1523,11 @@ static void dce_v8_0_afmt_setmode(struct drm_encoder *encoder,
 		bpc = amdgpu_crtc->bpc;
 	}
 
-	/* disable audio prior to setting up hw */
+	/* disable audio prior to setting up hw, unless the display has no audio */
 	dig->afmt->pin = dce_v8_0_audio_get_pin(adev);
-	dce_v8_0_audio_enable(adev, dig->afmt->pin, false);
+	if (connector->display_info.has_audio ||
+	    to_amdgpu_connector(connector)->audio == AMDGPU_AUDIO_ENABLE)
+		dce_v8_0_audio_enable(adev, dig->afmt->pin, false);
 
 	dce_v8_0_audio_set_dto(encoder, mode->clock);
 
@@ -1653,8 +1655,10 @@ static void dce_v8_0_afmt_setmode(struct drm_encoder *encoder,
 	WREG32(mmAFMT_RAMP_CONTROL2 + offset, 0x00000001);
 	WREG32(mmAFMT_RAMP_CONTROL3 + offset, 0x00000001);
 
-	/* enable audio after setting up hw */
-	dce_v8_0_audio_enable(adev, dig->afmt->pin, true);
+	/* Only enable audio if the display supports it or is forced on */
+	if (connector->display_info.has_audio ||
+	    to_amdgpu_connector(connector)->audio == AMDGPU_AUDIO_ENABLE)
+		dce_v8_0_audio_enable(adev, dig->afmt->pin, true);
 }
 
 static void dce_v8_0_afmt_enable(struct drm_encoder *encoder, bool enable)
-- 
2.43.0


             reply	other threads:[~2026-11-03  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  6:11 Panpan Ren [this message]
2026-11-03 11:49 ` Timur Kristóf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261103061147.25827-1-renpanpan@kylinos.cn \
    --to=renpanpan@kylinos.cn \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lijo.lazar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=timur.kristof@gmail.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®