Skip to content

Commit 2f9d517

Browse files
cillian646by9
authored andcommitted
drm/vc4: hdmi: Add jack detection to HDMI audio driver
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> Reviewed-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: David Turner <david.turner@raspberrypi.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250317-vc4_hotplug-v4-3-2af625629186@raspberrypi.com Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 34f051a commit 2f9d517

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <linux/reset.h>
5252
#include <sound/dmaengine_pcm.h>
5353
#include <sound/hdmi-codec.h>
54+
#include <sound/jack.h>
5455
#include <sound/pcm_drm_eld.h>
5556
#include <sound/pcm_params.h>
5657
#include <sound/soc.h>
@@ -2175,6 +2176,22 @@ static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs = {
21752176
.shutdown = vc4_hdmi_audio_shutdown,
21762177
};
21772178

2179+
static int vc4_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd)
2180+
{
2181+
struct vc4_hdmi *vc4_hdmi = snd_soc_card_get_drvdata(rtd->card);
2182+
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
2183+
int ret;
2184+
2185+
ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT,
2186+
&vc4_hdmi->hdmi_jack);
2187+
if (ret) {
2188+
dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret);
2189+
return ret;
2190+
}
2191+
2192+
return snd_soc_component_set_jack(component, &vc4_hdmi->hdmi_jack, NULL);
2193+
}
2194+
21782195
static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
21792196
{
21802197
const struct vc4_hdmi_register *mai_data =
@@ -2288,6 +2305,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
22882305
dai_link->cpus->dai_name = dev_name(dev);
22892306
dai_link->codecs->name = dev_name(&vc4_hdmi->connector.hdmi_audio.codec_pdev->dev);
22902307
dai_link->platforms->name = dev_name(dev);
2308+
dai_link->init = vc4_hdmi_codec_init;
22912309

22922310
card->dai_link = dai_link;
22932311
card->num_links = 1;

drivers/gpu/drm/vc4/vc4_hdmi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <drm/drm_connector.h>
55
#include <media/cec.h>
66
#include <sound/dmaengine_pcm.h>
7+
#include <sound/hdmi-codec.h>
78
#include <sound/soc.h>
89

910
#include "vc4_drv.h"
@@ -211,6 +212,12 @@ struct vc4_hdmi {
211212
* KMS hooks. Protected by @mutex.
212213
*/
213214
enum hdmi_colorspace output_format;
215+
216+
/**
217+
* @hdmi_jack: Represents the connection state of the HDMI plug, for
218+
* ALSA jack detection.
219+
*/
220+
struct snd_soc_jack hdmi_jack;
214221
};
215222

216223
#define connector_to_vc4_hdmi(_connector) \

0 commit comments

Comments
 (0)