Commit graph

47131 commits

Author SHA1 Message Date
Vijendar Mukunda 7e1fe5d9e7
ASoC: SOF: amd: fix for firmware reload failure after playback
Setting ACP ACLK as clock source when ACP enters D0 state causing
firmware load failure as mentioned in below scenario.

- Load snd_sof_amd_rembrandt
- Play or Record audio
- Stop audio
- Unload snd_sof_amd_rembrandt
- Reload snd_sof_amd_rembrandt

If acp_clkmux_sel register field is set, then clock source will be
set to ACP ACLK when ACP enters D0 state.

During stream stop, if there is no active stream is running then
acp firmware will set the ACP ACLK value to zero.

When driver is reloaded and clock source is selected as ACP ACLK,
as ACP ACLK is programmed to zero, firmware loading will fail.

For RMB platform, remove the clock mux selection field so that
ACP will use internal clock source when ACP enters D0 state.

Fixes: 41cb85bc4b ("ASoC: SOF: amd: Add support for Rembrandt plaform.")
Reported-by: coolstar <coolstarorganization@gmail.com>
Closes: https://github.com/thesofproject/sof/issues/8137
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/20230927071412.2416250-1-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-27 11:08:05 +02:00
Shengjiu Wang 2b21207afd
ASoC: fsl-asoc-card: use integer type for fll_id and pll_id
As the pll_id and pll_id can be zero (WM8960_SYSCLK_AUTO)
with the commit 2bbc2df46e ("ASoC: wm8960: Make automatic the
default clocking mode")

Then the machine driver will skip to call set_sysclk() and set_pll()
for codec, when the sysclk rate is different with what wm8960 read
at probe, the output sound frequency is wrong.

So change the fll_id and pll_id initial value, still keep machine
driver's behavior same as before.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1695202992-24864-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-26 11:23:25 +02:00
Shengjiu Wang 197c53c8ec
ASoC: fsl_sai: Don't disable bitclock for i.MX8MP
On i.MX8MP, the BCE and TERE bit are binding with mclk
enablement, if BCE and TERE are cleared the MCLK also be
disabled on output pin, that cause the external codec (wm8960)
in wrong state.

Codec (wm8960) is using the mclk to generate PLL clock,
if mclk is disabled before disabling PLL, the codec (wm8960)
won't generate bclk and frameclk when sysclk switch to
MCLK source in next test case.

The test case:
$aplay -r44100 test1.wav (PLL source)
$aplay -r48000 test2.wav (MCLK source)
aplay: pcm_write:2127: write error: Input/output error

Fixes: 269f399dc1 ("ASoC: fsl_sai: Disable bit clock with transmitter")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1695116533-23287-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-25 13:11:05 +01:00
Miquel Raynal e52dca7216
ASoC: soc-generic-dmaengine-pcm: Fix function name in comment
While browsing/grepping in the sound core, I found that
snd_dmaengine_set_config_from_dai_data() did not exist, in favor of
snd_dmaengine_pcm_set_config_from_dai_data(). Fix the typo.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20230922161547.594484-1-miquel.raynal@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-22 17:33:04 +01:00
Mark Brown 95bfb16d66
ASoC: Intel: soc-acpi: Adding Es83x6 codec entry and
Merge series from Bard Liao <yung-chuan.liao@linux.intel.com>:

Adding Es83x6 codec entry and HDMI-in capture support in MTL match table.
2023-09-19 19:30:55 +01:00
Kuninori Morimoto 41bae58df4
ASoC: simple-card: fixup asoc_simple_probe() error handling
asoc_simple_probe() is used for both "DT probe" (A) and "platform probe"
(B). It uses "goto err" when error case, but it is not needed for
"platform probe" case (B). Thus it is using "return" directly there.

	static int asoc_simple_probe(...)
	{
 ^		if (...) {
 |			...
(A)			if (ret < 0)
 |				goto err;
 v		} else {
 ^			...
 |			if (ret < 0)
(B)				return -Exxx;
 v		}

		...
 ^		if (ret < 0)
(C)			goto err;
 v		...

	err:
(D)		simple_util_clean_reference(card);

		return ret;
	}

Both case are using (C) part, and it calls (D) when err case.
But (D) will do nothing for (B) case.
Because of these behavior, current code itself is not wrong,
but is confusable, and more, static analyzing tool will warning on
(B) part (should use goto err).

To avoid static analyzing tool warning, this patch uses "goto err"
on (B) part.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o7hy7mlh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-19 13:48:38 +01:00
Kuninori Morimoto 69cf63b656
ASoC: simple-card-utils: fixup simple_util_startup() error handling
It should use "goto" instead of "return"

Fixes: 5ca2ab4598 ("ASoC: simple-card-utils: Add new system-clock-fixed flag")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/202309141205.ITZeDJxV-lkp@intel.com/
Closes: https://lore.kernel.org/all/202309151840.au9Aa2W4-lkp@intel.com/
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v8c76jnz.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-19 13:48:37 +01:00
Pierre-Louis Bossart fb0b8d2997
ASoC: Intel: sof_sdw: add support for SKU 0B14
One more missing SKU in the list.

Closes: https://github.com/thesofproject/linux/issues/4543
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230919092125.1922468-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-19 13:48:36 +01:00
Pierre-Louis Bossart b399f9706a
ASoC: Intel: soc-acpi: fix Dell SKU 0B34
The rule for the SoundWire tables is that the platforms with more
devices need to be added first. We broke that rule with the Dell SKU
0B34, and caused the second amplifier for SKU 0AF3 to be ignored.

The fix is simple, we need to move the single-amplifier entry after
the two-amplifier one.

Fixes: b62a1a839b ("ASoC: Intel: soc-acpi: add tables for Dell SKU 0B34")
Closes: https://github.com/thesofproject/linux/issues/4559
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230919083606.1920202-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-19 13:48:35 +01:00
Balamurugan C d1f67278d4
ASoC: Intel: soc-acpi: Add entry for HDMI_In capture support in MTL match table
Adding HDMI-In capture via I2S feature support in MTL platform.

Signed-off-by: Balamurugan C <balamurugan.c@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230919091136.1922253-3-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-19 13:48:33 +01:00
Balamurugan C 381ddcd587
ASoC: Intel: soc-acpi: Add entry for sof_es8336 in MTL match table.
Adding support for ES83x6 codec in MTL match table.

Signed-off-by: Balamurugan C <balamurugan.c@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230919091136.1922253-2-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-19 13:48:32 +01:00
Peter Ujfalusi 31bb7bd9ff
ASoC: SOF: core: Only call sof_ops_free() on remove if the probe was successful
All the fail paths during probe will free up the ops, on remove we should
only free it if the probe was successful.

Fixes: bc433fd76f ("ASoC: SOF: Add ops_free")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Link: https://lore.kernel.org/r/20230915124015.19637-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-15 17:14:22 +01:00
Ranjani Sridharan e0f96246c4
ASoC: SOF: Intel: MTL: Reduce the DSP init timeout
20s seems unnecessarily large for the DSP init timeout. This coupled with
multiple FW boot attempts causes an excessive delay in the error path when
booting in recovery mode. Reduce it to 0.5s and use the existing
HDA_DSP_INIT_TIMEOUT_US.

Link: https://github.com/thesofproject/linux/issues/4565
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230915134153.9688-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-15 17:14:21 +01:00
Charles Keepax c923e7759a
ASoC: cs42l43: Add shared IRQ flag for shutters
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-09-15 17:14:20 +01:00
Shengjiu Wang b19a5733de
ASoC: imx-audmix: Fix return error with devm_clk_get()
The devm_clk_get() can return -EPROBE_DEFER error,
modify the error code to be -EINVAL is not correct, which
cause the -EPROBE_DEFER error is not correctly handled.

This patch is to fix the return error code.

Fixes: b86ef53677 ("ASoC: fsl: Add Audio Mixer machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Link: https://lore.kernel.org/r/1694757731-18308-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-15 13:16:21 +01:00
Chen Ni c04efbfd76
ASoC: hdaudio.c: Add missing check for devm_kstrdup
Because of the potential failure of the devm_kstrdup(), the
dl[i].codecs->name could be NULL.
Therefore, we need to check it and return -ENOMEM in order to transfer
the error.

Fixes: 97030a4337 ("ASoC: Intel: avs: Add HDAudio machine board")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230915021344.3078-1-nichen@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-15 13:16:20 +01:00
Peter Ujfalusi bb0216d4db
ASoC: SOF: sof-audio: Fix DSP core put imbalance on widget setup failure
In case the widget setup fails we should only decrement the core usage
count if the sof_widget_free_unlocked() has not been called as part of
the error handling.
sof_widget_free_unlocked() calls snd_sof_dsp_core_put() and the additional
core_put will cause imbalance in core usage count.
Use the existing use_count_decremented to handle this issue.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230914124725.17397-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-14 15:32:43 +01:00
Bard Liao 6ba59c008f
ASoC: SOF: ipc4-topology: fix wrong sizeof argument
available_fmt is a pointer.

Fixes: 4fdef47a44 ("ASoC: SOF: ipc4-topology: Add new tokens for input/output pin format count")
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230914132504.18463-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-14 15:32:42 +01:00
Chancel Liu fac58baf8f
ASoC: imx-rpmsg: Set ignore_pmdown_time for dai_link
i.MX rpmsg sound cards work on codec slave mode. MCLK will be disabled
by CPU DAI driver in hw_free(). Some codec requires MCLK present at
power up/down sequence. So need to set ignore_pmdown_time to power down
codec immediately before MCLK is turned off.

Take WM8962 as an example, if MCLK is disabled before DAPM power down
playback stream, FIFO error will arise in WM8962 which will have bad
impact on playback next.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://lore.kernel.org/r/20230913102656.2966757-1-chancel.liu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-14 11:59:28 +01:00
Mark Brown ef3e1b8a31
ASoC: cs42l42: Fix handling of hard reset
Merge series from Stefan Binding <sbinding@opensource.cirrus.com>:

These patches fix 3 problems with hard reset:
1. Ensure a minimum reset pulse width
2. Deal with ACPI overriding the requested default GPIO state
3. Avoid a race condition when hard-resetting a SoundWire peripheral
   that is already enumerated
2023-09-13 22:46:18 +01:00
Richard Fitzgerald 781118bc2f
ASoC: wm_adsp: Fix missing locking in wm_adsp_[read|write]_ctl()
wm_adsp_read_ctl() and wm_adsp_write_ctl() must hold the cs_dsp pwr_lock
mutex when calling cs_dsp_coeff_read_ctrl() and cs_dsp_coeff_write_ctrl().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230913160250.3700346-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-13 18:50:33 +01:00
Richard Fitzgerald 2d066c6a78
ASoC: cs42l42: Avoid stale SoundWire ATTACH after hard reset
In SoundWire mode leave hard RESET asserted when exiting probe,
and wait for an UNATTACHED notification before deasserting RESET.

If the boot state of the reset GPIO was deasserted it is possible
that the SoundWire core had already enumerated the CS42L42 before
cs42l42_sdw_probe() is called. When cs42l42_common_probe() hard
resets the CS42L42 it triggers a race condition:

1) After cs42l42_sdw_probe() returns the thread that called it
   will call cs42l42_sdw_update_status() to report the last
   status recorded by the SoundWire core.

2) The SoundWire bus master will see a PING with the CS42L42
   now reporting as unenumerated and will trigger the core
   SoundWire code to start enumerating CS42L42.

