OSDN Git Service

tomoyo/tomoyo-test1.git
2 years agoASoC: fsl-asoc-card: Add missing Kconfig option for tlv320aic31xx
Ariel D'Alessandro [Fri, 3 Dec 2021 17:50:18 +0000 (14:50 -0300)]
ASoC: fsl-asoc-card: Add missing Kconfig option for tlv320aic31xx

The following commit added support for tlv320aic31xx codec to
fsl-asoc-card, but missed the related Kconfig option. Fix this.

  commit 8c9b9cfb7724685ce705f511b882f30597596536
  Author: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
  Date:   Fri Nov 19 12:32:48 2021 -0300

      ASoC: fsl-asoc-card: Support fsl,imx-audio-tlv320aic31xx codec

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Link: https://lore.kernel.org/r/20211203175018.252641-2-ariel.dalessandro@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Fix undefined reference to core functions
Lucas Tanure [Wed, 1 Dec 2021 18:00:04 +0000 (18:00 +0000)]
ASoC: cs35l41: Fix undefined reference to core functions

Auto select core driver if i2c or spi bus drivers are
selected

Fixes: a5e0091d62ab ("ASoC: cs35l41: Fix link problem")

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20211201180004.1402156-2-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: amd: Fix dependency for SPI master
Lucas Tanure [Wed, 1 Dec 2021 18:00:03 +0000 (18:00 +0000)]
ASoC: amd: Fix dependency for SPI master

Set SPI_MASTER as dependency as is using CS35L41 SPI driver

Fixes: 96792fdd77cd1 ("ASoC: amd: enable vangogh platform machine driver build")

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20211201180004.1402156-1-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Fix the wrong state of the JD in the HDA header
Oder Chiou [Wed, 1 Dec 2021 09:56:29 +0000 (17:56 +0800)]
ASoC: rt5640: Fix the wrong state of the JD in the HDA header

The patch fixes the wrong state of the JD with 1M pull up resistor in the
HDA header.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
Link: https://lore.kernel.org/r/20211201095629.21818-1-oder_chiou@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: wcd934x: remove redundant ret variable
Srinivas Kandagatla [Tue, 30 Nov 2021 16:05:05 +0000 (16:05 +0000)]
ASoC: codecs: wcd934x: remove redundant ret variable

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

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20211130160507.22180-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Add master volume/mute control support
Sameer Pujar [Tue, 30 Nov 2021 13:23:25 +0000 (18:53 +0530)]
ASoC: tegra: Add master volume/mute control support

The MVC module has a per channel control bit, based on which it decides
to apply channel specific volume/mute settings. When per channel control
bit is enabled (which is the default HW configuration), all MVC channel
volume/mute can be independently controlled. If the control is disabled,
channel-0 volume/mute setting is applied by HW to all remaining channels.
Thus add support to leverage this HW feature by exposing master controls
for volume/mute.

With this, now there are per channel and master volume/mute controls.
Users need to just use controls which are suitable for their applications.
The per channel control enable/disable is mananged in driver and hidden
from users, so that they need to just worry about respective volume/mute
controls.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1638278605-28225-1-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoMerge branch 'for-5.16' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
Mark Brown [Wed, 1 Dec 2021 14:15:12 +0000 (14:15 +0000)]
Merge branch 'for-5.16' of https://git./linux/kernel/git/broonie/sound into asoc-5.17 so we can apply new Tegra work

2 years agoASoC: Intel: boards: add max98390 2/4 speakers support
Mac Chiang [Thu, 25 Nov 2021 03:04:53 +0000 (22:04 -0500)]
ASoC: Intel: boards: add max98390 2/4 speakers support

support 2 hw boards.
1. SSP2 connects max98390, 2 speakers.
2. SSP1 connects max98390, 2/4 speakers.

2 or 4 speakers playback
add echo reference capture
add bt offload support
add DMI_OEM_STRING for board variants
add ALC5682I-VS support

Signed-off-by: Mark Hsieh <mark_hsieh@wistron.corp-partner.google.com>
Signed-off-by: Mac Chiang <mac.chiang@intel.com>
Signed-off-by: Kieth Tzeng <keith.tzeng@quantatw.com>
Signed-off-by: Brent Lu <brent.lu@intel.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211125030453.4382-1-mac.chiang@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: make several arrays static const
Colin Ian King [Mon, 29 Nov 2021 22:42:36 +0000 (22:42 +0000)]
ASoC: mediatek: mt8195: make several arrays static const

Don't populate various arrays on the stack but instead make them
static const. Also makes the object code smaller by a few hundred
bytes.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20211129224236.506883-1-colin.i.king@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agofirmware: cs_dsp: Move lockdep asserts to avoid potential null pointer
Charles Keepax [Tue, 30 Nov 2021 10:28:42 +0000 (10:28 +0000)]
firmware: cs_dsp: Move lockdep asserts to avoid potential null pointer

Move the lockdep asserts until after the ctl pointer has been checked
for NULL, to avoid potentially NULL pointer dereferences.

Fixes: fb2f364fb5b9 ("firmware: cs_dsp: Add lockdep asserts to interface functions")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211130102842.26410-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: intel: boards: bytcht*: Constify static snd_soc_ops
Rikard Falkeborn [Sat, 27 Nov 2021 09:19:54 +0000 (10:19 +0100)]
ASoC: intel: boards: bytcht*: Constify static snd_soc_ops

These are only assigned to the ops fields in the snd_soc_dai_link struct
which is a pointer to const struct snd_soc_ops. Make them const to allow
the compiler to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211127091954.12075-1-rikard.falkeborn@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: Intel: hda_dsp_common: don't multiline PCM topology warning
Chris Down [Sun, 28 Nov 2021 14:31:46 +0000 (14:31 +0000)]
ASoC: Intel: hda_dsp_common: don't multiline PCM topology warning

On my T14s Gen2 I saw the following:

    [   16.057258] skl_hda_dsp_generic skl_hda_dsp_generic: hda_dsp_hdmi_build_controls: no PCM in topology for HDMI converter 3

    [   16.057261] skl_hda_dsp_generic skl_hda_dsp_generic: hda_dsp_hdmi_build_controls: no PCM in topology for HDMI converter 4

    [   16.057263] skl_hda_dsp_generic skl_hda_dsp_generic: hda_dsp_hdmi_build_controls: no PCM in topology for HDMI converter 5

    [...and so on.]

It looks like the double newline is a mistake, so remove one.

Signed-off-by: Chris Down <chris@chrisdown.name>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/YaOS0sBueAfApwOx@chrisdown.name
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: mt8195: Constify static snd_soc_ops
Rikard Falkeborn [Sat, 27 Nov 2021 09:31:47 +0000 (10:31 +0100)]
ASoC: mediatek: mt8195: Constify static snd_soc_ops

These are only assigned to the ops field in the snd_soc_dai_link which
is a pointer to const struct snd_soc_ops. Make them const to allow the
compiler to put them in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20211127093147.17368-1-rikard.falkeborn@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: Retry codec probing if it fails
Hui Wang [Tue, 30 Nov 2021 09:06:06 +0000 (11:06 +0200)]
ASoC: SOF: Intel: Retry codec probing if it fails

On the latest Lenovo Thinkstation laptops, we often experience the
speaker failure after rebooting, check the dmesg, we could see:
 sof-audio-pci-intel-tgl 0000:00:1f.3: codec #0 probe error, ret: -5

The analogue codec on the machine is ALC287, then we designed a
testcase to reboot and check the codec probing result repeatedly, we
found the analogue codec probing always failed at least once within
several minutes to several hours (roughly 1 reboot per min). This
issue happens on all laptops of this Thinkstation model, but with
legacy HDA driver, we couldn't reproduce this issue on those laptops.
And so far, this issue is not reproduced on machines which don't
belong to this model.

We tried to make the hda_dsp_ctrl_init_chip() same as
hda_intel_init_chip() which is the controller init routine in the
legacy HDA driver, but it didn't help.

We found when issue happens, the resp is -1, and if we let driver
re-run send_cmd() and get_response(), it will get the correct response
10ec0287, then driver continues the rest work, finally boot to the
desktop and all audio function work well.

Here adding codec probing retries to 3 times, it could fix the issue
on this Thinkstation model, and it doesn't bring impact to other
machines.

Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211130090606.529348-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: amd: fix uninitialized variable in snd_acp6x_probe()
Dan Carpenter [Tue, 30 Nov 2021 12:56:33 +0000 (15:56 +0300)]
ASoC: amd: fix uninitialized variable in snd_acp6x_probe()

The "index" is potentially used without being initialized on the error
path.

Fixes: fc329c1de498 ("ASoC: amd: add platform devices for acp6x pdm driver and dmic driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20211130125633.GA24941@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rockchip: i2s_tdm: Dup static DAI template
Nicolas Frattaroli [Thu, 25 Nov 2021 08:48:59 +0000 (09:48 +0100)]
ASoC: rockchip: i2s_tdm: Dup static DAI template

Previously, the DAI template was used directly, which lead to
fun bugs such as "why is my channels_max changing?" when one
instantiated more than one i2s_tdm IP block in a device tree.

This change makes it so that we instead duplicate the template
struct, and then use that.

Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller")
Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Link: https://lore.kernel.org/r/20211125084900.417102-1-frattaroli.nicolas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-pcm: tidyup soc_pcm_pointer()'s delay update method
Mark Brown [Mon, 29 Nov 2021 16:43:16 +0000 (16:43 +0000)]
ASoC: soc-pcm: tidyup soc_pcm_pointer()'s delay update method

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Current soc_pcm_pointer() is checking runtime->delay,
but it might be updated silently by component's .point callback.
It is strange and difficult to find/know the issue.  This patch
adds .delay callback for component, and solve the issue.

2 years agoASoC: sunxi: sun4i-spdif: Implement IEC958 control
Jernej Skrabec [Wed, 17 Nov 2021 19:44:58 +0000 (20:44 +0100)]
ASoC: sunxi: sun4i-spdif: Implement IEC958 control

SPDIF core is capable of sending custom status.

Implement IEC958 control handling.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://lore.kernel.org/r/20211117194458.2249643-1-jernej.skrabec@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: qcom: Add support for ALC5682I-VS codec
lvzhaoxiong [Tue, 23 Nov 2021 02:43:29 +0000 (10:43 +0800)]
ASoC: qcom: Add support for ALC5682I-VS codec

Qcom machine driver adds rt5682s support in this patch.
Card name can be specified from dts by model property, and driver makes
use of the name to distinguish which headset codec is on the board.

Signed-off-by: lvzhaoxiong <lvzhaoxiong@huaqin.corp-partner.google.com>
Link: https://lore.kernel.org/r/20211123024329.21998-1-lvzhaoxiong@huaqin.corp-partner.google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: sun8i-codec: Add AIF, ADC, and DAC volume controls
Samuel Holland [Thu, 18 Nov 2021 03:36:45 +0000 (21:36 -0600)]
ASoC: sun8i-codec: Add AIF, ADC, and DAC volume controls

This allows changing the volume of each digital input/output
independently, and provides the only "master volume" for the DAC.
(The ADC also has a gain control on the analog side.)

While the hardware supports digital gain up to +72dB, the controls here
are limited to +24dB maximum, as any gain above that level makes volume
sliders difficult to use, and is extremely likely to cause clipping.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20211118033645.43524-1-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-pcm: tidyup soc_pcm_pointer()'s delay update method
Kuninori Morimoto [Tue, 16 Nov 2021 07:45:34 +0000 (16:45 +0900)]
ASoC: soc-pcm: tidyup soc_pcm_pointer()'s delay update method

No driver directly updates runtime->delay in .pointer.
This patch cleanups its method.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87zgq4wnkx.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: intel: sst-mfld-platform-pcm: add .delay support
Kuninori Morimoto [Tue, 16 Nov 2021 07:45:29 +0000 (16:45 +0900)]
ASoC: intel: sst-mfld-platform-pcm: add .delay support

Now ALSA SoC supports .delay for component.
This patch uses it, and not update runtime->delay on .pointer
directly / secretly.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871r3gy25j.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: amd: acp-pcm-dma: add .delay support
Kuninori Morimoto [Tue, 16 Nov 2021 07:45:23 +0000 (16:45 +0900)]
ASoC: amd: acp-pcm-dma: add .delay support

Now ALSA SoC supports .delay for component.
This patch uses it, and not update runtime->delay on .pointer
directly / secretly.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8735nwy25o.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-component: add snd_soc_pcm_component_delay()
Kuninori Morimoto [Tue, 16 Nov 2021 07:45:18 +0000 (16:45 +0900)]
ASoC: soc-component: add snd_soc_pcm_component_delay()

Current soc-pcm.c :: soc_pcm_pointer() is assuming that
component driver might update runtime->delay silently in
snd_soc_pcm_component_pointer() (= A).

static snd_pcm_uframes_t soc_pcm_pointer(...)
{
...

/* clearing the previous total delay */
=> runtime->delay = 0;

(A) offset = snd_soc_pcm_component_pointer(substream);

/* base delay if assigned in pointer callback */
=> delay = runtime->delay;
...
}

1) The behavior that ".pointer callback secretly updates
   runtime->delay" is strange and confusable.

2) Current snd_soc_pcm_component_pointer() uses 1st found component's
   .pointer callback only, thus it is no problem for now.
   But runtime->delay might be overwrote if it adjusted to multiple
   components in the future.

3) Component delay is updated at .pointer callback timing (secretly).
   But some components which doesn't have .pointer callback might want
   to increase runtime->delay for some reasons.

We already have .delay function for DAI, but not have for Component.
This patch adds new snd_soc_pcm_component_delay() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874k8cy25t.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-dai: update snd_soc_dai_delay() to snd_soc_pcm_dai_delay()
Kuninori Morimoto [Tue, 16 Nov 2021 07:45:12 +0000 (16:45 +0900)]
ASoC: soc-dai: update snd_soc_dai_delay() to snd_soc_pcm_dai_delay()

Current soc_pcm_pointer() is manually calculating
both CPU-DAI's   max delay (= A)
and  Codec-DAI's max delay (= B).

static snd_pcm_uframes_t soc_pcm_pointer(...)
{
...
 ^ for_each_rtd_cpu_dais(rtd, i, cpu_dai)
(A) cpu_delay = max(cpu_delay, ...);
 v delay += cpu_delay;

 ^ for_each_rtd_codec_dais(rtd, i, codec_dai)
(B) codec_delay = max(codec_delay, ...);
 v delay += codec_delay;

runtime->delay = delay;
...
}

Current soc_pcm_pointer() and the total delay calculating
is not readable / difficult to understand.

This patch update snd_soc_dai_delay() to snd_soc_pcm_dai_delay(),
and calcule both CPU/Codec delay in one function.

