linux-block.git
8 months agoALSA: hda: i915: Allow override of gpu binding.
Maarten Lankhorst [Mon, 9 Oct 2023 11:54:30 +0000 (13:54 +0200)]
ALSA: hda: i915: Allow override of gpu binding.

Selecting CONFIG_DRM selects CONFIG_VIDEO_NOMODESET, which exports
video_firmware_drivers_only(). This can be used as a first
approximation on whether i915 will be available. It's safe to use as
this is only built when CONFIG_SND_HDA_I915 is selected by CONFIG_I915.

It's not completely fool proof, as you can boot with "nomodeset
i915.modeset=1" to make i915 load regardless, or use
"i915.force_probe=!*" to never load i915, but the common case of
booting with nomodeset to disable all GPU drivers this will work as
intended.

Because of this, we add an extra module parameter,
snd_hda_core.gpu_bind that can be used to signal users intent.
-1 follows nomodeset, 0 disables binding, 1 forces wait/-EPROBE_DEFER
on binding.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20231009115437.99976-7-maarten.lankhorst@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: Intel: Fix error handling in azx_probe()
Maarten Lankhorst [Mon, 9 Oct 2023 11:54:29 +0000 (13:54 +0200)]
ALSA: hda: Intel: Fix error handling in azx_probe()

Add missing pci_set_drv to NULL call on error.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20231009115437.99976-6-maarten.lankhorst@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: SOF: Intel: Fix error handling in hda_init()
Maarten Lankhorst [Mon, 9 Oct 2023 11:54:28 +0000 (13:54 +0200)]
ASoC: SOF: Intel: Fix error handling in hda_init()

The hda_codec_i915_init() errors are ignored in
hda_init() so it can never return -EPROBE_DEFER.

Fix this before we move the call to hda_init() from the
deferred probe to early probe.

While at it, also fix error handling when hda_dsp_ctrl_get_caps
fails.

Suggested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20231009115437.99976-5-maarten.lankhorst@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: SOF: Intel: hda: start splitting the probe
Pierre-Louis Bossart [Mon, 9 Oct 2023 11:54:27 +0000 (13:54 +0200)]
ASoC: SOF: Intel: hda: start splitting the probe

This patch moves the initial parts of the probe to the probe_early()
callback, which provides a much faster decision on whether the SOF
driver shall deal with a specific platform or yield to other Intel
drivers.

This is a limited functionality change, the bigger change is to move
the i915/Xe initialization to the probe_early().

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20231009115437.99976-4-maarten.lankhorst@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: SOF: core: Add probe_early and remove_late callbacks
Pierre-Louis Bossart [Mon, 9 Oct 2023 11:54:26 +0000 (13:54 +0200)]
ASoC: SOF: core: Add probe_early and remove_late callbacks

The existing DSP probe may be handled in a workqueue to allow for
extra time, typically for the i915 request_module and HDAudio codec
handling.

With the upcoming changes for i915/Xe driver relying on the
-EPROBE_DEFER mechanism, we need to have a first pass of the probe
which cannot be pushed to a workqueue. Introduce 2 new optional
callbacks.

probe_early is called before the workqueue runs. remove_late may be
called from the workqueue if load is unsuccesful, but will otherwise
be called on module unload.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20231009115437.99976-3-maarten.lankhorst@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: SOF: core: Ensure sof_ops_free() is still called when probe never ran.
Maarten Lankhorst [Mon, 9 Oct 2023 11:54:25 +0000 (13:54 +0200)]
ASoC: SOF: core: Ensure sof_ops_free() is still called when probe never ran.

In an effort to not call sof_ops_free twice, we stopped running it when
probe was aborted.

Check the result of cancel_work_sync to see if this was the case.

Fixes: 31bb7bd9ffee ("ASoC: SOF: core: Only call sof_ops_free() on remove if the probe was successful")
Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://lore.kernel.org/r/20231009115437.99976-2-maarten.lankhorst@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoMerge branch 'for-linus' into for-next
Takashi Iwai [Thu, 19 Oct 2023 12:51:07 +0000 (14:51 +0200)]
Merge branch 'for-linus' into for-next

For applying HD-audio EPROBE_DEFER series cleanly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoMerge tag 'asoc-fix-v6.6-rc6' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Wed, 18 Oct 2023 18:02:46 +0000 (20:02 +0200)]
Merge tag 'asoc-fix-v6.6-rc6' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v6.6

A fairly large set of fixes here but all driver specific, the biggest
block is Johan's work shaking out issues with device setup and teardown
for the wcd938x driver which is a relatively large but clearly broken
down set of changes.

There is one core helper function added as part of a fix for wsa-macro.

8 months agoASoC: da7219: Correct the process of setting up Gnd switch in AAD
David Rau [Tue, 17 Oct 2023 02:12:58 +0000 (10:12 +0800)]
ASoC: da7219: Correct the process of setting up Gnd switch in AAD

Enable Gnd switch to improve stability when Jack insert event
occurs, and then disable Gnd switch after Jack type detection
is finished.

Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com>
Link: https://lore.kernel.org/r/20231017021258.5929-1-David.Rau.opensource@dm.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoALSA: hda/realtek - Fixed ASUS platform headset Mic issue
Kailang Yang [Tue, 17 Oct 2023 07:30:24 +0000 (15:30 +0800)]
ALSA: hda/realtek - Fixed ASUS platform headset Mic issue

ASUS platform Headset Mic was disable by default.
Assigned verb table for Mic pin will enable it.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1155d914c20c40569f56d36c79254879@realtek.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda/realtek: Add quirk for ASUS ROG GU603ZV
Artem Borisov [Sat, 14 Oct 2023 07:50:42 +0000 (10:50 +0300)]
ALSA: hda/realtek: Add quirk for ASUS ROG GU603ZV

Enables the SPI-connected Cirrus amp and the required pins
for headset mic detection.

As of BIOS version 313 it is still necessary to modify the
ACPI table to add the related _DSD properties:
  https://gist.github.com/Flex1911/1bce378645fc95a5743671bd5deabfc8

Signed-off-by: Artem Borisov <dedsa2002@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20231014075044.17474-1-dedsa2002@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda/relatek: Enable Mute LED on HP Laptop 15s-fq5xxx
Luka Guzenko [Mon, 16 Oct 2023 22:13:28 +0000 (00:13 +0200)]
ALSA: hda/relatek: Enable Mute LED on HP Laptop 15s-fq5xxx

This HP Laptop uses ALC236 codec with COEF 0x07 controlling the
mute LED. Enable existing quirk for this device.

