aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-11-23 14:42:04 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-23 16:34:54 -0500
commit1633281b79fd276f1c7c2fb37c3b97da74e42ae5 (patch)
treebe8fe06be86f436efb3ddece45338e28a394ccdb /sound/soc/soc-dapm.c
parentd4a2eca781bfd7323bfd98dbc7fd63c7d613fef2 (diff)
ASoC: Implement fully_routed card property
A card is fully routed if the DAPM route table describes all connections on the board. When a card is fully routed, some operations can be automated by the ASoC core. The first, and currently only, such operation is described below, and implemented by this patch. Codecs often have a large number of external pins, and not all of these pins will be connected on all board designs. Some machine drivers therefore call snd_soc_dapm_nc_pin() for all the unused pins, in order to tell the ASoC core never to activate them. However, when a card is fully routed, the information needed to derive the set of unused pins is present in card->dapm_routes. In this case, have the ASoC core automatically call snd_soc_dapm_nc_pin() for each unused codec pin. This has been tested with soc/tegra/tegra_wm8903.c and soc/tegra/trimslice.c. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f42e8b9fb17d..1ecd1b4927f9 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2947,6 +2947,79 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
2947} 2947}
2948EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend); 2948EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
2949 2949
2950static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
2951 struct snd_soc_dapm_widget *w)
2952{
2953 struct snd_soc_dapm_path *p;
2954
2955 list_for_each_entry(p, &card->paths, list) {
2956 if ((p->source == w) || (p->sink == w)) {
2957 dev_dbg(card->dev,
2958 "... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n",
2959 p->source->name, p->source->id, p->source->dapm,
2960 p->sink->name, p->sink->id, p->sink->dapm);
2961
2962 /* Connected to something other than the codec */
2963 if (p->source->dapm != p->sink->dapm)
2964 return true;
2965 /*
2966 * Loopback connection from codec external pin to
2967 * codec external pin
2968 */
2969 if (p->sink->id == snd_soc_dapm_input) {
2970 switch (p->source->id) {
2971 case snd_soc_dapm_output:
2972 case snd_soc_dapm_micbias:
2973 return true;
2974 default:
2975 break;
2976 }
2977 }
2978 }
2979 }
2980
2981 return false;
2982}
2983
2984/**
2985 * snd_soc_dapm_auto_nc_codec_pins - call snd_soc_dapm_nc_pin for unused pins
2986 * @codec: The codec whose pins should be processed
2987 *
2988 * Automatically call snd_soc_dapm_nc_pin() for any external pins in the codec
2989 * which are unused. Pins are used if they are connected externally to the
2990 * codec, whether that be to some other device, or a loop-back connection to
2991 * the codec itself.
2992 */
2993void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec)
2994{
2995 struct snd_soc_card *card = codec->card;
2996 struct snd_soc_dapm_context *dapm = &codec->dapm;
2997 struct snd_soc_dapm_widget *w;
2998
2999 dev_dbg(card->dev, "Auto NC: DAPMs: card:%p codec:%p\n",
3000 &card->dapm, &codec->dapm);
3001
3002 list_for_each_entry(w, &card->widgets, list) {
3003 if (w->dapm != dapm)
3004 continue;
3005 switch (w->id) {
3006 case snd_soc_dapm_input:
3007 case snd_soc_dapm_output:
3008 case snd_soc_dapm_micbias:
3009 dev_dbg(card->dev, "Auto NC: Checking widget %s\n",
3010 w->name);
3011 if (!snd_soc_dapm_widget_in_card_paths(card, w)) {
3012 dev_dbg(card->dev,
3013 "... Not in map; disabling\n");
3014 snd_soc_dapm_nc_pin(dapm, w->name);
3015 }
3016 break;
3017 default:
3018 break;
3019 }
3020 }
3021}
3022
2950/** 3023/**
2951 * snd_soc_dapm_free - free dapm resources 3024 * snd_soc_dapm_free - free dapm resources
2952 * @dapm: DAPM context 3025 * @dapm: DAPM context