Link: https://lore.kernel.org/r/87fszl4yrq.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875yssy25z.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Fixes for Intel HD-Audio DMA stopping
Mark Brown [Sat, 27 Nov 2021 01:27:27 +0000 (01:27 +0000)]
ASoC: SOF: Fixes for Intel HD-Audio DMA stopping

Merge series from Kai Vehmanen <kai.vehmanen@linux.intel.com>:

Implement an updated programming sequence to handle DMA stop for Intel
HD-Audio DMA.

The new flow is only used if the firmware is sufficiently new to
support the feature. SOF1.9.2 is the first release with the updated
flow. The kernel changes are backwards compatible with old firmware
releases. Likewise new firmware releases will work with old kernel.

Series reviewed originally at:
https://github.com/thesofproject/linux/pull/3167

2 years agoSuspend related fixes on Tegra
Mark Brown [Sat, 27 Nov 2021 01:27:20 +0000 (01:27 +0000)]
Suspend related fixes on Tegra

Merge series from Sameer Pujar <spujar@nvidia.com>:

This series addresses following problems:
 * The runtime PM is not balanced in MVC driver, whenever
   mute or volume mixer controls are set.
 * Some of the AHUB devices (SFC, MVC, Mixer, AMX and ADX)
   use late system sleep. Suspend failure is seen on Jetson
   TX2 platform.

2 years agoASoC: SOF: mediatek: Use %pR/%pa to print resources/physical addresses
Geert Uytterhoeven [Tue, 23 Nov 2021 10:30:13 +0000 (11:30 +0100)]
ASoC: SOF: mediatek: Use %pR/%pa to print resources/physical addresses

On 32-bit with CONFIG_ARCH_DMA_ADDR_T_64BIT=n:

    sound/soc/sof/mediatek/mt8195/mt8195.c: In function ‘platform_parse_resource’:
    sound/soc/sof/mediatek/mt8195/mt8195.c:51:15: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘unsigned int’ [-Werror=format=]
       51 |  dev_dbg(dev, "DMA pbase=0x%llx, size=0x%llx\n",
  |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    sound/soc/sof/mediatek/mt8195/mt8195.c: In function ‘adsp_memory_remap_init’:
    sound/soc/sof/mediatek/mt8195/mt8195.c:167:15: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Werror=format=]
      167 |  dev_dbg(dev, "adsp->pa_dram %llx, offset %#x\n", adsp->pa_dram, offset);
  |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    sound/soc/sof/mediatek/mt8195/mt8195.c: In function ‘adsp_shared_base_ioremap’:
    sound/soc/sof/mediatek/mt8195/mt8195.c:196:15: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Werror=format=]
      196 |  dev_dbg(dev, "shared-dram vbase=%p, phy addr :%llx,  size=%#x\n",
  |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix the first cases by printing the full resource using %pR.
Fix the other cases by printing the physical addresses using %pa.

Reported-by: noreply@ellerman.id.au
Fixes: 32d7e03d26fd9318 ("ASoC: SOF: mediatek: Add mt8195 hardware support")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/r/20211123103013.73645-1-geert@linux-m68k.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Fix link problem
Lucas Tanure [Thu, 25 Nov 2021 14:35:01 +0000 (14:35 +0000)]
ASoC: cs35l41: Fix link problem

Can't link I2C and SPI to the same binary, better
to move CS35L41 to 3 modules approach.
And instead of exposing cs35l41_reg, volatile_reg,
readable_reg and precious_reg arrays, move
cs35l41_regmap_i2c/spi to new module and expose it.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211125143501.7720-1-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs/jz4770: Add missing gain control after DAC/ADC mixer
Paul Cercueil [Thu, 25 Nov 2021 23:25:43 +0000 (23:25 +0000)]
ASoC: codecs/jz4770: Add missing gain control after DAC/ADC mixer

The capture and playback paths both have a configurable gain after their
respective mixer, which can be set from -31 dB to 0 dB in 32 steps.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20211125232543.117074-1-paul@crapouillou.net
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: imx-hdmi: add put_device() after of_find_device_by_node()
Ye Guojin [Wed, 10 Nov 2021 00:29:10 +0000 (00:29 +0000)]
ASoC: imx-hdmi: add put_device() after of_find_device_by_node()

This was found by coccicheck:
./sound/soc/fsl/imx-hdmi.c,209,1-7,ERROR  missing put_device; call
of_find_device_by_node on line 119, but without a corresponding object
release within this function.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
Link: https://lore.kernel.org/r/20211110002910.134915-1-ye.guojin@zte.com.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: hda: send DAI_CONFIG IPC during pause
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:20 +0000 (12:15 +0200)]
ASoC: SOF: Intel: hda: send DAI_CONFIG IPC during pause

For HDA DAI's the DMA must be paused after the RUN bit is cleared by the
host. So, send the DAI_CONFIG IPC with just the SOF_DAI_CONFIG_FLAGS_PAUSE
flag set to indicate this to the firmware.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-11-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: IPC: dai: Expand DAI_CONFIG IPC flags
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:19 +0000 (12:15 +0200)]
ASoC: SOF: IPC: dai: Expand DAI_CONFIG IPC flags

Some DAI components, such as HDaudio, need to be stopped in two steps
a) stop the DAI component
b) stop the DAI DMA

This patch enables this two-step stop by expanding the DAI_CONFIG
IPC flags and split them into 2 parts.

The 4 LSB bits indicate when the DAI_CONFIG IPC is sent, ex: hw_params,
hw_free or pause. The 4 MSB bits are used as the quirk flags to be used
along with the command flags. The quirk flag called
SOF_DAI_CONFIG_FLAGS_2_STEP_STOP shall be set along with the HW_PARAMS
command flag, i.e. before the pipeline is started so that the stop/pause
trigger op in the FW can take the appropriate action to either
perform/skip the DMA stop. If set, the DMA stop will be executed when
the DAI_CONFIG IPC is sent during hw_free. In the case of pause, DMA
pause will be handled when the DAI_CONFIG IPC is sent with the PAUSE
command flag.

Along with this, modify the signature for the hda_ctrl_dai_widget_setup/
hda_ctrl_dai_widget_free() functions to take additional flags as an
argument and modify all users to pass the appropriate quirk flags. Only
the HDA DAI's need to pass the SOF_DAI_CONFIG_FLAGS_2_STEP_STOP quirk
flag during hw_params to indicate that it supports two-step stop and
pause.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-10-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: align the hw_free sequence with stop
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:18 +0000 (12:15 +0200)]
ASoC: SOF: align the hw_free sequence with stop

Even though the order of stopping the DMA and freeing the widget list is
not important, align the sequence to match with the stop trigger to
avoid confusion.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-9-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: pcm: move the check for prepared flag
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:17 +0000 (12:15 +0200)]
ASoC: SOF: pcm: move the check for prepared flag

Move the check for the prepared flag inside snd_pcm_dsp_pcm_free() to
avoid having to check it before every invocation of the function.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-8-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Add a helper for freeing PCM stream
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:16 +0000 (12:15 +0200)]
ASoC: SOF: Add a helper for freeing PCM stream

Add a helper function to free PCM in the FW, stop the DMA and free the
widget list. These actions are performed both during PCM trigger STOP
and when a paused stream is freed during system suspend.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-7-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: call platform hw_free for paused streams during suspend
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:15 +0000 (12:15 +0200)]
ASoC: SOF: call platform hw_free for paused streams during suspend

