[alsa-devel] [PATCH] ASoC: Route Mic Bias in Visstrim_M10 board.
Visstrim_M10 board uses an external microphone that can be enabled/disabled by the user.
Signed-off-by: Javier Martin javier.martin@vista-silicon.com --- sound/soc/imx/mx27vis-aic32x4.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/sound/soc/imx/mx27vis-aic32x4.c b/sound/soc/imx/mx27vis-aic32x4.c index 054110b..7e55a99 100644 --- a/sound/soc/imx/mx27vis-aic32x4.c +++ b/sound/soc/imx/mx27vis-aic32x4.c @@ -74,6 +74,43 @@ static struct snd_soc_ops mx27vis_aic32x4_snd_ops = { .hw_params = mx27vis_aic32x4_hw_params, };
+static const struct snd_kcontrol_new mx27vis_aic32x4_controls[] = { + SOC_DAPM_PIN_SWITCH("External Mic"), +}; + +static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { + SND_SOC_DAPM_MIC("External Mic", NULL), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + {"Mic Bias", NULL, "External Mic"}, + {"IN1_R", NULL, "Mic Bias"}, + {"IN2_R", NULL, "Mic Bias"}, + {"IN3_R", NULL, "Mic Bias"}, + {"IN1_L", NULL, "Mic Bias"}, + {"IN2_L", NULL, "Mic Bias"}, + {"IN3_L", NULL, "Mic Bias"}, +}; + +static int mx27vis_aic32x4_dai_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dapm_context *dapm = &codec->dapm; + int err = 0; + + snd_soc_dapm_new_controls(dapm, aic32x4_dapm_widgets, + ARRAY_SIZE(aic32x4_dapm_widgets)); + + err = snd_soc_add_controls(codec, mx27vis_aic32x4_controls, + ARRAY_SIZE(mx27vis_aic32x4_controls)); + if (err < 0) + return err; + + snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); + + return 0; +} + static struct snd_soc_dai_link mx27vis_aic32x4_dai = { .name = "tlv320aic32x4", .stream_name = "TLV320AIC32X4", @@ -82,6 +119,7 @@ static struct snd_soc_dai_link mx27vis_aic32x4_dai = { .codec_name = "tlv320aic32x4.0-0018", .cpu_dai_name = "imx-ssi.0", .ops = &mx27vis_aic32x4_snd_ops, + .init = mx27vis_aic32x4_dai_init, };
static struct snd_soc_card mx27vis_aic32x4 = {
On 01/09/2012 12:01 PM, Javier Martin wrote:
[...] diff --git a/sound/soc/imx/mx27vis-aic32x4.c b/sound/soc/imx/mx27vis-aic32x4.c index 054110b..7e55a99 100644 --- a/sound/soc/imx/mx27vis-aic32x4.c +++ b/sound/soc/imx/mx27vis-aic32x4.c @@ -74,6 +74,43 @@ static struct snd_soc_ops mx27vis_aic32x4_snd_ops = {
[...]
+static const struct snd_soc_dapm_route audio_map[] = {
I know this is can be found in may drivers as well, but aic32x4_dapm_routes would be a much better name.
+};
+static int mx27vis_aic32x4_dai_init(struct snd_soc_pcm_runtime *rtd) +{
- struct snd_soc_codec *codec = rtd->codec;
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- int err = 0;
- snd_soc_dapm_new_controls(dapm, aic32x4_dapm_widgets,
ARRAY_SIZE(aic32x4_dapm_widgets));
- err = snd_soc_add_controls(codec, mx27vis_aic32x4_controls,
ARRAY_SIZE(mx27vis_aic32x4_controls));
- if (err < 0)
return err;
- snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
Use the snd_soc_card's controls, dapm_widgets and dapm_routes fields to register these instead of open coding it here.
participants (2)
-
Javier Martin
-
Lars-Peter Clausen