summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/cs42l43.c
AgeCommit message (Collapse)Author
2024-08-02ASoC: cs42l43: Cache shutter IRQ control pointersCharles Keepax
The microphone/speaker privacy shutter ALSA control handlers need to call pm_runtime_resume, since the hardware needs to be powered up to check the hardware state of the shutter. The IRQ handler for the shutters also needs to notify the ALSA control to inform user-space the shutters updated. However this leads to a mutex inversion, between the sdw_dev_lock and the controls_rwsem. To avoid this mutex inversion cache the kctl pointers before the IRQ handler, which avoids the need to lookup the control and take the controls_rwsem. Suggested-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20240802105734.2309788-5-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-02ASoC: cs42l43: Remove redundant semi-colon at end of functionCharles Keepax
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20240802105734.2309788-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-05-27ASoC: cs42l43: Only restrict 44.1kHz for the ASPCharles Keepax
The SoundWire interface can always support 44.1kHz using flow controlled mode, and whether the ASP is in master mode should obviously only affect the ASP. Update cs42l43_startup() to only restrict the rates for the ASP DAI. Fixes: fc918cbe874e ("ASoC: cs42l43: Add support for the cs42l43") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240527100840.439832-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-26ASoC: cs42l43: Correct extraction of data pointer in suspend/resumeCharles Keepax
The current code is pulling the wrong pointer causing it to disable the wrong IRQ. Correct the code to pull the correct cs42l43 core data pointer. Fixes: 64353af49fec ("ASoC: cs42l43: Add system suspend ops to disable IRQ") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240326105434.852907-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-21ASoC: Intel: avs: Fixes and new platforms supportMark Brown
Merge series from Cezary Rojewski <cezary.rojewski@intel.com>: The avs-driver continues to be utilized on more recent Intel machines. As TGL-based (cAVS 2.5) e.g.: RPL, inherit most of the functionality from previous platforms: SKL <- APL <- CNL <- ICL <- TGL rather than putting everything into a single file, the platform-specific bits are split into cnl/icl/tgl.c files instead. Makes the division clear and code easier to maintain. Layout of the patchset: First are two changes combined together address the sound-clipping problem, present when only one stream is running - specifically one CAPTURE stream. Follow up is naming-scheme adjustment for some of the existing functions what improves code incohesiveness. As existing IPC/IRQ code operates solely on cAVS 1.5 architecture, it needs no abstraction. The situation changes when newer platforms come into the picture. Thus the next two patches abstract the existing IPC/IRQ handlers so that majority of the common code can be re-used. The ICCMAX change stands out a bit - the AudioDSP firmware loading procedure differs on ICL-based platforms (and onwards) and having a separate commit makes the situation clear to the developers who are going to support the solution from LTS perspective. For that reason I decided not to merge it into the commit introducing the icl.c file.
2024-02-07ASoC: cs42l43: Add system suspend ops to disable IRQCharles Keepax
The IRQ should be disabled whilst entering and exiting system suspend to avoid the IRQ handler being called whilst the PM runtime is disabled. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240206113850.719888-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-07ASoC: cs42l43: Handle error from devm_pm_runtime_enableCharles Keepax
As devm_pm_runtime_enable can fail due to memory allocations, it is best to handle the error. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240206113850.719888-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-05ASoC: cs42l43: Shut down jack detection on component removeCharles Keepax
Disable the jack detection and sync in any currently running work when the component is removed. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240202140619.1068560-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-05ASoC: cs42l43: Sync the hp ilimit works when removing the componentCharles Keepax
Synchronise the headphone ilimit work functions when removing the component. These can only trigger whilst the headphone is enabled which shouldn't be possible once the component is removed but the works rely on the stashed component pointer so they should be shut down before the code moves on from component remove. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240202140619.1068560-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-05ASoC: cs42l43: Add clear of stashed pointer on component removeCharles Keepax
If the component is removed the stashed component pointer in the CODECs private struct should also be cleared to prevent use of a stale pointer. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20240202140619.1068560-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-26ASoC: cs42l43: Use fls to calculate the pre-divider for the PLLCharles Keepax
Use fls to calculate the pre-divider and input frequency for the PLL, this is marginally faster than the previous loop. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240125103117.2622095-7-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-26ASoC: cs42l43: Refactor to use for_each_set_bit()Charles Keepax
Refactor the code in cs42l43_mask_to_slots() to use for_each_set_bit(). Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240125103117.2622095-6-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-26ASoC: cs42l43: Add pm_ptr around the power opsCharles Keepax
Add missing pm_ptr around the power ops. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240125103117.2622095-4-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-26ASoC: cs42l43: Minor code tidy upsCharles Keepax
Add some missing commas, refactor a couple small bits of code. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240125103117.2622095-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-26ASoC: cs42l43: Tidy up header includesCharles Keepax
Use more forward declarations, move header guards to cover other includes, and rely less on including headers through other headers. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://msgid.link/r/20240125103117.2622095-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-12-12ASoC: cs42l43: Add missing statics for hp_ilimit functionsCharles Keepax
Fixes: bbbc18d8c27c ("ASoC: cs42l43: Allow HP amp to cool off after current limit") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20231212104149.2388753-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-12-11ASoC: cs42l43: Allow HP amp to cool off after current limitCharles Keepax
Whilst occasional current limiting is fine, constant current limiting should be avoided. Add a back off system that will disable the headphone amp, if a lot of current limiting is seen in a short window of time. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20231211160019.2034442-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-11-13ASoC: cs42l43: Add missing static from runtime PM opsCharles Keepax
Fixes: 2b59332ead54 ("ASoC: cs42l43: Use new-style PM runtime macros") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202311091824.5z6PROGZ-lkp@intel.com/ Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20231113151429.1554139-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-10-23ASoC: cs42l43: Convert to platform remove callback returning voidUwe Kleine-König
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 ignored (apart from emitting a warning) 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. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). 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> Link: https://lore.kernel.org/r/20231013221945.1489203-11-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-26ASoC: Merge up fixesMark Brown
For the benefit of CI.
2023-09-16ASoC: cs42l43: make const array controls staticColin Ian King
Don't populate the const array controls on the stack, instead make it static. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230915092639.31074-1-colin.i.king@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-15ASoC: cs42l43: Add shared IRQ flag for shuttersCharles Keepax
The microphone and speaker shutters on cs42l43 can be configured to trigger from the same GPIO, in this case the current code returns an error as we attempt to request two IRQ handlers for the same IRQ. Fix this by always requesting the shutter IRQs with the IRQF_SHARED flag. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230915144300.120100-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-29ASoC: cs42l43: Fix missing error code in cs42l43_codec_probe()Harshit Mogalapalli
When clk_get_optional() fails, the error handling code does a 'goto err_pm' with ret = 0, which is resturning success on a failure path. Fix this by assigning the PTR_ERR(priv-mclk) to ret variable. Fixes: fc918cbe874e ("ASoC: cs42l43: Add support for the cs42l43") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com Link: https://lore.kernel.org/r/20230829073635.1877367-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-08-24ASoC: cs42l43: Use new-style PM runtime macrosCharles Keepax
Update to the newer style PM runtime macros, no functional change. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com Link: https://lore.kernel.org/r/20230824103902.1606288-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-08-23ASoC: cs42l43: Initialize ret in default case in cs42l43_pll_ev()Nathan Chancellor
clang warns (or errors with CONFIG_WERROR=y): sound/soc/codecs/cs42l43.c:1371:2: error: variable 'ret' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] 1371 | default: | ^~~~~~~ sound/soc/codecs/cs42l43.c:1377:9: note: uninitialized use occurs here 1377 | return ret; | ^~~ sound/soc/codecs/cs42l43.c:1349:9: note: initialize the variable 'ret' to silence this warning 1349 | int ret; | ^ | = 0 1 error generated. Initialize ret to 0 in the default case, as there was nothing to do for other event types. Closes: https://github.com/ClangBuiltLinux/linux/issues/1922 Fixes: fc918cbe874e ("ASoC: cs42l43: Add support for the cs42l43") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20230823-cs42l43_pll_ev-init-ret-v1-1-5836f1ad5dad@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-18ASoC: cs42l43: Add support for the cs42l43Charles Keepax
The CS42L43 is an audio CODEC with integrated MIPI SoundWire interface (Version 1.2.1 compliant), I2C, SPI, and I2S/TDM interfaces designed for portable applications. It provides a high dynamic range, stereo DAC for headphone output, two integrated Class D amplifiers for loudspeakers, and two ADCs for wired headset microphone input or stereo line input. PDM inputs are provided for digital microphones. The ASoC component provides the majority of the functionality of the device, all the audio functions. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230804104602.395892-7-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>