Paused streams must be stopped and platform hw_free should be invoked
during system suspend so they can be restarted properly after system
resume.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-6-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: pcm: invoke platform hw_free for STOP/SUSPEND triggers
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:14 +0000 (12:15 +0200)]
ASoC: SOF: pcm: invoke platform hw_free for STOP/SUSPEND triggers

snd_sof_pcm_platform_hw_params() will be called when the stream is
restarted with a prepare ioctl. This happens in two cases i.e. when a
suspended stream is resumed or when a stream is restarted without
intermediate call to sof_pcm_hw_free(). Make sure to call
snd_sof_pcm_platform_hw_free() in both these cases to keep it balanced.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-5-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: hda: reset stream before coupling host and link DMA's
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:13 +0000 (12:15 +0200)]
ASoC: SOF: Intel: hda: reset stream before coupling host and link DMA's

The recommended programming sequence for HD-Audio DMA is to reset the
stream before coupling the link and host DMA's.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-4-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: hda: Add a helper function for stream reset
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:12 +0000 (12:15 +0200)]
ASoC: SOF: Intel: hda: Add a helper function for stream reset

Add a helper function to perform stream reset.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: hda: clear stream before freeing the DAI widget
Ranjani Sridharan [Thu, 25 Nov 2021 10:15:11 +0000 (12:15 +0200)]
ASoC: SOF: Intel: hda: clear stream before freeing the DAI widget

The DAI_CONFIG IPC that is sent during the STOP trigger is used for
stopping the DMA in the FW. This must be done after the DMA RUN bit is
cleared by the host. So move the call to snd_hdac_ext_link_stream_clear()
before hda_link_dai_widget_update() to follow the correct programming
sequence for DMA stop for HDA DAIs.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211125101520.291581-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5682s: Fix crash due to out of scope stack vars
Rob Clark [Thu, 18 Nov 2021 01:04:53 +0000 (17:04 -0800)]
ASoC: rt5682s: Fix crash due to out of scope stack vars

Move the declaration of temporary arrays to somewhere that won't go out
of scope before the devm_clk_hw_register() call, lest we be at the whim
of the compiler for whether those stack variables get overwritten.

Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)

Fixes: bdd229ab26be ("ASoC: rt5682s: Add driver for ALC5682I-VS codec")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20211118010453.843286-2-robdclark@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5682: Fix crash due to out of scope stack vars
Rob Clark [Thu, 18 Nov 2021 01:04:52 +0000 (17:04 -0800)]
ASoC: rt5682: Fix crash due to out of scope stack vars

Move the declaration of temporary arrays to somewhere that won't go out
of scope before the devm_clk_hw_register() call, lest we be at the whim
of the compiler for whether those stack variables get overwritten.

Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)

Fixes: edbd24ea1e5c ("ASoC: rt5682: Drop usage of __clk_get_name()")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20211118010453.843286-1-robdclark@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Use normal system sleep for ADX
Sameer Pujar [Tue, 23 Nov 2021 14:07:39 +0000 (19:37 +0530)]
ASoC: tegra: Use normal system sleep for ADX

The driver currently subscribes for a late system sleep call.
The initcall_debug log shows that suspend call for ADX device
happens after the parent device (AHUB). This seems to cause
suspend failure on Jetson TX2 platform. Also there is no use
of having late system sleep specifically for ADX device. Fix
the order by using normal system sleep.

