summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wsa883x.c
Commit message (Collapse)AuthorAgeFilesLines
* ASoC: Merge fixesMark Brown2024-08-081-1/+1
|\ | | | | | | So we can apply AMD patches that rely on them.
| * ASoC: codecs: wsa883x: Correct Soundwire ports maskKrzysztof Kozlowski2024-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Device has up to WSA883X_MAX_SWR_PORTS number of ports and the array assigned to prop.sink_dpn_prop has 0..WSA883X_MAX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between <high, low>, so we need the mask from 0 up to WSA883X_MAX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20240726-asoc-wcd-wsa-swr-ports-genmask-v1-5-d4d7a8b56f05@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: codecs: wsa88xx and wcd93xx: Soundwire portMark Brown2024-07-291-20/+22
|\ \ | | | | | | | | | | | | | | | | | | Merge series from Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>: Few cleanups to make the code more robust or readable. No functional impact (compiled objects stay the same).
| * | ASoC: codecs: wsa883x: Use designator array initializers for Soundwire portsKrzysztof Kozlowski2024-07-291-20/+22
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two arrays (with 'struct sdw_dpn_prop' and 'struct sdw_port_config') store configuration of Soundwire ports, thus each of their element is indexed according to the port number (enum wsa_port_ids, e.g. WSA883X_PORT_DAC). Except the indexing, they also store port number offset by one in member 'num'. Entire code depends on that correlation between array index and port number, thus make it explicit by using designators. The code is functionally the same, but more obvious for reading. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://patch.msgid.link/20240725-asoc-wsa88xx-port-arrays-v1-2-80a03f440c72@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: codecs: wsa883x: Simplify handling variant/versionKrzysztof Kozlowski2024-07-291-10/+7
| | | | | | | | | | | | | | | | | | Driver does not use detected variant/version variables past the init function, so do not store them in the state container structure. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20240710-asoc-wsa88xx-version-v1-3-f1c54966ccde@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: codecs: wsa883x: Handle reading version failureKrzysztof Kozlowski2024-07-291-5/+11
|/ | | | | | | | | | | | If reading version and variant from registers fails (which is unlikely but possible, because it is a read over bus), the driver will proceed and perform device configuration based on uninitialized stack variables. Handle it a bit better - bail out without doing any init and failing the update status Soundwire callback. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20240710-asoc-wsa88xx-version-v1-2-f1c54966ccde@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wsa883x: Constify struct regmap_configJavier Carrasco2024-07-031-1/+1
| | | | | | | | | `wsa883x_regmap_config` is not modified and can be declared as const to move its data to a read-only section. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20240703-sound-const-regmap_config-v1-8-2e379b0446a7@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: parse port-mapping informationSrinivas Kandagatla2024-07-011-0/+8
| | | | | | | | | | | | Add support to parse static master port map information from device tree. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://patch.msgid.link/20240626-port-map-v2-2-6cc1c5608cdd@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: Remove unused of_gpio.hAndy Shevchenko2024-06-101-1/+0
| | | | | | | | | | | | of_gpio.h is deprecated and subject to remove. The drivers in question don't use it, simply remove the unused header. Reviewed-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240605221446.2624964-2-andriy.shevchenko@linux.intel.com Acked-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: fix PA volume controlJohan Hovold2024-01-221-1/+5
| | | | | | | | | | | | | | | | | | | | | | The PA gain can be set in steps of 1.5 dB from -3 dB to 18 dB, that is, in 15 levels. Fix the dB values for the PA volume control as experiments using wsa8835 show that the first 16 levels all map to the same lowest gain while the last three map to the highest gain. These values specifically need to be correct for the sound server to provide proper volume control. Note that level 0 (-3 dB) does not mute the PA so the mute flag should also not be set. Fixes: cdb09e623143 ("ASoC: codecs: wsa883x: add control, dapm widgets and map") Cc: stable@vger.kernel.org # 6.0 Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Link: https://msgid.link/r/20240119112420.7446-2-johan+linaro@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: make use of new mute_unmute_on_trigger flagSrinivas Kandagatla2023-10-271-6/+1
| | | | | | | | | | | | | | | | | | | In the current setup the PA is left unmuted even when the Soundwire ports are not started streaming. This can lead to click and pop sounds during start. There is a same issue in the reverse order where in the PA is left unmute even after the data stream is stopped, the time between data stream stopping and port closing is long enough to accumulate DC on the line resulting in Click/Pop noise during end of stream. making use of new mute_unmute_on_trigger flag is helping a lot with this Click/Pop issues reported on this Codec Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Tested-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20231027105747.32450-3-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wsa883x: Update to use maple tree register cacheMark Brown2023-07-171-1/+1
| | | | | | | | | | | | | | | The maple tree register cache is based on a much more modern data structure than the rbtree cache and makes optimisation choices which are probably more appropriate for modern systems than those made by the rbtree cache. In v6.5 it has also acquired the ability to generate multi-register writes in sync operations, bringing performance up to parity with the rbtree cache there. Update the wsa883x driver to use the more modern data structure. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230712-asoc-qcom-maple-v1-4-15f8089664b9@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: Merge fixes due to dependenciesMark Brown2023-06-161-1/+0
|\ | | | | | | So we can apply the tlv320aic3xxx DT conversion.
| * ASoC: codecs: wsa883x: do not set can_multi_write flagSrinivas Kandagatla2023-05-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | regmap-sdw does not support multi register writes, so there is no point in setting this flag. This also leads to incorrect programming of WSA codecs with regmap_multi_reg_write() call. This invalid configuration should have been rejected by regmap-sdw. Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20230523154605.4284-1-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: codecs: wsa883x: use existing define instead of raw valueKrzysztof Kozlowski2023-06-071-1/+2
|/ | | | | | | | | Use existing define for WSA883X_GLOBAL_PA_ENABLE instead of hard-coded value, just like in other places in this driver. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230607171326.179527-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* Merge tag 'asoc-v6.3' of ↵Takashi Iwai2023-02-161-13/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next ASoC: Updates for v6.3 There's been quite a lot of activity this release, but not really one big feature - lots of new devices, plus a lot of cleanup and modernisation work spread throughout the subsystem: - More factoring out of common operations into helper functions by Morimoto-san. - DT schema conversons and stylistic nits. - Continued work on building out the new SOF IPC4 scheme. - Support for Awinc AT88395, Infineon PEB2466, Iron Device SMA1303, Mediatek MT8188, Realtek RT712, Renesas IDT821034, Samsung/Tesla FSD SoC I2S, and TI TAS5720A-Q1.
| * ASoC: codecs: wsa88xx: remove unneeded includesKrzysztof Kozlowski2023-01-251-4/+0
| | | | | | | | | | | | | | | | | | Remove unneeded includes from wsa881x and wsa883x drivers. The drivers do not reference anything from the headers. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230124163953.345949-3-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
| * ASoC: codecs: constify static sdw_port_config structKrzysztof Kozlowski2023-01-251-1/+1
| | | | | | | | | | | | | | | | | | The struct sdw_port_config is not modified, so make it a const for code safety. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230124163953.345949-2-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
| * ASoC: codecs: constify static sdw_slave_ops structKrzysztof Kozlowski2023-01-251-1/+1
| | | | | | | | | | | | | | | | | | The struct sdw_slave_ops is not modified and sdw_driver takes pointer to const, so make it a const for code safety. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230124163953.345949-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
| * ASoC: codecs: wsa883x: Simplify &pdev->dev in probeKrzysztof Kozlowski2023-01-161-7/+7
| | | | | | | | | | | | | | | | | | The probe already stores pointer to &pdev->dev, so use it to make the code a bit easier to read. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230102114152.297305-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: codecs: wsa883x: correct playback min/max ratesKrzysztof Kozlowski2023-01-251-2/+2
|/ | | | | | | | | | | Correct reversed values used in min/max rates, leading to incorrect playback constraints. Cc: <stable@vger.kernel.org> Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230124123049.285395-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: Simplify with dev_err_probeKrzysztof Kozlowski2022-11-161-12/+9
| | | | | | | | Code can be a bit simpler with dev_err_probe(). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20221109163759.1158837-2-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: Shutdown on error pathKrzysztof Kozlowski2022-11-161-0/+1
| | | | | | | | | If probe fails, toggle shutdown via GPIO to save power and reverse probe actions. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20221109163759.1158837-1-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: use correct header fileRandy Dunlap2022-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix build errors when GPIOLIB is not set/enabled: ../sound/soc/codecs/wsa883x.c: In function 'wsa883x_probe': ../sound/soc/codecs/wsa883x.c:1394:25: error: implicit declaration of function 'devm_gpiod_get_optional'; did you mean 'devm_regulator_get_optional'? [-Werror=implicit-function-declaration] wsa883x->sd_n = devm_gpiod_get_optional(&pdev->dev, "powerdown", ../sound/soc/codecs/wsa883x.c:1395:49: error: 'GPIOD_FLAGS_BIT_NONEXCLUSIVE' undeclared (first use in this function) GPIOD_FLAGS_BIT_NONEXCLUSIVE); ../sound/soc/codecs/wsa883x.c:1414:9: error: implicit declaration of function 'gpiod_direction_output'; did you mean 'gpio_direction_output'? [-Werror=implicit-function-declaration] gpiod_direction_output(wsa883x->sd_n, 1); Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: kernel test robot <lkp@intel.com> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Banajit Goswami <bgoswami@quicinc.com> Cc: Mark Brown <broonie@kernel.org> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: alsa-devel@alsa-project.org Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20221108001829.5100-1-rdunlap@infradead.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: Use proper shutdown GPIO polarityKrzysztof Kozlowski2022-11-111-2/+2
| | | | | | | | | | | | | | The shutdown GPIO is active low (SD_N), but this depends on actual board layout. Linux drivers should only care about logical state, where high (1) means shutdown and low (0) means do not shutdown. Invert the GPIO to match logical value. Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20221110133512.478831-2-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: add clock stop supportSrinivas Kandagatla2022-09-231-27/+1
| | | | | | | | | | WSA883x does support clock stop, so remove code that reset the Codec during runtime pm suspend and add flag to mark clock stop support. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220906170112.1984-7-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: fix warning using-module-alias-sdw.cocciGaosheng Cui2022-07-051-0/+2
| | | | | | | | | | | This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> Link: https://lore.kernel.org/r/20220705005315.663920-1-cuigaosheng1@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: add missing break statementSrinivas Kandagatla2022-07-011-0/+1
| | | | | | | | | | Add missing break in one of the switch statement. Reported-by: kernel test robot <lkp@intel.com> Fixes: cdb09e623143 ("ASoC: codecs: wsa883x: add control, dapm widgets and map") Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220701125515.32332-1-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: handle timeouts in resume pathSrinivas Kandagatla2022-06-301-2/+9
| | | | | | | | | | | | | | Currently we do not check if SoundWire slave initialization timeout expired before continuing to access its registers. Its possible that the registers are not accessible if timeout is expired. Handle this by returning timeout in resume path. Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220630130023.9308-2-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: wsa883x: add control, dapm widgets and mapSrinivas Kandagatla2022-06-301-0/+200
| | | | | | | | Add controls, dapm widgets along with route. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220630123633.8047-1-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: codecs: add wsa883x amplifier supportSrinivas Kandagatla2022-06-291-0/+1301
This patch adds support to WSA8830/WSA8812/WSA8835 Class-D Smart Speaker Amplifier. This Amplifier is primarily interfaced with SoundWire. This patch is tested on SM8450 MTP Board. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220629090644.67982-3-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>