History log of /linux-master/sound/soc/codecs/lpass-wsa-macro.c
Revision Date Author Comments
# 46188db0 18-Jan-2024 Johan Hovold <johan+linaro@kernel.org>

ASoC: codecs: lpass-wsa-macro: fix compander volume hack

The LPASS WSA macro codec driver is updating the digital gain settings
behind the back of user space on DAPM events if companding has been
enabled.

As compander control is exported to user space, this can result in the
digital gain setting being incremented (or decremented) every time the
sound server is started and the codec suspended depending on what the
UCM configuration looks like.

Soon enough playback will become distorted (or too quiet).

This is specifically a problem on the Lenovo ThinkPad X13s as this
bypasses the limit for the digital gain setting that has been set by the
machine driver.

Fix this by simply dropping the compander gain offset hack. If someone
cares about modelling the impact of the compander setting this can
possibly be done by exporting it as a volume control later.

Note that the volume registers still need to be written after enabling
clocks in order for any prior updates to take effect.

Fixes: 2c4066e5d428 ("ASoC: codecs: lpass-wsa-macro: add dapm widgets and route")
Cc: stable@vger.kernel.org # 5.11
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://msgid.link/r/20240119112420.7446-4-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 72151ad0 03-Oct-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

ASoC: codecs: wsa-macro: fix uninitialized stack variables with name prefix

Driver compares widget name in wsa_macro_spk_boost_event() widget event
callback, however it does not handle component's name prefix. This
leads to using uninitialized stack variables as registers and register
values. Handle gracefully such case.

Fixes: 2c4066e5d428 ("ASoC: codecs: lpass-wsa-macro: add dapm widgets and route")
Cc: stable@vger.kernel.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20231003155422.801160-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# c29e5263 03-Oct-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

ASoC: codecs: wsa-macro: handle component name prefix

When comparing widget names in wsa_macro_spk_boost_event(), consider
also the component's name prefix. Otherwise the WSA codec won't have
proper mixer setup resulting in no sound playback through speakers.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20231003155710.821315-3-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# f54e3474 21-Jul-2023 Bjorn Andersson <quic_bjorande@quicinc.com>

ASoC: codecs: lpass: Log clk_get() failures

The LPASS macro drivers all acquire a number of clocks, but give no
indication when clk_get() fails, making it hard to identify and debug
system configuration issues. Make these drivers provide useful debug
information when this happens.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20230721165027.2155528-1-quic_bjorande@quicinc.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 63e280a5 27-Mar-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

ASoC: codecs: lpass-wsa-macro: add support for SM8550

Add support for the WSA macro codec on Qualcomm SM8550. SM8550 does not
use NPL clock, thus add flags allowing to skip it.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230327132254.147975-11-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6b004b836 13-Mar-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

ASoC: codecs: lpass-wsa-macro: add support for SM8550

Add support for the WSA macro codec on Qualcomm SM8550. SM8550 does not
use NPL clock, thus add flags allowing to skip it.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230313075445.17160-9-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 23a3ef65 15-Mar-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

ASoC: codecs: lpass-wsa-macro: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20230315150745.67084-53-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# a4a32034 23-Mar-2023 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: lpass: fix the order or clks turn off during suspend

The order in which clocks are stopped matters as some of the clock
like NPL are derived from MCLK.

Without this patch, Dragonboard RB5 DSP would crash with below error:
qcom_q6v5_pas 17300000.remoteproc: fatal error received:
ABT_dal.c:278:ABTimeout: AHB Bus hang is detected,
Number of bus hang detected := 2 , addr0 = 0x3370000 , addr1 = 0x0!!!

Turn off fsgen first, followed by npl and then finally mclk, which is exactly
the opposite order of enable sequence.

Fixes: 1dc3459009c3 ("ASoC: codecs: lpass: register mclk after runtime pm")
Reported-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Amit Pundir <amit.pundir@linaro.org>
Link: https://lore.kernel.org/r/20230323110125.23790-1-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 777af241 08-Feb-2023 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

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>


# ddffe3b8 08-Feb-2023 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

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>


# 1dc34590 08-Feb-2023 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

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>


# 9f63869a 03-Nov-2022 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

ASoC: codecs: lpass-wsa-macro: parse clock-output-names

If we have several instances of WSA macro, each one of them should
register clock with unique name, so parse clock-output-names for this.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20221103195341.174972-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8d2be441e 06-Sep-2022 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: wsa-macro: add support for sm8450 and sc8280xp

Add compatible for sm8450 and sc8280xp.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220906170112.1984-9-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# fdc972d4 06-Sep-2022 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: wsa-macro: handle swr_reset correctly

Reset soundwire block on frame sync generation clock reset.
Without this we are hitting read/write timeouts randomly during
runtime pm.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220906170112.1984-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# c96baa29 24-Feb-2022 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: wsa-macro: add runtime pm support

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220224111718.6264-12-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 05a41340 24-Feb-2022 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: wsa-macro: setup soundwire clks correctly

For SoundWire Frame sync to be generated correctly we need both MCLK
and MCLKx2 (npl). Without pm runtime enabled these two clocks will remain on,
however after adding pm runtime support its possible that NPl clock could be
turned off even when SoundWire controller is active.

