2022-07-28 07:15:34

by Srinivasa Rao Mandadapu

[permalink] [raw]
Subject: [PATCH] ASoC: qcom: SC7280: Add support for external DMIC bias supply

Update SC7280 machine driver for enabling external mic bias supply,
Which is required for villager rev boards.

Signed-off-by: Srinivasa Rao Mandadapu <[email protected]>
---
sound/soc/qcom/sc7280.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/sound/soc/qcom/sc7280.c b/sound/soc/qcom/sc7280.c
index da7469a..6404e94 100644
--- a/sound/soc/qcom/sc7280.c
+++ b/sound/soc/qcom/sc7280.c
@@ -33,6 +33,7 @@ struct sc7280_snd_data {
struct snd_soc_jack hdmi_jack;
bool jack_setup;
bool stream_prepared[LPASS_MAX_PORTS];
+ struct regulator *vdd_supply;
};

static void sc7280_jack_free(struct snd_jack *jack)
@@ -345,6 +346,24 @@ static int sc7280_snd_startup(struct snd_pcm_substream *substream)
return ret;
}

+static int sc7280_dmic_micbias(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ struct snd_soc_card *card = w->dapm->card;
+ struct sc7280_snd_data *data = snd_soc_card_get_drvdata(card);
+ int ret = 0;
+
+ switch (event) {
+ case SND_SOC_DAPM_PRE_PMU:
+ ret = regulator_enable(data->vdd_supply);
+ break;
+ case SND_SOC_DAPM_POST_PMD:
+ ret = regulator_disable(data->vdd_supply);
+ break;
+ }
+ return ret;
+}
+
static const struct snd_soc_ops sc7280_ops = {
.startup = sc7280_snd_startup,
.hw_params = sc7280_snd_hw_params,
@@ -356,6 +375,7 @@ static const struct snd_soc_ops sc7280_ops = {
static const struct snd_soc_dapm_widget sc7280_snd_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
+ SND_SOC_DAPM_MIC("PMIC BIAS", sc7280_dmic_micbias),
};

static int sc7280_snd_platform_probe(struct platform_device *pdev)
@@ -389,6 +409,10 @@ static int sc7280_snd_platform_probe(struct platform_device *pdev)
link->ops = &sc7280_ops;
}

+ data->vdd_supply = devm_regulator_get(dev, "vdd-dmic-bias");
+ if (IS_ERR(data->vdd_supply)
+ return PTR_ERR(data->vdd_supply);
+
return devm_snd_soc_register_card(dev, card);
}

--
2.7.4


2022-07-28 11:18:36

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: qcom: SC7280: Add support for external DMIC bias supply

On Thu, Jul 28, 2022 at 12:40:33PM +0530, Srinivasa Rao Mandadapu wrote:

> +static int sc7280_dmic_micbias(struct snd_soc_dapm_widget *w,

> + struct snd_kcontrol *kcontrol, int event)
> +{
> + struct snd_soc_card *card = w->dapm->card;
> + struct sc7280_snd_data *data = snd_soc_card_get_drvdata(card);
> + int ret = 0;
> +

This is open coding SND_SOC_DAPM_REGULATOR_SUPPLY() isn't it?


Attachments:
(No filename) (404.00 B)
signature.asc (499.00 B)
Download all attachments

2022-07-28 13:09:37

by Srinivasa Rao Mandadapu

[permalink] [raw]
Subject: Re: [PATCH] ASoC: qcom: SC7280: Add support for external DMIC bias supply


On 7/28/2022 4:19 PM, Mark Brown wrote:
Thanks for your time Mark!!!
> On Thu, Jul 28, 2022 at 12:40:33PM +0530, Srinivasa Rao Mandadapu wrote:
>
>> +static int sc7280_dmic_micbias(struct snd_soc_dapm_widget *w,
>> + struct snd_kcontrol *kcontrol, int event)
>> +{
>> + struct snd_soc_card *card = w->dapm->card;
>> + struct sc7280_snd_data *data = snd_soc_card_get_drvdata(card);
>> + int ret = 0;
>> +
> This is open coding SND_SOC_DAPM_REGULATOR_SUPPLY() isn't it?

Yes, agree that SND_SOC_DAPM_REGULATOR_SUPPLY can be used here. As I was
using two different names for

VDD supply property and widget name, got confused. I will re post the
patch, with single name for both and replace with above macro .

2022-07-28 13:41:05

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] ASoC: qcom: SC7280: Add support for external DMIC bias supply

Hi Srinivasa,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on linus/master v5.19-rc8 next-20220728]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Srinivasa-Rao-Mandadapu/ASoC-qcom-SC7280-Add-support-for-external-DMIC-bias-supply/20220728-151249
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20220728/[email protected]/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d59fc8cd6dd22df37f41309d1d18a7853929e2f8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Srinivasa-Rao-Mandadapu/ASoC-qcom-SC7280-Add-support-for-external-DMIC-bias-supply/20220728-151249
git checkout d59fc8cd6dd22df37f41309d1d18a7853929e2f8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash sound/soc/qcom/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

sound/soc/qcom/sc7280.c: In function 'sc7280_snd_platform_probe':
>> sound/soc/qcom/sc7280.c:413:37: error: expected ')' before 'return'
413 | if (IS_ERR(data->vdd_supply)
| ~ ^
| )
414 | return PTR_ERR(data->vdd_supply);
| ~~~~~~
>> sound/soc/qcom/sc7280.c:417:1: error: expected expression before '}' token
417 | }
| ^
sound/soc/qcom/sc7280.c:417:1: error: control reaches end of non-void function [-Werror=return-type]
417 | }
| ^
cc1: some warnings being treated as errors


vim +413 sound/soc/qcom/sc7280.c

380
381 static int sc7280_snd_platform_probe(struct platform_device *pdev)
382 {
383 struct snd_soc_card *card;
384 struct sc7280_snd_data *data;
385 struct device *dev = &pdev->dev;
386 struct snd_soc_dai_link *link;
387 int ret, i;
388
389 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
390 if (!data)
391 return -ENOMEM;
392
393 card = &data->card;
394 snd_soc_card_set_drvdata(card, data);
395
396 card->owner = THIS_MODULE;
397 card->driver_name = "SC7280";
398 card->dev = dev;
399
400 card->dapm_widgets = sc7280_snd_widgets;
401 card->num_dapm_widgets = ARRAY_SIZE(sc7280_snd_widgets);
402
403 ret = qcom_snd_parse_of(card);
404 if (ret)
405 return ret;
406
407 for_each_card_prelinks(card, i, link) {
408 link->init = sc7280_init;
409 link->ops = &sc7280_ops;
410 }
411
412 data->vdd_supply = devm_regulator_get(dev, "vdd-dmic-bias");
> 413 if (IS_ERR(data->vdd_supply)
414 return PTR_ERR(data->vdd_supply);
415
416 return devm_snd_soc_register_card(dev, card);
> 417 }
418

--
0-DAY CI Kernel Test Service
https://01.org/lkp