These two threads are racing against each other. If (1)
happens before (2) a stale ATTACHED notification will be
reported to the cs42l42 driver when in fact the status of
cs42l42 is now unattached.

To avoid this race condition:

- Leave RESET asserted on exit from cs42l42_sdw_probe().
  This ensures that an UNATTACHED notification must be
  sent to the cs42l42 driver. If cs42l42 was already
  enumerated it will be seen to drop off the bus, causing
  an UNATTACH notification. If it was never enumerated the
  status is already UNATTACHED and this will be reported
  by thread (1).

- When the UNATTACH notification is received, release RESET.
  This will cause CS42L42 to be enumerated and eventually
  report an ATTACHED notification.

- The ATTACHED notification is now valid.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230913150012.604775-4-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-13 16:03:21 +01:00
Richard Fitzgerald a479b44ac0
ASoC: cs42l42: Don't rely on GPIOD_OUT_LOW to set RESET initially low
The ACPI setting for a GPIO default state has higher priority than the
flag passed to devm_gpiod_get_optional() so ACPI can override the
GPIOD_OUT_LOW. Explicitly set the GPIO low when hard resetting.

Although GPIOD_OUT_LOW can't be relied on this doesn't seem like a
reason to stop passing it to devm_gpiod_get_optional(). So we still pass
it to state our intent, but can deal with it having no effect.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230913150012.604775-3-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-13 16:03:20 +01:00
Richard Fitzgerald 41dac81b56
ASoC: cs42l42: Ensure a reset pulse meets minimum pulse width.
The CS42L42 can accept very short reset pulses of a few microseconds
but there's no reason to force a very short pulse.
Allow a wide range for the usleep_range() so it can be relaxed about
the choice of timing source.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230913150012.604775-2-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-13 16:03:19 +01:00
Dan Carpenter cf0ba445f5
ASoC: codecs: aw88395: Fix some error codes
These error paths should return -EINVAL instead of success.

