History log of /linux-master/sound/soc/codecs/sigmadsp.c
Revision Date Author Comments
# 4f88c72b 09-Oct-2023 Gustavo A. R. Silva <gustavoars@kernel.org>

ASoC: sigmadsp: Add __counted_by for struct sigmadsp_data and use struct_size()

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

While there, use struct_size() and size_sub() helpers, instead of the
open-coded version, to calculate the size for the allocation of the
whole flexible structure, including of course, the flexible-array
member.

This code was found with the help of Coccinelle, and audited and
fixed manually.

Signed-off-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/ZSRvh1j2MVVhuOUv@work
Signed-off-by: Mark Brown <broonie@kernel.org>


# a3bee62e 18-Jul-2023 Takashi Iwai <tiwai@suse.de>

ASoC: sigmadsp: Simplify with snd_ctl_activate_id()

Use the standard snd_ctl_activate_id() helper instead of an open code
for code simplification.

Acked-by: Mark Brown <broonie@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: "Nuno Sá" <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230718141304.1032-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4a34613b 25-Aug-2022 Yang Yingliang <yangyingliang@huawei.com>

ASoC: sigmadsp: switch to use kmemdup_nul() helper

Use kmemdup_nul() helper instead of open-coding to
simplify the code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20220825123525.1845695-1-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 11a9b987 19-Apr-2021 Niklas Carlsson <niklasc@axis.com>

ASoC: sigmadsp: Disable cache mechanism for readbacks

The ALSA control readback functionality only works for non-volatile
controls, i.e. control values that does not change on their own without
driver interaction.

This doesn't work for readbacks since the DSP firmware updates the
control value. Disable the cache mechanism in the driver if the control
name matches the prefix used for readbacks to ensure that the control
value is valid.

Signed-off-by: Niklas Carlsson <niklasc@axis.com>
Link: https://lore.kernel.org/r/20210419144901.9441-1-Niklas.Carlsson@axis.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 80503b23 23-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149

Based on 1 normalized pattern(s):

licensed under the gpl 2 or later

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 82 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190524100845.150836982@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5ea752c6 23-Aug-2018 Danny Smith <danny.smith@axis.com>

ASoC: sigmadsp: safeload should not have lower byte limit

Fixed range in safeload conditional to allow safeload to up to 20 bytes,
without a lower limit.

Signed-off-by: Danny Smith <dannys@axis.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d98123a7 26-Nov-2014 Dan Carpenter <dan.carpenter@oracle.com>

ASoC: sigmadsp: uninitialized variable in sigmadsp_activate_ctrl()

The "changed" variable should be set to false at the start.

Fixes: a35daac77a03 ('ASoC: sigmadsp: Add support for fw v2')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>


# 141f87d4 24-Nov-2014 kbuild test robot <fengguang.wu@intel.com>

ASoC: sigmadsp: fix simple_return.cocci warnings

sound/soc/codecs/sigmadsp.c:656:1-4: WARNING: end returns can be simpified and declaration on line 636 can be dropped

Simplify a trivial if-return sequence. Possibly combine with a
preceding function call.
Generated by: scripts/coccinelle/misc/simple_return.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1fc10044 21-Nov-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Fix endianness conversion

Make sure to always convert the firmware data to local endianness before
using it.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: a35daac77a03 ("ASoC: sigmadsp: Add support for fw v2")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a35daac7 19-Nov-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Add support for fw v2

This patch adds support for the v2 version of the SigmaDSP firmware file
format. The new format has support for having different program and
parameter settings for different samplerates. In addition it stores metadata
describing the firmware. This metadata includes the set of supported
samplerates which will be used to restrict the samplerates that can be
selected by userspace. Also included is information about the modifiable
parameters. Those will be exposed as ALSA controls so they can be changed at
runtime.

The new format is based on a binary type-length-value structure that makes
it both forward and backwards compatible.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d48b088e 19-Nov-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Restructure in preparation for fw v2 support

The v2 file format of the SigmaDSP takes a more declarative style compared
to the imperative style of the v1 format. In addition some features that are
supported with v2 require the driver to keep state around for the firmware.
This requires a bit of restructuring of both the firmware loader itself and
the drivers making use of the firmware loader.

