ASoC: dpcm: improve runtime update predictability
authorJerome Brunet <jbrunet@baylibre.com>
Tue, 26 Jun 2018 10:07:25 +0000 (12:07 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 28 Jun 2018 10:16:23 +0000 (11:16 +0100)
commitde15d7ff5bef98746fcb76a0db7ac46de48d3560
treebbbdea20f0bdf4bbc94515c68c1aa0562a037c4f
parentf516d32262a4c0fef3fccdf2a82671f54f5c1e33
ASoC: dpcm: improve runtime update predictability

As it is, dpcm_runtime_update() performs the old path and new path
update of a frontend before going on to the next frontend DAI.
Depending the order of the FEs within the rtd list, the result of
the update might be different.

For example:
 * Frontend A connected to backend C, with a 48kHz playback
 * Frontend B connected to backend D, with a 44.1kHz playback
 * FE A appears before FE B in the rtd list of the card.

If we reparent BE C to FE B (disconnecting BE D):
* old path update of FE A will run first, and BE C will get hw_free()
  and shutdown()
* new path update of FE B will run after and BE C, which is stopped,
  so it will be configured at 44.1kHz, as expected

If we reparent BE D to FE A (disconnecting BE C):
* new path update of FE A will run first but since BE D is still running
  at 44.1kHz, it won't be reconfigured (no call to startup() or
  hw_params())
* old path update of FE B runs after, nothing happens
* In this case, we end up with a BE playing at 44.1kHz a stream which is
  supposed to be played at 48Khz (too slow)

To improve this situation, this patch performs all the FE old paths update
before going on to update the new paths. With this, the result should
no longer depend on the order of the FE within the card rtd list.

Please note that there might be a small performance penalty since
dpcm_process_paths() is called twice per stream direction.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-pcm.c