platform/kernel/linux-rpi.git
21 months agoASoC: dt-bindings: maxim,max98095: Convert to dtschema
Krzysztof Kozlowski [Sat, 11 Feb 2023 13:47:55 +0000 (14:47 +0100)]
ASoC: dt-bindings: maxim,max98095: Convert to dtschema

Convert the Maxim Integrated MAX98095 audio codec bindings to DT schema.
Add missing sound-dai-cells during conversion.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230211134755.86061-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: ep93xx: ignore 0 Hz sysclk
Alexander Sverdlin [Sun, 12 Feb 2023 22:09:23 +0000 (23:09 +0100)]
ASoC: ep93xx: ignore 0 Hz sysclk

Commit 2458adb8f92a
("SoC: simple-card-utils: set 0Hz to sysclk when shutdown")
added a call to snd_soc_dai_set_sysclk() with 0 Hz frequency. Being
propagated further it causes a division by zero in clk-ep93xx driver:

Division by zero in kernel.
CPU: 0 PID: 52 Comm: aplay Tainted: G        W          6.2.0-rc4-... #1
Hardware name: Generic DT based system
 unwind_backtrace from show_stack+0x10/0x18
 show_stack from dump_stack_lvl+0x28/0x34
 dump_stack_lvl from __div0+0x10/0x1c
 __div0 from Ldiv0+0x8/0x1c
 Ldiv0 from ep93xx_mux_determine_rate+0x78/0x1d0
 ep93xx_mux_determine_rate from clk_core_round_rate_nolock+0x48/0xc8
 clk_core_round_rate_nolock from clk_core_set_rate_nolock+0x48/0x160
 clk_core_set_rate_nolock from clk_set_rate+0x30/0x8c
 clk_set_rate from ep93xx_i2s_set_sysclk+0x30/0x6c
 ep93xx_i2s_set_sysclk from snd_soc_dai_set_sysclk+0x3c/0xa4
 snd_soc_dai_set_sysclk from asoc_simple_shutdown+0xb8/0x164
 asoc_simple_shutdown from snd_soc_link_shutdown+0x44/0x54
 snd_soc_link_shutdown from soc_pcm_clean+0x78/0x180
 soc_pcm_clean from soc_pcm_close+0x28/0x40
 soc_pcm_close from snd_pcm_release_substream.part.0+0x3c/0x84
 snd_pcm_release_substream.part.0 from snd_pcm_release+0x40/0x88
 snd_pcm_release from __fput+0x74/0x278

There has been commit f1879d7b98dc ("ASoC: rockchip: ignore 0Hz sysclk"),
but it prepared by far not all drivers.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://lore.kernel.org/r/20230212220923.258414-1-alexander.sverdlin@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rt712-sdca: fix coding style and unconditionally return issues
Shuming Fan [Fri, 10 Feb 2023 08:21:41 +0000 (16:21 +0800)]
ASoC: rt712-sdca: fix coding style and unconditionally return issues

This patch fixes
1. coding style issues
2. check if the setting was set already in rt712_sdca_mux_put callback

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20230210082141.24077-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: core.c: indicate warning if strange TDM width was set
Kuninori Morimoto [Fri, 10 Feb 2023 05:13:43 +0000 (05:13 +0000)]
ASoC: rsnd: core.c: indicate warning if strange TDM width was set

Current rsnd silently uses default TDM width if it was strange
settings. It is difficult to notice about it.
This patch indicates warning for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lel6ksqn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: qcom: q6dsp and lpass codec stablity fixes
Mark Brown [Thu, 9 Feb 2023 18:24:42 +0000 (18:24 +0000)]
ASoC: qcom: q6dsp and lpass codec stablity fixes

Merge series from Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
From q6dsp side issues are around locking of position pointer and handle
From LPASS codec side most of the staiblity issues were around runtime pm,:

While testing X13s audio, we found multiple stablity issues this patchset
fixes these issues.
From q6dsp side issues are around locking of position pointer and handle
multiple prepare cases along with pulse audio timerbased scheduling workaround.

From LPASS codec side most of the staiblity issues were around runtime pm,
hitting various issues as the codec was firstly resetting the soundwire block
for every clk disable/enable which is taking the slaves out of sync and
resulting in re-enumerating. Second issue was around fsgen clk is not
brining up the codec out of suspend as it was not added after
runtime pm enabled. Final issue was with codec mclk rate which should
have been 192KHz same as npl instead of 96KHz. We were getting lucky as
wsa drivers are setting the same clk to 192KHz.

With this patches, x13s audio is pretty stable.

21 months agoASoC: SOF: ipc4-topology: Configure copier sink format
Mark Brown [Thu, 9 Feb 2023 18:24:35 +0000 (18:24 +0000)]
ASoC: SOF: ipc4-topology: Configure copier sink format

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

In a course of creating complicated topologies where multiple output pins of a
copier is enabled, we have discovered that additional configuration needs to be
sent to the firmware to make the use cases working.

21 months agoAdd the Infineon PEB2466 codec support
Mark Brown [Thu, 9 Feb 2023 18:24:27 +0000 (18:24 +0000)]
Add the Infineon PEB2466 codec support

Merge series from Herve Codina <herve.codina@bootlin.com>:

The Infineon PEB2466 codec is a programmable DSP-based four channels
codec with filters capabilities.
It also provides signals as GPIOs.

21 months agoASoC: dt-bindings: qcom,q6apm-dai: adjust iommus for SM8550 ADSP
Krzysztof Kozlowski [Mon, 6 Feb 2023 15:05:32 +0000 (16:05 +0100)]
ASoC: dt-bindings: qcom,q6apm-dai: adjust iommus for SM8550 ADSP

It seems that SM8550 ADSP remote processor uses two IOMMUs.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230206150532.513468-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: qcom,wcd934x: Allow usage as IFD device
Krzysztof Kozlowski [Mon, 6 Feb 2023 18:08:05 +0000 (19:08 +0100)]
ASoC: dt-bindings: qcom,wcd934x: Allow usage as IFD device

The WCD9340 audio codec appears on Slimbus twice: as IFD device without
properties and the actual audio-codec referencing the former via
wcd9340_ifd.  Allow in the binding both versions to fix several warnings
like:

  sdm850-samsung-w737.dtb: ifd@0,0: 'reset-gpios' is a required property
  sdm850-samsung-w737.dtb: ifd@0,0: 'slim-ifc-dev' is a required property
  sdm850-samsung-w737.dtb: ifd@0,0: 'interrupt-controller' is a required property

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230206180805.6621-3-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: qcom,wcd934x: Describe slim-ifc-dev
Krzysztof Kozlowski [Mon, 6 Feb 2023 18:08:04 +0000 (19:08 +0100)]
ASoC: dt-bindings: qcom,wcd934x: Describe slim-ifc-dev

The "slim-ifc-dev" property should not be just "true", because it allows
any type.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230206180805.6621-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: qcom,wsa881x: Allow sound-name-prefix
Krzysztof Kozlowski [Mon, 6 Feb 2023 18:08:03 +0000 (19:08 +0100)]
ASoC: dt-bindings: qcom,wsa881x: Allow sound-name-prefix

Reference common DAI properties to fix:

  sdm845-db845c.dtb: speaker@0,1: 'sound-name-prefix' does not match any of the regexes: 'pinctrl-[0-9]+'

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230206180805.6621-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rt712-sdca: Add RT712 SDCA driver for Jack and Amp topology
Shuming Fan [Tue, 7 Feb 2023 09:09:46 +0000 (17:09 +0800)]
ASoC: rt712-sdca: Add RT712 SDCA driver for Jack and Amp topology

This is the initial codec driver for rt712 SDCA (Jack+Amp topology).
The host should connect with rt712 SdW1 interface.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20230207090946.20659-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rt5640: Update MCLK rate in set_sysclk()
Sameer Pujar [Thu, 9 Feb 2023 14:36:56 +0000 (20:06 +0530)]
ASoC: rt5640: Update MCLK rate in set_sysclk()

Simple-card/audio-graph-card drivers do not handle MCLK clock when it
is specified in the codec device node. The expectation here is that,
the codec should actually own up the MCLK clock and do necessary setup
in the driver.

This is inspired from,
commit dbf54a953435 ("ASoC: rt5659: Update MCLK rate in set_sysclk()").

Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1675953417-8686-2-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoMAINTAINERS: add the Infineon PEB2466 codec entry
Herve Codina [Mon, 6 Feb 2023 14:49:04 +0000 (15:49 +0100)]
MAINTAINERS: add the Infineon PEB2466 codec entry

After contributing the driver, add myself as the maintainer for the
Infineon PEB2466 codec.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20230206144904.91078-4-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: Add support for the Infineon PEB2466 codec
Herve Codina [Mon, 6 Feb 2023 14:49:03 +0000 (15:49 +0100)]
ASoC: codecs: Add support for the Infineon PEB2466 codec

The Infineon PEB2466 codec is a programmable DSP-based four channels
codec with filters capabilities.
It also provides signals as GPIOs.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20230206144904.91078-3-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: Add the Infineon PEB2466 codec
Herve Codina [Mon, 6 Feb 2023 14:49:02 +0000 (15:49 +0100)]
ASoC: dt-bindings: Add the Infineon PEB2466 codec

The Infineon PEB2466 codec is a programmable DSP-based four channels
codec with filters capabilities.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230206144904.91078-2-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc4-topology: set copier sink format
Bard Liao [Thu, 9 Feb 2023 14:21:23 +0000 (16:21 +0200)]
ASoC: SOF: ipc4-topology: set copier sink format

MOD_INIT_INSTANCE IPC for a copier only contains the sink format for
output pin 0. Any additional output pins that are used need to have their
sink format set using the LARGE_CONFIG_SET IPC message.
Otherwise, firmware will report error or crash due to NULL format is used.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230209142123.17193-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc4-topology: Print queue IDs in error
Ranjani Sridharan [Thu, 9 Feb 2023 14:21:22 +0000 (16:21 +0200)]
ASoC: SOF: ipc4-topology: Print queue IDs in error

Print the queue ID's during bind/unbind errors as well to make it easier
to see what failed exactly.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230209142123.17193-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: lpass: remove not so useful verbose log
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:06 +0000 (12:28 +0000)]
ASoC: codecs: lpass: remove not so useful verbose log

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230209122806.18923-9-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: lpass: do not reset soundwire block on clk enable
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:05 +0000 (12:28 +0000)]
ASoC: codecs: lpass: do not reset soundwire block on clk enable

resetting soundwire block will put the slaves out of sync and result
in re-enumeration during fsgen disable/enable path this is totally
unnecessary and resulting fifo overflows.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230209122806.18923-8-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: lpass: fix incorrect mclk rate
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:04 +0000 (12:28 +0000)]
ASoC: codecs: lpass: fix incorrect mclk rate

For some reason we ended up with incorrect mclk rate which should be
1920000 instead of 96000, So far we were getting lucky as the same clk
is set to 192000 by wsa and va macro. This issue is discovered when there
is no wsa macro active and only rx or tx path is tested.
Fix this by setting correct rate.

Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Fixes: af3d54b99764 ("ASoC: codecs: lpass-rx-macro: add support for lpass rx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230209122806.18923-7-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: lpass: register mclk after runtime pm
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:03 +0000 (12:28 +0000)]
ASoC: codecs: lpass: register mclk after runtime pm

move mclk out registration after runtime pm is enabled so that the
clk framework can resume the codec if it requires to enable the mclk out.

Fixes: c96baa2949b2 ("ASoC: codecs: wsa-macro: add runtime pm support")
Fixes: 72ad25eabda0 ("ASoC: codecs: va-macro: add runtime pm support")
Fixes: 366ff79ed539 ("ASoC: codecs: rx-macro: add runtime pm support")
Fixes: 1fb83bc5cf64 ("ASoC: codecs: tx-macro: add runtime pm support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230209122806.18923-6-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: qcom: audioreach: fix ADSP ready check
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:02 +0000 (12:28 +0000)]
ASoC: qcom: audioreach: fix ADSP ready check

currently q6apm_is_adsp_ready() will only return the cached value of
previous result. If we are unlucky and previous result is not-ready
then the caller will always get not-ready flag.

This is not correct, we should query the dsp of its current state in
irrespective of previous reported state.