Signed-off-by: Luka Guzenko <l.guzenko@web.de>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20231016221328.1521674-1-l.guzenko@web.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: dwc: Fix non-DT instantiation
Mark Brown [Fri, 13 Oct 2023 17:37:33 +0000 (18:37 +0100)]
ASoC: dwc: Fix non-DT instantiation

Commit d6d6c513f5d2 ("ASoC: dwc: Use ops to get platform data")
converted the DesignWare I2S driver to use a DT specific function to
obtain platform data but this breaks at least non-DT systems such as
AMD.  Revert it.

Fixes: d6d6c513f5d2 ("ASoC: dwc: Use ops to get platform data")
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20231013-asoc-fix-dwc-v1-1-63211bb746b9@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: tas2780: Fix log of failed reset via I2C.
Roy Chateau [Fri, 13 Oct 2023 11:02:39 +0000 (13:02 +0200)]
ASoC: codecs: tas2780: Fix log of failed reset via I2C.

Correctly log failures of reset via I2C.

Signed-off-by: Roy Chateau <roy.chateau@mep-info.com>
Link: https://lore.kernel.org/r/20231013110239.473123-1-roy.chateau@mep-info.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: rt5650: fix the wrong result of key button
Shuming Fan [Fri, 13 Oct 2023 09:45:25 +0000 (17:45 +0800)]
ASoC: rt5650: fix the wrong result of key button

The RT5650 should enable a power setting for button detection to avoid the wrong result.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20231013094525.715518-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: cs42l42: Fix missing include of gpio/consumer.h
Richard Fitzgerald [Wed, 11 Oct 2023 13:48:53 +0000 (14:48 +0100)]
ASoC: cs42l42: Fix missing include of gpio/consumer.h

The call to gpiod_set_value_cansleep() in cs42l42_sdw_update_status()
needs the header file gpio/consumer.h to be included.