Fixes: 7f4ec77802 ("ASoC: codecs: Add code for bin parsing compatible with aw88261")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/81476e78-05c2-4656-b754-f314c7ccdb81@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-13 13:58:24 +01:00
Mark Brown ec83a0b39a
ASoC: rt5640: Fix various IRQ handling issues
Merge series from Hans de Goede <hdegoede@redhat.com>:

The recent(ish) rt5640 changes to add HDA header jack-detect support
and the related suspend/resume handling fixes have introduced several
issues with IRQ handling on boards not using the HDA header jack-detect
support.

This series fixes these issues, see the individual commit messages
for details.
2023-09-12 21:56:56 +01:00
Richard Fitzgerald 18789be8e0
ASoC: cs35l56: Disable low-power hibernation mode
Do not allow the CS35L56 to be put into its lowest power
"hibernation" mode. This only affects I2C because "hibernation"
is already disabled on SPI and SoundWire.

Recent firmwares need a different wake-up sequence. Until
that sequence has been specified, the chip "hibernation" mode
must be disabled otherwise it can intermittently fail to wake.

THIS WILL NOT APPLY CLEANLY TO 6.5 AND EARLIER:
We will send a separate backport patch to stable.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230912133841.3480466-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 18:53:44 +01:00
Hans de Goede 8fc7cc507d
ASoC: rt5640: Only cancel jack-detect work on suspend if active
If jack-detection is not used; or has already been disabled then
there is no need to call rt5640_cancel_work().

