History log of /linux-master/sound/soc/codecs/cros_ec_codec.c
Revision Date Author Comments
# 0a034d93 03-Jun-2022 Miaoqian Lin <linmq006@gmail.com>

ASoC: cros_ec_codec: Fix refcount leak in cros_ec_codec_platform_probe

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: b6bc07d4360d ("ASoC: cros_ec_codec: support WoV")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20220603131043.38907-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# cfacadbd 04-May-2022 Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: cros_ec_codec: Add endianness flag in i2s_rx_component_driver

The endianness flag is used on the CODEC side to specify an
ambivalence to endian, typically because it is lost over the hardware
link. The i2s_rx component receives audio over an I2S DAI and as such
should have endianness applied.

A fixup is also required to use the width directly rather than relying
on the format in hw_params, now both little and big endian would be
supported.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220504170905.332415-27-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 94767044 20-Sep-2021 Mark Brown <broonie@kernel.org>

ASoC: cros_ec_codec: Use modern ASoC DAI format terminology

As part of moving to remove the old style defines for the bus clocks update
the cros_ec_codec driver to use more modern terminology for clocking.

Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20210920170414.17903-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 157c4df6 11-Mar-2021 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: cros_ec_codec: remove null pointer dereference warning

Cppcheck complains of a possible issue:

sound/soc/codecs/cros_ec_codec.c:98:10: warning: Possible null pointer
dereference: in [nullPointer]
memcpy(in, msg->data, insize);
^
sound/soc/codecs/cros_ec_codec.c:162:34: note: Calling function
'send_ec_host_command', 5th argument 'NULL' value is 0
(uint8_t *)&p, sizeof(p), NULL, 0);
^
sound/soc/codecs/cros_ec_codec.c:98:10: note: Null pointer dereference
memcpy(in, msg->data, insize);
^

In practice the access to the pointer is protected by another
argument, but this is likely to fool other static analysis tools. Add
a test to avoid doing the memcpy if the pointer is NULL or the size is
zero.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20210312182246.5153-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7f1f7ae1 15-Jan-2021 Yu-Hsuan Hsu <yuhsuan@chromium.org>

ASoC: cros_ec_codec: Reset I2S RX when probing

It is not guaranteed that I2S RX is disabled when the kernel booting.
For example, if the kernel crashes while it is enabled, it will keep
enabled until the next time EC reboots. Reset I2S RX when probing to
fix this issue.

Signed-off-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20210115075301.47995-2-yuhsuan@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7061b8a5 03-Dec-2020 Arnd Bergmann <arnd@arndb.de>

ASoC: cros_ec_codec: fix uninitialized memory read

gcc points out a memory area that is copied to a device
but not initialized:

sound/soc/codecs/cros_ec_codec.c: In function 'i2s_rx_event':
arch/x86/include/asm/string_32.h:83:20: error: '*((void *)&p+4)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
83 | *((int *)to + 1) = *((int *)from + 1);

Initialize all the unused fields to zero.

Fixes: 727f1c71c780 ("ASoC: cros_ec_codec: refactor I2S RX")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20201203225458.1477830-1-arnd@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# a24d22b2 12-Nov-2020 Eric Biggers <ebiggers@google.com>

crypto: sha - split sha.h into sha1.h and sha2.h

Currently <crypto/sha.h> contains declarations for both SHA-1 and SHA-2,
and <crypto/sha3.h> contains declarations for SHA-3.

This organization is inconsistent, but more importantly SHA-1 is no
longer considered to be cryptographically secure. So to the extent
possible, SHA-1 shouldn't be grouped together with any of the other SHA
versions, and usage of it should be phased out.

Therefore, split <crypto/sha.h> into two headers <crypto/sha1.h> and
<crypto/sha2.h>, and make everyone explicitly specify whether they want
the declarations for SHA-1, SHA-2, or both.

