Revert "powerpc/ep8248e: Fix compile problem if !CONFIG_FS_ENET"
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / soc-dapm.c
blob2c87061c2a6b4d7b9c35d7479d782462a0d8b3c1
1 /*
2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * Features:
14 * o Changes power status of internal codec blocks depending on the
15 * dynamic configuration of codec internal audio paths and active
16 * DAC's/ADC's.
17 * o Platform power domain - can support external components i.e. amps and
18 * mic/meadphone insertion events.
19 * o Automatic Mic Bias support
20 * o Jack insertion power event initiation - e.g. hp insertion will enable
21 * sinks, dacs, etc
22 * o Delayed powerdown of audio susbsystem to reduce pops between a quick
23 * device reopen.
25 * Todo:
26 * o DAPM power change sequencing - allow for configurable per
27 * codec sequences.
28 * o Support for analogue bias optimisation.
29 * o Support for reduced codec oversampling rates.
30 * o Support for reduced codec bias currents.
33 #include <linux/module.h>
34 #include <linux/moduleparam.h>
35 #include <linux/init.h>
36 #include <linux/delay.h>
37 #include <linux/pm.h>
38 #include <linux/bitops.h>
39 #include <linux/platform_device.h>
40 #include <linux/jiffies.h>
41 #include <sound/core.h>
42 #include <sound/pcm.h>
43 #include <sound/pcm_params.h>
44 #include <sound/soc-dapm.h>
45 #include <sound/initval.h>
47 /* debug */
48 #ifdef DEBUG
49 #define dump_dapm(codec, action) dbg_dump_dapm(codec, action)
50 #else
51 #define dump_dapm(codec, action)
52 #endif
54 /* dapm power sequences - make this per codec in the future */
55 static int dapm_up_seq[] = {
56 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
57 snd_soc_dapm_mux, snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_pga,
58 snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post
60 static int dapm_down_seq[] = {
61 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
62 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic,
63 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post
66 static int dapm_status = 1;
67 module_param(dapm_status, int, 0);
68 MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
70 static unsigned int pop_time;
72 static void pop_wait(void)
74 if (pop_time)
75 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
78 static void pop_dbg(const char *fmt, ...)
80 va_list args;
82 va_start(args, fmt);
84 if (pop_time) {
85 vprintk(fmt, args);
86 pop_wait();
89 va_end(args);
92 /* create a new dapm widget */
93 static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
94 const struct snd_soc_dapm_widget *_widget)
96 return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
99 /* set up initial codec paths */
100 static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
101 struct snd_soc_dapm_path *p, int i)
103 switch (w->id) {
104 case snd_soc_dapm_switch:
105 case snd_soc_dapm_mixer: {
106 int val;
107 int reg = w->kcontrols[i].private_value & 0xff;
108 int shift = (w->kcontrols[i].private_value >> 8) & 0x0f;
109 int mask = (w->kcontrols[i].private_value >> 16) & 0xff;
110 int invert = (w->kcontrols[i].private_value >> 24) & 0x01;
112 val = snd_soc_read(w->codec, reg);
113 val = (val >> shift) & mask;
115 if ((invert && !val) || (!invert && val))
116 p->connect = 1;
117 else
118 p->connect = 0;
120 break;
121 case snd_soc_dapm_mux: {
122 struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value;
123 int val, item, bitmask;
125 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
127 val = snd_soc_read(w->codec, e->reg);
128 item = (val >> e->shift_l) & (bitmask - 1);
130 p->connect = 0;
131 for (i = 0; i < e->mask; i++) {
132 if (!(strcmp(p->name, e->texts[i])) && item == i)
133 p->connect = 1;
136 break;
137 /* does not effect routing - always connected */
138 case snd_soc_dapm_pga:
139 case snd_soc_dapm_output:
140 case snd_soc_dapm_adc:
141 case snd_soc_dapm_input:
142 case snd_soc_dapm_dac:
143 case snd_soc_dapm_micbias:
144 case snd_soc_dapm_vmid:
145 p->connect = 1;
146 break;
147 /* does effect routing - dynamically connected */
148 case snd_soc_dapm_hp:
149 case snd_soc_dapm_mic:
150 case snd_soc_dapm_spk:
151 case snd_soc_dapm_line:
152 case snd_soc_dapm_pre:
153 case snd_soc_dapm_post:
154 p->connect = 0;
155 break;
159 /* connect mux widget to it's interconnecting audio paths */
160 static int dapm_connect_mux(struct snd_soc_codec *codec,
161 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
162 struct snd_soc_dapm_path *path, const char *control_name,
163 const struct snd_kcontrol_new *kcontrol)
165 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
166 int i;
168 for (i = 0; i < e->mask; i++) {
169 if (!(strcmp(control_name, e->texts[i]))) {
170 list_add(&path->list, &codec->dapm_paths);
171 list_add(&path->list_sink, &dest->sources);
172 list_add(&path->list_source, &src->sinks);
173 path->name = (char*)e->texts[i];
174 dapm_set_path_status(dest, path, 0);
175 return 0;
179 return -ENODEV;
182 /* connect mixer widget to it's interconnecting audio paths */
183 static int dapm_connect_mixer(struct snd_soc_codec *codec,
184 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
185 struct snd_soc_dapm_path *path, const char *control_name)
187 int i;
189 /* search for mixer kcontrol */
190 for (i = 0; i < dest->num_kcontrols; i++) {
191 if (!strcmp(control_name, dest->kcontrols[i].name)) {
192 list_add(&path->list, &codec->dapm_paths);
193 list_add(&path->list_sink, &dest->sources);
194 list_add(&path->list_source, &src->sinks);
195 path->name = dest->kcontrols[i].name;
196 dapm_set_path_status(dest, path, i);
197 return 0;
200 return -ENODEV;
203 /* update dapm codec register bits */
204 static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
206 int change, power;
207 unsigned short old, new;
208 struct snd_soc_codec *codec = widget->codec;
210 /* check for valid widgets */
211 if (widget->reg < 0 || widget->id == snd_soc_dapm_input ||
212 widget->id == snd_soc_dapm_output ||
213 widget->id == snd_soc_dapm_hp ||
214 widget->id == snd_soc_dapm_mic ||
215 widget->id == snd_soc_dapm_line ||
216 widget->id == snd_soc_dapm_spk)
217 return 0;
219 power = widget->power;
220 if (widget->invert)
221 power = (power ? 0:1);
223 old = snd_soc_read(codec, widget->reg);
224 new = (old & ~(0x1 << widget->shift)) | (power << widget->shift);
226 change = old != new;
227 if (change) {
228 pop_dbg("pop test %s : %s in %d ms\n", widget->name,
229 widget->power ? "on" : "off", pop_time);
230 snd_soc_write(codec, widget->reg, new);
231 pop_wait();
233 pr_debug("reg %x old %x new %x change %d\n", widget->reg,
234 old, new, change);
235 return change;
238 /* ramps the volume up or down to minimise pops before or after a
239 * DAPM power event */
240 static int dapm_set_pga(struct snd_soc_dapm_widget *widget, int power)
242 const struct snd_kcontrol_new *k = widget->kcontrols;
244 if (widget->muted && !power)
245 return 0;
246 if (!widget->muted && power)
247 return 0;
249 if (widget->num_kcontrols && k) {
250 int reg = k->private_value & 0xff;
251 int shift = (k->private_value >> 8) & 0x0f;
252 int mask = (k->private_value >> 16) & 0xff;
253 int invert = (k->private_value >> 24) & 0x01;
255 if (power) {
256 int i;
257 /* power up has happended, increase volume to last level */
258 if (invert) {
259 for (i = mask; i > widget->saved_value; i--)
260 snd_soc_update_bits(widget->codec, reg, mask, i);
261 } else {
262 for (i = 0; i < widget->saved_value; i++)
263 snd_soc_update_bits(widget->codec, reg, mask, i);
265 widget->muted = 0;
266 } else {
267 /* power down is about to occur, decrease volume to mute */
268 int val = snd_soc_read(widget->codec, reg);
269 int i = widget->saved_value = (val >> shift) & mask;
270 if (invert) {
271 for (; i < mask; i++)
272 snd_soc_update_bits(widget->codec, reg, mask, i);
273 } else {
274 for (; i > 0; i--)
275 snd_soc_update_bits(widget->codec, reg, mask, i);
277 widget->muted = 1;
280 return 0;
283 /* create new dapm mixer control */
284 static int dapm_new_mixer(struct snd_soc_codec *codec,
285 struct snd_soc_dapm_widget *w)
287 int i, ret = 0;
288 char name[32];
289 struct snd_soc_dapm_path *path;
291 /* add kcontrol */
292 for (i = 0; i < w->num_kcontrols; i++) {
294 /* match name */
295 list_for_each_entry(path, &w->sources, list_sink) {
297 /* mixer/mux paths name must match control name */
298 if (path->name != (char*)w->kcontrols[i].name)
299 continue;
301 /* add dapm control with long name */
302 snprintf(name, 32, "%s %s", w->name, w->kcontrols[i].name);
303 path->long_name = kstrdup (name, GFP_KERNEL);
304 if (path->long_name == NULL)
305 return -ENOMEM;
307 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
308 path->long_name);
309 ret = snd_ctl_add(codec->card, path->kcontrol);
310 if (ret < 0) {
311 printk(KERN_ERR "asoc: failed to add dapm kcontrol %s\n",
312 path->long_name);
313 kfree(path->long_name);
314 path->long_name = NULL;
315 return ret;
319 return ret;
322 /* create new dapm mux control */
323 static int dapm_new_mux(struct snd_soc_codec *codec,
324 struct snd_soc_dapm_widget *w)
326 struct snd_soc_dapm_path *path = NULL;
327 struct snd_kcontrol *kcontrol;
328 int ret = 0;
330 if (!w->num_kcontrols) {
331 printk(KERN_ERR "asoc: mux %s has no controls\n", w->name);
332 return -EINVAL;
335 kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
336 ret = snd_ctl_add(codec->card, kcontrol);
337 if (ret < 0)
338 goto err;
340 list_for_each_entry(path, &w->sources, list_sink)
341 path->kcontrol = kcontrol;
343 return ret;
345 err:
346 printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name);
347 return ret;
350 /* create new dapm volume control */
351 static int dapm_new_pga(struct snd_soc_codec *codec,
352 struct snd_soc_dapm_widget *w)
354 struct snd_kcontrol *kcontrol;
355 int ret = 0;
357 if (!w->num_kcontrols)
358 return -EINVAL;
360 kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
361 ret = snd_ctl_add(codec->card, kcontrol);
362 if (ret < 0) {
363 printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name);
364 return ret;
367 return ret;
370 /* reset 'walked' bit for each dapm path */
371 static inline void dapm_clear_walk(struct snd_soc_codec *codec)
373 struct snd_soc_dapm_path *p;
375 list_for_each_entry(p, &codec->dapm_paths, list)
376 p->walked = 0;
380 * Recursively check for a completed path to an active or physically connected
381 * output widget. Returns number of complete paths.
383 static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
385 struct snd_soc_dapm_path *path;
386 int con = 0;
388 if (widget->id == snd_soc_dapm_adc && widget->active)
389 return 1;
391 if (widget->connected) {
392 /* connected pin ? */
393 if (widget->id == snd_soc_dapm_output && !widget->ext)
394 return 1;
396 /* connected jack or spk ? */
397 if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
398 widget->id == snd_soc_dapm_line)
399 return 1;
402 list_for_each_entry(path, &widget->sinks, list_source) {
403 if (path->walked)
404 continue;
406 if (path->sink && path->connect) {
407 path->walked = 1;
408 con += is_connected_output_ep(path->sink);
412 return con;
416 * Recursively check for a completed path to an active or physically connected
417 * input widget. Returns number of complete paths.
419 static int is_connected_input_ep(struct snd_soc_dapm_widget *widget)
421 struct snd_soc_dapm_path *path;
422 int con = 0;
424 /* active stream ? */
425 if (widget->id == snd_soc_dapm_dac && widget->active)
426 return 1;
428 if (widget->connected) {
429 /* connected pin ? */
430 if (widget->id == snd_soc_dapm_input && !widget->ext)
431 return 1;
433 /* connected VMID/Bias for lower pops */
434 if (widget->id == snd_soc_dapm_vmid)
435 return 1;
437 /* connected jack ? */
438 if (widget->id == snd_soc_dapm_mic || widget->id == snd_soc_dapm_line)
439 return 1;
442 list_for_each_entry(path, &widget->sources, list_sink) {
443 if (path->walked)
444 continue;
446 if (path->source && path->connect) {
447 path->walked = 1;
448 con += is_connected_input_ep(path->source);
452 return con;
456 * Handler for generic register modifier widget.
458 int dapm_reg_event(struct snd_soc_dapm_widget *w,
459 struct snd_kcontrol *kcontrol, int event)
461 unsigned int val;
463 if (SND_SOC_DAPM_EVENT_ON(event))
464 val = w->on_val;
465 else
466 val = w->off_val;
468 snd_soc_update_bits(w->codec, -(w->reg + 1),
469 w->mask << w->shift, val << w->shift);
471 return 0;
475 * Scan each dapm widget for complete audio path.
476 * A complete path is a route that has valid endpoints i.e.:-
478 * o DAC to output pin.
479 * o Input Pin to ADC.
480 * o Input pin to Output pin (bypass, sidetone)
481 * o DAC to ADC (loopback).
483 static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
485 struct snd_soc_dapm_widget *w;
486 int in, out, i, c = 1, *seq = NULL, ret = 0, power_change, power;
488 /* do we have a sequenced stream event */
489 if (event == SND_SOC_DAPM_STREAM_START) {
490 c = ARRAY_SIZE(dapm_up_seq);
491 seq = dapm_up_seq;
492 } else if (event == SND_SOC_DAPM_STREAM_STOP) {
493 c = ARRAY_SIZE(dapm_down_seq);
494 seq = dapm_down_seq;
497 for(i = 0; i < c; i++) {
498 list_for_each_entry(w, &codec->dapm_widgets, list) {
500 /* is widget in stream order */
501 if (seq && seq[i] && w->id != seq[i])
502 continue;
504 /* vmid - no action */
505 if (w->id == snd_soc_dapm_vmid)
506 continue;
508 /* active ADC */
509 if (w->id == snd_soc_dapm_adc && w->active) {
510 in = is_connected_input_ep(w);
511 dapm_clear_walk(w->codec);
512 w->power = (in != 0) ? 1 : 0;
513 dapm_update_bits(w);
514 continue;
517 /* active DAC */
518 if (w->id == snd_soc_dapm_dac && w->active) {
519 out = is_connected_output_ep(w);
520 dapm_clear_walk(w->codec);
521 w->power = (out != 0) ? 1 : 0;
522 dapm_update_bits(w);
523 continue;
526 /* programmable gain/attenuation */
527 if (w->id == snd_soc_dapm_pga) {
528 int on;
529 in = is_connected_input_ep(w);
530 dapm_clear_walk(w->codec);
531 out = is_connected_output_ep(w);
532 dapm_clear_walk(w->codec);
533 w->power = on = (out != 0 && in != 0) ? 1 : 0;
535 if (!on)
536 dapm_set_pga(w, on); /* lower volume to reduce pops */
537 dapm_update_bits(w);
538 if (on)
539 dapm_set_pga(w, on); /* restore volume from zero */
541 continue;
544 /* pre and post event widgets */
545 if (w->id == snd_soc_dapm_pre) {
546 if (!w->event)
547 continue;
549 if (event == SND_SOC_DAPM_STREAM_START) {
550 ret = w->event(w,
551 NULL, SND_SOC_DAPM_PRE_PMU);
552 if (ret < 0)
553 return ret;
554 } else if (event == SND_SOC_DAPM_STREAM_STOP) {
555 ret = w->event(w,
556 NULL, SND_SOC_DAPM_PRE_PMD);
557 if (ret < 0)
558 return ret;
560 continue;
562 if (w->id == snd_soc_dapm_post) {
563 if (!w->event)
564 continue;
566 if (event == SND_SOC_DAPM_STREAM_START) {
567 ret = w->event(w,
568 NULL, SND_SOC_DAPM_POST_PMU);
569 if (ret < 0)
570 return ret;
571 } else if (event == SND_SOC_DAPM_STREAM_STOP) {
572 ret = w->event(w,
573 NULL, SND_SOC_DAPM_POST_PMD);
574 if (ret < 0)
575 return ret;
577 continue;
580 /* all other widgets */
581 in = is_connected_input_ep(w);
582 dapm_clear_walk(w->codec);
583 out = is_connected_output_ep(w);
584 dapm_clear_walk(w->codec);
585 power = (out != 0 && in != 0) ? 1 : 0;
586 power_change = (w->power == power) ? 0: 1;
587 w->power = power;
589 /* call any power change event handlers */
590 if (power_change) {
591 if (w->event) {
592 pr_debug("power %s event for %s flags %x\n",
593 w->power ? "on" : "off", w->name, w->event_flags);
594 if (power) {
595 /* power up event */
596 if (w->event_flags & SND_SOC_DAPM_PRE_PMU) {
597 ret = w->event(w,
598 NULL, SND_SOC_DAPM_PRE_PMU);
599 if (ret < 0)
600 return ret;
602 dapm_update_bits(w);
603 if (w->event_flags & SND_SOC_DAPM_POST_PMU){
604 ret = w->event(w,
605 NULL, SND_SOC_DAPM_POST_PMU);
606 if (ret < 0)
607 return ret;
609 } else {
610 /* power down event */
611 if (w->event_flags & SND_SOC_DAPM_PRE_PMD) {
612 ret = w->event(w,
613 NULL, SND_SOC_DAPM_PRE_PMD);
614 if (ret < 0)
615 return ret;
617 dapm_update_bits(w);
618 if (w->event_flags & SND_SOC_DAPM_POST_PMD) {
619 ret = w->event(w,
620 NULL, SND_SOC_DAPM_POST_PMD);
621 if (ret < 0)
622 return ret;
625 } else
626 /* no event handler */
627 dapm_update_bits(w);
632 return ret;
635 #ifdef DEBUG
636 static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
638 struct snd_soc_dapm_widget *w;
639 struct snd_soc_dapm_path *p = NULL;
640 int in, out;
642 printk("DAPM %s %s\n", codec->name, action);
644 list_for_each_entry(w, &codec->dapm_widgets, list) {
646 /* only display widgets that effect routing */
647 switch (w->id) {
648 case snd_soc_dapm_pre:
649 case snd_soc_dapm_post:
650 case snd_soc_dapm_vmid:
651 continue;
652 case snd_soc_dapm_mux:
653 case snd_soc_dapm_output:
654 case snd_soc_dapm_input:
655 case snd_soc_dapm_switch:
656 case snd_soc_dapm_hp:
657 case snd_soc_dapm_mic:
658 case snd_soc_dapm_spk:
659 case snd_soc_dapm_line:
660 case snd_soc_dapm_micbias:
661 case snd_soc_dapm_dac:
662 case snd_soc_dapm_adc:
663 case snd_soc_dapm_pga:
664 case snd_soc_dapm_mixer:
665 if (w->name) {
666 in = is_connected_input_ep(w);
667 dapm_clear_walk(w->codec);
668 out = is_connected_output_ep(w);
669 dapm_clear_walk(w->codec);
670 printk("%s: %s in %d out %d\n", w->name,
671 w->power ? "On":"Off",in, out);
673 list_for_each_entry(p, &w->sources, list_sink) {
674 if (p->connect)
675 printk(" in %s %s\n", p->name ? p->name : "static",
676 p->source->name);
678 list_for_each_entry(p, &w->sinks, list_source) {
679 if (p->connect)
680 printk(" out %s %s\n", p->name ? p->name : "static",
681 p->sink->name);
684 break;
688 #endif
690 /* test and update the power status of a mux widget */
691 static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
692 struct snd_kcontrol *kcontrol, int mask,
693 int val, struct soc_enum* e)
695 struct snd_soc_dapm_path *path;
696 int found = 0;
698 if (widget->id != snd_soc_dapm_mux)
699 return -ENODEV;
701 if (!snd_soc_test_bits(widget->codec, e->reg, mask, val))
702 return 0;
704 /* find dapm widget path assoc with kcontrol */
705 list_for_each_entry(path, &widget->codec->dapm_paths, list) {
706 if (path->kcontrol != kcontrol)
707 continue;
709 if (!path->name || ! e->texts[val])
710 continue;
712 found = 1;
713 /* we now need to match the string in the enum to the path */
714 if (!(strcmp(path->name, e->texts[val])))
715 path->connect = 1; /* new connection */
716 else
717 path->connect = 0; /* old connection must be powered down */
720 if (found) {
721 dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
722 dump_dapm(widget->codec, "mux power update");
725 return 0;
728 /* test and update the power status of a mixer or switch widget */
729 static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
730 struct snd_kcontrol *kcontrol, int reg,
731 int val_mask, int val, int invert)
733 struct snd_soc_dapm_path *path;
734 int found = 0;
736 if (widget->id != snd_soc_dapm_mixer &&
737 widget->id != snd_soc_dapm_switch)
738 return -ENODEV;
740 if (!snd_soc_test_bits(widget->codec, reg, val_mask, val))
741 return 0;
743 /* find dapm widget path assoc with kcontrol */
744 list_for_each_entry(path, &widget->codec->dapm_paths, list) {
745 if (path->kcontrol != kcontrol)
746 continue;
748 /* found, now check type */
749 found = 1;
750 if (val)
751 /* new connection */
752 path->connect = invert ? 0:1;
753 else
754 /* old connection must be powered down */
755 path->connect = invert ? 1:0;
756 break;
759 if (found) {
760 dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
761 dump_dapm(widget->codec, "mixer power update");
764 return 0;
767 /* show dapm widget status in sys fs */
768 static ssize_t dapm_widget_show(struct device *dev,
769 struct device_attribute *attr, char *buf)
771 struct snd_soc_device *devdata = dev_get_drvdata(dev);
772 struct snd_soc_codec *codec = devdata->codec;
773 struct snd_soc_dapm_widget *w;
774 int count = 0;
775 char *state = "not set";
777 list_for_each_entry(w, &codec->dapm_widgets, list) {
779 /* only display widgets that burnm power */
780 switch (w->id) {
781 case snd_soc_dapm_hp:
782 case snd_soc_dapm_mic:
783 case snd_soc_dapm_spk:
784 case snd_soc_dapm_line:
785 case snd_soc_dapm_micbias:
786 case snd_soc_dapm_dac:
787 case snd_soc_dapm_adc:
788 case snd_soc_dapm_pga:
789 case snd_soc_dapm_mixer:
790 if (w->name)
791 count += sprintf(buf + count, "%s: %s\n",
792 w->name, w->power ? "On":"Off");
793 break;
794 default:
795 break;
799 switch (codec->bias_level) {
800 case SND_SOC_BIAS_ON:
801 state = "On";
802 break;
803 case SND_SOC_BIAS_PREPARE:
804 state = "Prepare";
805 break;
806 case SND_SOC_BIAS_STANDBY:
807 state = "Standby";
808 break;
809 case SND_SOC_BIAS_OFF:
810 state = "Off";
811 break;
813 count += sprintf(buf + count, "PM State: %s\n", state);
815 return count;
818 static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
820 /* pop/click delay times */
821 static ssize_t dapm_pop_time_show(struct device *dev,
822 struct device_attribute *attr, char *buf)
824 return sprintf(buf, "%d\n", pop_time);
827 static ssize_t dapm_pop_time_store(struct device *dev,
828 struct device_attribute *attr,
829 const char *buf, size_t count)
832 unsigned long val;
834 if (strict_strtoul(buf, 10, &val) >= 0)
835 pop_time = val;
836 else
837 printk(KERN_ERR "Unable to parse pop_time setting\n");
839 return count;
842 static DEVICE_ATTR(dapm_pop_time, 0744, dapm_pop_time_show,
843 dapm_pop_time_store);
845 int snd_soc_dapm_sys_add(struct device *dev)
847 int ret = 0;
849 if (dapm_status) {
850 ret = device_create_file(dev, &dev_attr_dapm_widget);
852 if (ret == 0)
853 ret = device_create_file(dev, &dev_attr_dapm_pop_time);
856 return ret;
859 static void snd_soc_dapm_sys_remove(struct device *dev)
861 if (dapm_status) {
862 device_remove_file(dev, &dev_attr_dapm_pop_time);
863 device_remove_file(dev, &dev_attr_dapm_widget);
867 /* free all dapm widgets and resources */
868 static void dapm_free_widgets(struct snd_soc_codec *codec)
870 struct snd_soc_dapm_widget *w, *next_w;
871 struct snd_soc_dapm_path *p, *next_p;
873 list_for_each_entry_safe(w, next_w, &codec->dapm_widgets, list) {
874 list_del(&w->list);
875 kfree(w);
878 list_for_each_entry_safe(p, next_p, &codec->dapm_paths, list) {
879 list_del(&p->list);
880 kfree(p->long_name);
881 kfree(p);
885 static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
886 char *pin, int status)
888 struct snd_soc_dapm_widget *w;
890 list_for_each_entry(w, &codec->dapm_widgets, list) {
891 if (!strcmp(w->name, pin)) {
892 pr_debug("dapm: %s: pin %s\n", codec->name, pin);
893 w->connected = status;
894 return 0;
898 pr_err("dapm: %s: configuring unknown pin %s\n", codec->name, pin);
899 return -EINVAL;
903 * snd_soc_dapm_sync - scan and power dapm paths
904 * @codec: audio codec
906 * Walks all dapm audio paths and powers widgets according to their
907 * stream or path usage.
909 * Returns 0 for success.
911 int snd_soc_dapm_sync(struct snd_soc_codec *codec)
913 int ret = dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
914 dump_dapm(codec, "sync");
915 return ret;
917 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
919 static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
920 const char *sink, const char *control, const char *source)
922 struct snd_soc_dapm_path *path;
923 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
924 int ret = 0;
926 /* find src and dest widgets */
927 list_for_each_entry(w, &codec->dapm_widgets, list) {
929 if (!wsink && !(strcmp(w->name, sink))) {
930 wsink = w;
931 continue;
933 if (!wsource && !(strcmp(w->name, source))) {
934 wsource = w;
938 if (wsource == NULL || wsink == NULL)
939 return -ENODEV;
941 path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
942 if (!path)
943 return -ENOMEM;
945 path->source = wsource;
946 path->sink = wsink;
947 INIT_LIST_HEAD(&path->list);
948 INIT_LIST_HEAD(&path->list_source);
949 INIT_LIST_HEAD(&path->list_sink);
951 /* check for external widgets */
952 if (wsink->id == snd_soc_dapm_input) {
953 if (wsource->id == snd_soc_dapm_micbias ||
954 wsource->id == snd_soc_dapm_mic ||
955 wsink->id == snd_soc_dapm_line ||
956 wsink->id == snd_soc_dapm_output)
957 wsink->ext = 1;
959 if (wsource->id == snd_soc_dapm_output) {
960 if (wsink->id == snd_soc_dapm_spk ||
961 wsink->id == snd_soc_dapm_hp ||
962 wsink->id == snd_soc_dapm_line ||
963 wsink->id == snd_soc_dapm_input)
964 wsource->ext = 1;
967 /* connect static paths */
968 if (control == NULL) {
969 list_add(&path->list, &codec->dapm_paths);
970 list_add(&path->list_sink, &wsink->sources);
971 list_add(&path->list_source, &wsource->sinks);
972 path->connect = 1;
973 return 0;
976 /* connect dynamic paths */
977 switch(wsink->id) {
978 case snd_soc_dapm_adc:
979 case snd_soc_dapm_dac:
980 case snd_soc_dapm_pga:
981 case snd_soc_dapm_input:
982 case snd_soc_dapm_output:
983 case snd_soc_dapm_micbias:
984 case snd_soc_dapm_vmid:
985 case snd_soc_dapm_pre:
986 case snd_soc_dapm_post:
987 list_add(&path->list, &codec->dapm_paths);
988 list_add(&path->list_sink, &wsink->sources);
989 list_add(&path->list_source, &wsource->sinks);
990 path->connect = 1;
991 return 0;
992 case snd_soc_dapm_mux:
993 ret = dapm_connect_mux(codec, wsource, wsink, path, control,
994 &wsink->kcontrols[0]);
995 if (ret != 0)
996 goto err;
997 break;
998 case snd_soc_dapm_switch:
999 case snd_soc_dapm_mixer:
1000 ret = dapm_connect_mixer(codec, wsource, wsink, path, control);
1001 if (ret != 0)
1002 goto err;
1003 break;
1004 case snd_soc_dapm_hp:
1005 case snd_soc_dapm_mic:
1006 case snd_soc_dapm_line:
1007 case snd_soc_dapm_spk:
1008 list_add(&path->list, &codec->dapm_paths);
1009 list_add(&path->list_sink, &wsink->sources);
1010 list_add(&path->list_source, &wsource->sinks);
1011 path->connect = 0;
1012 return 0;
1014 return 0;
1016 err:
1017 printk(KERN_WARNING "asoc: no dapm match for %s --> %s --> %s\n", source,
1018 control, sink);
1019 kfree(path);
1020 return ret;
1024 * snd_soc_dapm_connect_input - connect dapm widgets
1025 * @codec: audio codec
1026 * @sink: name of target widget
1027 * @control: mixer control name
1028 * @source: name of source name
1030 * Connects 2 dapm widgets together via a named audio path. The sink is
1031 * the widget receiving the audio signal, whilst the source is the sender
1032 * of the audio signal.
1034 * This function has been deprecated in favour of snd_soc_dapm_add_routes().
1036 * Returns 0 for success else error.
1038 int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
1039 const char *control, const char *source)
1041 return snd_soc_dapm_add_route(codec, sink, control, source);
1043 EXPORT_SYMBOL_GPL(snd_soc_dapm_connect_input);
1046 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
1047 * @codec: codec
1048 * @route: audio routes
1049 * @num: number of routes
1051 * Connects 2 dapm widgets together via a named audio path. The sink is
1052 * the widget receiving the audio signal, whilst the source is the sender
1053 * of the audio signal.
1055 * Returns 0 for success else error. On error all resources can be freed
1056 * with a call to snd_soc_card_free().
1058 int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,
1059 const struct snd_soc_dapm_route *route, int num)
1061 int i, ret;
1063 for (i = 0; i < num; i++) {
1064 ret = snd_soc_dapm_add_route(codec, route->sink,
1065 route->control, route->source);
1066 if (ret < 0) {
1067 printk(KERN_ERR "Failed to add route %s->%s\n",
1068 route->source,
1069 route->sink);
1070 return ret;
1072 route++;
1075 return 0;
1077 EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
1080 * snd_soc_dapm_new_widgets - add new dapm widgets
1081 * @codec: audio codec
1083 * Checks the codec for any new dapm widgets and creates them if found.
1085 * Returns 0 for success.
1087 int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1089 struct snd_soc_dapm_widget *w;
1091 list_for_each_entry(w, &codec->dapm_widgets, list)
1093 if (w->new)
1094 continue;
1096 switch(w->id) {
1097 case snd_soc_dapm_switch:
1098 case snd_soc_dapm_mixer:
1099 dapm_new_mixer(codec, w);
1100 break;
1101 case snd_soc_dapm_mux:
1102 dapm_new_mux(codec, w);
1103 break;
1104 case snd_soc_dapm_adc:
1105 case snd_soc_dapm_dac:
1106 case snd_soc_dapm_pga:
1107 dapm_new_pga(codec, w);
1108 break;
1109 case snd_soc_dapm_input:
1110 case snd_soc_dapm_output:
1111 case snd_soc_dapm_micbias:
1112 case snd_soc_dapm_spk:
1113 case snd_soc_dapm_hp:
1114 case snd_soc_dapm_mic:
1115 case snd_soc_dapm_line:
1116 case snd_soc_dapm_vmid:
1117 case snd_soc_dapm_pre:
1118 case snd_soc_dapm_post:
1119 break;
1121 w->new = 1;
1124 dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
1125 return 0;
1127 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
1130 * snd_soc_dapm_get_volsw - dapm mixer get callback
1131 * @kcontrol: mixer control
1132 * @uinfo: control element information
1134 * Callback to get the value of a dapm mixer control.
1136 * Returns 0 for success.
1138 int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
1139 struct snd_ctl_elem_value *ucontrol)
1141 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1142 int reg = kcontrol->private_value & 0xff;
1143 int shift = (kcontrol->private_value >> 8) & 0x0f;
1144 int rshift = (kcontrol->private_value >> 12) & 0x0f;
1145 int max = (kcontrol->private_value >> 16) & 0xff;
1146 int invert = (kcontrol->private_value >> 24) & 0x01;
1147 int mask = (1 << fls(max)) - 1;
1149 /* return the saved value if we are powered down */
1150 if (widget->id == snd_soc_dapm_pga && !widget->power) {
1151 ucontrol->value.integer.value[0] = widget->saved_value;
1152 return 0;
1155 ucontrol->value.integer.value[0] =
1156 (snd_soc_read(widget->codec, reg) >> shift) & mask;
1157 if (shift != rshift)
1158 ucontrol->value.integer.value[1] =
1159 (snd_soc_read(widget->codec, reg) >> rshift) & mask;
1160 if (invert) {
1161 ucontrol->value.integer.value[0] =
1162 max - ucontrol->value.integer.value[0];
1163 if (shift != rshift)
1164 ucontrol->value.integer.value[1] =
1165 max - ucontrol->value.integer.value[1];
1168 return 0;
1170 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
1173 * snd_soc_dapm_put_volsw - dapm mixer set callback
1174 * @kcontrol: mixer control
1175 * @uinfo: control element information
1177 * Callback to set the value of a dapm mixer control.
1179 * Returns 0 for success.
1181 int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
1182 struct snd_ctl_elem_value *ucontrol)
1184 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1185 int reg = kcontrol->private_value & 0xff;
1186 int shift = (kcontrol->private_value >> 8) & 0x0f;
1187 int rshift = (kcontrol->private_value >> 12) & 0x0f;
1188 int max = (kcontrol->private_value >> 16) & 0xff;
1189 int mask = (1 << fls(max)) - 1;
1190 int invert = (kcontrol->private_value >> 24) & 0x01;
1191 unsigned short val, val2, val_mask;
1192 int ret;
1194 val = (ucontrol->value.integer.value[0] & mask);
1196 if (invert)
1197 val = max - val;
1198 val_mask = mask << shift;
1199 val = val << shift;
1200 if (shift != rshift) {
1201 val2 = (ucontrol->value.integer.value[1] & mask);
1202 if (invert)
1203 val2 = max - val2;
1204 val_mask |= mask << rshift;
1205 val |= val2 << rshift;
1208 mutex_lock(&widget->codec->mutex);
1209 widget->value = val;
1211 /* save volume value if the widget is powered down */
1212 if (widget->id == snd_soc_dapm_pga && !widget->power) {
1213 widget->saved_value = val;
1214 mutex_unlock(&widget->codec->mutex);
1215 return 1;
1218 dapm_mixer_update_power(widget, kcontrol, reg, val_mask, val, invert);
1219 if (widget->event) {
1220 if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
1221 ret = widget->event(widget, kcontrol,
1222 SND_SOC_DAPM_PRE_REG);
1223 if (ret < 0) {
1224 ret = 1;
1225 goto out;
1228 ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
1229 if (widget->event_flags & SND_SOC_DAPM_POST_REG)
1230 ret = widget->event(widget, kcontrol,
1231 SND_SOC_DAPM_POST_REG);
1232 } else
1233 ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
1235 out:
1236 mutex_unlock(&widget->codec->mutex);
1237 return ret;
1239 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
1242 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
1243 * @kcontrol: mixer control
1244 * @uinfo: control element information
1246 * Callback to get the value of a dapm enumerated double mixer control.
1248 * Returns 0 for success.
1250 int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
1251 struct snd_ctl_elem_value *ucontrol)
1253 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1254 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1255 unsigned short val, bitmask;
1257 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
1259 val = snd_soc_read(widget->codec, e->reg);
1260 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
1261 if (e->shift_l != e->shift_r)
1262 ucontrol->value.enumerated.item[1] =
1263 (val >> e->shift_r) & (bitmask - 1);
1265 return 0;
1267 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
1270 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
1271 * @kcontrol: mixer control
1272 * @uinfo: control element information
1274 * Callback to set the value of a dapm enumerated double mixer control.
1276 * Returns 0 for success.
1278 int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
1279 struct snd_ctl_elem_value *ucontrol)
1281 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1282 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1283 unsigned short val, mux;
1284 unsigned short mask, bitmask;
1285 int ret = 0;
1287 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
1289 if (ucontrol->value.enumerated.item[0] > e->mask - 1)
1290 return -EINVAL;
1291 mux = ucontrol->value.enumerated.item[0];
1292 val = mux << e->shift_l;
1293 mask = (bitmask - 1) << e->shift_l;
1294 if (e->shift_l != e->shift_r) {
1295 if (ucontrol->value.enumerated.item[1] > e->mask - 1)
1296 return -EINVAL;
1297 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
1298 mask |= (bitmask - 1) << e->shift_r;
1301 mutex_lock(&widget->codec->mutex);
1302 widget->value = val;
1303 dapm_mux_update_power(widget, kcontrol, mask, mux, e);
1304 if (widget->event) {
1305 if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
1306 ret = widget->event(widget,
1307 kcontrol, SND_SOC_DAPM_PRE_REG);
1308 if (ret < 0)
1309 goto out;
1311 ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
1312 if (widget->event_flags & SND_SOC_DAPM_POST_REG)
1313 ret = widget->event(widget,
1314 kcontrol, SND_SOC_DAPM_POST_REG);
1315 } else
1316 ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
1318 out:
1319 mutex_unlock(&widget->codec->mutex);
1320 return ret;
1322 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
1325 * snd_soc_dapm_new_control - create new dapm control
1326 * @codec: audio codec
1327 * @widget: widget template
1329 * Creates a new dapm control based upon the template.
1331 * Returns 0 for success else error.
1333 int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
1334 const struct snd_soc_dapm_widget *widget)
1336 struct snd_soc_dapm_widget *w;
1338 if ((w = dapm_cnew_widget(widget)) == NULL)
1339 return -ENOMEM;
1341 w->codec = codec;
1342 INIT_LIST_HEAD(&w->sources);
1343 INIT_LIST_HEAD(&w->sinks);
1344 INIT_LIST_HEAD(&w->list);
1345 list_add(&w->list, &codec->dapm_widgets);
1347 /* machine layer set ups unconnected pins and insertions */
1348 w->connected = 1;
1349 return 0;
1351 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
1354 * snd_soc_dapm_new_controls - create new dapm controls
1355 * @codec: audio codec
1356 * @widget: widget array
1357 * @num: number of widgets
1359 * Creates new DAPM controls based upon the templates.
1361 * Returns 0 for success else error.
1363 int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
1364 const struct snd_soc_dapm_widget *widget,
1365 int num)
1367 int i, ret;
1369 for (i = 0; i < num; i++) {
1370 ret = snd_soc_dapm_new_control(codec, widget);
1371 if (ret < 0)
1372 return ret;
1373 widget++;
1375 return 0;
1377 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
1381 * snd_soc_dapm_stream_event - send a stream event to the dapm core
1382 * @codec: audio codec
1383 * @stream: stream name
1384 * @event: stream event
1386 * Sends a stream event to the dapm core. The core then makes any
1387 * necessary widget power changes.
1389 * Returns 0 for success else error.
1391 int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
1392 char *stream, int event)
1394 struct snd_soc_dapm_widget *w;
1396 if (stream == NULL)
1397 return 0;
1399 mutex_lock(&codec->mutex);
1400 list_for_each_entry(w, &codec->dapm_widgets, list)
1402 if (!w->sname)
1403 continue;
1404 pr_debug("widget %s\n %s stream %s event %d\n",
1405 w->name, w->sname, stream, event);
1406 if (strstr(w->sname, stream)) {
1407 switch(event) {
1408 case SND_SOC_DAPM_STREAM_START:
1409 w->active = 1;
1410 break;
1411 case SND_SOC_DAPM_STREAM_STOP:
1412 w->active = 0;
1413 break;
1414 case SND_SOC_DAPM_STREAM_SUSPEND:
1415 if (w->active)
1416 w->suspend = 1;
1417 w->active = 0;
1418 break;
1419 case SND_SOC_DAPM_STREAM_RESUME:
1420 if (w->suspend) {
1421 w->active = 1;
1422 w->suspend = 0;
1424 break;
1425 case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
1426 break;
1427 case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
1428 break;
1432 mutex_unlock(&codec->mutex);
1434 dapm_power_widgets(codec, event);
1435 dump_dapm(codec, __func__);
1436 return 0;
1438 EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
1441 * snd_soc_dapm_set_bias_level - set the bias level for the system
1442 * @socdev: audio device
1443 * @level: level to configure
1445 * Configure the bias (power) levels for the SoC audio device.
1447 * Returns 0 for success else error.
1449 int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1450 enum snd_soc_bias_level level)
1452 struct snd_soc_codec *codec = socdev->codec;
1453 struct snd_soc_machine *machine = socdev->machine;
1454 int ret = 0;
1456 if (machine->set_bias_level)
1457 ret = machine->set_bias_level(machine, level);
1458 if (ret == 0 && codec->set_bias_level)
1459 ret = codec->set_bias_level(codec, level);
1461 return ret;
1465 * snd_soc_dapm_enable_pin - enable pin.
1466 * @snd_soc_codec: SoC codec
1467 * @pin: pin name
1469 * Enables input/output pin and it's parents or children widgets iff there is
1470 * a valid audio route and active audio stream.
1471 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1472 * do any widget power switching.
1474 int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin)
1476 return snd_soc_dapm_set_pin(codec, pin, 1);
1478 EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
1481 * snd_soc_dapm_disable_pin - disable pin.
1482 * @codec: SoC codec
1483 * @pin: pin name
1485 * Disables input/output pin and it's parents or children widgets.
1486 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1487 * do any widget power switching.
1489 int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin)
1491 return snd_soc_dapm_set_pin(codec, pin, 0);
1493 EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
1496 * snd_soc_dapm_get_pin_status - get audio pin status
1497 * @codec: audio codec
1498 * @pin: audio signal pin endpoint (or start point)
1500 * Get audio pin status - connected or disconnected.
1502 * Returns 1 for connected otherwise 0.
1504 int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin)
1506 struct snd_soc_dapm_widget *w;
1508 list_for_each_entry(w, &codec->dapm_widgets, list) {
1509 if (!strcmp(w->name, pin))
1510 return w->connected;
1513 return 0;
1515 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
1518 * snd_soc_dapm_free - free dapm resources
1519 * @socdev: SoC device
1521 * Free all dapm widgets and resources.
1523 void snd_soc_dapm_free(struct snd_soc_device *socdev)
1525 struct snd_soc_codec *codec = socdev->codec;
1527 snd_soc_dapm_sys_remove(socdev->dev);
1528 dapm_free_widgets(codec);
1530 EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
1532 /* Module information */
1533 MODULE_AUTHOR("Liam Girdwood, liam.girdwood@wolfsonmicro.com, www.wolfsonmicro.com");
1534 MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC");
1535 MODULE_LICENSE("GPL");