2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 * o Changes power status of internal codec blocks depending on the
14 * dynamic configuration of codec internal audio paths and active
16 * o Platform power domain - can support external components i.e. amps and
17 * mic/meadphone insertion events.
18 * o Automatic Mic Bias support
19 * o Jack insertion power event initiation - e.g. hp insertion will enable
21 * o Delayed powerdown of audio susbsystem to reduce pops between a quick
25 * o DAPM power change sequencing - allow for configurable per
27 * o Support for analogue bias optimisation.
28 * o Support for reduced codec oversampling rates.
29 * o Support for reduced codec bias currents.
32 #include <linux/module.h>
33 #include <linux/moduleparam.h>
34 #include <linux/init.h>
35 #include <linux/async.h>
36 #include <linux/delay.h>
38 #include <linux/bitops.h>
39 #include <linux/platform_device.h>
40 #include <linux/jiffies.h>
41 #include <linux/debugfs.h>
42 #include <linux/slab.h>
43 #include <sound/core.h>
44 #include <sound/pcm.h>
45 #include <sound/pcm_params.h>
46 #include <sound/soc.h>
47 #include <sound/initval.h>
49 #include <trace/events/asoc.h>
51 /* dapm power sequences - make this per codec in the future */
52 static int dapm_up_seq[] = {
53 [snd_soc_dapm_pre] = 0,
54 [snd_soc_dapm_supply] = 1,
55 [snd_soc_dapm_micbias] = 2,
56 [snd_soc_dapm_aif_in] = 3,
57 [snd_soc_dapm_aif_out] = 3,
58 [snd_soc_dapm_mic] = 4,
59 [snd_soc_dapm_mux] = 5,
60 [snd_soc_dapm_virt_mux] = 5,
61 [snd_soc_dapm_value_mux] = 5,
62 [snd_soc_dapm_dac] = 6,
63 [snd_soc_dapm_mixer] = 7,
64 [snd_soc_dapm_mixer_named_ctl] = 7,
65 [snd_soc_dapm_pga] = 8,
66 [snd_soc_dapm_adc] = 9,
67 [snd_soc_dapm_out_drv] = 10,
68 [snd_soc_dapm_hp] = 10,
69 [snd_soc_dapm_spk] = 10,
70 [snd_soc_dapm_post] = 11,
73 static int dapm_down_seq[] = {
74 [snd_soc_dapm_pre] = 0,
75 [snd_soc_dapm_adc] = 1,
76 [snd_soc_dapm_hp] = 2,
77 [snd_soc_dapm_spk] = 2,
78 [snd_soc_dapm_out_drv] = 2,
79 [snd_soc_dapm_pga] = 4,
80 [snd_soc_dapm_mixer_named_ctl] = 5,
81 [snd_soc_dapm_mixer] = 5,
82 [snd_soc_dapm_dac] = 6,
83 [snd_soc_dapm_mic] = 7,
84 [snd_soc_dapm_micbias] = 8,
85 [snd_soc_dapm_mux] = 9,
86 [snd_soc_dapm_virt_mux] = 9,
87 [snd_soc_dapm_value_mux] = 9,
88 [snd_soc_dapm_aif_in] = 10,
89 [snd_soc_dapm_aif_out] = 10,
90 [snd_soc_dapm_supply] = 11,
91 [snd_soc_dapm_post] = 12,
94 static void pop_wait(u32 pop_time)
97 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
100 static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
108 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
113 vsnprintf(buf, PAGE_SIZE, fmt, args);
114 dev_info(dev, "%s", buf);
120 /* create a new dapm widget */
121 static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
122 const struct snd_soc_dapm_widget *_widget)
124 return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
128 * snd_soc_dapm_set_bias_level - set the bias level for the system
129 * @dapm: DAPM context
130 * @level: level to configure
132 * Configure the bias (power) levels for the SoC audio device.
134 * Returns 0 for success else error.
136 static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
137 enum snd_soc_bias_level level)
139 struct snd_soc_card *card = dapm->card;
142 trace_snd_soc_bias_level_start(card, level);
144 if (card && card->set_bias_level)
145 ret = card->set_bias_level(card, level);
147 if (dapm->codec && dapm->codec->driver->set_bias_level)
148 ret = dapm->codec->driver->set_bias_level(dapm->codec, level);
150 dapm->bias_level = level;
153 if (card && card->set_bias_level_post)
154 ret = card->set_bias_level_post(card, level);
157 trace_snd_soc_bias_level_done(card, level);
162 /* set up initial codec paths */
163 static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
164 struct snd_soc_dapm_path *p, int i)
167 case snd_soc_dapm_switch:
168 case snd_soc_dapm_mixer:
169 case snd_soc_dapm_mixer_named_ctl: {
171 struct soc_mixer_control *mc = (struct soc_mixer_control *)
172 w->kcontrol_news[i].private_value;
173 unsigned int reg = mc->reg;
174 unsigned int shift = mc->shift;
176 unsigned int mask = (1 << fls(max)) - 1;
177 unsigned int invert = mc->invert;
179 val = snd_soc_read(w->codec, reg);
180 val = (val >> shift) & mask;
182 if ((invert && !val) || (!invert && val))
188 case snd_soc_dapm_mux: {
189 struct soc_enum *e = (struct soc_enum *)
190 w->kcontrol_news[i].private_value;
191 int val, item, bitmask;
193 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
195 val = snd_soc_read(w->codec, e->reg);
196 item = (val >> e->shift_l) & (bitmask - 1);
199 for (i = 0; i < e->max; i++) {
200 if (!(strcmp(p->name, e->texts[i])) && item == i)
205 case snd_soc_dapm_virt_mux: {
206 struct soc_enum *e = (struct soc_enum *)
207 w->kcontrol_news[i].private_value;
210 /* since a virtual mux has no backing registers to
211 * decide which path to connect, it will try to match
212 * with the first enumeration. This is to ensure
213 * that the default mux choice (the first) will be
214 * correctly powered up during initialization.
216 if (!strcmp(p->name, e->texts[0]))
220 case snd_soc_dapm_value_mux: {
221 struct soc_enum *e = (struct soc_enum *)
222 w->kcontrol_news[i].private_value;
225 val = snd_soc_read(w->codec, e->reg);
226 val = (val >> e->shift_l) & e->mask;
227 for (item = 0; item < e->max; item++) {
228 if (val == e->values[item])
233 for (i = 0; i < e->max; i++) {
234 if (!(strcmp(p->name, e->texts[i])) && item == i)
239 /* does not effect routing - always connected */
240 case snd_soc_dapm_pga:
241 case snd_soc_dapm_out_drv:
242 case snd_soc_dapm_output:
243 case snd_soc_dapm_adc:
244 case snd_soc_dapm_input:
245 case snd_soc_dapm_dac:
246 case snd_soc_dapm_micbias:
247 case snd_soc_dapm_vmid:
248 case snd_soc_dapm_supply:
249 case snd_soc_dapm_aif_in:
250 case snd_soc_dapm_aif_out:
253 /* does effect routing - dynamically connected */
254 case snd_soc_dapm_hp:
255 case snd_soc_dapm_mic:
256 case snd_soc_dapm_spk:
257 case snd_soc_dapm_line:
258 case snd_soc_dapm_pre:
259 case snd_soc_dapm_post:
265 /* connect mux widget to its interconnecting audio paths */
266 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
267 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
268 struct snd_soc_dapm_path *path, const char *control_name,
269 const struct snd_kcontrol_new *kcontrol)
271 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
274 for (i = 0; i < e->max; i++) {
275 if (!(strcmp(control_name, e->texts[i]))) {
276 list_add(&path->list, &dapm->card->paths);
277 list_add(&path->list_sink, &dest->sources);
278 list_add(&path->list_source, &src->sinks);
279 path->name = (char*)e->texts[i];
280 dapm_set_path_status(dest, path, 0);
288 /* connect mixer widget to its interconnecting audio paths */
289 static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
290 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
291 struct snd_soc_dapm_path *path, const char *control_name)
295 /* search for mixer kcontrol */
296 for (i = 0; i < dest->num_kcontrols; i++) {
297 if (!strcmp(control_name, dest->kcontrol_news[i].name)) {
298 list_add(&path->list, &dapm->card->paths);
299 list_add(&path->list_sink, &dest->sources);
300 list_add(&path->list_source, &src->sinks);
301 path->name = dest->kcontrol_news[i].name;
302 dapm_set_path_status(dest, path, i);
309 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm,
310 struct snd_soc_dapm_widget *kcontrolw,
311 const struct snd_kcontrol_new *kcontrol_new,
312 struct snd_kcontrol **kcontrol)
314 struct snd_soc_dapm_widget *w;
319 list_for_each_entry(w, &dapm->card->widgets, list) {
320 if (w == kcontrolw || w->dapm != kcontrolw->dapm)
322 for (i = 0; i < w->num_kcontrols; i++) {
323 if (&w->kcontrol_news[i] == kcontrol_new) {
325 *kcontrol = w->kcontrols[i];
334 /* create new dapm mixer control */
335 static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
336 struct snd_soc_dapm_widget *w)
339 size_t name_len, prefix_len;
340 struct snd_soc_dapm_path *path;
341 struct snd_card *card = dapm->card->snd_card;
343 struct snd_soc_dapm_widget_list *wlist;
347 prefix = dapm->codec->name_prefix;
352 prefix_len = strlen(prefix) + 1;
357 for (i = 0; i < w->num_kcontrols; i++) {
360 list_for_each_entry(path, &w->sources, list_sink) {
362 /* mixer/mux paths name must match control name */
363 if (path->name != (char *)w->kcontrol_news[i].name)
366 wlistsize = sizeof(struct snd_soc_dapm_widget_list) +
367 sizeof(struct snd_soc_dapm_widget *),
368 wlist = kzalloc(wlistsize, GFP_KERNEL);
371 "asoc: can't allocate widget list for %s\n",
375 wlist->num_widgets = 1;
376 wlist->widgets[0] = w;
378 /* add dapm control with long name.
379 * for dapm_mixer this is the concatenation of the
380 * mixer and kcontrol name.
381 * for dapm_mixer_named_ctl this is simply the
384 name_len = strlen(w->kcontrol_news[i].name) + 1;
385 if (w->id != snd_soc_dapm_mixer_named_ctl)
386 name_len += 1 + strlen(w->name);
388 path->long_name = kmalloc(name_len, GFP_KERNEL);
390 if (path->long_name == NULL) {
397 /* The control will get a prefix from
398 * the control creation process but
399 * we're also using the same prefix
400 * for widgets so cut the prefix off
401 * the front of the widget name.
403 snprintf(path->long_name, name_len, "%s %s",
404 w->name + prefix_len,
405 w->kcontrol_news[i].name);
407 case snd_soc_dapm_mixer_named_ctl:
408 snprintf(path->long_name, name_len, "%s",
409 w->kcontrol_news[i].name);
413 path->long_name[name_len - 1] = '\0';
415 path->kcontrol = snd_soc_cnew(&w->kcontrol_news[i],
416 wlist, path->long_name,
418 ret = snd_ctl_add(card, path->kcontrol);
421 "asoc: failed to add dapm kcontrol %s: %d\n",
422 path->long_name, ret);
424 kfree(path->long_name);
425 path->long_name = NULL;
428 w->kcontrols[i] = path->kcontrol;
434 /* create new dapm mux control */
435 static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
436 struct snd_soc_dapm_widget *w)
438 struct snd_soc_dapm_path *path = NULL;
439 struct snd_kcontrol *kcontrol;
440 struct snd_card *card = dapm->card->snd_card;
444 struct snd_soc_dapm_widget_list *wlist;
445 int shared, wlistentries;
449 if (w->num_kcontrols != 1) {
451 "asoc: mux %s has incorrect number of controls\n",
456 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[0],
459 wlist = kcontrol->private_data;
460 wlistentries = wlist->num_widgets + 1;
465 wlistsize = sizeof(struct snd_soc_dapm_widget_list) +
466 wlistentries * sizeof(struct snd_soc_dapm_widget *),
467 wlist = krealloc(wlist, wlistsize, GFP_KERNEL);
470 "asoc: can't allocate widget list for %s\n", w->name);
473 wlist->num_widgets = wlistentries;
474 wlist->widgets[wlistentries - 1] = w;
478 prefix = dapm->codec->name_prefix;
483 name = w->kcontrol_news[0].name;
488 prefix_len = strlen(prefix) + 1;
494 * The control will get a prefix from the control creation
495 * process but we're also using the same prefix for widgets so
496 * cut the prefix off the front of the widget name.
498 kcontrol = snd_soc_cnew(&w->kcontrol_news[0], wlist,
499 name + prefix_len, prefix);
500 ret = snd_ctl_add(card, kcontrol);
503 "asoc: failed to add kcontrol %s\n", w->name);
509 kcontrol->private_data = wlist;
511 w->kcontrols[0] = kcontrol;
513 list_for_each_entry(path, &w->sources, list_sink)
514 path->kcontrol = kcontrol;
519 /* create new dapm volume control */
520 static int dapm_new_pga(struct snd_soc_dapm_context *dapm,
521 struct snd_soc_dapm_widget *w)
523 if (w->num_kcontrols)
524 dev_err(w->dapm->dev,
525 "asoc: PGA controls not supported: '%s'\n", w->name);
530 /* reset 'walked' bit for each dapm path */
531 static inline void dapm_clear_walk(struct snd_soc_dapm_context *dapm)
533 struct snd_soc_dapm_path *p;
535 list_for_each_entry(p, &dapm->card->paths, list)
539 /* We implement power down on suspend by checking the power state of
540 * the ALSA card - when we are suspending the ALSA state for the card
543 static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
545 int level = snd_power_get_state(widget->dapm->card->snd_card);
548 case SNDRV_CTL_POWER_D3hot:
549 case SNDRV_CTL_POWER_D3cold:
550 if (widget->ignore_suspend)
551 dev_dbg(widget->dapm->dev, "%s ignoring suspend\n",
553 return widget->ignore_suspend;
560 * Recursively check for a completed path to an active or physically connected
561 * output widget. Returns number of complete paths.
563 static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
565 struct snd_soc_dapm_path *path;
568 if (widget->id == snd_soc_dapm_supply)
571 switch (widget->id) {
572 case snd_soc_dapm_adc:
573 case snd_soc_dapm_aif_out:
575 return snd_soc_dapm_suspend_check(widget);
580 if (widget->connected) {
581 /* connected pin ? */
582 if (widget->id == snd_soc_dapm_output && !widget->ext)
583 return snd_soc_dapm_suspend_check(widget);
585 /* connected jack or spk ? */
586 if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
587 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sources)))
588 return snd_soc_dapm_suspend_check(widget);
591 list_for_each_entry(path, &widget->sinks, list_source) {
595 if (path->sink && path->connect) {
597 con += is_connected_output_ep(path->sink);
605 * Recursively check for a completed path to an active or physically connected
606 * input widget. Returns number of complete paths.
608 static int is_connected_input_ep(struct snd_soc_dapm_widget *widget)
610 struct snd_soc_dapm_path *path;
613 if (widget->id == snd_soc_dapm_supply)
616 /* active stream ? */
617 switch (widget->id) {
618 case snd_soc_dapm_dac:
619 case snd_soc_dapm_aif_in:
621 return snd_soc_dapm_suspend_check(widget);
626 if (widget->connected) {
627 /* connected pin ? */
628 if (widget->id == snd_soc_dapm_input && !widget->ext)
629 return snd_soc_dapm_suspend_check(widget);
631 /* connected VMID/Bias for lower pops */
632 if (widget->id == snd_soc_dapm_vmid)
633 return snd_soc_dapm_suspend_check(widget);
635 /* connected jack ? */
636 if (widget->id == snd_soc_dapm_mic ||
637 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sinks)))
638 return snd_soc_dapm_suspend_check(widget);
641 list_for_each_entry(path, &widget->sources, list_sink) {
645 if (path->source && path->connect) {
647 con += is_connected_input_ep(path->source);
655 * Handler for generic register modifier widget.
657 int dapm_reg_event(struct snd_soc_dapm_widget *w,
658 struct snd_kcontrol *kcontrol, int event)
662 if (SND_SOC_DAPM_EVENT_ON(event))
667 snd_soc_update_bits(w->codec, -(w->reg + 1),
668 w->mask << w->shift, val << w->shift);
672 EXPORT_SYMBOL_GPL(dapm_reg_event);
674 /* Generic check to see if a widget should be powered.
676 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w)
680 in = is_connected_input_ep(w);
681 dapm_clear_walk(w->dapm);
682 out = is_connected_output_ep(w);
683 dapm_clear_walk(w->dapm);
684 return out != 0 && in != 0;
687 /* Check to see if an ADC has power */
688 static int dapm_adc_check_power(struct snd_soc_dapm_widget *w)
693 in = is_connected_input_ep(w);
694 dapm_clear_walk(w->dapm);
697 return dapm_generic_check_power(w);
701 /* Check to see if a DAC has power */
702 static int dapm_dac_check_power(struct snd_soc_dapm_widget *w)
707 out = is_connected_output_ep(w);
708 dapm_clear_walk(w->dapm);
711 return dapm_generic_check_power(w);
715 /* Check to see if a power supply is needed */
716 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
718 struct snd_soc_dapm_path *path;
721 /* Check if one of our outputs is connected */
722 list_for_each_entry(path, &w->sinks, list_source) {
723 if (path->connected &&
724 !path->connected(path->source, path->sink))
730 if (path->sink->force) {
735 if (path->sink->power_check &&
736 path->sink->power_check(path->sink)) {
742 dapm_clear_walk(w->dapm);
747 static int dapm_seq_compare(struct snd_soc_dapm_widget *a,
748 struct snd_soc_dapm_widget *b,
756 sort = dapm_down_seq;
758 if (sort[a->id] != sort[b->id])
759 return sort[a->id] - sort[b->id];
760 if (a->subseq != b->subseq) {
762 return a->subseq - b->subseq;
764 return b->subseq - a->subseq;
766 if (a->reg != b->reg)
767 return a->reg - b->reg;
768 if (a->dapm != b->dapm)
769 return (unsigned long)a->dapm - (unsigned long)b->dapm;
774 /* Insert a widget in order into a DAPM power sequence. */
775 static void dapm_seq_insert(struct snd_soc_dapm_widget *new_widget,
776 struct list_head *list,
779 struct snd_soc_dapm_widget *w;
781 list_for_each_entry(w, list, power_list)
782 if (dapm_seq_compare(new_widget, w, power_up) < 0) {
783 list_add_tail(&new_widget->power_list, &w->power_list);
787 list_add_tail(&new_widget->power_list, list);
790 static void dapm_seq_check_event(struct snd_soc_dapm_context *dapm,
791 struct snd_soc_dapm_widget *w, int event)
793 struct snd_soc_card *card = dapm->card;
798 case SND_SOC_DAPM_PRE_PMU:
802 case SND_SOC_DAPM_POST_PMU:
803 ev_name = "POST_PMU";
806 case SND_SOC_DAPM_PRE_PMD:
810 case SND_SOC_DAPM_POST_PMD:
811 ev_name = "POST_PMD";
819 if (w->power != power)
822 if (w->event && (w->event_flags & event)) {
823 pop_dbg(dapm->dev, card->pop_time, "pop test : %s %s\n",
825 trace_snd_soc_dapm_widget_event_start(w, event);
826 ret = w->event(w, NULL, event);
827 trace_snd_soc_dapm_widget_event_done(w, event);
829 pr_err("%s: %s event failed: %d\n",
830 ev_name, w->name, ret);
834 /* Apply the coalesced changes from a DAPM sequence */
835 static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
836 struct list_head *pending)
838 struct snd_soc_card *card = dapm->card;
839 struct snd_soc_dapm_widget *w;
841 unsigned int value = 0;
842 unsigned int mask = 0;
843 unsigned int cur_mask;
845 reg = list_first_entry(pending, struct snd_soc_dapm_widget,
848 list_for_each_entry(w, pending, power_list) {
849 cur_mask = 1 << w->shift;
850 BUG_ON(reg != w->reg);
861 pop_dbg(dapm->dev, card->pop_time,
862 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
863 w->name, reg, value, mask);
865 /* Check for events */
866 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMU);
867 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMD);
871 pop_dbg(dapm->dev, card->pop_time,
872 "pop test : Applying 0x%x/0x%x to %x in %dms\n",
873 value, mask, reg, card->pop_time);
874 pop_wait(card->pop_time);
875 snd_soc_update_bits(dapm->codec, reg, mask, value);
878 list_for_each_entry(w, pending, power_list) {
879 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMU);
880 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMD);
884 /* Apply a DAPM power sequence.
886 * We walk over a pre-sorted list of widgets to apply power to. In
887 * order to minimise the number of writes to the device required
888 * multiple widgets will be updated in a single write where possible.
889 * Currently anything that requires more than a single write is not
892 static void dapm_seq_run(struct snd_soc_dapm_context *dapm,
893 struct list_head *list, int event, bool power_up)
895 struct snd_soc_dapm_widget *w, *n;
899 int cur_reg = SND_SOC_NOPM;
900 struct snd_soc_dapm_context *cur_dapm = NULL;
907 sort = dapm_down_seq;
909 list_for_each_entry_safe(w, n, list, power_list) {
912 /* Do we need to apply any queued changes? */
913 if (sort[w->id] != cur_sort || w->reg != cur_reg ||
914 w->dapm != cur_dapm || w->subseq != cur_subseq) {
915 if (!list_empty(&pending))
916 dapm_seq_run_coalesced(cur_dapm, &pending);
918 if (cur_dapm && cur_dapm->seq_notifier) {
919 for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
920 if (sort[i] == cur_sort)
921 cur_dapm->seq_notifier(cur_dapm,
926 INIT_LIST_HEAD(&pending);
929 cur_reg = SND_SOC_NOPM;
934 case snd_soc_dapm_pre:
936 list_for_each_entry_safe_continue(w, n, list,
939 if (event == SND_SOC_DAPM_STREAM_START)
941 NULL, SND_SOC_DAPM_PRE_PMU);
942 else if (event == SND_SOC_DAPM_STREAM_STOP)
944 NULL, SND_SOC_DAPM_PRE_PMD);
947 case snd_soc_dapm_post:
949 list_for_each_entry_safe_continue(w, n, list,
952 if (event == SND_SOC_DAPM_STREAM_START)
954 NULL, SND_SOC_DAPM_POST_PMU);
955 else if (event == SND_SOC_DAPM_STREAM_STOP)
957 NULL, SND_SOC_DAPM_POST_PMD);
961 /* Queue it up for application */
962 cur_sort = sort[w->id];
963 cur_subseq = w->subseq;
966 list_move(&w->power_list, &pending);
971 dev_err(w->dapm->dev,
972 "Failed to apply widget power: %d\n", ret);
975 if (!list_empty(&pending))
976 dapm_seq_run_coalesced(cur_dapm, &pending);
978 if (cur_dapm && cur_dapm->seq_notifier) {
979 for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
980 if (sort[i] == cur_sort)
981 cur_dapm->seq_notifier(cur_dapm,
986 static void dapm_widget_update(struct snd_soc_dapm_context *dapm)
988 struct snd_soc_dapm_update *update = dapm->update;
989 struct snd_soc_dapm_widget *w;
998 (w->event_flags & SND_SOC_DAPM_PRE_REG)) {
999 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG);
1001 pr_err("%s DAPM pre-event failed: %d\n",
1005 ret = snd_soc_update_bits(w->codec, update->reg, update->mask,
1008 pr_err("%s DAPM update failed: %d\n", w->name, ret);
1011 (w->event_flags & SND_SOC_DAPM_POST_REG)) {
1012 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG);
1014 pr_err("%s DAPM post-event failed: %d\n",
1019 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1020 * they're changing state.
1022 static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
1024 struct snd_soc_dapm_context *d = data;
1027 /* If we're off and we're not supposed to be go into STANDBY */
1028 if (d->bias_level == SND_SOC_BIAS_OFF &&
1029 d->target_bias_level != SND_SOC_BIAS_OFF) {
1030 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
1033 "Failed to turn on bias: %d\n", ret);
1036 /* Prepare for a STADDBY->ON or ON->STANDBY transition */
1037 if (d->bias_level != d->target_bias_level) {
1038 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE);
1041 "Failed to prepare bias: %d\n", ret);
1045 /* Async callback run prior to DAPM sequences - brings to their final
1048 static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
1050 struct snd_soc_dapm_context *d = data;
1053 /* If we just powered the last thing off drop to standby bias */
1054 if (d->bias_level == SND_SOC_BIAS_PREPARE &&
1055 (d->target_bias_level == SND_SOC_BIAS_STANDBY ||
1056 d->target_bias_level == SND_SOC_BIAS_OFF)) {
1057 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
1059 dev_err(d->dev, "Failed to apply standby bias: %d\n",
1063 /* If we're in standby and can support bias off then do that */
1064 if (d->bias_level == SND_SOC_BIAS_STANDBY &&
1065 d->target_bias_level == SND_SOC_BIAS_OFF) {
1066 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_OFF);
1068 dev_err(d->dev, "Failed to turn off bias: %d\n", ret);
1071 /* If we just powered up then move to active bias */
1072 if (d->bias_level == SND_SOC_BIAS_PREPARE &&
1073 d->target_bias_level == SND_SOC_BIAS_ON) {
1074 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_ON);
1076 dev_err(d->dev, "Failed to apply active bias: %d\n",
1082 * Scan each dapm widget for complete audio path.
1083 * A complete path is a route that has valid endpoints i.e.:-
1085 * o DAC to output pin.
1086 * o Input Pin to ADC.
1087 * o Input pin to Output pin (bypass, sidetone)
1088 * o DAC to ADC (loopback).
1090 static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
1092 struct snd_soc_card *card = dapm->card;
1093 struct snd_soc_dapm_widget *w;
1094 struct snd_soc_dapm_context *d;
1096 LIST_HEAD(down_list);
1097 LIST_HEAD(async_domain);
1098 enum snd_soc_bias_level bias;
1101 trace_snd_soc_dapm_start(card);
1103 list_for_each_entry(d, &card->dapm_list, list) {
1104 if (d->n_widgets || d->codec == NULL) {
1105 if (d->idle_bias_off)
1106 d->target_bias_level = SND_SOC_BIAS_OFF;
1108 d->target_bias_level = SND_SOC_BIAS_STANDBY;
1112 /* Check which widgets we need to power and store them in
1113 * lists indicating if they should be powered up or down.
1115 list_for_each_entry(w, &card->widgets, list) {
1117 case snd_soc_dapm_pre:
1118 dapm_seq_insert(w, &down_list, false);
1120 case snd_soc_dapm_post:
1121 dapm_seq_insert(w, &up_list, true);
1125 if (!w->power_check)
1129 power = w->power_check(w);
1136 /* Supplies and micbiases only bring
1137 * the context up to STANDBY as unless
1138 * something else is active and
1139 * passing audio they generally don't
1140 * require full power.
1143 case snd_soc_dapm_supply:
1144 case snd_soc_dapm_micbias:
1145 if (d->target_bias_level < SND_SOC_BIAS_STANDBY)
1146 d->target_bias_level = SND_SOC_BIAS_STANDBY;
1149 d->target_bias_level = SND_SOC_BIAS_ON;
1154 if (w->power == power)
1157 trace_snd_soc_dapm_widget_power(w, power);
1160 dapm_seq_insert(w, &up_list, true);
1162 dapm_seq_insert(w, &down_list, false);
1169 /* If there are no DAPM widgets then try to figure out power from the
1172 if (!dapm->n_widgets) {
1174 case SND_SOC_DAPM_STREAM_START:
1175 case SND_SOC_DAPM_STREAM_RESUME:
1176 dapm->target_bias_level = SND_SOC_BIAS_ON;
1178 case SND_SOC_DAPM_STREAM_STOP:
1179 if (dapm->codec->active)
1180 dapm->target_bias_level = SND_SOC_BIAS_ON;
1182 dapm->target_bias_level = SND_SOC_BIAS_STANDBY;
1184 case SND_SOC_DAPM_STREAM_SUSPEND:
1185 dapm->target_bias_level = SND_SOC_BIAS_STANDBY;
1187 case SND_SOC_DAPM_STREAM_NOP:
1188 dapm->target_bias_level = dapm->bias_level;
1195 /* Force all contexts in the card to the same bias state */
1196 bias = SND_SOC_BIAS_OFF;
1197 list_for_each_entry(d, &card->dapm_list, list)
1198 if (d->target_bias_level > bias)
1199 bias = d->target_bias_level;
1200 list_for_each_entry(d, &card->dapm_list, list)
1201 d->target_bias_level = bias;
1204 /* Run all the bias changes in parallel */
1205 list_for_each_entry(d, &dapm->card->dapm_list, list)
1206 async_schedule_domain(dapm_pre_sequence_async, d,
1208 async_synchronize_full_domain(&async_domain);
1210 /* Power down widgets first; try to avoid amplifying pops. */
1211 dapm_seq_run(dapm, &down_list, event, false);
1213 dapm_widget_update(dapm);
1216 dapm_seq_run(dapm, &up_list, event, true);
1218 /* Run all the bias changes in parallel */
1219 list_for_each_entry(d, &dapm->card->dapm_list, list)
1220 async_schedule_domain(dapm_post_sequence_async, d,
1222 async_synchronize_full_domain(&async_domain);
1224 pop_dbg(dapm->dev, card->pop_time,
1225 "DAPM sequencing finished, waiting %dms\n", card->pop_time);
1226 pop_wait(card->pop_time);
1228 trace_snd_soc_dapm_done(card);
1233 #ifdef CONFIG_DEBUG_FS
1234 static int dapm_widget_power_open_file(struct inode *inode, struct file *file)
1236 file->private_data = inode->i_private;
1240 static ssize_t dapm_widget_power_read_file(struct file *file,
1241 char __user *user_buf,
1242 size_t count, loff_t *ppos)
1244 struct snd_soc_dapm_widget *w = file->private_data;
1248 struct snd_soc_dapm_path *p = NULL;
1250 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
1254 in = is_connected_input_ep(w);
1255 dapm_clear_walk(w->dapm);
1256 out = is_connected_output_ep(w);
1257 dapm_clear_walk(w->dapm);
1259 ret = snprintf(buf, PAGE_SIZE, "%s: %s in %d out %d",
1260 w->name, w->power ? "On" : "Off", in, out);
1263 ret += snprintf(buf + ret, PAGE_SIZE - ret,
1264 " - R%d(0x%x) bit %d",
1265 w->reg, w->reg, w->shift);
1267 ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
1270 ret += snprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n",
1272 w->active ? "active" : "inactive");
1274 list_for_each_entry(p, &w->sources, list_sink) {
1275 if (p->connected && !p->connected(w, p->sink))
1279 ret += snprintf(buf + ret, PAGE_SIZE - ret,
1280 " in \"%s\" \"%s\"\n",
1281 p->name ? p->name : "static",
1284 list_for_each_entry(p, &w->sinks, list_source) {
1285 if (p->connected && !p->connected(w, p->sink))
1289 ret += snprintf(buf + ret, PAGE_SIZE - ret,
1290 " out \"%s\" \"%s\"\n",
1291 p->name ? p->name : "static",
1295 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
1301 static const struct file_operations dapm_widget_power_fops = {
1302 .open = dapm_widget_power_open_file,
1303 .read = dapm_widget_power_read_file,
1304 .llseek = default_llseek,
1307 static int dapm_bias_open_file(struct inode *inode, struct file *file)
1309 file->private_data = inode->i_private;
1313 static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf,
1314 size_t count, loff_t *ppos)
1316 struct snd_soc_dapm_context *dapm = file->private_data;
1319 switch (dapm->bias_level) {
1320 case SND_SOC_BIAS_ON:
1323 case SND_SOC_BIAS_PREPARE:
1324 level = "Prepare\n";
1326 case SND_SOC_BIAS_STANDBY:
1327 level = "Standby\n";
1329 case SND_SOC_BIAS_OFF:
1334 level = "Unknown\n";
1338 return simple_read_from_buffer(user_buf, count, ppos, level,
1342 static const struct file_operations dapm_bias_fops = {
1343 .open = dapm_bias_open_file,
1344 .read = dapm_bias_read_file,
1345 .llseek = default_llseek,
1348 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
1349 struct dentry *parent)
1353 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent);
1355 if (!dapm->debugfs_dapm) {
1357 "Failed to create DAPM debugfs directory\n");
1361 d = debugfs_create_file("bias_level", 0444,
1362 dapm->debugfs_dapm, dapm,
1366 "ASoC: Failed to create bias level debugfs file\n");
1369 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
1371 struct snd_soc_dapm_context *dapm = w->dapm;
1374 if (!dapm->debugfs_dapm || !w->name)
1377 d = debugfs_create_file(w->name, 0444,
1378 dapm->debugfs_dapm, w,
1379 &dapm_widget_power_fops);
1381 dev_warn(w->dapm->dev,
1382 "ASoC: Failed to create %s debugfs file\n",
1386 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
1388 debugfs_remove_recursive(dapm->debugfs_dapm);
1392 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
1393 struct dentry *parent)
1397 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
1401 static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
1407 /* test and update the power status of a mux widget */
1408 static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
1409 struct snd_kcontrol *kcontrol, int change,
1410 int mux, struct soc_enum *e)
1412 struct snd_soc_dapm_path *path;
1415 if (widget->id != snd_soc_dapm_mux &&
1416 widget->id != snd_soc_dapm_virt_mux &&
1417 widget->id != snd_soc_dapm_value_mux)
1423 /* find dapm widget path assoc with kcontrol */
1424 list_for_each_entry(path, &widget->dapm->card->paths, list) {
1425 if (path->kcontrol != kcontrol)
1428 if (!path->name || !e->texts[mux])
1432 /* we now need to match the string in the enum to the path */
1433 if (!(strcmp(path->name, e->texts[mux])))
1434 path->connect = 1; /* new connection */
1436 path->connect = 0; /* old connection must be powered down */
1440 dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP);
1445 /* test and update the power status of a mixer or switch widget */
1446 static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
1447 struct snd_kcontrol *kcontrol, int connect)
1449 struct snd_soc_dapm_path *path;
1452 if (widget->id != snd_soc_dapm_mixer &&
1453 widget->id != snd_soc_dapm_mixer_named_ctl &&
1454 widget->id != snd_soc_dapm_switch)
1457 /* find dapm widget path assoc with kcontrol */
1458 list_for_each_entry(path, &widget->dapm->card->paths, list) {
1459 if (path->kcontrol != kcontrol)
1462 /* found, now check type */
1464 path->connect = connect;
1469 dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP);
1474 /* show dapm widget status in sys fs */
1475 static ssize_t dapm_widget_show(struct device *dev,
1476 struct device_attribute *attr, char *buf)
1478 struct snd_soc_pcm_runtime *rtd =
1479 container_of(dev, struct snd_soc_pcm_runtime, dev);
1480 struct snd_soc_codec *codec =rtd->codec;
1481 struct snd_soc_dapm_widget *w;
1483 char *state = "not set";
1485 list_for_each_entry(w, &codec->card->widgets, list) {
1486 if (w->dapm != &codec->dapm)
1489 /* only display widgets that burnm power */
1491 case snd_soc_dapm_hp:
1492 case snd_soc_dapm_mic:
1493 case snd_soc_dapm_spk:
1494 case snd_soc_dapm_line:
1495 case snd_soc_dapm_micbias:
1496 case snd_soc_dapm_dac:
1497 case snd_soc_dapm_adc:
1498 case snd_soc_dapm_pga:
1499 case snd_soc_dapm_out_drv:
1500 case snd_soc_dapm_mixer:
1501 case snd_soc_dapm_mixer_named_ctl:
1502 case snd_soc_dapm_supply:
1504 count += sprintf(buf + count, "%s: %s\n",
1505 w->name, w->power ? "On":"Off");
1512 switch (codec->dapm.bias_level) {
1513 case SND_SOC_BIAS_ON:
1516 case SND_SOC_BIAS_PREPARE:
1519 case SND_SOC_BIAS_STANDBY:
1522 case SND_SOC_BIAS_OFF:
1526 count += sprintf(buf + count, "PM State: %s\n", state);
1531 static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
1533 int snd_soc_dapm_sys_add(struct device *dev)
1535 return device_create_file(dev, &dev_attr_dapm_widget);
1538 static void snd_soc_dapm_sys_remove(struct device *dev)
1540 device_remove_file(dev, &dev_attr_dapm_widget);
1543 /* free all dapm widgets and resources */
1544 static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
1546 struct snd_soc_dapm_widget *w, *next_w;
1547 struct snd_soc_dapm_path *p, *next_p;
1549 list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) {
1550 if (w->dapm != dapm)
1554 * remove source and sink paths associated to this widget.
1555 * While removing the path, remove reference to it from both
1556 * source and sink widgets so that path is removed only once.
1558 list_for_each_entry_safe(p, next_p, &w->sources, list_sink) {
1559 list_del(&p->list_sink);
1560 list_del(&p->list_source);
1562 kfree(p->long_name);
1565 list_for_each_entry_safe(p, next_p, &w->sinks, list_source) {
1566 list_del(&p->list_sink);
1567 list_del(&p->list_source);
1569 kfree(p->long_name);
1572 kfree(w->kcontrols);
1578 static struct snd_soc_dapm_widget *dapm_find_widget(
1579 struct snd_soc_dapm_context *dapm, const char *pin,
1580 bool search_other_contexts)
1582 struct snd_soc_dapm_widget *w;
1583 struct snd_soc_dapm_widget *fallback = NULL;
1585 list_for_each_entry(w, &dapm->card->widgets, list) {
1586 if (!strcmp(w->name, pin)) {
1587 if (w->dapm == dapm)
1594 if (search_other_contexts)
1600 static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
1601 const char *pin, int status)
1603 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
1606 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
1610 w->connected = status;
1618 * snd_soc_dapm_sync - scan and power dapm paths
1619 * @dapm: DAPM context
1621 * Walks all dapm audio paths and powers widgets according to their
1622 * stream or path usage.
1624 * Returns 0 for success.
1626 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
1628 return dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
1630 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
1632 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
1633 const struct snd_soc_dapm_route *route)
1635 struct snd_soc_dapm_path *path;
1636 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
1637 struct snd_soc_dapm_widget *wtsource = NULL, *wtsink = NULL;
1639 const char *control = route->control;
1641 char prefixed_sink[80];
1642 char prefixed_source[80];
1645 if (dapm->codec && dapm->codec->name_prefix) {
1646 snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
1647 dapm->codec->name_prefix, route->sink);
1648 sink = prefixed_sink;
1649 snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
1650 dapm->codec->name_prefix, route->source);
1651 source = prefixed_source;
1654 source = route->source;
1658 * find src and dest widgets over all widgets but favor a widget from
1659 * current DAPM context
1661 list_for_each_entry(w, &dapm->card->widgets, list) {
1662 if (!wsink && !(strcmp(w->name, sink))) {
1664 if (w->dapm == dapm)
1668 if (!wsource && !(strcmp(w->name, source))) {
1670 if (w->dapm == dapm)
1674 /* use widget from another DAPM context if not found from this */
1680 if (wsource == NULL || wsink == NULL)
1683 path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
1687 path->source = wsource;
1689 path->connected = route->connected;
1690 INIT_LIST_HEAD(&path->list);
1691 INIT_LIST_HEAD(&path->list_source);
1692 INIT_LIST_HEAD(&path->list_sink);
1694 /* check for external widgets */
1695 if (wsink->id == snd_soc_dapm_input) {
1696 if (wsource->id == snd_soc_dapm_micbias ||
1697 wsource->id == snd_soc_dapm_mic ||
1698 wsource->id == snd_soc_dapm_line ||
1699 wsource->id == snd_soc_dapm_output)
1702 if (wsource->id == snd_soc_dapm_output) {
1703 if (wsink->id == snd_soc_dapm_spk ||
1704 wsink->id == snd_soc_dapm_hp ||
1705 wsink->id == snd_soc_dapm_line ||
1706 wsink->id == snd_soc_dapm_input)
1710 /* connect static paths */
1711 if (control == NULL) {
1712 list_add(&path->list, &dapm->card->paths);
1713 list_add(&path->list_sink, &wsink->sources);
1714 list_add(&path->list_source, &wsource->sinks);
1719 /* connect dynamic paths */
1720 switch (wsink->id) {
1721 case snd_soc_dapm_adc:
1722 case snd_soc_dapm_dac:
1723 case snd_soc_dapm_pga:
1724 case snd_soc_dapm_out_drv:
1725 case snd_soc_dapm_input:
1726 case snd_soc_dapm_output:
1727 case snd_soc_dapm_micbias:
1728 case snd_soc_dapm_vmid:
1729 case snd_soc_dapm_pre:
1730 case snd_soc_dapm_post:
1731 case snd_soc_dapm_supply:
1732 case snd_soc_dapm_aif_in:
1733 case snd_soc_dapm_aif_out:
1734 list_add(&path->list, &dapm->card->paths);
1735 list_add(&path->list_sink, &wsink->sources);
1736 list_add(&path->list_source, &wsource->sinks);
1739 case snd_soc_dapm_mux:
1740 case snd_soc_dapm_virt_mux:
1741 case snd_soc_dapm_value_mux:
1742 ret = dapm_connect_mux(dapm, wsource, wsink, path, control,
1743 &wsink->kcontrol_news[0]);
1747 case snd_soc_dapm_switch:
1748 case snd_soc_dapm_mixer:
1749 case snd_soc_dapm_mixer_named_ctl:
1750 ret = dapm_connect_mixer(dapm, wsource, wsink, path, control);
1754 case snd_soc_dapm_hp:
1755 case snd_soc_dapm_mic:
1756 case snd_soc_dapm_line:
1757 case snd_soc_dapm_spk:
1758 list_add(&path->list, &dapm->card->paths);
1759 list_add(&path->list_sink, &wsink->sources);
1760 list_add(&path->list_source, &wsource->sinks);
1767 dev_warn(dapm->dev, "asoc: no dapm match for %s --> %s --> %s\n",
1768 source, control, sink);
1774 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
1775 * @dapm: DAPM context
1776 * @route: audio routes
1777 * @num: number of routes
1779 * Connects 2 dapm widgets together via a named audio path. The sink is
1780 * the widget receiving the audio signal, whilst the source is the sender
1781 * of the audio signal.
1783 * Returns 0 for success else error. On error all resources can be freed
1784 * with a call to snd_soc_card_free().
1786 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
1787 const struct snd_soc_dapm_route *route, int num)
1791 for (i = 0; i < num; i++) {
1792 ret = snd_soc_dapm_add_route(dapm, route);
1794 dev_err(dapm->dev, "Failed to add route %s->%s\n",
1795 route->source, route->sink);
1803 EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
1806 * snd_soc_dapm_new_widgets - add new dapm widgets
1807 * @dapm: DAPM context
1809 * Checks the codec for any new dapm widgets and creates them if found.
1811 * Returns 0 for success.
1813 int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
1815 struct snd_soc_dapm_widget *w;
1818 list_for_each_entry(w, &dapm->card->widgets, list)
1823 if (w->num_kcontrols) {
1824 w->kcontrols = kzalloc(w->num_kcontrols *
1825 sizeof(struct snd_kcontrol *),
1832 case snd_soc_dapm_switch:
1833 case snd_soc_dapm_mixer:
1834 case snd_soc_dapm_mixer_named_ctl:
1835 w->power_check = dapm_generic_check_power;
1836 dapm_new_mixer(dapm, w);
1838 case snd_soc_dapm_mux:
1839 case snd_soc_dapm_virt_mux:
1840 case snd_soc_dapm_value_mux:
1841 w->power_check = dapm_generic_check_power;
1842 dapm_new_mux(dapm, w);
1844 case snd_soc_dapm_adc:
1845 case snd_soc_dapm_aif_out:
1846 w->power_check = dapm_adc_check_power;
1848 case snd_soc_dapm_dac:
1849 case snd_soc_dapm_aif_in:
1850 w->power_check = dapm_dac_check_power;
1852 case snd_soc_dapm_pga:
1853 case snd_soc_dapm_out_drv:
1854 w->power_check = dapm_generic_check_power;
1855 dapm_new_pga(dapm, w);
1857 case snd_soc_dapm_input:
1858 case snd_soc_dapm_output:
1859 case snd_soc_dapm_micbias:
1860 case snd_soc_dapm_spk:
1861 case snd_soc_dapm_hp:
1862 case snd_soc_dapm_mic:
1863 case snd_soc_dapm_line:
1864 w->power_check = dapm_generic_check_power;
1866 case snd_soc_dapm_supply:
1867 w->power_check = dapm_supply_check_power;
1868 case snd_soc_dapm_vmid:
1869 case snd_soc_dapm_pre:
1870 case snd_soc_dapm_post:
1874 /* Read the initial power state from the device */
1876 val = snd_soc_read(w->codec, w->reg);
1877 val &= 1 << w->shift;
1887 dapm_debugfs_add_widget(w);
1890 dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
1893 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
1896 * snd_soc_dapm_get_volsw - dapm mixer get callback
1897 * @kcontrol: mixer control
1898 * @ucontrol: control element information
1900 * Callback to get the value of a dapm mixer control.
1902 * Returns 0 for success.
1904 int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
1905 struct snd_ctl_elem_value *ucontrol)
1907 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1908 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1909 struct soc_mixer_control *mc =
1910 (struct soc_mixer_control *)kcontrol->private_value;
1911 unsigned int reg = mc->reg;
1912 unsigned int shift = mc->shift;
1913 unsigned int rshift = mc->rshift;
1915 unsigned int invert = mc->invert;
1916 unsigned int mask = (1 << fls(max)) - 1;
1918 ucontrol->value.integer.value[0] =
1919 (snd_soc_read(widget->codec, reg) >> shift) & mask;
1920 if (shift != rshift)
1921 ucontrol->value.integer.value[1] =
1922 (snd_soc_read(widget->codec, reg) >> rshift) & mask;
1924 ucontrol->value.integer.value[0] =
1925 max - ucontrol->value.integer.value[0];
1926 if (shift != rshift)
1927 ucontrol->value.integer.value[1] =
1928 max - ucontrol->value.integer.value[1];
1933 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
1936 * snd_soc_dapm_put_volsw - dapm mixer set callback
1937 * @kcontrol: mixer control
1938 * @ucontrol: control element information
1940 * Callback to set the value of a dapm mixer control.
1942 * Returns 0 for success.
1944 int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
1945 struct snd_ctl_elem_value *ucontrol)
1947 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1948 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1949 struct snd_soc_codec *codec = widget->codec;
1950 struct soc_mixer_control *mc =
1951 (struct soc_mixer_control *)kcontrol->private_value;
1952 unsigned int reg = mc->reg;
1953 unsigned int shift = mc->shift;
1955 unsigned int mask = (1 << fls(max)) - 1;
1956 unsigned int invert = mc->invert;
1958 int connect, change;
1959 struct snd_soc_dapm_update update;
1962 val = (ucontrol->value.integer.value[0] & mask);
1966 mask = mask << shift;
1970 /* new connection */
1971 connect = invert ? 0 : 1;
1973 /* old connection must be powered down */
1974 connect = invert ? 1 : 0;
1976 mutex_lock(&codec->mutex);
1978 change = snd_soc_test_bits(widget->codec, reg, mask, val);
1980 for (wi = 0; wi < wlist->num_widgets; wi++) {
1981 widget = wlist->widgets[wi];
1983 widget->value = val;
1985 update.kcontrol = kcontrol;
1986 update.widget = widget;
1990 widget->dapm->update = &update;
1992 dapm_mixer_update_power(widget, kcontrol, connect);
1994 widget->dapm->update = NULL;
1998 mutex_unlock(&codec->mutex);
2001 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
2004 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
2005 * @kcontrol: mixer control
2006 * @ucontrol: control element information
2008 * Callback to get the value of a dapm enumerated double mixer control.
2010 * Returns 0 for success.
2012 int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
2013 struct snd_ctl_elem_value *ucontrol)
2015 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2016 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2017 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2018 unsigned int val, bitmask;
2020 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2022 val = snd_soc_read(widget->codec, e->reg);
2023 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
2024 if (e->shift_l != e->shift_r)
2025 ucontrol->value.enumerated.item[1] =
2026 (val >> e->shift_r) & (bitmask - 1);
2030 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
2033 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
2034 * @kcontrol: mixer control
2035 * @ucontrol: control element information
2037 * Callback to set the value of a dapm enumerated double mixer control.
2039 * Returns 0 for success.
2041 int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
2042 struct snd_ctl_elem_value *ucontrol)
2044 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2045 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2046 struct snd_soc_codec *codec = widget->codec;
2047 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2048 unsigned int val, mux, change;
2049 unsigned int mask, bitmask;
2050 struct snd_soc_dapm_update update;
2053 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2055 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2057 mux = ucontrol->value.enumerated.item[0];
2058 val = mux << e->shift_l;
2059 mask = (bitmask - 1) << e->shift_l;
2060 if (e->shift_l != e->shift_r) {
2061 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2063 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
2064 mask |= (bitmask - 1) << e->shift_r;
2067 mutex_lock(&codec->mutex);
2069 change = snd_soc_test_bits(widget->codec, e->reg, mask, val);
2071 for (wi = 0; wi < wlist->num_widgets; wi++) {
2072 widget = wlist->widgets[wi];
2074 widget->value = val;
2076 update.kcontrol = kcontrol;
2077 update.widget = widget;
2078 update.reg = e->reg;
2081 widget->dapm->update = &update;
2083 dapm_mux_update_power(widget, kcontrol, change, mux, e);
2085 widget->dapm->update = NULL;
2089 mutex_unlock(&codec->mutex);
2092 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
2095 * snd_soc_dapm_get_enum_virt - Get virtual DAPM mux
2096 * @kcontrol: mixer control
2097 * @ucontrol: control element information
2099 * Returns 0 for success.
2101 int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
2102 struct snd_ctl_elem_value *ucontrol)
2104 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2105 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2107 ucontrol->value.enumerated.item[0] = widget->value;
2111 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt);
2114 * snd_soc_dapm_put_enum_virt - Set virtual DAPM mux
2115 * @kcontrol: mixer control
2116 * @ucontrol: control element information
2118 * Returns 0 for success.
2120 int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
2121 struct snd_ctl_elem_value *ucontrol)
2123 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2124 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2125 struct snd_soc_codec *codec = widget->codec;
2126 struct soc_enum *e =
2127 (struct soc_enum *)kcontrol->private_value;
2132 if (ucontrol->value.enumerated.item[0] >= e->max)
2135 mutex_lock(&codec->mutex);
2137 change = widget->value != ucontrol->value.enumerated.item[0];
2139 for (wi = 0; wi < wlist->num_widgets; wi++) {
2140 widget = wlist->widgets[wi];
2142 widget->value = ucontrol->value.enumerated.item[0];
2144 dapm_mux_update_power(widget, kcontrol, change,
2149 mutex_unlock(&codec->mutex);
2152 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
2155 * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get
2157 * @kcontrol: mixer control
2158 * @ucontrol: control element information
2160 * Callback to get the value of a dapm semi enumerated double mixer control.
2162 * Semi enumerated mixer: the enumerated items are referred as values. Can be
2163 * used for handling bitfield coded enumeration for example.
2165 * Returns 0 for success.
2167 int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
2168 struct snd_ctl_elem_value *ucontrol)
2170 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2171 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2172 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2173 unsigned int reg_val, val, mux;
2175 reg_val = snd_soc_read(widget->codec, e->reg);
2176 val = (reg_val >> e->shift_l) & e->mask;
2177 for (mux = 0; mux < e->max; mux++) {
2178 if (val == e->values[mux])
2181 ucontrol->value.enumerated.item[0] = mux;
2182 if (e->shift_l != e->shift_r) {
2183 val = (reg_val >> e->shift_r) & e->mask;
2184 for (mux = 0; mux < e->max; mux++) {
2185 if (val == e->values[mux])
2188 ucontrol->value.enumerated.item[1] = mux;
2193 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double);
2196 * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set
2198 * @kcontrol: mixer control
2199 * @ucontrol: control element information
2201 * Callback to set the value of a dapm semi enumerated double mixer control.
2203 * Semi enumerated mixer: the enumerated items are referred as values. Can be
2204 * used for handling bitfield coded enumeration for example.
2206 * Returns 0 for success.
2208 int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
2209 struct snd_ctl_elem_value *ucontrol)
2211 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2212 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2213 struct snd_soc_codec *codec = widget->codec;
2214 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2215 unsigned int val, mux, change;
2217 struct snd_soc_dapm_update update;
2220 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2222 mux = ucontrol->value.enumerated.item[0];
2223 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
2224 mask = e->mask << e->shift_l;
2225 if (e->shift_l != e->shift_r) {
2226 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2228 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
2229 mask |= e->mask << e->shift_r;
2232 mutex_lock(&codec->mutex);
2234 change = snd_soc_test_bits(widget->codec, e->reg, mask, val);
2236 for (wi = 0; wi < wlist->num_widgets; wi++) {
2237 widget = wlist->widgets[wi];
2239 widget->value = val;
2241 update.kcontrol = kcontrol;
2242 update.widget = widget;
2243 update.reg = e->reg;
2246 widget->dapm->update = &update;
2248 dapm_mux_update_power(widget, kcontrol, change, mux, e);
2250 widget->dapm->update = NULL;
2254 mutex_unlock(&codec->mutex);
2257 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double);
2260 * snd_soc_dapm_info_pin_switch - Info for a pin switch
2262 * @kcontrol: mixer control
2263 * @uinfo: control element information
2265 * Callback to provide information about a pin switch control.
2267 int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
2268 struct snd_ctl_elem_info *uinfo)
2270 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2272 uinfo->value.integer.min = 0;
2273 uinfo->value.integer.max = 1;
2277 EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch);
2280 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
2282 * @kcontrol: mixer control
2285 int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
2286 struct snd_ctl_elem_value *ucontrol)
2288 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2289 const char *pin = (const char *)kcontrol->private_value;
2291 mutex_lock(&codec->mutex);
2293 ucontrol->value.integer.value[0] =
2294 snd_soc_dapm_get_pin_status(&codec->dapm, pin);
2296 mutex_unlock(&codec->mutex);
2300 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch);
2303 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
2305 * @kcontrol: mixer control
2308 int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
2309 struct snd_ctl_elem_value *ucontrol)
2311 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2312 const char *pin = (const char *)kcontrol->private_value;
2314 mutex_lock(&codec->mutex);
2316 if (ucontrol->value.integer.value[0])
2317 snd_soc_dapm_enable_pin(&codec->dapm, pin);
2319 snd_soc_dapm_disable_pin(&codec->dapm, pin);
2321 snd_soc_dapm_sync(&codec->dapm);
2323 mutex_unlock(&codec->mutex);
2327 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
2330 * snd_soc_dapm_new_control - create new dapm control
2331 * @dapm: DAPM context
2332 * @widget: widget template
2334 * Creates a new dapm control based upon the template.
2336 * Returns 0 for success else error.
2338 int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2339 const struct snd_soc_dapm_widget *widget)
2341 struct snd_soc_dapm_widget *w;
2344 if ((w = dapm_cnew_widget(widget)) == NULL)
2347 name_len = strlen(widget->name) + 1;
2348 if (dapm->codec && dapm->codec->name_prefix)
2349 name_len += 1 + strlen(dapm->codec->name_prefix);
2350 w->name = kmalloc(name_len, GFP_KERNEL);
2351 if (w->name == NULL) {
2355 if (dapm->codec && dapm->codec->name_prefix)
2356 snprintf(w->name, name_len, "%s %s",
2357 dapm->codec->name_prefix, widget->name);
2359 snprintf(w->name, name_len, "%s", widget->name);
2363 w->codec = dapm->codec;
2364 INIT_LIST_HEAD(&w->sources);
2365 INIT_LIST_HEAD(&w->sinks);
2366 INIT_LIST_HEAD(&w->list);
2367 list_add(&w->list, &dapm->card->widgets);
2369 /* machine layer set ups unconnected pins and insertions */
2373 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
2376 * snd_soc_dapm_new_controls - create new dapm controls
2377 * @dapm: DAPM context
2378 * @widget: widget array
2379 * @num: number of widgets
2381 * Creates new DAPM controls based upon the templates.
2383 * Returns 0 for success else error.
2385 int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
2386 const struct snd_soc_dapm_widget *widget,
2391 for (i = 0; i < num; i++) {
2392 ret = snd_soc_dapm_new_control(dapm, widget);
2395 "ASoC: Failed to create DAPM control %s: %d\n",
2403 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
2405 static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
2406 const char *stream, int event)
2408 struct snd_soc_dapm_widget *w;
2410 list_for_each_entry(w, &dapm->card->widgets, list)
2412 if (!w->sname || w->dapm != dapm)
2414 dev_dbg(w->dapm->dev, "widget %s\n %s stream %s event %d\n",
2415 w->name, w->sname, stream, event);
2416 if (strstr(w->sname, stream)) {
2418 case SND_SOC_DAPM_STREAM_START:
2421 case SND_SOC_DAPM_STREAM_STOP:
2424 case SND_SOC_DAPM_STREAM_SUSPEND:
2425 case SND_SOC_DAPM_STREAM_RESUME:
2426 case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
2427 case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
2433 dapm_power_widgets(dapm, event);
2437 * snd_soc_dapm_stream_event - send a stream event to the dapm core
2438 * @rtd: PCM runtime data
2439 * @stream: stream name
2440 * @event: stream event
2442 * Sends a stream event to the dapm core. The core then makes any
2443 * necessary widget power changes.
2445 * Returns 0 for success else error.
2447 int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
2448 const char *stream, int event)
2450 struct snd_soc_codec *codec = rtd->codec;
2455 mutex_lock(&codec->mutex);
2456 soc_dapm_stream_event(&codec->dapm, stream, event);
2457 mutex_unlock(&codec->mutex);
2462 * snd_soc_dapm_enable_pin - enable pin.
2463 * @dapm: DAPM context
2466 * Enables input/output pin and its parents or children widgets iff there is
2467 * a valid audio route and active audio stream.
2468 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2469 * do any widget power switching.
2471 int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
2473 return snd_soc_dapm_set_pin(dapm, pin, 1);
2475 EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
2478 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
2479 * @dapm: DAPM context
2482 * Enables input/output pin regardless of any other state. This is
2483 * intended for use with microphone bias supplies used in microphone
2486 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2487 * do any widget power switching.
2489 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
2492 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
2495 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
2499 dev_dbg(w->dapm->dev, "dapm: force enable pin %s\n", pin);
2505 EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
2508 * snd_soc_dapm_disable_pin - disable pin.
2509 * @dapm: DAPM context
2512 * Disables input/output pin and its parents or children widgets.
2513 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2514 * do any widget power switching.
2516 int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
2519 return snd_soc_dapm_set_pin(dapm, pin, 0);
2521 EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
2524 * snd_soc_dapm_nc_pin - permanently disable pin.
2525 * @dapm: DAPM context
2528 * Marks the specified pin as being not connected, disabling it along
2529 * any parent or child widgets. At present this is identical to
2530 * snd_soc_dapm_disable_pin() but in future it will be extended to do
2531 * additional things such as disabling controls which only affect
2532 * paths through the pin.
2534 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2535 * do any widget power switching.
2537 int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
2539 return snd_soc_dapm_set_pin(dapm, pin, 0);
2541 EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
2544 * snd_soc_dapm_get_pin_status - get audio pin status
2545 * @dapm: DAPM context
2546 * @pin: audio signal pin endpoint (or start point)
2548 * Get audio pin status - connected or disconnected.
2550 * Returns 1 for connected otherwise 0.
2552 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
2555 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
2558 return w->connected;
2562 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
2565 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
2566 * @dapm: DAPM context
2567 * @pin: audio signal pin endpoint (or start point)
2569 * Mark the given endpoint or pin as ignoring suspend. When the
2570 * system is disabled a path between two endpoints flagged as ignoring
2571 * suspend will not be disabled. The path must already be enabled via
2572 * normal means at suspend time, it will not be turned on if it was not
2575 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
2578 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false);
2581 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
2585 w->ignore_suspend = 1;
2589 EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
2592 * snd_soc_dapm_free - free dapm resources
2595 * Free all dapm widgets and resources.
2597 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
2599 snd_soc_dapm_sys_remove(dapm->dev);
2600 dapm_debugfs_cleanup(dapm);
2601 dapm_free_widgets(dapm);
2602 list_del(&dapm->list);
2604 EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
2606 static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
2608 struct snd_soc_dapm_widget *w;
2609 LIST_HEAD(down_list);
2612 list_for_each_entry(w, &dapm->card->widgets, list) {
2613 if (w->dapm != dapm)
2616 dapm_seq_insert(w, &down_list, false);
2622 /* If there were no widgets to power down we're already in
2626 snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_PREPARE);
2627 dapm_seq_run(dapm, &down_list, 0, false);
2628 snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_STANDBY);
2633 * snd_soc_dapm_shutdown - callback for system shutdown
2635 void snd_soc_dapm_shutdown(struct snd_soc_card *card)
2637 struct snd_soc_codec *codec;
2639 list_for_each_entry(codec, &card->codec_dev_list, list) {
2640 soc_dapm_shutdown_codec(&codec->dapm);
2641 snd_soc_dapm_set_bias_level(&codec->dapm, SND_SOC_BIAS_OFF);
2645 /* Module information */
2646 MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
2647 MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC");
2648 MODULE_LICENSE("GPL");