[alsa-devel] [PATCH 0/3] ASoC: codecs: msm8916-wcd-digital: Fix dmic support
From: Srinivas Kandagatla srinivas.kandagatla@linaro.org
This patchset fixes dmic support in the codec driver, first and second patch fixes the mclk rate for the codec and the third patch adds few missing register writes to select dmic.
Tested on DB410c with Audio Mezz board which has got dmic on it.
Srinivas Kandagatla (3): ASoC: codecs: msm8916-wcd-digital: add support to set_sysclk ASoC: qcom: apq8016-sbc: set default mclk rate ASoC: codecs: msm8916-wcd-digital: fix dmic support
sound/soc/codecs/msm8916-wcd-digital.c | 36 ++++++++++++++++++++++++++++++++++ sound/soc/qcom/apq8016_sbc.c | 6 ++++++ 2 files changed, 42 insertions(+)
From: Srinivas Kandagatla srinivas.kandagatla@linaro.org
This patch adds support to set_sysclk() which can let the sound card driver to set default mclk rate. In this case MCLK for internal audio codec is expected to be at 9.6MHz by default.
Signed-off-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org --- sound/soc/codecs/msm8916-wcd-digital.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index f690442af8c9..126a0ee8aded 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -568,6 +568,16 @@ static int msm8916_wcd_digital_codec_probe(struct snd_soc_codec *codec) return 0; }
+static int msm8916_set_dai_sysclk(struct snd_soc_dai *dai, + int clk_id, unsigned int freq, int dir) +{ + struct msm8916_wcd_digital_priv *p = dev_get_drvdata(dai->codec->dev); + + clk_set_rate(p->mclk, freq); + + return 0; +} + static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -792,6 +802,7 @@ static struct snd_soc_dai_ops msm8916_wcd_digital_dai_ops = { .startup = msm8916_wcd_digital_startup, .shutdown = msm8916_wcd_digital_shutdown, .hw_params = msm8916_wcd_digital_hw_params, + .set_sysclk = msm8916_set_dai_sysclk, };
static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = {
On Mon, Jul 17, 2017 at 03:54:08PM +0200, srinivas.kandagatla@linaro.org wrote:
+static int msm8916_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir)
+{
- struct msm8916_wcd_digital_priv *p = dev_get_drvdata(dai->codec->dev);
- clk_set_rate(p->mclk, freq);
This is ignoring the return value.
On 17/07/17 15:44, Mark Brown wrote:
On Mon, Jul 17, 2017 at 03:54:08PM +0200, srinivas.kandagatla@linaro.org wrote:
+static int msm8916_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir)
+{
- struct msm8916_wcd_digital_priv *p = dev_get_drvdata(dai->codec->dev);
- clk_set_rate(p->mclk, freq);
This is ignoring the return value.
Thanks, I will take care of it in next version.
--srini
From: Srinivas Kandagatla srinivas.kandagatla@linaro.org
MCLK for internal audio codec is expected to be at 9.6MHz by default. This patch adds support to 9.6MHz to make the default case possible.
Signed-off-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org --- sound/soc/qcom/apq8016_sbc.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index d084d7468299..1064c1b85c63 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -34,10 +34,12 @@ struct apq8016_sbc_data { #define MIC_CTRL_QUA_WS_SLAVE_SEL_10 BIT(17) #define MIC_CTRL_TLMM_SCLK_EN BIT(1) #define SPKR_CTL_PRI_WS_SLAVE_SEL_11 (BIT(17) | BIT(16)) +#define DEFAULT_MCLK_RATE 9600000
static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_card *card = rtd->card; struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card); int rval = 0; @@ -68,6 +70,10 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd)
}
+ /* Set default mclk for internal codec */ + snd_soc_dai_set_sysclk(codec_dai, 0, DEFAULT_MCLK_RATE, + SND_SOC_CLOCK_IN); + return rval; }
From: Srinivas Kandagatla srinivas.kandagatla@linaro.org
This patch fixes dmic support which was broken in this driver.
Signed-off-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org --- sound/soc/codecs/msm8916-wcd-digital.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index 126a0ee8aded..3265bd404fd7 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -168,6 +168,9 @@
#define LPASS_CDC_TX2_VOL_CTL_CFG (0x2A8) #define LPASS_CDC_TX1_MUX_CTL (0x28C) +#define TX_MUX_CTL_ADC_DMIC_SEL_MASK BIT(0) +#define TX_MUX_CTL_ADC_DMIC_SEL_DMIC BIT(0) +#define TX_MUX_CTL_ADC_DMIC_SEL_ADC 0 #define TX_MUX_CTL_CUT_OFF_FREQ_MASK GENMASK(5, 4) #define TX_MUX_CTL_CUT_OFF_FREQ_SHIFT 4 #define TX_MUX_CTL_CF_NEG_3DB_4HZ (0x0 << 4) @@ -439,17 +442,37 @@ static int msm8916_wcd_digital_enable_dmic(struct snd_soc_dapm_widget *w, DMIC_B1_CTL_DMIC0_CLK_SEL_DIV3); switch (dmic) { case 1: + snd_soc_update_bits(codec, LPASS_CDC_TX1_MUX_CTL, + TX_MUX_CTL_ADC_DMIC_SEL_MASK, + TX_MUX_CTL_ADC_DMIC_SEL_DMIC); snd_soc_update_bits(codec, LPASS_CDC_TX1_DMIC_CTL, TXN_DMIC_CTL_CLK_SEL_MASK, TXN_DMIC_CTL_CLK_SEL_DIV3); break; case 2: + snd_soc_update_bits(codec, LPASS_CDC_TX2_MUX_CTL, + TX_MUX_CTL_ADC_DMIC_SEL_MASK, + TX_MUX_CTL_ADC_DMIC_SEL_DMIC); snd_soc_update_bits(codec, LPASS_CDC_TX2_DMIC_CTL, TXN_DMIC_CTL_CLK_SEL_MASK, TXN_DMIC_CTL_CLK_SEL_DIV3); break; } break; + case SND_SOC_DAPM_POST_PMD: + switch (dmic) { + case 1: + snd_soc_update_bits(codec, LPASS_CDC_TX1_MUX_CTL, + TX_MUX_CTL_ADC_DMIC_SEL_MASK, + 0); + break; + case 2: + snd_soc_update_bits(codec, LPASS_CDC_TX2_MUX_CTL, + TX_MUX_CTL_ADC_DMIC_SEL_MASK, + 0); + break; + } + break; }
return 0; @@ -536,6 +559,8 @@ static const struct snd_soc_dapm_widget msm8916_wcd_digital_dapm_widgets[] = { /* Connectivity Clock */ SND_SOC_DAPM_SUPPLY_S("CDC_CONN", -2, LPASS_CDC_CLK_OTHR_CTL, 2, 0, NULL, 0), + SND_SOC_DAPM_MIC("Digital Mic1", NULL), + SND_SOC_DAPM_MIC("Digital Mic2", NULL),
};
On Mon, Jul 17, 2017 at 03:54:10PM +0200, srinivas.kandagatla@linaro.org wrote:
From: Srinivas Kandagatla srinivas.kandagatla@linaro.org
This patch fixes dmic support which was broken in this driver.
In what way is DMIC support broken and how does this patch fix it?
On 17/07/17 15:45, Mark Brown wrote:
On Mon, Jul 17, 2017 at 03:54:10PM +0200, srinivas.kandagatla@linaro.org wrote:
From: Srinivas Kandagatla srinivas.kandagatla@linaro.org
This patch fixes dmic support which was broken in this driver.
In what way is DMIC support broken and how does this patch fix it?
The driver was not selecting DMIC in CIC filter source path. Which is why dmic was not functional from the beginning.
--srini
participants (3)
-
Mark Brown
-
Srinivas Kandagatla
-
srinivas.kandagatla@linaro.org