From 549d11d4fe24af10cd7d892ce6448d92bafa8131 Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Thu, 18 Jul 2019 13:44:17 +0530 Subject: [PATCH] asoc: codecs: Update on support for WCD938x DMICs WCD938x codec can support upto 8 DMICs. Fix driver to enable support for these DMICs over soundwire. Change-Id: I82b9c7c6f56271c03acee3a966dbaa4fefb62102 Signed-off-by: Laxminath Kasam --- asoc/codecs/bolero/tx-macro.c | 20 ++++++++++++++++++-- asoc/codecs/bolero/va-macro.c | 21 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c index bc5b056b03ec..2b830995b8e3 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -470,6 +470,12 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val = 0; u16 mic_sel_reg = 0; + u16 dmic_clk_reg = 0; + struct device *tx_dev = NULL; + struct tx_macro_priv *tx_priv = NULL; + + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) + return -EINVAL; val = ucontrol->value.enumerated.item[0]; if (val > e->items - 1) @@ -510,14 +516,24 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, } if (strnstr(widget->name, "SMIC", strlen(widget->name))) { if (val != 0) { - if (val < 5) + if (val < 5) { snd_soc_component_update_bits(component, mic_sel_reg, 1 << 7, 0x0 << 7); - else + } else { snd_soc_component_update_bits(component, mic_sel_reg, 1 << 7, 0x1 << 7); + snd_soc_component_update_bits(component, + BOLERO_CDC_VA_TOP_CSR_DMIC_CFG, + 0x80, 0x00); + dmic_clk_reg = + BOLERO_CDC_TX_TOP_CSR_SWR_DMIC0_CTL + + ((val - 5)/2) * 4; + snd_soc_component_update_bits(component, + dmic_clk_reg, + 0x0E, tx_priv->dmic_clk_div << 0x1); + } } } else { /* DMIC selected */ diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c index 8e5abaa3c7d4..70ff6909e43f 100644 --- a/asoc/codecs/bolero/va-macro.c +++ b/asoc/codecs/bolero/va-macro.c @@ -409,7 +409,12 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; - u16 mic_sel_reg; + u16 mic_sel_reg, dmic_clk_reg; + struct device *va_dev = NULL; + struct va_macro_priv *va_priv = NULL; + + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) + return -EINVAL; val = ucontrol->value.enumerated.item[0]; if (val > e->items - 1) @@ -450,14 +455,24 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, } if (strnstr(widget->name, "SMIC", strlen(widget->name))) { if (val != 0) { - if (val < 5) + if (val < 5) { snd_soc_component_update_bits(component, mic_sel_reg, 1 << 7, 0x0 << 7); - else + } else { snd_soc_component_update_bits(component, mic_sel_reg, 1 << 7, 0x1 << 7); + snd_soc_component_update_bits(component, + BOLERO_CDC_VA_TOP_CSR_DMIC_CFG, + 0x80, 0x00); + dmic_clk_reg = + BOLERO_CDC_TX_TOP_CSR_SWR_DMIC0_CTL + + ((val - 5)/2) * 4; + snd_soc_component_update_bits(component, + dmic_clk_reg, + 0x0E, va_priv->dmic_clk_div << 0x1); + } } } else { /* DMIC selected */