[PATCH] ASoc: amd: Add DMIC switch capability to machine driver
Switch between DMIC0 and DMIC1 based on recording device selected. This is done by toggling the dmic select gpio.
Signed-off-by: Akshu Agrawal akshu.agrawal@amd.com --- sound/soc/amd/acp3x-rt5682-max9836.c | 53 ++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 6 deletions(-)
diff --git a/sound/soc/amd/acp3x-rt5682-max9836.c b/sound/soc/amd/acp3x-rt5682-max9836.c index 96fbcd29e3ed..511b8b1722aa 100644 --- a/sound/soc/amd/acp3x-rt5682-max9836.c +++ b/sound/soc/amd/acp3x-rt5682-max9836.c @@ -12,6 +12,7 @@ #include <sound/jack.h> #include <linux/clk.h> #include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/i2c.h> #include <linux/input.h> @@ -27,6 +28,7 @@ static struct snd_soc_jack pco_jack; static struct clk *rt5682_dai_wclk; static struct clk *rt5682_dai_bclk; +static struct gpio_desc *dmic_sel;
static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd) { @@ -176,7 +178,7 @@ static int acp3x_max_startup(struct snd_pcm_substream *substream) return rt5682_clk_enable(substream); }
-static int acp3x_ec_startup(struct snd_pcm_substream *substream) +static int acp3x_ec_dmic0_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; @@ -185,6 +187,23 @@ static int acp3x_ec_startup(struct snd_pcm_substream *substream)
machine->cap_i2s_instance = I2S_BT_INSTANCE; snd_soc_dai_set_bclk_ratio(codec_dai, 64); + if (dmic_sel) + gpiod_set_value(dmic_sel, 0); + + return rt5682_clk_enable(substream); +} + +static int acp3x_ec_dmic1_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct acp3x_platform_info *machine = snd_soc_card_get_drvdata(card); + + machine->cap_i2s_instance = I2S_BT_INSTANCE; + snd_soc_dai_set_bclk_ratio(codec_dai, 64); + if (dmic_sel) + gpiod_set_value(dmic_sel, 1);
return rt5682_clk_enable(substream); } @@ -204,8 +223,13 @@ static const struct snd_soc_ops acp3x_max_play_ops = { .shutdown = rt5682_shutdown, };
-static const struct snd_soc_ops acp3x_ec_cap_ops = { - .startup = acp3x_ec_startup, +static const struct snd_soc_ops acp3x_ec_cap0_ops = { + .startup = acp3x_ec_dmic0_startup, + .shutdown = rt5682_shutdown, +}; + +static const struct snd_soc_ops acp3x_ec_cap1_ops = { + .startup = acp3x_ec_dmic1_startup, .shutdown = rt5682_shutdown, };
@@ -246,12 +270,21 @@ static struct snd_soc_dai_link acp3x_dai_5682_98357[] = { SND_SOC_DAILINK_REG(acp3x_bt, max, platform), }, { - .name = "acp3x-ec-capture", - .stream_name = "Capture", + .name = "acp3x-ec-dmic0-capture", + .stream_name = "Capture DMIC0", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBS_CFS, + .dpcm_capture = 1, + .ops = &acp3x_ec_cap0_ops, + SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform), + }, + { + .name = "acp3x-ec-dmic1-capture", + .stream_name = "Capture DMIC1", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .dpcm_capture = 1, - .ops = &acp3x_ec_cap_ops, + .ops = &acp3x_ec_cap1_ops, SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform), }, }; @@ -302,6 +335,14 @@ static int acp3x_probe(struct platform_device *pdev) acp3x_card.dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); + + dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW); + if (IS_ERR(dmic_sel)) { + dev_err(&pdev->dev, "DMIC gpio failed err=%d\n", + PTR_ERR(dmic_sel)); + return PTR_ERR(dmic_sel); + } + ret = devm_snd_soc_register_card(&pdev->dev, &acp3x_card); if (ret) { dev_err(&pdev->dev,
Hi Akshu,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on asoc/for-next] [also build test WARNING on next-20200228] [cannot apply to v5.6-rc4] [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/Akshu-Agrawal/ASoc-amd-Add-DMIC-swi... base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: i386-allyesconfig (attached as .config) compiler: gcc-7 (Debian 7.5.0-5) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=i386
If you fix the issue, kindly add following tag Reported-by: kbuild test robot lkp@intel.com
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15:0, from include/sound/core.h:10, from sound/soc//amd/acp3x-rt5682-max9836.c:7: sound/soc//amd/acp3x-rt5682-max9836.c: In function 'acp3x_probe':
sound/soc//amd/acp3x-rt5682-max9836.c:341:23: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
dev_err(&pdev->dev, "DMIC gpio failed err=%d\n", ^ include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt' #define dev_fmt(fmt) fmt ^~~
sound/soc//amd/acp3x-rt5682-max9836.c:341:3: note: in expansion of macro 'dev_err'
dev_err(&pdev->dev, "DMIC gpio failed err=%d\n", ^~~~~~~
vim +/dev_err +341 sound/soc//amd/acp3x-rt5682-max9836.c
323 324 static int acp3x_probe(struct platform_device *pdev) 325 { 326 int ret; 327 struct snd_soc_card *card; 328 struct acp3x_platform_info *machine; 329 330 machine = devm_kzalloc(&pdev->dev, sizeof(*machine), GFP_KERNEL); 331 if (!machine) 332 return -ENOMEM; 333 334 card = &acp3x_card; 335 acp3x_card.dev = &pdev->dev; 336 platform_set_drvdata(pdev, card); 337 snd_soc_card_set_drvdata(card, machine); 338 339 dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW); 340 if (IS_ERR(dmic_sel)) {
341 dev_err(&pdev->dev, "DMIC gpio failed err=%d\n",
342 PTR_ERR(dmic_sel)); 343 return PTR_ERR(dmic_sel); 344 } 345 346 ret = devm_snd_soc_register_card(&pdev->dev, &acp3x_card); 347 if (ret) { 348 dev_err(&pdev->dev, 349 "devm_snd_soc_register_card(%s) failed: %d\n", 350 acp3x_card.name, ret); 351 return ret; 352 } 353 return 0; 354 } 355
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
The patch
ASoc: amd: Add DMIC switch capability to machine driver
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 72c3b2b09fcdaa6a63e17e9a715e2a8236af529a Mon Sep 17 00:00:00 2001
From: Akshu Agrawal akshu.agrawal@amd.com Date: Mon, 2 Mar 2020 13:54:36 +0530 Subject: [PATCH] ASoc: amd: Add DMIC switch capability to machine driver
Switch between DMIC0 and DMIC1 based on recording device selected. This is done by toggling the dmic select gpio.
Signed-off-by: Akshu Agrawal akshu.agrawal@amd.com Link: https://lore.kernel.org/r/20200302082443.51587-1-akshu.agrawal@amd.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/amd/acp3x-rt5682-max9836.c | 53 ++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 6 deletions(-)
diff --git a/sound/soc/amd/acp3x-rt5682-max9836.c b/sound/soc/amd/acp3x-rt5682-max9836.c index 96fbcd29e3ed..511b8b1722aa 100644 --- a/sound/soc/amd/acp3x-rt5682-max9836.c +++ b/sound/soc/amd/acp3x-rt5682-max9836.c @@ -12,6 +12,7 @@ #include <sound/jack.h> #include <linux/clk.h> #include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/i2c.h> #include <linux/input.h> @@ -27,6 +28,7 @@ static struct snd_soc_jack pco_jack; static struct clk *rt5682_dai_wclk; static struct clk *rt5682_dai_bclk; +static struct gpio_desc *dmic_sel;
static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd) { @@ -176,7 +178,7 @@ static int acp3x_max_startup(struct snd_pcm_substream *substream) return rt5682_clk_enable(substream); }
-static int acp3x_ec_startup(struct snd_pcm_substream *substream) +static int acp3x_ec_dmic0_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; @@ -185,6 +187,23 @@ static int acp3x_ec_startup(struct snd_pcm_substream *substream)
machine->cap_i2s_instance = I2S_BT_INSTANCE; snd_soc_dai_set_bclk_ratio(codec_dai, 64); + if (dmic_sel) + gpiod_set_value(dmic_sel, 0); + + return rt5682_clk_enable(substream); +} + +static int acp3x_ec_dmic1_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct acp3x_platform_info *machine = snd_soc_card_get_drvdata(card); + + machine->cap_i2s_instance = I2S_BT_INSTANCE; + snd_soc_dai_set_bclk_ratio(codec_dai, 64); + if (dmic_sel) + gpiod_set_value(dmic_sel, 1);
return rt5682_clk_enable(substream); } @@ -204,8 +223,13 @@ static const struct snd_soc_ops acp3x_max_play_ops = { .shutdown = rt5682_shutdown, };
-static const struct snd_soc_ops acp3x_ec_cap_ops = { - .startup = acp3x_ec_startup, +static const struct snd_soc_ops acp3x_ec_cap0_ops = { + .startup = acp3x_ec_dmic0_startup, + .shutdown = rt5682_shutdown, +}; + +static const struct snd_soc_ops acp3x_ec_cap1_ops = { + .startup = acp3x_ec_dmic1_startup, .shutdown = rt5682_shutdown, };
@@ -246,12 +270,21 @@ static struct snd_soc_dai_link acp3x_dai_5682_98357[] = { SND_SOC_DAILINK_REG(acp3x_bt, max, platform), }, { - .name = "acp3x-ec-capture", - .stream_name = "Capture", + .name = "acp3x-ec-dmic0-capture", + .stream_name = "Capture DMIC0", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBS_CFS, + .dpcm_capture = 1, + .ops = &acp3x_ec_cap0_ops, + SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform), + }, + { + .name = "acp3x-ec-dmic1-capture", + .stream_name = "Capture DMIC1", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .dpcm_capture = 1, - .ops = &acp3x_ec_cap_ops, + .ops = &acp3x_ec_cap1_ops, SND_SOC_DAILINK_REG(acp3x_bt, cros_ec, platform), }, }; @@ -302,6 +335,14 @@ static int acp3x_probe(struct platform_device *pdev) acp3x_card.dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); + + dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW); + if (IS_ERR(dmic_sel)) { + dev_err(&pdev->dev, "DMIC gpio failed err=%d\n", + PTR_ERR(dmic_sel)); + return PTR_ERR(dmic_sel); + } + ret = devm_snd_soc_register_card(&pdev->dev, &acp3x_card); if (ret) { dev_err(&pdev->dev,
participants (3)
-
Akshu Agrawal
-
kbuild test robot
-
Mark Brown