* [PATCH] drm/i915/display: add audio dis/enable when connector hotplug
@ 2025-03-18 7:04 Lu Yao
2025-03-20 10:57 ` Jani Nikula
0 siblings, 1 reply; 2+ messages in thread
From: Lu Yao @ 2025-03-18 7:04 UTC (permalink / raw)
To: jani.nikula, rodrigo.vivi, joonas.lahtinen, tursulin
Cc: intel-gfx, dri-devel, linux-kernel, Lu Yao
Now audio enable/disable depends on an atomic commit, it doesn't make
sence. For wayland, there will trigering an atomic commit, so it
works well. But for Xorg using modesetting, there won't. In this
case, unplug the HDMI/DP and the audio jack event is not triggered,
resulting in still having a HDMI/DP audio output choice.
Signed-off-by: Lu Yao <yaolu@kylinos.cn>
---
drivers/gpu/drm/i915/display/intel_hotplug.c | 31 ++++++++++++++++++++
1 file changed, 31 insertions(+)
---
Test hardware:
CPU: i5-12500
GPU: UHD Graphics 770
diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
index 3adc791d3776..332d6e1a99cd 100644
--- a/drivers/gpu/drm/i915/display/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
@@ -32,6 +32,7 @@
#include "intel_display_types.h"
#include "intel_hotplug.h"
#include "intel_hotplug_irq.h"
+#include "intel_audio.h"
/**
* DOC: Hotplug
@@ -415,6 +416,35 @@ void intel_hpd_trigger_irq(struct intel_digital_port *dig_port)
queue_work(i915->display.hotplug.dp_wq, &i915->display.hotplug.dig_port_work);
}
+/*
+ * when connector hotplug state changed, audio need changed too.
+ */
+static void i915_audio_hotplug(struct intel_connector *connector)
+{
+ struct drm_crtc *crtc;
+ struct drm_device *dev = connector->base.dev;
+
+ drm_for_each_crtc(crtc, dev) {
+ if (connector->base.state->crtc == crtc) {
+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+ struct intel_crtc_state *pipe_config =
+ to_intel_crtc_state(intel_crtc->base.state);
+ struct intel_encoder *encoder =
+ intel_attached_encoder(connector);
+
+ if (pipe_config && pipe_config->has_audio) {
+ if (connector->base.status == connector_status_disconnected)
+ intel_audio_codec_disable(encoder, pipe_config,
+ connector->base.state);
+ else if (connector->base.status == connector_status_connected)
+ intel_audio_codec_enable(encoder, pipe_config,
+ connector->base.state);
+ }
+ break;
+ }
+ }
+}
+
/*
* Handle hotplug events outside the interrupt handler proper.
*/
@@ -487,6 +517,7 @@ static void i915_hotplug_work_func(struct work_struct *work)
drm_connector_get(&connector->base);
first_changed_connector = &connector->base;
}
+ i915_audio_hotplug(connector);
break;
case INTEL_HOTPLUG_RETRY:
retry |= hpd_bit;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/i915/display: add audio dis/enable when connector hotplug
2025-03-18 7:04 [PATCH] drm/i915/display: add audio dis/enable when connector hotplug Lu Yao
@ 2025-03-20 10:57 ` Jani Nikula
0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2025-03-20 10:57 UTC (permalink / raw)
To: Lu Yao, rodrigo.vivi, joonas.lahtinen, tursulin
Cc: intel-gfx, dri-devel, linux-kernel, Lu Yao
On Tue, 18 Mar 2025, Lu Yao <yaolu@kylinos.cn> wrote:
> Now audio enable/disable depends on an atomic commit, it doesn't make
> sence. For wayland, there will trigering an atomic commit, so it
> works well. But for Xorg using modesetting, there won't. In this
> case, unplug the HDMI/DP and the audio jack event is not triggered,
> resulting in still having a HDMI/DP audio output choice.
As it is, the implementation is not acceptable, but with this
description I also don't understand the problem.
Please file a bug at [1], attach dmesg from boot exhibiting the problem.
BR,
Jani.
[1] https://drm.pages.freedesktop.org/intel-docs/how-to-file-i915-bugs.html
> Signed-off-by: Lu Yao <yaolu@kylinos.cn>
> ---
> drivers/gpu/drm/i915/display/intel_hotplug.c | 31 ++++++++++++++++++++
> 1 file changed, 31 insertions(+)
> ---
> Test hardware:
> CPU: i5-12500
> GPU: UHD Graphics 770
>
>
> diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
> index 3adc791d3776..332d6e1a99cd 100644
> --- a/drivers/gpu/drm/i915/display/intel_hotplug.c
> +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
> @@ -32,6 +32,7 @@
> #include "intel_display_types.h"
> #include "intel_hotplug.h"
> #include "intel_hotplug_irq.h"
> +#include "intel_audio.h"
>
> /**
> * DOC: Hotplug
> @@ -415,6 +416,35 @@ void intel_hpd_trigger_irq(struct intel_digital_port *dig_port)
> queue_work(i915->display.hotplug.dp_wq, &i915->display.hotplug.dig_port_work);
> }
>
> +/*
> + * when connector hotplug state changed, audio need changed too.
> + */
> +static void i915_audio_hotplug(struct intel_connector *connector)
> +{
> + struct drm_crtc *crtc;
> + struct drm_device *dev = connector->base.dev;
> +
> + drm_for_each_crtc(crtc, dev) {
> + if (connector->base.state->crtc == crtc) {
> + struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> + struct intel_crtc_state *pipe_config =
> + to_intel_crtc_state(intel_crtc->base.state);
> + struct intel_encoder *encoder =
> + intel_attached_encoder(connector);
> +
> + if (pipe_config && pipe_config->has_audio) {
> + if (connector->base.status == connector_status_disconnected)
> + intel_audio_codec_disable(encoder, pipe_config,
> + connector->base.state);
> + else if (connector->base.status == connector_status_connected)
> + intel_audio_codec_enable(encoder, pipe_config,
> + connector->base.state);
> + }
> + break;
> + }
> + }
> +}
> +
> /*
> * Handle hotplug events outside the interrupt handler proper.
> */
> @@ -487,6 +517,7 @@ static void i915_hotplug_work_func(struct work_struct *work)
> drm_connector_get(&connector->base);
> first_changed_connector = &connector->base;
> }
> + i915_audio_hotplug(connector);
> break;
> case INTEL_HOTPLUG_RETRY:
> retry |= hpd_bit;
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-20 10:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 7:04 [PATCH] drm/i915/display: add audio dis/enable when connector hotplug Lu Yao
2025-03-20 10:57 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox