Commit Graph

13278 Commits

Author SHA1 Message Date
Sheetal
247d1c1399 ASoC: rt5640: Handle 0Hz sysclk during stream shutdown
Commit 2458adb8f9 ("SoC: simple-card-utils: set 0Hz to sysclk when
shutdown") sends a 0Hz sysclk request during stream shutdown to clear
codec rate constraints. The rt5640 codec forwards this 0Hz to
clk_set_rate(), which can cause clock controller firmware faults on
platforms where MCLK is SoC-driven (e.g. Tegra) and 0Hz falls below
the hardware minimum rate.

Handle the 0Hz case by clearing the internal sysclk state and
returning early, avoiding the invalid clk_set_rate() call.

Signed-off-by: Sheetal <sheetal@nvidia.com>
Link: https://patch.msgid.link/20260406090547.988966-1-sheetal@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-04-06 13:04:03 +01:00
Rosen Penev
04cc47624a ASoC: codecs: tlv320dac33: remove kmemdup_array
Use a flexible array member and struct_size to use one allocation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260402025040.93569-1-rosenp@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-04-03 15:11:50 +01:00
Kuninori Morimoto
9b4f93a8b1 ASoC: ak5558: remove unused snd_soc_component
ak5558_priv::component has never been used. Remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/875x6bttv8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-04-01 13:07:22 +01:00
Mark Brown
18cc8cc30b ASoC: jz47xx: Convert to devm_clk_get_enabled()
Jihed Chaibi <jihed.chaibi.dev@gmail.com> says:

The jz4725b, jz4760 and jz4770 Ingenic codec drivers all share the same
clock management pattern: the clock is obtained with devm_clk_get() in
the platform probe, then manually enabled in the component probe and
disabled in the component remove. The clk_prepare_enable() call in the
component probe is unchecked, meaning clock enable failures are silently
ignored and can lead to register access on unpowered hardware.

This series converts all three drivers to devm_clk_get_enabled(), which
combines the get, prepare and enable steps and ties the clock lifetime to
the device via devres. The now-redundant component remove callbacks and
the struct clk pointers in the private structs are removed.
2026-03-30 19:40:31 +01:00
Jihed Chaibi
7dcb79e5c0 ASoC: jz4770: Convert to devm_clk_get_enabled()
The clock is obtained with devm_clk_get() in the platform probe, then
manually enabled in the component probe and disabled in the component
remove without checking the return value of clk_prepare_enable().

Use devm_clk_get_enabled() instead, which combines the get, prepare and
enable operations into one call whose lifetime is tied to the device.
This removes the need for explicit enable/disable in the component
probe/remove callbacks, and ensures that clock enable failures are
propagated as errors rather than silently ignored.

Remove the now-unused struct clk pointer from struct jz_codec and drop
the empty component remove callback.

Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Link: https://patch.msgid.link/20260323161551.47181-4-jihed.chaibi.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-30 19:40:29 +01:00
Jihed Chaibi
00df61cbc7 ASoC: jz4760: Convert to devm_clk_get_enabled()
The clock is obtained with devm_clk_get() in the platform probe, then
manually enabled in the component probe and disabled in the component
remove without checking the return value of clk_prepare_enable().

Use devm_clk_get_enabled() instead, which combines the get, prepare and
enable operations into one call whose lifetime is tied to the device.
This removes the need for explicit enable/disable in the component
probe/remove callbacks, and ensures that clock enable failures are
propagated as errors rather than silently ignored.

Remove the now-unused struct clk pointer from struct jz_codec and drop
the empty component remove callback.

Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Link: https://patch.msgid.link/20260323161551.47181-3-jihed.chaibi.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-30 19:40:28 +01:00
Jihed Chaibi
9644e7f83d ASoC: jz4725b: Convert to devm_clk_get_enabled()
The clock is obtained with devm_clk_get() in the platform probe, then
manually enabled in the component probe and disabled in the component
remove without checking the return value of clk_prepare_enable().

Use devm_clk_get_enabled() instead, which combines the get, prepare and
enable operations into one call whose lifetime is tied to the device.
This removes the need for explicit enable/disable in the component
probe/remove callbacks, and ensures that clock enable failures are
propagated as errors rather than silently ignored.

Remove the now-unused struct clk pointer from struct jz_icdc and drop
the empty component remove callback.

Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Link: https://patch.msgid.link/20260323161551.47181-2-jihed.chaibi.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-30 19:40:27 +01:00
Mark Brown
2a740dc589 ASoC: Merge up fixes
Merge branch 'for-7.0' of
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into
asoc-7.1 for both ASoC and general bug fixes to support testing.
2026-03-30 17:59:52 +01:00
Thorsten Blum
1e28cdeec3 ASoC: codecs: inline i2c_check_functionality checks
Inline i2c_check_functionality() checks, since the function returns a
boolean status rather than an error code.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260329163152.366356-2-thorsten.blum@linux.dev
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-30 15:05:34 +01:00
Mark Brown
9800e7741f ASoC: Drop some unused GPIO includes
Linus Walleij <linusw@kernel.org> says:

This drops the unnecessary legacy includes from three
more codecs.

Link: https://patch.msgid.link/20260327-asoc-rt1318-v1-0-9fcecf868fda@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-27 18:37:57 +00:00
Linus Walleij
00e981c7c0 ASoC: ts3a227e: Drop unused include
The driver includes the legacy GPIO header <linux/gpio.h> but does
not use any symbols from it so drop the include.

Signed-off-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260327-asoc-rt1318-v1-3-9fcecf868fda@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-27 18:37:55 +00:00
Linus Walleij
175b2d0258 ASoC: nau8315: Drop unused include
The driver includes the legacy GPIO header <linux/gpio.h> but does
not use any symbols from it so drop the include. (It is already
using the consumer header as is proper.)

Signed-off-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260327-asoc-rt1318-v1-2-9fcecf868fda@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-27 18:37:54 +00:00
Linus Walleij
486c064515 ASoC: rt1318: Drop unused include
The driver includes the legacy GPIO header <linux/gpio.h> but does
not use any symbols from it so drop the include.

Signed-off-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260327-asoc-rt1318-v1-1-9fcecf868fda@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-27 18:37:54 +00:00
Richard Fitzgerald
951a4e8589 ASoC: wm_adsp_fw_find_test: Fix missing NULL terminator on file name list
The array wm_adsp_fw_find_test_dir_all_files[] needs a NULL terminator.

It was documented at line 41 that dir_files points to a NULL-terminated
array.

   /* NULL-terminated array of pointers to filenames ... <snip> */
   const char * const *dir_files;

This fixes the error reported by KASAN:

[17:46:43] BUG: KASAN: global-out-of-bounds in
  wm_adsp_fw_find_test_pick_file+0x8cc/0xc80
[17:46:43] Read of size 8 at addr ffff800081e5ffe8 by task
  kunit_try_catch/18349

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: bf2d44d07d ("ASoC: wm_adsp: Add kunit test for firmware file search")
Link: https://patch.msgid.link/20260326100853.1582886-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-26 10:44:45 +00:00
Mark Brown
c6eea4ff84 ASoC: adau1372: Fix error handling in adau1372_set_power()
Jihed Chaibi <jihed.chaibi.dev@gmail.com> says:

adau1372_set_power() had two related error handling issues in its enable
path: clk_prepare_enable() was called but its return value discarded, and
adau1372_enable_pll() was a void function that silently swallowed lock
failures, leaving mclk enabled and adau1372->enabled set to true despite
the device being in a broken state.

Patch 1 fixes the unchecked clk_prepare_enable() by making
adau1372_set_power() return int and propagating the error.

Patch 2 converts adau1372_enable_pll() to return int and adds a full
unwind in adau1372_set_power() if PLL lock fails, reversing the regcache,
GPIO power-down, and clock state.
2026-03-26 10:33:38 +00:00
Jihed Chaibi
bfe6a264ef ASoC: adau1372: Fix clock leak on PLL lock failure
adau1372_enable_pll() was a void function that logged a dev_err() on
PLL lock timeout but did not propagate the error. As a result,
adau1372_set_power() would continue with adau1372->enabled set to true
despite the PLL being unlocked, and the mclk left enabled with no
corresponding disable on the error path.

Convert adau1372_enable_pll() to return int, using -ETIMEDOUT on lock
timeout and propagating regmap errors directly. In adau1372_set_power(),
check the return value and unwind in reverse order: restore regcache to
cache-only mode, reassert GPIO power-down, and disable the clock before
returning the error.

Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Fixes: 6cd4c6459e ("ASoC: Add ADAU1372 audio CODEC support")
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20260325210704.76847-3-jihed.chaibi.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-26 10:33:36 +00:00
Jihed Chaibi
326fe8104a ASoC: adau1372: Fix unchecked clk_prepare_enable() return value
adau1372_set_power() calls clk_prepare_enable() but discards the return
value. If the clock enable fails, the driver proceeds to access registers
on unpowered hardware, potentially causing silent corruption.

Make adau1372_set_power() return int and propagate the error from
clk_prepare_enable(). Update adau1372_set_bias_level() to return the
error directly for the STANDBY and OFF cases.

Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Fixes: 6cd4c6459e ("ASoC: Add ADAU1372 audio CODEC support")
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20260325210704.76847-2-jihed.chaibi.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-26 10:33:35 +00:00
Mark Brown
7b907b55eb ASoC: cs35l56: Support for factory calibration through ALSA controls
Richard Fitzgerald <rf@opensource.cirrus.com> says:

Factory calibration is normally done through debugfs files.
Google have requested that factory calibration can be performed by
repair shops. These repair shops only have access to the standard
"user" kernel, which does not include debugfs.

Patch #1 adds a new control definition macro to create a boolean control
         with specified access permissions. (new in V2)

Patch #2 is the implementation in the cs35l56 driver.
2026-03-26 10:20:46 +00:00
Richard Fitzgerald
ee7d655dba ASoC: cs35l56: Allow factory calibration through ALSA controls
Add support for using ALSA controls to trigger a factory calibration.
This is protected by a new Kconfig option so that it is only available
if explicitly enabled in the kernel. By default it is not enabled.

Factory calibration is normally done through debugfs files.
Google have requested that factory calibration can be performed by
repair shops. These repair shops only have access to the standard
"user" kernel, which does not include debugfs.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260325170841.1405368-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-26 10:20:44 +00:00
Mark Brown
5a306bef59 ASoC: Merge up fixes
Merge branch 'for-7.0' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-7.1

to get fixes into our development branch and resolve interactions with
the match tables.
2026-03-24 17:29:47 +00:00
Mark Brown
1f0f14aa18 ASoc: uda1380: Improve error reporting
Wenyuan Li <2063309626@qq.com> says:

The driver currently ignores the return values of several I2C operations
during register writes, which could lead to silent failures and
inconsistent device state.

Link: https://patch.msgid.link/tencent_579D057AC557914CF739A2D9EAD045CE7306@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-24 15:04:01 +00:00
Wenyuan Li
e5d5cc4479 ASoC: uda1380: use dev_err() and %pe for better error reporting
Convert existing debug and error prints to dev_err() to provide better
diagnostic information. Use the %pe format specifier to print
human-readable error strings for I2C failures.

Signed-off-by: Wenyuan Li <2063309626@qq.com>
Link: https://patch.msgid.link/tencent_A26B55F062F2B9C282A142BFC8BCDB1B9105@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-24 15:03:59 +00:00
Wenyuan Li
071efde6b7 ASoC: uda1380: fix missing return value checks for I2C operations
The driver currently ignores the return values of several I2C operations
during register writes, which could lead to silent failures and
inconsistent device state.

Fix this by:
- Moving variable declarations to the beginning of the function (C90).
- Checking the return value of every i2c_master_send() and recv() call.
- Returning the actual error code if it's negative, or -EIO if the
  transfer was incomplete.

Signed-off-by: Wenyuan Li <2063309626@qq.com>
Link: https://patch.msgid.link/tencent_579D057AC557914CF739A2D9EAD045CE7306@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-24 15:03:58 +00:00
Srinivas Kandagatla
cfb385a8dc ASoC: codecs: wcd934x: fix typo in dt parsing
Looks like we ended up with a typo during device tree data parsing
as part of 4f16b6351b ("ASoC: codecs: wcd: add common helper for wcd
codecs") patch.
 This will result in not parsing the device tree data and results in
zero mic bias values.

Fix this by calling wcd_dt_parse_micbias_info instead of
wcd_dt_parse_mbhc_data.

Fixes: 4f16b6351b ("ASoC: codecs: wcd: add common helper for wcd codecs")
Cc: Stable@vger.kernel.org
Reported-by: Joel Selvaraj <foss@joelselvaraj.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260323231748.2217967-1-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-24 13:09:09 +00:00
Arnd Bergmann
e3f1ce073a ASoC: wm_adsp: select CONFIG_SND_SOC_WM_ADSP from all users
The addition of the kunit test made it possible to enable the WM_ADSP
driver even when there are no users. However, an unintended side-effect
was that it is also possible to turn it off when it is actually required,
leading to build failures:

ERROR: modpost: "wm_halo_init" [sound/soc/codecs/snd-soc-cs35l45.ko] undefined!
ERROR: modpost: "wm_adsp2_remove" [sound/soc/codecs/snd-soc-cs35l45.ko] undefined!
ERROR: modpost: "wm_adsp_hibernate" [sound/soc/codecs/snd-soc-cs35l45.ko] undefined!
ERROR: modpost: "wm_adsp2_component_probe" [sound/soc/codecs/snd-soc-cs35l45.ko] undefined!

Reverse the logic to replace the ununual list of 'default y if ....' with
the regular 'select' that do the same thing but prevent it from being
disabled if that would break the build.

Fixes: bf2d44d07d ("ASoC: wm_adsp: Add kunit test for firmware file search")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260320151752.3439218-1-arnd@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-23 14:36:01 +00:00
Baojun Xu
a437601a0a ASoC: tas2781: Add null check for calibration data
For avoid null pointer problem if no calibration data exist.

Fixes: 55137f5a68 ("ASoC: tas2781: Put three different calibrated data solution into the same data structure")

Signed-off-by: Baojun Xu <baojun.xu@ti.com>
Link: https://patch.msgid.link/20260319090747.2090-1-baojun.xu@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-19 12:52:55 +00:00
Charles Keepax
6017671da9 ASoC: wm_adsp: Fix crash in kunit tests on arm64
Several of the wm_adsp kunit tests failed by only on arm64. This
turns out to be passing things to release_firmware which were not
allocated with request_firmware. This does actually drop some
errors on other platforms but somehow doesn't cause the tests to
fail, and kunit hides a lot of the output for passing tests.

There is a comment in the code regarding this exact thing in
wm_adsp_fw_find_test_case_exit(), but then it goes on and
does it anyway. I suspect maybe there was a plan to override
wm_adsp_release_firmware_files() that got forgotten, as the
function appears to have hooks for kunit that aren't used. Anyway
for now implement a simple fix of freeing the filenames
locally. It is likely a more detailed fix will be implemented in
the near future but this should get things moving again.

Fixes: bf2d44d07d ("ASoC: wm_adsp: Add kunit test for firmware file search")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20260318103813.249190-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-18 11:21:15 +00:00
James Calligeros
4ebaf9d999 ASoC: codecs: cs42l84: set up PLL for more sample rates
Previously, this driver only advertised support for 48 kHz and
96 kHz sample rates, as there was no PLL configuration data
specified for any other sample rate/BCLK.

The CS42L84 is an Apple-specific variant of CS42L42. The PLL
configuration parameters for a variety of common BCLKs are
available in the latter's datasheet. What happens if we just
use those? As it turns out, they work just fine.

Fill out more PLL config parameters in the PLL config lookup
table, and advertise the corresponding sample rates to userspace.
This enables 44.1, 88.2, 176.4 and 192 kHz output and input.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Link: https://patch.msgid.link/20260314-cs42l84-rates-v2-1-ea8a5af52542@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-17 18:16:05 +00:00
Cédric Bellegarde
f8d51e903a ASoC: codecs: wcd-clsh: Always update buck/flyback on transitions on transitions
The WCD934x audio outputs (earpiece, headphone, speaker) share two power
supply converters, a buck and a flyback, managed by reference counters
(buck_users, flyback_users) in the Class-H controller.

The early return in wcd_clsh_ctrl_set_state() when nstate == ctrl->state
prevented _wcd_clsh_ctrl_set_state() from being called when switching
between outputs sharing the same state value. As a result, the buck and
flyback reference counters were never decremented on disable, leaving the
converters active and their counters out of sync with the actual hardware
state.

This caused audible distortion on the earpiece output and spurious MBHC
over-current protection interrupts on HPHL/HPHR during output switching.

Remove the early return so that CLSH_REQ_ENABLE and CLSH_REQ_DISABLE are
always dispatched, keeping the buck and flyback reference counters
consistent on every state transition.

Signed-off-by: Cédric Bellegarde <cedric.bellegarde@adishatz.org>
Link: https://patch.msgid.link/20260304141006.280894-1-cedric.bellegarde@adishatz.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 18:43:13 +00:00
Mark Brown
0861893cff ASoC: soc-component: re-add pcm_new()/pcm_free()
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> says:

Because old pcm_new()/pcm_free() didn't care about parameter component,
to avoid name collisions, we have added pcm_construct()/pcm_destruct() by
commit c64bfc9066 ("ASoC: soc-core: add new pcm_construct/pcm_destruct")

Because all driver switch to new pcm_construct()/pcm_destruct(), old
pcm_new()/pcm_free() were remoted by commit e9067bb502 ("ASoC:
soc-component: remove snd_pcm_ops from component driver")

But naming of pcm_construct()/pcm_destruct() are not goot. re-add
pcm_new()/pcm_free(), and switch to use it, again.

Because it has no functional significance, 1 patch is for 1 vender.
2026-03-16 13:38:10 +00:00
Kuninori Morimoto
a1f956d851 ASoC: codecs: rt5xxx-spi: name back to pcm_new()/pcm_free()
We have been used pcm_new()/pcm_free(), but switched to
pcm_construct()/pcm_destruct() to use extra parameters [1].

pcm_new()/free() had been removed [2], but each drivers are still
using such function naming. Let's name back to pcm_new()/pcm_free()
again.

[1] commit c64bfc9066 ("ASoC: soc-core: add new pcm_construct/pcmdestruct")
[2] commit e9067bb502 ("ASoC: soc-component: remove snd_pcm_ops from component driver")

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/87zf48jys3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 13:37:48 +00:00
Kuninori Morimoto
2a97dfda9e ASoC: codecs: cros_ec_codec: name back to pcm_new()/pcm_free()
We have been used pcm_new()/pcm_free(), but switched to
pcm_construct()/pcm_destruct() to use extra parameters [1].

pcm_new()/free() had been removed [2], but each drivers are still
using such function naming. Let's name back to pcm_new()/pcm_free()
again.

[1] commit c64bfc9066 ("ASoC: soc-core: add new pcm_construct/pcmdestruct")
[2] commit e9067bb502 ("ASoC: soc-component: remove snd_pcm_ops from component driver")

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/871phkldcq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 13:37:47 +00:00
Linus Walleij
cb15d8e6cb ASoC: codec: arizona: Convert to use GPIO descriptors
This converts the Arizona driver to use GPIO descriptors
exclusively, deletes the legacy code path an updates the
in-tree user of legacy GPIO.

The GPIO lines for mic detect polarity and headphone ID
detection are made exclusively descriptor-oriented. The
headphone ID detection could actually only be used by
the legacy GPIO code, but I converted it to use a
descriptor if someone would actually need it so we don't
just drop useful code.

The compatible "wlf,hpdet-id-gpio" is not in the device
tree bindings and only intended to be used by software
nodes if any. If someone insists I can try to add a
binding for it, but I doubt there is any real user so
it seems pointless.

Signed-off-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260314-asoc-arizona-v1-1-ecc9a165307c@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 13:11:47 +00:00
Teguh Sobirin
fc1fbafc18 ASoC: codecs: aw88166: Support device specific firmware
This driver currently loads firmware from a hardcoded path. Support
loading device specific firmware when provided by the boot firmware.

Signed-off-by: Teguh Sobirin <teguh@sobir.in>
Co-developed-by: Aaron Kling <webgeek1234@gmail.com>
Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
Link: https://patch.msgid.link/20260311-aw88166-fw-v2-1-8ef30dae3657@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 01:13:57 +00:00
Mark Brown
706d2dc026 ASoC: basic support for configuring bus keepers
James Calligeros <jcalligeros99@gmail.com> says:

This series introduces some infrastructure to allow platform drivers
to specify what a DAI should be doing when it is not active on the
bus. The primary use case for this is configuring bus keepers which
may be integrated into various codecs. The instigating use case for
this functionality is an interesting bus topology on Apple Silicon
laptops with multiple codecs.

Most Apple Silicon laptops have six codecs split into groups of
three, driving a pair of dual opposed woofers and a tweeter for
L/R stereo sound. These codecs report the voltage and current across
their connected voice coils back to the SoC via the SDOUT pin,
represented as PCM data sent via configurable TDM slots. This data is
used in conjunction with the connected speaker's Thiele/Small Parameters
to ensure that the speaker is not being driven to levels that would
permanently damage them. This is integrated into CoreAudio on macOS.
speakersafetyd[1] handles this for Linux.

All of the codec SDOUT pins are attached to a single receiver port
on the SoC's I2S peripheral, however are split across two physical
data lines (one each for the left and right codec groups). The receiver
has an OR gate in front of it, which is used to sum the two lines.

If at any point a codec is trying to transmit data, and the "opposite"
line ends up floating high, the transmitting codec's data will be
corrupted. We need to guarantee that the idle line stays idle.

In the downstream Asahi Linux kernel[2], we set up one codec in each
group to zero-fill or pull down its line while a codec on the opposite
line is actively transmitting. This is done entirely in the codec
driver, however this approach is over-fit for this one use case. This
sort of functionality may also be of use for other hardware, so following
previous mailing list discussions[3], I have tried to expose the
functionality in a more configurable and generic way.

I have integrated this approach into our downstream platform driver
and select Devicetrees as an example of how this mechanism is intended
to be used[4].

[1] https://github.com/AsahiLinux/speakersafetyd
[2] https://github.com/AsahiLinux/linux/tree/bits/070-audio
[3] https://lore.kernel.org/asahi/20250227-apple-codec-changes-v3-17-cbb130030acf@gmail.com/
[4] https://github.com/chadmed/tree/tdm-revised2

Link: https://patch.msgid.link/20260301-tdm-idle-slots-v3-0-c6ac5351489a@gmail.com
2026-03-16 01:13:07 +00:00
James Calligeros
af176d0787 ASoC: tas2770: expose SDOUT bus keeper via set_tdm_idle
TAS2770 includes a bus keeper which can be used to control the behaviour
of the SDOUT pin during specified TDM slots. The chip can either pull
the pin to ground, actively transmit zeroes, or keep the pin floating
(default/uninitialised behaviour).

Expose the bus keeper via the set_tdm_idle DAI op so that it can be
configured by consumers.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Link: https://patch.msgid.link/20260301-tdm-idle-slots-v3-7-c6ac5351489a@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 01:13:05 +00:00
James Calligeros
45573ee1f2 ASoC: tas2764: expose SDOUT bus keeper via set_tdm_idle operation
TAS2764, and the Apple-exclusive variant SN012776, include bus keepers
on the SDOUT pin that can be configured to alter the behaviour of the
SDOUT pin during specified TDM slots. The chip can either leave the
bus floating (default/uninitialised behaviour) or fill the specified
slots with zeroes.

Expose the SDOUT bus keeper and allow it to be configured using the
set_tdm_idle DAI op. The mask must be cropped to only cover slots
valid for the configured BCLK ratio, so introduce a set_bclk_ratio
op that properly configures this.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Link: https://patch.msgid.link/20260301-tdm-idle-slots-v3-6-c6ac5351489a@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 01:13:04 +00:00
Mark Brown
3e9cda2f4a ASoC: amd: Move to GPIO descriptors
Linus Walleij <linusw@kernel.org> says:

After a quick look and test-compile I can determine that
all of these drivers include <linux/gpio.h> for no reason
whatsoever, so fixing it is low hanging fruit.

Link: https://patch.msgid.link/20260314-asoc-amd-v1-0-31afed06e022@kernel.org
2026-03-16 01:11:23 +00:00
Guangshuo Li
fe757092d2 ASoC: sma1307: fix double free of devm_kzalloc() memory
A previous change added NULL checks and cleanup for allocation
failures in sma1307_setting_loaded().

However, the cleanup for mode_set entries is wrong. Those entries are
allocated with devm_kzalloc(), so they are device-managed resources and
must not be freed with kfree(). Manually freeing them in the error path
can lead to a double free when devres later releases the same memory.

Drop the manual kfree() loop and let devres handle the cleanup.

Fixes: 0ec6bd1670 ("ASoC: sma1307: Add NULL check in sma1307_setting_loaded()")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Link: https://patch.msgid.link/20260313040611.391479-1-lgs201920130244@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-16 00:05:44 +00:00
Mark Brown
00da2edc64 ASoC: wm_adsp: Some improvements to firmware file
Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>:

This series makes some improvements to the code that searches for firmware
files.

Patch 1 is a trivial patch to remove an unused function argument, before
   adding any new code that uses this API.

Patches 2..4 add KUnit testing to prove that the subsequent changes don't
   break anything.

The remaining patches remove duplicated code and clean up some of the
implementation.
2026-03-12 11:29:05 +00:00
Richard Fitzgerald
48863104d2 ASoC: cs35l56: Support clock stop mode 1 if enabled in ACPI
Report the ability to support SoundWire clock-stop mode 1 if this is
enabled in ACPI. Mode 1 allows the device to lose state, so it can
reduce power consumption in clock-stop. Also add the necessary
handling to wait for re-enumeration on resume.

This does not use sdw_slave_read_prop(), because that also fills in
other properties from ACPI that were not previously set by the driver
and this has been observed to break some systems. Instead, the
"mipi-sdw-clock-stop-mode1-supported" property is checked directly.

When a SoundWire peripheral has been put into clock-stop mode 1 it
must be re-enumerated after the clock is restarted. A new flag
sdw_in_clock_stop_1 is set to true in cs35l56_sdw_clk_stop() if the
SoundWire core notifies that it is entering clock-stop 1.
cs35l56_sdw_handle_unattach() will wait for re-enumeration if
sdw_in_clock_stop_1 is true.

sdw_in_clock_stop_1 will be reset to false when an ATTACH notification
is received in cs35l56_sdw_update_status().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260311142153.2201761-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-11 16:17:10 +00:00
Peter Ujfalusi
30e4b2290c ASoC: codecs: rt1011: Use component to get the dapm context in spk_mode_put
The correct helper to use in rt1011_recv_spk_mode_put() to retrieve the
DAPM context is snd_soc_component_to_dapm(), from kcontrol we will
receive NULL pointer.

Closes: https://github.com/thesofproject/linux/issues/5691
Fixes: 5b35bb517f ("ASoC: codecs: rt1011: convert to snd_soc_dapm_xxx()")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20260310065350.18921-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 19:32:56 +00:00
Pengpeng Hou
4ba5c63778 ASoC: da7219: scope AAD suspend and resume helpers to CONFIG_PM
In current linux.git, da7219_aad_suspend() and
da7219_aad_resume() are defined and declared unconditionally. However,
their only in-tree callers are the component PM callbacks in da7219.c,
which are already guarded by #ifdef CONFIG_PM.

This inconsistency leads to unnecessary code inclusion and potential
compiler warnings when CONFIG_PM is disabled. Match the helper
declarations and definitions to the callers' scope and provide no-op
!CONFIG_PM stubs in the header.

Signed-off-by: Pengpeng Hou <pengpeng.hou@isrc.iscas.ac.cn>
Link: https://patch.msgid.link/20260310082348.743716-1-pengpeng.hou@isrc.iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 19:32:42 +00:00
Richard Fitzgerald
8fc5c78951 ASoC: wm_adsp: Combine some similar code in firmware file search
In wm_adsp_request_firmware_files() squash the if (system_name && suffix)
and the following if (system_name) blocks together. This removes some
duplicated code.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-11-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:57 +00:00
Richard Fitzgerald
7bca3ca55e ASoC: wm_adsp: Use a struct to pass around firmware struct and filename
Bundle the pointers to struct firmware and its filename into a new
struct wm_adsp_fw_files. This simplifies passing these pointers around.

Changes are also needed to the test cases in wm_adsp_fw_find_test.c that
use this API.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-10-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:56 +00:00
Richard Fitzgerald
d8a4c96082 ASoC: wm_adsp: Add KUnit test cases for '/' in firmware filenames
Add test cases that '/' in the system name or ALSA prefix are converted
to '-' in the firmware filename.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-9-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:55 +00:00
Richard Fitzgerald
66170cc7ed ASoC: wm_adsp: Convert '/' to '-' when normalizing firmware filenames
Don't preserve '/' in firmware filename fields - convert it to '-' like
other punctuation characters.

The code originally normalized the entire string, including the
directory prefix. To prevent breaking the directory it had to preserve
'/' characters in the name, but this meant that the system name and ALSA
prefix must not contain those characters.

It's trivial to skip the directory name prefix and start the
normalization after it, and that means the normalization does not need
to make a special case for '/'.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-8-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:54 +00:00
Richard Fitzgerald
f8f0c68c75 ASoC: wm_adsp: Use consistent error checks in wm_adsp_request_firmware_files()
Use a consistent pattern of error checking in
wm_adsp_request_firmware_files().

- The integer return value of wm_adsp_request_firmware_file() reports
  unrecoverable errors, for example -ENOMEM.

- A NULL struct firmware pointer is a valid result. This not an error,
  not all DSPs require both files, some may not require any files.

Previously wm_adsp_request_firmware_files() was using a mix of checking
the return value and checking the struct firmware pointer to determine
whether a file was found. It wasn't checking for unrecoverable errors.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-7-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:53 +00:00
Richard Fitzgerald
2c7c270253 ASoC: wm_adsp: Remove duplicated code to find firmware file
The 3rd search case in wm_adsp_request_firmware_files() does exactly the
same bin file searches as the case immediately above it. Merge the
conditional from the 3rd case into the second case so the duplicated code
can be removed.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-6-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:52 +00:00
Richard Fitzgerald
bf2d44d07d ASoC: wm_adsp: Add kunit test for firmware file search
Add KUnit testing of the wm_adsp code that searches for firmware files.
Also make the SND_SOC_WM_ADSP Kconfig symbol visible if KUNIT is enabled
so that wm_adsp can be manually included for KUnit testing.

The firmware filename is composed of several fields, some of which are
optional, and there is a search algorithm to fallback from specific to
generic versions of firmware for a device. This KUnit test verifies that
wm_adsp is searching for the correct sequence of filenames.

The are two ways of testing this, and both are used in this KUnit test.

1. Trap the calls to firmware_request_nowarn() and test that the sequence
   of filenames request is correct.

   This is the most thorough test because it proves that exactly the
   expected filenames are requested, in the correct order.

   But it doesn't fully cover regression testing. If a change to the search
   algorithm changes the expected sequence of requested files, the test
   must also be changed to expect that new sequence. If the expectation is
   wrong, the tests can pass (because the search order is as expected)
   while picking a different file in some cases from what it did before the
   change.

2. Test which file is picked from a simulated directory of files.

   This is better for regression testing because it is independent of the
   search algorithm. It does not need to change if the search algorithm
   changes. It is not testing exactly which files the algorithm searches
   for, only which file it eventually picks from a given set of available
   files.

   In other words, the regression test is: does it still pick the same file
   from the same directory of files?

   But it is impractical for thorough testing. It doesn't prove that
   exactly the correct files were searched for, unless it was to test with
   every possible combination of file names and directory content that
   could ever exist. Clearly this is impossible to implement, since the
   number of combations of possible valid filenames in a directory and
   number of files in a directory is astronomically large.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260310141817.1871794-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-03-10 14:52:51 +00:00