This avoids making the SHA-1 declarations visible to files that don't
want anything to do with SHA-1. It also prepares for potentially moving
sha1.h into a new insecure/ or dangerous/ directory.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>


# 9d4cafa5 08-Jul-2020 Eric Biggers <ebiggers@google.com>

ASoC: cros_ec_codec: use sha256() instead of open coding

Now that there's a function that calculates the SHA-256 digest of a
buffer in one step, use it instead of sha256_init() + sha256_update() +
sha256_final().

Also simplify the code by inlining calculate_sha256() into its caller
and switching a debug log statement to use %*phN instead of bin2hex().

Acked-by: Tzung-Bi Shih <tzungbi@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Cc: alsa-devel@alsa-project.org
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>


# fbcde4ff 07-Jul-2020 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: codecs: cros_ec_codec: fix 'defined but not used' warning

fix W=1 warning

sound/soc/codecs/cros_ec_codec.c:1056:36: warning:
'cros_ec_codec_acpi_id' defined but not used
[-Wunused-const-variable=]
1056 | static const struct acpi_device_id cros_ec_codec_acpi_id[] = {
| ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200707190612.97799-11-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 93fa0af4 14-May-2020 Ard Biesheuvel <ardb@kernel.org>

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>


# 9a611a1d 14-May-2020 Herbert Xu <herbert@gondor.apana.org.au>

Revert "ASoC: cros_ec_codec: use crypto_shash_tfm_digest()"

This reverts commit 85fc78b80f15d723db3aa8f368b414ee70a1937c as
a different fix has already been applied in the sound-asoc tree
and this patch is no longer required.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>


# a1304cba 07-May-2020 Arnd Bergmann <arnd@arndb.de>

ASoC: cros_ec_codec: allocate shash_desc dynamically

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>


# 85fc78b8 01-May-2020 Eric Biggers <ebiggers@google.com>

ASoC: cros_ec_codec: use crypto_shash_tfm_digest()

Instead of manually allocating a 'struct shash_desc' on the stack and
calling crypto_shash_digest(), switch to using the new helper function
crypto_shash_tfm_digest() which does this for us.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>


# 99b4f439 25-Jan-2020 Yu-Hsuan Hsu <yuhsuan@chromium.org>

ASoC: cros_ec_codec: Support setting bclk ratio

Support setting bclk ratio from machine drivers.

Signed-off-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20200125162917.247485-1-yuhsuan@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 877167ef 11-Jan-2020 Yu-Hsuan Hsu <yuhsuan@chromium.org>

ASoC: cros_ec_codec: Make the device acpi compatible

Add ACPI entry for cros_ec_codec.

Signed-off-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Link: https://lore.kernel.org/r/20200112054900.236576-1-yuhsuan@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 66b3621b 10-Dec-2019 Takashi Iwai <tiwai@suse.de>

ASoC: cros_ec_codec: Use managed buffer allocation

Clean up the driver with the new managed buffer allocation API.
The superfluous snd_pcm_lib_malloc_pages() and
snd_pcm_lib_free_pages() calls are dropped.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Benson Leung <bleung@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20191210142614.19405-18-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# e610748a 08-Nov-2019 Takashi Iwai <tiwai@suse.de>

ASoC: cros_ec_codec: Convert to the common vmalloc memalloc

The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling. This patch
coverts to the common code.
(*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
support
7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
default mmap handler

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20191108094641.20086-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b6bc07d4 19-Oct-2019 Tzung-Bi Shih <tzungbi@google.com>

ASoC: cros_ec_codec: support WoV

1. Get EC codec's capabilities.
2. Get and set SHM address if any.
3. Transmit language model to EC codec if needed.
4. Start to read audio data from EC codec if receives host event.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20191019143504.1.I5388b69a7a9c551078fed216a77440cee6dedf49@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>


# f3e82ad4 17-Oct-2019 Tzung-Bi Shih <tzungbi@google.com>

ASoC: cros_ec_codec: read max DMIC gain from EC codec

Read max DMIC gain from EC codec instead of DTS. Also removes the
dt-binding of max-dmic-gain.

Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20191017213539.05.Id4657c864d544634f2b5c1c9b34fa8232ecba44d@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8f731d4c 14-Oct-2019 Tzung-Bi Shih <tzungbi@google.com>

ASoC: cros_ec_codec: extract DMIC EC command from I2S RX

Extract DMIC EC command from I2S RX. Setting and getting
microphone gains is common features.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Acked-By: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20191014180059.03.I93d9c65964f3c30f85a36d228e31150ff1917706@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>


# 727f1c71 14-Oct-2019 Tzung-Bi Shih <tzungbi@google.com>

ASoC: cros_ec_codec: refactor I2S RX

Refactor by the following items:
- reformat copyright declaration
- use more specific name "i2s rx"
- use verbose symbol names to separate namespaces
- make some short functions inline
- remove unused TDM-related code

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Acked-By: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20191014180059.02.I43373b9a66dbb70196b3f216b3aa86111c410836@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>


# 840d9f13 02-Sep-2019 Enric Balletbo i Serra <enric.balletbo@collabora.com>

mfd / platform: cros_ec: Reorganize platform and mfd includes

There is a bit of mess between cros-ec mfd includes and platform
includes. For example, we have a linux/mfd/cros_ec.h include that
exports the interface implemented in platform/chrome/cros_ec_proto.c. Or
we have a linux/mfd/cros_ec_commands.h file that is non related to the
multifunction device (in the sense that is not exporting any function of
the mfd device). This causes crossed includes between mfd and
platform/chrome subsystems and makes the code difficult to read, apart
from creating 'curious' situations where a platform/chrome driver includes
a linux/mfd/cros_ec.h file just to get the exported functions that are
implemented in another platform/chrome driver.

In order to have a better separation on what the cros-ec multifunction
driver does and what the cros-ec core provides move and rework the
affected includes doing:

- Move cros_ec_commands.h to include/linux/platform_data/cros_ec_commands.h
- Get rid of the parts that are implemented in the platform/chrome/cros_ec_proto.c
driver from include/linux/mfd/cros_ec.h to a new file
include/linux/platform_data/cros_ec_proto.h
- Update all the drivers with the new includes, so
- Drivers that only need to know about the protocol include
- linux/platform_data/cros_ec_proto.h
- linux/platform_data/cros_ec_commands.h
- Drivers that need to know about the cros-ec mfd device also include
- linux/mfd/cros_ec.h

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Series changes: 3
- Fix dereferencing pointer to incomplete type 'struct cros_ec_dev' (lkp)
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# dcbe6ed3 27-Jun-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: cros_ec_codec: use devm_snd_soc_register_component()

We have devm_xxx version of snd_soc_register_component,
let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3aa6be30 03-Jun-2019 Gwendal Grignou <gwendal@chromium.org>

mfd: cros_ec: Update I2S API

Improve I2S API.
Rename ec_response_codec_gain into ec_codec_i2s_gain,
update caller accordlingly.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# a4cbb465 12-Feb-2019 Wei Yongjun <weiyongjun1@huawei.com>

ASoC: cros_ec_codec: Make symbol 'cros_ec_dai' static

Fixes the following sparse warning:

sound/soc/codecs/cros_ec_codec.c:209:27: warning:
symbol 'cros_ec_dai' was not declared. Should it be static?

Fixes: b291f42a3718 ("ASoC: cros_ec_codec: Add codec driver for Cros EC")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b291f42a 19-Jan-2019 Cheng-Yi Chiang <cychiang@chromium.org>

ASoC: cros_ec_codec: Add codec driver for Cros EC

Add a codec driver to control ChromeOS EC codec.

Use EC Host command to enable/disable I2S recording and control other
configurations.

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>