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, dapm, level);
150 if (dapm->codec->driver->set_bias_level)
151 ret = dapm->codec->driver->set_bias_level(dapm->codec,
154 dapm->bias_level = level;
159 if (card && card->set_bias_level_post)
160 ret = card->set_bias_level_post(card, dapm, level);
162 trace_snd_soc_bias_level_done(card, level);
167 /* set up initial codec paths */
168 static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
169 struct snd_soc_dapm_path *p, int i)
172 case snd_soc_dapm_switch:
173 case snd_soc_dapm_mixer:
174 case snd_soc_dapm_mixer_named_ctl: {
176 struct soc_mixer_control *mc = (struct soc_mixer_control *)
177 w->kcontrol_news[i].private_value;
178 unsigned int reg = mc->reg;
179 unsigned int shift = mc->shift;
181 unsigned int mask = (1 << fls(max)) - 1;
182 unsigned int invert = mc->invert;
184 val = snd_soc_read(w->codec, reg);
185 val = (val >> shift) & mask;
187 if ((invert && !val) || (!invert && val))
193 case snd_soc_dapm_mux: {
194 struct soc_enum *e = (struct soc_enum *)
195 w->kcontrol_news[i].private_value;
196 int val, item, bitmask;
198 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
200 val = snd_soc_read(w->codec, e->reg);
201 item = (val >> e->shift_l) & (bitmask - 1);
204 for (i = 0; i < e->max; i++) {
205 if (!(strcmp(p->name, e->texts[i])) && item == i)
210 case snd_soc_dapm_virt_mux: {
211 struct soc_enum *e = (struct soc_enum *)
212 w->kcontrol_news[i].private_value;
215 /* since a virtual mux has no backing registers to
216 * decide which path to connect, it will try to match
217 * with the first enumeration. This is to ensure
218 * that the default mux choice (the first) will be
219 * correctly powered up during initialization.
221 if (!strcmp(p->name, e->texts[0]))
225 case snd_soc_dapm_value_mux: {
226 struct soc_enum *e = (struct soc_enum *)
227 w->kcontrol_news[i].private_value;
230 val = snd_soc_read(w->codec, e->reg);
231 val = (val >> e->shift_l) & e->mask;
232 for (item = 0; item < e->max; item++) {
233 if (val == e->values[item])
238 for (i = 0; i < e->max; i++) {
239 if (!(strcmp(p->name, e->texts[i])) && item == i)
244 /* does not effect routing - always connected */
245 case snd_soc_dapm_pga:
246 case snd_soc_dapm_out_drv:
247 case snd_soc_dapm_output:
248 case snd_soc_dapm_adc:
249 case snd_soc_dapm_input:
250 case snd_soc_dapm_dac:
251 case snd_soc_dapm_micbias:
252 case snd_soc_dapm_vmid:
253 case snd_soc_dapm_supply:
254 case snd_soc_dapm_aif_in:
255 case snd_soc_dapm_aif_out:
258 /* does effect routing - dynamically connected */
259 case snd_soc_dapm_hp:
260 case snd_soc_dapm_mic:
261 case snd_soc_dapm_spk:
262 case snd_soc_dapm_line:
263 case snd_soc_dapm_pre:
264 case snd_soc_dapm_post:
270 /* connect mux widget to its interconnecting audio paths */
271 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
272 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
273 struct snd_soc_dapm_path *path, const char *control_name,
274 const struct snd_kcontrol_new *kcontrol)
276 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
279 for (i = 0; i < e->max; i++) {
280 if (!(strcmp(control_name, e->texts[i]))) {
281 list_add(&path->list, &dapm->card->paths);
282 list_add(&path->list_sink, &dest->sources);
283 list_add(&path->list_source, &src->sinks);
284 path->name = (char*)e->texts[i];
285 dapm_set_path_status(dest, path, 0);
293 /* connect mixer widget to its interconnecting audio paths */
294 static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
295 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
296 struct snd_soc_dapm_path *path, const char *control_name)
300 /* search for mixer kcontrol */
301 for (i = 0; i < dest->num_kcontrols; i++) {
302 if (!strcmp(control_name, dest->kcontrol_news[i].name)) {
303 list_add(&path->list, &dapm->card->paths);
304 list_add(&path->list_sink, &dest->sources);
305 list_add(&path->list_source, &src->sinks);
306 path->name = dest->kcontrol_news[i].name;
307 dapm_set_path_status(dest, path, i);
314 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm,
315 struct snd_soc_dapm_widget *kcontrolw,
316 const struct snd_kcontrol_new *kcontrol_new,
317 struct snd_kcontrol **kcontrol)
319 struct snd_soc_dapm_widget *w;
324 list_for_each_entry(w, &dapm->card->widgets, list) {
325 if (w == kcontrolw || w->dapm != kcontrolw->dapm)
327 for (i = 0; i < w->num_kcontrols; i++) {
328 if (&w->kcontrol_news[i] == kcontrol_new) {
330 *kcontrol = w->kcontrols[i];
339 /* create new dapm mixer control */
340 static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
341 struct snd_soc_dapm_widget *w)
344 size_t name_len, prefix_len;
345 struct snd_soc_dapm_path *path;
346 struct snd_card *card = dapm->card->snd_card;
348 struct snd_soc_dapm_widget_list *wlist;
352 prefix = dapm->codec->name_prefix;
357 prefix_len = strlen(prefix) + 1;
362 for (i = 0; i < w->num_kcontrols; i++) {
365 list_for_each_entry(path, &w->sources, list_sink) {
367 /* mixer/mux paths name must match control name */
368 if (path->name != (char *)w->kcontrol_news[i].name)
371 wlistsize = sizeof(struct snd_soc_dapm_widget_list) +
372 sizeof(struct snd_soc_dapm_widget *),
373 wlist = kzalloc(wlistsize, GFP_KERNEL);
376 "asoc: can't allocate widget list for %s\n",
380 wlist->num_widgets = 1;
381 wlist->widgets[0] = w;
383 /* add dapm control with long name.
384 * for dapm_mixer this is the concatenation of the
385 * mixer and kcontrol name.
386 * for dapm_mixer_named_ctl this is simply the
389 name_len = strlen(w->kcontrol_news[i].name) + 1;
390 if (w->id != snd_soc_dapm_mixer_named_ctl)
391 name_len += 1 + strlen(w->name);
393 path->long_name = kmalloc(name_len, GFP_KERNEL);
395 if (path->long_name == NULL) {
402 /* The control will get a prefix from
403 * the control creation process but
404 * we're also using the same prefix
405 * for widgets so cut the prefix off
406 * the front of the widget name.
408 snprintf(path->long_name, name_len, "%s %s",
409 w->name + prefix_len,
410 w->kcontrol_news[i].name);
412 case snd_soc_dapm_mixer_named_ctl:
413 snprintf(path->long_name, name_len, "%s",
414 w->kcontrol_news[i].name);
418 path->long_name[name_len - 1] = '\0';
420 path->kcontrol = snd_soc_cnew(&w->kcontrol_news[i],
421 wlist, path->long_name,
423 ret = snd_ctl_add(card, path->kcontrol);
426 "asoc: failed to add dapm kcontrol %s: %d\n",
427 path->long_name, ret);
429 kfree(path->long_name);
430 path->long_name = NULL;
433 w->kcontrols[i] = path->kcontrol;
439 /* create new dapm mux control */
440 static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
441 struct snd_soc_dapm_widget *w)
443 struct snd_soc_dapm_path *path = NULL;
444 struct snd_kcontrol *kcontrol;
445 struct snd_card *card = dapm->card->snd_card;
449 struct snd_soc_dapm_widget_list *wlist;
450 int shared, wlistentries;
454 if (w->num_kcontrols != 1) {
456 "asoc: mux %s has incorrect number of controls\n",
461 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[0],
464 wlist = kcontrol->private_data;
465 wlistentries = wlist->num_widgets + 1;
470 wlistsize = sizeof(struct snd_soc_dapm_widget_list) +
471 wlistentries * sizeof(struct snd_soc_dapm_widget *),
472 wlist = krealloc(wlist, wlistsize, GFP_KERNEL);
475 "asoc: can't allocate widget list for %s\n", w->name);
478 wlist->num_widgets = wlistentries;
479 wlist->widgets[wlistentries - 1] = w;
483 prefix = dapm->codec->name_prefix;
488 name = w->kcontrol_news[0].name;
493 prefix_len = strlen(prefix) + 1;
499 * The control will get a prefix from the control creation
500 * process but we're also using the same prefix for widgets so
501 * cut the prefix off the front of the widget name.
503 kcontrol = snd_soc_cnew(&w->kcontrol_news[0], wlist,
504 name + prefix_len, prefix);
505 ret = snd_ctl_add(card, kcontrol);
508 "asoc: failed to add kcontrol %s\n", w->name);
514 kcontrol->private_data = wlist;
516 w->kcontrols[0] = kcontrol;
518 list_for_each_entry(path, &w->sources, list_sink)
519 path->kcontrol = kcontrol;
524 /* create new dapm volume control */
525 static int dapm_new_pga(struct snd_soc_dapm_context *dapm,
526 struct snd_soc_dapm_widget *w)
528 if (w->num_kcontrols)
529 dev_err(w->dapm->dev,
530 "asoc: PGA controls not supported: '%s'\n", w->name);
535 /* reset 'walked' bit for each dapm path */
536 static inline void dapm_clear_walk(struct snd_soc_dapm_context *dapm)
538 struct snd_soc_dapm_path *p;
540 list_for_each_entry(p, &dapm->card->paths, list)
544 /* We implement power down on suspend by checking the power state of
545 * the ALSA card - when we are suspending the ALSA state for the card
548 static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
550 int level = snd_power_get_state(widget->dapm->card->snd_card);
553 case SNDRV_CTL_POWER_D3hot:
554 case SNDRV_CTL_POWER_D3cold:
555 if (widget->ignore_suspend)
556 dev_dbg(widget->dapm->dev, "%s ignoring suspend\n",
558 return widget->ignore_suspend;
565 * Recursively check for a completed path to an active or physically connected
566 * output widget. Returns number of complete paths.
568 static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
570 struct snd_soc_dapm_path *path;
573 if (widget->id == snd_soc_dapm_supply)
576 switch (widget->id) {
577 case snd_soc_dapm_adc:
578 case snd_soc_dapm_aif_out:
580 return snd_soc_dapm_suspend_check(widget);
585 if (widget->connected) {
586 /* connected pin ? */
587 if (widget->id == snd_soc_dapm_output && !widget->ext)
588 return snd_soc_dapm_suspend_check(widget);
590 /* connected jack or spk ? */
591 if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
592 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sources)))
593 return snd_soc_dapm_suspend_check(widget);
596 list_for_each_entry(path, &widget->sinks, list_source) {
600 if (path->sink && path->connect) {
602 con += is_connected_output_ep(path->sink);
610 * Recursively check for a completed path to an active or physically connected
611 * input widget. Returns number of complete paths.
613 static int is_connected_input_ep(struct snd_soc_dapm_widget *widget)
615 struct snd_soc_dapm_path *path;
618 if (widget->id == snd_soc_dapm_supply)
621 /* active stream ? */
622 switch (widget->id) {
623 case snd_soc_dapm_dac:
624 case snd_soc_dapm_aif_in:
626 return snd_soc_dapm_suspend_check(widget);
631 if (widget->connected) {
632 /* connected pin ? */
633 if (widget->id == snd_soc_dapm_input && !widget->ext)
634 return snd_soc_dapm_suspend_check(widget);
636 /* connected VMID/Bias for lower pops */
637 if (widget->id == snd_soc_dapm_vmid)
638 return snd_soc_dapm_suspend_check(widget);
640 /* connected jack ? */
641 if (widget->id == snd_soc_dapm_mic ||
642 (widget->id == snd_soc_dapm_line && !list_empty(&widget->sinks)))
643 return snd_soc_dapm_suspend_check(widget);
646 list_for_each_entry(path, &widget->sources, list_sink) {
650 if (path->source && path->connect) {
652 con += is_connected_input_ep(path->source);
660 * Handler for generic register modifier widget.
662 int dapm_reg_event(struct snd_soc_dapm_widget *w,
663 struct snd_kcontrol *kcontrol, int event)
667 if (SND_SOC_DAPM_EVENT_ON(event))
672 snd_soc_update_bits(w->codec, -(w->reg + 1),
673 w->mask << w->shift, val << w->shift);
677 EXPORT_SYMBOL_GPL(dapm_reg_event);
679 /* Generic check to see if a widget should be powered.
681 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w)
685 in = is_connected_input_ep(w);
686 dapm_clear_walk(w->dapm);
687 out = is_connected_output_ep(w);
688 dapm_clear_walk(w->dapm);
689 return out != 0 && in != 0;
692 /* Check to see if an ADC has power */
693 static int dapm_adc_check_power(struct snd_soc_dapm_widget *w)
698 in = is_connected_input_ep(w);
699 dapm_clear_walk(w->dapm);
702 return dapm_generic_check_power(w);
706 /* Check to see if a DAC has power */
707 static int dapm_dac_check_power(struct snd_soc_dapm_widget *w)
712 out = is_connected_output_ep(w);
713 dapm_clear_walk(w->dapm);
716 return dapm_generic_check_power(w);
720 /* Check to see if a power supply is needed */
721 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
723 struct snd_soc_dapm_path *path;
726 /* Check if one of our outputs is connected */
727 list_for_each_entry(path, &w->sinks, list_source) {
728 if (path->connected &&
729 !path->connected(path->source, path->sink))
735 if (path->sink->force) {
740 if (path->sink->power_check &&
741 path->sink->power_check(path->sink)) {
747 dapm_clear_walk(w->dapm);
752 static int dapm_seq_compare(struct snd_soc_dapm_widget *a,
753 struct snd_soc_dapm_widget *b,
761 sort = dapm_down_seq;
763 if (sort[a->id] != sort[b->id])
764 return sort[a->id] - sort[b->id];
765 if (a->subseq != b->subseq) {
767 return a->subseq - b->subseq;
769 return b->subseq - a->subseq;
771 if (a->reg != b->reg)
772 return a->reg - b->reg;
773 if (a->dapm != b->dapm)
774 return (unsigned long)a->dapm - (unsigned long)b->dapm;
779 /* Insert a widget in order into a DAPM power sequence. */
780 static void dapm_seq_insert(struct snd_soc_dapm_widget *new_widget,
781 struct list_head *list,
784 struct snd_soc_dapm_widget *w;
786 list_for_each_entry(w, list, power_list)
787 if (dapm_seq_compare(new_widget, w, power_up) < 0) {
788 list_add_tail(&new_widget->power_list, &w->power_list);
792 list_add_tail(&new_widget->power_list, list);
795 static void dapm_seq_check_event(struct snd_soc_dapm_context *dapm,
796 struct snd_soc_dapm_widget *w, int event)
798 struct snd_soc_card *card = dapm->card;
803 case SND_SOC_DAPM_PRE_PMU:
807 case SND_SOC_DAPM_POST_PMU:
808 ev_name = "POST_PMU";
811 case SND_SOC_DAPM_PRE_PMD:
815 case SND_SOC_DAPM_POST_PMD:
816 ev_name = "POST_PMD";
824 if (w->power != power)
827 if (w->event && (w->event_flags & event)) {
828 pop_dbg(dapm->dev, card->pop_time, "pop test : %s %s\n",
830 trace_snd_soc_dapm_widget_event_start(w, event);
831 ret = w->event(w, NULL, event);
832 trace_snd_soc_dapm_widget_event_done(w, event);
834 pr_err("%s: %s event failed: %d\n",
835 ev_name, w->name, ret);
839 /* Apply the coalesced changes from a DAPM sequence */
840 static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
841 struct list_head *pending)
843 struct snd_soc_card *card = dapm->card;
844 struct snd_soc_dapm_widget *w;
846 unsigned int value = 0;
847 unsigned int mask = 0;
848 unsigned int cur_mask;
850 reg = list_first_entry(pending, struct snd_soc_dapm_widget,
853 list_for_each_entry(w, pending, power_list) {
854 cur_mask = 1 << w->shift;
855 BUG_ON(reg != w->reg);
866 pop_dbg(dapm->dev, card->pop_time,
867 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
868 w->name, reg, value, mask);
870 /* Check for events */
871 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMU);
872 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_PRE_PMD);
876 pop_dbg(dapm->dev, card->pop_time,
877 "pop test : Applying 0x%x/0x%x to %x in %dms\n",
878 value, mask, reg, card->pop_time);
879 pop_wait(card->pop_time);
880 snd_soc_update_bits(dapm->codec, reg, mask, value);
883 list_for_each_entry(w, pending, power_list) {
884 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMU);
885 dapm_seq_check_event(dapm, w, SND_SOC_DAPM_POST_PMD);
889 /* Apply a DAPM power sequence.
891 * We walk over a pre-sorted list of widgets to apply power to. In
892 * order to minimise the number of writes to the device required
893 * multiple widgets will be updated in a single write where possible.
894 * Currently anything that requires more than a single write is not
897 static void dapm_seq_run(struct snd_soc_dapm_context *dapm,
898 struct list_head *list, int event, bool power_up)
900 struct snd_soc_dapm_widget *w, *n;
904 int cur_reg = SND_SOC_NOPM;
905 struct snd_soc_dapm_context *cur_dapm = NULL;
912 sort = dapm_down_seq;
914 list_for_each_entry_safe(w, n, list, power_list) {
917 /* Do we need to apply any queued changes? */
918 if (sort[w->id] != cur_sort || w->reg != cur_reg ||
919 w->dapm != cur_dapm || w->subseq != cur_subseq) {
920 if (!list_empty(&pending))
921 dapm_seq_run_coalesced(cur_dapm, &pending);
923 if (cur_dapm && cur_dapm->seq_notifier) {
924 for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
925 if (sort[i] == cur_sort)
926 cur_dapm->seq_notifier(cur_dapm,
931 INIT_LIST_HEAD(&pending);
934 cur_reg = SND_SOC_NOPM;
939 case snd_soc_dapm_pre:
941 list_for_each_entry_safe_continue(w, n, list,
944 if (event == SND_SOC_DAPM_STREAM_START)
946 NULL, SND_SOC_DAPM_PRE_PMU);
947 else if (event == SND_SOC_DAPM_STREAM_STOP)
949 NULL, SND_SOC_DAPM_PRE_PMD);
952 case snd_soc_dapm_post:
954 list_for_each_entry_safe_continue(w, n, list,
957 if (event == SND_SOC_DAPM_STREAM_START)
959 NULL, SND_SOC_DAPM_POST_PMU);
960 else if (event == SND_SOC_DAPM_STREAM_STOP)
962 NULL, SND_SOC_DAPM_POST_PMD);
966 /* Queue it up for application */
967 cur_sort = sort[w->id];
968 cur_subseq = w->subseq;
971 list_move(&w->power_list, &pending);
976 dev_err(w->dapm->dev,
977 "Failed to apply widget power: %d\n", ret);
980 if (!list_empty(&pending))
981 dapm_seq_run_coalesced(cur_dapm, &pending);
983 if (cur_dapm && cur_dapm->seq_notifier) {
984 for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
985 if (sort[i] == cur_sort)
986 cur_dapm->seq_notifier(cur_dapm,
991 static void dapm_widget_update(struct snd_soc_dapm_context *dapm)
993 struct snd_soc_dapm_update *update = dapm->update;
994 struct snd_soc_dapm_widget *w;
1003 (w->event_flags & SND_SOC_DAPM_PRE_REG)) {
1004 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG);
1006 pr_err("%s DAPM pre-event failed: %d\n",
1010 ret = snd_soc_update_bits(w->codec, update->reg, update->mask,
1013 pr_err("%s DAPM update failed: %d\n", w->name, ret);
1016 (w->event_flags & SND_SOC_DAPM_POST_REG)) {
1017 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG);
1019 pr_err("%s DAPM post-event failed: %d\n",
1024 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1025 * they're changing state.
1027 static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
1029 struct snd_soc_dapm_context *d = data;
1032 /* If we're off and we're not supposed to be go into STANDBY */
1033 if (d->bias_level == SND_SOC_BIAS_OFF &&
1034 d->target_bias_level != SND_SOC_BIAS_OFF) {
1035 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
1038 "Failed to turn on bias: %d\n", ret);
1041 /* Prepare for a STADDBY->ON or ON->STANDBY transition */
1042 if (d->bias_level != d->target_bias_level) {
1043 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE);
1046 "Failed to prepare bias: %d\n", ret);
1050 /* Async callback run prior to DAPM sequences - brings to their final
1053 static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
1055 struct snd_soc_dapm_context *d = data;
1058 /* If we just powered the last thing off drop to standby bias */
1059 if (d->bias_level == SND_SOC_BIAS_PREPARE &&
1060 (d->target_bias_level == SND_SOC_BIAS_STANDBY ||
1061 d->target_bias_level == SND_SOC_BIAS_OFF)) {
1062 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
1064 dev_err(d->dev, "Failed to apply standby bias: %d\n",
1068 /* If we're in standby and can support bias off then do that */
1069 if (d->bias_level == SND_SOC_BIAS_STANDBY &&
1070 d->target_bias_level == SND_SOC_BIAS_OFF) {
1071 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_OFF);
1073 dev_err(d->dev, "Failed to turn off bias: %d\n", ret);
1076 /* If we just powered up then move to active bias */
1077 if (d->bias_level == SND_SOC_BIAS_PREPARE &&
1078 d->target_bias_level == SND_SOC_BIAS_ON) {
1079 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_ON);
1081 dev_err(d->dev, "Failed to apply active bias: %d\n",
1087 * Scan each dapm widget for complete audio path.
1088 * A complete path is a route that has valid endpoints i.e.:-
1090 * o DAC to output pin.
1091 * o Input Pin to ADC.
1092 * o Input pin to Output pin (bypass, sidetone)
1093 * o DAC to ADC (loopback).
1095 static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
1097 struct snd_soc_card *card = dapm->card;
1098 struct snd_soc_dapm_widget *w;
1099 struct snd_soc_dapm_context *d;
1101 LIST_HEAD(down_list);
1102 LIST_HEAD(async_domain);
1103 enum snd_soc_bias_level bias;
1106 trace_snd_soc_dapm_start(card);
1108 list_for_each_entry(d, &card->dapm_list, list) {
1109 if (d->n_widgets || d->codec == NULL) {
1110 if (d->idle_bias_off)
1111 d->target_bias_level = SND_SOC_BIAS_OFF;
1113 d->target_bias_level = SND_SOC_BIAS_STANDBY;
1117 /* Check which widgets we need to power and store them in
1118 * lists indicating if they should be powered up or down.
1120 list_for_each_entry(w, &card->widgets, list) {
1122 case snd_soc_dapm_pre:
1123 dapm_seq_insert(w, &down_list, false);
1125 case snd_soc_dapm_post:
1126 dapm_seq_insert(w, &up_list, true);
1130 if (!w->power_check)
1134 power = w->power_check(w);
1141 /* Supplies and micbiases only bring
1142 * the context up to STANDBY as unless
1143 * something else is active and
1144 * passing audio they generally don't
1145 * require full power.
1148 case snd_soc_dapm_supply:
1149 case snd_soc_dapm_micbias:
1150 if (d->target_bias_level < SND_SOC_BIAS_STANDBY)
1151 d->target_bias_level = SND_SOC_BIAS_STANDBY;
1154 d->target_bias_level = SND_SOC_BIAS_ON;
1159 if (w->power == power)
1162 trace_snd_soc_dapm_widget_power(w, power);
1165 dapm_seq_insert(w, &up_list, true);
1167 dapm_seq_insert(w, &down_list, false);
1174 /* If there are no DAPM widgets then try to figure out power from the
1177 if (!dapm->n_widgets) {
1179 case SND_SOC_DAPM_STREAM_START:
1180 case SND_SOC_DAPM_STREAM_RESUME:
1181 dapm->target_bias_level = SND_SOC_BIAS_ON;
1183 case SND_SOC_DAPM_STREAM_STOP:
1184 if (dapm->codec->active)
1185 dapm->target_bias_level = SND_SOC_BIAS_ON;
1187 dapm->target_bias_level = SND_SOC_BIAS_STANDBY;
1189 case SND_SOC_DAPM_STREAM_SUSPEND:
1190 dapm->target_bias_level = SND_SOC_BIAS_STANDBY;
1192 case SND_SOC_DAPM_STREAM_NOP:
1193 dapm->target_bias_level = dapm->bias_level;
1200 /* Force all contexts in the card to the same bias state */
1201 bias = SND_SOC_BIAS_OFF;
1202 list_for_each_entry(d, &card->dapm_list, list)
1203 if (d->target_bias_level > bias)
1204 bias = d->target_bias_level;
1205 list_for_each_entry(d, &card->dapm_list, list)
1206 d->target_bias_level = bias;
1209 /* Run all the bias changes in parallel */
1210 list_for_each_entry(d, &dapm->card->dapm_list, list)
1211 async_schedule_domain(dapm_pre_sequence_async, d,
1213 async_synchronize_full_domain(&async_domain);
1215 /* Power down widgets first; try to avoid amplifying pops. */
1216 dapm_seq_run(dapm, &down_list, event, false);
1218 dapm_widget_update(dapm);
1221 dapm_seq_run(dapm, &up_list, event, true);
1223 /* Run all the bias changes in parallel */
1224 list_for_each_entry(d, &dapm->card->dapm_list, list)
1225 async_schedule_domain(dapm_post_sequence_async, d,
1227 async_synchronize_full_domain(&async_domain);
1229 pop_dbg(dapm->dev, card->pop_time,
1230 "DAPM sequencing finished, waiting %dms\n", card->pop_time);
1231 pop_wait(card->pop_time);
1233 trace_snd_soc_dapm_done(card);
1238 #ifdef CONFIG_DEBUG_FS
1239 static int dapm_widget_power_open_file(struct inode *inode, struct file *file)
1241 file->private_data = inode->i_private;
1245 static ssize_t dapm_widget_power_read_file(struct file *file,
1246 char __user *user_buf,
1247 size_t count, loff_t *ppos)
1249 struct snd_soc_dapm_widget *w = file->private_data;
1253 struct snd_soc_dapm_path *p = NULL;
1255 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
1259 in = is_connected_input_ep(w);
1260 dapm_clear_walk(w->dapm);
1261 out = is_connected_output_ep(w);
1262 dapm_clear_walk(w->dapm);
1264 ret = snprintf(buf, PAGE_SIZE, "%s: %s in %d out %d",
1265 w->name, w->power ? "On" : "Off", in, out);
1268 ret += snprintf(buf + ret, PAGE_SIZE - ret,
1269 " - R%d(0x%x) bit %d",
1270 w->reg, w->reg, w->shift);
1272 ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
1275 ret += snprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n",
1277 w->active ? "active" : "inactive");
1279 list_for_each_entry(p, &w->sources, list_sink) {
1280 if (p->connected && !p->connected(w, p->sink))
1284 ret += snprintf(buf + ret, PAGE_SIZE - ret,
1285 " in \"%s\" \"%s\"\n",
1286 p->name ? p->name : "static",
1289 list_for_each_entry(p, &w->sinks, list_source) {
1290 if (p->connected && !p->connected(w, p->sink))
1294 ret += snprintf(buf + ret, PAGE_SIZE - ret,
1295 " out \"%s\" \"%s\"\n",
1296 p->name ? p->name : "static",
1300 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
1306 static const struct file_operations dapm_widget_power_fops = {
1307 .open = dapm_widget_power_open_file,
1308 .read = dapm_widget_power_read_file,
1309 .llseek = default_llseek,
1312 static int dapm_bias_open_file(struct inode *inode, struct file *file)
1314 file->private_data = inode->i_private;
1318 static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf,
1319 size_t count, loff_t *ppos)
1321 struct snd_soc_dapm_context *dapm = file->private_data;
1324 switch (dapm->bias_level) {
1325 case SND_SOC_BIAS_ON:
1328 case SND_SOC_BIAS_PREPARE:
1329 level = "Prepare\n";
1331 case SND_SOC_BIAS_STANDBY:
1332 level = "Standby\n";
1334 case SND_SOC_BIAS_OFF:
1339 level = "Unknown\n";
1343 return simple_read_from_buffer(user_buf, count, ppos, level,
1347 static const struct file_operations dapm_bias_fops = {
1348 .open = dapm_bias_open_file,
1349 .read = dapm_bias_read_file,
1350 .llseek = default_llseek,
1353 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
1354 struct dentry *parent)
1358 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent);
1360 if (!dapm->debugfs_dapm) {
1362 "Failed to create DAPM debugfs directory\n");
1366 d = debugfs_create_file("bias_level", 0444,
1367 dapm->debugfs_dapm, dapm,
1371 "ASoC: Failed to create bias level debugfs file\n");
1374 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
1376 struct snd_soc_dapm_context *dapm = w->dapm;
1379 if (!dapm->debugfs_dapm || !w->name)
1382 d = debugfs_create_file(w->name, 0444,
1383 dapm->debugfs_dapm, w,
1384 &dapm_widget_power_fops);
1386 dev_warn(w->dapm->dev,
1387 "ASoC: Failed to create %s debugfs file\n",
1391 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
1393 debugfs_remove_recursive(dapm->debugfs_dapm);
1397 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
1398 struct dentry *parent)
1402 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w)
1406 static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
1412 /* test and update the power status of a mux widget */
1413 static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
1414 struct snd_kcontrol *kcontrol, int change,
1415 int mux, struct soc_enum *e)
1417 struct snd_soc_dapm_path *path;
1420 if (widget->id != snd_soc_dapm_mux &&
1421 widget->id != snd_soc_dapm_virt_mux &&
1422 widget->id != snd_soc_dapm_value_mux)
1428 /* find dapm widget path assoc with kcontrol */
1429 list_for_each_entry(path, &widget->dapm->card->paths, list) {
1430 if (path->kcontrol != kcontrol)
1433 if (!path->name || !e->texts[mux])
1437 /* we now need to match the string in the enum to the path */
1438 if (!(strcmp(path->name, e->texts[mux])))
1439 path->connect = 1; /* new connection */
1441 path->connect = 0; /* old connection must be powered down */
1445 dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP);
1450 /* test and update the power status of a mixer or switch widget */
1451 static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
1452 struct snd_kcontrol *kcontrol, int connect)
1454 struct snd_soc_dapm_path *path;
1457 if (widget->id != snd_soc_dapm_mixer &&
1458 widget->id != snd_soc_dapm_mixer_named_ctl &&
1459 widget->id != snd_soc_dapm_switch)
1462 /* find dapm widget path assoc with kcontrol */
1463 list_for_each_entry(path, &widget->dapm->card->paths, list) {
1464 if (path->kcontrol != kcontrol)
1467 /* found, now check type */
1469 path->connect = connect;
1474 dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP);
1479 /* show dapm widget status in sys fs */
1480 static ssize_t dapm_widget_show(struct device *dev,
1481 struct device_attribute *attr, char *buf)
1483 struct snd_soc_pcm_runtime *rtd =
1484 container_of(dev, struct snd_soc_pcm_runtime, dev);
1485 struct snd_soc_codec *codec =rtd->codec;
1486 struct snd_soc_dapm_widget *w;
1488 char *state = "not set";
1490 list_for_each_entry(w, &codec->card->widgets, list) {
1491 if (w->dapm != &codec->dapm)
1494 /* only display widgets that burnm power */
1496 case snd_soc_dapm_hp:
1497 case snd_soc_dapm_mic:
1498 case snd_soc_dapm_spk:
1499 case snd_soc_dapm_line:
1500 case snd_soc_dapm_micbias:
1501 case snd_soc_dapm_dac:
1502 case snd_soc_dapm_adc:
1503 case snd_soc_dapm_pga:
1504 case snd_soc_dapm_out_drv:
1505 case snd_soc_dapm_mixer:
1506 case snd_soc_dapm_mixer_named_ctl:
1507 case snd_soc_dapm_supply:
1509 count += sprintf(buf + count, "%s: %s\n",
1510 w->name, w->power ? "On":"Off");
1517 switch (codec->dapm.bias_level) {
1518 case SND_SOC_BIAS_ON:
1521 case SND_SOC_BIAS_PREPARE:
1524 case SND_SOC_BIAS_STANDBY:
1527 case SND_SOC_BIAS_OFF:
1531 count += sprintf(buf + count, "PM State: %s\n", state);
1536 static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
1538 int snd_soc_dapm_sys_add(struct device *dev)
1540 return device_create_file(dev, &dev_attr_dapm_widget);
1543 static void snd_soc_dapm_sys_remove(struct device *dev)
1545 device_remove_file(dev, &dev_attr_dapm_widget);
1548 /* free all dapm widgets and resources */
1549 static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
1551 struct snd_soc_dapm_widget *w, *next_w;
1552 struct snd_soc_dapm_path *p, *next_p;
1554 list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) {
1555 if (w->dapm != dapm)
1559 * remove source and sink paths associated to this widget.
1560 * While removing the path, remove reference to it from both
1561 * source and sink widgets so that path is removed only once.
1563 list_for_each_entry_safe(p, next_p, &w->sources, list_sink) {
1564 list_del(&p->list_sink);
1565 list_del(&p->list_source);
1567 kfree(p->long_name);
1570 list_for_each_entry_safe(p, next_p, &w->sinks, list_source) {
1571 list_del(&p->list_sink);
1572 list_del(&p->list_source);
1574 kfree(p->long_name);
1577 kfree(w->kcontrols);
1583 static struct snd_soc_dapm_widget *dapm_find_widget(
1584 struct snd_soc_dapm_context *dapm, const char *pin,
1585 bool search_other_contexts)
1587 struct snd_soc_dapm_widget *w;
1588 struct snd_soc_dapm_widget *fallback = NULL;
1590 list_for_each_entry(w, &dapm->card->widgets, list) {
1591 if (!strcmp(w->name, pin)) {
1592 if (w->dapm == dapm)
1599 if (search_other_contexts)
1605 static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
1606 const char *pin, int status)
1608 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
1611 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
1615 w->connected = status;
1623 * snd_soc_dapm_sync - scan and power dapm paths
1624 * @dapm: DAPM context
1626 * Walks all dapm audio paths and powers widgets according to their
1627 * stream or path usage.
1629 * Returns 0 for success.
1631 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
1633 return dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
1635 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
1637 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
1638 const struct snd_soc_dapm_route *route)
1640 struct snd_soc_dapm_path *path;
1641 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
1642 struct snd_soc_dapm_widget *wtsource = NULL, *wtsink = NULL;
1644 const char *control = route->control;
1646 char prefixed_sink[80];
1647 char prefixed_source[80];
1650 if (dapm->codec && dapm->codec->name_prefix) {
1651 snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
1652 dapm->codec->name_prefix, route->sink);
1653 sink = prefixed_sink;
1654 snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
1655 dapm->codec->name_prefix, route->source);
1656 source = prefixed_source;
1659 source = route->source;
1663 * find src and dest widgets over all widgets but favor a widget from
1664 * current DAPM context
1666 list_for_each_entry(w, &dapm->card->widgets, list) {
1667 if (!wsink && !(strcmp(w->name, sink))) {
1669 if (w->dapm == dapm)
1673 if (!wsource && !(strcmp(w->name, source))) {
1675 if (w->dapm == dapm)
1679 /* use widget from another DAPM context if not found from this */
1685 if (wsource == NULL || wsink == NULL)
1688 path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
1692 path->source = wsource;
1694 path->connected = route->connected;
1695 INIT_LIST_HEAD(&path->list);
1696 INIT_LIST_HEAD(&path->list_source);
1697 INIT_LIST_HEAD(&path->list_sink);
1699 /* check for external widgets */
1700 if (wsink->id == snd_soc_dapm_input) {
1701 if (wsource->id == snd_soc_dapm_micbias ||
1702 wsource->id == snd_soc_dapm_mic ||
1703 wsource->id == snd_soc_dapm_line ||
1704 wsource->id == snd_soc_dapm_output)
1707 if (wsource->id == snd_soc_dapm_output) {
1708 if (wsink->id == snd_soc_dapm_spk ||
1709 wsink->id == snd_soc_dapm_hp ||
1710 wsink->id == snd_soc_dapm_line ||
1711 wsink->id == snd_soc_dapm_input)
1715 /* connect static paths */
1716 if (control == NULL) {
1717 list_add(&path->list, &dapm->card->paths);
1718 list_add(&path->list_sink, &wsink->sources);
1719 list_add(&path->list_source, &wsource->sinks);
1724 /* connect dynamic paths */
1725 switch (wsink->id) {
1726 case snd_soc_dapm_adc:
1727 case snd_soc_dapm_dac:
1728 case snd_soc_dapm_pga:
1729 case snd_soc_dapm_out_drv:
1730 case snd_soc_dapm_input:
1731 case snd_soc_dapm_output:
1732 case snd_soc_dapm_micbias:
1733 case snd_soc_dapm_vmid:
1734 case snd_soc_dapm_pre:
1735 case snd_soc_dapm_post:
1736 case snd_soc_dapm_supply:
1737 case snd_soc_dapm_aif_in:
1738 case snd_soc_dapm_aif_out:
1739 list_add(&path->list, &dapm->card->paths);
1740 list_add(&path->list_sink, &wsink->sources);
1741 list_add(&path->list_source, &wsource->sinks);
1744 case snd_soc_dapm_mux:
1745 case snd_soc_dapm_virt_mux:
1746 case snd_soc_dapm_value_mux:
1747 ret = dapm_connect_mux(dapm, wsource, wsink, path, control,
1748 &wsink->kcontrol_news[0]);
1752 case snd_soc_dapm_switch:
1753 case snd_soc_dapm_mixer:
1754 case snd_soc_dapm_mixer_named_ctl:
1755 ret = dapm_connect_mixer(dapm, wsource, wsink, path, control);
1759 case snd_soc_dapm_hp:
1760 case snd_soc_dapm_mic:
1761 case snd_soc_dapm_line:
1762 case snd_soc_dapm_spk:
1763 list_add(&path->list, &dapm->card->paths);
1764 list_add(&path->list_sink, &wsink->sources);
1765 list_add(&path->list_source, &wsource->sinks);
1772 dev_warn(dapm->dev, "asoc: no dapm match for %s --> %s --> %s\n",
1773 source, control, sink);
1779 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
1780 * @dapm: DAPM context
1781 * @route: audio routes
1782 * @num: number of routes
1784 * Connects 2 dapm widgets together via a named audio path. The sink is
1785 * the widget receiving the audio signal, whilst the source is the sender
1786 * of the audio signal.
1788 * Returns 0 for success else error. On error all resources can be freed
1789 * with a call to snd_soc_card_free().
1791 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
1792 const struct snd_soc_dapm_route *route, int num)
1796 for (i = 0; i < num; i++) {
1797 ret = snd_soc_dapm_add_route(dapm, route);
1799 dev_err(dapm->dev, "Failed to add route %s->%s\n",
1800 route->source, route->sink);
1808 EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
1811 * snd_soc_dapm_new_widgets - add new dapm widgets
1812 * @dapm: DAPM context
1814 * Checks the codec for any new dapm widgets and creates them if found.
1816 * Returns 0 for success.
1818 int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
1820 struct snd_soc_dapm_widget *w;
1823 list_for_each_entry(w, &dapm->card->widgets, list)
1828 if (w->num_kcontrols) {
1829 w->kcontrols = kzalloc(w->num_kcontrols *
1830 sizeof(struct snd_kcontrol *),
1837 case snd_soc_dapm_switch:
1838 case snd_soc_dapm_mixer:
1839 case snd_soc_dapm_mixer_named_ctl:
1840 w->power_check = dapm_generic_check_power;
1841 dapm_new_mixer(dapm, w);
1843 case snd_soc_dapm_mux:
1844 case snd_soc_dapm_virt_mux:
1845 case snd_soc_dapm_value_mux:
1846 w->power_check = dapm_generic_check_power;
1847 dapm_new_mux(dapm, w);
1849 case snd_soc_dapm_adc:
1850 case snd_soc_dapm_aif_out:
1851 w->power_check = dapm_adc_check_power;
1853 case snd_soc_dapm_dac:
1854 case snd_soc_dapm_aif_in:
1855 w->power_check = dapm_dac_check_power;
1857 case snd_soc_dapm_pga:
1858 case snd_soc_dapm_out_drv:
1859 w->power_check = dapm_generic_check_power;
1860 dapm_new_pga(dapm, w);
1862 case snd_soc_dapm_input:
1863 case snd_soc_dapm_output:
1864 case snd_soc_dapm_micbias:
1865 case snd_soc_dapm_spk:
1866 case snd_soc_dapm_hp:
1867 case snd_soc_dapm_mic:
1868 case snd_soc_dapm_line:
1869 w->power_check = dapm_generic_check_power;
1871 case snd_soc_dapm_supply:
1872 w->power_check = dapm_supply_check_power;
1873 case snd_soc_dapm_vmid:
1874 case snd_soc_dapm_pre:
1875 case snd_soc_dapm_post:
1879 /* Read the initial power state from the device */
1881 val = snd_soc_read(w->codec, w->reg);
1882 val &= 1 << w->shift;
1892 dapm_debugfs_add_widget(w);
1895 dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
1898 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
1901 * snd_soc_dapm_get_volsw - dapm mixer get callback
1902 * @kcontrol: mixer control
1903 * @ucontrol: control element information
1905 * Callback to get the value of a dapm mixer control.
1907 * Returns 0 for success.
1909 int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
1910 struct snd_ctl_elem_value *ucontrol)
1912 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1913 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1914 struct soc_mixer_control *mc =
1915 (struct soc_mixer_control *)kcontrol->private_value;
1916 unsigned int reg = mc->reg;
1917 unsigned int shift = mc->shift;
1918 unsigned int rshift = mc->rshift;
1920 unsigned int invert = mc->invert;
1921 unsigned int mask = (1 << fls(max)) - 1;
1923 ucontrol->value.integer.value[0] =
1924 (snd_soc_read(widget->codec, reg) >> shift) & mask;
1925 if (shift != rshift)
1926 ucontrol->value.integer.value[1] =
1927 (snd_soc_read(widget->codec, reg) >> rshift) & mask;
1929 ucontrol->value.integer.value[0] =
1930 max - ucontrol->value.integer.value[0];
1931 if (shift != rshift)
1932 ucontrol->value.integer.value[1] =
1933 max - ucontrol->value.integer.value[1];
1938 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
1941 * snd_soc_dapm_put_volsw - dapm mixer set callback
1942 * @kcontrol: mixer control
1943 * @ucontrol: control element information
1945 * Callback to set the value of a dapm mixer control.
1947 * Returns 0 for success.
1949 int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
1950 struct snd_ctl_elem_value *ucontrol)
1952 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
1953 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
1954 struct snd_soc_codec *codec = widget->codec;
1955 struct soc_mixer_control *mc =
1956 (struct soc_mixer_control *)kcontrol->private_value;
1957 unsigned int reg = mc->reg;
1958 unsigned int shift = mc->shift;
1960 unsigned int mask = (1 << fls(max)) - 1;
1961 unsigned int invert = mc->invert;
1963 int connect, change;
1964 struct snd_soc_dapm_update update;
1967 val = (ucontrol->value.integer.value[0] & mask);
1971 mask = mask << shift;
1975 /* new connection */
1976 connect = invert ? 0 : 1;
1978 /* old connection must be powered down */
1979 connect = invert ? 1 : 0;
1981 mutex_lock(&codec->mutex);
1983 change = snd_soc_test_bits(widget->codec, reg, mask, val);
1985 for (wi = 0; wi < wlist->num_widgets; wi++) {
1986 widget = wlist->widgets[wi];
1988 widget->value = val;
1990 update.kcontrol = kcontrol;
1991 update.widget = widget;
1995 widget->dapm->update = &update;
1997 dapm_mixer_update_power(widget, kcontrol, connect);
1999 widget->dapm->update = NULL;
2003 mutex_unlock(&codec->mutex);
2006 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
2009 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
2010 * @kcontrol: mixer control
2011 * @ucontrol: control element information
2013 * Callback to get the value of a dapm enumerated double mixer control.
2015 * Returns 0 for success.
2017 int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
2018 struct snd_ctl_elem_value *ucontrol)
2020 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2021 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2022 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2023 unsigned int val, bitmask;
2025 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2027 val = snd_soc_read(widget->codec, e->reg);
2028 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
2029 if (e->shift_l != e->shift_r)
2030 ucontrol->value.enumerated.item[1] =
2031 (val >> e->shift_r) & (bitmask - 1);
2035 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
2038 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
2039 * @kcontrol: mixer control
2040 * @ucontrol: control element information
2042 * Callback to set the value of a dapm enumerated double mixer control.
2044 * Returns 0 for success.
2046 int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
2047 struct snd_ctl_elem_value *ucontrol)
2049 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2050 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2051 struct snd_soc_codec *codec = widget->codec;
2052 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2053 unsigned int val, mux, change;
2054 unsigned int mask, bitmask;
2055 struct snd_soc_dapm_update update;
2058 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2060 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2062 mux = ucontrol->value.enumerated.item[0];
2063 val = mux << e->shift_l;
2064 mask = (bitmask - 1) << e->shift_l;
2065 if (e->shift_l != e->shift_r) {
2066 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2068 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
2069 mask |= (bitmask - 1) << e->shift_r;
2072 mutex_lock(&codec->mutex);
2074 change = snd_soc_test_bits(widget->codec, e->reg, mask, val);
2076 for (wi = 0; wi < wlist->num_widgets; wi++) {
2077 widget = wlist->widgets[wi];
2079 widget->value = val;
2081 update.kcontrol = kcontrol;
2082 update.widget = widget;
2083 update.reg = e->reg;
2086 widget->dapm->update = &update;
2088 dapm_mux_update_power(widget, kcontrol, change, mux, e);
2090 widget->dapm->update = NULL;
2094 mutex_unlock(&codec->mutex);
2097 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
2100 * snd_soc_dapm_get_enum_virt - Get virtual DAPM mux
2101 * @kcontrol: mixer control
2102 * @ucontrol: control element information
2104 * Returns 0 for success.
2106 int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
2107 struct snd_ctl_elem_value *ucontrol)
2109 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2110 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2112 ucontrol->value.enumerated.item[0] = widget->value;
2116 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt);
2119 * snd_soc_dapm_put_enum_virt - Set virtual DAPM mux
2120 * @kcontrol: mixer control
2121 * @ucontrol: control element information
2123 * Returns 0 for success.
2125 int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
2126 struct snd_ctl_elem_value *ucontrol)
2128 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2129 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2130 struct snd_soc_codec *codec = widget->codec;
2131 struct soc_enum *e =
2132 (struct soc_enum *)kcontrol->private_value;
2137 if (ucontrol->value.enumerated.item[0] >= e->max)
2140 mutex_lock(&codec->mutex);
2142 change = widget->value != ucontrol->value.enumerated.item[0];
2144 for (wi = 0; wi < wlist->num_widgets; wi++) {
2145 widget = wlist->widgets[wi];
2147 widget->value = ucontrol->value.enumerated.item[0];
2149 dapm_mux_update_power(widget, kcontrol, change,
2154 mutex_unlock(&codec->mutex);
2157 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
2160 * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get
2162 * @kcontrol: mixer control
2163 * @ucontrol: control element information
2165 * Callback to get the value of a dapm semi enumerated double mixer control.
2167 * Semi enumerated mixer: the enumerated items are referred as values. Can be
2168 * used for handling bitfield coded enumeration for example.
2170 * Returns 0 for success.
2172 int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
2173 struct snd_ctl_elem_value *ucontrol)
2175 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2176 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2177 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2178 unsigned int reg_val, val, mux;
2180 reg_val = snd_soc_read(widget->codec, e->reg);
2181 val = (reg_val >> e->shift_l) & e->mask;
2182 for (mux = 0; mux < e->max; mux++) {
2183 if (val == e->values[mux])
2186 ucontrol->value.enumerated.item[0] = mux;
2187 if (e->shift_l != e->shift_r) {
2188 val = (reg_val >> e->shift_r) & e->mask;
2189 for (mux = 0; mux < e->max; mux++) {
2190 if (val == e->values[mux])
2193 ucontrol->value.enumerated.item[1] = mux;
2198 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double);
2201 * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set
2203 * @kcontrol: mixer control
2204 * @ucontrol: control element information
2206 * Callback to set the value of a dapm semi enumerated double mixer control.
2208 * Semi enumerated mixer: the enumerated items are referred as values. Can be
2209 * used for handling bitfield coded enumeration for example.
2211 * Returns 0 for success.
2213 int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
2214 struct snd_ctl_elem_value *ucontrol)
2216 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2217 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2218 struct snd_soc_codec *codec = widget->codec;
2219 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2220 unsigned int val, mux, change;
2222 struct snd_soc_dapm_update update;
2225 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2227 mux = ucontrol->value.enumerated.item[0];
2228 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
2229 mask = e->mask << e->shift_l;
2230 if (e->shift_l != e->shift_r) {
2231 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2233 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
2234 mask |= e->mask << e->shift_r;
2237 mutex_lock(&codec->mutex);
2239 change = snd_soc_test_bits(widget->codec, e->reg, mask, val);
2241 for (wi = 0; wi < wlist->num_widgets; wi++) {
2242 widget = wlist->widgets[wi];
2244 widget->value = val;
2246 update.kcontrol = kcontrol;
2247 update.widget = widget;
2248 update.reg = e->reg;
2251 widget->dapm->update = &update;
2253 dapm_mux_update_power(widget, kcontrol, change, mux, e);
2255 widget->dapm->update = NULL;
2259 mutex_unlock(&codec->mutex);
2262 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double);
2265 * snd_soc_dapm_info_pin_switch - Info for a pin switch
2267 * @kcontrol: mixer control
2268 * @uinfo: control element information
2270 * Callback to provide information about a pin switch control.
2272 int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
2273 struct snd_ctl_elem_info *uinfo)
2275 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2277 uinfo->value.integer.min = 0;
2278 uinfo->value.integer.max = 1;
2282 EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch);
2285 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
2287 * @kcontrol: mixer control
2290 int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
2291 struct snd_ctl_elem_value *ucontrol)
2293 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2294 const char *pin = (const char *)kcontrol->private_value;
2296 mutex_lock(&codec->mutex);
2298 ucontrol->value.integer.value[0] =
2299 snd_soc_dapm_get_pin_status(&codec->dapm, pin);
2301 mutex_unlock(&codec->mutex);
2305 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch);
2308 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
2310 * @kcontrol: mixer control
2313 int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
2314 struct snd_ctl_elem_value *ucontrol)
2316 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2317 const char *pin = (const char *)kcontrol->private_value;
2319 mutex_lock(&codec->mutex);
2321 if (ucontrol->value.integer.value[0])
2322 snd_soc_dapm_enable_pin(&codec->dapm, pin);
2324 snd_soc_dapm_disable_pin(&codec->dapm, pin);
2326 snd_soc_dapm_sync(&codec->dapm);
2328 mutex_unlock(&codec->mutex);
2332 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
2335 * snd_soc_dapm_new_control - create new dapm control
2336 * @dapm: DAPM context
2337 * @widget: widget template
2339 * Creates a new dapm control based upon the template.
2341 * Returns 0 for success else error.
2343 int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2344 const struct snd_soc_dapm_widget *widget)
2346 struct snd_soc_dapm_widget *w;
2349 if ((w = dapm_cnew_widget(widget)) == NULL)
2352 name_len = strlen(widget->name) + 1;
2353 if (dapm->codec && dapm->codec->name_prefix)
2354 name_len += 1 + strlen(dapm->codec->name_prefix);
2355 w->name = kmalloc(name_len, GFP_KERNEL);
2356 if (w->name == NULL) {
2360 if (dapm->codec && dapm->codec->name_prefix)
2361 snprintf(w->name, name_len, "%s %s",
2362 dapm->codec->name_prefix, widget->name);
2364 snprintf(w->name, name_len, "%s", widget->name);
2368 w->codec = dapm->codec;
2369 INIT_LIST_HEAD(&w->sources);
2370 INIT_LIST_HEAD(&w->sinks);
2371 INIT_LIST_HEAD(&w->list);
2372 list_add(&w->list, &dapm->card->widgets);
2374 /* machine layer set ups unconnected pins and insertions */
2378 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
2381 * snd_soc_dapm_new_controls - create new dapm controls
2382 * @dapm: DAPM context
2383 * @widget: widget array
2384 * @num: number of widgets
2386 * Creates new DAPM controls based upon the templates.
2388 * Returns 0 for success else error.
2390 int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
2391 const struct snd_soc_dapm_widget *widget,
2396 for (i = 0; i < num; i++) {
2397 ret = snd_soc_dapm_new_control(dapm, widget);
2400 "ASoC: Failed to create DAPM control %s: %d\n",
2408 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
2410 static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
2411 const char *stream, int event)
2413 struct snd_soc_dapm_widget *w;
2415 list_for_each_entry(w, &dapm->card->widgets, list)
2417 if (!w->sname || w->dapm != dapm)
2419 dev_dbg(w->dapm->dev, "widget %s\n %s stream %s event %d\n",
2420 w->name, w->sname, stream, event);
2421 if (strstr(w->sname, stream)) {
2423 case SND_SOC_DAPM_STREAM_START:
2426 case SND_SOC_DAPM_STREAM_STOP:
2429 case SND_SOC_DAPM_STREAM_SUSPEND:
2430 case SND_SOC_DAPM_STREAM_RESUME:
2431 case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
2432 case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
2438 dapm_power_widgets(dapm, event);
2442 * snd_soc_dapm_stream_event - send a stream event to the dapm core
2443 * @rtd: PCM runtime data
2444 * @stream: stream name
2445 * @event: stream event
2447 * Sends a stream event to the dapm core. The core then makes any
2448 * necessary widget power changes.
2450 * Returns 0 for success else error.
2452 int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
2453 const char *stream, int event)
2455 struct snd_soc_codec *codec = rtd->codec;
2460 mutex_lock(&codec->mutex);
2461 soc_dapm_stream_event(&codec->dapm, stream, event);
2462 mutex_unlock(&codec->mutex);
2467 * snd_soc_dapm_enable_pin - enable pin.
2468 * @dapm: DAPM context
2471 * Enables input/output pin and its parents or children widgets iff there is
2472 * a valid audio route and active audio stream.
2473 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2474 * do any widget power switching.
2476 int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
2478 return snd_soc_dapm_set_pin(dapm, pin, 1);
2480 EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
2483 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
2484 * @dapm: DAPM context
2487 * Enables input/output pin regardless of any other state. This is
2488 * intended for use with microphone bias supplies used in microphone
2491 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2492 * do any widget power switching.
2494 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
2497 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
2500 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
2504 dev_dbg(w->dapm->dev, "dapm: force enable pin %s\n", pin);
2510 EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
2513 * snd_soc_dapm_disable_pin - disable pin.
2514 * @dapm: DAPM context
2517 * Disables input/output pin and its parents or children widgets.
2518 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2519 * do any widget power switching.
2521 int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
2524 return snd_soc_dapm_set_pin(dapm, pin, 0);
2526 EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
2529 * snd_soc_dapm_nc_pin - permanently disable pin.
2530 * @dapm: DAPM context
2533 * Marks the specified pin as being not connected, disabling it along
2534 * any parent or child widgets. At present this is identical to
2535 * snd_soc_dapm_disable_pin() but in future it will be extended to do
2536 * additional things such as disabling controls which only affect
2537 * paths through the pin.
2539 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2540 * do any widget power switching.
2542 int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
2544 return snd_soc_dapm_set_pin(dapm, pin, 0);
2546 EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
2549 * snd_soc_dapm_get_pin_status - get audio pin status
2550 * @dapm: DAPM context
2551 * @pin: audio signal pin endpoint (or start point)
2553 * Get audio pin status - connected or disconnected.
2555 * Returns 1 for connected otherwise 0.
2557 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
2560 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
2563 return w->connected;
2567 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
2570 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
2571 * @dapm: DAPM context
2572 * @pin: audio signal pin endpoint (or start point)
2574 * Mark the given endpoint or pin as ignoring suspend. When the
2575 * system is disabled a path between two endpoints flagged as ignoring
2576 * suspend will not be disabled. The path must already be enabled via
2577 * normal means at suspend time, it will not be turned on if it was not
2580 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
2583 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false);
2586 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
2590 w->ignore_suspend = 1;
2594 EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
2597 * snd_soc_dapm_free - free dapm resources
2600 * Free all dapm widgets and resources.
2602 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
2604 snd_soc_dapm_sys_remove(dapm->dev);
2605 dapm_debugfs_cleanup(dapm);
2606 dapm_free_widgets(dapm);
2607 list_del(&dapm->list);
2609 EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
2611 static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
2613 struct snd_soc_dapm_widget *w;
2614 LIST_HEAD(down_list);
2617 list_for_each_entry(w, &dapm->card->widgets, list) {
2618 if (w->dapm != dapm)
2621 dapm_seq_insert(w, &down_list, false);
2627 /* If there were no widgets to power down we're already in
2631 snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_PREPARE);
2632 dapm_seq_run(dapm, &down_list, 0, false);
2633 snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_STANDBY);
2638 * snd_soc_dapm_shutdown - callback for system shutdown
2640 void snd_soc_dapm_shutdown(struct snd_soc_card *card)
2642 struct snd_soc_codec *codec;
2644 list_for_each_entry(codec, &card->codec_dev_list, list) {
2645 soc_dapm_shutdown_codec(&codec->dapm);
2646 snd_soc_dapm_set_bias_level(&codec->dapm, SND_SOC_BIAS_OFF);
2650 /* Module information */
2651 MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
2652 MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC");
2653 MODULE_LICENSE("GPL");