Fixes: a99ab6f395a9 ("ASoC: tegra: Add Tegra210 based ADX driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1637676459-31191-7-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Use normal system sleep for AMX
Sameer Pujar [Tue, 23 Nov 2021 14:07:38 +0000 (19:37 +0530)]
ASoC: tegra: Use normal system sleep for AMX

The driver currently subscribes for a late system sleep call.
The initcall_debug log shows that suspend call for AMX device
happens after the parent device (AHUB). This seems to cause
suspend failure on Jetson TX2 platform. Also there is no use
of having late system sleep specifically for AMX device. Fix
the order by using normal system sleep.

Fixes: 77f7df346c45 ("ASoC: tegra: Add Tegra210 based AMX driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1637676459-31191-6-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Use normal system sleep for Mixer
Sameer Pujar [Tue, 23 Nov 2021 14:07:37 +0000 (19:37 +0530)]
ASoC: tegra: Use normal system sleep for Mixer

The driver currently subscribes for a late system sleep call.
The initcall_debug log shows that suspend call for Mixer device
happens after the parent device (AHUB). This seems to cause
suspend failure on Jetson TX2 platform. Also there is no use
of having late system sleep specifically for Mixer device. Fix
the order by using normal system sleep.

Fixes: 05bb3d5ec64a ("ASoC: tegra: Add Tegra210 based Mixer driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1637676459-31191-5-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Use normal system sleep for MVC
Sameer Pujar [Tue, 23 Nov 2021 14:07:36 +0000 (19:37 +0530)]
ASoC: tegra: Use normal system sleep for MVC

The driver currently subscribes for a late system sleep call.
The initcall_debug log shows that suspend call for MVC device
happens after the parent device (AHUB). This seems to cause
suspend failure on Jetson TX2 platform. Also there is no use
of having late system sleep specifically for MVC device. Fix
the order by using normal system sleep.

Fixes: e539891f9687 ("ASoC: tegra: Add Tegra210 based MVC driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1637676459-31191-4-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Use normal system sleep for SFC
Sameer Pujar [Tue, 23 Nov 2021 14:07:35 +0000 (19:37 +0530)]
ASoC: tegra: Use normal system sleep for SFC

The driver currently subscribes for a late system sleep call.
The initcall_debug log shows that suspend call for SFC device
happens after the parent device (AHUB). This seems to cause
suspend failure on Jetson TX2 platform. Also there is no use
of having late system sleep specifically for SFC device. Fix
the order by using normal system sleep.

Fixes: b2f74ec53a6c ("ASoC: tegra: Add Tegra210 based SFC driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1637676459-31191-3-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Balance runtime PM count
Sameer Pujar [Tue, 23 Nov 2021 14:07:34 +0000 (19:37 +0530)]
ASoC: tegra: Balance runtime PM count

After successful application of volume/mute settings via mixer control
put calls, the control returns without balancing the runtime PM count.
This makes device to be always runtime active. Fix this by allowing
control to reach pm_runtime_put() call.

Fixes: e539891f9687 ("ASoC: tegra: Add Tegra210 based MVC driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1637676459-31191-2-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Add the HDA header support
Oder Chiou [Thu, 25 Nov 2021 05:58:12 +0000 (13:58 +0800)]
ASoC: rt5640: Add the HDA header support

The patch adds the HDA header support.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
Link: https://lore.kernel.org/r/20211125055812.8911-2-oder_chiou@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rt5640: Add the binding include file for the HDA header support
Oder Chiou [Thu, 25 Nov 2021 05:58:11 +0000 (13:58 +0800)]
ASoC: rt5640: Add the binding include file for the HDA header support

The patch adds the binding include file for the HDA header support.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
Link: https://lore.kernel.org/r/20211125055812.8911-1-oder_chiou@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: codecs: wcd938x: add SND_SOC_WCD938_SDW to codec list instead
Lukas Bulwahn [Thu, 25 Nov 2021 09:51:58 +0000 (10:51 +0100)]
ASoC: codecs: wcd938x: add SND_SOC_WCD938_SDW to codec list instead

Commit 045442228868 ("ASoC: codecs: wcd938x: add audio routing and
Kconfig") adds SND_SOC_WCD937X, which does not exist, and
SND_SOC_WCD938X, which seems not really to be the intended config to be
selected, but only a supporting config symbol to the actual config
SND_SOC_WCD938X_SDW for the codec.

Add SND_SOC_WCD938_SDW to the list instead of SND_SOC_WCD93{7,8}X.

The issue was identified with ./scripts/checkkconfigsymbols.py.

Fixes: 045442228868 ("ASoC: codecs: wcd938x: add audio routing and Kconfig")
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20211125095158.8394-3-lukas.bulwahn@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: uniphier: drop selecting non-existing SND_SOC_UNIPHIER_AIO_DMA
Lukas Bulwahn [Thu, 25 Nov 2021 09:51:57 +0000 (10:51 +0100)]
ASoC: uniphier: drop selecting non-existing SND_SOC_UNIPHIER_AIO_DMA

Commit f37fe2f9987b ("ASoC: uniphier: add support for UniPhier AIO common
driver") adds configs SND_SOC_UNIPHIER_{LD11,PXS2}, which select the
non-existing config SND_SOC_UNIPHIER_AIO_DMA.

Hence, ./scripts/checkkconfigsymbols.py warns:

  SND_SOC_UNIPHIER_AIO_DMA
  Referencing files: sound/soc/uniphier/Kconfig

Probably, there is actually no further config intended to be selected
here. So, just drop selecting the non-existing config.

Fixes: f37fe2f9987b ("ASoC: uniphier: add support for UniPhier AIO common driver")
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20211125095158.8394-2-lukas.bulwahn@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: mediatek: Add missing of_node_put() in platform_parse_resource()
Yang Yingliang [Thu, 25 Nov 2021 07:16:08 +0000 (15:16 +0800)]
ASoC: SOF: mediatek: Add missing of_node_put() in platform_parse_resource()

The node pointer is returned by of_parse_phandle() with
refcount incremented in platform_parse_resource(). Calling
of_node_put() to aovid the refcount leak.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20211125071608.3056715-1-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: mediatek: remove unnecessary CONFIG_PM
Jiaxin Yu [Thu, 25 Nov 2021 04:24:22 +0000 (12:24 +0800)]
ASoC: mediatek: remove unnecessary CONFIG_PM

The unnecessary conditional inclusion caused the following warning.

Such as:
>> sound/soc/mediatek/mt8192/mt8192-afe-pcm.c:2368:32: warning: unused
>> variable 'mt8192_afe_pm_ops' [-Wunused-const-variable]
   static const struct dev_pm_ops mt8192_afe_pm_ops = {

Because runtime_pm already handles the case without CONFIG_PM, we
can remove CONFIG_PM condition.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
Reported-by: kernel test robot <lkp@intel.com>
Acked-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20211125042422.2349-1-jiaxin.yu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: dt-bindings: wlf,wm8962: add missing interrupt property
David Heidelberg [Wed, 24 Nov 2021 15:51:01 +0000 (16:51 +0100)]
ASoC: dt-bindings: wlf,wm8962: add missing interrupt property

Both, hardware and drivers does support interrupts.

Fix warnings as:
arch/arm/boot/dts/tegra30-microsoft-surface-rt-efi.dt.yaml: audio-codec@1a: 'interrupt-parent', 'interrupts' do not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /home/runner/work/linux/linux/Documentation/devicetree/bindings/sound/wlf,wm8962.yaml

Fixes: cd51b942f344 ("ASoC: dt-bindings: wlf,wm8962: Convert to json-schema")

Signed-off-by: David Heidelberg <david@ixit.cz>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20211124155101.59694-1-david@ixit.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: power optimizations with HDaudio SPIB register
Mark Brown [Wed, 24 Nov 2021 17:33:54 +0000 (17:33 +0000)]
ASoC: SOF: Intel: power optimizations with HDaudio SPIB register

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

The use of the SPIB register helps reduce power consumption - though
to a smaller degree than DMI_L1. This hardware capability is however
incompatible with userspace-initiated rewinds typically used by
PulseAudio.

In the past (2015..2017) Intel suggested an API extension to let
applications disable rewinds. At the time the feedback was that such a
capability was too Intel-specific and SPIB remained unused except for
loading DSP code. We now see devices with smaller batteries being
released, and it's time to revisit Linux support for SPIB to extend
battery life.

In this update the rewinds are disabled via an opt-in kernel
parameter. In the previous reviews, there was consensus that a Kconfig
option was too complicated for distributions to set, and we are
missing a TBD API to expose such capabilities to user-space.

The debate on whether or not to use rewinds, and the impact of
disabling rewinds, will likely be closed when Intel releases the
'deep-buffer' support, currently under development [2][3]. With this
solution, rewinds will not be needed, ever. When an application deals
with content that is not latency-sensitive (e.g. music playback), it
will be able to reduce power consumption by selecting a different PCM
device with increased buffering capabilities.  Low-latency streams
will be handled by the 'regular' path. In other words, the impossible
compromise between power and latency will be handled with different
PCM devices/profiles for the same endpoint, and we can push the design
of capability negotiation to a later time when all the building blocks
(firmware topology, kernel, userspace) are ready - we still have
firmware xruns, DPCM race conditions to solve, and a need to describe
these alternate PCM devices with UCM using 'modifiers'.

2 years agoASoC: SOF: handle paused streams during system suspend
Ranjani Sridharan [Tue, 23 Nov 2021 17:16:06 +0000 (19:16 +0200)]
ASoC: SOF: handle paused streams during system suspend

During system suspend, paused streams do not get suspended.
Therefore, we need to explicitly free these PCMs in the DSP
and free the associated DAPM widgets so that they can be set
up again during resume.

Fixes: 5fcdbb2d45df ("ASoC: SOF: Add support for dynamic pipelines")
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211123171606.129350-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: topology: don't use list_for_each_entry_reverse()
Pierre-Louis Bossart [Tue, 23 Nov 2021 17:16:05 +0000 (19:16 +0200)]
ASoC: SOF: topology: don't use list_for_each_entry_reverse()

It's not clear why we would walk the list backwards. That makes no
difference.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211123171606.129350-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: sof-audio: setup sched widgets during pipeline complete step
Pierre-Louis Bossart [Tue, 23 Nov 2021 17:16:04 +0000 (19:16 +0200)]
ASoC: SOF: sof-audio: setup sched widgets during pipeline complete step

Older firmware prior to ABI 3.19 has a dependency where the scheduler
widgets need to be setup last. Moving the call to sof_widget_setup()
before the pipeline_complete() call also helps remove the need for the
'reverse' direction when walking through the widget list - this was
only working because of the topology macros but the topology does not
require any order.

Fixes: 5fcdbb2d45df ("ASoC: SOF: Add support for dynamic pipelines")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211123171606.129350-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: add .ack support for HDaudio platforms
Ranjani Sridharan [Fri, 19 Nov 2021 23:08:52 +0000 (17:08 -0600)]
ASoC: SOF: Intel: add .ack support for HDaudio platforms

When we disable rewinds, then the .ack can be used to program SPIB
with the application pointer, which allows the HDaudio DMA to save
power by opportunistically bursting data transfers when the path to
memory is enabled (and conversely to shut it down when there are no
transfer requests).

The SPIB register can only be programmed with incremental values with
wrap-around after the DMA RUN bits are set. For simplicity, we set the
INFO_NO_REWINDS flag in the .open callback when we already need to
program the SNDRV_PCM_INFO_SYNC_APPLPTR flag.

Rewinds are not used by many applications. One notable application
using rewinds is PulseAudio. Practical experiments with
Ubuntu/PulseAudio default settings did not show any audible issues,
but the user may hear volume changes and notification with a delay,
depending on the size of the ring buffer and latency constraints.

The choice of disabling rewinds is exposed as a kernel parameter and
not a Kconfig option to avoid any undesirable side-effects.

Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
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>
Link: https://lore.kernel.org/r/20211119230852.206310-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: pcm: add .ack callback support
Ranjani Sridharan [Fri, 19 Nov 2021 23:08:51 +0000 (17:08 -0600)]
ASoC: SOF: pcm: add .ack callback support

Add the indirections required at the core level for platform-specific
operations on ack.

Note that on errors in the .ack the ALSA core will restore the
previous appl_ptr.

Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119230852.206310-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoALSA: pcm: introduce INFO_NO_REWINDS flag
Pierre-Louis Bossart [Fri, 19 Nov 2021 23:08:50 +0000 (17:08 -0600)]
ALSA: pcm: introduce INFO_NO_REWINDS flag

When the hardware can only deal with a monotonically increasing
appl_ptr, this flag can be set.

In case the application requests a rewind, be it with a
snd_pcm_rewind() or with a direct change of a mmap'ed pointer followed
by a SNDRV_PCM_IOCTL_SYNC_PTR, this patch checks if a rewind
occurred and returns an error.

Credits to Takashi Iwai for identifying the path with SYNC_PTR and
suggesting the pointer checks.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119230852.206310-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoALSA: pcm: unconditionally check if appl_ptr is in 0..boundary range
Pierre-Louis Bossart [Fri, 19 Nov 2021 23:08:49 +0000 (17:08 -0600)]
ALSA: pcm: unconditionally check if appl_ptr is in 0..boundary range

In some cases, the appl_ptr passed by userspace is not checked before
being used. This patch adds an unconditional check and returns an
error code should the appl_ptr exceed the ALSA 'boundary'.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119230852.206310-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: hda: reset DAI widget before reconfiguring it
Ranjani Sridharan [Tue, 23 Nov 2021 16:57:59 +0000 (18:57 +0200)]
ASoC: SOF: hda: reset DAI widget before reconfiguring it

It is not unusual for ALSA/ASoC hw_params callbacks to be invoked
multiple times. Reset and free the DAI widget before reconfiguring
it to keep the DAI widget use_count balanced.

Fixes: 0acb48dd31e3 ("ASoC: SOF: Intel: hda: make sure DAI widget is set up before IPC")
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211123165759.127884-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs35l41: Set the max SPI speed for the whole device
Lucas Tanure [Tue, 23 Nov 2021 16:31:39 +0000 (16:31 +0000)]
ASoC: cs35l41: Set the max SPI speed for the whole device

Higher speeds are only supported when PLL is enabled, but
the current driver doesn't enable PLL outside of stream
use cases, so better to set the lowest SPI speed accepted
by the entire device.

Move the current frequency set to the spi sub-driver so
the whole device can benefit from that speed.

spi-max-frequency property could be used, but ACPI systems don't
support it, so by setting it in the spi sub-driver probe
both Device Trees and ACPI systems are supported.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211123163149.1530535-2-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: Intel: soc-acpi: add entry for ESSX8336 on CML
Pierre-Louis Bossart [Mon, 22 Nov 2021 23:23:56 +0000 (17:23 -0600)]
ASoC: Intel: soc-acpi: add entry for ESSX8336 on CML

We have configurations for this codec on APL, GLK, JSL and TGL, somehow the
information that some designs rely on CometLake was not shared.

BugLink: https://github.com/thesofproject/linux/issues/3248
Fixes: 790049fb6623 ("ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211122232356.23505-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Add PM support for i.MX8/i.MX8X/i.MX8M
Mark Brown [Mon, 22 Nov 2021 23:57:32 +0000 (23:57 +0000)]
ASoC: SOF: Add PM support for i.MX8/i.MX8X/i.MX8M

Merge series from Daniel Baluta <daniel.baluta@oss.nxp.com>:

This patch series adds support for System PM and Runtime PM with
SOF for i.MX8 platforms.

2 years agoASoC: stm32: add pm runtime support
Mark Brown [Mon, 22 Nov 2021 23:56:02 +0000 (23:56 +0000)]
ASoC: stm32: add pm runtime support

Merge series from Olivier Moysan <olivier.moysan@foss.st.com>:

Enable support of pm runtime on STM32 SPDIFRX, I2S and DFSDM drivers
to allow power state monitoring.

2 years agoSupport BCLK input clock in tlv320aic31xx
Mark Brown [Mon, 22 Nov 2021 23:56:00 +0000 (23:56 +0000)]
Support BCLK input clock in tlv320aic31xx

Merge series from Ariel D'Alessandro <ariel.dalessandro@collabora.com>:

This patchset modifies the tlv320aic31xx driver to update its sysclk if
BCLK is used as the input clock. This allows to be used by the generic
fsl-asoc-card, without having to add a specific driver.

2 years agoASoC: SOF: enable multicore with dynamic pipelines
Mark Brown [Mon, 22 Nov 2021 23:55:59 +0000 (23:55 +0000)]
ASoC: SOF: enable multicore with dynamic pipelines

Merge series from Kai Vehmanen <kai.vehmanen@linux.intel.com>:

When a pipeline is marked dynamic in the SOF DSP firmware
topology definition (the tplg file kernel loads from filesystem),
it means the pipeline resources are not allocated when DSP is
booted (at driver probe, or at runtime resume), but rather delayed
until the pipeline is actually used.

2 years agoASoC: fsl-asoc-card: Support fsl,imx-audio-tlv320aic31xx codec
Ariel D'Alessandro [Fri, 19 Nov 2021 15:32:48 +0000 (12:32 -0300)]
ASoC: fsl-asoc-card: Support fsl,imx-audio-tlv320aic31xx codec

Add entry for fsl,imx-audio-tlv320aic31xx audio codec. This codec is
configured to use BCLK as clock input.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Link: https://lore.kernel.org/r/20211119153248.419802-6-ariel.dalessandro@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tlv320aic31xx: Handle BCLK set as PLL input configuration
Ariel D'Alessandro [Fri, 19 Nov 2021 15:32:47 +0000 (12:32 -0300)]
ASoC: tlv320aic31xx: Handle BCLK set as PLL input configuration

If BCLK is used as PLL input, the sysclk is determined by the hw
params. So it must be updated here to match the input frequency, based
on sample rate, format and channels.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Link: https://lore.kernel.org/r/20211119153248.419802-5-ariel.dalessandro@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tlv320aic31xx: Add divs for bclk as clk_in
Ariel D'Alessandro [Fri, 19 Nov 2021 15:32:46 +0000 (12:32 -0300)]
ASoC: tlv320aic31xx: Add divs for bclk as clk_in

Add divisors for rates needed when the clk_in is set to BCLK.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Link: https://lore.kernel.org/r/20211119153248.419802-4-ariel.dalessandro@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tlv320aic31xx: Add support for pll_r coefficient
Ariel D'Alessandro [Fri, 19 Nov 2021 15:32:45 +0000 (12:32 -0300)]
ASoC: tlv320aic31xx: Add support for pll_r coefficient

When the clock used by the codec is BCLK, the operation parameters need
to be calculated from input sample rate and format. Low frequency rates
required different r multipliers, in order to achieve a higher PLL
output frequency.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Link: https://lore.kernel.org/r/20211119153248.419802-3-ariel.dalessandro@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tlv320aic31xx: Fix typo in BCLK clock name
Ariel D'Alessandro [Fri, 19 Nov 2021 15:32:44 +0000 (12:32 -0300)]
ASoC: tlv320aic31xx: Fix typo in BCLK clock name

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Link: https://lore.kernel.org/r/20211119153248.419802-2-ariel.dalessandro@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: cs42l42: Report initial jack state
Richard Fitzgerald [Fri, 19 Nov 2021 12:48:54 +0000 (12:48 +0000)]
ASoC: cs42l42: Report initial jack state

When a jack handler is registered in cs42l42_set_jack() the
initial state should be reported if an attached headphone/headset
has already been detected.

The jack detect sequence takes around 1 second: typically long
enough for the machine driver to probe and register the jack handler
in time to receive the first report from the interrupt handler. So
it is possible on some systems that the correct initial state was seen
simply because of lucky timing. Modular builds were more likely to
miss the reporting of the initial state.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 4ca239f33737 ("ASoC: cs42l42: Always enable TS_PLUG and TS_UNPLUG interrupts")
Link: https://lore.kernel.org/r/20211119124854.58939-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: sof-pci-dev: use community key on all Up boards
Pierre-Louis Bossart [Fri, 19 Nov 2021 23:13:27 +0000 (17:13 -0600)]
ASoC: SOF: sof-pci-dev: use community key on all Up boards

There are already 3 versions of the Up boards with support for the SOF
community key (ApolloLake, WhiskyLake, TigerLake). Rather than
continue to add quirks for each version, let's add a wildcard.

For WHL and TGL, the authentication supports both the SOF community
key and the firmware signed with the Intel production key. Given two
choices, the community key is the preferred option to allow developers
to sign their own firmware. The firmware signed with production key
can still be selected if needed with a kernel module
option (snd-sof-pci.fw_path="intel/sof")

Tested-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-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>
Link: https://lore.kernel.org/r/20211119231327.211946-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: stm32: spdifrx: add pm_runtime support
Olivier Moysan [Fri, 19 Nov 2021 10:47:52 +0000 (11:47 +0100)]
ASoC: stm32: spdifrx: add pm_runtime support

Enable support of pm_runtime on STM32 SPDIFRX driver to allow
SPDIFRX power state monitoring.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://lore.kernel.org/r/20211119104752.13564-4-olivier.moysan@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: stm32: dfsdm: add pm_runtime support for audio
Olivier Moysan [Fri, 19 Nov 2021 10:47:51 +0000 (11:47 +0100)]
ASoC: stm32: dfsdm: add pm_runtime support for audio

Enable support of pm_runtime on STM32 DFSDM audio driver
to allow power state monitoring.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://lore.kernel.org/r/20211119104752.13564-3-olivier.moysan@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: stm32: i2s: add pm_runtime support
Olivier Moysan [Fri, 19 Nov 2021 10:47:50 +0000 (11:47 +0100)]
ASoC: stm32: i2s: add pm_runtime support

Enable support of pm_runtime on STM32 I2S driver to allow
I2S power state monitoring.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://lore.kernel.org/r/20211119104752.13564-2-olivier.moysan@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: hda: free DAI widget during stop and suspend
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:21 +0000 (21:26 +0200)]
ASoC: SOF: Intel: hda: free DAI widget during stop and suspend

To keep the widget use_counts balanced, free the DAI widget
during suspend and also during the stop trigger.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-11-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: add support for dynamic pipelines with multi-core
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:20 +0000 (21:26 +0200)]
ASoC: SOF: add support for dynamic pipelines with multi-core

This patch adds support for dynamic pipelines with multi-core
by using the platform-specific core_get/put() ops to
power up/down a core when a widget is set up/freed.

Along with this, a few redundant functions are removed:
1. sof_pipeline_core_enable() is no longer needed as the
pipeline core will be set up when the pipeline widget
is set up
2. sof_core_enable() is replaced with snd_sof_core_get()
4. core_power_up/down() DSP ops are deprecated and replaced with
core get/put ops.
5. Core power down in sof_widget_unload() during topology
removal is also removed as it is not really needed. For dynamic
pipelines, the cores will be powered off when they are not used.
For static pipelines, the cores will be powered off in the device
remove callback.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-10-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: hda: don't use the core op for power up/power down
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:19 +0000 (21:26 +0200)]
ASoC: SOF: hda: don't use the core op for power up/power down

The core_power_up/down() ops will be deprecated. Use the
HDA platform-specific functions for powering up/down
the cores during probe/suspend/remove. The enabled_cores_mask
and the core ref_count's are manually updated in each of
these functions.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-9-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: free widgets in sof_tear_down_pipelines() for static pipelines
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:18 +0000 (21:26 +0200)]
ASoC: SOF: free widgets in sof_tear_down_pipelines() for static pipelines

Free widgets for static pipelines in sof_tear_down_pipelines().
But this feature is unavailable in older firmware with ABI < 3.19.
Just reset widget use_count's for this case. This would ensure that
the secondary cores enabled required for topology setup are powered
down properly before the primary core is powered off during
system suspend.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-8-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: topology: remove sof_load_pipeline_ipc()
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:17 +0000 (21:26 +0200)]
ASoC: SOF: topology: remove sof_load_pipeline_ipc()

Remove the function sof_load_pipeline_ipc() and directly
send the IPC instead. The pipeline core is already enabled
with the call to sof_pipeline_core_enable() in sof_widget_setup().

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-7-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: CNL/ICL/APL: set core_get/core_put ops
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:16 +0000 (21:26 +0200)]
ASoC: SOF: Intel: CNL/ICL/APL: set core_get/core_put ops

Set core_get/put ops for CNL/ICL platforms. These platforms
do not support enabling/disabling secondary cores
dynamically. So skip sending the IPC to power off the
cores in the core_put op.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-6-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: TGL: set core_get/put ops
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:15 +0000 (21:26 +0200)]
ASoC: SOF: Intel: TGL: set core_get/put ops

Set core_get/put() ops for TGL. When core_get()
is requested for a core, its ref_count is incremented
and the PM_CORE_ENABLE IPC sent to the firmware to
power up the core if the current ref_count is 1.
Conversely, the ref_count is decremented in core_put()
and an IPC is sent to the DSP to power off the core
if the ref_count is 0.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-5-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Add ops for core_get and core_put
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:14 +0000 (21:26 +0200)]
ASoC: SOF: Add ops for core_get and core_put

Add ops to get/put a core that will be used to power
up/down a core along with incrementing/decrementing
its ref_count.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-4-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Introduce num_cores and ref count per core
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:13 +0000 (21:26 +0200)]
ASoC: SOF: Introduce num_cores and ref count per core

Add two fields num_cores and dsp_cores_ref_count to
struct snd_sof_dev. These will be used to maintain the
ref count for each core to determine when it should be
powered up or down.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: Intel: hda: expose get_chip_info()
Ranjani Sridharan [Fri, 19 Nov 2021 19:26:12 +0000 (21:26 +0200)]
ASoC: SOF: Intel: hda: expose get_chip_info()

expose get_chip_info().

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119192621.4096077-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: imx8m: Implement reset callback
Daniel Baluta [Fri, 19 Nov 2021 09:43:19 +0000 (11:43 +0200)]
ASoC: SOF: imx8m: Implement reset callback

Resume common flow (System PM / Runtime PM) is like this:

    sof_resume
      -> specific device resume
      -> snd_sof_load_firmware
         -> snd_sof_dsp_reset (1)
         -> load_modules()
      -> snd_sof_run_firmware (2)

    We need to implement dsp_reset callback (1) that will actually reset
    the DSP but keep it stalled.

    In order to implement this we do the following:
            -> put DSP into reset (assert CoreReset bit from PWRCTL)
            -> stall the DSP using RunStall bit from AudioDSP_REG2 mix
            -> take DSP out of reset (de-assert CoreReset bit from PWRCTL)

    At this moment the DSP is taken out of reset and Stalled! This means
    that we can load the firmware and then start the DSP (2).

    Until now we resetted the DSP by turning down the Audiomix PD. This
    doesn't work for Runtime PM if another IP is keeping Audiomix PD up.

    By introducing dsp_reset() we no longer rely on turning off the
    audiomix to reset the DSP.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20211119094319.81674-6-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: imx8m: Implement DSP start
Daniel Baluta [Fri, 19 Nov 2021 09:43:18 +0000 (11:43 +0200)]
ASoC: SOF: imx8m: Implement DSP start

On i.MX8M DSP is controlled via a set of registers
from Audio MIX. This patches gets a reference (via regmap)
to Audio Mix registers and implements DSP start.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119094319.81674-5-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: imx8m: Add runtime PM / System PM support
Daniel Baluta [Fri, 19 Nov 2021 09:43:17 +0000 (11:43 +0200)]
ASoC: SOF: imx8m: Add runtime PM / System PM support

We make use of common imx8m_suspend / imx8m_resume functions
for both system PM and runtime PM.

imx8m_suspend:
- frees the MU channels
- disables the clocks

imx8m_resume
- enables the clocks
- requests the MU channels

On i.MX8MP there is no dedicated functionality to put the DSP in reset.
The only way of doing this is to POWER DOWN the Audiomix domain.

We are able to do this because turning off the clocks and freeing the
channels makes the Audiomix to have no users thus PM kernel core turns
it down.

SOF core will not call system PM suspend handler if the DSP is already
down, but at resume it will call the system PM resume. So, we need to
keep track of the state via snd_sof_dsp_set_power_state

Few insights on how SOF core handles the PM:
 - SOF core uses PM runtime autosuspend (with a timeout of 2 secs)
 - at probe, SOF core boots the DSP and lets the PM runtime suspend to
   turn it off, if there is no activity
 - when someone opens the ALSA sound card (aplay/arecord, etc) ALSA core
   calls PM runtime resume to turn on the DSP
 - when the ALSA sound card is closed SOF core make use of PM subsystem
  to call PM runtime suspend and thus turning off the DSP.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119094319.81674-4-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: imx8: Add runtime PM / System PM support
Daniel Baluta [Fri, 19 Nov 2021 09:43:16 +0000 (11:43 +0200)]
ASoC: SOF: imx8: Add runtime PM / System PM support

Handle clocks and mailbox channels at runtime suspend/resume
in order to save power.

DSP runtime PM uses a timeout of 2s. If device
is idle for 2s system will enter runtime suspend.

Because SOF state machine assumes that even if the DSP wasn't previously
active at a System resume, will re-load the firmware we need to make sure
that all needed resources are active.

Kernel core will take care of enabling the PD, we need to make sure that
we request the MU channels.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119094319.81674-3-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: SOF: imx: Add code to manage DSP related clocks
Daniel Baluta [Fri, 19 Nov 2021 09:43:15 +0000 (11:43 +0200)]
ASoC: SOF: imx: Add code to manage DSP related clocks

We need at least 3 clocks in order to power up and access
DSP core registers found on i.MX8QM, i.MX8QXP and i.MX8MP
platforms.

Add code to request these clocks and enable them at probe. Next
patches will add PM support which will only activate clocks when
DSP is used.

DSP clocks are already documented in
Documentation/devicetree/bindings/dsp/fsl,dsp.yaml

We choose to add:
* imx8_parse_clocks
* imx8_enable_clocks
* imx8_disable_clocks

wrappers because in the future DSP will need to take care about the
clocks of other related Audio IPs (e.g SAI, ESAI).

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119094319.81674-2-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: rk817: Add module alias for rk817-codec
Nicolas Frattaroli [Sun, 21 Nov 2021 15:05:20 +0000 (16:05 +0100)]
ASoC: rk817: Add module alias for rk817-codec

Without a module alias, autoloading the driver does not occurr
when it is built as a module.

By adding a module alias, the driver now probes fine automatically
and therefore analog audio output works as it should.

Fixes: 0d6a04da9b25 ("ASoC: Add Rockchip rk817 audio CODEC support")
Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Link: https://lore.kernel.org/r/20211121150521.159543-1-frattaroli.nicolas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: soc-acpi: Set mach->id field on comp_ids matches
Hans de Goede [Thu, 18 Nov 2021 15:30:14 +0000 (16:30 +0100)]
ASoC: soc-acpi: Set mach->id field on comp_ids matches

Commit dac7cbd55dca ("ASoC: Intel: soc-acpi-byt: shrink tables using
compatible IDs") and commit 959ae8215a9e ("ASoC: Intel: soc-acpi-cht:
shrink tables using compatible IDs") simplified the match tables in
soc-acpi-intel-byt-match.c and soc-acpi-intel-cht-match.c by merging
identical entries using the new .comp_ids snd_soc_acpi_mach field to
point a single entry to multiple ACPI HIDs and clearing the previously
unique per entry .id field.

But various machine drivers from sound/soc/intel/boards rely on mach->id
in one or more ways, e.g. some drivers contain the following snippets:

adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);

pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, ...

if (!strncmp(snd_soc_cards[i].codec_id, mach->id, 8)) { ...

All of which are broken by the match table shrinking.

Make the snd_soc_acpi_mach.id field non const (the storage for the tables
already is non const) and on a comps_ids match copy the matching HID to
the id field to fix this.

Fixes: dac7cbd55dca ("ASoC: Intel: soc-acpi-byt: shrink tables using compatible IDs")
Fixes: 959ae8215a9e ("ASoC: Intel: soc-acpi-cht: shrink tables using compatible IDs")
Suggested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Brent Lu <brent.lu@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211118153014.349222-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Fix kcontrol put callback in Mixer
Sameer Pujar [Thu, 18 Nov 2021 07:07:11 +0000 (12:37 +0530)]
ASoC: tegra: Fix kcontrol put callback in Mixer

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Filter
out duplicate updates in Mixer driver.

Fixes: 05bb3d5ec64a ("ASoC: tegra: Add Tegra210 based Mixer driver")
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Suggested-by: Jaroslav Kysela <perex@perex.cz>
Suggested-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/1637219231-406-17-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoASoC: tegra: Fix kcontrol put callback in ADX
Sameer Pujar [Thu, 18 Nov 2021 07:07:10 +0000 (12:37 +0530)]
ASoC: tegra: Fix kcontrol put callback in ADX

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Filter
out duplicate updates in ADX driver.

Fixes: a99ab6f395a9 ("ASoC: tegra: Add Tegra210 based ADX driver")
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Suggested-by: Jaroslav Kysela <perex@perex.cz>
Suggested-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/1637219231-406-16-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>