Fixes: 47bc8cf60e92 ("ASoC: qdsp6: audioreach: Add ADSP ready check")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230209122806.18923-5-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: qcom: q6apm-dai: Add SNDRV_PCM_INFO_BATCH flag
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:01 +0000 (12:28 +0000)]
ASoC: qcom: q6apm-dai: Add SNDRV_PCM_INFO_BATCH flag

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>
21 months agoASoC: qcom: q6apm-dai: fix race condition while updating the position pointer
Srinivas Kandagatla [Thu, 9 Feb 2023 12:28:00 +0000 (12:28 +0000)]
ASoC: qcom: q6apm-dai: fix race condition while updating the position pointer

It is noticed that the position pointer value seems to get a get corrupted
due to missing locking between updating and reading.

Fix this by adding a spinlock around the position pointer.

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-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: qcom: q6apm-lpass-dai: unprepare stream if its already prepared
Srinivas Kandagatla [Thu, 9 Feb 2023 12:27:59 +0000 (12:27 +0000)]
ASoC: qcom: q6apm-lpass-dai: unprepare stream if its already prepared

prepare callback can be called multiple times, so unprepare the stream
if its already prepared.

Without this DSP is not happy to setting the params on a already
prepared graph.

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-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SMA1303: Remove the sysclk setting in devicetree
Kiseok Jo [Thu, 9 Feb 2023 08:49:03 +0000 (08:49 +0000)]
ASoC: SMA1303: Remove the sysclk setting in devicetree

In SMA1303, this device does not support MCLK.
So it need to remove sysclk setting in devicetree.

Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com>
Link: https://lore.kernel.org/r/20230209084903.13000-2-kiseok.jo@irondevice.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: max98090: simplify snd_soc_dai_driver
Krzysztof Kozlowski [Wed, 8 Feb 2023 16:04:10 +0000 (17:04 +0100)]
ASoC: codecs: max98090: simplify snd_soc_dai_driver

The max98090 has only one DAI, so snd_soc_dai_driver does not have to be
an array.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230208160410.371609-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: maxim,max98090: Convert to dtschema
Krzysztof Kozlowski [Wed, 8 Feb 2023 16:04:09 +0000 (17:04 +0100)]
ASoC: dt-bindings: maxim,max98090: Convert to dtschema

Convert the Maxim Integrated MAX98090/MAX98091 audio codecs bindings to
DT schema.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230208160410.371609-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg sound card control to schema
Jerome Brunet [Wed, 8 Feb 2023 09:35:19 +0000 (10:35 +0100)]
ASoC: dt-bindings: meson: convert axg sound card control to schema

Convert the DT binding documentation for the Amlogic axg sound card to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230208093520.52843-2-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: irondevice,sma1303: Rework binding and add missing properties
Kiseok Jo [Wed, 8 Feb 2023 09:24:20 +0000 (09:24 +0000)]
ASoC: dt-bindings: irondevice,sma1303: Rework binding and add missing properties

Add the missing properties as compatible, reg, sound-dai-cells.
And then check this file using 'make dt_binding_check'.

Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230208092420.5037-8-kiseok.jo@irondevice.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SMA1303: Convert the TDM slot properties in devicetree to mixer
Kiseok Jo [Wed, 8 Feb 2023 09:24:18 +0000 (09:24 +0000)]
ASoC: SMA1303: Convert the TDM slot properties in devicetree to mixer

It seems correct that the user changes the TDM slot needed after
device probe.

Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com>
Link: https://lore.kernel.org/r/20230208092420.5037-6-kiseok.jo@irondevice.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SMA1303: Remove the I2C Retry property in devicetree
Kiseok Jo [Wed, 8 Feb 2023 09:24:17 +0000 (09:24 +0000)]
ASoC: SMA1303: Remove the I2C Retry property in devicetree

It's necessary to set the value for each device, so remove that.

Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com>
Link: https://lore.kernel.org/r/20230208092420.5037-5-kiseok.jo@irondevice.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: renesas,rsnd.yaml: tidyup reg/reg-name
Kuninori Morimoto [Wed, 8 Feb 2023 01:31:38 +0000 (01:31 +0000)]
ASoC: dt-bindings: renesas,rsnd.yaml: tidyup reg/reg-name

Tidyup reg/reg-name "maxItems".
Pointed by Krzysztof, and corrected by Rob.

Link: https://lore.kernel.org/r/46974ae7-5f7f-8fc1-4ea8-fe77b58f5bfb@linaro.org
Link: https://lore.kernel.org/r/20230207211621.GA4158591-robh@kernel.org
Reported-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/87pmalt01x.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg spdif output to schema
Jerome Brunet [Mon, 6 Feb 2023 15:34:48 +0000 (16:34 +0100)]
ASoC: dt-bindings: meson: convert axg spdif output to schema

Convert the DT binding documentation for the Amlogic axg spdif output to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230206153449.596326-7-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg spdif input to schema
Jerome Brunet [Mon, 6 Feb 2023 15:34:47 +0000 (16:34 +0100)]
ASoC: dt-bindings: meson: convert axg spdif input to schema

Convert the DT binding documentation for the Amlogic axg spdif input to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230206153449.596326-6-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg fifo to schema
Jerome Brunet [Mon, 6 Feb 2023 15:34:46 +0000 (16:34 +0100)]
ASoC: dt-bindings: meson: convert axg fifo to schema

Convert the DT binding documentation for the Amlogic axg audio FIFOs to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230206153449.596326-5-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg pdm to schema
Jerome Brunet [Mon, 6 Feb 2023 15:34:45 +0000 (16:34 +0100)]
ASoC: dt-bindings: meson: convert axg pdm to schema

Convert the DT binding documentation for the Amlogic axg PDM device to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230206153449.596326-4-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg tdm formatters to schema
Jerome Brunet [Mon, 6 Feb 2023 15:34:44 +0000 (16:34 +0100)]
ASoC: dt-bindings: meson: convert axg tdm formatters to schema

Convert the DT binding documentation for the Amlogic tdm formatters to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230206153449.596326-3-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: convert axg tdm interface to schema
Jerome Brunet [Mon, 6 Feb 2023 15:34:43 +0000 (16:34 +0100)]
ASoC: dt-bindings: meson: convert axg tdm interface to schema

Convert the DT binding documentation for the Amlogic tdm interface to
schema.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230206153449.596326-2-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: Fix unsigned comparison with less than zero
Jiapeng Chong [Mon, 6 Feb 2023 07:55:18 +0000 (15:55 +0800)]
ASoC: codecs: Fix unsigned comparison with less than zero

