ASoC: soc-dapm: use snd_soc_dai_activate()/deactivate()
soc-dapm.c :: snd_soc_dai_link_event_pre_pmu() / snd_soc_dai_link_event()
are directly updating dai->active without caring about
stream_active / component->active.
It is breaking xxx_active count balance.
This patch uses snd_soc_dai_action() for it.
snd_soc_runtime_action() updates DAI's xxx_active.
We should update these in the same time, and
it can be implemented at soc-dai.c.
This patch adds snd_soc_dai_action() for it.
This is prepare for xxx_active cleanup.
ASoC: soc-pcm: replace snd_soc_runtime_activate()/deactivate() to macro
snd_soc_runtime_activate()/deactivate() are implemented by global function
which are just calling snd_soc_runtime_action().
We can replace it to macro, and this patch do it.
This patch is prepare for xxx_active cleanup.
Ard Biesheuvel [Fri, 15 May 2020 10:03:09 +0000 (12:03 +0200)]
ASoC: cros_ec_codec: switch to library API for SHA-256
The CrOS EC codec driver uses SHA-256 explicitly, and not in a
performance critical manner, so there is really no point in using
the SHASH crypto API here. Let's switch to the library API instead.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Cc: Cheng-Yi Chiang <cychiang@chromium.org> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> Cc: Guenter Roeck <groeck@chromium.org> Cc: Benson Leung <bleung@chromium.org> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Eric Biggers <ebiggers@kernel.org> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Tzung-Bi Shih <tzungbi@google.com> Link: https://lore.kernel.org/r/20200515100309.20795-1-ardb@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
Shengjiu Wang [Fri, 15 May 2020 10:10:50 +0000 (18:10 +0800)]
ASoC: fsl_esai: introduce SoC specific data
Introduce a SoC specific data structure which contains the
differences between the different SoCs.
This makes it easier to support more differences without having
to introduce a new if/else each time.
Dan Murphy [Thu, 14 May 2020 12:33:36 +0000 (07:33 -0500)]
ASoC: tlv320adcx140: Add controls for PDM clk
Add ALSA controls to configure the PDM clocks.
The clocks need to be configurable to accommodate various microphones
that use clocks for low power/low resolution modes to high power/high
resolution modes.
Dan Murphy [Wed, 13 May 2020 14:28:07 +0000 (09:28 -0500)]
ASoC: tlv320adcx140: Fix bias config values
The device tree binding declares the ti,mic-bias-source and the
ti,vref-source properties as u32. The code reads them as u8 which is
incorrect. Since the device tree binding indicates them as u32 the
conde needs to be updated to read u32.
In addition the bias source needs to be shifted 4 bits to
correctly write the register.
Shengjiu Wang [Wed, 13 May 2020 05:30:35 +0000 (13:30 +0800)]
ASoC: wm8962: Use force clear for WM8962_SYSCLK_ENA after reset
When CLOCKING2 is non-volatile register, we need force clear
the WM8962_SYSCLK_ENA bit after reset, for the value in cache
maybe 0 but in hardware it is 1. Otherwise there will issue
as below statement in driver.
/* SYSCLK defaults to on; make sure it is off so we can safely
* write to registers if the device is declocked.
Lubomir Rintel [Mon, 11 May 2020 21:01:32 +0000 (23:01 +0200)]
ASoC: mmp-sspa: Set appropriate bus format for given bit width
The values set by set_dai_fmt() and hw_params() seem to be tailored only
for 32-bit formats. Negotiate the correct ones in hw_params() callback
instead.
This was essentially copied from the OLPC kernel driver and tested to
fix wrong audio output for non-32bit formats. The documentation is not
available.
Lubomir Rintel [Mon, 11 May 2020 21:01:29 +0000 (23:01 +0200)]
ASoC: mmp-sspa: Remove the embedded struct ssp_device
The "serial port" it represents is actually a SPI controller -- it's not
clear why would the audio serial interface embed it. We're only using
the mmio_base and clk fields.
Lubomir Rintel [Mon, 11 May 2020 21:01:28 +0000 (23:01 +0200)]
ASoC: mmp-sspa: Add support for soc-generic-dmaengine-pcm
This makes the driver usable with the mmp_tdma drier via
soc-generic-dmaengine-pcm. This is conditionalized on DT node (support
for DT is added by a later patch).
A custom mmap callback that creates a NC mapping is used instead of the
default WC one, because with write-combining some bytes don't seem to
make it through for reasons unknown to me.
Lubomir Rintel [Mon, 11 May 2020 21:01:27 +0000 (23:01 +0200)]
ASoC: mmp-sspa: Get rid of dma_params and phys_base
This makes things simpler. There's no reason not to just embed the struct
snd_dmaengine_dai_dma_data in struct sspa_priv and do away with an
unnecessary kmalloc(). While at that, we can initialize the
snd_dmaengine_dai_dma_data structures earlier.
Let's also stop offsetting the source/destination of the DMA transfer by
phys_base. Firstly, it's never set and is always zero. Secondly, the
hardware actually ignores it, at least on a MMP2 and MMP3.
Johan Jonker [Thu, 7 May 2020 11:32:38 +0000 (13:32 +0200)]
ASoC: rockchip-i2s: add description for rk3308
The description below is already in use for rk3308.dtsi,
but was somehow never added to a document, so add
"rockchip,rk3308-i2s", "rockchip,rk3066-i2s"
for i2s nodes on a rk3308 platform to rockchip-i2s.yaml.
One of the rk3308 i2s nodes also has a different dma layout,
so change that as well.
ASoC: ux500: mop500: Fix some refcounted resources issues
There are 2 issues here:
- if one of the 'of_parse_phandle' fails, calling 'mop500_of_node_put()'
is a no-op because the 'mop500_dai_links' structure has not been
initialized yet, so the referenced are not decremented
- The reference stored in 'mop500_dai_links[i].codecs' is refcounted
only once in the probe and must be decremented only once.
ASoC: Intel: Skylake: Replace zero-length array with flexible-array
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.
Lubomir Rintel [Mon, 11 May 2020 21:01:25 +0000 (23:01 +0200)]
ASoC: mmp-sspa: Drop S20_3LE case
It does nothing, because the corresponding bit s not flipped on in .formats
and the audio SRAM DMA engine is not able to handle 20-bit transfers
anyway.
Yongbo Zhang [Tue, 12 May 2020 09:30:03 +0000 (17:30 +0800)]
SoC: rsnd: add interrupt support for SSI BUSIF buffer
SSI BUSIF buffer is possible to overflow or underflow, especially in a
hypervisor environment. If there is no interrupt support, it will eventually
lead to errors in pcm data.
This patch adds overflow and underflow interrupt support for SSI BUSIF buffer.
Reported-by: Chen Li <licheng0822@thundersoft.com> Signed-off-by: Yongbo Zhang <giraffesnn123@gmail.com> Tested-by: Chen Li <licheng0822@thundersoft.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/20200512093003.28332-1-giraffesnn123@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
The wov_hotword_model_put() function has multiple large variables on
its stack, the largest of which is the result of SHASH_DESC_ON_STACK().
In total, this exceeds the warning limit for 32-bit architectures:
sound/soc/codecs/cros_ec_codec.c:776:12: error: stack frame size of 1152 bytes in function 'wov_hotword_model_put' [-Werror,-Wframe-larger-than=]
The function already has a dynamic crypto_alloc_shash() allocation, so
using kmalloc() for the descriptor is correct as well and does not
introduce any additional failure scenarios. With this, the stack usage
of wov_hotword_model_put() gets reduced to 480 bytes in my test
configuration.
Fixes: b6bc07d4360d ("ASoC: cros_ec_codec: support WoV") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Link: https://lore.kernel.org/r/20200507213405.1869430-1-arnd@arndb.de Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: soc-core: Replace zero-length array with flexible-array
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.
YueHaibing [Thu, 7 May 2020 07:27:35 +0000 (15:27 +0800)]
ASoC: SOF: Intel: Fix unused variable warning
When CONFIG_SND_SOC_SOF_BAYTRAIL is not set, gcc warns:
sound/soc/sof/intel/byt.c:85:41: warning: ‘cht_debugfs’ defined but not used [-Wunused-const-variable=]
static const struct snd_sof_debugfs_map cht_debugfs[] = {
^~~~~~~~~~~
Move the variable inside #ifdef
ChenTao [Thu, 7 May 2020 02:29:59 +0000 (10:29 +0800)]
soc: fsl_asrc: Make some functions static
Fix the following warning:
sound/soc/fsl/fsl_asrc.c:157:5: warning:
symbol 'fsl_asrc_request_pair' was not declared. Should it be static?
sound/soc/fsl/fsl_asrc.c:200:6: warning:
symbol 'fsl_asrc_release_pair' was not declared. Should it be static?
Tang Bin [Wed, 6 May 2020 14:30:09 +0000 (22:30 +0800)]
ASoC: mediatek: Fix error handling
If the function platform_get_irq() failed, the negative value
returned will not be detected here. So fix error handling in
mt6797_afe_pcm_dev_probe(). And when get irq failed, the function
platform_get_irq() logs an error message, so remove redundant
message here.
Akshu Agrawal [Wed, 6 May 2020 10:26:00 +0000 (15:56 +0530)]
ASoC: amd :High hw_level while simultaneous capture
Simultaneous capture on dmic and headset mic is having
issue with high hw_level being reported.
Issue Can be reproduced by:
arecord -D hw:2,0 -f dat -d 60 /tmp/test0 &
arecord -D hw:2,2 -f dat -d 60 /tmp/test1 &
cat /proc/asound/card2/pcm?c/sub0/status
Actual issue is :
When we open one capture stream on one instance lets say I2S_SP and then
once again if we open other capture on other instance lets say I2S_BT while
first capture is in progress and when we try to read the status of both
running instances by below command cat /proc/asound/card2/pcm?c/sub0/status
we observe that avail_max is being doubled on first opened
capture(I2S_SP in the example).
This is because our previous implementation was like when any instance is
opened it gets initialized in dma_open irrespective of on what instance it
called open.
For example:
First I2S_SP called opened it initializes both SP/BT capture streams
irrespective of on which instance the stream opened.next time I2S_BT
called opened and it initializes both SP/BT this corrupts the behaviour .
So with this patch the stream gets initialized only on specific instance
when ever it gets opened calls hw_params.
Stephan Gerhold [Sat, 25 Apr 2020 18:46:57 +0000 (20:46 +0200)]
ASoC: qcom: lpass-cpu: Make I2S SD lines configurable
The LPASS hardware allows configuring the MI2S SD lines to use
when playing/recording audio. However, at the moment the lpass-cpu
driver has SD0 hard-coded for mono/stereo (or additional fixed
SD lines for more channels).
For weird reasons there seems to be hardware that uses one of the
other SD lines for mono/stereo. For example, some Samsung devices
use an external Speaker amplifier connected to Quaternary MI2S.
For some reason, the SD line for audio playback was connected to
SD1 rather than SD0. (I have no idea why...)
At the moment, the lpass-cpu driver cannot be configured to work
for the Speaker on these devices.
The q6afe driver already allows configuring the MI2S SD lines
through the "qcom,sd-lines" device tree property, but this works
only when routing audio through the ADSP.
This commit adds a very similar configuration for the lpass-cpu driver.
It is now possible to add additional subnodes to the lpass device in
the device tree, to configure the SD lines for playback and/or capture.
E.g. for the Samsung devices mentioned above:
qcom,playback/capture-sd-lines takes a list of SD lines (0-3)
in the same format as the q6afe driver. (The difference here is that
q6afe has separate DAIs for playback/capture, while lpass-cpu has one
for both...)
For backwards compatibility with older device trees, the lpass-cpu driver
defaults to LPAIF_I2SCTL_MODE_8CH if the subnode for a DAI is missing.
This is equivalent to the previous behavior: Up to 8 channels can be
configured, and SD0/QUAT01 will be chosen when setting up a stream
with fewer channels.
This allows the speaker to work on Samsung MSM8916 devices
that use an external speaker amplifier.
When calling regmap_update_bits(), since map->reg_update_bits is NULL,
_regmap_read() is entered with the following logic:
if (!map->cache_bypass) {
ret = regcache_read(map, reg, val);
if (ret == 0)
return 0;
}
if (map->cache_only)
return -EBUSY;
regcache_read() hits -EINVAL because MAX98373_R2000_SW_RESET is volatile,
as map->cache_only is set by codec suspend, thus -EBUSY is returned.
Fix by moving max98373_reset() after cache_only set to false in max98373_resume().
dt-bindings: sound: wm8994: Correct required supplies based on actual implementaion
The required supplies in bindings were actually not matching
implementation making the bindings incorrect and misleading. The Linux
kernel driver requires all supplies to be present. Also for wlf,wm8994
uses just DBVDD-supply instead of DBVDDn-supply (n: <1,3>).
ASoC: Intel: boards: sof-wm8804: support for Hifiberry Digiplus boards
Add a new machine driver to interface with WM8804. The code is based
on settings found in sound/soc/bcm/hifiberry-digi.c in the Raspberry
PI tree.
Tested on Up2 with Digi+ IO (capture+playback) and Digi+ PRO (playback
with two local oscillators supported). The codec is clock master in
both cases.
Capture support has known clocking restrictions: the transmitter needs
to be active for the clock recovery, the "Tx Source" mixer set to
"S/PDIF RX". Playback will only work while capture is active.
When Capture is not desired, or when there is no RX connector, the "Tx
Source" mixer should be set to "AIF"
ASoC: SOF: Update correct LED status at the first time usage of update_mute_led()
At the first time update_mute_led() gets called, if channels are already
muted, the temp value equals to led_value as 0, skipping the following
LED setting.
So set led_value to -1 as an uninitialized state, to update the correct
LED status at first time usage.
Fixes: 5d43001ae436 ("ASoC: SOF: acpi led support for switch controls") Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Acked-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200430091139.7003-1-kai.heng.feng@canonical.com Signed-off-by: Mark Brown <broonie@kernel.org>
Mark Brown [Thu, 30 Apr 2020 13:39:45 +0000 (14:39 +0100)]
Merge series "SOF topology parsing updates" from Ranjani Sridharan <ranjani.sridharan@linux.intel.com>:
This series includes updates in the topology parser for DAIs
and their config.
The first three patches address the problem of sending the DAI
config to the DSP when there are multiple DAIs associated with
a DAI link.
The last patch deals with setting the default trigger order
for all links. Exceptions needed for HDA links are moved to
the DAI link fixup() callback.
Bard Liao (3):
ASoC: SOF: topology: send ipc for all found DAIs in sof_set_dai_config
ASoC: topology: set component dai_index to ipc dai config dai_index
ASoC: SOF: topology: replace sof_link_hda_process by
sof_set_dai_config
randerwang (1):
ASoC: SOF: Intel: change trigger sequence to fix pop noise when
stopping playback on sdw platforms
This is complicated by two drivers having dependencies on both
platform specific drivers and the SND_SOC_SOF_OF framework code,
and using an somewhat obscure method to build them the same way
as the SOC_SOF_OF symbol (built-in or modular).
My solution now ensures that the two drivers can only be enabled
when the dependencies are met:
- When the platform specific drivers are built-in, everything is
fine, as SOC_SOF_OF is either =y or =m
- When both are loadable modules, it also works, both for Kconfig
and at runtime
- When the hardware drivers are loadable modules or disabled, and
SOC_SOF_OF=y, prevent the IMX_SOF_OF drivers from being turned on,
as this would be broken.
It seems that this is just an elaborate way to describe two tristate
symbols that have straight dependencies, but maybe I'm missing some
subtle point. It seems to always build for me now.
ASoC: SOF: Intel: change trigger sequence to fix pop noise when stopping playback on sdw platforms
Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for
SOF. This means FE will be stopped before BE, so BE will consume
invalid data and this generates huge pop noise. This sequence is
introduced for HDA DAI which requires SND_SOC_DPCM_TRIGGER_POST for
some reasons. Now set default trigger sequence to SND_SOC_DPCM_TRIGGER_PRE
for playback with all DAI and fix sequence only for HDA DAI.
ASoC: SOF: topology: replace sof_link_hda_process by sof_set_dai_config
Now we send ipc in sof_set_dai_config(), too. Therefore, we can use
sof_set_dai_config() in sof_link_hda_load() just like other link load
functions do.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200427172939.25848-4-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: topology: set component dai_index to ipc dai config dai_index
The ipc dai config dai_index is from topology. However, the same dai
config will be applied to all DAIs in the same dai link. We have to
ensure that the ipc dai config's dai_index match to the component's
dai_index.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200427172939.25848-3-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: Intel: broadwell: Fix oops during module removal
When removing the SOF module, the RT286 jack detect
handler will oops if jack detection is not disabled.
Disable the jack in the machine driver remove callback
to prevent this. This fix is only for SOF support and is
not needed for earlier versions.
If one of the two is a loadable module, the combined driver must
not be built-in:
aarch64-linux-ld: sound/soc/codecs/rt5682.o: in function `rt5682_sdw_hw_free':
rt5682.c:(.text+0xb34): undefined reference to `sdw_stream_remove_slave'
aarch64-linux-ld: sound/soc/codecs/rt5682.o: in function `rt5682_sdw_hw_params':
rt5682.c:(.text+0xe78): undefined reference to `sdw_stream_add_slave'
In particular, the soundwire driver must not be built-in if
CONFIG_I2C=m.
ifdefs are hard, and in this driver the suspend/resume functions are
the only callers of some other helpers that trigger a harmless warning
when CONFIG_PM is disabled:
sound/soc/fsl/fsl_easrc.c:1807:12: warning: 'fsl_easrc_get_firmware' defined but not used [-Wunused-function]
1807 | static int fsl_easrc_get_firmware(struct fsl_asrc *easrc)
| ^~~~~~~~~~~~~~~~~~~~~~
sound/soc/fsl/fsl_easrc.c:303:12: warning: 'fsl_easrc_resampler_config' defined but not used [-Wunused-function]
303 | static int fsl_easrc_resampler_config(struct fsl_asrc *easrc)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Remove the #ifdef and just mark the callers as __maybe_unused to
suppress the warnings altogether.
Fixes: 955ac624058f ("ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com> Link: https://lore.kernel.org/r/20200428212847.2926376-1-arnd@arndb.de Signed-off-by: Mark Brown <broonie@kernel.org>
Old versions of gcc (tested on gcc-4.8) produce a warning for
correct code:
sound/soc/soc-compress.c: In function 'soc_compr_open':
sound/soc/soc-compress.c:75:28: error: 'component' is used uninitialized in this function [-Werror=uninitialized]
struct snd_soc_component *component, *save = NULL;
Change the for_each_rtd_components() macro to ensure 'component'
gets initialized to a value the compiler does not complain about.
Current ASoC overwrites null_dai_ops to dai->driver->ops if it
was NULL. But, we can remove it if framework always checks
dai->driver->ops when it uses DAI callbacks.
This patch do it, and removes null_dai_ops.