Move the rt5640_cancel_work() inside the "if (rt5640->jack) {}" block,
grouping it together with the disabling of the IRQ which queues the work
in the first place.

This also makes suspend() symetrical with resume() which re-queues the work
in an "if (rt5640->jack) {}" block.

Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230912113245.320159-7-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 14:37:51 +01:00
Hans de Goede 8c8bf3df6b
ASoC: rt5640: Fix IRQ not being free-ed for HDA jack detect mode
Set "rt5640->irq_requested = true" after a successful request_irq()
in rt5640_enable_hda_jack_detect(), so that rt5640_disable_jack_detect()
properly frees the IRQ.

This fixes the IRQ not being freed on rmmod / driver unbind.

Fixes: 2b9c8d2b3c ("ASoC: rt5640: Add the HDA header support")
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230912113245.320159-6-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 14:37:50 +01:00
Hans de Goede b5e85e5355
ASoC: rt5640: Enable the IRQ on resume after configuring jack-detect
The jack-detect IRQ should be enabled *after* the jack-detect related
configuration registers have been programmed.

Move the enable_irq() call for this to after the register setup.

Fixes: 5fabcc90e7 ("ASoC: rt5640: Fix Jack work after system suspend")
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230912113245.320159-5-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 14:37:49 +01:00
Hans de Goede 786120ebb6
ASoC: rt5640: Do not disable/enable IRQ twice on suspend/resume
When jack-detect was originally added disabling the IRQ during suspend
was done by the sound/soc/intel/boards/bytcr_rt5640.c driver
calling snd_soc_component_set_jack(NULL) on suspend, which calls
rt5640_disable_jack_detect(), which calls free_irq() which also
disables it.

Commit 5fabcc90e7 ("ASoC: rt5640: Fix Jack work after system suspend")
added disable_irq() / enable_irq() calls on suspend/resume for machine
drivers which do not call snd_soc_component_set_jack(NULL) on suspend.

The new disable_irq() / enable_irq() are made conditional by
"if (rt5640->irq)" statements, but this is true for the machine drivers
which do call snd_soc_component_set_jack(NULL) on suspend too, causing
a disable_irq() call there on the already free-ed IRQ.