Fix this by enabling mclk and npl clk when SoundWire clks are enabled.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220224111718.6264-8-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# e252801d 24-Feb-2022 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: wsa-macro: move to individual clks from bulk

Using bulk clocks and referencing them individually using array index is
not great for readers.
So move them to individual clocks handling and also remove some unnecessary
error handling in the code.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220224111718.6264-7-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# aa505ecc 21-Jan-2022 Jiasheng Jiang <jiasheng@iscas.ac.cn>

ASoC: codecs: Check for error pointer after calling devm_regmap_init_mmio

Since the potential failure of the devm_regmap_init_mmio(), it will
return error pointer and be assigned to the regmap.
Then the error pointer will be dereferenced.
For example rx->regmap will be used in rx_macro_mclk_enable().
Therefore, it should be better to check it.

Fixes: af3d54b99764 ("ASoC: codecs: lpass-rx-macro: add support for lpass rx macro")
Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Fixes: 809bcbcecebf ("ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220121171031.2826198-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9d8c6981 26-Oct-2021 Srinivasa Rao Mandadapu <srivasam@codeaurora.org>

ASoC: qcom: Add compatible names in va,wsa,rx,tx codec drivers for sc7280

Add compatible names for sc7280 based targets in digital codec drivers
va,wsa,rx and tx.

Signed-off-by: Srinivasa Rao Mandadapu <srivasam@codeaurora.org>
Co-developed-by: Venkata Prasad Potturu <potturu@codeaurora.org>
Signed-off-by: Venkata Prasad Potturu <potturu@codeaurora.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/1635234188-7746-2-git-send-email-srivasam@codeaurora.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 58f01c7f 30-Apr-2021 Tom Rix <trix@redhat.com>

ASoC: codecs: lpass-wsa-macro: handle unexpected input

Static analysis reports this problem

lpass-wsa-macro.c:1732:6: warning: Array subscript is undefined
if (wsa->ec_hq[ec_tx]) {
^~~~~~~~~~~~~~~~~

The happens because 'ec_tx' is never initialized and there is
no default in switch statement that sets ec_tx. Add a default
case that returns an error before the array is accessed.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210430142117.3272772-1-trix@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 27dc72b4 21-Apr-2021 Jerome Brunet <jbrunet@baylibre.com>

ASoC: lpass: use the clock provider API

Clock providers should be registered using the clk_hw API.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20210421120512.413057-5-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a893a666 08-Apr-2021 Ye Bin <yebin10@huawei.com>

ASoC: codecs: lpass-wsa-macro: constify static struct snd_soc_dai_ops

The snd_soc_dai_ops structures is only stored in the ops field of a
snd_soc_dai_driver structure, so make the snd_soc_dai_ops structure
const to allow the compiler to put it in read-only memory.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ye Bin <yebin10@huawei.com>
Link: https://lore.kernel.org/r/20210408062642.802846-1-yebin10@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4b4f2119 18-Feb-2021 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: lpass-wsa-macro: add missing test

cppcheck warning:

sound/soc/codecs/lpass-wsa-macro.c:958:6: style: Variable 'ret' is
reassigned a value before the old one has been
used. [redundantAssignment]
ret = wsa_macro_set_prim_interpolator_rate(dai, (u8) rate_val, sample_rate);
^
sound/soc/codecs/lpass-wsa-macro.c:946:6: note: ret is assigned
ret = wsa_macro_set_mix_interpolator_rate(dai, (u8) rate_val, sample_rate);
^
sound/soc/codecs/lpass-wsa-macro.c:958:6: note: ret is overwritten
ret = wsa_macro_set_prim_interpolator_rate(dai, (u8) rate_val, sample_rate);
^

set_mix_interpolator_rate can return -EINVAL, add a test and bail on error.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210218222916.89809-11-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# e4b8b7c9 04-Mar-2021 Jonathan Marek <jonathan@marek.ca>

ASoC: codecs: lpass-wsa-macro: fix RX MIX input controls

Attempting to use the RX MIX path at 48kHz plays at 96kHz, because these
controls are incorrectly toggling the first bit of the register, which
is part of the FS_RATE field.

Fix the problem by using the same method used by the "WSA RX_MIX EC0_MUX"
control, which is to use SND_SOC_NOPM as the register and use an enum in
the shift field instead.

Fixes: 2c4066e5d428 ("ASoC: codecs: lpass-wsa-macro: add dapm widgets and route")
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210305005049.24726-1-jonathan@marek.ca
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7db4c4cd 26-Jan-2021 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: lpass-wsa-macro: make use of snd_soc_component_read_field()

Make use of snd_soc_component_read_field() to make the code more readable!

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210126171749.1863-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2c4066e5 05-Nov-2020 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: lpass-wsa-macro: add dapm widgets and route

This patch adds dapm widgets and routes on this codec

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20201105113458.12360-4-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 809bcbce 05-Nov-2020 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro

Qualcomm LPASS (Low Power Audio SubSystem) has internal codec
WSA macro block which is used for connecting with WSA Smart
speakers over soundwire.

This patch adds support to the codec part of the WSA Macro block.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20201105113458.12360-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>