On Wed, Feb 26, 2025 at 12:04:56PM +0100, Stefan Wahren wrote:
> Hi Dmitry,
> 
> Am 24.02.25 um 04:15 schrieb Dmitry Baryshkov:
> > On Sat, Feb 22, 2025 at 11:29:21AM +0100, Stefan Wahren wrote:
> > > From: David Turner <david.tur...@raspberrypi.com>
> > > 
> > > Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows
> > > when to add/remove HDMI audio devices.
> > > 
> > > Signed-off-by: David Turner <david.tur...@raspberrypi.com>
> > > Signed-off-by: Stefan Wahren <wahre...@gmx.net>
> > > ---
> > >   drivers/gpu/drm/vc4/vc4_hdmi.c | 26 ++++++++++++++++++++++++--
> > >   drivers/gpu/drm/vc4/vc4_hdmi.h |  7 +++++++
> > >   2 files changed, 31 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c 
> > > b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > > index 47d9ada98430..d24ae86d799e 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>
> > > @@ -386,6 +387,12 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi 
> > > *vc4_hdmi,
> > >           struct drm_connector *connector = &vc4_hdmi->connector;
> > >           int ret;
> > > 
> > > + /*
> > > +  * Needs to be called for both connects and disconnects for HDMI
> > > +  * audio hotplug to work correctly.
> > > +  */
> > > + drm_atomic_helper_connector_hdmi_hotplug(connector, status);
> > > +
> > >           /*
> > >            * NOTE: This function should really be called with 
> > > vc4_hdmi->mutex
> > >            * held, but doing so results in reentrancy issues since
> > > @@ -405,8 +412,6 @@ static void vc4_hdmi_handle_hotplug(struct vc4_hdmi 
> > > *vc4_hdmi,
> > >                   return;
> > >           }
> > > 
> > > - drm_atomic_helper_connector_hdmi_hotplug(connector, status);
> > > -
> > >           cec_s_phys_addr(vc4_hdmi->cec_adap,
> > >                           
> > > connector->display_info.source_physical_address, false);
> > > 
> > > @@ -2203,6 +2208,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);
> > PLease excuse my ignorance, but dows this work. In other words, how is
> > the driver exporting the plugged state through this jack?
> there is no ignorance just a valid question. Unfortunately my knowledge
> here is very limited and I just wanted to minimize the delta between
> vendor and mainline tree. That's why I marked it as RFC.
> 
> Can someone from Raspberry Pi helps here?

Okay, I found it, the hdmi-codec calls snd_soc_jack_report() when
plugged_cb() is called by the HDMI driver.

Please split the patch into two pieces:
- one which moves a call to drm_atomic_helper_connector_hdmi_hotplug()
  to a proper place. The "Needs to be called" comment should go to the
  commit message insteads of the source code.

- another one which adds a jack to the sound card.

> 
> The patch seems to fix an issue? But I don't know the broader context.
> 
> Regards

-- 
With best wishes
Dmitry

Reply via email to