The val is defined as unsigned int type, if(val<0) is redundant, so
delete it.

sound/soc/codecs/idt821034.c:449 idt821034_kctrl_gain_put() warn: unsigned 'val' is never less than zero.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3947
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Acked-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20230206075518.84169-1-jiapeng.chong@linux.alibaba.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: aw88395: initialize cur_scene_id to 0
Tom Rix [Sun, 5 Feb 2023 01:57:33 +0000 (17:57 -0800)]
ASoC: codecs: aw88395: initialize cur_scene_id to 0

cppcheck reports
sound/soc/codecs/aw88395/aw88395_lib.c:789:6: error: Uninitialized variable: cur_scene_id [uninitvar]
 if (cur_scene_id == 0) {
     ^

Passing a garbage value to aw_dev_parse_data_by_sec_type_v1() will cause a crash
when the value is used as an array index.  This check assumes cur_scene_id is
initialized to 0, so initialize it to 0.

Fixes: 4345865b003b ("ASoC: codecs: ACF bin parsing and check library file for aw88395")
Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20230205015733.1721009-1-trix@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: core/ipc4/mtl: Add support for PCM delay
Mark Brown [Fri, 3 Feb 2023 15:07:15 +0000 (15:07 +0000)]
ASoC: SOF: core/ipc4/mtl: Add support for PCM delay

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

The following series adds support for the PCM delay reporting in SOF core level
and implements the needed infrastructure with IPC4 to finally enable it for MTL.

Currently this is only supported on MTL (and via IPC4), but with the
infrastructure in place it will be possible to support other platforms with
DeepBuffer.

21 months agoASoC: (SOF) topology: Regression fixes for next
Mark Brown [Fri, 3 Feb 2023 14:43:55 +0000 (14:43 +0000)]
ASoC: (SOF) topology: Regression fixes for next

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

Today I came across two regressions in next with SOF:

The topology would not load with a failure of creating playback DAI
the first patch is fixing this which was caused by a missing 'else' in the patch

After fixing the topology loading, the module unloading caused kernel panic.
The second patch is correcting that which is I likely caused by copy-paste to
set wrong unload callback for the graph element.

With these patches applied SOF is working on next and modules can be unloaded

21 months agoASoC: amd: update ps platform acp header file
Vijendar Mukunda [Wed, 1 Feb 2023 16:56:25 +0000 (22:26 +0530)]
ASoC: amd: update ps platform acp header file

Rename Audio buffer and soundwire manager instance registers.
Remove scratch registers as these registers can be accessed
using ACP_SCRATCH_REG_0 register relative offset.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/20230201165626.3169041-1-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs: fix platform_no_drv_owner.cocci warning
Yang Li [Fri, 3 Feb 2023 01:15:04 +0000 (09:15 +0800)]
ASoC: codecs: fix platform_no_drv_owner.cocci warning

./sound/soc/codecs/aw88395/aw88395.c:572:3-8: No need to set .owner here. The core will do it.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3935
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230203011504.78918-1-yang.lee@linux.alibaba.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: meson: fix gx-card codec node regex
Jerome Brunet [Thu, 2 Feb 2023 18:36:46 +0000 (19:36 +0100)]
ASoC: dt-bindings: meson: fix gx-card codec node regex

'codec' is a valid node name when there is a single codec
in the link. Fix the node regular expression to apply this.

Fixes: fd00366b8e41 ("ASoC: meson: gx: add sound card dt-binding documentation")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230202183653.486216-3-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: create component common schema
Jerome Brunet [Thu, 2 Feb 2023 18:36:45 +0000 (19:36 +0100)]
ASoC: dt-bindings: create component common schema

All DAIs are component but not all components are DAI.
Move the component properties (sound-name-prefix ATM) to a separate schema
file so it can be used by non-DAI components, such as auxiliary devices.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230202183653.486216-2-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: fix intel-soundwire link failure
Arnd Bergmann [Thu, 2 Feb 2023 10:22:30 +0000 (11:22 +0100)]
ASoC: SOF: fix intel-soundwire link failure

My randconfig build setup ran into a rare build failure with

CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE=y
CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE=m
CONFIG_SOUNDWIRE=y
CONFIG_SOUNDWIRE_INTEL=m
CONFIG_SND_SOC_SOF_HDA=y
CONFIG_SND_SOC_SOF_INTEL_TGL=y

x86_64-linux-ld: sound/soc/sof/intel/hda.o: in function `hda_init_caps':
hda.c:(.text+0x691): undefined reference to `sdw_intel_cnl_hw_ops'
x86_64-linux-ld: hda.c:(.text+0x6f2): undefined reference to `sdw_intel_probe'
x86_64-linux-ld: sound/soc/sof/intel/hda.o: in function `hda_sdw_startup':
hda.c:(.text+0x1c40): undefined reference to `sdw_intel_startup'
x86_64-linux-ld: sound/soc/sof/intel/hda.o: in function `hda_sdw_process_wakeen':
hda.c:(.text+0x1cb6): undefined reference to `sdw_intel_process_wakeen_event'
x86_64-linux-ld: sound/soc/sof/intel/hda.o: in function `hda_dsp_interrupt_thread':
hda.c:(.text+0x1d67): undefined reference to `sdw_intel_thread'
x86_64-linux-ld: sound/soc/sof/intel/hda.o: in function `hda_dsp_remove':
hda.c:(.text+0x2655): undefined reference to `sdw_intel_exit'

My best understanding is that the definition of
SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE was intended to avoid this
problem, but got it wrong for the SND_SOC_SOF_INTEL_SOUNDWIRE=m case,
where the 'select' is meant to set SOUNDWIRE_INTEL to the value of
SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE rather than the intersection of
SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE and SND_SOC_SOF_INTEL_SOUNDWIRE.

Change the condition to check for SND_SOC_SOF_INTEL_SOUNDWIRE to be a
boolean rather than a tristate expression in order to propagate this
as intended.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230202102247.806749-1-arnd@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: mediatek: mt8188: remove etdm dead code
Trevor Wu [Thu, 2 Feb 2023 10:37:04 +0000 (18:37 +0800)]
ASoC: mediatek: mt8188: remove etdm dead code

Some Smatch static checker warning like below was found.

sound/soc/mediatek/mt8188/mt8188-dai-etdm.c:2487
mt8188_dai_etdm_parse_of()
warn: 'ret' returned from snprintf() might be larger than 48

    2479         for (i = 0; i < MT8188_AFE_IO_ETDM_NUM; i++) {
    2480                 dai_id = ETDM_TO_DAI_ID(i);
    2481                 etdm_data = afe_priv->dai_priv[dai_id];
    2482
    2483                 ret = snprintf(prop, sizeof(prop),
    2484                                "mediatek,%s-multi-pin-mode",
    2485                                of_afe_etdms[i].name);
    2486                 if (ret < 0) {
--> 2487                         dev_err(afe->dev, "%s snprintf
err=%d\n",
    2488

In linux kernel, snprintf() never returns negatives. On the other hand,
the format string like "mediatek,%s-multi-pin-mode" must be smaller
than sizeof(prop)=48.

After discussing in the mail thread[1], I remove the dead code to fix
the Smatch warnings.

[1]: https://lore.kernel.org/all/Y9EdBg641tJDDrt%2F@kili/

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20230202103704.15626-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc4-pcm: add delay function support
Rander Wang [Thu, 2 Feb 2023 13:29:54 +0000 (15:29 +0200)]
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>
21 months agoASoC: SOF: Intel: mtl: add get_stream_position support
Rander Wang [Thu, 2 Feb 2023 13:29:53 +0000 (15:29 +0200)]
ASoC: SOF: Intel: mtl: add get_stream_position support

Get HDaudio link position for current stream delay calculation
from hda registers.

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-9-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: add get_stream_position ops for pcm delay
Rander Wang [Thu, 2 Feb 2023 13:29:52 +0000 (15:29 +0200)]
ASoC: SOF: add get_stream_position ops for pcm delay

PCM delay depends on stream position based on hardware
counter to calculate stream delay so add this ops to get
stream position according to hardware counter.

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-8-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: add delay function support in sof framework
Rander Wang [Thu, 2 Feb 2023 13:29:51 +0000 (15:29 +0200)]
ASoC: SOF: add delay function support in sof framework

Sof framework will call specific delay function for
different IPC version.

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-7-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc4-pcm: add hw_params
Rander Wang [Thu, 2 Feb 2023 13:29:50 +0000 (15:29 +0200)]
ASoC: SOF: ipc4-pcm: add hw_params

Use the hw_params to init time info for ipc4 delay calculation.

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-6-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: ipc4-pcm: allocate time info for pcm delay feature
Rander Wang [Thu, 2 Feb 2023 13:29:49 +0000 (15:29 +0200)]
ASoC: SOF: ipc4-pcm: allocate time info for pcm delay feature

Allocate time info when pcm is loaded by topology
and free it when pcm is unloaded by topology.

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-5-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: add time info structure for ipc4 path
Rander Wang [Thu, 2 Feb 2023 13:29:48 +0000 (15:29 +0200)]
ASoC: SOF: add time info structure for ipc4 path

Start_stream_offset is used to strip invalid sample count in dai
for some cases like dai is started before host. llp_offset is used
to get current dai position from memory windows.

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-4-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: add fw_info_box support
Rander Wang [Thu, 2 Feb 2023 13:29:47 +0000 (15:29 +0200)]
ASoC: SOF: add fw_info_box support

FW can share some information with host driver, .e.g fw status, pipeline
status and volume status. On ipc4 platform it is located in memory
windows 0 with size of struct sof_ipc4_fw_reg.

With this patch, ipc4 driver can find fw information in fw_info_box

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-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: add ipc4_fw_reg header file
Rander Wang [Thu, 2 Feb 2023 13:29:46 +0000 (15:29 +0200)]
ASoC: SOF: add ipc4_fw_reg header file

Ipc4_fw_reg defines the content of memory window 0 shared by fw.
Host driver can get fw information by data structure defined in
this file.

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-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: mchp-spdifrx: Fix uninitialized use of mr in mchp_spdifrx_hw_params()
Nathan Chancellor [Thu, 2 Feb 2023 16:34:19 +0000 (09:34 -0700)]
ASoC: mchp-spdifrx: Fix uninitialized use of mr in mchp_spdifrx_hw_params()

Clang warns:

  ../sound/soc/atmel/mchp-spdifrx.c:455:3: error: variable 'mr' is uninitialized when used here [-Werror,-Wuninitialized]
                  mr |= SPDIFRX_MR_ENDIAN_BIG;
                  ^~
  ../sound/soc/atmel/mchp-spdifrx.c:432:8: note: initialize the variable 'mr' to silence this warning
          u32 mr;
                ^
                 = 0
  1 error generated.

Zero initialize mr so that these bitwise OR and assignment operation
works unconditionally.

Fixes: fa09fa60385a ("ASoC: mchp-spdifrx: fix controls which rely on rsr register")
Link: https://github.com/ClangBuiltLinux/linux/issues/1797
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/20230202-mchp-spdifrx-fix-uninit-mr-v1-1-629a045d7a2f@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoFix default DMIC gain on AMD PDM drivers
Mark Brown [Thu, 2 Feb 2023 15:36:47 +0000 (15:36 +0000)]
Fix default DMIC gain on AMD PDM drivers

Merge series from Mario Limonciello <mario.limonciello@amd.com>:

It's been reported that a number of laptops have a low volume
level from the digital microphone compared to Windows.

AMD offers a register that can adjust the gain for PDM which is not
configured at maximum gain by default.

To fix this change the default for all 3 drivers to raise the gain
but also offer a module parameter. The module parameter can be used
for debugging if the gain is too high on a given laptop.

This is intentionally split into multiple patches for default and
parameter so that if the default really does behave better universally
we can bring it back to stable too later.

21 months agoASoC: codecs: aw88395: Fix spelling mistake "cersion" -> "version"
Colin Ian King [Thu, 2 Feb 2023 10:32:36 +0000 (10:32 +0000)]
ASoC: codecs: aw88395: Fix spelling mistake "cersion" -> "version"

There are spelling mistakes in dev_err messages. Fix them.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20230202103236.270057-1-colin.i.king@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: ps: Add a module parameter to influence pdm_gain
Mario Limonciello [Tue, 31 Jan 2023 18:46:52 +0000 (12:46 -0600)]
ASoC: amd: ps: Add a module parameter to influence pdm_gain

In case of regressions for any users that the new pdm_gain value is
too high and for additional debugging, introduce a module parameter
that would let them configure it.

This parameter should be removed in the future:
 * If it's determined that the parameter is not needed, just hardcode
   the correct value as before
 * If users do end up using it to debug and report different values
   we should introduce a config knob that can have policy set by ucm.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230131184653.10216-7-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: ps: Adjust the gain for PDM DMIC
Mario Limonciello [Tue, 31 Jan 2023 18:46:51 +0000 (12:46 -0600)]
ASoC: amd: ps: Adjust the gain for PDM DMIC

No issues have been reported yet for DMIC audio level on ps platforms,
but as problems were found both on YC (Rembrandt) and Renoir based
designs it's very likely they happen on ps too.

Increase the PDM gain to solve this problem.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230131184653.10216-6-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: renoir: Add a module parameter to influence pdm_gain
Mario Limonciello [Tue, 31 Jan 2023 18:46:50 +0000 (12:46 -0600)]
ASoC: amd: renoir: Add a module parameter to influence pdm_gain

In case of regressions for any users that the new pdm_gain value is
too high and for additional debugging, introduce a module parameter
that would let them configure it.

This parameter should be removed in the future:
 * If it's determined that the parameter is not needed, just hardcode
   the correct value as before
 * If users do end up using it to debug and report different values
   we should introduce a config knob that can have policy set by ucm.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230131184653.10216-5-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: renoir: Adjust the gain for PDM DMIC
Mario Limonciello [Tue, 31 Jan 2023 18:46:49 +0000 (12:46 -0600)]
ASoC: amd: renoir: Adjust the gain for PDM DMIC

A similar issue that was reported on Rembrandt based laptops with
low DMIC volume is also being reported for Barcelo based laptops
that use renoir acp3x.

Increase the PDM gain to overcome this problem.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230131184653.10216-4-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: yc: Add a module parameter to influence pdm_gain
Mario Limonciello [Tue, 31 Jan 2023 18:46:48 +0000 (12:46 -0600)]
ASoC: amd: yc: Add a module parameter to influence pdm_gain

In case of regressions for any users that the new pdm_gain value is
too high and for additional debugging, introduce a module parameter
that would let them configure it.

This parameter should be removed in the future:
 * If it's determined that the parameter is not needed, just hardcode
   the correct value as before
 * If users do end up using it to debug and report different values
   we should introduce a config knob that can have policy set by ucm.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230131184653.10216-3-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: amd: yc: Adjust the gain for PDM DMIC
Mario Limonciello [Tue, 31 Jan 2023 18:46:47 +0000 (12:46 -0600)]
ASoC: amd: yc: Adjust the gain for PDM DMIC

A number of users for Lenovo Rembrandt based laptops are
reporting that the microphone is too quiet relative to
Windows with a dual boot.

Increase the PDM gain to overcome this problem.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230131184653.10216-2-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: topology: Set correct unload callback for graph type
Peter Ujfalusi [Wed, 1 Feb 2023 11:28:46 +0000 (13:28 +0200)]
ASoC: topology: Set correct unload callback for graph type

Using the control_unload for graph type of elem will lead surprises on
module unload.

The correct callback to use is the dapm_route_unload.

Fixes: 31e9273912bf ("ASoC: topology: Use unload() op directly")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230201112846.27707-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: SOF: topology: Add missed "else" in sof_connect_dai_widget
Peter Ujfalusi [Wed, 1 Feb 2023 11:28:45 +0000 (13:28 +0200)]
ASoC: SOF: topology: Add missed "else" in sof_connect_dai_widget

The conversion to use generic helpers missed the else for the dai
direction check which leads to failure when loading playback widgets

Fixes: 323f09a61d43 ("ASoC: sof: use helper function")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20230201112846.27707-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: codecs/jz4760: add digital gain controls
Christophe Branchereau [Sun, 22 Jan 2023 21:07:03 +0000 (22:07 +0100)]
ASoC: codecs/jz4760: add digital gain controls

Both the DAC and ADC have digital gain controls available
for their mixers, which go from -31 to 0db by step of 1db.

Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com>
Link: https://lore.kernel.org/r/20230122210703.2552384-1-cbranchereau@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: add R-Car Gen4 Sound support
Kuninori Morimoto [Wed, 1 Feb 2023 02:02:22 +0000 (02:02 +0000)]
ASoC: rsnd: add R-Car Gen4 Sound support

This patch is tested on V4H White Hawk + ARD-AUDIO-DA7212

Signed-off-by: Linh Phung <linh.phung.jy@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o7qe5ej5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: dt-bindings: renesas: add R8A779G0 V4H
Kuninori Morimoto [Wed, 1 Feb 2023 02:02:07 +0000 (02:02 +0000)]
ASoC: dt-bindings: renesas: add R8A779G0 V4H

Document R-Car V4H (R8A779G0), and R-Car Gen4 SoC bindings.

Link: https://lore.kernel.org/r/87zga6t5r4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87pmau5ejk.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: dma.c: tidyup rsnd_dma_probe()
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:49 +0000 (02:00 +0000)]
ASoC: rsnd: dma.c: tidyup rsnd_dma_probe()

This patch tidyups rsnd_dma_probe(), but there is no effect.

This is prepare for Gen4 support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87r0va5elq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: tidyup rsnd_dma_addr()
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:42 +0000 (02:00 +0000)]
ASoC: rsnd: tidyup rsnd_dma_addr()

This patch tidyups rsnd_dma_addr(), but there is no effect.

This is prepare for Gen4 support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sffq5elx.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: use array for 44.1kHz/48kHz rate handling
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:36 +0000 (02:00 +0000)]
ASoC: rsnd: use array for 44.1kHz/48kHz rate handling

ADG need to know output rate of 44.1kHz/48kHz.
It is using single variable for each, but this patch changes
it to array. Nothing is changed by this patch.

This is prepare for R-Car Gen4 support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tu065em3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: use clkin/out_size
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:32 +0000 (02:00 +0000)]
ASoC: rsnd: use clkin/out_size

Current adg.c is assuming number of clkin/clkout are fixed, but it is
not correct on Gen4. This patch uses clkin/out_size to handling it.

This is prepare for R-Car Gen4 support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v8km5em7.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: moves clkout_name to top of the file
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:27 +0000 (02:00 +0000)]
ASoC: rsnd: moves clkout_name to top of the file

This patch moves clkout_name to top of the file to handling both
clkin/clkout in the same place.

This is prepare for R-Car Gen4 support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87wn525emc.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: rename clk to clkin
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:22 +0000 (02:00 +0000)]
ASoC: rsnd: rename clk to clkin

Current adg.c is usig "clk" as clock IN, but is using "clkout" for
clock OUT. This patch arranges "clk" to "clkin".

This is prepare for R-Car Gen4 support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87y1pi5emh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: remove unnecessary ADG flags
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:18 +0000 (02:00 +0000)]
ASoC: rsnd: remove unnecessary ADG flags

The flag LRCLK_ASYNC / AUDIO_OUT_48 had been added to handling
special case of Salvator-X board, but it is not used on upstream.
It makes code complex today, let's remove these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87zg9y5emm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: use same debug message format on clkout
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:13 +0000 (02:00 +0000)]
ASoC: rsnd: use same debug message format on clkout

This patch follows clkin debug message style on clkout.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871qna6t77.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: indicate warning once if it can't handle requested rule
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:08 +0000 (02:00 +0000)]
ASoC: rsnd: indicate warning once if it can't handle requested rule

Some SoC can't handle all requested hw rule. In such case, it will indicate
like below, but it is unclear why it didn't work to user.
This patch indicates warning in such case once, because player will try to
similar rule many times.

# aplay sound.wav
Playing WAVE 'sound.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
aplay: aplay.c: 1359: set_params: Assertion `err >= 0' failed.
Aborted by signal Aborted...

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87357q6t7b.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: indicate necessary error when clock start failed
Kuninori Morimoto [Wed, 1 Feb 2023 02:00:03 +0000 (02:00 +0000)]
ASoC: rsnd: indicate necessary error when clock start failed

rsnd_ssi_master_clk_start() indicates error message if it couldn't
handle requested clock/rate, but it is not caring all cases.
This patch cares it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874js66t7g.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: Remove unnecessary rsnd_dbg_dai_call()
Kuninori Morimoto [Wed, 1 Feb 2023 01:59:58 +0000 (01:59 +0000)]
ASoC: rsnd: Remove unnecessary rsnd_dbg_dai_call()

commit b43b8ae87c8e0a8 ("ASoC: rsnd: protect mod->status") removed
RSND_DEBUG_NO_DAI_CALL and rsnd_dbg_dai_call(), but these are still
exist on rsnd.h. This patch removes it.

Fixes: b43b8ae87c8e ("ASoC: rsnd: protect mod->status")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875ycm6t7l.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: fixup #endif position
Kuninori Morimoto [Wed, 1 Feb 2023 01:59:52 +0000 (01:59 +0000)]
ASoC: rsnd: fixup #endif position

commit 1f9c82b5ab83ff2 ("ASoC: rsnd: add debugfs support") added
CONFIG_DEBUG_FS related definitions on rsnd.h, but it should be
added inside of RSND_H. This patch fixup it.

Fixes: 1f9c82b5ab83 ("ASoC: rsnd: add debugfs support")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877cx26t7r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: rsnd: check whether playback/capture property exists
Kuninori Morimoto [Wed, 1 Feb 2023 01:59:46 +0000 (01:59 +0000)]
ASoC: rsnd: check whether playback/capture property exists

Current rsnd sets "channels_min" which is used from
snd_soc_dai_stream_valid() without checking DT playback/capture property.
Thus, "aplay -l" or "arecord -l" will indicate un-exising device.
This patch checks DT proerty and do nothing playback/capture settings if
not exist.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878rhi6t7x.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: qcom: apq8096: set driver name correctly
Yassine Oudjana [Wed, 22 Jun 2022 06:11:06 +0000 (10:11 +0400)]
ASoC: qcom: apq8096: set driver name correctly

Set driver name to allow matching different UCM2 configurations
for the multiple devices sharing the same APQ8096 ASoC.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Link: https://lore.kernel.org/r/20220622061106.35071-1-y.oudjana@protonmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: use helper function
Kuninori Morimoto [Wed, 1 Feb 2023 01:06:15 +0000 (01:06 +0000)]
ASoC: cs42l42: use helper function

Current ASoC has many helper function.

Link: https://lore.kernel.org/r/20230201111415.67bd4b7e@canb.auug.org.au
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bkme6vp5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Add SoundWire support
Mark Brown [Tue, 31 Jan 2023 17:07:56 +0000 (17:07 +0000)]
ASoC: cs42l42: Add SoundWire support

Merge series from Stefan Binding <sbinding@opensource.cirrus.com>:

The CS42L42 has a SoundWire interface for control and audio. This
chain of patches adds support for this.

Patches #1 .. #5 split out various changes to the existing code that
are needed for adding Soundwire. These are mostly around clocking and
supporting the separate probe and enumeration stages in SoundWire.

Patches #6 .. #8 actually adds the SoundWire handling.

21 months agoASoC: use helper function and cleanup
Mark Brown [Tue, 31 Jan 2023 17:07:49 +0000 (17:07 +0000)]
ASoC: use helper function and cleanup

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

struct snd_soc_dai need to have info for playback/capture,
but it is using "playback/capture_xxx" or "tx/tx_xxx" or array.
This kind of random definition is very difficult to read.

This patch-set add helper functions and each driver use it.
And cleanup the definition.

21 months agoASoC: mchp-spdifrx: add runtime PM support and fixes
Mark Brown [Tue, 31 Jan 2023 14:12:09 +0000 (14:12 +0000)]
ASoC: mchp-spdifrx: add runtime PM support and fixes

Merge series from Claudiu Beznea <claudiu.beznea@microchip.com>:

This series adds runtime PM support for Microchip SPDIFRX driver.
Along with it I added few fixes identified while going though the code
and playing with Microchip SPDIFRX controller.

21 months agoASoC: codecs: Add Awinic AW88395 audio amplifier
Mark Brown [Tue, 31 Jan 2023 14:12:02 +0000 (14:12 +0000)]
ASoC: codecs: Add Awinic AW88395 audio amplifier

Merge series from wangweidong.a@awinic.com:

The Awinic AW88395 is an I2S/TDM input, high efficiency
digital Smart K audio amplifier with an integrated 10.25V
smart boost converter.

Add a DT schema for describing Awinic AW88395 audio amplifiers. They are
controlled using I2C

21 months agoAdd the Renesas IDT821034 codec support
Mark Brown [Tue, 31 Jan 2023 14:11:55 +0000 (14:11 +0000)]
Add the Renesas IDT821034 codec support

Merge series from Herve Codina <herve.codina@bootlin.com>:

The Renesas IDT821034 codec is four channel PCM codec with on-chip
filters and programmable gain setting.  It also provides SLIC
(Subscriber Line Interface Circuit) signals as GPIOs.

21 months agoASoC: cs42l42: Wait for debounce interval after resume
Stefan Binding [Fri, 27 Jan 2023 16:51:11 +0000 (16:51 +0000)]
ASoC: cs42l42: Wait for debounce interval after resume

Since clock stop causes bus reset on Intel controllers, we need
to wait for the debounce interval on resume, to ensure all the
interrupt status registers are set correctly.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-9-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Don't set idle_bias_on
Richard Fitzgerald [Fri, 27 Jan 2023 16:51:10 +0000 (16:51 +0000)]
ASoC: cs42l42: Don't set idle_bias_on

idle_bias_on was set because cs42l42 has a "VMID" type pseudo-midrail
supply (named FILT+), and these typically take a long time to charge.
But the driver never enabled pm_runtime so it would never have powered-
down the cs42l42 anyway.

In fact, FILT+ can charge to operating voltage within 12.5 milliseconds
of enabling HP or ADC. This time is already covered by the startup
delay of the HP/ADC.

The datasheet warning about FILT+ taking up to 1 second to charge only
applies in the special cases that either the PLL is started or
DETECT_MODE set to non-zero while both HP and ADC are off. The driver
never does either of these.

Removing idle_bias_on allows the Soundwire host controller to suspend
if there isn't a snd_soc_jack handler registered.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-8-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Add SoundWire support
Richard Fitzgerald [Fri, 27 Jan 2023 16:51:09 +0000 (16:51 +0000)]
ASoC: cs42l42: Add SoundWire support

This adds support for using CS42L42 as a SoundWire device.

SoundWire-specifics are kept separate from the I2S implementation as
much as possible, aiming to limit the risk of breaking the I2C+I2S
support.

There are some important differences in the silicon behaviour between
I2S and SoundWire mode that are reflected in the implementation:

- ASP (I2S) most not be used in SoundWire mode because the two interfaces
  share pins.

- The SoundWire capture (record) port only supports 1 channel. It does
  not have left-to-right duplication like the ASP.

- DP2 can only be prepared if the HP has powered-up. DP1 can only be
  prepared if the ADC has powered-up. (This ordering restriction does
  not exist for ASPs.) The SoundWire core port-prepare step is
  triggered by the DAI-link prepare(). This happens before the
  codec DAI prepare() or the DAPM sequence so these cannot be used
  to enable HP/ADC. Instead the HP/ADC enable/disable are done during
  the port_prep callback.

- The SRCs are an integral part of the audio chain but in silicon their
  power control is linked to the ASP. There is no equivalent power link
  to SoundWire DPs so the driver must take "manual" control of SRC power.

- The SoundWire control registers occupy the lower part of the SoundWire
  address space so cs42l42 registers are offset by 0x8000 (non-paged) in
  SoundWire mode.

- Register addresses are 8-bit paged in I2C mode but 16-bit unpaged in
  SoundWire.

- Special procedures are needed on register read/writes to (a) ensure
  that the previous internal bus transaction has completed, and
  (b) handle delayed read results, when the read value could not be
  returned within the SoundWire read command.

There are also some differences in driver implementation between I2S
and SoundWire operation:

- CS42L42 I2S does not runtime_suspend, but runtime_suspend/resume support
  has been added into the driver in SoundWire mode as the most convenient
  way to power-up the bus manager and to handle the unattach_request
  condition, though the CS42L42 chip does not itself suspend or resume.

- Intel SoundWire host controllers have a low-power clock-stop mode that
  requires resetting all peripherals when resuming. This means that the
  interrupt registers will be reset in between the interrupt being
  generated and the interrupt being handled, and since the interrupt
  status is debounced, these values may not be accurate immediately,
  and may cause spurious unplug events before settling.

- As in I2S mode, the PLL is only used while audio is active because
  of clocking quirks in the silicon. For SoundWire the cs42l42_pll_config()
  is deferred until the DAI prepare(), to allow the cs42l42_bus_config()
  callback to set the SCLK.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-7-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Export some functions for SoundWire
Richard Fitzgerald [Fri, 27 Jan 2023 16:51:08 +0000 (16:51 +0000)]
ASoC: cs42l42: Export some functions for SoundWire

Export functions that will be needed by a SoundWire module.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-6-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Separate ASP config from PLL config
Richard Fitzgerald [Fri, 27 Jan 2023 16:51:07 +0000 (16:51 +0000)]
ASoC: cs42l42: Separate ASP config from PLL config

Setup of the ASP (audio serial port) was being done as a side-effect of
cs42l42_pll_config() and forces a restriction on the ratio of sample_rate
to bit_clock that is invalid for Soundwire.

Move the ASP setup into a dedicated function.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-5-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Ensure MCLKint is a multiple of the sample rate
Richard Fitzgerald [Fri, 27 Jan 2023 16:51:06 +0000 (16:51 +0000)]
ASoC: cs42l42: Ensure MCLKint is a multiple of the sample rate

The chosen clocking configuration must give an internal MCLK (MCLKint)
that is an integer multiple of the sample rate.

On I2S each of the supported bit clock frequencies can only be generated
from one sample rate group (either the 44100 or the 48000) so the code
could use only the bitclock to look up a PLL config.

The relationship between sample rate and bitclock frequency is more
complex on Soundwire and so it is possible to set a frame shape to
generate a bitclock from the "wrong" group. For example 2*147 with a
48000 sample rate would give a bitclock of 14112000 which on I2S
could only be derived from a 44100 sample rate.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-4-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
21 months agoASoC: cs42l42: Add SOFT_RESET_REBOOT register
Richard Fitzgerald [Fri, 27 Jan 2023 16:51:05 +0000 (16:51 +0000)]
ASoC: cs42l42: Add SOFT_RESET_REBOOT register

The SOFT_RESET_REBOOT register is needed to recover CS42L42 state after
a Soundwire bus reset.

This is required to be set whenever there is severe/hard bus reset.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230127165111.3010960-3-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>