This was introduced by commit 2d066c6a7865 ("ASoC: cs42l42: Avoid stale
SoundWire ATTACH after hard reset")

and caused error:
    sound/soc/codecs/cs42l42-sdw.c:374:4: error: implicit declaration of
    function ‘gpiod_set_value_cansleep’;
    did you mean gpio_set_value_cansleep’?

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2d066c6a7865 ("ASoC: cs42l42: Avoid stale SoundWire ATTACH after hard reset")
Link: https://lore.kernel.org/r/20231011134853.20059-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: cs42l43: Update values for bias sense
Charles Keepax [Tue, 10 Oct 2023 10:24:25 +0000 (11:24 +0100)]
ASoC: cs42l43: Update values for bias sense

Due to an error in the datasheet the bias sense values currently don't
match the hardware. Whilst this is a change to the binding no devices
have yet shipped so updating the binding will not cause any issues.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231010102425.3662364-2-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: dt-bindings: cirrus,cs42l43: Update values for bias sense
Charles Keepax [Tue, 10 Oct 2023 10:24:24 +0000 (11:24 +0100)]
ASoC: dt-bindings: cirrus,cs42l43: Update values for bias sense

Due to an error in the datasheet the bias sense values currently don't
match the hardware. Whilst this is a change to the binding no devices
have yet shipped so updating the binding will not cause any issues.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231010102425.3662364-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: cs35l56: ASP1 DOUT must default to Hi-Z when not transmitting
Richard Fitzgerald [Mon, 9 Oct 2023 15:34:12 +0000 (16:34 +0100)]
ASoC: cs35l56: ASP1 DOUT must default to Hi-Z when not transmitting

The ASP1 DOUT line must be defaulted to be high-impedance when
it is not actually transmitting data for an active channel.

In non-SoundWire modes ASP1 will usually be shared by multiple
amps so each amp must only drive the line during the slot for
an enabled TX channel.

In SoundWire mode a custom firmware can use ASP1 as a secondary
chip-to-chip audio link or as GPIO. It should be defaulted to
high-impedance since by default the purpose of this pin is not
known.

Backport note:
On kernel versions before 6.6 the cs35l56->base.regmap argument
to regmap_set_bits() must be changed to cs35l56->regmap.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e49611252900 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
Link: https://lore.kernel.org/r/20231009153412.30380-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: fix widget name comparisons
Mark Brown [Mon, 9 Oct 2023 17:40:09 +0000 (18:40 +0100)]
ASoC: codecs: fix widget name comparisons

Merge series from Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>:

Some codec drivers compare widget names with strcmp, ignoring the component
name prefix.  If prefix is used, the comparisons start failing.
Add a helper to fix the issue.

8 months agoASoC: codecs: wcd938x: fix probe and bind error
Mark Brown [Mon, 9 Oct 2023 17:40:01 +0000 (18:40 +0100)]
ASoC: codecs: wcd938x: fix probe and bind error

Merge series from Johan Hovold <johan+linaro@kernel.org>:

The wcd938x codec driver happily ignores error handling, something which
has bitten us in the past when we hit a probe deferral:

https://lore.kernel.org/lkml/20230705123018.30903-1-johan+linaro@kernel.org/

Fix up the remaining probe and component bind paths that left resources
allocated and registered after errors to avoid similar future issues.

8 months agoASoC: pxa: fix a memory leak in probe()
Dan Carpenter [Thu, 5 Oct 2023 14:00:24 +0000 (17:00 +0300)]
ASoC: pxa: fix a memory leak in probe()

Free the "priv" pointer before returning the error code.

Fixes: 90eb6b59d311 ("ASoC: pxa-ssp: add support for an external clock in devicetree")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/84ac2313-1420-471a-b2cb-3269a2e12a7c@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: cs35l56: Fix illegal use of init_completion()
Richard Fitzgerald [Fri, 6 Oct 2023 16:44:05 +0000 (17:44 +0100)]
ASoC: cs35l56: Fix illegal use of init_completion()

Fix cs35l56_patch() to call reinit_completion() to reinitialize
the completion object.

It was incorrectly using init_completion().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e49611252900 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56")
Link: https://lore.kernel.org/r/20231006164405.253796-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x-sdw: fix runtime PM imbalance on probe errors
Johan Hovold [Tue, 3 Oct 2023 15:55:58 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x-sdw: fix runtime PM imbalance on probe errors

Make sure to balance the runtime PM operations, including the disable
count, on probe errors and on driver unbind.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-8-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x-sdw: fix use after free on driver unbind
Johan Hovold [Tue, 3 Oct 2023 15:55:57 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x-sdw: fix use after free on driver unbind

Make sure to deregister the component when the driver is being unbound
and before the underlying device-managed resources are freed.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-7-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x: fix runtime PM imbalance on remove
Johan Hovold [Tue, 3 Oct 2023 15:55:56 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x: fix runtime PM imbalance on remove

Make sure to balance the runtime PM operations, including the disable
count, on driver unbind.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-6-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x: fix regulator leaks on probe errors
Johan Hovold [Tue, 3 Oct 2023 15:55:55 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x: fix regulator leaks on probe errors

Make sure to disable and free the regulators on probe errors and on
driver unbind.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-5-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x: fix resource leaks on bind errors
Johan Hovold [Tue, 3 Oct 2023 15:55:54 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x: fix resource leaks on bind errors

Add the missing code to release resources on bind errors, including the
references taken by wcd938x_sdw_device_get() which also need to be
dropped on unbind().

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-4-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x: fix unbind tear down order
Johan Hovold [Tue, 3 Oct 2023 15:55:53 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x: fix unbind tear down order

Make sure to deregister the component before tearing down the resources
it depends on during unbind().

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-3-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wcd938x: drop bogus bind error handling
Johan Hovold [Tue, 3 Oct 2023 15:55:52 +0000 (17:55 +0200)]
ASoC: codecs: wcd938x: drop bogus bind error handling

Drop the bogus error handling for a soundwire device backcast during
bind() that cannot fail.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-2-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: codecs: wsa-macro: handle component name prefix
Krzysztof Kozlowski [Tue, 3 Oct 2023 15:57:10 +0000 (17:57 +0200)]
ASoC: codecs: wsa-macro: handle component name prefix

When comparing widget names in wsa_macro_spk_boost_event(), consider
also the component's name prefix.  Otherwise the WSA codec won't have
proper mixer setup resulting in no sound playback through speakers.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20231003155710.821315-3-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoASoC: soc-dapm: Add helper for comparing widget name
Krzysztof Kozlowski [Tue, 3 Oct 2023 15:57:09 +0000 (17:57 +0200)]
ASoC: soc-dapm: Add helper for comparing widget name

Some drivers use one event callback for multiple widgets but still need
to perform a bit different actions based on actual widget.  This is done
by comparing widget name, however drivers tend to miss possible name
prefix.  Add a helper to solve common mistakes.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20231003155710.821315-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
8 months agoALSA: usb-audio: Fix microphone sound on Nexigo webcam.
Christos Skevis [Fri, 6 Oct 2023 15:53:30 +0000 (17:53 +0200)]
ALSA: usb-audio: Fix microphone sound on Nexigo webcam.

I own an external usb Webcam, model NexiGo N930AF, which had low mic volume and
inconsistent sound quality. Video works as expected.

(snip)
[  +0.047857] usb 5-1: new high-speed USB device number 2 using xhci_hcd
[  +0.003406] usb 5-1: New USB device found, idVendor=1bcf, idProduct=2283, bcdDevice=12.17
[  +0.000007] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0.000004] usb 5-1: Product: NexiGo N930AF FHD Webcam
[  +0.000003] usb 5-1: Manufacturer: SHENZHEN AONI ELECTRONIC CO., LTD
[  +0.000004] usb 5-1: SerialNumber: 20201217011
[  +0.003900] usb 5-1: Found UVC 1.00 device NexiGo N930AF FHD Webcam (1bcf:2283)
[  +0.025726] usb 5-1: 3:1: cannot get usb sound sample rate freq at ep 0x86
[  +0.071482] usb 5-1: 3:2: cannot get usb sound sample rate freq at ep 0x86
[  +0.004679] usb 5-1: 3:3: cannot get usb sound sample rate freq at ep 0x86
[  +0.051607] usb 5-1: Warning! Unlikely big volume range (=4096), cval->res is probably wrong.
[  +0.000005] usb 5-1: [7] FU [Mic Capture Volume] ch = 1, val = 0/4096/1

Set up quirk cval->res to 16 for 256 levels,
Set GET_SAMPLE_RATE quirk flag to stop trying to get the sample rate.
Confirmed that happened anyway later due to the backoff mechanism, after 3 failures

All audio stream on device interfaces share the same values,
apart from wMaxPacketSize and tSamFreq :

(snip)
Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       3
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           8
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             1
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            1 Discrete
        tSamFreq[ 0]        44100
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x005c  1x 92 bytes
        bInterval               4
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
(snip)

Based on the usb data about manufacturer, SPCA2281B3 is the most likely controller IC
Manufacturer does not provide link for datasheet nor detailed specs.
No way to confirm if the firmware supports any other way of getting the sample rate.

Testing patch provides consistent good sound recording quality and volume range.

(snip)
[  +0.045764] usb 5-1: new high-speed USB device number 2 using xhci_hcd
[  +0.106290] usb 5-1: New USB device found, idVendor=1bcf, idProduct=2283, bcdDevice=12.17
[  +0.000006] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0.000004] usb 5-1: Product: NexiGo N930AF FHD Webcam
[  +0.000003] usb 5-1: Manufacturer: SHENZHEN AONI ELECTRONIC CO., LTD
[  +0.000004] usb 5-1: SerialNumber: 20201217011
[  +0.043700] usb 5-1: set resolution quirk: cval->res = 16
[  +0.002585] usb 5-1: Found UVC 1.00 device NexiGo N930AF FHD Webcam (1bcf:2283)

Signed-off-by: Christos Skevis <xristos.thes@gmail.com>
Link: https://lore.kernel.org/r/20231006155330.399393-1-xristos.thes@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: scarlett2: Add Focusrite Clarett 2Pre and 4Pre USB support
Geoffrey D. Bennett [Sat, 7 Oct 2023 11:33:04 +0000 (22:03 +1030)]
ALSA: scarlett2: Add Focusrite Clarett 2Pre and 4Pre USB support

It has been confirmed that all devices in the Focusrite Clarett USB
series work the same as the devices in the Clarett+ series. Add the
missing PIDs to enable support for the Clarett 2Pre and 4Pre USB.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/ZSFB8EVTG1PK1eq/@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: Add code_loading parameter to stream setup
Cezary Rojewski [Fri, 6 Oct 2023 10:28:57 +0000 (12:28 +0200)]
ALSA: hda: Add code_loading parameter to stream setup

AudioDSP firmware is the one who kicks SDxFIFOS calculation when a
stream is decoupled mode. During firmware bring up procedure, there is
no firmware running and the code-loading stream is always a decoupled
one. So, there is none to trigger the calculation and we end up with
false-positive timeout (-110) messages.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20231006102857.749143-4-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: Fix stream fifo_size initialization
Cezary Rojewski [Fri, 6 Oct 2023 10:28:56 +0000 (12:28 +0200)]
ALSA: hda: Fix stream fifo_size initialization

SDxFIFOS register indicates the fifo size directly. There is no need to
modify the value after reading the register.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20231006102857.749143-3-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: Fix possible null-ptr-deref when assigning a stream
Cezary Rojewski [Fri, 6 Oct 2023 10:28:55 +0000 (12:28 +0200)]
ALSA: hda: Fix possible null-ptr-deref when assigning a stream

While AudioDSP drivers assign streams exclusively of HOST or LINK type,
nothing blocks a user to attempt to assign a COUPLED stream. As
supplied substream instance may be a stub, what is the case when
code-loading, such scenario ends with null-ptr-deref.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20231006102857.749143-2-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoMerge tag 'asoc-fix-v6.6-rc5' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Fri, 6 Oct 2023 12:28:12 +0000 (14:28 +0200)]
Merge tag 'asoc-fix-v6.6-rc5' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: More fixes for v6.6

Some additional fixes for v6.6, some fairly unremarkable driver specific
ones and a couple of minor core fixes for error handling and improved
logging.

8 months agoALSA: aoa: Replace asm/prom.h with explicit includes
Rob Herring [Tue, 3 Oct 2023 16:32:02 +0000 (11:32 -0500)]
ALSA: aoa: Replace asm/prom.h with explicit includes

asm/prom.h should not be included directly as it no longer contains
anything drivers need. Drivers should include of.h and/or other headers
which were getting implicitly included.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20231003163209.770750-1-robh@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: aloop: Add control element for getting the access mode
Ivan Orlov [Wed, 27 Sep 2023 11:35:55 +0000 (12:35 +0100)]
ALSA: aloop: Add control element for getting the access mode

Add new control element 'PCM Slave Access Mode' which shows the access
mode (interleaved/non-interleaved) for the PCM playing device. Add
corresponding control change notification calls.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230927113555.14877-2-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: aloop: Add support for the non-interleaved access mode
Ivan Orlov [Wed, 27 Sep 2023 11:35:54 +0000 (12:35 +0100)]
ALSA: aloop: Add support for the non-interleaved access mode

The current version of the loopback driver supports interleaved access
mode only. This patch introduces support for the non-interleaved
access mode.

When in the interleaved mode, the 'copy_play_buf' function copies data
from the playback to the capture buffer using one memcpy call. This call
copies samples for multiple, interleaved channels.

In the non-interleaved mode we have multiple channel buffers, so we have
to perform multiple memcpy calls to copy samples channel after channel.

Add new function called 'copy_play_buf_part_n', which copies a part of
each channel buffer from playback to capture. Modify the 'copy_play_buf'
to use the corresponding memory copy function(just memcpy /
copy_play_buf_part_n) depending on the access mode.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230927113555.14877-1-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: intel8x0m: fix name of SIS7013 sound chip in comment
Thomas Perl [Wed, 27 Sep 2023 07:17:32 +0000 (07:17 +0000)]
ALSA: intel8x0m: fix name of SIS7013 sound chip in comment

While grep'ing for SIS7012, I noticed that there is
only one reference to it in sound/pci/intel8x0m.c,
while most of its code lives in sound/pci/intel8x0.c.

This probably was a simple copy'n'paste mistake, as
the sound/pci/intel8x0m.c driver implements support
for SIS7013 (see DEVICE_SIS), and the two devices
seem to share the same behavior / registers.

Signed-off-by: Thomas Perl <m@thp.io>
Link: https://lore.kernel.org/r/5E4B5CA1-1109-4C82-A581-838ACF19A15D@thp.io
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: scarlett2: Add Focusrite Clarett+ 2Pre and 4Pre support
Geoffrey D. Bennett [Tue, 26 Sep 2023 15:41:30 +0000 (01:11 +0930)]
ALSA: scarlett2: Add Focusrite Clarett+ 2Pre and 4Pre support

The Focusrite Clarett+ series uses the same protocol as the Scarlett
Gen 2 and Gen 3 series. This patch adds support for the Clarett+ 2Pre
and Clarett+ 4Pre similarly to the existing 8Pre support by adding
appropriate entries to the scarlett2 driver.

The Clarett 2Pre USB and 4Pre USB presumably use the same protocol as
well, so support for them can easily be added if someone can test.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/ZRL7qjC3tYQllT3H@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: Intel: Skylake: Use helper to setup HOST stream
Cezary Rojewski [Tue, 26 Sep 2023 08:06:23 +0000 (10:06 +0200)]
ASoC: Intel: Skylake: Use helper to setup HOST stream

snd_hdac_ext_host_stream_setup() abstracts the procedure details away.
Simplify the code by using it.

Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230926080623.43927-5-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: Intel: avs: Use helper to setup HOST stream
Cezary Rojewski [Tue, 26 Sep 2023 08:06:22 +0000 (10:06 +0200)]
ASoC: Intel: avs: Use helper to setup HOST stream

snd_hdac_ext_host_stream_setup() abstracts the procedure details away.
Simplify the code by using it.

Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230926080623.43927-4-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: Introduce HOST stream setup mechanism
Cezary Rojewski [Tue, 26 Sep 2023 08:06:21 +0000 (10:06 +0200)]
ALSA: hda: Introduce HOST stream setup mechanism

HDAudio stream setup procedure differs between revisions of the
controller device. Currently the differences are handled directly within
AudioDSP platform drivers with if-statements. Implement a more generic
approach and expose a function that a platform driver may use to ensure
the correct procedure is followed each time.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230926080623.43927-3-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: Poll SDxFIFOS after programming SDxFMT
Cezary Rojewski [Tue, 26 Sep 2023 08:06:20 +0000 (10:06 +0200)]
ALSA: hda: Poll SDxFIFOS after programming SDxFMT

Software shall read SDxFIFOS calculated by the hardware and notify if
invalid value is programmed before continuing the stream preparation.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230926080623.43927-2-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda/realtek: Change model for Intel RVP board
Kailang Yang [Fri, 6 Oct 2023 06:47:37 +0000 (14:47 +0800)]
ALSA: hda/realtek: Change model for Intel RVP board

Intel RVP board (0x12cc) has Headset Mic issue for reboot.
If system plugged headset when system reboot the headset Mic was gone.

Fixes: 1a93f10c5b12 ("ALSA: hda/realtek: Add "Intel Reference board" and "NUC 13" SSID in the ALC256")
Signed-off-by: Kailang Yang <kailang@realtek.com>
Link: https://lore.kernel.org/r/28112f54c0c6496f97ac845645bc0256@realtek.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: usb-audio: Fix microphone sound on Opencomm2 Headset
WhaleChang [Fri, 6 Oct 2023 04:48:49 +0000 (12:48 +0800)]
ALSA: usb-audio: Fix microphone sound on Opencomm2 Headset

When a Opencomm2 Headset is connected to a Bluetooth USB dongle,
the audio playback functions properly, but the microphone does not work.

In the dmesg logs, there are messages indicating that the init_pitch
function fails when the capture process begins.

The microphone only functions when the ep pitch control is not set.

Toggling the pitch control off bypasses the init_piatch function
and allows the microphone to work.

Signed-off-by: WhaleChang <whalechang@google.com>
Link: https://lore.kernel.org/r/20231006044852.4181022-1-whalechang@google.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoALSA: hda: cs35l41: Cleanup and fix double free in firmware request
Stefan Binding [Tue, 3 Oct 2023 14:21:38 +0000 (15:21 +0100)]
ALSA: hda: cs35l41: Cleanup and fix double free in firmware request

There is an unlikely but possible double free when loading firmware,
and a missing free calls if a firmware is successfully requested but
the coefficient file request fails, leading to the fallback firmware
request occurring without clearing the previously loaded firmware.

Fixes: cd40dad2ca91 ("ALSA: hda: cs35l41: Ensure firmware/tuning pairs are always loaded")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202309291331.0JUUQnPT-lkp@intel.com/
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231003142138.180108-1-sbinding@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
8 months agoASoC: dt-bindings: fsl,micfil: Document #sound-dai-cells
Fabio Estevam [Wed, 4 Oct 2023 12:29:35 +0000 (09:29 -0300)]
ASoC: dt-bindings: fsl,micfil: Document #sound-dai-cells

imx8mp.dtsi passes #sound-dai-cells = <0> in the micfil node.

Document #sound-dai-cells to fix the following schema warning:

audio-controller@30ca0000: '#sound-dai-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/sound/fsl,micfil.yaml#

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Adam Ford <aford173@gmail.com>
Link: https://lore.kernel.org/r/20231004122935.2250889-1-festevam@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoASoC: amd: yc: Fix non-functional mic on Lenovo 82YM
Sven Frotscher [Wed, 27 Sep 2023 22:36:07 +0000 (00:36 +0200)]
ASoC: amd: yc: Fix non-functional mic on Lenovo 82YM

Like the Lenovo 82TL, 82V2, 82QF and 82UG, the 82YM (Yoga 7 14ARP8)
requires an entry in the quirk list to enable the internal microphone.
The latter two received similar fixes in commit 1263cc0f414d
("ASoC: amd: yc: Fix non-functional mic on Lenovo 82QF and 82UG").

Fixes: c008323fe361 ("ASoC: amd: yc: Fix a non-functional mic on Lenovo 82SJ")
Cc: stable@vger.kernel.org
Signed-off-by: Sven Frotscher <sven.frotscher@gmail.com>
Link: https://lore.kernel.org/r/20230927223758.18870-1-sven.frotscher@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoASoC: tlv320adc3xxx: BUG: Correct micbias setting
Antoine Gennart [Fri, 29 Sep 2023 13:01:17 +0000 (15:01 +0200)]
ASoC: tlv320adc3xxx: BUG: Correct micbias setting

The micbias setting for tlv320adc can also have the value '3' which
means that the micbias ouput pin is connected to the input pin AVDD.

Signed-off-by: Antoine Gennart <gennartan@disroot.org>
Link: https://lore.kernel.org/r/20230929130117.77661-1-gennartan@disroot.org
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoASoC: rt5682: Fix regulator enable/disable sequence
Zhang Shurong [Sat, 30 Sep 2023 09:55:50 +0000 (17:55 +0800)]
ASoC: rt5682: Fix regulator enable/disable sequence

This will attempt to disable the regulators if the initial enable fails
which is a bug.

Fix this bug by modifying the code to the correct sequence.

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Link: https://lore.kernel.org/r/tencent_4F37C9B5315B7960041E8E0ADDA869128F08@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoASoC: hdmi-codec: Fix broken channel map reporting
Matthias Reichl [Fri, 29 Sep 2023 19:50:28 +0000 (21:50 +0200)]
ASoC: hdmi-codec: Fix broken channel map reporting

Commit 4e0871333661 ("ASoC: hdmi-codec: fix channel info for
compressed formats") accidentally changed hcp->chmap_idx from
ca_id, the CEA channel allocation ID, to idx, the index to
the table of channel mappings ordered by preference.

This resulted in wrong channel maps being reported to userspace,
eg for 5.1 "FL,FR,LFE,FC" was reported instead of the expected
"FL,FR,LFE,FC,RL,RR":

~ # speaker-test -c 6 -t sine
...
 0 - Front Left
 3 - Front Center
 1 - Front Right
 2 - LFE
 4 - Unknown
 5 - Unknown

~ # amixer cget iface=PCM,name='Playback Channel Map' | grep ': values'
  : values=3,4,8,7,0,0,0,0

Switch this back to ca_id in case of PCM audio so the correct channel
map is reported again and set it to HDMI_CODEC_CHMAP_IDX_UNKNOWN in
case of non-PCM audio so the PCM channel map control returns "Unknown"
channels (value 0).

Fixes: 4e0871333661 ("ASoC: hdmi-codec: fix channel info for compressed formats")
Cc: stable@vger.kernel.org
Signed-off-by: Matthias Reichl <hias@horus.com>
Link: https://lore.kernel.org/r/20230929195027.97136-1-hias@horus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoALSA: hda: cirrus_scodec: fix an error code
Dan Carpenter [Wed, 27 Sep 2023 12:44:01 +0000 (15:44 +0300)]
ALSA: hda: cirrus_scodec: fix an error code

The "ret" variable is zero but we should return -EINVAL.

Fixes: 2144833e7b41 ("ALSA: hda: cirrus_scodec: Add KUnit test")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/5eea7fd5-67c8-4ed4-b5b3-b85dfb7572cc@moroto.mountain
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoMerge tag 'asoc-fix-v6.6-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Sat, 30 Sep 2023 07:38:30 +0000 (09:38 +0200)]
Merge tag 'asoc-fix-v6.6-rc4' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v6.6

There's quite a lot of changes here, but a lot of them are simple quirks
or device IDs rather than actual fixes.  The fixes that are here are all
quite device specific and relatively minor.

9 months agoASoC: core: Do not call link_exit() on uninitialized rtd objects
Amadeusz Sławiński [Fri, 29 Sep 2023 10:32:43 +0000 (12:32 +0200)]
ASoC: core: Do not call link_exit() on uninitialized rtd objects

On init we have sequence:

for_each_card_prelinks(card, i, dai_link) {
ret = snd_soc_add_pcm_runtime(card, dai_link);

ret = init_some_other_things(...);
if (ret)
goto probe_end:

for_each_card_rtds(card, rtd) {
ret = soc_init_pcm_runtime(card, rtd);

probe_end:

while on exit:
for_each_card_rtds(card, rtd)
snd_soc_link_exit(rtd);

If init_some_other_things() step fails due to error we end up with
not fully setup rtds and try to call snd_soc_link_exit on them, which
depending on contents on .link_exit handler, can end up dereferencing
NULL pointer.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230929103243.705433-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoASoC: core: Print component name when printing log
Amadeusz Sławiński [Fri, 29 Sep 2023 10:32:42 +0000 (12:32 +0200)]
ASoC: core: Print component name when printing log

When printing log related to component it is useful to know, to which
component it applies to.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230929103243.705433-1-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoASoC: SOF: amd: fix for firmware reload failure after playback
Vijendar Mukunda [Wed, 27 Sep 2023 07:14:10 +0000 (12:44 +0530)]
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: 41cb85bc4b52 ("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>
9 months agoASoC: fsl-asoc-card: use integer type for fll_id and pll_id
Shengjiu Wang [Wed, 20 Sep 2023 09:43:12 +0000 (17:43 +0800)]
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 2bbc2df46e67 ("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>
9 months agoASoC: fsl_sai: Don't disable bitclock for i.MX8MP
Shengjiu Wang [Tue, 19 Sep 2023 09:42:13 +0000 (17:42 +0800)]
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: 269f399dc19f ("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>
9 months agodt-bindings: ASoC: rockchip: Add compatible for RK3128 spdif
Alex Bee [Tue, 29 Aug 2023 17:16:19 +0000 (19:16 +0200)]
dt-bindings: ASoC: rockchip: Add compatible for RK3128 spdif

Add compatible for RK3128's S/PDIF.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230829171647.187787-4-knaerzche@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
9 months agoALSA: usx2y: Annotate struct snd_usx2y_urb_seq with __counted_by
Kees Cook [Fri, 22 Sep 2023 17:50:47 +0000 (10:50 -0700)]
ALSA: usx2y: Annotate struct snd_usx2y_urb_seq with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct snd_usx2y_urb_seq.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230922175046.work.766-kees@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda: Annotate struct hda_conn_list with __counted_by
Kees Cook [Fri, 22 Sep 2023 17:50:42 +0000 (10:50 -0700)]
ALSA: hda: Annotate struct hda_conn_list with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct hda_conn_list.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230922175042.work.547-kees@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoASoC: soc-generic-dmaengine-pcm: Fix function name in comment
Miquel Raynal [Fri, 22 Sep 2023 16:15:47 +0000 (18:15 +0200)]
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>
9 months agoALSA: hda: cs35l41: Add read-only ALSA control for forced mute
Stefan Binding [Thu, 21 Sep 2023 16:28:49 +0000 (17:28 +0100)]
ALSA: hda: cs35l41: Add read-only ALSA control for forced mute

When the CS35L41 amp is requested to mute using the ACPI
notification mechanism, userspace is not notified that the amp
is muted. To allow userspace to know about the mute, add an
ALSA control which tracks the forced mute override.
This control does not track the overall mute state of the amp,
since the amp is only unmuted during playback anyway, instead
it tracks the mute override request from the ACPI notification.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230921162849.1988124-5-sbinding@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda: cs35l41: Support mute notifications for CS35L41 HDA
Stefan Binding [Thu, 21 Sep 2023 16:28:48 +0000 (17:28 +0100)]
ALSA: hda: cs35l41: Support mute notifications for CS35L41 HDA

Some laptops require a hardware based mute system, where when a hotkey
is pressed, it forces the amp to be muted.

For CS35L41, when the hotkey is pressed, an acpi notification is sent
to the CS35L41 Device Node. The driver needs to handle this notification
and call a _DSM function to retrieve the mute state.

Since the amp is only muted during playback, the driver will only mute
or unmute if playback is occurring, otherwise it will save the mute
state for when playback starts.

This uses the ACPI Notification mechanism, where a handler has been
registered in the component master, which notifies each amp through
the component binding.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230921162849.1988124-4-sbinding@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda/realtek: Support ACPI Notification framework via component binding
Stefan Binding [Thu, 21 Sep 2023 16:28:47 +0000 (17:28 +0100)]
ALSA: hda/realtek: Support ACPI Notification framework via component binding

For systems which have support for ACPI notifications, add a mechanism to
register a handler for ACPI notifications and then call the acpi_notify
api on the bound components.

Registering a handler in the Realtek HDA driver, allows a single handler to
be registered, which then calls into all the components, rather than
attempting to register the same handler multiple times, once for each
component.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230921162849.1988124-3-sbinding@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda: cs35l41: Add notification support into component binding
Stefan Binding [Thu, 21 Sep 2023 16:28:46 +0000 (17:28 +0100)]
ALSA: hda: cs35l41: Add notification support into component binding

Some systems support a notification from ACPI, which can be used
for different things.

Only one handler can be registered for the acpi notification, but all
amps need to receive that notification, we can register a single handler
inside the component master, so that it can then notify through the
component framework.

This is required to support mute notifications from ACPI.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230921162849.1988124-2-sbinding@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda/realtek - ALC287 merge RTK codec with CS CS35L41 AMP
Kailang Yang [Thu, 21 Sep 2023 07:20:41 +0000 (15:20 +0800)]
ALSA: hda/realtek - ALC287 merge RTK codec with CS CS35L41 AMP

This is merge model ALC287_FIXUP_THINKPAD_I2S_SPK and
ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Fixes: f7b069cf0881 ("ALSA: hda/realtek: Fix generic fixup definition for cs35l41 amp")
Link: https://lore.kernel.org/r/82a45234327c4c50b4988a27e9f64c37@realtek.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agokselftest/alsa: pcm-test: Report cards declared in config but missing
Nícolas F. R. A. Prado [Tue, 19 Sep 2023 15:26:21 +0000 (11:26 -0400)]
kselftest/alsa: pcm-test: Report cards declared in config but missing

When parsing the configs, keep track of card configurations that match
the current system but haven't matched any card, and report those as
test failures as they represent that a card which was expected to be
present on the system is missing. This allows the configuration files to
not only be used to detect missing PCM devices (which is currently
possible) but also that the soundcard hasn't been registered at all.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230919152702.100617-1-nfraprado@collabora.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoMerge tag 'asoc-fix-v6.6-rc2' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Wed, 20 Sep 2023 13:02:16 +0000 (15:02 +0200)]
Merge tag 'asoc-fix-v6.6-rc2' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v6.6

Quite a large collection of fixes, with numbers boosted by multiple
vendors sending multi-patch serieses.  Nothing super major, and also one
device quirk.

9 months agoALSA: hda: cirrus_scodec: Select GPIOLIB for KUnit test
Richard Fitzgerald [Wed, 20 Sep 2023 09:03:38 +0000 (10:03 +0100)]
ALSA: hda: cirrus_scodec: Select GPIOLIB for KUnit test

The KUnit test for cirrus_scodec uses GPIO library functions so select
GPIOLIB in Kconfig.

This fixes the ld failures on builds that didn't already select GPIOLIB.
 ld: vmlinux.o: in function `cirrus_scodec_test_gpio_get':
 sound/pci/hda/cirrus_scodec_test.c:40: undefined reference to
`gpiochip_get_data'
 ld: vmlinux.o: in function `cirrus_scodec_test_gpio_probe':
 sound/pci/hda/cirrus_scodec_test.c:94: undefined reference to
`gpiochip_generic_request'
 ld: sound/pci/hda/cirrus_scodec_test.c:94: undefined reference to
`gpiochip_generic_free'
 ld: sound/pci/hda/cirrus_scodec_test.c:95: undefined reference to
`devm_gpiochip_add_data_with_key'

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202309201646.NnjfKPWk-lkp@intel.com/
Fixes: 2144833e7b41 ("ALSA: hda: cirrus_scodec: Add KUnit test")
Link: https://lore.kernel.org/r/20230920090338.29345-1-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoASoC: Intel: soc-acpi: Adding Es83x6 codec entry and
Mark Brown [Tue, 19 Sep 2023 18:30:55 +0000 (19:30 +0100)]
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.

9 months agoALSA: hda/realtek - ALC287 Realtek I2S speaker platform support
Kailang Yang [Tue, 19 Sep 2023 08:27:16 +0000 (16:27 +0800)]
ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support

New platform SSID:0x231f.

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.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/8d63c6e360124e3ea2523753050e6f05@realtek.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoASoC: simple-card: fixup asoc_simple_probe() error handling
Kuninori Morimoto [Tue, 19 Sep 2023 05:34:18 +0000 (05:34 +0000)]
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>
9 months agoASoC: simple-card-utils: fixup simple_util_startup() error handling
Kuninori Morimoto [Tue, 19 Sep 2023 01:22:57 +0000 (01:22 +0000)]
ASoC: simple-card-utils: fixup simple_util_startup() error handling

It should use "goto" instead of "return"

Fixes: 5ca2ab459817 ("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>
9 months agoASoC: Intel: sof_sdw: add support for SKU 0B14
Pierre-Louis Bossart [Tue, 19 Sep 2023 09:21:25 +0000 (17:21 +0800)]
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>
9 months agoASoC: Intel: soc-acpi: fix Dell SKU 0B34
Pierre-Louis Bossart [Tue, 19 Sep 2023 08:36:06 +0000 (16:36 +0800)]
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: b62a1a839b48 ("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>
9 months agoASoC: Intel: soc-acpi: Add entry for HDMI_In capture support in MTL match table
Balamurugan C [Tue, 19 Sep 2023 09:11:36 +0000 (17:11 +0800)]
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>
9 months agoASoC: Intel: soc-acpi: Add entry for sof_es8336 in MTL match table.
Balamurugan C [Tue, 19 Sep 2023 09:11:35 +0000 (17:11 +0800)]
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>
9 months agoALSA: hda: cs35l56: Use the new RUNTIME_PM_OPS() macro
Richard Fitzgerald [Tue, 19 Sep 2023 08:11:53 +0000 (09:11 +0100)]
ALSA: hda: cs35l56: Use the new RUNTIME_PM_OPS() macro

Use RUNTIME_PM_OPS() instead of the old SET_RUNTIME_PM_OPS().
This means we don't need  __maybe_unused on the functions.

Fixes: 73cfbfa9caea ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230919081153.19793-1-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: usb-audio: scarlett_gen2: Fix another -Wformat-truncation warning
Peter Ujfalusi [Tue, 19 Sep 2023 07:12:05 +0000 (10:12 +0300)]
ALSA: usb-audio: scarlett_gen2: Fix another -Wformat-truncation warning

The recent enablement of -Wformat-truncation leads to a false-positive
warning for mixer_scarlett_gen2.c.

For suppressing the warning, replace snprintf() with scnprintf().
As stated in the above, truncation doesn't matter.

Fixes: 78bd8f5126f8 ("ALSA: usb-audio: scarlett_gen2: Fix -Wformat-truncation warning")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230919071205.10684-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda: cirrus_scodec: Add KUnit test
Richard Fitzgerald [Mon, 18 Sep 2023 09:51:29 +0000 (10:51 +0100)]
ALSA: hda: cirrus_scodec: Add KUnit test

Add a KUnit test for cirrus_scodec_get_speaker_id(). It is impractical
to have enough hardware with every possible permutation of speaker id.
So use a test harness to test all theoretically supported options.

The test harness consists of:
- a mock GPIO controller.
- a mock struct device to represent the scodec driver
- software nodes to provide the fwnode info that would normally come
  from ACPI.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230918095129.440-3-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda: cs35l56: Add support for speaker id
Richard Fitzgerald [Mon, 18 Sep 2023 09:51:28 +0000 (10:51 +0100)]
ALSA: hda: cs35l56: Add support for speaker id

Add handling of the "spk-id-gpios" _DSD property. If present, the
value indicated by the GPIOs is appended to the subsystem-id
part of the firmware name to load the appropriate tunings for that
speaker.

Some manufacturers use multiple sources of speakers, which need
different tunings for best performance. On these models the type
of speaker fitted is indicated by the values of one or more GPIOs.
The number formed by the GPIOs identifies the tuning required.

The speaker ID is only used in combination with a _SUB identifier
because the value is only meaningful if the exact model is known.

The code to get the speaker ID value has been implemented as a
new library so that the cs35l41_hda driver can be switched in
future to share common code. This library can be extended for
other common functionality shared by Cirrus Logic amp drivers.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230918095129.440-2-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: scarlett2: Add correct product series name to messages
Geoffrey D. Bennett [Thu, 14 Sep 2023 17:33:03 +0000 (03:03 +0930)]
ALSA: scarlett2: Add correct product series name to messages

This driver was originally developed for the Focusrite Scarlett Gen 2
series, but now also supports the Scarlett Gen 3 series, the
Clarett 8Pre USB, and the Clarett+ 8Pre. The messages output by the
driver on initialisation and error include the identifying text
"Scarlett Gen 2/3", but this is no longer accurate, and writing
"Scarlett Gen 2/3/Clarett USB/Clarett+" would be unwieldy.

Add series_name field to the scarlett2_device_entry struct so that
concise and accurate messages can be output.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/3774b9d35bf1fbdd6fdad9f3f4f97e9b82ac76bf.1694705811.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: scarlett2: Add support for Clarett 8Pre USB
Geoffrey D. Bennett [Thu, 14 Sep 2023 17:32:37 +0000 (03:02 +0930)]
ALSA: scarlett2: Add support for Clarett 8Pre USB

The Clarett 8Pre USB works the same as the Clarett+ 8Pre, only the USB
ID is different.

Tested-by: Philippe Perrot <philippe@perrot-net.fr>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/e59f47b29e2037f031b56bde10474c6e96e31ba5.1694705811.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: scarlett2: Move USB IDs out from device_info struct
Geoffrey D. Bennett [Thu, 14 Sep 2023 17:32:16 +0000 (03:02 +0930)]
ALSA: scarlett2: Move USB IDs out from device_info struct

By moving the USB IDs from the device_info struct into
scarlett2_devices[], that will allow for devices with different
USB IDs to share the same device_info.

Tested-by: Philippe Perrot <philippe@perrot-net.fr>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/8263368e8d49e6fcebc709817bd82ab79b404468.1694705811.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: scarlett2: Default mixer driver to enabled
Geoffrey D. Bennett [Thu, 14 Sep 2023 17:31:57 +0000 (03:01 +0930)]
ALSA: scarlett2: Default mixer driver to enabled

Early versions of this mixer driver did not work on all hardware, so
out of caution the driver was disabled by default and had to be
explicitly enabled with device_setup=1.

Since commit 764fa6e686e0 ("ALSA: usb-audio: scarlett2: Fix device
hang with ehci-pci") no more problems of this nature have been
reported. Therefore, enable the driver by default but provide a new
device_setup option to disable the driver in case that is needed.

- device_setup value of 0 now means "enable" rather than "disable".
- device_setup value of 1 is now ignored.
- device_setup value of 4 now means "disable".

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/89600a35b40307f2766578ad1ca2f21801286b58.1694705811.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: rawmidi: Fix NULL dereference at proc read
Takashi Iwai [Sat, 16 Sep 2023 06:07:25 +0000 (08:07 +0200)]
ALSA: rawmidi: Fix NULL dereference at proc read

At the implementation of the optional proc fs in rawmidi, I forgot
that rmidi->ops itself is optional and can be NULL.
Add the proper NULL check for avoiding the Oops.

Fixes: fa030f666d24 ("ALSA: ump: Additional proc output")
Reported-and-tested-by: Mark Hills <mark@xwax.org>
Closes: https://lore.kernel.org/r/ef9118c3-a2eb-d0ff-1efa-cc5fb6416bde@xwax.org
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20230916060725.11726-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoASoC: SOF: core: Only call sof_ops_free() on remove if the probe was successful
Peter Ujfalusi [Fri, 15 Sep 2023 12:40:15 +0000 (15:40 +0300)]
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: bc433fd76fae ("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>
9 months agoASoC: SOF: Intel: MTL: Reduce the DSP init timeout
Ranjani Sridharan [Fri, 15 Sep 2023 13:41:53 +0000 (16:41 +0300)]
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>
9 months agoASoC: cs42l43: Add shared IRQ flag for shutters
Charles Keepax [Fri, 15 Sep 2023 14:43:00 +0000 (15:43 +0100)]
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>
9 months agoASoC: imx-audmix: Fix return error with devm_clk_get()
Shengjiu Wang [Fri, 15 Sep 2023 06:02:11 +0000 (14:02 +0800)]
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: b86ef5367761 ("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>
9 months agoASoC: hdaudio.c: Add missing check for devm_kstrdup
Chen Ni [Fri, 15 Sep 2023 02:13:44 +0000 (02:13 +0000)]
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: 97030a43371e ("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>
9 months agoALSA: riptide: Fix -Wformat-truncation warning for longname string
Takashi Iwai [Fri, 15 Sep 2023 09:13:13 +0000 (11:13 +0200)]
ALSA: riptide: Fix -Wformat-truncation warning for longname string

The filling of card->longname can be gracefully truncated, as it's
only informative.  Use scnprintf() and suppress the superfluous
compile warning with -Wformat-truncation.

Link: https://lore.kernel.org/r/20230915091313.5988-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: cs4231: Fix -Wformat-truncation warning for longname string
Takashi Iwai [Fri, 15 Sep 2023 09:13:12 +0000 (11:13 +0200)]
ALSA: cs4231: Fix -Wformat-truncation warning for longname string

The filling of card->longname can be gracefully truncated, as it's
only informative.  Use scnprintf() and suppress the superfluous
compile warning with -Wformat-truncation.

Link: https://lore.kernel.org/r/20230915091313.5988-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: ad1848: Fix -Wformat-truncation warning for longname string
Takashi Iwai [Fri, 15 Sep 2023 09:13:11 +0000 (11:13 +0200)]
ALSA: ad1848: Fix -Wformat-truncation warning for longname string

The filling of card->longname can be gracefully truncated, as it's
only informative.  Use scnprintf() and suppress the superfluous
compile warning with -Wformat-truncation.

Link: https://lore.kernel.org/r/20230915091313.5988-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
9 months agoALSA: hda: generic: Check potential mixer name string truncation
Takashi Iwai [Fri, 15 Sep 2023 08:28:02 +0000 (10:28 +0200)]
ALSA: hda: generic: Check potential mixer name string truncation

add_control_with_pfx() constructs a mixer name element with the fixed
size, and it got compile warnings with -Wformat-truncation.

Although the size overflow is very unlikely, let's have a sanity check
of the string size and returns the error if it really doesn't fit
instead of silent truncation.

Link: https://lore.kernel.org/r/20230915082802.28684-14-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>