Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 so it could not be done in .trigger(), which is atomic by default.

It turns out there is a problem on capture path of the AXG series.
The FIFO may get out of sync with the TDM decoder if the IP are not enabled
in a specific order. The FIFO must be enabled before the formatter starts
producing data. IOW, we must deal with FE before the BE. The .prepare()
callback is called on the BEs before the FE so it is not OK for the AXG.

The .trigger() callback order can be configured, and it deals with the FE
before the BEs by default. To solve our problem, we just need to start and
stop the formatters from the .trigger() callback. It is OK do so now that
the links have been made 'nonatomic' in the card driver.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20211020114217.133153-3-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jerome Brunet and committed by
Mark Brown
bf5e4887 e138233e

+21 -5
+21 -5
sound/soc/meson/axg-tdm-interface.c
··· 351 351 return 0; 352 352 } 353 353 354 - static int axg_tdm_iface_prepare(struct snd_pcm_substream *substream, 354 + static int axg_tdm_iface_trigger(struct snd_pcm_substream *substream, 355 + int cmd, 355 356 struct snd_soc_dai *dai) 356 357 { 357 - struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream); 358 + struct axg_tdm_stream *ts = 359 + snd_soc_dai_get_dma_data(dai, substream); 358 360 359 - /* Force all attached formatters to update */ 360 - return axg_tdm_stream_reset(ts); 361 + switch (cmd) { 362 + case SNDRV_PCM_TRIGGER_START: 363 + case SNDRV_PCM_TRIGGER_RESUME: 364 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 365 + axg_tdm_stream_start(ts); 366 + break; 367 + case SNDRV_PCM_TRIGGER_SUSPEND: 368 + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 369 + case SNDRV_PCM_TRIGGER_STOP: 370 + axg_tdm_stream_stop(ts); 371 + break; 372 + default: 373 + return -EINVAL; 374 + } 375 + 376 + return 0; 361 377 } 362 378 363 379 static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai) ··· 413 397 .set_fmt = axg_tdm_iface_set_fmt, 414 398 .startup = axg_tdm_iface_startup, 415 399 .hw_params = axg_tdm_iface_hw_params, 416 - .prepare = axg_tdm_iface_prepare, 417 400 .hw_free = axg_tdm_iface_hw_free, 401 + .trigger = axg_tdm_iface_trigger, 418 402 }; 419 403 420 404 /* TDM Backend DAIs */