aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIcenowy Zheng <icenowy@aosc.xyz>2017-05-24 06:05:59 -0400
committerMark Brown <broonie@kernel.org>2017-05-24 12:53:40 -0400
commitb08a20f58d2efcd88bf5276e34cd4020028accb7 (patch)
tree31d0bd1b4ac3d18bef3732eed34f0bcf6040869d
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
ASoC: sun8i-codec-analog: split out mbias
Allwinner V3s features an analog codec without MBIAS pin. Split out this part, in order to prepare for the V3s analog codec. Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sunxi/sun8i-codec-analog.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c
index 6c17c99c2c8d..edcc3eb7cd9a 100644
--- a/sound/soc/sunxi/sun8i-codec-analog.c
+++ b/sound/soc/sunxi/sun8i-codec-analog.c
@@ -289,11 +289,6 @@ static const struct snd_soc_dapm_widget sun8i_codec_common_widgets[] = {
289 /* Microphone input */ 289 /* Microphone input */
290 SND_SOC_DAPM_INPUT("MIC1"), 290 SND_SOC_DAPM_INPUT("MIC1"),
291 291
292 /* Microphone Bias */
293 SND_SOC_DAPM_SUPPLY("MBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
294 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MMICBIASEN,
295 0, NULL, 0),
296
297 /* Mic input path */ 292 /* Mic input path */
298 SND_SOC_DAPM_PGA("Mic1 Amplifier", SUN8I_ADDA_MIC1G_MICBIAS_CTRL, 293 SND_SOC_DAPM_PGA("Mic1 Amplifier", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
299 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN, 0, NULL, 0), 294 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN, 0, NULL, 0),
@@ -453,6 +448,27 @@ static int sun8i_codec_add_headphone(struct snd_soc_component *cmpnt)
453 return 0; 448 return 0;
454} 449}
455 450
451/* mbias specific widget */
452static const struct snd_soc_dapm_widget sun8i_codec_mbias_widgets[] = {
453 SND_SOC_DAPM_SUPPLY("MBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
454 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MMICBIASEN,
455 0, NULL, 0),
456};
457
458static int sun8i_codec_add_mbias(struct snd_soc_component *cmpnt)
459{
460 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
461 struct device *dev = cmpnt->dev;
462 int ret;
463
464 ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_mbias_widgets,
465 ARRAY_SIZE(sun8i_codec_mbias_widgets));
466 if (ret)
467 dev_err(dev, "Failed to add MBIAS DAPM widgets: %d\n", ret);
468
469 return ret;
470}
471
456/* hmic specific widget */ 472/* hmic specific widget */
457static const struct snd_soc_dapm_widget sun8i_codec_hmic_widgets[] = { 473static const struct snd_soc_dapm_widget sun8i_codec_hmic_widgets[] = {
458 SND_SOC_DAPM_SUPPLY("HBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL, 474 SND_SOC_DAPM_SUPPLY("HBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
@@ -679,6 +695,7 @@ struct sun8i_codec_analog_quirks {
679 bool has_hmic; 695 bool has_hmic;
680 bool has_linein; 696 bool has_linein;
681 bool has_lineout; 697 bool has_lineout;
698 bool has_mbias;
682 bool has_mic2; 699 bool has_mic2;
683}; 700};
684 701
@@ -686,12 +703,14 @@ static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
686 .has_headphone = true, 703 .has_headphone = true,
687 .has_hmic = true, 704 .has_hmic = true,
688 .has_linein = true, 705 .has_linein = true,
706 .has_mbias = true,
689 .has_mic2 = true, 707 .has_mic2 = true,
690}; 708};
691 709
692static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { 710static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
693 .has_linein = true, 711 .has_linein = true,
694 .has_lineout = true, 712 .has_lineout = true,
713 .has_mbias = true,
695 .has_mic2 = true, 714 .has_mic2 = true,
696}; 715};
697 716
@@ -734,6 +753,12 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
734 return ret; 753 return ret;
735 } 754 }
736 755
756 if (quirks->has_mbias) {
757 ret = sun8i_codec_add_mbias(cmpnt);
758 if (ret)
759 return ret;
760 }
761
737 if (quirks->has_mic2) { 762 if (quirks->has_mic2) {
738 ret = sun8i_codec_add_mic2(cmpnt); 763 ret = sun8i_codec_add_mic2(cmpnt);
739 if (ret) 764 if (ret)