Instead of loading and executing the firmware in place when the DSP is
configured the firmware is now loaded at driver probe time. This is required
since the new firmware format will in addition to the firmware data itself
contain meta information describing the firmware and its requirements and
capabilities. Those will for example be used to restrict the supported
samplerates advertised by the driver to userspace to the list of samplerates
supported for the firmware.

This only does the restructuring required by the v2 format, but does not
yet add support for the new format itself.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6b25730f 19-Nov-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Drop support support SIGMA_ACTION_DELAY

The official firmware generation tool never emitted any SIGMA_ACTION_DELAY
instructions. Keeping support for it with the new restructured loader that
also supports v2 will be difficult, so drop support for it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 50c0f21b 19-Nov-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Refuse to load firmware files with a non-supported version

Make sure to check the version field of the firmware header to make sure to
not accidentally try to parse a firmware file with a different layout.
Trying to do so can result in loading invalid firmware code to the device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# 2488708f 06-Jun-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Split regmap and I2C support into separate modules

When the SigmaDSP module is built-in, but the I2C core is build as a module
we'll get a undefined reference:

sound/built-in.o: In function `sigma_action_write_i2c':
:(.text+0x5d8d4): undefined reference to `i2c_master_send'

This can happen if a audio driver that is using the regmap SigmaDSP interface is
built into the kernel, but core I2C support is build as a module. To fix this
split the SigmaDSP module into three modules, one module providing the core
infrastructure and two small modules implementing the regmap and I2C interfaces.
This allows e.g. the core infrastructure and regmap support to be built into the
kernel while I2C support can still be build as a module.

Fixes: dab464b60 ("ASoC: Add ADAU1361/ADAU1761 audio CODEC support")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 6b10998d 06-Jun-2014 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Split regmap and I2C support into separate modules

When the SigmaDSP module is built-in, but the I2C core is build as a module
we'll get a undefined reference:

sound/built-in.o: In function `sigma_action_write_i2c':
:(.text+0x5d8d4): undefined reference to `i2c_master_send'

This can happen if a audio driver that is using the regmap SigmaDSP interface is
built into the kernel, but core I2C support is build as a module. To fix this
split the SigmaDSP module into three modules, one module providing the core
infrastructure and two small modules implementing the regmap and I2C interfaces.
This allows e.g. the core infrastructure and regmap support to be built into the
kernel while I2C support can still be build as a module.

Fixes: dab464b60 ("ASoC: Add ADAU1361/ADAU1761 audio CODEC support")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# a3adb143 07-Dec-2012 Lars-Peter Clausen <lars@metafoo.de>

ASoC: sigmadsp: Fix endianness conversion issue

The 'addr' field of the sigma_action struct is stored as big endian in the
firmware file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org


# 38fd54ee 28-Nov-2011 Lars-Peter Clausen <lars@metafoo.de>

ASoC: SigmaDSP: Add regmap support

Add support for loading the SigmaDSP firmware using regmap. This allows us
to transparently use SPI or I2C as the transport protocol on devices which
support them.

For now we keep the old I2C support since we have one user of this which is not
straight forward to convert to regmap, due to variable length registers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# a4c1d7e6 28-Nov-2011 Lars-Peter Clausen <lars@metafoo.de>

ASoC: SigmaDSP: Move private structs and functions to C file

Move the structs and functions only used by SigmaDSP firmware loader itself
from the header to the C file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 48afc527 28-Nov-2011 Lars-Peter Clausen <lars@metafoo.de>

ASoC: SigmaDSP: Provide diagnostic error messages

Provide some error messages when loading the firmware fails, so it is possible
to diagnose the reason for the failure.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 40216ce7 28-Nov-2011 Lars-Peter Clausen <lars@metafoo.de>

ASoC: Move SigmaDSP firmware loader to ASoC

It has been pointed out previously, that the firmware subsystem is not the right
place for the SigmaDSP firmware loader. Furthermore the SigmaDSP is currently
only used in audio products and we are aiming for better integration into the
ASoC framework in the future, with support for ALSA controls for firmware
parameters and support dynamic power management as well. So the natural choice
for the SigmaDSP firmware loader is the ASoC subsystem.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>