* [PATCH v3 0/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver
@ 2025-03-12 15:40 David Turner
2025-03-12 15:40 ` [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect David Turner
2025-03-12 15:40 ` [PATCH v3 2/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
0 siblings, 2 replies; 7+ messages in thread
From: David Turner @ 2025-03-12 15:40 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dave Stevenson, Maíra Canal,
Raspberry Pi Kernel Maintenance, Dmitry Baryshkov
Cc: dri-devel, linux-kernel, David Turner, Stefan Wahren
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 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
Signed-off-by: David Turner <david.turner@raspberrypi.com>
---
David Turner (1):
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 | 3 ++-
drivers/gpu/drm/vc4/vc4_hdmi.c | 22 ++++++++++++++++++++--
drivers/gpu/drm/vc4/vc4_hdmi.h | 7 +++++++
3 files changed, 29 insertions(+), 3 deletions(-)
---
base-commit: eff0347e7c228335e9ff64aaf02c66957803af6a
change-id: 20250312-vc4_hotplug-3ae4e783484a
Best regards,
--
David Turner <david.turner@raspberrypi.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect
2025-03-12 15:40 [PATCH v3 0/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
@ 2025-03-12 15:40 ` David Turner
2025-03-14 13:33 ` Maxime Ripard
2025-03-12 15:40 ` [PATCH v3 2/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
1 sibling, 1 reply; 7+ messages in thread
From: David Turner @ 2025-03-12 15:40 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dave Stevenson, Maíra Canal,
Raspberry Pi Kernel Maintenance, Dmitry Baryshkov
Cc: dri-devel, linux-kernel, David Turner, Stefan Wahren
From: Stefan Wahren <wahrenst@gmx.net>
drm_atomic_helper_connector_hdmi_hotplug() must be called
regardless of the connection status, otherwise the HDMI audio
disconnect event won't be notified. Also update the comment on
drm_atomic_helper_connector_hdmi_hotplug() to explain that this is
necessary.
Fixes: 2ea9ec5d2c20 ("drm/vc4: hdmi: use drm_atomic_helper_connector_hdmi_hotplug()")
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: David Turner <david.turner@raspberrypi.com>
---
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 ++-
drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index c205f37da1e12b11c384670db83e43613e031340..d26d51902ba1a73175b23eec71562a30ceda1082 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -816,7 +816,8 @@ 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, updating the HDMI-specific connector's data. It also needs to be
+ * called for disconnects to notify audio users of the unplug.
*/
void drm_atomic_helper_connector_hdmi_hotplug(struct drm_connector *connector,
enum drm_connector_status status)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 37238a12baa58a06a5d6f40d1ab64abc7fac60d7..37a7d45695f236d3ab281d9a8676921fd434955c 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver
2025-03-12 15:40 [PATCH v3 0/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
2025-03-12 15:40 ` [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect David Turner
@ 2025-03-12 15:40 ` David Turner
2025-03-14 13:33 ` Maxime Ripard
1 sibling, 1 reply; 7+ messages in thread
From: David Turner @ 2025-03-12 15:40 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Dave Stevenson, Maíra Canal,
Raspberry Pi Kernel Maintenance, Dmitry Baryshkov
Cc: dri-devel, linux-kernel, David Turner, Stefan Wahren
Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows
when to add/remove HDMI audio devices.
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: David Turner <david.turner@raspberrypi.com>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 18 ++++++++++++++++++
drivers/gpu/drm/vc4/vc4_hdmi.h | 7 +++++++
2 files changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 37a7d45695f236d3ab281d9a8676921fd434955c..a29a6ef266f9a5952af53030a9a2d313e2ecdfce 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -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;
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h
index e3d989ca302b72533c374dfa3fd0d5bd7fe64a82..a31157c99bee6b33527c4b558fc72fff65d2a278 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.h
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
@@ -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) \
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect
2025-03-12 15:40 ` [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect David Turner
@ 2025-03-14 13:33 ` Maxime Ripard
2025-03-17 14:37 ` David Turner
0 siblings, 1 reply; 7+ messages in thread
From: Maxime Ripard @ 2025-03-14 13:33 UTC (permalink / raw)
To: David Turner
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Dave Stevenson, Maíra Canal, Raspberry Pi Kernel Maintenance,
Dmitry Baryshkov, dri-devel, linux-kernel, Stefan Wahren
[-- Attachment #1: Type: text/plain, Size: 2954 bytes --]
Hi,
On Wed, Mar 12, 2025 at 03:40:55PM +0000, David Turner wrote:
> From: Stefan Wahren <wahrenst@gmx.net>
>
> drm_atomic_helper_connector_hdmi_hotplug() must be called
> regardless of the connection status, otherwise the HDMI audio
> disconnect event won't be notified. Also update the comment on
> drm_atomic_helper_connector_hdmi_hotplug() to explain that this is
> necessary.
>
> Fixes: 2ea9ec5d2c20 ("drm/vc4: hdmi: use drm_atomic_helper_connector_hdmi_hotplug()")
> Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> Signed-off-by: David Turner <david.turner@raspberrypi.com>
> ---
> drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 ++-
> drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++--
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> index c205f37da1e12b11c384670db83e43613e031340..d26d51902ba1a73175b23eec71562a30ceda1082 100644
> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> @@ -816,7 +816,8 @@ 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, updating the HDMI-specific connector's data. It also needs to be
> + * called for disconnects to notify audio users of the unplug.
This part should be in a separate patch.
I also think that it's wrong, it's not just about audio. It just needs
to be called as part of detect no matter what the status is. Audio is
one thing that it will possibly handle depending on the driver, but
EDIDs, CEC, etc. might also be dealt with. So I don't think it's right
to focus on audio there.
> */
> void drm_atomic_helper_connector_hdmi_hotplug(struct drm_connector *connector,
> enum drm_connector_status status)
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 37238a12baa58a06a5d6f40d1ab64abc7fac60d7..37a7d45695f236d3ab281d9a8676921fd434955c 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -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);
For the vc4 part alone,
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver
2025-03-12 15:40 ` [PATCH v3 2/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
@ 2025-03-14 13:33 ` Maxime Ripard
0 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2025-03-14 13:33 UTC (permalink / raw)
To: David Turner
Cc: dri-devel, linux-kernel, Dave Stevenson, David Airlie,
Dmitry Baryshkov, Maarten Lankhorst, Maxime Ripard,
Maíra Canal, Raspberry Pi Kernel Maintenance, Simona Vetter,
Stefan Wahren, Thomas Zimmermann
On Wed, 12 Mar 2025 15:40:56 +0000, David Turner wrote:
> Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows
> when to add/remove HDMI audio devices.
>
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> Signed-off-by: David Turner <david.turner@raspberrypi.com>
>
> [ ... ]
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Thanks!
Maxime
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect
2025-03-14 13:33 ` Maxime Ripard
@ 2025-03-17 14:37 ` David Turner
2025-03-17 16:22 ` Maxime Ripard
0 siblings, 1 reply; 7+ messages in thread
From: David Turner @ 2025-03-17 14:37 UTC (permalink / raw)
To: Maxime Ripard
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Dave Stevenson, Maíra Canal, Raspberry Pi Kernel Maintenance,
Dmitry Baryshkov, dri-devel, linux-kernel, Stefan Wahren
Hi Maxime,
Thanks for the reviews.
On Fri, 14 Mar 2025 at 13:33, Maxime Ripard <mripard@kernel.org> wrote:
> I also think that it's wrong, it's not just about audio. It just needs
> to be called as part of detect no matter what the status is. Audio is
> one thing that it will possibly handle depending on the driver, but
> EDIDs, CEC, etc. might also be dealt with. So I don't think it's right
> to focus on audio there.
Does this wording sound ok?
* This function should be called as a part of the .detect() / .detect_ctx()
* callbacks for all status changes in order to update the HDMI-specific
* connector's data.
Best regards,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect
2025-03-17 14:37 ` David Turner
@ 2025-03-17 16:22 ` Maxime Ripard
0 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2025-03-17 16:22 UTC (permalink / raw)
To: David Turner
Cc: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Dave Stevenson, Maíra Canal, Raspberry Pi Kernel Maintenance,
Dmitry Baryshkov, dri-devel, linux-kernel, Stefan Wahren
[-- Attachment #1: Type: text/plain, Size: 826 bytes --]
On Mon, Mar 17, 2025 at 02:37:03PM +0000, David Turner wrote:
> Hi Maxime,
>
> Thanks for the reviews.
>
> On Fri, 14 Mar 2025 at 13:33, Maxime Ripard <mripard@kernel.org> wrote:
> > I also think that it's wrong, it's not just about audio. It just needs
> > to be called as part of detect no matter what the status is. Audio is
> > one thing that it will possibly handle depending on the driver, but
> > EDIDs, CEC, etc. might also be dealt with. So I don't think it's right
> > to focus on audio there.
>
> Does this wording sound ok?
>
> * This function should be called as a part of the .detect() / .detect_ctx()
> * callbacks for all status changes in order to update the HDMI-specific
> * connector's data.
I'd drop everything after "in order to..." but yeah, it's much better, thanks!
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-03-17 16:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 15:40 [PATCH v3 0/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
2025-03-12 15:40 ` [PATCH v3 1/2] drm/vc4: hdmi: Call HDMI hotplug helper on disconnect David Turner
2025-03-14 13:33 ` Maxime Ripard
2025-03-17 14:37 ` David Turner
2025-03-17 16:22 ` Maxime Ripard
2025-03-12 15:40 ` [PATCH v3 2/2] drm/vc4: hdmi: Add jack detection to HDMI audio driver David Turner
2025-03-14 13:33 ` Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox