ASoC: qcom: q6apm-dai: Add SNDRV_PCM_INFO_BATCH flag
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Thu, 9 Feb 2023 12:28:01 +0000 (12:28 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:21 +0000 (09:33 +0100)
commitadcc7c98ce4c98f4c12f7f8b387bf2756a3f824b
treef3515295ee091e1b05cc32d9d81861e0b438164e
parentcd57b2898a81e232db419e1fe892f6b188031e48
ASoC: qcom: q6apm-dai: Add SNDRV_PCM_INFO_BATCH flag

[ Upstream commit aa759f3f9f4394a3af65ad1772fca6cb9dd9e4cc ]

At the moment, playing audio with PulseAudio with the qdsp6 driver
results in distorted sound. It seems like its timer-based scheduling
does not work properly with qdsp6 since setting tsched=0 in
the PulseAudio configuration avoids the issue.

Apparently this happens when the pointer() callback is not accurate
enough. There is a SNDRV_PCM_INFO_BATCH flag that can be used to stop
PulseAudio from using timer-based scheduling by default.

According to https://www.alsa-project.org/pipermail/alsa-devel/2014-March/073816.html:

The flag is being used in the sense explained in the previous audio
meeting -- the data transfer granularity isn't fine enough but aligned
to the period size (or less).

q6apm-dai reports the position as multiple of

prtd->pcm_count = snd_pcm_lib_period_bytes(substream)

so it indeed just a multiple of the period size.

Therefore adding the flag here seems appropriate and makes audio
work out of the box.

Comment log inspired by Stephan Gerhold sent for q6asm-dai.c few years back.

Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230209122806.18923-4-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/qcom/qdsp6/q6apm-dai.c