Change the "if (rt5640->irq)" condition to "if (rt5640->jack)" to fix this,
rt5640->jack is only set if the jack-detect IRQ handler is still active
when rt5640_suspend() runs.

And adjust rt5640_enable_hda_jack_detect()'s request_irq() error handling
to set rt5640->jack to NULL to match (note that the old setting of irq to
-ENOXIO still resulted in disable_irq(-ENOXIO) calls on suspend).

Fixes: 5fabcc90e7 ("ASoC: rt5640: Fix Jack work after system suspend")
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230912113245.320159-4-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 14:37:48 +01:00
Hans de Goede df7d595f6b
ASoC: rt5640: Fix sleep in atomic context
Following prints are observed while testing audio on Jetson AGX Orin which
has onboard RT5640 audio codec:

  BUG: sleeping function called from invalid context at kernel/workqueue.c:3027
  in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0
  preempt_count: 10001, expected: 0
  RCU nest depth: 0, expected: 0
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at kernel/irq/handle.c:159 __handle_irq_event_percpu+0x1e0/0x270
  ---[ end trace ad1c64905aac14a6 ]-

The IRQ handler rt5640_irq() runs in interrupt context and can sleep
during cancel_delayed_work_sync().

The only thing which rt5640_irq() does is cancel + (re-)queue
the jack_work delayed_work. This can be done in a single non sleeping
call by replacing queue_delayed_work() with mod_delayed_work(),
avoiding the sleep in atomic context.

Fixes: 051dade346 ("ASoC: rt5640: Fix the wrong state of JD1 and JD2")
Reported-by: Sameer Pujar <spujar@nvidia.com>
Closes: https://lore.kernel.org/r/1688015537-31682-4-git-send-email-spujar@nvidia.com
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230912113245.320159-3-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 14:37:47 +01:00
Hans de Goede fa6a0c0c1d
ASoC: rt5640: Revert "Fix sleep in atomic context"
Commit 70a6404ff6 ("ASoC: rt5640: Fix sleep in atomic context")
not only switched from request_irq() to request_threaded_irq(),
to fix the sleep in atomic context issue, but it also added
devm management of the IRQ by actually switching to
devm_request_threaded_irq() (without any explanation in the commit
message for this change).

This is wrong since the IRQ was already explicitly managed by
the driver. On unbind the ASoC core will call rt5640_set_jack(NULL)
which in turn will call rt5640_disable_jack_detect() which
frees the IRQ already. So now we have a double free.

Besides the unexplained switch to devm being wrong, the actual fix
for the sleep in atomic context issue also is not the best solution.

The only thing which rt5640_irq() does is cancel + (re-)queue
the jack_work delayed_work. This can be done in a single non sleeping
call by replacing queue_delayed_work() with mod_delayed_work(),
which does not sleep. Using mod_delayed_work() is a much better fix
then adding a thread which does nothing other then queuing a work-item.

This patch is a straight revert of the troublesome changes, the switch
to mod_delayed_work() is done in a separate follow-up patch.

