ASoC: SOF: ipc4-pcm: add delay function support
authorRander Wang <rander.wang@intel.com>
Thu, 2 Feb 2023 13:29:54 +0000 (15:29 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 3 Feb 2023 12:03:55 +0000 (12:03 +0000)
commit3937a76c64931109dfafa999a0c78b4df2a6e0a1
tree7c26b451bfd63cefb2319c8d8cb08b6371fa0127
parentfaceb3445aaf1704583744b48c622dbc96ef9ab2
ASoC: SOF: ipc4-pcm: add delay function support

The delay function is used to calculate the difference
between hw_ptr and dai dma position. I2S, DMIC and SDW will
use dai dma position in shared SRAM window to calculate the
delay. HDaudio will retrieve dai dma position from host mmio memory
space since it doesn't support LLP counter reported by firmware.

In two cases dai dma position is inaccurate for delay calculation
(1) dai pipeline is started before host pipeline
(2) multiple streams mixed into one. Each stream has the same dai
    dma position
Firmware calculates correct stream_start_offset for all cases including
above two. Driver subtracts stream_start_offset from dai dma position to
get accurate one.

Signed-off-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230202132954.26773-10-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc4-pcm.c