platform/kernel/linux-starfive.git
2 years agoASoC: codecs: wcd934x: fix kcontrol max values
Srinivas Kandagatla [Tue, 22 Feb 2022 18:32:11 +0000 (18:32 +0000)]
ASoC: codecs: wcd934x: fix kcontrol max values

set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX.
set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as
max field is integer type.

Without this patch amixer for these controls will show -1 as max value to userspace.

Fixes: 9fb9b1690f0b ("ASoC: codecs: wcd934x: add mbhc support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220222183212.11580-9-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: wcd938x: fix kcontrol max values
Srinivas Kandagatla [Tue, 22 Feb 2022 18:32:10 +0000 (18:32 +0000)]
ASoC: codecs: wcd938x: fix kcontrol max values

set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX.
set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as
max field is integer type.

Without this patch amixer for these controls will show -1 as max value to userspace.

Fixes: bcee7ed09b8e ("ASoC: codecs: wcd938x: add Multi Button Headset Control support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220222183212.11580-8-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: wc938x: fix accessing array out of bounds for enum type
Srinivas Kandagatla [Tue, 22 Feb 2022 18:32:09 +0000 (18:32 +0000)]
ASoC: codecs: wc938x: fix accessing array out of bounds for enum type

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fix this by using enumerated items instead of integers.

Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220222183212.11580-7-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: va-macro: fix accessing array out of bounds for enum type
Srinivas Kandagatla [Tue, 22 Feb 2022 18:32:07 +0000 (18:32 +0000)]
ASoC: codecs: va-macro: fix accessing array out of bounds for enum type

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220222183212.11580-5-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: rx-macro: fix accessing array out of bounds for enum type
Srinivas Kandagatla [Tue, 22 Feb 2022 18:32:05 +0000 (18:32 +0000)]
ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220222183212.11580-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: rx-macro: fix accessing compander for aux
Srinivas Kandagatla [Tue, 22 Feb 2022 18:32:04 +0000 (18:32 +0000)]
ASoC: codecs: rx-macro: fix accessing compander for aux

AUX interpolator does not have compander, so check before accessing
compander data for this.

Without this checkan array of out bounds access will be made in
comp_enabled[] array.

Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220222183212.11580-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs4265: Fix the duplicated control name
Fabio Estevam [Tue, 15 Feb 2022 12:05:14 +0000 (09:05 -0300)]
ASoC: cs4265: Fix the duplicated control name

Currently, the following error messages are seen during boot:

asoc-simple-card sound: control 2:0:0:SPDIF Switch:0 is already present
cs4265 1-004f: ASoC: failed to add widget SPDIF dapm kcontrol SPDIF Switch: -16

Quoting Mark Brown:

"The driver is just plain buggy, it defines both a regular SPIDF Switch
control and a SND_SOC_DAPM_SWITCH() called SPDIF both of which will
create an identically named control, it can never have loaded without
error.  One or both of those has to be renamed or they need to be
merged into one thing."

Fix the duplicated control name by combining the two SPDIF controls here
and move the register bits onto the DAPM widget and have DAPM control them.

Fixes: f853d6b3ba34 ("ASoC: cs4265: Add a S/PDIF enable switch")
Signed-off-by: Fabio Estevam <festevam@denx.de>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220215120514.1760628-1-festevam@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Shift tested values in snd_soc_put_volsw() by +min
Marek Vasut [Tue, 15 Feb 2022 13:06:45 +0000 (14:06 +0100)]
ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min

While the $val/$val2 values passed in from userspace are always >= 0
integers, the limits of the control can be signed integers and the $min
can be non-zero and less than zero. To correctly validate $val/$val2
against platform_max, add the $min offset to val first.

Fixes: 817f7c9335ec0 ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220215130645.164025-1-marex@denx.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: wm_adsp: Correct control read size when parsing compressed buffer
Charles Keepax [Thu, 10 Feb 2022 17:20:51 +0000 (17:20 +0000)]
ASoC: wm_adsp: Correct control read size when parsing compressed buffer

When parsing the compressed stream the whole buffer descriptor is
now read in a single cs_dsp_coeff_read_ctrl; on older firmwares
this descriptor is just 4 bytes but on more modern firmwares it is
24 bytes. The current code reads the full 24 bytes regardless, this
was working but reading junk for the last 20 bytes. However commit
f444da38ac92 ("firmware: cs_dsp: Add offset to cs_dsp read/write")
added a size check into cs_dsp_coeff_read_ctrl, causing the older
firmwares to now return an error.

Update the code to only read the amount of data appropriate for
the firmware loaded.

Fixes: 04ae08596737 ("ASoC: wm_adsp: Switch to using wm_coeff_read_ctrl for compressed buffers")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220210172053.22782-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: qcom: Actually clear DMA interrupt register for HDMI
Stephen Boyd [Wed, 9 Feb 2022 23:25:20 +0000 (15:25 -0800)]
ASoC: qcom: Actually clear DMA interrupt register for HDMI

In commit da0363f7bfd3 ("ASoC: qcom: Fix for DMA interrupt clear reg
overwriting") we changed regmap_write() to regmap_update_bits() so that
we can avoid overwriting bits that we didn't intend to modify.
Unfortunately this change breaks the case where a register is writable
but not readable, which is exactly how the HDMI irq clear register is
designed (grep around LPASS_HDMITX_APP_IRQCLEAR_REG to see how it's
write only). That's because regmap_update_bits() tries to read the
register from the hardware and if it isn't readable it looks in the
regmap cache to see what was written there last time to compare against
what we want to write there. Eventually, we're unable to modify this
register at all because the bits that we're trying to set are already
set in the cache.

This is doubly bad for the irq clear register because you have to write
the bit to clear an interrupt. Given the irq is level triggered, we see
an interrupt storm upon plugging in an HDMI cable and starting audio
playback. The irq storm is so great that performance degrades
significantly, leading to CPU soft lockups.

Fix it by using regmap_write_bits() so that we really do write the bits
in the clear register that we want to. This brings the number of irqs
handled by lpass_dma_interrupt_handler() down from ~150k/sec to ~10/sec.

Fixes: da0363f7bfd3 ("ASoC: qcom: Fix for DMA interrupt clear reg overwriting")
Cc: Srinivasa Rao Mandadapu <srivasam@codeaurora.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20220209232520.4017634-1-swboyd@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoMAINTAINERS: update cros_ec_codec maintainers
Tzung-Bi Shih [Tue, 8 Feb 2022 03:12:42 +0000 (11:12 +0800)]
MAINTAINERS: update cros_ec_codec maintainers

Updates cros_ec_codec maintainers.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Acked-By: Cheng-Yi Chiang <cychiang@chromium.org>
Acked-By: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20220208031242.227563-1-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5682: do not block workqueue if card is unbound
Kai Vehmanen [Mon, 7 Feb 2022 15:30:00 +0000 (17:30 +0200)]
ASoC: rt5682: do not block workqueue if card is unbound

The current rt5682_jack_detect_handler() assumes the component
and card will always show up and implements an infinite usleep
loop waiting for them to show up.

This does not hold true if a codec interrupt (or other
event) occurs when the card is unbound. The codec driver's
remove  or shutdown functions cannot cancel the workqueue due
to the wait loop. As a result, code can either end up blocking
the workqueue, or hit a kernel oops when the card is freed.

Fix the issue by rescheduling the jack detect handler in
case the card is not ready. In case card never shows up,
the shutdown/remove/suspend calls can now cancel the detect
task.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20220207153000.3452802-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5668: do not block workqueue if card is unbound
Kai Vehmanen [Mon, 7 Feb 2022 15:29:59 +0000 (17:29 +0200)]
ASoC: rt5668: do not block workqueue if card is unbound

The current rt5668_jack_detect_handler() assumes the component
and card will always show up and implements an infinite usleep
loop waiting for them to show up.

This does not hold true if a codec interrupt (or other
event) occurs when the card is unbound. The codec driver's
remove  or shutdown functions cannot cancel the workqueue due
to the wait loop. As a result, code can either end up blocking
the workqueue, or hit a kernel oops when the card is freed.

Fix the issue by rescheduling the jack detect handler in
case the card is not ready. In case card never shows up,
the shutdown/remove/suspend calls can now cancel the detect
task.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20220207153000.3452802-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5682s: do not block workqueue if card is unbound
Kai Vehmanen [Mon, 7 Feb 2022 15:29:58 +0000 (17:29 +0200)]
ASoC: rt5682s: do not block workqueue if card is unbound

The current rt5682s_jack_detect_handler() assumes the component
and card will always show up and implements an infinite usleep
loop waiting for them to show up.

This does not hold true if a codec interrupt (or other
event) occurs when the card is unbound. The codec driver's
remove  or shutdown functions cannot cancel the workqueue due
to the wait loop. As a result, code can either end up blocking
the workqueue, or hit a kernel oops when the card is freed.

Fix the issue by rescheduling the jack detect handler in
case the card is not ready. In case card never shows up,
the shutdown/remove/suspend calls can now cancel the detect
task.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20220207153000.3452802-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tas2770: Insert post reset delay
Martin Povišer [Fri, 4 Feb 2022 09:53:01 +0000 (10:53 +0100)]
ASoC: tas2770: Insert post reset delay

Per TAS2770 datasheet there must be a 1 ms delay from reset to first
command. So insert delays into the driver where appropriate.

Fixes: 1a476abc723e ("tas2770: add tas2770 smart PA kernel driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220204095301.5554-1-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: Revert "ASoC: mediatek: Check for error clk pointer"
Guenter Roeck [Mon, 7 Feb 2022 16:09:23 +0000 (08:09 -0800)]
ASoC: Revert "ASoC: mediatek: Check for error clk pointer"

This reverts commit 9de2b9286a6d ("ASoC: mediatek: Check for error clk
pointer").

With this patch in the tree, Chromebooks running the affected hardware
no longer boot. Bisect points to this patch, and reverting it fixes
the problem.

An analysis of the code with this patch applied shows:

        ret = init_clks(pdev, clk);
        if (ret)
                return ERR_PTR(ret);
...
                for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) {
                        struct clk *c = clk[data->clk_id[j]];

                        if (IS_ERR(c)) {
                                dev_err(&pdev->dev, "%s: clk unavailable\n",
                                        data->name);
                                return ERR_CAST(c);
                        }

                        scpd->clk[j] = c;
                }

Not all clocks in the clk_names array have to be present. Only the clocks
in the data->clk_id array are actually needed. The code already checks if
the required clocks are available and bails out if not. The assumption that
all clocks have to be present is wrong, and commit 9de2b9286a6d ("ASoC:
mediatek: Check for error clk pointer") needs to be reverted.

Cc: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: Mark Brown <broonie@kernel.org>
Cc: James Liao <jamesjj.liao@mediatek.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Reported-by: Frank Wunderlich <frank-w@public-files.de>
Reported-by: Daniel Golle <daniel@makrotopia.org>
Fixes: 9de2b9286a6d ("ASoC: mediatek: Check for error clk pointer")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220207160923.3911501-1-linux@roeck-us.net
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Fix stereo change notifications
Mark Brown [Wed, 2 Feb 2022 18:15:20 +0000 (18:15 +0000)]
ASoC: ops: Fix stereo change notifications

Merge series from Mark Brown <broonie@kernel.org>:

The event generation coverage I just wrote shows that the generic ASoC
ops fail to generate events for stereo controls when only the first
channel is changed, we just return the status for the second channel and
discard that for the first.

2 years agoASoC: amd: acp: Set gpio_spkr_en to None for max speaker amplifer in machine driver
V sujith kumar Reddy [Mon, 31 Jan 2022 20:32:15 +0000 (02:02 +0530)]
ASoC: amd: acp: Set gpio_spkr_en to None for max speaker amplifer in machine driver

Maxim codec driver already enabling/disabling spk_en_gpio in form of sd_mode gpio
hence remove such gpio access control from machine driver to avoid conflict

Signed-off-by: V sujith kumar Reddy <vsujithkumar.reddy@amd.com>
Link: https://lore.kernel.org/r/20220131203225.1418648-1-vsujithkumar.reddy@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Fix stereo change notifications in snd_soc_put_xr_sx()
Mark Brown [Tue, 1 Feb 2022 15:56:29 +0000 (15:56 +0000)]
ASoC: ops: Fix stereo change notifications in snd_soc_put_xr_sx()

When writing out a stereo control we discard the change notification from
the first channel, meaning that events are only generated based on changes
to the second channel. Ensure that we report a change if either channel
has changed.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220201155629.120510-5-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_range()
Mark Brown [Tue, 1 Feb 2022 15:56:28 +0000 (15:56 +0000)]
ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_range()

When writing out a stereo control we discard the change notification from
the first channel, meaning that events are only generated based on changes
to the second channel. Ensure that we report a change if either channel
has changed.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220201155629.120510-4-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_sx()
Mark Brown [Tue, 1 Feb 2022 15:56:27 +0000 (15:56 +0000)]
ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_sx()

When writing out a stereo control we discard the change notification from
the first channel, meaning that events are only generated based on changes
to the second channel. Ensure that we report a change if either channel
has changed.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220201155629.120510-3-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Fix stereo change notifications in snd_soc_put_volsw()
Mark Brown [Tue, 1 Feb 2022 15:56:26 +0000 (15:56 +0000)]
ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw()

When writing out a stereo control we discard the change notification from
the first channel, meaning that events are only generated based on changes
to the second channel. Ensure that we report a change if either channel
has changed.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220201155629.120510-2-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoInput: wm97xx: Simplify resource management
Christophe JAILLET [Sun, 30 Jan 2022 08:06:36 +0000 (09:06 +0100)]
Input: wm97xx: Simplify resource management

Since the commit in the Fixes tag below, 'wm->input_dev' is a managed
resource that doesn't need to be explicitly unregistered or freed (see
devm_input_allocate_device() documentation)

So, remove some unless line of code to slightly simplify it.

Fixes: c72f61e74073 ("Input: wm97xx: split out touchscreen registering")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/87dce7e80ea9b191843fa22415ca3aef5f3cc2e6.1643529968.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Check for negative values before reading them
Mark Brown [Fri, 28 Jan 2022 19:24:43 +0000 (19:24 +0000)]
ASoC: ops: Check for negative values before reading them

The controls allow inputs to be specified as negative but our manipulating
them into register fields need to be done on unsigned variables so the
checks for negative numbers weren't taking effect properly. Do the checks
for negative values on the variable in the ABI struct rather than on our
local unsigned copy.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220128192443.3504823-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC DPCM lockdep fixes
Mark Brown [Fri, 28 Jan 2022 20:45:33 +0000 (20:45 +0000)]
ASoC DPCM lockdep fixes

Merge series from Takashi Iwai <tiwai@suse.de>:

This is the revised patches for addressing ASoC lockdep warnings due
to the recent DPCM locking refactoring.

2 years agoASoC: rt5682: Fix deadlock on resume
Peter Ujfalusi [Wed, 26 Jan 2022 10:03:25 +0000 (12:03 +0200)]
ASoC: rt5682: Fix deadlock on resume

On resume from suspend the following chain of events can happen:
A rt5682_resume() -> mod_delayed_work() for jack_detect_work
B DAPM sequence starts ( DAPM is locked now)

A1. rt5682_jack_detect_handler() scheduled
 - Takes both jdet_mutex and calibrate_mutex
 - Calls in to rt5682_headset_detect() which tries to take DAPM lock, it
   starts to wait for it as B path took it already.
B1. DAPM sequence reaches the "HP Amp", rt5682_hp_event() tries to take
    the jdet_mutex, but it is locked in A1, so it waits.

Deadlock.

To solve the deadlock, drop the jdet_mutex, use the jack_detect_work to do
the jack removal handling, move the dapm lock up one level to protect the
most of the rt5682_jack_detect_handler(), but not the jack reporting as it
might trigger a DAPM sequence.
The rt5682_headset_detect() can be changed to static as well.

Fixes: 8deb34a90f063 ("ASoC: rt5682: fix the wrong jack type detected")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220126100325.16513-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: hdmi-codec: Fix OOB memory accesses
Dmitry Osipenko [Wed, 12 Jan 2022 19:50:39 +0000 (22:50 +0300)]
ASoC: hdmi-codec: Fix OOB memory accesses

Correct size of iec_status array by changing it to the size of status
array of the struct snd_aes_iec958. This fixes out-of-bounds slab
read accesses made by memcpy() of the hdmi-codec driver. This problem
is reported by KASAN.

Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20220112195039.1329-1-digetx@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-pcm: Move debugfs removal out of spinlock
Takashi Iwai [Wed, 19 Jan 2022 15:52:49 +0000 (16:52 +0100)]
ASoC: soc-pcm: Move debugfs removal out of spinlock

The recent fix for DPCM locking also covered the loop in
dpcm_be_disconnect() with the FE stream lock.  This caused an
unexpected side effect, thought: calling debugfs_remove_recursive() in
the spinlock may lead to lockdep splats as the code there assumes the
SOFTIRQ-safe context.

For avoiding the problem, this patch changes the disconnection
procedure to two phases: at first, the matching entries are removed
from the linked list, then the resources are freed outside the lock.

Fixes: b7898396f4bb ("ASoC: soc-pcm: Fix and cleanup DPCM locking")
Reported-and-tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220119155249.26754-3-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-pcm: Fix DPCM lockdep warning due to nested stream locks
Takashi Iwai [Wed, 19 Jan 2022 15:52:48 +0000 (16:52 +0100)]
ASoC: soc-pcm: Fix DPCM lockdep warning due to nested stream locks

The recent change for DPCM locking caused spurious lockdep warnings.
Actually the warnings are false-positive, as those are triggered due
to the nested stream locks for FE and BE.  Since both locks belong to
the same lock class, lockdep sees it as if a deadlock.

For fixing this, we need to take PCM stream locks for BE with the
nested lock primitives.  Since currently snd_pcm_stream_lock*() helper
assumes only the top-level single locking, a new helper function
snd_pcm_stream_lock_irqsave_nested() is defined for a single-depth
nested lock, which is now used in the BE DAI trigger that is always
performed inside a FE stream lock.

Fixes: b2ae80663008 ("ASoC: soc-pcm: serialize BE triggers")
Reported-and-tested-by: Hans de Goede <hdegoede@redhat.com>
Reported-and-tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/73018f3c-9769-72ea-0325-b3f8e2381e30@redhat.com
Link: https://lore.kernel.org/alsa-devel/9a0abddd-49e9-872d-2f00-a1697340f786@samsung.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220119155249.26754-2-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: fsl: Add missing error handling in pcm030_fabric_probe
Miaoqian Lin [Thu, 27 Jan 2022 13:13:34 +0000 (13:13 +0000)]
ASoC: fsl: Add missing error handling in pcm030_fabric_probe

Add the missing platform_device_put() and platform_device_del()
before return from pcm030_fabric_probe in the error handling case.

Fixes: c912fa913446 ("ASoC: fsl: register the wm9712-codec")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220127131336.30214-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: qdsp6: q6apm-dai: only stop graphs that are started
Srinivas Kandagatla [Wed, 26 Jan 2022 11:35:49 +0000 (11:35 +0000)]
ASoC: qdsp6: q6apm-dai: only stop graphs that are started

Its possible that the sound card is just opened and closed without actually
playing stream, ex: if the audio file itself is missing.

Even in such cases we do call stop on graphs that are not yet started.
DSP can throw errors in such cases, so add a check to see if the graph
was started before stopping it.

Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220126113549.8853-5-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: wcd938x: fix return value of mixer put function
Srinivas Kandagatla [Wed, 26 Jan 2022 11:35:48 +0000 (11:35 +0000)]
ASoC: codecs: wcd938x: fix return value of mixer put function

wcd938x_ear_pa_put_gain, wcd938x_set_swr_port and  wcd938x_set_compander
currently returns zero eventhough it changes the value.
Fix this, so that change notifications are sent correctly.

Fixes: e8ba1e05bdc01 ("ASoC: codecs: wcd938x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220126113549.8853-4-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: lpass-rx-macro: fix sidetone register offsets
Srinivas Kandagatla [Wed, 26 Jan 2022 11:35:47 +0000 (11:35 +0000)]
ASoC: codecs: lpass-rx-macro: fix sidetone register offsets

For some reason we ended up with incorrect register offfset calcuations
for sidetone. regmap clearly throw errors when accessing these incorrect
registers as these do not belong to any read/write ranges.
so fix them to point to correct register offsets.

Fixes: f3ce6f3c9a99 ("ASoC: codecs: lpass-rx-macro: add iir widgets")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220126113549.8853-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: wcd938x: fix incorrect used of portid
Srinivas Kandagatla [Wed, 26 Jan 2022 11:35:46 +0000 (11:35 +0000)]
ASoC: codecs: wcd938x: fix incorrect used of portid

Mixer controls have the channel id in mixer->reg, which is not same
as port id. port id should be derived from chan_info array.
So fix this. Without this, its possible that we could corrupt
struct wcd938x_sdw_priv by accessing port_map array out of range
with channel id instead of port id.

Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220126113549.8853-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx()
Mark Brown [Mon, 24 Jan 2022 15:32:53 +0000 (15:32 +0000)]
ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx()

We don't currently validate that the values being set are within the range
we advertised to userspace as being valid, do so and reject any values
that are out of range.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220124153253.3548853-4-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()
Mark Brown [Mon, 24 Jan 2022 15:32:52 +0000 (15:32 +0000)]
ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()

We don't currently validate that the values being set are within the range
we advertised to userspace as being valid, do so and reject any values
that are out of range.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220124153253.3548853-3-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ops: Reject out of bounds values in snd_soc_put_volsw()
Mark Brown [Mon, 24 Jan 2022 15:32:51 +0000 (15:32 +0000)]
ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()

We don't currently validate that the values being set are within the range
we advertised to userspace as being valid, do so and reject any values
that are out of range.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220124153253.3548853-2-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: amd: acp-mach: Fix Left and Right rt1019 amp devices
Ajit Kumar Pandey [Thu, 20 Jan 2022 13:36:01 +0000 (19:06 +0530)]
ASoC: amd: acp-mach: Fix Left and Right rt1019 amp devices

We're setting wrong card codec conf for rt1019 amp devices in our
machine driver. Due to this left and right amp channels data are
reversed in our machines as wrong device prefix results in wrong
value for "Mono LR Select" rt1019 mixer control. Reverse dev ids
in codec conf with Left and Right name_prefix to fix such issue.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
Link: https://lore.kernel.org/r/20220120133605.476138-1-AjitKumar.Pandey@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: fix unmet dependency on GPIOLIB for SND_SOC_DMIC
Julian Braha [Mon, 17 Jan 2022 05:03:24 +0000 (00:03 -0500)]
ASoC: mediatek: fix unmet dependency on GPIOLIB for SND_SOC_DMIC

When SND_SOC_MT8195_MT6359_RT1011_RT5682 is selected,
and GPIOLIB is not selected,
Kbuild gives the following warning:

WARNING: unmet direct dependencies detected for SND_SOC_DMIC
  Depends on [n]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && GPIOLIB [=n]
  Selected by [y]:
  - SND_SOC_MT8195_MT6359_RT1011_RT5682 [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && I2C [=y] && SND_SOC_MT8195 [=y] && MTK_PMIC_WRAP [=y]

This is because SND_SOC_MT8195_MT6359_RT1011_RT5682
selects SND_SOC_DMIC without selecting or depending on
GPIOLIB, depsite SND_SOC_DMIC depending on GPIOLIB.

This unmet dependency bug was detected by Kismet,
a static analysis tool for Kconfig. Please advise
if this is not the appropriate solution.

Signed-off-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20220117050324.68371-1-julianbraha@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: max9759: fix underflow in speaker_gain_control_put()
Dan Carpenter [Wed, 19 Jan 2022 12:31:01 +0000 (15:31 +0300)]
ASoC: max9759: fix underflow in speaker_gain_control_put()

Check for negative values of "priv->gain" to prevent an out of bounds
access.  The concern is that these might come from the user via:
  -> snd_ctl_elem_write_user()
    -> snd_ctl_elem_write()
      -> kctl->put()

Fixes: fa8d915172b8 ("ASoC: max9759: Add Amplifier Driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220119123101.GA9509@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name
Jiasheng Jiang [Tue, 11 Jan 2022 02:50:48 +0000 (10:50 +0800)]
ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name

If the device does not exist, of_get_child_by_name() will return NULL
pointer.
And devm_snd_soc_register_component() does not check it.
Also, I have noticed that cpcap_codec_driver has not been used yet.
Therefore, it should be better to check it in order to avoid the future
dereference of the NULL pointer.

Fixes: f6cdf2d3445d ("ASoC: cpcap: new codec")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: simple-card: fix probe failure on platform component
Robert Hancock [Fri, 7 Jan 2022 21:47:10 +0000 (15:47 -0600)]
ASoC: simple-card: fix probe failure on platform component

A previous change to simple-card resulted in asoc_simple_parse_dai
attempting to retrieve the dai_name for platform components, which are
unlikely to have a valid DAI name. This caused simple-card to fail to
probe when using the xlnx_formatter_pcm as the platform component, since
it does not register any DAI components.

Since the dai_name is not used for platform components, just skip trying
to retrieve it for those.

Fixes: f107294c6422 ("ASoC: simple-card: support snd_soc_dai_link_component style for cpu")
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Link: https://lore.kernel.org/r/20220107214711.1100162-6-robert.hancock@calian.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes
Robert Hancock [Fri, 7 Jan 2022 21:47:06 +0000 (15:47 -0600)]
ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes

This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make
buffer bytes multiple of period bytes" by Devarsh Thakkar. The same
issue exists in the mainline version of the driver. The original
patch description is as follows:

"The Xilinx Audio Formatter IP has a constraint on period
bytes to be multiple of 64. This leads to driver changing
the period size to suitable frames such that period bytes
are multiple of 64.

Now since period bytes and period size are updated but not
the buffer bytes, this may make the buffer bytes unaligned
and not multiple of period bytes.

When this happens we hear popping noise as while DMA is being
done the buffer bytes are not enough to complete DMA access
for last period of frame within the application buffer boundary.

To avoid this, align buffer bytes too as multiple of 64, and
set another constraint to always enforce number of periods as
integer. Now since, there is already a rule in alsa core
to enforce Buffer size = Number of Periods * Period Size
this automatically aligns buffer bytes as multiple of period
bytes."

Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver")
Cc: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Link: https://lore.kernel.org/r/20220107214711.1100162-2-robert.hancock@calian.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Add support for hibernate memory retention mode
Charles Keepax [Fri, 7 Jan 2022 16:06:36 +0000 (16:06 +0000)]
ASoC: cs35l41: Add support for hibernate memory retention mode

The cs35l41 supports a low power DSP memory retention mode. Add support
for entering this mode when then device is not in use.

Co-authored-by: David Rhodes <david.rhodes@cirrus.com>
Signed-off-by: David Rhodes <david.rhodes@cirrus.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220107160636.6555-3-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Update handling of test key registers
Charles Keepax [Fri, 7 Jan 2022 16:06:35 +0000 (16:06 +0000)]
ASoC: cs35l41: Update handling of test key registers

In preparation for the addition of PM runtime support move the test
key out of the register patches themselves. This is necessary to
allow the test key to be held during cache synchronisation, which is
required by the OTP settings which were unpacked from the device and
written by the driver.

Also whilst at it, the driver uses a mixture of accessing the test key
register by name and by address, consistently use the name.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220107160636.6555-2-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: imx-card: several improvement and fixes
Mark Brown [Thu, 6 Jan 2022 20:26:24 +0000 (20:26 +0000)]
ASoC: imx-card: several improvement and fixes

Merge series from Shengjiu Wang <shengjiu.wang@nxp.com>:

Several improvement and fixes for AK codecs supported on i.MX platfroms

2 years agoASoC: wcd9335: Keep a RX port value for each SLIM RX mux
Yassine Oudjana [Tue, 4 Jan 2022 03:35:36 +0000 (03:35 +0000)]
ASoC: wcd9335: Keep a RX port value for each SLIM RX mux

Currently, rx_port_value is a single unsigned int that gets overwritten
when slim_rx_mux_put() is called for any RX mux, then the same value is
read when slim_rx_mux_get() is called for any of them. This results in
slim_rx_mux_get() reporting the last value set by slim_rx_mux_put()
regardless of which SLIM RX mux is in question.

Turn rx_port_value into an array and store a separate value for each
SLIM RX mux.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Link: https://lore.kernel.org/r/20220104033356.343685-1-y.oudjana@protonmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: amd: acp: acp-mach: Change default RT1019 amp dev id
Ajit Kumar Pandey [Thu, 6 Jan 2022 15:05:21 +0000 (20:35 +0530)]
ASoC: amd: acp: acp-mach: Change default RT1019 amp dev id

RT1019 components was initially registered with i2c1 and i2c2 but
now changed to i2c0 and i2c1 in most of our AMD platforms. Change
default rt1019 components to 10EC1019:00 and 10EC1019:01 which is
aligned with most of AMD machines.

Any exception to rt1019 device ids in near future board design can
be handled using dmi based quirk for that machine.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
Link: https://lore.kernel.org/r/20220106150525.396170-1-AjitKumar.Pandey@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: topology: Fix typo
Qinghua Jin [Thu, 6 Jan 2022 09:28:47 +0000 (17:28 +0800)]
ASoC: topology: Fix typo

change 'postion' to 'position'

Signed-off-by: Qinghua Jin <qhjin.dev@gmail.com>
Link: https://lore.kernel.org/r/20220106092847.357035-1-qhjin.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: fsl_asrc: refine the check of available clock divider
Shengjiu Wang [Wed, 5 Jan 2022 11:08:03 +0000 (19:08 +0800)]
ASoC: fsl_asrc: refine the check of available clock divider

According to RM, the clock divider range is from 1 to 8, clock
prescaling ratio may be any power of 2 from 1 to 128.
So the supported divider is not all the value between
1 and 1024, just limited value in that range.

Create table for the supported divder and add function to
check the clock divider is available by comparing with
the table.

Fixes: d0250cf4f2ab ("ASoC: fsl_asrc: Add an option to select internal ratio mode")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1641380883-20709-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: Intel: bytcr_rt5640: Add support for external GPIO jack-detect
Hans de Goede [Thu, 6 Jan 2022 11:01:28 +0000 (12:01 +0100)]
ASoC: Intel: bytcr_rt5640: Add support for external GPIO jack-detect

Some boards have the codec IRQ hooked-up as normally, so the driver can
still do things like headset vs headphones and button-press detection,
but instead of using one of the JD pins of the codec, an external GPIO
is used to report the jack-presence switch status of the jack.

Add support for boards which have this setup and which specify which
external GPIO to use in the special Android AMCR0F28 ACPI device.

And add a quirk for the Asus TF103C tablet which uses this setup.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-7-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: Intel: bytcr_rt5640: Support retrieving the codec IRQ from the AMCR0F28 ACPI dev
Hans de Goede [Thu, 6 Jan 2022 11:01:27 +0000 (12:01 +0100)]
ASoC: Intel: bytcr_rt5640: Support retrieving the codec IRQ from the AMCR0F28 ACPI dev

Some X86 tablets, which ship with Android as factory installed OS,
specify codec IRQs/GPIOS in a special Android AMCR0F28 ACPI device.

Add support for retrieving the codec IRQ from this ACPI device instead
of from the 10EC5640 device describing the codec itself and enable this
on Asus MemoPad 7 ME176C tablets.

This fixes jack-detect not working on these tablets.

Cc: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-6-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Add support for boards with an external jack-detect GPIO
Hans de Goede [Thu, 6 Jan 2022 11:01:26 +0000 (12:01 +0100)]
ASoC: rt5640: Add support for boards with an external jack-detect GPIO

Some boards have the codec IRQ hooked-up as normally, so the driver can
still do things like headset vs headphones and button-press detection,
but instead of using one of the JD pins of the codec, an external GPIO
is used to report the jack-presence switch status of the jack.

Add support for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-5-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Allow snd_soc_component_set_jack() to override the codec IRQ
Hans de Goede [Thu, 6 Jan 2022 11:01:25 +0000 (12:01 +0100)]
ASoC: rt5640: Allow snd_soc_component_set_jack() to override the codec IRQ

On some boards where the firmware/fwnode information is in essence
read-only (x86 + ACPI boards) the i2c_client for the codec may contain
the wrong IRQ or no IRQ at all.

Since we only request the IRQ once snd_soc_component_set_jack() gets
called, allow machine drivers to override the IRQ with the proper one
through the data parameter to snd_soc_component_set_jack().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-4-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Change jack_work to a delayed_work
Hans de Goede [Thu, 6 Jan 2022 11:01:24 +0000 (12:01 +0100)]
ASoC: rt5640: Change jack_work to a delayed_work

Change jack_work from a struct work_struct to a struct delayed_work, this
is a preparation patch for adding support for boards where an external
GPIO is used for jack-detect, rather then one of the JD pins of the codec.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-3-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Fix possible NULL pointer deref on resume
Hans de Goede [Thu, 6 Jan 2022 11:01:23 +0000 (12:01 +0100)]
ASoC: rt5640: Fix possible NULL pointer deref on resume

Commit 2b9c8d2b3c89 ("ASoC: rt5640: Add the HDA header support") adds
re-queuing of the jack_work on resume when rt5640->jd_src != 0.

But the jack_work will unconditionally deref rt5640->jack and that might
be NULL. E.g. the sound/soc/intel/boards/bytcr_rt5640.c machine driver
call snd_soc_component_set_jack(codec, NULL, NULL) from pre_suspend to
disable the IRQ to avoid spurious wakeups, so when rt5640_resume()
runs rt5640->jack will be NULL in this case.

Make the queueing of the work conditional on rt5640->jack instead of
on rt5640->jd_src to fix this.

Fixes: 2b9c8d2b3c89 ("ASoC: rt5640: Add the HDA header support")
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-2-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: imx-card: improve the sound quality for low rate
Shengjiu Wang [Tue, 4 Jan 2022 10:40:35 +0000 (18:40 +0800)]
ASoC: imx-card: improve the sound quality for low rate

According to RM, on auto mode:
For codec AK4458 and AK4497, the lowest ratio of MLCK/FS is 256
if sample rate is 8kHz-48kHz,
For codec AK5558, the lowest ratio of MLCK/FS is 512 if sample
rate is 8kHz-48kHz.

With these setting the sound quality for 8kHz-48kHz can be improved.

Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1641292835-19085-4-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: imx-card: Fix mclk calculation issue for akcodec
Shengjiu Wang [Tue, 4 Jan 2022 10:40:34 +0000 (18:40 +0800)]
ASoC: imx-card: Fix mclk calculation issue for akcodec

Transfer the refined slots and slot_width to akcodec_get_mclk_rate()
for mclk calculation, otherwise the mclk frequency does not match
with the slots and slot_width for S16_LE format, because the default
slot_width is 32.

Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1641292835-19085-3-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: imx-card: Need special setting for ak4497 on i.MX8MQ
Shengjiu Wang [Tue, 4 Jan 2022 10:40:33 +0000 (18:40 +0800)]
ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ

The SAI on i.MX8MQ don't support one2one ratio for mclk:bclk, so
the mclk frequency exceeds the supported range of codec for
the case that sample rate is larger than 705kHZ and format is
S32_LE. Update the supported width for such case.

Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1641292835-19085-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: ak4375: Fix unused function error
Takashi Iwai [Wed, 5 Jan 2022 16:24:09 +0000 (17:24 +0100)]
ASoC: ak4375: Fix unused function error

A randconfig caught a compile warning that is now treated as a fatal
error:
  sound/soc/codecs/ak4375.c:415:13: error: ‘ak4375_power_off’ defined but not used [-Werror=unused-function]

where ak4375_power_off() is used only from the PM handler.

As both suspend and resumes are already marked with __maybe_unused,
let's rip off the superfluous ifdef CONFIG_PM, so that the error above
can be avoided.

Fixes: 53778b8292b5 ("ASoC: Add AK4375 support")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220105162409.20635-1-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoAdd low power hibernation support to cs35l41
Mark Brown [Wed, 5 Jan 2022 15:59:21 +0000 (15:59 +0000)]
Add low power hibernation support to cs35l41

Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

This patch series adds support for the low power hibernation feature
on cs35l41. This allows the DSP memory to be retained whilst the
device enters a very low power state.

2 years agoASoC: cs4265: Add a remove() function
Fabio Estevam [Tue, 4 Jan 2022 18:06:13 +0000 (15:06 -0300)]
ASoC: cs4265: Add a remove() function

When the reset_gpio GPIO is used, it is better to put the codec
back into reset state when the driver unbinds.

Add a remove() function to accomplish that.

Suggested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220104180613.639317-1-festevam@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: wm_adsp: Add support for "toggle" preloaders
Charles Keepax [Wed, 5 Jan 2022 11:30:24 +0000 (11:30 +0000)]
ASoC: wm_adsp: Add support for "toggle" preloaders

In the case a device can support retaining the firmware memory across
low power states it is useful for the preloader widget to only power up
whilst actually loading/unloading the core, as opposed to the normal
operation where the widget is powered for the entire time a firmware is
preloaded onto the core. Add support for this mode and a flag to enable
it.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220105113026.18955-7-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agofirmware: cs_dsp: Clear core reset for cache
Charles Keepax [Wed, 5 Jan 2022 11:30:23 +0000 (11:30 +0000)]
firmware: cs_dsp: Clear core reset for cache

If the Halo registers are kept in the register cache the
HALO_CORE_RESET bit will be retained as 1 after reset is triggered in
cs_dsp_halo_start_core. This will cause subsequent writes to reset
the core which is not desired. Apart from this bit the rest of the
register bits are cacheable, so for safety sake clear the bit to
ensure the cache is consistent.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220105113026.18955-6-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Correct handling of some registers in the cache
Charles Keepax [Wed, 5 Jan 2022 11:30:22 +0000 (11:30 +0000)]
ASoC: cs35l41: Correct handling of some registers in the cache

It makes no sense to cache the test/user key registers, since they
require values written at specific times, mark them volatile. It is
probably best if they can't be accessed from user-space either, so
mark them precious as well.

The interrupt force, edge, polarity and debounce are all settings
applied to the IRQ rather than status bits and as such should not be
volatile.

The OTP trim values will require re-application in the event of a
cache sync and as such should not be volatile. The OTPID however
should be volatile.

The DSP scratch registers are used to read back an error/debug code
from the DSP on shutdown, as such these should be marked volatile.

Finally, add some missing defaults, add TST_FS_MON0, and allow the
DSP core control register to be cached.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220105113026.18955-5-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Correct DSP power down
Charles Keepax [Wed, 5 Jan 2022 11:30:21 +0000 (11:30 +0000)]
ASoC: cs35l41: Correct DSP power down

The wm_adsp_event should be called before the early_event on power
down, event stops the core running and early_event then powers down
the core. Additionally, the core should only be stopped if it was
actually running in the first place.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220105113026.18955-4-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Remove incorrect comment
Charles Keepax [Wed, 5 Jan 2022 11:30:20 +0000 (11:30 +0000)]
ASoC: cs35l41: Remove incorrect comment

The IRQ is not used for the PDN_DONE bit, this is polled during the DAPM
sequence, remove the misleading comment.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220105113026.18955-3-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Add cs35l51/53 IDs
David Rhodes [Wed, 5 Jan 2022 11:30:19 +0000 (11:30 +0000)]
ASoC: cs35l41: Add cs35l51/53 IDs

Add IDs for the CS35L51/53 variants, the functionality is shared with
CS35L41.

Signed-off-by: David Rhodes <david.rhodes@cirrus.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220105113026.18955-2-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: fsl_mqs: fix MODULE_ALIAS
Alyssa Ross [Tue, 4 Jan 2022 13:22:16 +0000 (13:22 +0000)]
ASoC: fsl_mqs: fix MODULE_ALIAS

modprobe can't handle spaces in aliases.

Fixes: 9e28f6532c61 ("ASoC: fsl_mqs: Add MQS component driver")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Link: https://lore.kernel.org/r/20220104132218.1690103-1-hi@alyssa.is
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: repair pcmif BE dai
Mark Brown [Fri, 31 Dec 2021 14:38:47 +0000 (14:38 +0000)]
ASoC: mediatek: mt8195: repair pcmif BE dai

Merge series from Trevor Wu <trevor.wu@mediatek.com>:

This series of patches repairs some problems for pcmif BE dai.
The unexpected control flow is corrected, and the missing playback
support of DPCM is added.

2 years agoASoC: Add support for CS35L41 in HDA systems
Mark Brown [Fri, 31 Dec 2021 14:38:45 +0000 (14:38 +0000)]
ASoC: Add support for CS35L41 in HDA systems

Merge series from Lucas Tanure <tanureal@opensource.cirrus.com>:

Initial refactoring to support use of cs35l41 from the HDA driver stack.

2 years agoASoC: Merge fixes
Mark Brown [Fri, 31 Dec 2021 13:21:39 +0000 (13:21 +0000)]
ASoC: Merge fixes

So we can send to Linus.

2 years agoASoC: cs35l41: Create shared function for boost configuration
Lucas Tanure [Fri, 17 Dec 2021 11:57:04 +0000 (11:57 +0000)]
ASoC: cs35l41: Create shared function for boost configuration

ASoC and HDA will use the same registers to configure
internal boost for the device

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211217115708.882525-7-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Create shared function for setting channels
Lucas Tanure [Fri, 17 Dec 2021 11:57:03 +0000 (11:57 +0000)]
ASoC: cs35l41: Create shared function for setting channels

ASoC and HDA will use the same register to set channels
for the device

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211217115708.882525-6-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Create shared function for errata patches
Lucas Tanure [Fri, 17 Dec 2021 11:57:02 +0000 (11:57 +0000)]
ASoC: cs35l41: Create shared function for errata patches

ASoC and HDA systems require the same errata patches, so
move it to the shared code using a function the correctly
applies the patches by revision

Also, move CS35L41_DSP1_CCM_CORE_CTRL write to errata
patch function as is required to be written at boot,
but not in regmap_register_patch sequence as will affect
waking up from hibernation

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211217115708.882525-5-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Move power initializations to reg_sequence
Lucas Tanure [Fri, 17 Dec 2021 11:57:01 +0000 (11:57 +0000)]
ASoC: cs35l41: Move power initializations to reg_sequence

ASoC and HDA systems for all revisions of CS35L41 will benefit
from having this initialization, so add it to reg_sequence of
each revision

By moving to reg_sequence all gains are set to zero. And boost,
monitoring parts, and class D amplifier are disabled.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211217115708.882525-4-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Move cs35l41_otp_unpack to shared code
Lucas Tanure [Fri, 17 Dec 2021 11:57:00 +0000 (11:57 +0000)]
ASoC: cs35l41: Move cs35l41_otp_unpack to shared code

ASoC and HDA will do the same cs35l41_otp_unpack, so move it
to shared code

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211217115708.882525-3-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Convert tables to shared source code
Lucas Tanure [Fri, 17 Dec 2021 11:56:59 +0000 (11:56 +0000)]
ASoC: cs35l41: Convert tables to shared source code

To support CS35L41 in HDA systems the HDA driver
for CS35L41 would have to duplicate some functions
that already exist on ASoC driver
So instead of duplicate the code, use the new lib
source as a shared resource for both ASoC and HDA

Also, change the way CONFIG_SND_SOC_CS35L41 is
selected, as reported by Intel Kernel test robot,
it is possible to build SND_SOC_CS35L41_SPI/I2C
without the main driver, which would lead to build
failures.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20211217115708.882525-2-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: add playback support to PCM1_BE dai_link
Trevor Wu [Thu, 30 Dec 2021 08:47:31 +0000 (16:47 +0800)]
ASoC: mediatek: mt8195: add playback support to PCM1_BE dai_link

PCM1_BE should be a dai_link for both playback and capture.
In the patch, the missing DPCM playback support is added.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20211230084731.31372-3-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: correct pcmif BE dai control flow
Trevor Wu [Thu, 30 Dec 2021 08:47:30 +0000 (16:47 +0800)]
ASoC: mediatek: mt8195: correct pcmif BE dai control flow

Originally, the conditions for preventing reentry are not correct.
dai->component->active is not the state specifically for pcmif dai, so it
is not a correct condition to indicate the status of pcmif dai.
On the other hand, snd_soc_dai_stream_actvie() in prepare ops for both
playback and capture possibly return true at the first entry when these
two streams are opened at the same time.

In the patch, I refer to the implementation in mt8192-dai-pcm.c.
Clock and enabling bit for PCMIF are managed by DAPM, and the condition
for prepare ops is replaced by the status of dai widget.

Fixes: 1f95c019115c ("ASoC: mediatek: mt8195: support pcm in platform driver")
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20211230084731.31372-2-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5682: Register wclk with its parent_hws instead of parent_data
Derek Fang [Mon, 27 Dec 2021 05:54:46 +0000 (13:54 +0800)]
ASoC: rt5682: Register wclk with its parent_hws instead of parent_data

The mclk might not be registered as a fixed clk name "mclk" on some
platforms.
In those platforms, if the mclk needed to be controlled by codec driver
and acquired by a fixed name, it would be a problem.

This patch to fix the issue that wclk becomes an orphan due to the fixed
mclk's name.

Signed-off-by: Derek Fang <derek.fang@realtek.com>
Link: https://lore.kernel.org/r/20211227055446.27563-1-derek.fang@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: update control for RT5682 series
Trevor Wu [Tue, 28 Dec 2021 06:48:21 +0000 (14:48 +0800)]
ASoC: mediatek: mt8195: update control for RT5682 series

Playback pop is observed and the root cause is the reference clock
provided by MT8195 is diabled before RT5682 finishes the control flow.

To ensure the reference clock supplied to RT5682 is disabled after RT5682
finishes all register controls. We replace BCLK with MCLK for RT5682
reference clock, and makes use of set_bias_level_post to handle MCLK
which guarantees MCLK is off after all RT5682 register access.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211228064821.27865-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: samsung: idma: Check of ioremap return value
Jiasheng Jiang [Tue, 28 Dec 2021 03:40:26 +0000 (11:40 +0800)]
ASoC: samsung: idma: Check of ioremap return value

Because of the potential failure of the ioremap(), the buf->area could
be NULL.
Therefore, we need to check it and return -ENOMEM in order to transfer
the error.

Fixes: f09aecd50f39 ("ASoC: SAMSUNG: Add I2S0 internal dma driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20211228034026.1659385-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: use of_device_get_match_data()
Tzung-Bi Shih [Mon, 27 Dec 2021 06:21:53 +0000 (14:21 +0800)]
ASoC: mediatek: use of_device_get_match_data()

Uses of_device_get_match_data() helper to clean some boilerplate code.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211227062153.3887447-1-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs4265: Fix part number ID error message
Fabio Estevam [Wed, 22 Dec 2021 14:19:19 +0000 (11:19 -0300)]
ASoC: cs4265: Fix part number ID error message

The Chip ID - Register 01h contains the following description
as per the CS4265 datasheet:

"Bits 7 through 4 are the part number ID, which is 1101b (0Dh)"

The current error message is incorrect as it prints CS4265_CHIP_ID,
which is the register number, instead of printing the expected
part number ID value.

To make it clearer, also do a shift by 4, so that the error message
would become:

[    4.218083] cs4265 1-004f: CS4265 Part Number ID: 0x0 Expected: 0xd

Signed-off-by: Fabio Estevam <festevam@denx.de>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211222141920.1482451-1-festevam@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC/SoundWire: improve suspend flows and use set_stream() instead of set_tdm_slots...
Mark Brown [Fri, 24 Dec 2021 16:15:47 +0000 (16:15 +0000)]
ASoC/SoundWire: improve suspend flows and use set_stream() instead of set_tdm_slots() for HDAudio

Merge series from Bard Liao <yung-chuan.liao@linux.intel.com>:

This series contains three topics.
1. SoundWire: Intel: remove pdm support
2. ASoC/SoundWire: dai: expand 'stream' concept beyond SoundWire
3. ASoC/SOF/SoundWire: fix suspend-resume on pause with dynamic pipelines

The topics are independent but the changes are dependent. So please
allow me to send them in one series.

2 years agoASoC: amd: acp: Power on/off the speaker enable gpio pin based on DAPM callback.
V sujith kumar Reddy [Fri, 24 Dec 2021 15:00:43 +0000 (20:30 +0530)]
ASoC: amd: acp: Power on/off the speaker enable gpio pin based on DAPM callback.

Configure the speaker gpio pin based on power sequence of the DAPM
speaker events.
Enable speaker after widget power up and Disable before widget  powerdown.

Signed-off-by: V sujith kumar Reddy <vsujithkumar.reddy@amd.com>
Link: https://lore.kernel.org/r/20211224150058.2444776-1-vsujithkumar.reddy@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: remove unneeded variable
chiminghao [Thu, 9 Dec 2021 01:57:07 +0000 (01:57 +0000)]
ASoC: remove unneeded variable

return value form directly instead of
taking this in another redundant variable.

Reported-by: Zeal Robot <zealci@zte.com.cm>
Signed-off-by: chiminghao <chi.minghao@zte.com.cn>
Link: https://lore.kernel.org/r/20211209015707.409870-1-chi.minghao@zte.com.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: Check for error clk pointer
Jiasheng Jiang [Wed, 22 Dec 2021 01:51:57 +0000 (09:51 +0800)]
ASoC: mediatek: Check for error clk pointer

Yes, you are right and now the return code depending on the
init_clks().

Fixes: 6078c651947a ("soc: mediatek: Refine scpsys to support multiple platform")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20211222015157.1025853-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: release device_node after snd_soc_register_card
Tzung-Bi Shih [Fri, 24 Dec 2021 06:47:19 +0000 (14:47 +0800)]
ASoC: mediatek: mt8195: release device_node after snd_soc_register_card

Device nodes can be released after components have bound.

Shortens the lifecycle of the device nodes.  Releases the reference
counts after snd_soc_register_card.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211224064719.2031210-5-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8173: reduce log verbosity in probe()
Tzung-Bi Shih [Fri, 24 Dec 2021 06:47:18 +0000 (14:47 +0800)]
ASoC: mediatek: mt8173: reduce log verbosity in probe()

Eliminates error messages if snd_soc_register_card() failed.  Kernel
emits messages if device probe error anyway.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211224064719.2031210-4-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8183: fix device_node leak
Tzung-Bi Shih [Fri, 24 Dec 2021 06:47:17 +0000 (14:47 +0800)]
ASoC: mediatek: mt8183: fix device_node leak

Fixes the device_node leak.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211224064719.2031210-3-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8173: fix device_node leak
Tzung-Bi Shih [Fri, 24 Dec 2021 06:47:16 +0000 (14:47 +0800)]
ASoC: mediatek: mt8173: fix device_node leak

Fixes the device_node leak.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211224064719.2031210-2-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agosoundwire: intel: remove PDM support
Pierre-Louis Bossart [Fri, 24 Dec 2021 02:10:34 +0000 (10:10 +0800)]
soundwire: intel: remove PDM support

While the hardware supports PDM streams, this capability has never
been tested or enabled on any product, so this is dead-code. Let's
remove all this.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211224021034.26635-8-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agosoundwire: intel: remove unnecessary init
Pierre-Louis Bossart [Fri, 24 Dec 2021 02:10:33 +0000 (10:10 +0800)]
soundwire: intel: remove unnecessary init

cppcheck warning:

drivers/soundwire/intel.c:1487:10: style: Variable 'ret' is assigned a
value that is never used. [unreadVariable]
 int ret = 0;
         ^

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211224021034.26635-7-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: Intel/SOF: use set_stream() instead of set_tdm_slots() for HDAudio
Pierre-Louis Bossart [Fri, 24 Dec 2021 02:10:32 +0000 (10:10 +0800)]
ASoC: Intel/SOF: use set_stream() instead of set_tdm_slots() for HDAudio

Overloading the tx_mask with a linear value is asking for trouble and
only works because the codec_dai hw_params() is called before the
cpu_dai hw_params().

Move to the more generic set_stream() API to pass the hdac_stream
information.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20211224021034.26635-6-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC/SoundWire: dai: expand 'stream' concept beyond SoundWire
Pierre-Louis Bossart [Fri, 24 Dec 2021 02:10:31 +0000 (10:10 +0800)]
ASoC/SoundWire: dai: expand 'stream' concept beyond SoundWire

The HDAudio ASoC support relies on the set_tdm_slots() helper to store
the HDaudio stream tag in the tx_mask. This only works because of the
pre-existing order in soc-pcm.c, where the hw_params() is handled for
codec_dais *before* cpu_dais. When the order is reversed, the
stream_tag is used as a mask in the codec fixup functions:

/* fixup params based on TDM slot masks */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
    codec_dai->tx_mask)
soc_pcm_codec_params_fixup(&codec_params,
   codec_dai->tx_mask);

As a result of this confusion, the codec_params_fixup() ends-up
generating bad channel masks, depending on what stream_tag was
allocated.

We could add a flag to state that the tx_mask is really not a mask,
but it would be quite ugly to persist in overloading concepts.

Instead, this patch suggests a more generic get/set 'stream' API based
on the existing model for SoundWire. We can expand the concept to
store 'stream' opaque information that is specific to different DAI
types. In the case of HDAudio DAIs, we only need to store a stream tag
as an unsigned char pointer. The TDM rx_ and tx_masks should really
only be used to store masks.

Rename get_sdw_stream/set_sdw_stream callbacks and helpers as
get_stream/set_stream. No functionality change beyond the rename.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211224021034.26635-5-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agosoundwire: intel: improve suspend flows
Ranjani Sridharan [Fri, 24 Dec 2021 02:10:30 +0000 (10:10 +0800)]
soundwire: intel: improve suspend flows

This patch provides both a simplification of the suspend flows and a
better balanced operation during suspend/resume transition, as part of
the transition of Sound Open Firmware (SOF) to dynamic pipelines: the
DSP resources are only enabled when required instead of enabled on
startup.

The exiting code relies on a convoluted way of dealing with suspend
signals. Since there is no .suspend DAI callback, we used the
component .suspend and marked all the component DAI dmas as
'suspended'. The information was used in the .prepare stage to
differentiate resume operations from xrun handling, and only
reinitialize SHIM registers and DMA in the former case.

While this solution has been working reliably for about 2 years, there
is a much better solution consisting in trapping the TRIGGER_SUSPEND
in the .trigger DAI ops. The DMA is still marked in the same way for
the .prepare op to run, but in addition the callbacks sent to DSP
firmware are now balanced.

Normal operation:
hw_params -> intel_params_stream
hw_free   -> intel_free_stream

suspend    -> intel_free_stream
prepare    -> intel_params_stream

This balanced operation was not required with existing SOF firmware
relying on static pipelines instantiated at every boot. With the
on-going transition to dynamic pipelines, it's however a requirement
to keep the use count for the DAI widget balanced across all
transitions.

The component suspend is not removed but instead modified to deal with
a corner case: when a substream is PAUSED, the ALSA core does not
throw the TRIGGER_SUSPEND. This is problematic since the refcount for
all pipelines and widgets is not balanced, leading to issues on
resume. The trigger callback keeps track of the 'paused' state with a
new flag, which is tested during the component suspend called later to
release the remaining DSP resources. These resources will be
re-enabled in the .prepare step.

The IPC used in the TRIGGER_SUSPEND to release DSP resources is not a
problem since the BE dailink is already marked as non-atomic.

Co-developed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211224021034.26635-4-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC/soundwire: intel: simplify callbacks for params/hw_free
Pierre-Louis Bossart [Fri, 24 Dec 2021 02:10:29 +0000 (10:10 +0800)]
ASoC/soundwire: intel: simplify callbacks for params/hw_free

We don't really need to pass a substream to the callback, we only need
the direction. No functionality change, only simplification to enable
improve suspend with paused streams.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211224021034.26635-3-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASOC: SOF: Intel: use snd_soc_dai_get_widget()
Pierre-Louis Bossart [Fri, 24 Dec 2021 02:10:28 +0000 (10:10 +0800)]
ASOC: SOF: Intel: use snd_soc_dai_get_widget()

We have a helper, use it to simplify widget lookup

Suggested-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20211224021034.26635-2-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>