* [PATCH] ASoC: Route Mic Bias in Visstrim_M10 board.
@ 2012-01-09 11:01 Javier Martin
2012-01-09 19:10 ` Lars-Peter Clausen
0 siblings, 1 reply; 2+ messages in thread
From: Javier Martin @ 2012-01-09 11:01 UTC (permalink / raw)
To: alsa-devel; +Cc: broonie, lrg, Javier Martin
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 = {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: Route Mic Bias in Visstrim_M10 board.
2012-01-09 11:01 [PATCH] ASoC: Route Mic Bias in Visstrim_M10 board Javier Martin
@ 2012-01-09 19:10 ` Lars-Peter Clausen
0 siblings, 0 replies; 2+ messages in thread
From: Lars-Peter Clausen @ 2012-01-09 19:10 UTC (permalink / raw)
To: Javier Martin; +Cc: alsa-devel, broonie, lrg
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-09 19:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 11:01 [PATCH] ASoC: Route Mic Bias in Visstrim_M10 board Javier Martin
2012-01-09 19:10 ` Lars-Peter Clausen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.