drm/connector: add CRTC state change callback to HDMI audio helpers
Subsystems (2)
PATCH 1/1 drm/connector: add CRTC state change callback to HDMI audio helpers
From: wangdicheng <[email protected]>
The DRM HDMI audio helper framework notifies the audio codec about physical connection changes via drm_connector_hdmi_audio_plugged_notify(), but has no mechanism to notify when the CRTC state changes while the connector remains physically connected.
This is a real problem on platforms with DP/HDMI audio. When a CRTC is disabled while the sink remains connected (e.g. user switches to "internal display only" mode but still wants audio from the external monitor), the audio path silently breaks because:
1. The video stream is disabled, so there are no blanking intervals for audio Secondary Data Packets (SDP) to be transported.
2. The audio codec still believes the jack is present because plugged_notify() was not called (the connector is still physically connected).
3. Userspace (PulseAudio/PipeWire) continues routing audio to the external display, but no sound is actually output.
Without a framework-level notification, vendors who need to support "audio output to external display while CRTC is inactive" are forced to scatter condition checks across CRTC disable, encoder disable, suspend, and resume paths. This pattern is fragile: any change in the display pipeline can break the audio path, and the same condition ("connector connected but CRTC inactive, and audio is in use") must be duplicated in multiple locations.
The root cause is architectural: the audio codec has no visibility into CRTC state changes, so there is no clean way to implement policies like:
- Mute audio output when CRTC is disabled (instead of silent breakage)
- Keep the video stream alive for audio transport
- Switch to DP Audio Only mode (hardware-supported on some platforms, e.g. Intel TRANS_DP_AUDIO_ONLY, but never used in i915 driver)
The HDA HDMI silent stream / KAE mechanism partially addresses this on Intel platforms, but it operates only on the audio codec side and does not coordinate with the DRM side. It also cannot work on platforms without HDA codec support (e.g. ASoC-based designs).
Add an optional callback crtc_state_change() to drm_connector_hdmi_audio_funcs, and a corresponding notification function drm_connector_hdmi_audio_crtc_notify(). DRM drivers should call this when the CRTC state changes on a connector with audio capability, allowing audio codec implementations to react to display pipeline state changes rather than only physical connection changes.
This provides a framework-level mechanism to implement "audio without active display" policies cleanly, instead of scattering condition checks across the display pipeline.
--- .../gpu/drm/display/drm_hdmi_audio_helper.c | 23 +++++++++++++++++++ include/drm/display/drm_hdmi_audio_helper.h | 2 ++ include/drm/drm_connector.h | 16 +++++++++++++ 3 files changed, 41 insertions(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +23 -0
@@ -128,6 +128,29 @@ void drm_connector_hdmi_audio_plugged_notify(struct drm_connector *connector, }EXPORT_SYMBOL (drm_connector_hdmi_audio_plugged_notify); +/** +* drm_connector_hdmi_audio_crtc_notify - Notify the audio codec of CRTC state change +* @connector: A pointer to the connector +* @crtc_active: true if the CRTC is now active, false if disabled +* +* Notify the HDMI audio codec that the CRTC state has changed on this +* connector. This should be called by DRM drivers when a CRTC is +* enabled or disabled on a connector that has audio capability, even +* if the connector remains physically connected. +* +* Unlike drm_connector_hdmi_audio_plugged_notify() which signals +* physical connection changes, this function signals display pipeline +* state changes that affect the audio transport path. +*/ +void drm_connector_hdmi_audio_crtc_notify (struct drm_connector *connector, +bool crtc_active) +{ +if (connector->hdmi_audio.funcs->crtc_state_change) + connector->hdmi_audio.funcs->crtc_state_change (connector, + crtc_active); +} +EXPORT_SYMBOL (drm_connector_hdmi_audio_crtc_notify); +static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = { .audio_startup = drm_connector_hdmi_audio_startup, .prepare = drm_connector_hdmi_audio_prepare,
include/drm/display/drm_hdmi_audio_helper.h +2 -0
@@ -19,5 +19,7 @@ int drm_connector_hdmi_audio_init(struct drm_connector *connector, int sound_dai_port);void drm_connector_hdmi_audio_plugged_notify (struct drm_connector *connector,bool plugged); +void drm_connector_hdmi_audio_crtc_notify (struct drm_connector *connector, +bool crtc_active);#endif
include/drm/drm_connector.h +16 -0
@@ -1256,6 +1256,22 @@ struct drm_connector_hdmi_audio_funcs {*/ int (*mute_stream)(struct drm_connector *connector,bool enable,int direction); + +/** +* @crtc_state_change: +* +* Notify the audio codec that the CRTC state has changed on this +* connector. Called when a CRTC is enabled or disabled while the +* connector remains physically connected. This is important for +* DP/HDMI audio because audio transport depends on the video +* stream's blanking intervals. The @crtc_state_change callback +* is optional. +* +* @connector: the connector whose CRTC state changed +* @crtc_active: true if the CRTC is now active, false if disabled +*/ +void (*crtc_state_change)(struct drm_connector *connector, +bool crtc_active); };void drm_connector_cec_phys_addr_invalidate (struct drm_connector *connector);
Signature · 1 line
2.25.1
Maxime Ripard
maintainerHi,
Quoted 51 lines · On Wed, May 27, 2026 at 04:53:29PM +0800, [email protected] wrote:
From: wangdicheng <[email protected]>
The DRM HDMI audio helper framework notifies the audio codec about physical connection changes via
drm_connector_hdmi_audio_plugged_notify(), but has no mechanism to notify when the CRTC state changes while the connector remains physically connected.This is a real problem on platforms with DP/HDMI audio. When a CRTC is disabled while the sink remains connected (e.g. user switches to "internal display only" mode but still wants audio from the external monitor), the audio path silently breaks because:
1. The video stream is disabled, so there are no blanking intervals for audio Secondary Data Packets (SDP) to be transported.
2. The audio codec still believes the jack is present because
plugged_notify()was not called (the connector is still physically connected).3. Userspace (PulseAudio/PipeWire) continues routing audio to the external display, but no sound is actually output.
Without a framework-level notification, vendors who need to support "audio output to external display while CRTC is inactive" are forced to scatter condition checks across CRTC disable, encoder disable, suspend, and resume paths. This pattern is fragile: any change in the display pipeline can break the audio path, and the same condition ("connector connected but CRTC inactive, and audio is in use") must be duplicated in multiple locations.
The root cause is architectural: the audio codec has no visibility into CRTC state changes, so there is no clean way to implement policies like:
- Mute audio output when CRTC is disabled (instead of silent breakage)
- Keep the video stream alive for audio transport
- Switch to DP Audio Only mode (hardware-supported on some platforms, e.g. IntelTRANS_DP_AUDIO_ONLY, but never used in i915 driver)The HDA HDMI silent stream / KAE mechanism partially addresses this on Intel platforms, but it operates only on the audio codec side and does not coordinate with the DRM side. It also cannot work on platforms without HDA codec support (e.g. ASoC-based designs).
Add an optional callback
crtc_state_change()todrm_connector_hdmi_audio_funcs, and a corresponding notification functiondrm_connector_hdmi_audio_crtc_notify(). DRM drivers should call this when the CRTC state changes on a connector with audio capability, allowing audio codec implementations to react to display pipeline state changes rather than only physical connection changes.
Quoted 5 lines
This provides a framework-level mechanism to implement "audio without active display" policies cleanly, instead of scattering condition checks across the display pipeline.
Signed-off-by wangdicheng <[email protected]>
I'm not saying this is right or wrong, but I'd like to see what it looks like from a driver point of view before merging anything in the framework.
Maxime
Hi Maxime,
Thank you for the feedback. You're right - showing the driver usage is important to validate the API design before merging framework changes.
I'm preparing follow-up patches to demonstrate how this would be used in practice. Here's the plan:
1. DRM driver side: Show where to call drm_connector_hdmi_audio_crtc_notify() in the CRTC enable/disable paths (using i915 as an example)
2. Audio codec side: Show how an audio codec driver would implement the crtc_state_change callback (using HDA HDMI as an example)
I'll send these as a small series (framework patch + driver usage examples) for your review. The examples will show:
- How i915 would notify audio when a CRTC is disabled while the connector remains physically connected (e.g., user switches to "internal display only")
- How the HDA HDMI codec would handle this notification to prevent silent audio breakage
Would you prefer I send the full series now, or would you like to see the example patches first for API design review?
Best regards,
Wang Dicheng
Maxime Ripard
maintainerQuoted 10 lines · On Fri, Jun 05, 2026 at 02:09:46PM +0800, [email protected] wrote:
Hi Maxime,
Thank you for the feedback. You're right - showing the driver usage is important to validate the API design before merging framework changes.
I'm preparing follow-up patches to demonstrate how this would be used in practice. Here's the plan:
1. DRM driver side: Show where to call
drm_connector_hdmi_audio_crtc_notify()in the CRTC enable/disable paths (using i915 as an example)
i915 doesn't use the audio helpers, so I'm not sure what good that would do.
That being said, that patch and answer sure looks AI generated, and you have to disclose that in your commit log.
Maxime
Hi Maxime,
Thank you for the feedback. You're right - showing the driver usage is important to validate the API design before merging framework changes.
I'm preparing follow-up patches to demonstrate how this would be used in practice. Here's the plan:
1. DRM driver side: Show where to call drm_connector_hdmi_audio_crtc_notify() in the CRTC enable/disable paths (using i915 as an example)
2. Audio codec side: Show how an audio codec driver would implement the crtc_state_change callback (using HDA HDMI as an example)
I'll send these as a small series (framework patch + driver usage examples) for your review. The examples will show:
- How i915 would notify audio when a CRTC is disabled while the connector remains physically connected (e.g., user switches to "internal display only")
- How the HDA HDMI codec would handle this notification to prevent silent audio breakage
Would you prefer I send the full series now, or would you like to see the example patches first for API design review?
Best regards,
Wang Dicheng
Quoted 65 lines · Maxime Ripard
Hi,
Quoted 51 lines · On Wed, May 27, 2026 at 04:53:29PM +0800, [email protected] wrote:
From: wangdicheng <[email protected]>
The DRM HDMI audio helper framework notifies the audio codec about physical connection changes via
drm_connector_hdmi_audio_plugged_notify(), but has no mechanism to notify when the CRTC state changes while the connector remains physically connected.This is a real problem on platforms with DP/HDMI audio. When a CRTC is disabled while the sink remains connected (e.g. user switches to "internal display only" mode but still wants audio from the external monitor), the audio path silently breaks because:
1. The video stream is disabled, so there are no blanking intervals for audio Secondary Data Packets (SDP) to be transported.
2. The audio codec still believes the jack is present because
plugged_notify()was not called (the connector is still physically connected).3. Userspace (PulseAudio/PipeWire) continues routing audio to the external display, but no sound is actually output.
Without a framework-level notification, vendors who need to support "audio output to external display while CRTC is inactive" are forced to scatter condition checks across CRTC disable, encoder disable, suspend, and resume paths. This pattern is fragile: any change in the display pipeline can break the audio path, and the same condition ("connector connected but CRTC inactive, and audio is in use") must be duplicated in multiple locations.
The root cause is architectural: the audio codec has no visibility into CRTC state changes, so there is no clean way to implement policies like:
- Mute audio output when CRTC is disabled (instead of silent breakage)
- Keep the video stream alive for audio transport
- Switch to DP Audio Only mode (hardware-supported on some platforms, e.g. IntelTRANS_DP_AUDIO_ONLY, but never used in i915 driver)The HDA HDMI silent stream / KAE mechanism partially addresses this on Intel platforms, but it operates only on the audio codec side and does not coordinate with the DRM side. It also cannot work on platforms without HDA codec support (e.g. ASoC-based designs).
Add an optional callback
crtc_state_change()todrm_connector_hdmi_audio_funcs, and a corresponding notification functiondrm_connector_hdmi_audio_crtc_notify(). DRM drivers should call this when the CRTC state changes on a connector with audio capability, allowing audio codec implementations to react to display pipeline state changes rather than only physical connection changes.Quoted 5 lines
This provides a framework-level mechanism to implement "audio without active display" policies cleanly, instead of scattering condition checks across the display pipeline.
Signed-off-by wangdicheng <[email protected]>I'm not saying this is right or wrong, but I'd like to see what it looks like from a driver point of view before merging anything in the framework.
Maxime