drm/vc4: hdmi: Add jack detection to HDMI audio driver
Subsystems (3)
v4 cover drm/vc4: hdmi: Add jack detection to HDMI audio driver
This series enables jack detection for HDMI audio on vc4 devices. This means that userspace audio applications can detect when HDMI devices are connected or disconnected, for example to play/pause or switch to another audio device.
Changes in v4:
- Split the update of the comment on drm_atomic_helper_connector_hdmi_hotplug() into a separate patch
- Update the wording of the comment
- Add Reviewed-by tags
- Link to v3:
https://lore.kernel.org/r/[email protected]
Changes in V3:
- Update comment on drm_atomic_helper_connector_hdmi_hotplug() to clarify that it must be called for disconnets too
Changes in V2:
- split initial patch into fix and jack detection feature as suggested by Dmitry
---
David Turner (2):
drm/display: Update comment on hdmi hotplug helper drm/vc4: hdmi: Add jack detection to HDMI audio driver
Stefan Wahren (1):
drm/vc4: hdmi: Call HDMI hotplug helper on disconnect
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 2 +- drivers/gpu/drm/vc4/vc4_hdmi.c | 22 ++++++++++++++++++++-- drivers/gpu/drm/vc4/vc4_hdmi.h | 7 +++++++ 3 files changed, 28 insertions(+), 3 deletions(-)
---
base-commit: eff0347e7c228335e9ff64aaf02c66957803af6a
change-id: 20250312-vc4_hotplug-3ae4e783484a
Best regards,
Signature · 1 line
David Turner <[email protected]>
PATCH v4 1/3 drm/display: Update comment on hdmi hotplug helper
Update the comment on drm_atomic_helper_connector_hdmi_hotplug() to clarify that it must be called for all status updates.
--- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/display/drm_hdmi_state_helper.c +1 -1
@@ -816,7 +816,7 @@ drm_atomic_helper_connector_hdmi_update(struct drm_connector *connector,* @status: Connection status * * This function should be called as a part of the .detect() / .detect_ctx() -* callbacks, updating the HDMI-specific connector's data. +* callbacks for all status changes. */ void drm_atomic_helper_connector_hdmi_hotplug (struct drm_connector *connector,enum drm_connector_status status)
Signature · 1 line
2.34.1
Re: [PATCH v4 1/3] drm/display: Update comment on hdmi hotplug helper
Quoted 4 lines · David Turner
Update the comment on
drm_atomic_helper_connector_hdmi_hotplug()to clarify that it must be called for all status updates.Signed-off-by David Turner <[email protected]>
Thanks!
Maxime
PATCH v4 2/3 drm/vc4: hdmi: Call HDMI hotplug helper on disconnect
In reply to David TurnerFrom: Stefan Wahren <[email protected]>
drm_atomic_helper_connector_hdmi_hotplug() must be called regardless of the connection status, otherwise the HDMI audio disconnect event won't be notified.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +2 -2
@@ -372,13 +372,13 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi *vc4_hdmi,* the lock for now. */ +drm_atomic_helper_connector_hdmi_hotplug (connector, status); +if (status == connector_status_disconnected) {cec_phys_addr_invalidate (vc4_hdmi->cec_adap);return ; } -drm_atomic_helper_connector_hdmi_hotplug (connector, status); -cec_s_phys_addr (vc4_hdmi->cec_adap, connector->display_info.source_physical_address, false);
Signature · 1 line
2.34.1
PATCH v4 3/3 drm/vc4: hdmi: Add jack detection to HDMI audio driver
In reply to David TurnerAdd ALSA jack detection to the vc4-hdmi audio driver so userspace knows when to add/remove HDMI audio devices.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 18 ++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 7 +++++++ 2 files changed, 25 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +18 -0
@@ -51,6 +51,7 @@#include <linux/reset.h> #include <sound/dmaengine_pcm.h> #include <sound/hdmi-codec.h> +#include <sound/jack.h> #include <sound/pcm_drm_eld.h> #include <sound/pcm_params.h> #include <sound/soc.h>
@@ -2175,6 +2176,22 @@ static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs = { .shutdown = vc4_hdmi_audio_shutdown, }; +static int vc4_hdmi_codec_init (struct snd_soc_pcm_runtime *rtd) +{ +struct vc4_hdmi *vc4_hdmi =snd_soc_card_get_drvdata (rtd->card); +struct snd_soc_component *component =snd_soc_rtd_to_codec (rtd,0 )->component; +int ret; + + ret =snd_soc_card_jack_new (rtd->card,"HDMI Jack" ,SND_JACK_LINEOUT , + &vc4_hdmi->hdmi_jack); +if (ret) { +dev_err (rtd->dev,"HDMI Jack creation failed: %d\n" , ret); +return ret; + } + +return snd_soc_component_set_jack (component, &vc4_hdmi->hdmi_jack,NULL ); +} +static int vc4_hdmi_audio_init (struct vc4_hdmi *vc4_hdmi) { const struct vc4_hdmi_register *mai_data =
@@ -2288,6 +2305,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) dai_link->cpus->dai_name =dev_name (dev); dai_link->codecs->name =dev_name (&vc4_hdmi->connector.hdmi_audio.codec_pdev->dev); dai_link->platforms->name =dev_name (dev); + dai_link->init = vc4_hdmi_codec_init; card->dai_link = dai_link; card->num_links =1 ;
drivers/gpu/drm/vc4/vc4_hdmi.h +7 -0
@@ -4,6 +4,7 @@#include <drm/drm_connector.h> #include <media/cec.h> #include <sound/dmaengine_pcm.h> +#include <sound/hdmi-codec.h> #include <sound/soc.h> #include "vc4_drv.h"
@@ -211,6 +212,12 @@ struct vc4_hdmi {* KMS hooks. Protected by @mutex. */ enum hdmi_colorspace output_format; + +/** +* @hdmi_jack: Represents the connection state of the HDMI plug, for +* ALSA jack detection. +*/ +struct snd_soc_jack hdmi_jack; };#define connector_to_vc4_hdmi (_connector) \
Signature · 1 line
2.34.1
Dave Stevenson
maintainerQuoted 5 lines · David Turner
This series enables jack detection for HDMI audio on vc4 devices. This means that userspace audio applications can detect when HDMI devices are connected or disconnected, for example to play/pause or switch to another audio device.
Thanks.
Series merged to drm-misc-next.
Quoted 37 lines
Changes in v4:
- Split the update of the comment ondrm_atomic_helper_connector_hdmi_hotplug()into a separate patch
- Update the wording of the comment
- Add Reviewed-by tags
- Link to v3:
https://lore.kernel.org/r/[email protected]Changes in V3:
- Update comment ondrm_atomic_helper_connector_hdmi_hotplug()to clarify that it must be called for disconnets tooChanges in V2:
- split initial patch into fix and jack detection feature as suggested by DmitrySigned-off-by David Turner <[email protected]>---
David Turner (2):
drm/display: Update comment on hdmi hotplug helper drm/vc4: hdmi: Add jack detection to HDMI audio driverStefan Wahren (1):
drm/vc4: hdmi: Call HDMI hotplug helper on disconnectdrivers/gpu/drm/display/drm_hdmi_state_helper.c | 2 +- drivers/gpu/drm/vc4/vc4_hdmi.c | 22 ++++++++++++++++++++-- drivers/gpu/drm/vc4/vc4_hdmi.h | 7 +++++++ 3 files changed, 28 insertions(+), 3 deletions(-)---
base-commit:eff0347e7c228335e9ff64aaf02c66957803af6a
change-id: 20250312-vc4_hotplug-3ae4e783484aBest regards,
--
David Turner <[email protected]>