aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorIcenowy Zheng2017-03-05 07:36:58 -0600
committerMark Brown2017-03-15 13:05:32 -0500
commit3f48947d56ff3e42e2e490714025e984af817f5d (patch)
tree79d37bf97508ee28056c7eaa3f1d60c3bf1e3daa /sound
parentfa22ca4f905d7001ed966bc95bcffb890a1b8d73 (diff)
downloadkernel-3f48947d56ff3e42e2e490714025e984af817f5d.tar.gz
kernel-3f48947d56ff3e42e2e490714025e984af817f5d.tar.xz
kernel-3f48947d56ff3e42e2e490714025e984af817f5d.zip
ASoC: sun8i-codec-analog: split out mic2
Allwinner V3s features an analog codec without MIC2. Split out this part, in order to prepare for the V3s analog codec. Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/sunxi/sun8i-codec-analog.c92
1 files changed, 76 insertions, 16 deletions
diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c
index 72331332b72e..b95ff045cd7f 100644
--- a/sound/soc/sunxi/sun8i-codec-analog.c
+++ b/sound/soc/sunxi/sun8i-codec-analog.c
@@ -259,17 +259,11 @@ static const struct snd_kcontrol_new sun8i_codec_common_controls[] = {
259 SOC_SINGLE_TLV("Mic1 Playback Volume", SUN8I_ADDA_MICIN_GCTRL, 259 SOC_SINGLE_TLV("Mic1 Playback Volume", SUN8I_ADDA_MICIN_GCTRL,
260 SUN8I_ADDA_MICIN_GCTRL_MIC1G, 260 SUN8I_ADDA_MICIN_GCTRL_MIC1G,
261 0x7, 0, sun8i_codec_out_mixer_pregain_scale), 261 0x7, 0, sun8i_codec_out_mixer_pregain_scale),
262 SOC_SINGLE_TLV("Mic2 Playback Volume",
263 SUN8I_ADDA_MICIN_GCTRL, SUN8I_ADDA_MICIN_GCTRL_MIC2G,
264 0x7, 0, sun8i_codec_out_mixer_pregain_scale),
265 262
266 /* Microphone Amp boost gains */ 263 /* Microphone Amp boost gain */
267 SOC_SINGLE_TLV("Mic1 Boost Volume", SUN8I_ADDA_MIC1G_MICBIAS_CTRL, 264 SOC_SINGLE_TLV("Mic1 Boost Volume", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
268 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1BOOST, 0x7, 0, 265 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1BOOST, 0x7, 0,
269 sun8i_codec_mic_gain_scale), 266 sun8i_codec_mic_gain_scale),
270 SOC_SINGLE_TLV("Mic2 Boost Volume", SUN8I_ADDA_MIC2G_CTRL,
271 SUN8I_ADDA_MIC2G_CTRL_MIC2BOOST, 0x7, 0,
272 sun8i_codec_mic_gain_scale),
273 267
274 /* ADC */ 268 /* ADC */
275 SOC_SINGLE_TLV("ADC Gain Capture Volume", SUN8I_ADDA_ADC_AP_EN, 269 SOC_SINGLE_TLV("ADC Gain Capture Volume", SUN8I_ADDA_ADC_AP_EN,
@@ -298,9 +292,8 @@ static const struct snd_soc_dapm_widget sun8i_codec_common_widgets[] = {
298 /* Line In */ 292 /* Line In */
299 SND_SOC_DAPM_INPUT("LINEIN"), 293 SND_SOC_DAPM_INPUT("LINEIN"),
300 294
301 /* Microphone inputs */ 295 /* Microphone input */
302 SND_SOC_DAPM_INPUT("MIC1"), 296 SND_SOC_DAPM_INPUT("MIC1"),
303 SND_SOC_DAPM_INPUT("MIC2"),
304 297
305 /* Microphone Bias */ 298 /* Microphone Bias */
306 SND_SOC_DAPM_SUPPLY("MBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL, 299 SND_SOC_DAPM_SUPPLY("MBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
@@ -310,8 +303,6 @@ static const struct snd_soc_dapm_widget sun8i_codec_common_widgets[] = {
310 /* Mic input path */ 303 /* Mic input path */
311 SND_SOC_DAPM_PGA("Mic1 Amplifier", SUN8I_ADDA_MIC1G_MICBIAS_CTRL, 304 SND_SOC_DAPM_PGA("Mic1 Amplifier", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
312 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN, 0, NULL, 0), 305 SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN, 0, NULL, 0),
313 SND_SOC_DAPM_PGA("Mic2 Amplifier", SUN8I_ADDA_MIC2G_CTRL,
314 SUN8I_ADDA_MIC2G_CTRL_MIC2AMPEN, 0, NULL, 0),
315 306
316 /* Mixers */ 307 /* Mixers */
317 SND_SOC_DAPM_MIXER("Left Mixer", SUN8I_ADDA_DAC_PA_SRC, 308 SND_SOC_DAPM_MIXER("Left Mixer", SUN8I_ADDA_DAC_PA_SRC,
@@ -335,35 +326,30 @@ static const struct snd_soc_dapm_widget sun8i_codec_common_widgets[] = {
335static const struct snd_soc_dapm_route sun8i_codec_common_routes[] = { 326static const struct snd_soc_dapm_route sun8i_codec_common_routes[] = {
336 /* Microphone Routes */ 327 /* Microphone Routes */
337 { "Mic1 Amplifier", NULL, "MIC1"}, 328 { "Mic1 Amplifier", NULL, "MIC1"},
338 { "Mic2 Amplifier", NULL, "MIC2"},
339 329
340 /* Left Mixer Routes */ 330 /* Left Mixer Routes */
341 { "Left Mixer", "DAC Playback Switch", "Left DAC" }, 331 { "Left Mixer", "DAC Playback Switch", "Left DAC" },
342 { "Left Mixer", "DAC Reversed Playback Switch", "Right DAC" }, 332 { "Left Mixer", "DAC Reversed Playback Switch", "Right DAC" },
343 { "Left Mixer", "Line In Playback Switch", "LINEIN" }, 333 { "Left Mixer", "Line In Playback Switch", "LINEIN" },
344 { "Left Mixer", "Mic1 Playback Switch", "Mic1 Amplifier" }, 334 { "Left Mixer", "Mic1 Playback Switch", "Mic1 Amplifier" },
345 { "Left Mixer", "Mic2 Playback Switch", "Mic2 Amplifier" },
346 335
347 /* Right Mixer Routes */ 336 /* Right Mixer Routes */
348 { "Right Mixer", "DAC Playback Switch", "Right DAC" }, 337 { "Right Mixer", "DAC Playback Switch", "Right DAC" },
349 { "Right Mixer", "DAC Reversed Playback Switch", "Left DAC" }, 338 { "Right Mixer", "DAC Reversed Playback Switch", "Left DAC" },
350 { "Right Mixer", "Line In Playback Switch", "LINEIN" }, 339 { "Right Mixer", "Line In Playback Switch", "LINEIN" },
351 { "Right Mixer", "Mic1 Playback Switch", "Mic1 Amplifier" }, 340 { "Right Mixer", "Mic1 Playback Switch", "Mic1 Amplifier" },
352 { "Right Mixer", "Mic2 Playback Switch", "Mic2 Amplifier" },
353 341
354 /* Left ADC Mixer Routes */ 342 /* Left ADC Mixer Routes */
355 { "Left ADC Mixer", "Mixer Capture Switch", "Left Mixer" }, 343 { "Left ADC Mixer", "Mixer Capture Switch", "Left Mixer" },
356 { "Left ADC Mixer", "Mixer Reversed Capture Switch", "Right Mixer" }, 344 { "Left ADC Mixer", "Mixer Reversed Capture Switch", "Right Mixer" },
357 { "Left ADC Mixer", "Line In Capture Switch", "LINEIN" }, 345 { "Left ADC Mixer", "Line In Capture Switch", "LINEIN" },
358 { "Left ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" }, 346 { "Left ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" },
359 { "Left ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
360 347
361 /* Right ADC Mixer Routes */ 348 /* Right ADC Mixer Routes */
362 { "Right ADC Mixer", "Mixer Capture Switch", "Right Mixer" }, 349 { "Right ADC Mixer", "Mixer Capture Switch", "Right Mixer" },
363 { "Right ADC Mixer", "Mixer Reversed Capture Switch", "Left Mixer" }, 350 { "Right ADC Mixer", "Mixer Reversed Capture Switch", "Left Mixer" },
364 { "Right ADC Mixer", "Line In Capture Switch", "LINEIN" }, 351 { "Right ADC Mixer", "Line In Capture Switch", "LINEIN" },
365 { "Right ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" }, 352 { "Right ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" },
366 { "Right ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
367 353
368 /* ADC Routes */ 354 /* ADC Routes */
369 { "Left ADC", NULL, "Left ADC Mixer" }, 355 { "Left ADC", NULL, "Left ADC Mixer" },
@@ -578,19 +564,87 @@ static int sun8i_codec_add_lineout(struct snd_soc_component *cmpnt)
578 return 0; 564 return 0;
579} 565}
580 566
567/* mic2 specific controls, widgets and routes */
568static const struct snd_kcontrol_new sun8i_codec_mic2_controls[] = {
569 /* Mixer pre-gain */
570 SOC_SINGLE_TLV("Mic2 Playback Volume",
571 SUN8I_ADDA_MICIN_GCTRL, SUN8I_ADDA_MICIN_GCTRL_MIC2G,
572 0x7, 0, sun8i_codec_out_mixer_pregain_scale),
573
574 /* Microphone Amp boost gain */
575 SOC_SINGLE_TLV("Mic2 Boost Volume", SUN8I_ADDA_MIC2G_CTRL,
576 SUN8I_ADDA_MIC2G_CTRL_MIC2BOOST, 0x7, 0,
577 sun8i_codec_mic_gain_scale),
578};
579
580static const struct snd_soc_dapm_widget sun8i_codec_mic2_widgets[] = {
581 /* Microphone input */
582 SND_SOC_DAPM_INPUT("MIC2"),
583
584 /* Mic input path */
585 SND_SOC_DAPM_PGA("Mic2 Amplifier", SUN8I_ADDA_MIC2G_CTRL,
586 SUN8I_ADDA_MIC2G_CTRL_MIC2AMPEN, 0, NULL, 0),
587};
588
589static const struct snd_soc_dapm_route sun8i_codec_mic2_routes[] = {
590 { "Mic2 Amplifier", NULL, "MIC2"},
591
592 { "Left Mixer", "Mic2 Playback Switch", "Mic2 Amplifier" },
593
594 { "Right Mixer", "Mic2 Playback Switch", "Mic2 Amplifier" },
595
596 { "Left ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
597
598 { "Right ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
599};
600
601static int sun8i_codec_add_mic2(struct snd_soc_component *cmpnt)
602{
603 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
604 struct device *dev = cmpnt->dev;
605 int ret;
606
607 ret = snd_soc_add_component_controls(cmpnt,
608 sun8i_codec_mic2_controls,
609 ARRAY_SIZE(sun8i_codec_mic2_controls));
610 if (ret) {
611 dev_err(dev, "Failed to add MIC2 controls: %d\n", ret);
612 return ret;
613 }
614
615 ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_mic2_widgets,
616 ARRAY_SIZE(sun8i_codec_mic2_widgets));
617 if (ret) {
618 dev_err(dev, "Failed to add MIC2 DAPM widgets: %d\n", ret);
619 return ret;
620 }
621
622 ret = snd_soc_dapm_add_routes(dapm, sun8i_codec_mic2_routes,
623 ARRAY_SIZE(sun8i_codec_mic2_routes));
624 if (ret) {
625 dev_err(dev, "Failed to add MIC2 DAPM routes: %d\n", ret);
626 return ret;
627 }
628
629 return 0;
630}
631
581struct sun8i_codec_analog_quirks { 632struct sun8i_codec_analog_quirks {
582 bool has_headphone; 633 bool has_headphone;
583 bool has_hmic; 634 bool has_hmic;
584 bool has_lineout; 635 bool has_lineout;
636 bool has_mic2;
585}; 637};
586 638
587static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { 639static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
588 .has_headphone = true, 640 .has_headphone = true,
589 .has_hmic = true, 641 .has_hmic = true,
642 .has_mic2 = true,
590}; 643};
591 644
592static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { 645static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
593 .has_lineout = true, 646 .has_lineout = true,
647 .has_mic2 = true,
594}; 648};
595 649
596static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt) 650static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
@@ -626,6 +680,12 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
626 return ret; 680 return ret;
627 } 681 }
628 682
683 if (quirks->has_mic2) {
684 ret = sun8i_codec_add_mic2(cmpnt);
685 if (ret)
686 return ret;
687 }
688
629 return 0; 689 return 0;
630} 690}
631 691