aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt5682-sdw.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-06-21ASoC: rt5682-sdw: fix race condition on system suspendPierre-Louis Bossart1-2/+36
In the initial driver we cancelled deferred work, but there is still a window of time where a new interrupt could result in new deferred work executed after the link is disabled, leading to an IO error. While we did not see this IO error on RT5682-based platforms, the code pattern is similar to the RT700 case where the IO error was noted, so the fix is added for consistency. This patch uses an 'disable_irq_lock' mutex to prevent new interrupts from happening after the start of the system suspend. The choice of a mutex v. a spinlock is mainly due to the time required to clear interrupts, which requires a command to be transmitted by the SoundWire host IP and acknowledged with an interrupt. The 'interrupt_callback' routine is also not meant to be called from an interrupt context. An additional 'disable_irq' flag prevents race conditions where the status changes before the interrupts are disabled, but the workqueue handling status changes is scheduled after the completion of the system suspend. On resume the interrupts are re-enabled already by the io_init routine so we only clear the flag. The Fixes tag points to a 5.10 commit, there's no need to propagate this change to earlier upstream versions. BugLink: https://github.com/thesofproject/linux/issues/2943 Fixes: 4a55000722d7 ('ASoC: codecs: rt*.c: remove useless pointer cast') Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Bard Liao <bard.liao@intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210614180815.153711-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-08ASoC: rt5682-sdw: set regcache_cache_only false before reading RT5682_DEVICE_IDBard Liao1-5/+5
RT5682_DEVICE_ID is a volatile register, we can not read it in cache only mode. Fixes: 03f6fc6de919 ("ASoC: rt5682: Add the soundwire support") Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20210607222239.582139-14-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-08ASoC: rt5682: Fix a problem with error handling in the io init function of the soundwireOder Chiou1-2/+5
The device checking error should be a jump to pm_runtime_put_autosuspend() as done before returning value. Fixes: 867f8d18df4f ('ASoC: rt5682: fix getting the wrong device id when the suspend_stress_test') Reviewed-by: Bard Liao <bard.liao@intel.com> Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20210607222239.582139-13-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-08ASoC: rt5682-sdw: use first_hw_init flag on resumePierre-Louis Bossart1-1/+1
The intent of the status check on resume was to verify if a SoundWire peripheral reported ATTACHED before waiting for the initialization to complete. This is required to avoid timeouts that will happen with 'ghost' devices that are exposed in the platform firmware but are not populated in hardware. Unfortunately we used 'hw_init' instead of 'first_hw_init'. Due to another error, the resume operation never timed out, but the volume settings were not properly restored. BugLink: https://github.com/thesofproject/linux/issues/2908 BugLink: https://github.com/thesofproject/linux/issues/2637 Fixes: 03f6fc6de9192 ('ASoC: rt5682: Add the soundwire support') Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Bard Liao <bard.liao@intel.com> Link: https://lore.kernel.org/r/20210607222239.582139-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-04ASoC: rt5682: Fix the fast discharge for headset unplugging in soundwire modeOder Chiou1-1/+2
Based on ("5a15cd7fce20b1fd4aece6a0240e2b58cd6a225d"), the setting also should be set in soundwire mode. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Link: https://lore.kernel.org/r/20210604063150.29925-1-oder_chiou@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-10ASoC: rt5682: add delay time of workqueue to control next IRQ eventShuming Fan1-1/+1
This patch keeps the delay time (50 ms) for jack detection and zero delay time for the button press. This patch improves the reaction of the button press. Signed-off-by: Shuming Fan <shumingf@realtek.com> Link: https://lore.kernel.org/r/20210309085827.32032-1-shumingf@realtek.com Tested-by Curtis Malainey <cujomalainey@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-10ASoC: rt*: Constify static struct snd_soc_dai_opsRikard Falkeborn1-1/+1
The only usage of them is to assign their address to the ops field in the snd_soc_dai_driver struct, which is a pointer to const. Make them const to allow the compiler to put them in read-only memory. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Link: https://lore.kernel.org/r/20210224211918.39109-3-rikard.falkeborn@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-10ASoC: rt*: Constify static struct sdw_slave_opsRikard Falkeborn1-1/+1
The only usage of these is to assign their address to the ops field in the sdw_driver struct, which is a pointer to const. Make them const to allow the compiler to put them in read-only memory. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Link: https://lore.kernel.org/r/20210224211918.39109-2-rikard.falkeborn@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-02-05Merge branch 'asoc-5.11' into asoc-5.12Mark Brown1-1/+3
2021-02-05ASoC: rt5682-sdw: cancel_work_sync() in .remove and .suspendPierre-Louis Bossart1-1/+3
Follow pattern from other drivers and use cancel_work_sync() for both .remove() and .suspend(). Fixes: 03f6fc6de919 ('ASoC: rt5682: Add the soundwire support') Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Link: https://lore.kernel.org/r/20210204201739.25206-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-11ASoC: rt5682: fix getting the wrong device id when the suspend_stress_testShuming Fan1-7/+14
This patch will be the workaround to fix getting the wrong device ID on the rare chance. It seems like something unstable when the system resumes. e.g. the bus clock This patch tries to read the device ID to check several times. After the test, the driver will get the correct device ID the second time. Signed-off-by: Shuming Fan <shumingf@realtek.com> Link: https://lore.kernel.org/r/20210111092740.9128-1-shumingf@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-12ASoC: codecs: rt*.c: remove useless pointer castPierre-Louis Bossart1-1/+1
Pointer cast is not necessary, remove. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Link: https://lore.kernel.org/r/20201111214318.150529-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-15Merge tag 'sound-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/soundLinus Torvalds1-1/+1
Pull sound updates from Takashi Iwai: "The amount of changes is smaller at this round (what a surprise), but lots of activity is seen. Most of changes are about ASoC driver development, especially Intel platforms. Here are some highlights: General: - Replace all tasklet usages with other alternatives - Cleanup of the ASoC error unwinding code - Fixes for trivial issues caught by static checker - Spell fixes allover the places ALSA Core: - Lockdep fix for control devices - Fix for potential OSS sequencer mutex stalls HD-audio and USB-audio: - SoundBlaster AE-7 support - Changes in quirk table for the rename handling - Quirks for HP and ASUS machines, Pioneer DJ DJM-250MK2. ASoC: - Lots of updates for Intel SOF and SoundWire enablement - Replacement of the DSP driver for some older x86 systems; the new code was written from scratch, better maintenance expected - Helpers for parsing auxiluary devices from the device tree - New support for AllWinner A64, Cirrus Logic CS4234, Mediatek MT6359 Microchip S/PDIF TX and RX controllers, Realtek RT1015P, and Texas Instruments J721E, TAS2110, TAS2564 and TAS2764" * tag 'sound-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (498 commits) ALSA: hda/hdmi: fix incorrect locking in hdmi_pcm_close ALSA: hda: fix jack detection with Realtek codecs when in D3 ALSA: fireworks: use semicolons rather than commas to separate statements ALSA: hda: use semicolons rather than commas to separate statements ALSA: hda/i915 - fix list corruption with concurrent probes ASoC: dmaengine: Document support for TX only or RX only streams ASoC: mchp-spdiftx: remove 'TX' from playback stream name ASoC: ti: davinci-mcasp: Use &pdev->dev for early dev_warn ASoC: tas2764: Add the driver for the TAS2764 dt-bindings: tas2764: Add the TAS2764 binding doc ASoC: Intel: catpt: Add explicit DMADEVICES kconfig dependency ASoC: Intel: catpt: Fix compilation when CONFIG_MODULES is disabled ASoC: stm32: dfsdm: add actual resolution trace ASoC: stm32: dfsdm: change rate limits ASoC: qcom: sc7180: Add support for audio over DP Asoc: qcom: lpass-platform : Increase buffer size ASoC: qcom: Add support for lpass hdmi driver Asoc: qcom: lpass:Update lpaif_dmactl members order Asoc:qcom:lpass-cpu:Update dts property read API ASoC: dt-bindings: Add dt binding for lpass hdmi ...
2020-09-10ASoC: codecs: realtek-soundwire: ignore initial PARITY errorsPierre-Louis Bossart1-0/+1
The parity calculation is not reset on a Severe Reset, which leads to misleading/harmless errors reported on startup. The addition of a quirk helps filter out such errors while leaving the error checks on in steady-state. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20200908134521.6781-6-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
2020-09-10ASoC/soundwire: bus: use property to set interrupt masksPierre-Louis Bossart1-0/+4
Add a slave-level property and program the SCP_INT1_MASK as desired by the codec driver. Since there is no DisCo property this has to be an implementation-specific firmware property or hard-coded in the driver. The only functionality change is that implementation-defined interrupts are no longer set for amplifiers - those interrupts are typically for jack detection or acoustic event detection/hotwording. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20200908134521.6781-2-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
2020-09-03ASoC: codecs: soundwire: remove port_ready[] usage from codecs.Pierre-Louis Bossart1-14/+1
port_ready will be changed to a fixed array in sdw.h and all initialization work will be done at soundwire side in the following patch. So remove them from codec drivers. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20200831134318.11443-2-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
2020-08-19ASoC: codecs: rt*-sdw: use SDW_SLAVE_ENTRY_EXTPierre-Louis Bossart1-1/+1
Add version and class information explicitly to prepare for support for new devices. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200818141435.29205-1-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-17ASoC: rt5682: optimize the power consumptionShuming Fan1-1/+1
Some settings should set to default value after the calibration. This patch also disables the 25MHz and 1MHz clock power when the jack unplugged. The JD is triggered by JDH, therefore this patch removes JDL setting. Signed-off-by: Shuming Fan <shumingf@realtek.com> Link: https://lore.kernel.org/r/20200717070228.28660-1-shumingf@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-28ASoC: rt5682: split i2c driver into separate moduleArnd Bergmann1-2/+457
With SND_SOC_AMD_RV_RT5682_MACH using the i2c version of the driver, we can easily get a build failure when I2C is built-in but soundwire is not: WARNING: unmet direct dependencies detected for SND_SOC_RT5682 Depends on [m]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && (I2C [=y] || SOUNDWIRE [=m]) && (SOUNDWIRE [=m] || !SOUNDWIRE [=m]) && (I2C [=y] || !I2C [=y]) Selected by [y]: - SND_SOC_AMD_RV_RT5682_MACH [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_SOC_AMD_ACP3x [=y] && I2C [=y] && CROS_EC [=y] Selected by [m]: - SND_SOC_RT5682_SDW [=m] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SOUNDWIRE [=m] && (I2C [=y] || !I2C [=y]) Rework the driver to have three separate modules, with the main driver just dealing with the common bits and the actual initialization as part of i2c and sdw specific modules. The conversion is fairly mechanical to keep it easy to review, i.e. it moves code around with the minimal required renaming and changes. Fixes: 6b8e4e7db3cd ("ASoC: amd: Add machine driver for Raven based platform") Fixes: fd443a20c2f0 ("ASoC: rt5682: fix I2C/Soundwire dependencies") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200528091851.2889754-1-arnd@arndb.de Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-18ASoC: codecs: rt*-sdw: don't assign slave_opsPierre-Louis Bossart1-3/+0
The SoundWire bus core already assigns the slave ops, no need to set them a second time manually in each driver. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Cc: Oder Chiou <oder_chiou@realtek.com> Cc: Shuming Fan <shumingf@realtek.com> Cc: Jack Yu <jack.yu@realtek.com> Link: https://lore.kernel.org/r/20200515211531.11416-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-03-10ASoC: rt5682-sdw: fix 'defined but not used' pm functionsPierre-Louis Bossart1-2/+2
Gcc reports the following warnings: sound/soc/codecs/rt5682-sdw.c:286:12: warning: 'rt5682_dev_resume' defined but not used [-Wunused-function] static int rt5682_dev_resume(struct device *dev) ^~~~~~~~~~~~~~~~~ sound/soc/codecs/rt5682-sdw.c:273:12: warning: 'rt5682_dev_suspend' defined but not used [-Wunused-function] static int rt5682_dev_suspend(struct device *dev) ^~~~~~~~~~~~~~~~~~ Fix by adding maybe_unused as done for other SoundWire codecs Fixes: 03f6fc6de9192f ('ASoC: rt5682: Add the soundwire support') Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Cc: Oder Chiou <oder_chiou@realtek.com> Link: https://lore.kernel.org/r/20200310163509.14466-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-02-28ASoC: rt5682: Make rt5682_clock_config staticYueHaibing1-1/+1
Fix sparse warning: sound/soc/codecs/rt5682-sdw.c:163:5: warning: symbol 'rt5682_clock_config' was not declared. Should it be static? Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: YueHaibing <yuehaibing@huawei.com> Link: https://lore.kernel.org/r/20200228075609.38236-1-yuehaibing@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-02-26ASoC: rt5682: Add the soundwire supportOder Chiou1-0/+333
This patch adds the soundwire support for ALC5682. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Link: https://lore.kernel.org/r/20200219102858.20166-1-oder_chiou@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>