From 1e7cbe5fb74db6a196fd9e8a665852c928a3128e Mon Sep 17 00:00:00 2001 From: Binyuan Lan Date: Fri, 20 Nov 2020 20:55:08 +0800 Subject: [PATCH] ASoC: es7202: add es7202 pdm adc support ES7202 is 2-ch ADC with PDM interface Replace digital_mute with mute_stream Change-Id: Id204f592ed91bbdddd71b6dda2e6e0bbae4bb9e8 Signed-off-by: Binyuan Lan Signed-off-by: Xing Zheng Signed-off-by: Sugar Zhang --- sound/soc/codecs/Kconfig | 4 ++++ sound/soc/codecs/Makefile | 2 ++ sound/soc/codecs/es7202.c | 36 +++++++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 5fae18d3e170..6a7a741b6d4c 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -96,6 +96,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_ES8328_I2C imply SND_SOC_ES8396 imply SND_SOC_ES7134 + imply SND_SOC_ES7202 imply SND_SOC_ES7241 imply SND_SOC_GTM601 imply SND_SOC_HDAC_HDMI @@ -781,6 +782,9 @@ config SND_SOC_HDMI_CODEC config SND_SOC_ES7134 tristate "Everest Semi ES7134 CODEC" +config SND_SOC_ES7202 + tristate "Everest Semi ES7202 PDM 2CH ADC" + config SND_SOC_ES7241 tristate "Everest Semi ES7241 CODEC" diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1e4488c472b8..da9268a4053e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -86,6 +86,7 @@ snd-soc-da9055-objs := da9055.o snd-soc-dmic-objs := dmic.o snd-soc-dummy-codec-objs := dummy-codec.o snd-soc-es7134-objs := es7134.o +snd-soc-es7202-objs := es7202.o snd-soc-es7241-objs := es7241.o snd-soc-es8311-objs := es8311.o snd-soc-es8316-objs := es8316.o @@ -404,6 +405,7 @@ obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o obj-$(CONFIG_SND_SOC_DUMMY_CODEC) += snd-soc-dummy-codec.o obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o +obj-$(CONFIG_SND_SOC_ES7202) += snd-soc-es7202.o obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o obj-$(CONFIG_SND_SOC_ES8311) += snd-soc-es8311.o obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o diff --git a/sound/soc/codecs/es7202.c b/sound/soc/codecs/es7202.c index 38bc78c9dab9..49035e8ca52d 100644 --- a/sound/soc/codecs/es7202.c +++ b/sound/soc/codecs/es7202.c @@ -533,20 +533,24 @@ static const struct snd_kcontrol_new es7202_snd_controls[] = { #endif }; -static int es7202_mute(struct snd_soc_dai *dai, int mute) +static int es7202_mute(struct snd_soc_dai *dai, int mute, int stream) { + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + return 0; + if (mute) { es7202_multi_chips_update_bits(ES7202_PDM_INF_CTL_REG07, 0x03,0x03); - } else if (dai->playback_active) { - es7202_multi_chips_update_bits(ES7202_PDM_INF_CTL_REG07, 0x03,0x00); + } else { + es7202_multi_chips_update_bits(ES7202_PDM_INF_CTL_REG07, 0x03,0x00); } + return 0; } #define es7202_RATES SNDRV_PCM_RATE_8000_96000 static struct snd_soc_dai_ops es7202_ops = { - .digital_mute = es7202_mute, + .mute_stream = es7202_mute, }; #if ES7202_CHANNELS_MAX > 0 static struct snd_soc_dai_driver es7202_dai0 = { @@ -556,6 +560,7 @@ static struct snd_soc_dai_driver es7202_dai0 = { .channels_min = 1, .channels_max = 2, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -567,8 +572,9 @@ static struct snd_soc_dai_driver es7202_dai1 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 4, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -580,8 +586,9 @@ static struct snd_soc_dai_driver es7202_dai2 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 6, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -593,8 +600,9 @@ static struct snd_soc_dai_driver es7202_dai3 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 8, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -606,8 +614,9 @@ static struct snd_soc_dai_driver es7202_dai4 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 10, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -619,8 +628,9 @@ static struct snd_soc_dai_driver es7202_dai5 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 12, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -632,8 +642,9 @@ static struct snd_soc_dai_driver es7202_dai6 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 14, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -645,8 +656,9 @@ static struct snd_soc_dai_driver es7202_dai7 = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 16, .rates = es7202_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &es7202_ops, .symmetric_rates = 1, @@ -732,6 +744,8 @@ static int es7202_probe(struct snd_soc_component *component) es7202_write(ES7202_RESET_REG00, 0x01, i2c_ctl[cnt]); es7202_write(ES7202_CLK_EN_REG03, 0x03, i2c_ctl[cnt]); es7202_write(ES7202_BIAS_VMID_REG11, 0x2E, i2c_ctl[cnt]); + + es7202_multi_chips_update_bits(ES7202_PDM_INF_CTL_REG07, 0x03, 0x00); } return ret; }