Skip to content

Commit f949ed4

Browse files
jbrun3tbroonie
authored andcommitted
ASoC: meson: axg-tdm-interface: manage formatters in trigger
So far, the formatters have been reset/enabled using the .prepare() callback. This was done in this callback because walking the formatters use a mutex. A mutex is used because formatter handling require dealing possibly slow clock operation. With the support of non-atomic, .trigger() callback may be used which also allows to properly enable and disable formatters on start but also pause/resume. This solve a random shift on TDMIN as well repeated samples on for TDMOUT. Fixes: d60e4f1 ("ASoC: meson: add tdm interface driver") Signed-off-by: Jerome Brunet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent dcba52a commit f949ed4

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

sound/soc/meson/axg-tdm-interface.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,26 +349,31 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream,
349349
return 0;
350350
}
351351

352-
static int axg_tdm_iface_hw_free(struct snd_pcm_substream *substream,
352+
static int axg_tdm_iface_trigger(struct snd_pcm_substream *substream,
353+
int cmd,
353354
struct snd_soc_dai *dai)
354355
{
355-
struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream);
356+
struct axg_tdm_stream *ts =
357+
snd_soc_dai_get_dma_data(dai, substream);
356358

357-
/* Stop all attached formatters */
358-
axg_tdm_stream_stop(ts);
359+
switch (cmd) {
360+
case SNDRV_PCM_TRIGGER_START:
361+
case SNDRV_PCM_TRIGGER_RESUME:
362+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
363+
axg_tdm_stream_start(ts);
364+
break;
365+
case SNDRV_PCM_TRIGGER_SUSPEND:
366+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
367+
case SNDRV_PCM_TRIGGER_STOP:
368+
axg_tdm_stream_stop(ts);
369+
break;
370+
default:
371+
return -EINVAL;
372+
}
359373

360374
return 0;
361375
}
362376

363-
static int axg_tdm_iface_prepare(struct snd_pcm_substream *substream,
364-
struct snd_soc_dai *dai)
365-
{
366-
struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream);
367-
368-
/* Force all attached formatters to update */
369-
return axg_tdm_stream_reset(ts);
370-
}
371-
372377
static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai)
373378
{
374379
int stream;
@@ -412,8 +417,7 @@ static const struct snd_soc_dai_ops axg_tdm_iface_ops = {
412417
.set_fmt = axg_tdm_iface_set_fmt,
413418
.startup = axg_tdm_iface_startup,
414419
.hw_params = axg_tdm_iface_hw_params,
415-
.prepare = axg_tdm_iface_prepare,
416-
.hw_free = axg_tdm_iface_hw_free,
420+
.trigger = axg_tdm_iface_trigger,
417421
};
418422

419423
/* TDM Backend DAIs */

0 commit comments

Comments
 (0)