From nobody Mon Jun 8 18:56:51 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED7103E0C5C for ; Wed, 27 May 2026 08:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779872053; cv=none; b=cHwYXP7Vn1TW58v6dbsTDoCFbr2WKIeBG8ATU9p69dHBasICxOp9ERud6ftJ0NJkRIvDiFMsz5ZzxawkIyFFzcFz9Ra/wnsuNmZKflpA3l8HQktaLP017r4LMT2Fv1yWlhbI+WHdaezI6fUvwk6/URymdVCyCZpet7nXt7ycHTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779872053; c=relaxed/simple; bh=HrlGIIPar/o336haayP1wk2+blfGHPzjTKoKLqJcoIo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Oo0FjNr0dCZ5h6qpZHnahM/mYvZ6IPTCPiZVU8m/I68MjY2/+B9ur7MWMl9ELQfOlI6gEfcmJzakSboBngBc8XPunnPqRCasqv3bVNaVuv5AO+M8JVxHUu/NthxX3egNvcR3yY05Bl1i90M1SBafnl2v0oNvTb7MOOh6UI32Wu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=dRe90rpu; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="dRe90rpu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=px ZNWo9LRCPMIVUw+9c1ow02KTqS79PGb7Cne9zcVKA=; b=dRe90rpuxC7raE+xCm /+CorRR4fUlVbmBU/IEv+1h3wpYh+6QGxjWWYOx4aKSogilA/Q0ykCU4UAMhQXFq 1OaUgMt+YMkeSVZJa4rxwwkFfCyUzs3fK+K7d3+sjxdbDMJhIrKTXUVXkzj2IqAu XQWEwWuuPt5tnqiiGSmAX7dvA= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wD315cLsRZqnSQMDw--.17642S2; Wed, 27 May 2026 16:53:32 +0800 (CST) From: wangdich9700@163.com To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, wangdich9700@163.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, wangdicheng Subject: [PATCH] drm/connector: add CRTC state change callback to HDMI audio helpers Date: Wed, 27 May 2026 16:53:29 +0800 Message-Id: <20260527085329.124777-1-wangdich9700@163.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wD315cLsRZqnSQMDw--.17642S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3GFy7AFW3ZFW5JFyUCFy8Krg_yoWxXr13pa 9FyrZ3Kr4vq343CFn7AF1fGrs0kaykJFyUt34Ygw15C398Krn8Aa1kGFn5u3WDJr9xZ3W2 yanIqw43Aa4vkw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zKjgshUUUUU= X-CM-SenderInfo: pzdqwv5lfkmliqq6il2tof0z/xtbC5wyP3moWsQxk5AAA37 Content-Type: text/plain; charset="utf-8" From: wangdicheng 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. Signed-off-by: wangdicheng --- .../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(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_audio_helper.c b/drivers/gpu/= drm/display/drm_hdmi_audio_helper.c index 7d78b02c1446..3437be6ee989 100644 --- a/drivers/gpu/drm/display/drm_hdmi_audio_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_audio_helper.c @@ -128,6 +128,29 @@ void drm_connector_hdmi_audio_plugged_notify(struct dr= m_connector *connector, } EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify); =20 +/** + * drm_connector_hdmi_audio_crtc_notify - Notify the audio codec of CRTC s= tate 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 =3D { .audio_startup =3D drm_connector_hdmi_audio_startup, .prepare =3D drm_connector_hdmi_audio_prepare, diff --git a/include/drm/display/drm_hdmi_audio_helper.h b/include/drm/disp= lay/drm_hdmi_audio_helper.h index 44d910bdc72d..6b6672ae73cf 100644 --- a/include/drm/display/drm_hdmi_audio_helper.h +++ b/include/drm/display/drm_hdmi_audio_helper.h @@ -19,5 +19,7 @@ int drm_connector_hdmi_audio_init(struct drm_connector *c= onnector, int sound_dai_port); void drm_connector_hdmi_audio_plugged_notify(struct drm_connector *connect= or, bool plugged); +void drm_connector_hdmi_audio_crtc_notify(struct drm_connector *connector, + bool crtc_active); =20 #endif diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index f83f28cae207..54aa15d0ef45 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -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); }; =20 void drm_connector_cec_phys_addr_invalidate(struct drm_connector *connecto= r); --=20 2.25.1