summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt5682s.c
AgeCommit message (Collapse)AuthorFilesLines
2022-04-06ASoC: rt*: use simple i2c probe functionStephen Kitt1-3/+2
The i2c probe functions here don't use the id information provided in their second argument, so the single-parameter i2c probe function ("probe_new") can be used instead. This avoids scanning the identifier tables during probes. Signed-off-by: Stephen Kitt <steve@sk2.org> Link: https://lore.kernel.org/r/20220405130326.2107293-1-steve@sk2.org Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-05ASoC: Pull in fixesMark Brown1-7/+4
cs35l41 is getting some active work and conflicts, plus some of the fixes are needed for my testing. Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-05ASoC: rt5682s: Separate the regulator consumer controlsDerek Fang1-5/+22
Control the regulators separately instead of using regulator_bulk to accord to the timing request in the datasheet. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20220328053338.21441-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-04codecs: rt5682s: fix an incorrect NULL check on list iteratorXiaomeng Tong1-7/+4
The bug is here: if (!dai) { The list iterator value 'dai' will *always* be set and non-NULL by for_each_component_dais(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found (In fact, it will be a bogus pointer to an invalid struct object containing the HEAD). Otherwise it will bypass the check 'if (!dai) {' (never call dev_err() and never return -ENODEV;) and lead to invalid memory access lately when calling 'rt5682s_set_bclk1_ratio(dai, factor);'. To fix the bug, just return rt5682s_set_bclk1_ratio(dai, factor); when found the 'dai', otherwise dev_err() and return -ENODEV; Cc: stable@vger.kernel.org Fixes: bdd229ab26be9 ("ASoC: rt5682s: Add driver for ALC5682I-VS codec") Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com> Link: https://lore.kernel.org/r/20220327081300.12962-1-xiam0nd.tong@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-03-21Merge tag 'asoc-v5.18' of ↵Takashi Iwai1-21/+26
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus ASoC: Updates for v5.18 Quite a quiet release for ASoC, lots of work on drivers and platforms but nothing too groundbreaking but not much on the core itself: - Start of moving SoF to support multiple IPC mechanisms. - Use of NHLT ACPI table to reduce the amount of quirking required for Intel systems. - Some building blocks for use in forthcoming Intel AVS driver for legacy Intel DSP firmwares. - Support for AMD PDM, Atmel PDMC, Awinic AW8738, i.MX cards with TLV320AIC31xx, Intel machines with CS35L41 and ESSX8336, Mediatek MT8181 wideband bluetooth, nVidia Tegra234, Qualcomm SC7280, Renesas RZ/V2L, Texas Instruments TAS585M
2022-03-07ASoC: rt5682s: Stabilize the combo jack detectionDerek Fang1-21/+26
Changes: 1. Revise rt5682s_sar_power_mode and rt5682s_headset_detect to be more rational. 2. Manually set to the jack-unplugging state via rt5682s_headset_detect during going to suspend. Close unnecessary powers and prepare for re-detecting the CBJ during resuming. 3. Simplize rt5682s_resume. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20220307102154.26065-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-24ASoC: rt5682s: Fix the wrong jack type detectedDerek Fang1-17/+9
Some powers were changed during the jack insert detection and clk's enable/disable in CCF. If in parallel, the influence has a chance to detect the wrong jack type. We refer to the below commit of the variant codec (rt5682) to fix this issue. ASoC: rt5682: Fix deadlock on resume 1. Remove rt5682s_headset_detect in rt5682s_jd_check_handler and use jack_detect_work instead of. 2. Use dapm mutex used in CCF to protect most of jack_detect_work. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20220223101450.4577-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-08ASoC: rt5682s: do not block workqueue if card is unboundKai Vehmanen1-5/+7
The current rt5682s_jack_detect_handler() assumes the component and card will always show up and implements an infinite usleep loop waiting for them to show up. This does not hold true if a codec interrupt (or other event) occurs when the card is unbound. The codec driver's remove or shutdown functions cannot cancel the workqueue due to the wait loop. As a result, code can either end up blocking the workqueue, or hit a kernel oops when the card is freed. Fix the issue by rescheduling the jack detect handler in case the card is not ready. In case card never shows up, the shutdown/remove/suspend calls can now cancel the detect task. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-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: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Shuming Fan <shumingf@realtek.com> Link: https://lore.kernel.org/r/20220207153000.3452802-1-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-12-08ASoC: rt5682s: add delay time to fix pop sound issueShuming Fan1-3/+31
There is a pop noise at the beginning of the capture data. This patch adds the delay time before stereo1 ADC unmute to fix the pop sound issue. Signed-off-by: Shuming Fan <shumingf@realtek.com> Link: https://lore.kernel.org/r/20211208101718.28945-1-shumingf@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-11-26ASoC: rt5682s: Fix crash due to out of scope stack varsRob Clark1-4/+6
Move the declaration of temporary arrays to somewhere that won't go out of scope before the devm_clk_hw_register() call, lest we be at the whim of the compiler for whether those stack variables get overwritten. Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1) Fixes: bdd229ab26be ("ASoC: rt5682s: Add driver for ALC5682I-VS codec") Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20211118010453.843286-2-robdclark@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-27ASoC: rt5682s: use 'static' qualifierPierre-Louis Bossart1-3/+3
Sparse reports the following warnings: sound/soc/codecs/rt5682s.c:44:12: error: symbol 'rt5682s_supply_names' was not declared. Should it be static? sound/soc/codecs/rt5682s.c:74:26: error: symbol 'rt5682s_reg' was not declared. Should it be static? sound/soc/codecs/rt5682s.c:2841:30: error: symbol 'rt5682s_aif1_dai_ops' was not declared. Should it be static? Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20211025185933.144327-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-23ASoC: rt5682s: Downsizing the DAC volume scaleDerek Fang1-2/+2
Use 0.75db/step of DAC volume instead of 1.5 to get a more smooth volume curve. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20211021120303.4601-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-07ASoC: rt5682s: Fix hp pop produced immediately after resumingDerek Fang1-7/+20
When the system plays a sound immediately after resuming from S3, it could hear a little pop from headphones. It is due to the HP was unmuted before the completion of jack re-detection finished in parallel. This patch adds a lock to make sure the HP unmute after jack detect handler, and adds a few depop changes. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20211007085519.12543-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-01ASoC: rt5682s: Fix HP noise caused by SAR mode switch when the system resumesDerek Fang1-16/+10
When the system resumes from S3, if the system plays a beep, there is continuous "Zizi.." noise from HP that could be heard. It is caused by the SAR mode switch during the combo jack re-detection which be executed parallelly in a workqueue after the system resumes. This patch changes the behavior of SAR mode switch to avoid this issue. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20211001074113.2223-2-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-01ASoC: rt5682s: Enable ASRC auto-disable to fix pop during jack plug-in while ↵Derek Fang1-0/+3
playback When codec's ASRC was enabled, the DA and AD filters use the reference clk which tracks the I2S clks. And if the I2S clks' timing of open and close are not expected, this patch allows the filters to switch to use sysclk if ASRC's ref clks disappeared and could fix the below possible issues: 1. Avoid DA filter to keep surplus samples. 2. Avoid that AD filter works failed during dapm's power on. For example, if I2S clks were closed before dacdat during playback off due to jack unplug, it causes ref clks disappeared and DA filter remained some samples which will produce pop noise on the next HP playback. ASRC auto-disable could clear the samples during the playback off. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20211001074113.2223-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-09-30ASoC: rt5682s: Use dev_dbg instead of pr_debugDerek Fang1-1/+1
It could observe the debug messages more clearly by using dev_dbg. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20210930102928.28628-2-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-09-30ASoC: rt5682s: Remove the volatile SW reset register from reg_defaultDerek Fang1-1/+0
This reg is for SW reset. It shouldn't have default value, so remove. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://lore.kernel.org/r/20210930102928.28628-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-09-20ASoC: rt5682s: make rt5682s_aif2_dai_ops and rt5682s_soc_component_devJiapeng Chong1-2/+2
This symbol is not used outside of rt5682s.c, so marks it static. Fix the following sparse warning: sound/soc/codecs/rt5682s.c:2848:39: warning: symbol 'rt5682s_soc_component_dev' was not declared. Should it be static? sound/soc/codecs/rt5682s.c:2842:30: warning: symbol 'rt5682s_aif2_dai_ops' was not declared. Should it be static? Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Link: https://lore.kernel.org/r/1631955726-77693-1-git-send-email-jiapeng.chong@linux.alibaba.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-09-13ASoC: rt5682s: Add driver for ALC5682I-VS codecDerek Fang1-0/+3188
This is an initial codec driver for Realtek ALC5682I-VS codec. Signed-off-by: Derek Fang <derek.fang@realtek.com> Signed-off-by: Derek Fang <derek.fang@realtek.com<mailto:derek.fang@realtek.com>> Link: https://lore.kernel.org/r/20210831130258.19286-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>