[alsa-devel] [PATCH 1/2] ASoC: sgtl5000: Enable VAG when DAC/ADC up
From: Zeng Zhaoming zengzm.kernel@gmail.com
As manual described, VAG is an internal voltage reference of DAC/ADC, So enabled it before DAC/ADC up.
One more thing should care about is VAG fully ramped down requires 400ms, wait it to avoid pop.
Signed-off-by: Zeng Zhaoming zengzm.kernel@gmail.com Signed-off-by: Shawn Guo shawn.guo@linaro.org --- sound/soc/codecs/sgtl5000.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 77beb6d..159e3a8 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -143,11 +143,11 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, }
/* - * using codec assist to small pop, hp_powerup or lineout_powerup - * should stay setting until vag_powerup is fully ramped down, - * vag fully ramped down require 400ms. + * As manual described, ADC/DAC only works when VAG powerup, + * So enabled VAG before ADC/DAC up. + * In power down case, we need wait 400ms when vag fully ramped down. */ -static int small_pop_event(struct snd_soc_dapm_widget *w, +static int power_vag_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { switch (event) { @@ -156,7 +156,7 @@ static int small_pop_event(struct snd_soc_dapm_widget *w, SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); break;
- case SND_SOC_DAPM_PRE_PMD: + case SND_SOC_DAPM_POST_PMD: snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, 0); msleep(400); @@ -201,12 +201,8 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = { mic_bias_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
- SND_SOC_DAPM_PGA_E("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0, - small_pop_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), - SND_SOC_DAPM_PGA_E("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0, - small_pop_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PGA("HP", SGTL5000_CHIP_ANA_POWER, 4, 0, NULL, 0), + SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0),
SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux), SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &dac_mux), @@ -221,8 +217,11 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = { 0, SGTL5000_CHIP_DIG_POWER, 1, 0),
- SND_SOC_DAPM_ADC("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0), + SND_SOC_DAPM_SUPPLY("VAG_POWER", SGTL5000_CHIP_ANA_POWER, 7, 0, + power_vag_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+ SND_SOC_DAPM_ADC("ADC", "Capture", SGTL5000_CHIP_ANA_POWER, 1, 0), SND_SOC_DAPM_DAC("DAC", "Playback", SGTL5000_CHIP_ANA_POWER, 3, 0), };
@@ -231,9 +230,11 @@ static const struct snd_soc_dapm_route sgtl5000_dapm_routes[] = { {"Capture Mux", "LINE_IN", "LINE_IN"}, /* line_in --> adc_mux */ {"Capture Mux", "MIC_IN", "MIC_IN"}, /* mic_in --> adc_mux */
+ {"ADC", NULL, "VAG_POWER"}, {"ADC", NULL, "Capture Mux"}, /* adc_mux --> adc */ {"AIFOUT", NULL, "ADC"}, /* adc --> i2s_out */
+ {"DAC", NULL, "VAG_POWER"}, {"DAC", NULL, "AIFIN"}, /* i2s-->dac,skip audio mux */ {"Headphone Mux", "DAC", "DAC"}, /* dac --> hp_mux */ {"LO", NULL, "DAC"}, /* dac --> line_out */
Add DAPM widgets and audio routing support for imx-sgtl5000 machine driver.
Signed-off-by: Shawn Guo shawn.guo@linaro.org --- .../bindings/sound/imx-audio-sgtl5000.txt | 25 ++++++++++++++++++++ sound/soc/fsl/imx-sgtl5000.c | 13 ++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt b/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt index 421a374..d09b4e3 100644 --- a/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt +++ b/Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt @@ -5,6 +5,27 @@ Required properties: - model : The user-visible name of this sound complex - ssi-controller : The phandle of the i.MX SSI controller - audio-codec : The phandle of the SGTL5000 audio codec +- audio-routing : A list of the connections between audio components. + Each entry is a pair of strings, the first being the connection's sink, + the second being the connection's source. Valid names could be power + supplies, SGTL5000 pins, and the jacks on the board: + + Power supplies: + * Mic Bias + + SGTL5000 pins: + * MIC_IN + * LINE_IN + * HP_OUT + * LINE_OUT + + Board connectors: + * Mic Jack + * Line In Jack + * Headphone Jack + * Line Out Jack + * Ext Spk + - mux-int-port : The internal port of the i.MX audio muxer (AUDMUX) - mux-ext-port : The external port of the i.MX audio muxer
@@ -19,6 +40,10 @@ sound { model = "imx51-babbage-sgtl5000"; ssi-controller = <&ssi1>; audio-codec = <&sgtl5000>; + audio-routing = + "Mic Jack", "Mic Bias", + "MIC_IN", "Mic Bias", + "Headphone Jack", "HP_OUT"; mux-int-port = <1>; mux-ext-port = <3>; }; diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index 3786b61..e1a7441 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c @@ -45,6 +45,14 @@ static int imx_sgtl5000_dai_init(struct snd_soc_pcm_runtime *rtd) return 0; }
+static const struct snd_soc_dapm_widget imx_sgtl5000_dapm_widgets[] = { + SND_SOC_DAPM_MIC("Mic Jack", NULL), + SND_SOC_DAPM_LINE("Line In Jack", NULL), + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_SPK("Line Out Jack", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), +}; + static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -129,8 +137,13 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev) ret = snd_soc_of_parse_card_name(&data->card, "model"); if (ret) return ret; + ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); + if (ret) + return ret; data->card.num_links = 1; data->card.dai_link = &data->dai; + data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; + data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets);
ret = snd_soc_register_card(&data->card); if (ret) {
On Fri, Mar 30, 2012 at 12:13:03AM +0800, Shawn Guo wrote:
Add DAPM widgets and audio routing support for imx-sgtl5000 machine driver.
Signed-off-by: Shawn Guo shawn.guo@linaro.org
Applied, thanks. Good to see that the code Stephen provided is working for you guys too.
On Fri, Mar 30, 2012 at 12:13:02AM +0800, Shawn Guo wrote:
From: Zeng Zhaoming zengzm.kernel@gmail.com
As manual described, VAG is an internal voltage reference of DAC/ADC, So enabled it before DAC/ADC up.
Applied, thanks. I applied it for 3.4 since it's basically a bug fix, please check that the patch got applied correctly.
On 30 March 2012 05:32, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Fri, Mar 30, 2012 at 12:13:02AM +0800, Shawn Guo wrote:
From: Zeng Zhaoming zengzm.kernel@gmail.com
As manual described, VAG is an internal voltage reference of DAC/ADC, So enabled it before DAC/ADC up.
Applied, thanks. I applied it for 3.4 since it's basically a bug fix, please check that the patch got applied correctly.
Yes, it looks correct to me.
Regards, Shawn
participants (2)
-
Mark Brown
-
Shawn Guo