Commit b6bc07d4 authored by Tzung-Bi Shih's avatar Tzung-Bi Shih Committed by Mark Brown

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: default avatarTzung-Bi Shih <tzungbi@google.com>
Acked-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20191019143504.1.I5388b69a7a9c551078fed216a77440cee6dedf49@changeidSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7d2f70f2
......@@ -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), \
......
......@@ -556,6 +556,9 @@ enum host_event_code {
/* Keyboard recovery combo with hardware reinitialization */
EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT = 30,
/* WoV */
EC_HOST_EVENT_WOV = 31,
/*
* The high bit of the event mask is not used as a host event code. If
* it reads back as set, then the entire event mask should be
......@@ -4477,10 +4480,14 @@ enum ec_codec_subcmd {
};
enum ec_codec_cap {
EC_CODEC_CAP_WOV_AUDIO_SHM = 0,
EC_CODEC_CAP_WOV_LANG_SHM = 1,
EC_CODEC_CAP_LAST = 32,
};
enum ec_codec_shm_id {
EC_CODEC_SHM_ID_WOV_AUDIO = 0x0,
EC_CODEC_SHM_ID_WOV_LANG = 0x1,
EC_CODEC_SHM_ID_LAST,
};
......@@ -4641,6 +4648,68 @@ struct __ec_align4 ec_param_ec_codec_i2s_rx {
};
};
/*****************************************************************************/
/* Commands for WoV on audio codec. */
#define EC_CMD_EC_CODEC_WOV 0x00BF
enum ec_codec_wov_subcmd {
EC_CODEC_WOV_SET_LANG = 0x0,
EC_CODEC_WOV_SET_LANG_SHM = 0x1,
EC_CODEC_WOV_GET_LANG = 0x2,
EC_CODEC_WOV_ENABLE = 0x3,
EC_CODEC_WOV_DISABLE = 0x4,
EC_CODEC_WOV_READ_AUDIO = 0x5,
EC_CODEC_WOV_READ_AUDIO_SHM = 0x6,
EC_CODEC_WOV_SUBCMD_COUNT,
};
/*
* @hash is SHA256 of the whole language model.
* @total_len indicates the length of whole language model.
* @offset is the cursor from the beginning of the model.
* @buf is the packet buffer.
* @len denotes how many bytes in the buf.
*/
struct __ec_align4 ec_param_ec_codec_wov_set_lang {
uint8_t hash[32];
uint32_t total_len;
uint32_t offset;
uint8_t buf[128];
uint32_t len;
};
struct __ec_align4 ec_param_ec_codec_wov_set_lang_shm {
uint8_t hash[32];
uint32_t total_len;
};
struct __ec_align4 ec_param_ec_codec_wov {
uint8_t cmd; /* enum ec_codec_wov_subcmd */
uint8_t reserved[3];
union {
struct ec_param_ec_codec_wov_set_lang
set_lang_param;
struct ec_param_ec_codec_wov_set_lang_shm
set_lang_shm_param;
};
};
struct __ec_align4 ec_response_ec_codec_wov_get_lang {
uint8_t hash[32];
};
struct __ec_align4 ec_response_ec_codec_wov_read_audio {
uint8_t buf[128];
uint32_t len;
};
struct __ec_align4 ec_response_ec_codec_wov_read_audio_shm {
uint32_t offset;
uint32_t len;
};
/*****************************************************************************/
/* System commands */
......
......@@ -509,6 +509,8 @@ config SND_SOC_CQ0093VC
config SND_SOC_CROS_EC_CODEC
tristate "codec driver for ChromeOS EC"
depends on CROS_EC
select CRYPTO
select CRYPTO_SHA256
help
If you say yes here you will get support for the
ChromeOS Embedded Controller's Audio Codec.
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment