[PATCH v2 09/21] ASoC: apple: Add macaudio machine driver

Ajay Kumar Nandam ajay.nandam at oss.qualcomm.com
Wed Oct 7 11:04:37 PDT 2026



On 10/4/2026 11:33 AM, James Calligeros wrote:
> From: Martin Povišer <povik+lin at cutebit.org>
> 
> Apple Silicon Macs have a complex audio subsystem consisting
> of an I2S peripheral (MCA) and multiple codecs of various
> models and capabilities. Some machines have a basic mono
> speaker with hardware downmix, while others have a very
> intricate stereo system consisting of multiple codecs and
> drivers per L/R channel. Some machines report voice coil
> voltage and current information back to the SoC, and others
> do not. All machines have a headset jack.
> 
> Add an ASoC machine driver for this platform.
> 
> To express all of this sanely, we initialise the correct
> combinations of codecs/I2S ports as DAI backends and link
> them to a synthetic frontend. Each frontend is linked to
> a PCM, one for the headset codec and one for the speaker
> system on the target machine.
> 
> Signed-off-by: Martin Povišer <povik+lin at cutebit.org>
> Co-developed-by: Hector Martin <marcan at marcan.st>
> Signed-off-by: Hector Martin <marcan at marcan.st>
> Co-developed-by: Janne Grunau <j at jannau.net>
> Signed-off-by: Janne Grunau <j at jannau.net>
> Co-developed-by: Sasha Finkelstein <fnkl.kernel at gmail.com>
> Signed-off-by: Sasha Finkelstein <fnkl.kernel at gmail.com>
> Co-developed-by: James Calligeros <jcalligeros99 at gmail.com>
> Signed-off-by: James Calligeros <jcalligeros99 at gmail.com>
> ---
>   sound/soc/apple/Kconfig    |   18 +
>   sound/soc/apple/Makefile   |    4 +
>   sound/soc/apple/macaudio.c | 1699 +++++++++++++++++++++++++
>   3 files changed, 1721 insertions(+)
> 

> +
> +static int macaudio_be_trigger(struct snd_pcm_substream *substream, int cmd)
> +{
> +	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
> +	struct macaudio_snd_data *ma = snd_soc_card_get_drvdata(rtd->card);
> +	struct macaudio_link_props *props = &ma->link_props[rtd->dai_link->id];
> +
> +	guard(mutex)(&ma->be_link_mutex);
> +

This is in the DAI link `.trigger` callback, but I don't see the
macaudio links being marked `.nonatomic = 1`.

The default PCM trigger path can run with the stream lock held and IRQs
disabled, so taking a normal mutex here can sleep in atomic context. If
this state really needs a sleeping lock, should the affected links be
marked nonatomic, or should the trigger path avoid the mutex?

> +	if (props->is_speakers && substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> +		switch (cmd) {
> +		case SNDRV_PCM_TRIGGER_START:
> +		case SNDRV_PCM_TRIGGER_RESUME:
> +		case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> +			ma->bes_active |= BIT(rtd->dai_link->id);
> +			break;
> +		case SNDRV_PCM_TRIGGER_SUSPEND:
> +		case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> +		case SNDRV_PCM_TRIGGER_STOP:
> +			ma->bes_active &= ~BIT(rtd->dai_link->id);
> +			break;
> +		default:
> +			return -EINVAL;
> +		}
> +
> +		schedule_work(&ma->lock_update_work);
> +	}
> +
> +	return 0;
> +}
> +



More information about the Linux-mediatek mailing list