linux-stable/sound/soc
Cristian Ciocaltea 863054be8d ASoC: es8316: Do not set rate constraints for unsupported MCLKs
[ Upstream commit 60413129ee ]

When using the codec through the generic audio graph card, there are at
least two calls of es8316_set_dai_sysclk(), with the effect of limiting
the allowed sample rates according to the MCLK/LRCK ratios supported by
the codec:

1. During audio card setup, to set the initial MCLK - see
   asoc_simple_init_dai().

2. Before opening a stream, to update MCLK, according to the stream
   sample rate and the multiplication factor - see
   asoc_simple_hw_params().

In some cases the initial MCLK might be set to a frequency that doesn't
match any of the supported ratios, e.g. 12287999 instead of 12288000,
which is only 1 Hz below the supported clock, as that is what the
hardware reports. This creates an empty list of rate constraints, which
is further passed to snd_pcm_hw_constraint_list() via
es8316_pcm_startup(), and causes the following error on the very first
access of the sound card:

  $ speaker-test -D hw:Analog,0 -F S16_LE -c 2 -t wav
  Broken configuration for playback: no configurations available: Invalid argument
  Setting of hwparams failed: Invalid argument

Note that all subsequent retries succeed thanks to the updated MCLK set
at point 2 above, which uses a computed frequency value instead of a
reading from the hardware registers. Normally this would have mitigated
the issue, but es8316_pcm_startup() executes before the 2nd call to
es8316_set_dai_sysclk(), hence it cannot make use of the updated
constraints.

Since es8316_pcm_hw_params() performs anyway a final validation of MCLK
against the stream sample rate and the supported MCLK/LRCK ratios, fix
the issue by ensuring that sysclk_constraints list is only set when at
least one supported sample rate is autodetected by the codec.

Fixes: b8b88b7087 ("ASoC: add es8316 codec driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://lore.kernel.org/r/20230530181140.483936-3-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-19 16:21:24 +02:00
..
adi
amd ASoC: amd: yc: Add Thinkpad Neo14 to quirks list for acp6x 2023-06-28 11:12:38 +02:00
apple ASoC: apple: mca: Improve handling of unavailable DMA channels 2023-03-11 13:55:31 +01:00
atmel ASoC: mchp-spdifrx: Fix uninitialized use of mr in mchp_spdifrx_hw_params() 2023-03-10 09:33:19 +01:00
au1x
bcm
cirrus
codecs ASoC: es8316: Do not set rate constraints for unsupported MCLKs 2023-07-19 16:21:24 +02:00
dwc ASoC: dwc: move DMA init to snd_soc_dai_driver probe() 2023-06-21 16:00:53 +02:00
fsl ASoC: fsl_sai: Enable BCI bit if SAI works on synchronous mode with BYP asserted 2023-06-28 11:12:38 +02:00
generic ASoC: simple-card: Add missing of_node_put() in case of error 2023-06-28 11:12:37 +02:00
hisilicon
img
intel ASoC: Intel: sof_sdw: remove SOF_SDW_TGL_HDMI for MeteorLake devices 2023-07-19 16:21:18 +02:00
jz4740 ASoC: jz4740-i2s: Handle independent FIFO flush bits 2023-01-07 11:11:51 +01:00
kirkwood ASoC: kirkwood: Iterate over array indexes instead of using pointer math 2023-03-10 09:33:58 +01:00
mediatek ASoC: mediatek: mt8195: fix use-after-free in driver remove path 2023-06-14 11:15:31 +02:00
meson
mxs
pxa ASoC: pxa: fix null-pointer dereference in filter() 2022-12-31 13:32:11 +01:00
qcom ASoC: qcom: q6prm: fix incorrect clk_root passed to ADSP 2023-03-22 13:34:05 +01:00
rockchip ASoC: rockchip: spdif: Add missing clk_disable_unprepare() in rk_spdif_runtime_resume() 2022-12-31 13:33:07 +01:00
samsung
sh ASoC: rsnd: fixup #endif position 2023-03-10 09:33:19 +01:00
sof ASoC: SOF: pm: save io region state in case of errors in resume 2023-06-09 10:34:13 +02:00
spear
sprd
sti
stm ASoC: stm32: i2s: remove irqf_oneshot flag 2022-11-10 17:50:52 +00:00
sunxi ASoC: sunxi: fix declaration compile error 2022-09-21 10:28:19 +01:00
tegra
ti
uniphier
ux500
xilinx
xtensa
Kconfig
Makefile
soc-ac97.c
soc-acpi.c
soc-card.c
soc-component.c Revert "ASoC: soc-component: using pm_runtime_resume_and_get instead of pm_runtime_get_sync" 2022-10-04 14:09:30 +01:00
soc-compress.c ASoC: soc-compress: Inherit atomicity from DAI link for Compress FE 2023-05-11 23:03:28 +09:00
soc-core.c ASoC: core: Fix use-after-free in snd_soc_exit() 2022-10-28 12:58:04 +01:00
soc-dai.c
soc-dapm.c ASoC: dapm: Don't use prefix for regulator name 2022-10-26 14:17:34 +01:00
soc-devres.c
soc-generic-dmaengine-pcm.c
soc-jack.c
soc-link.c
soc-ops.c ASoC: ops: Correct bounds check for second channel on SX controls 2022-11-25 16:29:33 +00:00
soc-pcm.c ASoC: soc-pcm: test if a BE can be prepared 2023-06-21 16:00:53 +02:00
soc-topology-test.c
soc-topology.c ASoC: topology: Properly access value coming from topology file 2023-03-10 09:33:18 +01:00
soc-utils-test.c
soc-utils.c ASoC: soc-utils: Remove __exit for snd_soc_util_exit() 2022-11-07 13:37:04 +00:00