Fixes: 70a6404ff6 ("ASoC: rt5640: Fix sleep in atomic context")
Cc: Sameer Pujar <spujar@nvidia.com>
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230912113245.320159-2-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 14:37:46 +01:00
August Wikerfors 1263cc0f41
ASoC: amd: yc: Fix non-functional mic on Lenovo 82QF and 82UG
Like the Lenovo 82TL and 82V2, the Lenovo 82QF (Yoga 7 14ARB7) and 82UG
(Legion S7 16ARHA7) both need a quirk entry for the internal microphone to
function. Commit c008323fe3 ("ASoC: amd: yc: Fix a non-functional mic on
Lenovo 82SJ") restricted the quirk that previously matched "82" to "82V2",
breaking microphone functionality on these devices. Fix this by adding
specific quirks for these models, as was done for the Lenovo 82TL.

Fixes: c008323fe3 ("ASoC: amd: yc: Fix a non-functional mic on Lenovo 82SJ")
Closes: https://github.com/tomsom/yoga-linux/issues/51
Link: https://bugzilla.kernel.org/show_bug.cgi?id=208555#c780
Cc: stable@vger.kernel.org
Signed-off-by: August Wikerfors <git@augustwikerfors.se>
Link: https://lore.kernel.org/r/20230911213409.6106-1-git@augustwikerfors.se
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-12 13:16:30 +01:00
Mark Brown 7e6096634c
Fix redundant PLLA update
Merge series from Sameer Pujar <spujar@nvidia.com>:

This small series fixes redundant PLLA updates that happen for
each DAI link in the audio path. This helps to resolve DMIC clock
issue seen on Jetson TX2 platform.
2023-09-11 22:21:23 +01:00
Shengjiu Wang 2f9426905a
ASoC: fsl: imx-pcm-rpmsg: Add SNDRV_PCM_INFO_BATCH flag
The rpmsg pcm device is a device which should support
double buffering.

Found this issue with pipewire. When there is no
SNDRV_PCM_INFO_BATCH flag in driver, the pipewire will
set headroom to be zero, and because rpmsg pcm device
don't support residue report, when the latency setting
is small, the "delay" always larger than "target" in
alsa-pcm.c, that reading next period data is not
scheduled on time.

With SNDRV_PCM_INFO_BATCH flag in driver, the pipewire
will select a smaller period size for device, then
the task of reading next period data will be scheduled
on time.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1694414287-13291-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 16:09:01 +01:00
Walt Holman e616a916fe
Add DMI ID for MSI Bravo 15 B7ED
Signed-off-by: Walt Holman <waltholman09@gmail.com>
Link: https://lore.kernel.org/r/20230910185433.13677-1-waltholman09@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:57 +01:00
Charles Keepax 396b907919
ASoC: soc-pcm: Shrink stack frame for __soc_pcm_hw_params
Commit ac950278b0 ("ASoC: add N cpus to M codecs dai link support")
added an additional local params in __soc_pcm_hw_params, for the CPU
side of the DAI. The snd_pcm_hw_params struct is pretty large (604
bytes) and keeping two local copies of it can make the stack frame
really large.

It is worth noting the variables are in separate code blocks so for
some optimisation levels in the compiler these will get automatically
combined keeping the stack frame reasonable. But better to manually
combine them to cover all cases.

Add a single local variable for __soc_pcm_hw_params and use in both
loops to shrink the stack frame.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230908085920.2906359-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:56 +01:00
Guenter Roeck d7e47e3219
ASoC: wm8960: Fix error handling in probe
Commit 422f10adc3 ("ASoC: wm8960: Add support for the power supplies")
added regulator support to the wm8960 driver, but neglected to update
error handling in the probe function. This results in warning backtraces
if the probe function fails.

Fixes: 422f10adc3 ("ASoC: wm8960: Add support for the power supplies")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Link: https://lore.kernel.org/r/20230909120237.2646275-1-linux@roeck-us.net
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:55 +01:00
Julia Lawall 28115b1c4f
ASoC: rsnd: add missing of_node_put
for_each_child_of_node performs an of_node_get on each
iteration, so a break out of the loop requires an
of_node_put.

This was done using the Coccinelle semantic patch
iterators/for_each_child.cocci

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20230907095521.14053-11-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:54 +01:00
Jerome Brunet aedf323b66
ASoC: meson: spdifin: start hw on dai probe
For spdif input to report the locked rate correctly, even when no capture
is running, the HW and reference clock must be started as soon as
the dai is probed.

Fixes: 5ce5658375 ("ASoC: meson: add axg spdif input")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20230907090504.12700-1-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:53 +01:00
Richard Fitzgerald ec03804552
ASoC: cs35l56: Call pm_runtime_dont_use_autosuspend()
Driver remove() must call pm_runtime_dont_use_autosuspend().

Drivers that call pm_runtime_use_autosuspend() must disable
it in driver remove(). Unfortunately until recently this was
only mentioned in 1 line in a 900+ line document so most
people hadn't noticed this. It has only recently been added
to the kerneldoc of pm_runtime_use_autosuspend().

THIS WON'T APPLY CLEANLY TO V6.5 AND EARLIER:
We will send a separate backported patch to stable.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230908101716.2658582-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:53 +01:00
Sameer Pujar e765886249
ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates
Tegra audio graph card has many DAI links which connects internal
AHUB modules and external audio codecs. Since these are DPCM links,
hw_params() call in the machine driver happens for each connected
BE link and PLLA is updated every time. This is not really needed
for all links as only I/O link DAIs derive respective clocks from
PLLA_OUT0 and thus from PLLA. Hence add checks to limit the clock
updates to DAIs over I/O links.

This found to be fixing a DMIC clock discrepancy which is suspected
to happen because of back to back quick PLLA and PLLA_OUT0 rate
updates. This was observed on Jetson TX2 platform where DMIC clock
ended up with unexpected value.

Fixes: 202e2f7745 ("ASoC: tegra: Add audio graph based card driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1694098945-32760-3-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:51 +01:00
Sameer Pujar f101583fa9
ASoC: soc-utils: Export snd_soc_dai_is_dummy() symbol
Export symbol snd_soc_dai_is_dummy() for usage outside core driver
modules. This is required by Tegra ASoC machine driver.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1694098945-32760-2-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-11 01:23:50 +01:00
Linus Torvalds a3d231e44a sound fixes for 6.6-rc1
A collection of fixes for 6.6-rc1.  All small and easy ones.
 
 - The corrections of the previous PCM iov_iter transitions
 - Regression fixes in MIDI 2.0 / USB changes
 - Various ASoC codec fixes for Cirrus, Realtek, WCD
 - ASoC AMD quirks and ASoC Intel AVS driver workaround
 -----BEGIN PGP SIGNATURE-----
 
 iQJCBAABCAAsFiEEIXTw5fNLNI7mMiVaLtJE4w1nLE8FAmT5xkIOHHRpd2FpQHN1
 c2UuZGUACgkQLtJE4w1nLE9k8RAAkgeTtv8W3YWKvkMMf7kMEP4Go8COJ4pLqY4A
 zPfJp//tDSKiOLPm8XzYYQQddTlcVc6iNbV/3Enw3Ov9xvnQxAk+N+5ciF+s27q5
 KyxzKZneEOSJSCPHPcbcI0LgqpSH/b71S8NhGL48DXxCd+GHyHSind8hel6xi+u4
 dQIL9cQOp1HGmKreMrHvsvY4ruG5SrnQ+GXjcnkmdmMWP17xtubAXcRWvZs/PMl4
 dg5HNUDy/KuRbHnxTAee7tuGZyG10sLkS4UfP+J4gKGdOKQvltrQ7dTyG3dCKtRl
 Ezq0++IY7asMAdBu39IDJdC7XFr4jNSmeZbqcmhX8PTggIUJuyHzfnC9pAadkXOn
 B11ZJUL2I6QYI6UZyyvWTc2HD4+rxOvl6IkFkDgaiOD3chPTqhAwAhDUeFICSuBi
 BPJ4fG2r0iEFP92dTli9Q2gY2fXkE24ndpwP+zWbt0zO0/nQPh0XfWO3x6Vt/ml1
 NNNj12qx6w6I4k8kx+mj4zFewz7x8dTIdXLukYAPk5tlagXpora9u1tt0ZT72T22
 +wintcjfIp6agKxcWVmKVXi2PFdQmrwpUe5lW5EPKhEXNcrQaTBOKb9MYvFrCTz3
 6olHbocegqolNnTJ/uSRTBD0E5jkwpdbc3MbSKrxUpcyTyKZmPDpd9JuPLLJHPfn
 BkFdx5U=
 =txoJ
 -----END PGP SIGNATURE-----

Merge tag 'sound-fix-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
 "A collection of fixes for 6.6-rc1. All small and easy ones.

   - The corrections of the previous PCM iov_iter transitions

   - Regression fixes in MIDI 2.0 / USB changes

   - Various ASoC codec fixes for Cirrus, Realtek, WCD

   - ASoC AMD quirks and ASoC Intel AVS driver workaround"

* tag 'sound-fix-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (21 commits)
  ALSA: hda/realtek - ALC287 I2S speaker platform support
  ASoC: amd: yc: Fix a non-functional mic on Lenovo 82TL
  ASoC: Intel: avs: Provide support for fallback topology
  ALSA: seq: Fix snd_seq_expand_var_event() call to user-space
  ALSA: usb-audio: Fix potential memory leaks at error path for UMP open
  ALSA: hda/cirrus: Fix broken audio on hardware with two CS42L42 codecs.
  ASoC: rt5645: NULL pointer access when removing jack
  ASoC: amd: yc: Add DMI entries to support Victus by HP Gaming Laptop 15-fb0xxx (8A3E)
  MAINTAINERS: Update the MAINTAINERS enties for TEXAS INSTRUMENTS ASoC DRIVERS
  ALSA: sb: Fix wrong argument in commented code
  ALSA: pcm: Fix error checks of default read/write copy ops
  ASoC: Name iov_iter argument as iterator instead of buffer
  ASoC: dmaengine: Drop unused iov_iter for process callback
  ALSA: hda/tas2781: Use standard clamp() macro
  ASoC: cs35l56: Waiting for firmware to boot must be tolerant of I/O errors
  ASoC: dt-bindings: fsl_easrc: Add support for imx8mp-easrc
  ASoC: cs42l43: Fix missing error code in cs42l43_codec_probe()
  ASoC: cs35l45: Rename DACPCM1 Source control
  ASoC: cs35l45: Fix "Dead assigment" warning
  ASoC: cs35l45: Add support for Chip ID 0x35A460
  ...
2023-09-08 13:07:50 -07:00
Takashi Iwai ecc8b4d0b6 ASoC: Fixes for v6.6
A bunch of fixes and new IDs that came in since the initial pull request
 - all driver specific and nothing too exciting.
 
 There's a trivial conflict in the AMD driver ID table due to the last
 v6.5 fixes not having been merged up.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmT5uzEACgkQJNaLcl1U
 h9D1RAf/SrPNpWDm5nX0suSQiNqxyzeT+deZtYtKGaF0/rMdOLsnqQyPKV25s9xS
 bqdI03oFMPfXOqfPW9F+4bmFBuWlL2kl1n1HZIx/bm8/lDCEBQVOXpOl56lHJpPv
 I91dh/1eVUp20FtPwaLwMgPpVb/iJvVSol/IuSvjXICggDY2091F05nBWef2z93S
 3tRVkDX4p+Ywra9lFexV0goRL/bCfdMSG8GHHurdVWB4y6fI1LC6eoPEYsLujzvx
 92//HR7mx11uo9Kf+SiHBJVgZAzW9pJXpnjgTx3X/Isrfxv8h/MnSR3btUKDp3Ti
 okxLvCujDZVhbVP6DiJEuCmXr0OXdQ==
 =abtH
 -----END PGP SIGNATURE-----

Merge tag 'asoc-fix-v6.6-merge-window' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v6.6

A bunch of fixes and new IDs that came in since the initial pull request
- all driver specific and nothing too exciting.

There's a trivial conflict in the AMD driver ID table due to the last
v6.5 fixes not having been merged up.
2023-09-07 14:10:36 +02:00
Kailang Yang e43252db7e ALSA: hda/realtek - ALC287 I2S speaker platform support
0x17 was only speaker pin, DAC assigned will be 0x03. Headphone
assigned to 0x02.
Playback via headphone will get EQ filter processing. So,it needs to
swap DAC.

Tested-by: Mark Pearson <mpearson@lenovo.com>
Signed-off-by: Kailang Yang <kailang@realtek.com>
Link: https://lore.kernel.org/r/4e4cfa1b3b4c46838aecafc6e8b6f876@realtek.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-09-07 10:33:04 +02:00
Mario Limonciello cfff2a7794
ASoC: amd: yc: Fix a non-functional mic on Lenovo 82TL
Lenovo 82TL has DMIC connected like 82V2 does.  Also match
82TL.

Reported-by: wildjim@kiwinet.org
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217063
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20230906182257.45736-1-mario.limonciello@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-06 20:06:36 +01:00
Amadeusz Sławiński 739c031110
ASoC: Intel: avs: Provide support for fallback topology
HDA and HDMI devices are simple enough that in case of user not having
topology tailored to their device, they can use fallback topology.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230905093147.1960675-1-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-09-05 17:28:07 +01:00
Takashi Iwai 86496fd4a2 ALSA: seq: Fix snd_seq_expand_var_event() call to user-space
The recent fix to clear the padding bytes at
snd_seq_expand_var_event() broke the read to user-space with
in_kernel=0 parameter.  For user-space address, it has to use
clear_user() instead of memset().

Fixes: f80e6d60d6 ("ALSA: seq: Clear padded bytes at expanding events")
Reported-and-tested-by: Ash Holland <ash@sorrel.sh>
Closes: https://lore.kernel.org/r/8a555319-9f31-4ea2-878f-adc338bc40d4@sorrel.sh
Link: https://lore.kernel.org/r/20230905052631.18240-1-tiwai@suse.de
Link: https://lore.kernel.org/r/20230905081210.6731-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-09-05 10:13:46 +02:00