ASoC: mediatek: mt8183-mt6358-ts3a227-max98357: support WoV
Subsystems (7)
cover ASoC: mediatek: mt8183-mt6358-ts3a227-max98357: support WoV
This series makes mt6358, cros_ec_codec, and mt8183-mt6358-ts3a227-max98357 support WoV (wake on voice).
The first 3 commits are some cleanups and refactors. It looks like breaking the existing interface. But please be noticed that, the cros_ec_codec has not used by any real device yet. The refactor is very necessary to keep the style consistent and for easier to further extend and maintain.
platform/chrome: cros_ec: remove unused EC feature
ASoC: cros_ec_codec: refactor I2S RX
ASoC: cros_ec_codec: extract DMIC EC command from I2S RX
The 4th commit extends the feature offered from EC codec.
platform/chrome: cros_ec: add common commands for EC codec
The 5th commit changes the behavior of setting and getting DMIC gains.
ASoC: cros_ec_codec: read max DMIC gain from EC codec
The 6th and 7th commit make cros_ec_codec support WoV.
ASoC: dt-bindings: cros_ec_codec: add SHM bindings
ASoC: cros_ec_codec: support WoV
The 8th commit sets necessary registers on mt6358 to support WoV.
ASoC: mediatek: mt6358: support WoV
The last 2 commit make machine driver mt8183-mt6358-ts3a227-max98357 support WoV if ec-codec is in DTS.
ASoC: dt-bindings: mt8183: add ec-codec
ASoC: mediatek: mt8183: support WoV
Tzung-Bi Shih (10):
platform/chrome: cros_ec: remove unused EC feature
ASoC: cros_ec_codec: refactor I2S RX
ASoC: cros_ec_codec: extract DMIC EC command from I2S RX platform/chrome: cros_ec: add common commands for EC codec
ASoC: cros_ec_codec: read max DMIC gain from EC codec
ASoC: dt-bindings: cros_ec_codec: add SHM bindings
ASoC: cros_ec_codec: support WoV
ASoC: mediatek: mt6358: support WoV
ASoC: dt-bindings: mt8183: add ec-codec
ASoC: mediatek: mt8183: support WoV
.../bindings/sound/google,cros-ec-codec.txt | 24 +- .../sound/mt8183-mt6358-ts3a227-max98357.txt | 3 + drivers/platform/chrome/cros_ec_trace.c | 5 +- .../linux/platform_data/cros_ec_commands.h | 285 ++++- sound/soc/codecs/cros_ec_codec.c | 1125 +++++++++++++---- sound/soc/codecs/mt6358.c | 105 ++ sound/soc/mediatek/Kconfig | 1 + .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 70 +- 8 files changed, 1292 insertions(+), 326 deletions(-)
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 1/10 platform/chrome: cros_ec: remove unused EC feature
Remove unused EC_FEATURE_AUDIO_CODEC.
--- include/linux/platform_data/cros_ec_commands.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/platform_data/cros_ec_commands.h +0 -2
@@ -1277,8 +1277,6 @@ enum ec_feature_code {* MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */ EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS =37 , -/* EC supports audio codec. */ -EC_FEATURE_AUDIO_CODEC =38 ,/* The MCU is a System Companion Processor (SCP). */ EC_FEATURE_SCP = 39,/* The MCU is an Integrated Sensor Hub */
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 2/10 ASoC: cros_ec_codec: refactor I2S RX
In reply to Tzung-Bi ShihRefactor 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
--- drivers/platform/chrome/cros_ec_trace.c | 2 +- .../linux/platform_data/cros_ec_commands.h | 120 ++--- sound/soc/codecs/cros_ec_codec.c | 502 +++++++----------- 3 files changed, 251 insertions(+), 373 deletions(-)
drivers/platform/chrome/cros_ec_trace.c +1 -1
@@ -98,7 +98,7 @@TRACE_SYMBOL (EC_CMD_SB_READ_BLOCK ), \TRACE_SYMBOL (EC_CMD_SB_WRITE_BLOCK ), \TRACE_SYMBOL (EC_CMD_BATTERY_VENDOR_PARAM ), \ -TRACE_SYMBOL (EC_CMD_CODEC_I2S ), \ +TRACE_SYMBOL (EC_CMD_EC_CODEC_I2S_RX ), \TRACE_SYMBOL (EC_CMD_REBOOT_EC ), \TRACE_SYMBOL (EC_CMD_GET_PANIC_INFO ), \ TRACE_SYMBOL(EC_CMD_ACPI_READ), \
include/linux/platform_data/cros_ec_commands.h +51 -69
143 lines not on this page · raw message
sound/soc/codecs/cros_ec_codec.c +199 -303
619 lines not on this page · raw message
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 3/10 ASoC: cros_ec_codec: extract DMIC EC command from I2S RX
In reply to Tzung-Bi ShihExtract DMIC EC command from I2S RX. Setting and getting microphone gains is common features.
--- drivers/platform/chrome/cros_ec_trace.c | 1 + .../linux/platform_data/cros_ec_commands.h | 49 +++++++++++----- sound/soc/codecs/cros_ec_codec.c | 57 ++++++++++--------- 3 files changed, 68 insertions(+), 39 deletions(-)
drivers/platform/chrome/cros_ec_trace.c +1 -0
@@ -98,6 +98,7 @@TRACE_SYMBOL (EC_CMD_SB_READ_BLOCK ), \TRACE_SYMBOL (EC_CMD_SB_WRITE_BLOCK ), \TRACE_SYMBOL (EC_CMD_BATTERY_VENDOR_PARAM ), \ +TRACE_SYMBOL (EC_CMD_EC_CODEC_DMIC ), \TRACE_SYMBOL (EC_CMD_EC_CODEC_I2S_RX ), \TRACE_SYMBOL (EC_CMD_REBOOT_EC ), \ TRACE_SYMBOL(EC_CMD_GET_PANIC_INFO), \
include/linux/platform_data/cros_ec_commands.h +36 -13
73 lines not on this page · raw message
sound/soc/codecs/cros_ec_codec.c +31 -26
91 lines not on this page · raw message
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 4/10 platform/chrome: cros_ec: add common commands for EC codec
In reply to Tzung-Bi ShihAdd the following common commands:
- GET_CAPABILITIES
- GET_SHM_ADDR
- SET_SHM_ADDR
--- drivers/platform/chrome/cros_ec_trace.c | 1 + .../linux/platform_data/cros_ec_commands.h | 64 ++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_trace.c +1 -0
@@ -98,6 +98,7 @@TRACE_SYMBOL (EC_CMD_SB_READ_BLOCK ), \TRACE_SYMBOL (EC_CMD_SB_WRITE_BLOCK ), \TRACE_SYMBOL (EC_CMD_BATTERY_VENDOR_PARAM ), \ +TRACE_SYMBOL (EC_CMD_EC_CODEC ), \TRACE_SYMBOL (EC_CMD_EC_CODEC_DMIC ), \TRACE_SYMBOL (EC_CMD_EC_CODEC_I2S_RX ), \ TRACE_SYMBOL(EC_CMD_REBOOT_EC), \
include/linux/platform_data/cros_ec_commands.h +62 -2
77 lines not on this page · raw message
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 5/10 ASoC: cros_ec_codec: read max DMIC gain from EC codec
In reply to Tzung-Bi ShihRead max DMIC gain from EC codec instead of DTS. Also removes the dt-binding of max-dmic-gain.
--- .../bindings/sound/google,cros-ec-codec.txt | 4 +- .../linux/platform_data/cros_ec_commands.h | 43 +++++++++++---- sound/soc/codecs/cros_ec_codec.c | 53 ++++++++++++++----- 3 files changed, 73 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt +1 -3
@@ -1,4 +1,4 @@ -* Audio codec controlled by ChromeOS EC +Audio codec controlled by ChromeOS EC Google's ChromeOS EC codec is a digital mic codec provided by the Embedded Controller (EC) and is controlled via a host-command interface.
@@ -9,7 +9,6 @@ Documentation/devicetree/bindings/mfd/cros-ec.txt). Required properties: - compatible: Must contain "google,cros-ec-codec" - #sound-dai-cells: Should be 1. The cell specifies number of DAIs. -- max-dmic-gain: A number for maximum gain in dB on digital microphone. Example:
@@ -21,6 +20,5 @@ cros-ec@0 { cros_ec_codec: ec-codec { compatible = "google,cros-ec-codec"; #sound-dai-cells = <1>; - max-dmic-gain = <43>; }; };
include/linux/platform_data/cros_ec_commands.h +33 -10
63 lines not on this page · raw message
sound/soc/codecs/cros_ec_codec.c +39 -14
91 lines not on this page · raw message
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 6/10 ASoC: dt-bindings: cros_ec_codec: add SHM bindings
In reply to Tzung-Bi Shih- Add "ec-shm" for binding to shared memory exposed by EC.
- Add "memory-region" for binding to memory region shared by AP.
--- .../bindings/sound/google,cros-ec-codec.txt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
Documentation/devicetree/bindings/sound/google,cros-ec-codec.txt +20 -0
@@ -10,8 +10,26 @@ Required properties: - compatible: Must contain "google,cros-ec-codec" - #sound-dai-cells: Should be 1. The cell specifies number of DAIs. +Optional properties: +- ec-shm: Shared memory region from EC. It contains 3 unsigned 32-bit + integer. The first 2 integers combine to become an unsigned + 64-bit address. The last one integer is length of the shared + memory. +- memory-region: Shared memory region to EC. A "shared-dma-pool". See + ../reserved-memory/reserved-memory.txt for details. + Example: +{ + ... + + reserved_mem: reserved_mem { + compatible = "shared-dma-pool"; + reg = <0 0x52800000 0 0x100000>; + no-map; + }; +} + cros-ec@0 { compatible = "google,cros-ec-spi";
@@ -20,5 +38,7 @@ cros-ec@0 { cros_ec_codec: ec-codec { compatible = "google,cros-ec-codec"; #sound-dai-cells = <1>; + ec-shm = <0x0 0x10500000 0x80000>; + memory-region = <&reserved_mem>; }; };
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 7/10 ASoC: cros_ec_codec: support WoV
In reply to Tzung-Bi Shih1. 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.
--- drivers/platform/chrome/cros_ec_trace.c | 1 + .../linux/platform_data/cros_ec_commands.h | 69 ++ sound/soc/codecs/cros_ec_codec.c | 695 +++++++++++++++++- 3 files changed, 763 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_trace.c +1 -0
@@ -101,6 +101,7 @@TRACE_SYMBOL (EC_CMD_EC_CODEC ), \TRACE_SYMBOL (EC_CMD_EC_CODEC_DMIC ), \TRACE_SYMBOL (EC_CMD_EC_CODEC_I2S_RX ), \ +TRACE_SYMBOL (EC_CMD_EC_CODEC_WOV ), \TRACE_SYMBOL (EC_CMD_REBOOT_EC ), \TRACE_SYMBOL (EC_CMD_GET_PANIC_INFO ), \ TRACE_SYMBOL(EC_CMD_ACPI_READ), \
include/linux/platform_data/cros_ec_commands.h +69 -0
91 lines not on this page · raw message
sound/soc/codecs/cros_ec_codec.c +693 -2
746 lines not on this page · raw message
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
kbuild test robot
build botRe: [alsa-devel] [PATCH 07/10] ASoC: cros_ec_codec: support WoV
Thank you for the patch! Yet something to improve:
Hi Tzung-Bi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on asoc/for-next]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Tzung-Bi-Shih/ASoC-mediatek-mt8183-mt6358-ts3a227-max98357-support-WoV/20191005-142224 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: m68k-allyesconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag
All error/warnings (new ones prefixed by >>):
sound/soc/codecs/cros_ec_codec.c: In function 'calculate_sha256':
>> sound/soc/codecs/cros_ec_codec.c:117:7: error: 'struct shash_desc' has no member named 'flags'
desc->flags = 0x0;
^~
sound/soc/codecs/cros_ec_codec.c: In function 'wov_map_shm':
>> sound/soc/codecs/cros_ec_codec.c:469:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
return (void *)(priv->ap_shm_addr + offset);
^
sound/soc/codecs/cros_ec_codec.c: In function 'cros_ec_codec_platform_probe':
>> sound/soc/codecs/cros_ec_codec.c:1002:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
priv->ap_shm_addr = (uint64_t)devm_ioremap_wc(
^vim +117 sound/soc/codecs/cros_ec_codec.c
101
102 static int calculate_sha256(struct cros_ec_codec_priv *priv,
103 uint8_t *buf, uint32_t size, uint8_t *digest)
104 {
105 struct crypto_shash *tfm;
106
107 tfm = crypto_alloc_shash("sha256", CRYPTO_ALG_TYPE_SHASH, 0);
108 if (IS_ERR(tfm)) {
109 dev_err(priv->dev, "can't alloc shash\n");
110 return PTR_ERR(tfm);
111 }
112
113 {
114 SHASH_DESC_ON_STACK(desc, tfm);
115
116 desc->tfm = tfm;
> 117 desc->flags = 0x0;
118
119 crypto_shash_digest(desc, buf, size, digest);
120 shash_desc_zero(desc);
121 }
122
123 crypto_free_shash(tfm);
124
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 8/10 ASoC: mediatek: mt6358: support WoV
In reply to Tzung-Bi ShihSwitch mono DMIC on to support wake-on-voice.
--- sound/soc/codecs/mt6358.c | 105 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
sound/soc/codecs/mt6358.c +105 -0
@@ -93,6 +93,8 @@ struct mt6358_priv {int mtkaif_protocol;struct regulator *avdd_reg; + +int wov_enabled; }; int mt6358_set_mtkaif_protocol(struct snd_soc_component *cmpnt,
@@ -464,6 +466,106 @@ static int mt6358_put_volsw(struct snd_kcontrol *kcontrol,return ret; } +static void mt6358_restore_pga (struct mt6358_priv *priv); + +static int mt6358_enable_wov_phase2 (struct mt6358_priv *priv) +{ +/* analog */ +regmap_update_bits (priv->regmap,MT6358_AUDDEC_ANA_CON13 , +0xffff ,0x0000 ); +regmap_update_bits (priv->regmap,MT6358_DCXO_CW14 ,0xffff ,0xa2b5 ); +regmap_update_bits (priv->regmap,MT6358_AUDENC_ANA_CON1 , +0xffff ,0x0800 ); +mt6358_restore_pga (priv); + +regmap_update_bits (priv->regmap,MT6358_DCXO_CW13 ,0xffff ,0x9929 ); +regmap_update_bits (priv->regmap,MT6358_AUDENC_ANA_CON9 , +0xffff ,0x0025 ); +regmap_update_bits (priv->regmap,MT6358_AUDENC_ANA_CON8 , +0xffff ,0x0005 ); + +/* digital */ +regmap_update_bits (priv->regmap,MT6358_AUD_TOP_CKPDN_CON0 , +0xffff ,0x0000 ); +regmap_update_bits (priv->regmap,MT6358_GPIO_MODE3 ,0xffff ,0x0120 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG0 ,0xffff ,0xffff ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG1 ,0xffff ,0x0200 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG2 ,0xffff ,0x2424 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG3 ,0xffff ,0xdbac ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG4 ,0xffff ,0x029e ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG5 ,0xffff ,0x0000 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_POSDIV_CFG0 , +0xffff ,0x0000 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_HPF_CFG0 , +0xffff ,0x0451 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_TOP ,0xffff ,0x68d1 ); + +return 0 ; +} + +static int mt6358_disable_wov_phase2 (struct mt6358_priv *priv) +{ +/* digital */ +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_TOP ,0xffff ,0xc000 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_HPF_CFG0 , +0xffff ,0x0450 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_POSDIV_CFG0 , +0xffff ,0x0c00 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG5 ,0xffff ,0x0100 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG4 ,0xffff ,0x006c ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG3 ,0xffff ,0xa879 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG2 ,0xffff ,0x2323 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG1 ,0xffff ,0x0400 ); +regmap_update_bits (priv->regmap,MT6358_AFE_VOW_CFG0 ,0xffff ,0x0000 ); +regmap_update_bits (priv->regmap,MT6358_GPIO_MODE3 ,0xffff ,0x02d8 ); +regmap_update_bits (priv->regmap,MT6358_AUD_TOP_CKPDN_CON0 , +0xffff ,0x0000 ); + +/* analog */ +regmap_update_bits (priv->regmap,MT6358_AUDENC_ANA_CON8 , +0xffff ,0x0004 ); +regmap_update_bits (priv->regmap,MT6358_AUDENC_ANA_CON9 , +0xffff ,0x0000 ); +regmap_update_bits (priv->regmap,MT6358_DCXO_CW13 ,0xffff ,0x9829 ); +regmap_update_bits (priv->regmap,MT6358_AUDENC_ANA_CON1 , +0xffff ,0x0000 ); +mt6358_restore_pga (priv); +regmap_update_bits (priv->regmap,MT6358_DCXO_CW14 ,0xffff ,0xa2b5 ); +regmap_update_bits (priv->regmap,MT6358_AUDDEC_ANA_CON13 , +0xffff ,0x0010 ); + +return 0 ; +} + +static int mt6358_get_wov (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_component *c =snd_soc_kcontrol_component (kcontrol); +struct mt6358_priv *priv =snd_soc_component_get_drvdata (c); + + ucontrol->value.integer.value[0 ] = priv->wov_enabled; +return 0 ; +} + +static int mt6358_put_wov (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_component *c =snd_soc_kcontrol_component (kcontrol); +struct mt6358_priv *priv =snd_soc_component_get_drvdata (c); +int enabled = ucontrol->value.integer.value[0 ]; + +if (priv->wov_enabled != enabled) { +if (enabled) +mt6358_enable_wov_phase2 (priv); +else +mt6358_disable_wov_phase2 (priv); + + priv->wov_enabled = enabled; + } + +return 0 ; +} + static const DECLARE_TLV_DB_SCALE(playback_tlv, -1000, 100, 0); static const DECLARE_TLV_DB_SCALE(pga_tlv, 0, 600, 0);
@@ -483,6 +585,9 @@ static const struct snd_kcontrol_new mt6358_snd_controls[] = { MT6358_AUDENC_ANA_CON0, MT6358_AUDENC_ANA_CON1, 8, 4, 0, snd_soc_get_volsw, mt6358_put_volsw, pga_tlv), + + SOC_SINGLE_BOOL_EXT("Wake-on-Voice Phase2 Switch", 0, + mt6358_get_wov, mt6358_put_wov), };/* MUX */
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 9/10 ASoC: dt-bindings: mt8183: add ec-codec
In reply to Tzung-Bi ShihAdd an optional property "ec-codec". If specified, mt8183 could use the "wake on voice" feature offered by EC codec.
--- .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt +3 -0
@@ -6,12 +6,15 @@ Required properties: Optional properties: - mediatek,headset-codec: the phandles of ts3a227 codecs +- mediatek,ec-codec: the phandle of EC codecs. + See google,cros-ec-codec.txt for more details. Example: sound { compatible = "mediatek,mt8183_mt6358_ts3a227_max98357"; mediatek,headset-codec = <&ts3a227>; + mediatek,ec-codec = <&ec_codec>; mediatek,platform = <&afe>; };
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
PATCH 10/10 ASoC: mediatek: mt8183: support WoV
In reply to Tzung-Bi ShihAdd DAI link and pin muxing for wake on voice.
--- sound/soc/mediatek/Kconfig | 1 + .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 70 ++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-)
sound/soc/mediatek/Kconfig +1 -0
@@ -125,6 +125,7 @@ config SND_SOC_MT8183_MT6358_TS3A227E_MAX98357A select SND_SOC_MAX98357A select SND_SOC_BT_SCO select SND_SOC_TS3A227E + select SND_SOC_CROS_EC_CODEC help This adds ASoC driver for Mediatek MT8183 boards with the MT6358 TS3A227E MAX98357A audio codec.
sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c +67 -3
113 lines not on this page · raw message
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog