aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-11-05 09:53:46 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-06 11:28:29 -0400
commitce6120cca2589ede530200c7cfe11ac9f144333c (patch)
tree6ea7c26ce64dd4753e7cf9a3b048e74614b169dc /sound/soc/soc-dapm.c
parent22e2fda5660cdf62513acabdb5c82a5af415f838 (diff)
ASoC: Decouple DAPM from CODECs
Decoupling Dynamic Audio Power Management (DAPM) from codec devices is required when developing ASoC further. Such as for other ASoC components to have DAPM widgets or when extending DAPM to handle cross-device paths. This patch decouples DAPM related variables from struct snd_soc_codec and moves them to new struct snd_soc_dapm_context that is used to encapsulate DAPM context of a device. ASoC core and API of DAPM functions are modified to use DAPM context instead of codec. This patch does not change current functionality and a large part of changes come because of structure and internal API changes. Core implementation is from Liam Girdwood <lrg@slimlogic.co.uk> with some minor core changes, codecs and machine driver conversions from Jarkko Nikula <jhnikula@gmail.com>. Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Manuel Lauss <manuel.lauss@googlemail.com> Cc: Mike Frysinger <vapier.adi@gmail.com> Cc: Cliff Cai <cliff.cai@analog.com> Cc: Kevin Hilman <khilman@deeprootsystems.com> Cc: Ryan Mallon <ryan@bluewatersys.com> Cc: Timur Tabi <timur@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> Cc: Wan ZongShun <mcuos.com@gmail.com> Cc: Eric Miao <eric.y.miao@gmail.com> Cc: Jassi Brar <jassi.brar@samsung.com> Cc: Daniel Gloeckner <dg@emlix.com> Cc: Kuninori Morimoto <morimoto.kuninori@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c355
1 files changed, 187 insertions, 168 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7d85c6496afa..b8f653eaffaa 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -42,6 +42,7 @@
42#include <sound/core.h> 42#include <sound/core.h>
43#include <sound/pcm.h> 43#include <sound/pcm.h>
44#include <sound/pcm_params.h> 44#include <sound/pcm_params.h>
45#include <sound/soc.h>
45#include <sound/soc-dapm.h> 46#include <sound/soc-dapm.h>
46#include <sound/initval.h> 47#include <sound/initval.h>
47 48
@@ -120,35 +121,36 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
120 * Returns 0 for success else error. 121 * Returns 0 for success else error.
121 */ 122 */
122static int snd_soc_dapm_set_bias_level(struct snd_soc_card *card, 123static int snd_soc_dapm_set_bias_level(struct snd_soc_card *card,
123 struct snd_soc_codec *codec, enum snd_soc_bias_level level) 124 struct snd_soc_dapm_context *dapm,
125 enum snd_soc_bias_level level)
124{ 126{
125 int ret = 0; 127 int ret = 0;
126 128
127 switch (level) { 129 switch (level) {
128 case SND_SOC_BIAS_ON: 130 case SND_SOC_BIAS_ON:
129 dev_dbg(codec->dev, "Setting full bias\n"); 131 dev_dbg(dapm->dev, "Setting full bias\n");
130 break; 132 break;
131 case SND_SOC_BIAS_PREPARE: 133 case SND_SOC_BIAS_PREPARE:
132 dev_dbg(codec->dev, "Setting bias prepare\n"); 134 dev_dbg(dapm->dev, "Setting bias prepare\n");
133 break; 135 break;
134 case SND_SOC_BIAS_STANDBY: 136 case SND_SOC_BIAS_STANDBY:
135 dev_dbg(codec->dev, "Setting standby bias\n"); 137 dev_dbg(dapm->dev, "Setting standby bias\n");
136 break; 138 break;
137 case SND_SOC_BIAS_OFF: 139 case SND_SOC_BIAS_OFF:
138 dev_dbg(codec->dev, "Setting bias off\n"); 140 dev_dbg(dapm->dev, "Setting bias off\n");
139 break; 141 break;
140 default: 142 default:
141 dev_err(codec->dev, "Setting invalid bias %d\n", level); 143 dev_err(dapm->dev, "Setting invalid bias %d\n", level);
142 return -EINVAL; 144 return -EINVAL;
143 } 145 }
144 146
145 if (card && card->set_bias_level) 147 if (card && card->set_bias_level)
146 ret = card->set_bias_level(card, level); 148 ret = card->set_bias_level(card, level);
147 if (ret == 0) { 149 if (ret == 0) {
148 if (codec->driver->set_bias_level) 150 if (dapm->codec && dapm->codec->driver->set_bias_level)
149 ret = codec->driver->set_bias_level(codec, level); 151 ret = dapm->codec->driver->set_bias_level(dapm->codec, level);
150 else 152 else
151 codec->bias_level = level; 153 dapm->bias_level = level;
152 } 154 }
153 155
154 return ret; 156 return ret;
@@ -241,7 +243,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
241} 243}
242 244
243/* connect mux widget to its interconnecting audio paths */ 245/* connect mux widget to its interconnecting audio paths */
244static int dapm_connect_mux(struct snd_soc_codec *codec, 246static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
245 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, 247 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
246 struct snd_soc_dapm_path *path, const char *control_name, 248 struct snd_soc_dapm_path *path, const char *control_name,
247 const struct snd_kcontrol_new *kcontrol) 249 const struct snd_kcontrol_new *kcontrol)
@@ -251,7 +253,7 @@ static int dapm_connect_mux(struct snd_soc_codec *codec,
251 253
252 for (i = 0; i < e->max; i++) { 254 for (i = 0; i < e->max; i++) {
253 if (!(strcmp(control_name, e->texts[i]))) { 255 if (!(strcmp(control_name, e->texts[i]))) {
254 list_add(&path->list, &codec->dapm_paths); 256 list_add(&path->list, &dapm->paths);
255 list_add(&path->list_sink, &dest->sources); 257 list_add(&path->list_sink, &dest->sources);
256 list_add(&path->list_source, &src->sinks); 258 list_add(&path->list_source, &src->sinks);
257 path->name = (char*)e->texts[i]; 259 path->name = (char*)e->texts[i];
@@ -264,7 +266,7 @@ static int dapm_connect_mux(struct snd_soc_codec *codec,
264} 266}
265 267
266/* connect mixer widget to its interconnecting audio paths */ 268/* connect mixer widget to its interconnecting audio paths */
267static int dapm_connect_mixer(struct snd_soc_codec *codec, 269static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
268 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, 270 struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
269 struct snd_soc_dapm_path *path, const char *control_name) 271 struct snd_soc_dapm_path *path, const char *control_name)
270{ 272{
@@ -273,7 +275,7 @@ static int dapm_connect_mixer(struct snd_soc_codec *codec,
273 /* search for mixer kcontrol */ 275 /* search for mixer kcontrol */
274 for (i = 0; i < dest->num_kcontrols; i++) { 276 for (i = 0; i < dest->num_kcontrols; i++) {
275 if (!strcmp(control_name, dest->kcontrols[i].name)) { 277 if (!strcmp(control_name, dest->kcontrols[i].name)) {
276 list_add(&path->list, &codec->dapm_paths); 278 list_add(&path->list, &dapm->paths);
277 list_add(&path->list_sink, &dest->sources); 279 list_add(&path->list_sink, &dest->sources);
278 list_add(&path->list_source, &src->sinks); 280 list_add(&path->list_source, &src->sinks);
279 path->name = dest->kcontrols[i].name; 281 path->name = dest->kcontrols[i].name;
@@ -290,6 +292,7 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
290 int change, power; 292 int change, power;
291 unsigned int old, new; 293 unsigned int old, new;
292 struct snd_soc_codec *codec = widget->codec; 294 struct snd_soc_codec *codec = widget->codec;
295 struct snd_soc_dapm_context *dapm = widget->dapm;
293 296
294 /* check for valid widgets */ 297 /* check for valid widgets */
295 if (widget->reg < 0 || widget->id == snd_soc_dapm_input || 298 if (widget->reg < 0 || widget->id == snd_soc_dapm_input ||
@@ -309,10 +312,10 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
309 312
310 change = old != new; 313 change = old != new;
311 if (change) { 314 if (change) {
312 pop_dbg(codec->pop_time, "pop test %s : %s in %d ms\n", 315 pop_dbg(dapm->pop_time, "pop test %s : %s in %d ms\n",
313 widget->name, widget->power ? "on" : "off", 316 widget->name, widget->power ? "on" : "off",
314 codec->pop_time); 317 dapm->pop_time);
315 pop_wait(codec->pop_time); 318 pop_wait(dapm->pop_time);
316 snd_soc_write(codec, widget->reg, new); 319 snd_soc_write(codec, widget->reg, new);
317 } 320 }
318 pr_debug("reg %x old %x new %x change %d\n", widget->reg, 321 pr_debug("reg %x old %x new %x change %d\n", widget->reg,
@@ -321,12 +324,13 @@ static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
321} 324}
322 325
323/* create new dapm mixer control */ 326/* create new dapm mixer control */
324static int dapm_new_mixer(struct snd_soc_codec *codec, 327static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
325 struct snd_soc_dapm_widget *w) 328 struct snd_soc_dapm_widget *w)
326{ 329{
327 int i, ret = 0; 330 int i, ret = 0;
328 size_t name_len; 331 size_t name_len;
329 struct snd_soc_dapm_path *path; 332 struct snd_soc_dapm_path *path;
333 struct snd_card *card = dapm->codec->card->snd_card;
330 334
331 /* add kcontrol */ 335 /* add kcontrol */
332 for (i = 0; i < w->num_kcontrols; i++) { 336 for (i = 0; i < w->num_kcontrols; i++) {
@@ -368,7 +372,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
368 372
369 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, 373 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
370 path->long_name); 374 path->long_name);
371 ret = snd_ctl_add(codec->card->snd_card, path->kcontrol); 375 ret = snd_ctl_add(card, path->kcontrol);
372 if (ret < 0) { 376 if (ret < 0) {
373 printk(KERN_ERR "asoc: failed to add dapm kcontrol %s: %d\n", 377 printk(KERN_ERR "asoc: failed to add dapm kcontrol %s: %d\n",
374 path->long_name, 378 path->long_name,
@@ -383,11 +387,12 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
383} 387}
384 388
385/* create new dapm mux control */ 389/* create new dapm mux control */
386static int dapm_new_mux(struct snd_soc_codec *codec, 390static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
387 struct snd_soc_dapm_widget *w) 391 struct snd_soc_dapm_widget *w)
388{ 392{
389 struct snd_soc_dapm_path *path = NULL; 393 struct snd_soc_dapm_path *path = NULL;
390 struct snd_kcontrol *kcontrol; 394 struct snd_kcontrol *kcontrol;
395 struct snd_card *card = dapm->codec->card->snd_card;
391 int ret = 0; 396 int ret = 0;
392 397
393 if (!w->num_kcontrols) { 398 if (!w->num_kcontrols) {
@@ -396,7 +401,8 @@ static int dapm_new_mux(struct snd_soc_codec *codec,
396 } 401 }
397 402
398 kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name); 403 kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
399 ret = snd_ctl_add(codec->card->snd_card, kcontrol); 404 ret = snd_ctl_add(card, kcontrol);
405
400 if (ret < 0) 406 if (ret < 0)
401 goto err; 407 goto err;
402 408
@@ -411,7 +417,7 @@ err:
411} 417}
412 418
413/* create new dapm volume control */ 419/* create new dapm volume control */
414static int dapm_new_pga(struct snd_soc_codec *codec, 420static int dapm_new_pga(struct snd_soc_dapm_context *dapm,
415 struct snd_soc_dapm_widget *w) 421 struct snd_soc_dapm_widget *w)
416{ 422{
417 if (w->num_kcontrols) 423 if (w->num_kcontrols)
@@ -421,11 +427,11 @@ static int dapm_new_pga(struct snd_soc_codec *codec,
421} 427}
422 428
423/* reset 'walked' bit for each dapm path */ 429/* reset 'walked' bit for each dapm path */
424static inline void dapm_clear_walk(struct snd_soc_codec *codec) 430static inline void dapm_clear_walk(struct snd_soc_dapm_context *dapm)
425{ 431{
426 struct snd_soc_dapm_path *p; 432 struct snd_soc_dapm_path *p;
427 433
428 list_for_each_entry(p, &codec->dapm_paths, list) 434 list_for_each_entry(p, &dapm->paths, list)
429 p->walked = 0; 435 p->walked = 0;
430} 436}
431 437
@@ -435,7 +441,7 @@ static inline void dapm_clear_walk(struct snd_soc_codec *codec)
435 */ 441 */
436static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget) 442static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
437{ 443{
438 int level = snd_power_get_state(widget->codec->card->snd_card); 444 int level = snd_power_get_state(widget->dapm->codec->card->snd_card);
439 445
440 switch (level) { 446 switch (level) {
441 case SNDRV_CTL_POWER_D3hot: 447 case SNDRV_CTL_POWER_D3hot:
@@ -621,9 +627,9 @@ static int dapm_generic_check_power(struct snd_soc_dapm_widget *w)
621 int in, out; 627 int in, out;
622 628
623 in = is_connected_input_ep(w); 629 in = is_connected_input_ep(w);
624 dapm_clear_walk(w->codec); 630 dapm_clear_walk(w->dapm);
625 out = is_connected_output_ep(w); 631 out = is_connected_output_ep(w);
626 dapm_clear_walk(w->codec); 632 dapm_clear_walk(w->dapm);
627 return out != 0 && in != 0; 633 return out != 0 && in != 0;
628} 634}
629 635
@@ -634,7 +640,7 @@ static int dapm_adc_check_power(struct snd_soc_dapm_widget *w)
634 640
635 if (w->active) { 641 if (w->active) {
636 in = is_connected_input_ep(w); 642 in = is_connected_input_ep(w);
637 dapm_clear_walk(w->codec); 643 dapm_clear_walk(w->dapm);
638 return in != 0; 644 return in != 0;
639 } else { 645 } else {
640 return dapm_generic_check_power(w); 646 return dapm_generic_check_power(w);
@@ -648,7 +654,7 @@ static int dapm_dac_check_power(struct snd_soc_dapm_widget *w)
648 654
649 if (w->active) { 655 if (w->active) {
650 out = is_connected_output_ep(w); 656 out = is_connected_output_ep(w);
651 dapm_clear_walk(w->codec); 657 dapm_clear_walk(w->dapm);
652 return out != 0; 658 return out != 0;
653 } else { 659 } else {
654 return dapm_generic_check_power(w); 660 return dapm_generic_check_power(w);
@@ -674,7 +680,7 @@ static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
674 } 680 }
675 } 681 }
676 682
677 dapm_clear_walk(w->codec); 683 dapm_clear_walk(w->dapm);
678 684
679 return power; 685 return power;
680} 686}
@@ -710,7 +716,7 @@ static void dapm_seq_insert(struct snd_soc_dapm_widget *new_widget,
710} 716}
711 717
712/* Apply the coalesced changes from a DAPM sequence */ 718/* Apply the coalesced changes from a DAPM sequence */
713static void dapm_seq_run_coalesced(struct snd_soc_codec *codec, 719static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
714 struct list_head *pending) 720 struct list_head *pending)
715{ 721{
716 struct snd_soc_dapm_widget *w; 722 struct snd_soc_dapm_widget *w;
@@ -735,14 +741,14 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec,
735 if (power) 741 if (power)
736 value |= cur_mask; 742 value |= cur_mask;
737 743
738 pop_dbg(codec->pop_time, 744 pop_dbg(dapm->pop_time,
739 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n", 745 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
740 w->name, reg, value, mask); 746 w->name, reg, value, mask);
741 747
742 /* power up pre event */ 748 /* power up pre event */
743 if (w->power && w->event && 749 if (w->power && w->event &&
744 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { 750 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
745 pop_dbg(codec->pop_time, "pop test : %s PRE_PMU\n", 751 pop_dbg(dapm->pop_time, "pop test : %s PRE_PMU\n",
746 w->name); 752 w->name);
747 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU); 753 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
748 if (ret < 0) 754 if (ret < 0)
@@ -753,7 +759,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec,
753 /* power down pre event */ 759 /* power down pre event */
754 if (!w->power && w->event && 760 if (!w->power && w->event &&
755 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) { 761 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
756 pop_dbg(codec->pop_time, "pop test : %s PRE_PMD\n", 762 pop_dbg(dapm->pop_time, "pop test : %s PRE_PMD\n",
757 w->name); 763 w->name);
758 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD); 764 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
759 if (ret < 0) 765 if (ret < 0)
@@ -763,18 +769,18 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec,
763 } 769 }
764 770
765 if (reg >= 0) { 771 if (reg >= 0) {
766 pop_dbg(codec->pop_time, 772 pop_dbg(dapm->pop_time,
767 "pop test : Applying 0x%x/0x%x to %x in %dms\n", 773 "pop test : Applying 0x%x/0x%x to %x in %dms\n",
768 value, mask, reg, codec->pop_time); 774 value, mask, reg, dapm->pop_time);
769 pop_wait(codec->pop_time); 775 pop_wait(dapm->pop_time);
770 snd_soc_update_bits(codec, reg, mask, value); 776 snd_soc_update_bits(dapm->codec, reg, mask, value);
771 } 777 }
772 778
773 list_for_each_entry(w, pending, power_list) { 779 list_for_each_entry(w, pending, power_list) {
774 /* power up post event */ 780 /* power up post event */
775 if (w->power && w->event && 781 if (w->power && w->event &&
776 (w->event_flags & SND_SOC_DAPM_POST_PMU)) { 782 (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
777 pop_dbg(codec->pop_time, "pop test : %s POST_PMU\n", 783 pop_dbg(dapm->pop_time, "pop test : %s POST_PMU\n",
778 w->name); 784 w->name);
779 ret = w->event(w, 785 ret = w->event(w,
780 NULL, SND_SOC_DAPM_POST_PMU); 786 NULL, SND_SOC_DAPM_POST_PMU);
@@ -786,7 +792,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec,
786 /* power down post event */ 792 /* power down post event */
787 if (!w->power && w->event && 793 if (!w->power && w->event &&
788 (w->event_flags & SND_SOC_DAPM_POST_PMD)) { 794 (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
789 pop_dbg(codec->pop_time, "pop test : %s POST_PMD\n", 795 pop_dbg(dapm->pop_time, "pop test : %s POST_PMD\n",
790 w->name); 796 w->name);
791 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD); 797 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
792 if (ret < 0) 798 if (ret < 0)
@@ -804,8 +810,8 @@ static void dapm_seq_run_coalesced(struct snd_soc_codec *codec,
804 * Currently anything that requires more than a single write is not 810 * Currently anything that requires more than a single write is not
805 * handled. 811 * handled.
806 */ 812 */
807static void dapm_seq_run(struct snd_soc_codec *codec, struct list_head *list, 813static void dapm_seq_run(struct snd_soc_dapm_context *dapm,
808 int event, int sort[]) 814 struct list_head *list, int event, int sort[])
809{ 815{
810 struct snd_soc_dapm_widget *w, *n; 816 struct snd_soc_dapm_widget *w, *n;
811 LIST_HEAD(pending); 817 LIST_HEAD(pending);
@@ -819,7 +825,7 @@ static void dapm_seq_run(struct snd_soc_codec *codec, struct list_head *list,
819 /* Do we need to apply any queued changes? */ 825 /* Do we need to apply any queued changes? */
820 if (sort[w->id] != cur_sort || w->reg != cur_reg) { 826 if (sort[w->id] != cur_sort || w->reg != cur_reg) {
821 if (!list_empty(&pending)) 827 if (!list_empty(&pending))
822 dapm_seq_run_coalesced(codec, &pending); 828 dapm_seq_run_coalesced(dapm, &pending);
823 829
824 INIT_LIST_HEAD(&pending); 830 INIT_LIST_HEAD(&pending);
825 cur_sort = -1; 831 cur_sort = -1;
@@ -877,7 +883,7 @@ static void dapm_seq_run(struct snd_soc_codec *codec, struct list_head *list,
877 } 883 }
878 884
879 if (!list_empty(&pending)) 885 if (!list_empty(&pending))
880 dapm_seq_run_coalesced(codec, &pending); 886 dapm_seq_run_coalesced(dapm, &pending);
881} 887}
882 888
883/* 889/*
@@ -889,9 +895,9 @@ static void dapm_seq_run(struct snd_soc_codec *codec, struct list_head *list,
889 * o Input pin to Output pin (bypass, sidetone) 895 * o Input pin to Output pin (bypass, sidetone)
890 * o DAC to ADC (loopback). 896 * o DAC to ADC (loopback).
891 */ 897 */
892static int dapm_power_widgets(struct snd_soc_codec *codec, int event) 898static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
893{ 899{
894 struct snd_soc_card *card = codec->card; 900 struct snd_soc_card *card = dapm->codec->card;
895 struct snd_soc_dapm_widget *w; 901 struct snd_soc_dapm_widget *w;
896 LIST_HEAD(up_list); 902 LIST_HEAD(up_list);
897 LIST_HEAD(down_list); 903 LIST_HEAD(down_list);
@@ -902,7 +908,7 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
902 /* Check which widgets we need to power and store them in 908 /* Check which widgets we need to power and store them in
903 * lists indicating if they should be powered up or down. 909 * lists indicating if they should be powered up or down.
904 */ 910 */
905 list_for_each_entry(w, &codec->dapm_widgets, list) { 911 list_for_each_entry(w, &dapm->widgets, list) {
906 switch (w->id) { 912 switch (w->id) {
907 case snd_soc_dapm_pre: 913 case snd_soc_dapm_pre:
908 dapm_seq_insert(w, &down_list, dapm_down_seq); 914 dapm_seq_insert(w, &down_list, dapm_down_seq);
@@ -938,7 +944,7 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
938 /* If there are no DAPM widgets then try to figure out power from the 944 /* If there are no DAPM widgets then try to figure out power from the
939 * event type. 945 * event type.
940 */ 946 */
941 if (list_empty(&codec->dapm_widgets)) { 947 if (list_empty(&dapm->widgets)) {
942 switch (event) { 948 switch (event) {
943 case SND_SOC_DAPM_STREAM_START: 949 case SND_SOC_DAPM_STREAM_START:
944 case SND_SOC_DAPM_STREAM_RESUME: 950 case SND_SOC_DAPM_STREAM_RESUME:
@@ -948,7 +954,7 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
948 sys_power = 0; 954 sys_power = 0;
949 break; 955 break;
950 case SND_SOC_DAPM_STREAM_NOP: 956 case SND_SOC_DAPM_STREAM_NOP:
951 switch (codec->bias_level) { 957 switch (dapm->bias_level) {
952 case SND_SOC_BIAS_STANDBY: 958 case SND_SOC_BIAS_STANDBY:
953 case SND_SOC_BIAS_OFF: 959 case SND_SOC_BIAS_OFF:
954 sys_power = 0; 960 sys_power = 0;
@@ -963,52 +969,52 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
963 } 969 }
964 } 970 }
965 971
966 if (sys_power && codec->bias_level == SND_SOC_BIAS_OFF) { 972 if (sys_power && dapm->bias_level == SND_SOC_BIAS_OFF) {
967 ret = snd_soc_dapm_set_bias_level(card, codec, 973 ret = snd_soc_dapm_set_bias_level(card, dapm,
968 SND_SOC_BIAS_STANDBY); 974 SND_SOC_BIAS_STANDBY);
969 if (ret != 0) 975 if (ret != 0)
970 pr_err("Failed to turn on bias: %d\n", ret); 976 pr_err("Failed to turn on bias: %d\n", ret);
971 } 977 }
972 978
973 /* If we're changing to all on or all off then prepare */ 979 /* If we're changing to all on or all off then prepare */
974 if ((sys_power && codec->bias_level == SND_SOC_BIAS_STANDBY) || 980 if ((sys_power && dapm->bias_level == SND_SOC_BIAS_STANDBY) ||
975 (!sys_power && codec->bias_level == SND_SOC_BIAS_ON)) { 981 (!sys_power && dapm->bias_level == SND_SOC_BIAS_ON)) {
976 ret = snd_soc_dapm_set_bias_level(card, codec, SND_SOC_BIAS_PREPARE); 982 ret = snd_soc_dapm_set_bias_level(card, dapm, SND_SOC_BIAS_PREPARE);
977 if (ret != 0) 983 if (ret != 0)
978 pr_err("Failed to prepare bias: %d\n", ret); 984 pr_err("Failed to prepare bias: %d\n", ret);
979 } 985 }
980 986
981 /* Power down widgets first; try to avoid amplifying pops. */ 987 /* Power down widgets first; try to avoid amplifying pops. */
982 dapm_seq_run(codec, &down_list, event, dapm_down_seq); 988 dapm_seq_run(dapm, &down_list, event, dapm_down_seq);
983 989
984 /* Now power up. */ 990 /* Now power up. */
985 dapm_seq_run(codec, &up_list, event, dapm_up_seq); 991 dapm_seq_run(dapm, &up_list, event, dapm_up_seq);
986 992
987 /* If we just powered the last thing off drop to standby bias */ 993 /* If we just powered the last thing off drop to standby bias */
988 if (codec->bias_level == SND_SOC_BIAS_PREPARE && !sys_power) { 994 if (dapm->bias_level == SND_SOC_BIAS_PREPARE && !sys_power) {
989 ret = snd_soc_dapm_set_bias_level(card, codec, SND_SOC_BIAS_STANDBY); 995 ret = snd_soc_dapm_set_bias_level(card, dapm, SND_SOC_BIAS_STANDBY);
990 if (ret != 0) 996 if (ret != 0)
991 pr_err("Failed to apply standby bias: %d\n", ret); 997 pr_err("Failed to apply standby bias: %d\n", ret);
992 } 998 }
993 999
994 /* If we're in standby and can support bias off then do that */ 1000 /* If we're in standby and can support bias off then do that */
995 if (codec->bias_level == SND_SOC_BIAS_STANDBY && 1001 if (dapm->bias_level == SND_SOC_BIAS_STANDBY &&
996 codec->idle_bias_off) { 1002 dapm->idle_bias_off) {
997 ret = snd_soc_dapm_set_bias_level(card, codec, SND_SOC_BIAS_OFF); 1003 ret = snd_soc_dapm_set_bias_level(card, dapm, SND_SOC_BIAS_OFF);
998 if (ret != 0) 1004 if (ret != 0)
999 pr_err("Failed to turn off bias: %d\n", ret); 1005 pr_err("Failed to turn off bias: %d\n", ret);
1000 } 1006 }
1001 1007
1002 /* If we just powered up then move to active bias */ 1008 /* If we just powered up then move to active bias */
1003 if (codec->bias_level == SND_SOC_BIAS_PREPARE && sys_power) { 1009 if (dapm->bias_level == SND_SOC_BIAS_PREPARE && sys_power) {
1004 ret = snd_soc_dapm_set_bias_level(card, codec, SND_SOC_BIAS_ON); 1010 ret = snd_soc_dapm_set_bias_level(card, dapm, SND_SOC_BIAS_ON);
1005 if (ret != 0) 1011 if (ret != 0)
1006 pr_err("Failed to apply active bias: %d\n", ret); 1012 pr_err("Failed to apply active bias: %d\n", ret);
1007 } 1013 }
1008 1014
1009 pop_dbg(codec->pop_time, "DAPM sequencing finished, waiting %dms\n", 1015 pop_dbg(dapm->pop_time, "DAPM sequencing finished, waiting %dms\n",
1010 codec->pop_time); 1016 dapm->pop_time);
1011 pop_wait(codec->pop_time); 1017 pop_wait(dapm->pop_time);
1012 1018
1013 return 0; 1019 return 0;
1014} 1020}
@@ -1035,9 +1041,9 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
1035 return -ENOMEM; 1041 return -ENOMEM;
1036 1042
1037 in = is_connected_input_ep(w); 1043 in = is_connected_input_ep(w);
1038 dapm_clear_walk(w->codec); 1044 dapm_clear_walk(w->dapm);
1039 out = is_connected_output_ep(w); 1045 out = is_connected_output_ep(w);
1040 dapm_clear_walk(w->codec); 1046 dapm_clear_walk(w->dapm);
1041 1047
1042 ret = snprintf(buf, PAGE_SIZE, "%s: %s in %d out %d", 1048 ret = snprintf(buf, PAGE_SIZE, "%s: %s in %d out %d",
1043 w->name, w->power ? "On" : "Off", in, out); 1049 w->name, w->power ? "On" : "Off", in, out);
@@ -1087,20 +1093,20 @@ static const struct file_operations dapm_widget_power_fops = {
1087 .llseek = default_llseek, 1093 .llseek = default_llseek,
1088}; 1094};
1089 1095
1090void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec) 1096void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm)
1091{ 1097{
1092 struct snd_soc_dapm_widget *w; 1098 struct snd_soc_dapm_widget *w;
1093 struct dentry *d; 1099 struct dentry *d;
1094 1100
1095 if (!codec->debugfs_dapm) 1101 if (!dapm->debugfs_dapm)
1096 return; 1102 return;
1097 1103
1098 list_for_each_entry(w, &codec->dapm_widgets, list) { 1104 list_for_each_entry(w, &dapm->widgets, list) {
1099 if (!w->name) 1105 if (!w->name)
1100 continue; 1106 continue;
1101 1107
1102 d = debugfs_create_file(w->name, 0444, 1108 d = debugfs_create_file(w->name, 0444,
1103 codec->debugfs_dapm, w, 1109 dapm->debugfs_dapm, w,
1104 &dapm_widget_power_fops); 1110 &dapm_widget_power_fops);
1105 if (!d) 1111 if (!d)
1106 printk(KERN_WARNING 1112 printk(KERN_WARNING
@@ -1109,7 +1115,7 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec)
1109 } 1115 }
1110} 1116}
1111#else 1117#else
1112void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec) 1118void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm)
1113{ 1119{
1114} 1120}
1115#endif 1121#endif
@@ -1130,7 +1136,7 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
1130 return 0; 1136 return 0;
1131 1137
1132 /* find dapm widget path assoc with kcontrol */ 1138 /* find dapm widget path assoc with kcontrol */
1133 list_for_each_entry(path, &widget->codec->dapm_paths, list) { 1139 list_for_each_entry(path, &widget->dapm->paths, list) {
1134 if (path->kcontrol != kcontrol) 1140 if (path->kcontrol != kcontrol)
1135 continue; 1141 continue;
1136 1142
@@ -1146,7 +1152,7 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
1146 } 1152 }
1147 1153
1148 if (found) 1154 if (found)
1149 dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP); 1155 dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP);
1150 1156
1151 return 0; 1157 return 0;
1152} 1158}
@@ -1164,7 +1170,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
1164 return -ENODEV; 1170 return -ENODEV;
1165 1171
1166 /* find dapm widget path assoc with kcontrol */ 1172 /* find dapm widget path assoc with kcontrol */
1167 list_for_each_entry(path, &widget->codec->dapm_paths, list) { 1173 list_for_each_entry(path, &widget->dapm->paths, list) {
1168 if (path->kcontrol != kcontrol) 1174 if (path->kcontrol != kcontrol)
1169 continue; 1175 continue;
1170 1176
@@ -1175,7 +1181,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
1175 } 1181 }
1176 1182
1177 if (found) 1183 if (found)
1178 dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP); 1184 dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP);
1179 1185
1180 return 0; 1186 return 0;
1181} 1187}
@@ -1191,7 +1197,7 @@ static ssize_t dapm_widget_show(struct device *dev,
1191 int count = 0; 1197 int count = 0;
1192 char *state = "not set"; 1198 char *state = "not set";
1193 1199
1194 list_for_each_entry(w, &codec->dapm_widgets, list) { 1200 list_for_each_entry(w, &codec->dapm.widgets, list) {
1195 1201
1196 /* only display widgets that burnm power */ 1202 /* only display widgets that burnm power */
1197 switch (w->id) { 1203 switch (w->id) {
@@ -1215,7 +1221,7 @@ static ssize_t dapm_widget_show(struct device *dev,
1215 } 1221 }
1216 } 1222 }
1217 1223
1218 switch (codec->bias_level) { 1224 switch (codec->dapm.bias_level) {
1219 case SND_SOC_BIAS_ON: 1225 case SND_SOC_BIAS_ON:
1220 state = "On"; 1226 state = "On";
1221 break; 1227 break;
@@ -1247,31 +1253,31 @@ static void snd_soc_dapm_sys_remove(struct device *dev)
1247} 1253}
1248 1254
1249/* free all dapm widgets and resources */ 1255/* free all dapm widgets and resources */
1250static void dapm_free_widgets(struct snd_soc_codec *codec) 1256static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
1251{ 1257{
1252 struct snd_soc_dapm_widget *w, *next_w; 1258 struct snd_soc_dapm_widget *w, *next_w;
1253 struct snd_soc_dapm_path *p, *next_p; 1259 struct snd_soc_dapm_path *p, *next_p;
1254 1260
1255 list_for_each_entry_safe(w, next_w, &codec->dapm_widgets, list) { 1261 list_for_each_entry_safe(w, next_w, &dapm->widgets, list) {
1256 list_del(&w->list); 1262 list_del(&w->list);
1257 kfree(w); 1263 kfree(w);
1258 } 1264 }
1259 1265
1260 list_for_each_entry_safe(p, next_p, &codec->dapm_paths, list) { 1266 list_for_each_entry_safe(p, next_p, &dapm->paths, list) {
1261 list_del(&p->list); 1267 list_del(&p->list);
1262 kfree(p->long_name); 1268 kfree(p->long_name);
1263 kfree(p); 1269 kfree(p);
1264 } 1270 }
1265} 1271}
1266 1272
1267static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec, 1273static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
1268 const char *pin, int status) 1274 const char *pin, int status)
1269{ 1275{
1270 struct snd_soc_dapm_widget *w; 1276 struct snd_soc_dapm_widget *w;
1271 1277
1272 list_for_each_entry(w, &codec->dapm_widgets, list) { 1278 list_for_each_entry(w, &dapm->widgets, list) {
1273 if (!strcmp(w->name, pin)) { 1279 if (!strcmp(w->name, pin)) {
1274 pr_debug("dapm: %s: pin %s\n", codec->name, pin); 1280 pr_debug("dapm: %s: pin %s\n", dapm->codec->name, pin);
1275 w->connected = status; 1281 w->connected = status;
1276 /* Allow disabling of forced pins */ 1282 /* Allow disabling of forced pins */
1277 if (status == 0) 1283 if (status == 0)
@@ -1280,26 +1286,27 @@ static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
1280 } 1286 }
1281 } 1287 }
1282 1288
1283 pr_err("dapm: %s: configuring unknown pin %s\n", codec->name, pin); 1289 pr_err("dapm: %s: configuring unknown pin %s\n",
1290 dapm->codec->name, pin);
1284 return -EINVAL; 1291 return -EINVAL;
1285} 1292}
1286 1293
1287/** 1294/**
1288 * snd_soc_dapm_sync - scan and power dapm paths 1295 * snd_soc_dapm_sync - scan and power dapm paths
1289 * @codec: audio codec 1296 * @dapm: DAPM context
1290 * 1297 *
1291 * Walks all dapm audio paths and powers widgets according to their 1298 * Walks all dapm audio paths and powers widgets according to their
1292 * stream or path usage. 1299 * stream or path usage.
1293 * 1300 *
1294 * Returns 0 for success. 1301 * Returns 0 for success.
1295 */ 1302 */
1296int snd_soc_dapm_sync(struct snd_soc_codec *codec) 1303int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
1297{ 1304{
1298 return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP); 1305 return dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
1299} 1306}
1300EXPORT_SYMBOL_GPL(snd_soc_dapm_sync); 1307EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
1301 1308
1302static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, 1309static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
1303 const struct snd_soc_dapm_route *route) 1310 const struct snd_soc_dapm_route *route)
1304{ 1311{
1305 struct snd_soc_dapm_path *path; 1312 struct snd_soc_dapm_path *path;
@@ -1310,7 +1317,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
1310 int ret = 0; 1317 int ret = 0;
1311 1318
1312 /* find src and dest widgets */ 1319 /* find src and dest widgets */
1313 list_for_each_entry(w, &codec->dapm_widgets, list) { 1320 list_for_each_entry(w, &dapm->widgets, list) {
1314 1321
1315 if (!wsink && !(strcmp(w->name, sink))) { 1322 if (!wsink && !(strcmp(w->name, sink))) {
1316 wsink = w; 1323 wsink = w;
@@ -1353,7 +1360,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
1353 1360
1354 /* connect static paths */ 1361 /* connect static paths */
1355 if (control == NULL) { 1362 if (control == NULL) {
1356 list_add(&path->list, &codec->dapm_paths); 1363 list_add(&path->list, &dapm->paths);
1357 list_add(&path->list_sink, &wsink->sources); 1364 list_add(&path->list_sink, &wsink->sources);
1358 list_add(&path->list_source, &wsource->sinks); 1365 list_add(&path->list_source, &wsource->sinks);
1359 path->connect = 1; 1366 path->connect = 1;
@@ -1374,14 +1381,14 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
1374 case snd_soc_dapm_supply: 1381 case snd_soc_dapm_supply:
1375 case snd_soc_dapm_aif_in: 1382 case snd_soc_dapm_aif_in:
1376 case snd_soc_dapm_aif_out: 1383 case snd_soc_dapm_aif_out:
1377 list_add(&path->list, &codec->dapm_paths); 1384 list_add(&path->list, &dapm->paths);
1378 list_add(&path->list_sink, &wsink->sources); 1385 list_add(&path->list_sink, &wsink->sources);
1379 list_add(&path->list_source, &wsource->sinks); 1386 list_add(&path->list_source, &wsource->sinks);
1380 path->connect = 1; 1387 path->connect = 1;
1381 return 0; 1388 return 0;
1382 case snd_soc_dapm_mux: 1389 case snd_soc_dapm_mux:
1383 case snd_soc_dapm_value_mux: 1390 case snd_soc_dapm_value_mux:
1384 ret = dapm_connect_mux(codec, wsource, wsink, path, control, 1391 ret = dapm_connect_mux(dapm, wsource, wsink, path, control,
1385 &wsink->kcontrols[0]); 1392 &wsink->kcontrols[0]);
1386 if (ret != 0) 1393 if (ret != 0)
1387 goto err; 1394 goto err;
@@ -1389,7 +1396,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
1389 case snd_soc_dapm_switch: 1396 case snd_soc_dapm_switch:
1390 case snd_soc_dapm_mixer: 1397 case snd_soc_dapm_mixer:
1391 case snd_soc_dapm_mixer_named_ctl: 1398 case snd_soc_dapm_mixer_named_ctl:
1392 ret = dapm_connect_mixer(codec, wsource, wsink, path, control); 1399 ret = dapm_connect_mixer(dapm, wsource, wsink, path, control);
1393 if (ret != 0) 1400 if (ret != 0)
1394 goto err; 1401 goto err;
1395 break; 1402 break;
@@ -1397,7 +1404,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
1397 case snd_soc_dapm_mic: 1404 case snd_soc_dapm_mic:
1398 case snd_soc_dapm_line: 1405 case snd_soc_dapm_line:
1399 case snd_soc_dapm_spk: 1406 case snd_soc_dapm_spk:
1400 list_add(&path->list, &codec->dapm_paths); 1407 list_add(&path->list, &dapm->paths);
1401 list_add(&path->list_sink, &wsink->sources); 1408 list_add(&path->list_sink, &wsink->sources);
1402 list_add(&path->list_source, &wsource->sinks); 1409 list_add(&path->list_source, &wsource->sinks);
1403 path->connect = 0; 1410 path->connect = 0;
@@ -1414,7 +1421,7 @@ err:
1414 1421
1415/** 1422/**
1416 * snd_soc_dapm_add_routes - Add routes between DAPM widgets 1423 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
1417 * @codec: codec 1424 * @dapm: DAPM context
1418 * @route: audio routes 1425 * @route: audio routes
1419 * @num: number of routes 1426 * @num: number of routes
1420 * 1427 *
@@ -1425,13 +1432,13 @@ err:
1425 * Returns 0 for success else error. On error all resources can be freed 1432 * Returns 0 for success else error. On error all resources can be freed
1426 * with a call to snd_soc_card_free(). 1433 * with a call to snd_soc_card_free().
1427 */ 1434 */
1428int snd_soc_dapm_add_routes(struct snd_soc_codec *codec, 1435int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
1429 const struct snd_soc_dapm_route *route, int num) 1436 const struct snd_soc_dapm_route *route, int num)
1430{ 1437{
1431 int i, ret; 1438 int i, ret;
1432 1439
1433 for (i = 0; i < num; i++) { 1440 for (i = 0; i < num; i++) {
1434 ret = snd_soc_dapm_add_route(codec, route); 1441 ret = snd_soc_dapm_add_route(dapm, route);
1435 if (ret < 0) { 1442 if (ret < 0) {
1436 printk(KERN_ERR "Failed to add route %s->%s\n", 1443 printk(KERN_ERR "Failed to add route %s->%s\n",
1437 route->source, 1444 route->source,
@@ -1447,17 +1454,17 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
1447 1454
1448/** 1455/**
1449 * snd_soc_dapm_new_widgets - add new dapm widgets 1456 * snd_soc_dapm_new_widgets - add new dapm widgets
1450 * @codec: audio codec 1457 * @dapm: DAPM context
1451 * 1458 *
1452 * Checks the codec for any new dapm widgets and creates them if found. 1459 * Checks the codec for any new dapm widgets and creates them if found.
1453 * 1460 *
1454 * Returns 0 for success. 1461 * Returns 0 for success.
1455 */ 1462 */
1456int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) 1463int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
1457{ 1464{
1458 struct snd_soc_dapm_widget *w; 1465 struct snd_soc_dapm_widget *w;
1459 1466
1460 list_for_each_entry(w, &codec->dapm_widgets, list) 1467 list_for_each_entry(w, &dapm->widgets, list)
1461 { 1468 {
1462 if (w->new) 1469 if (w->new)
1463 continue; 1470 continue;
@@ -1467,12 +1474,12 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1467 case snd_soc_dapm_mixer: 1474 case snd_soc_dapm_mixer:
1468 case snd_soc_dapm_mixer_named_ctl: 1475 case snd_soc_dapm_mixer_named_ctl:
1469 w->power_check = dapm_generic_check_power; 1476 w->power_check = dapm_generic_check_power;
1470 dapm_new_mixer(codec, w); 1477 dapm_new_mixer(dapm, w);
1471 break; 1478 break;
1472 case snd_soc_dapm_mux: 1479 case snd_soc_dapm_mux:
1473 case snd_soc_dapm_value_mux: 1480 case snd_soc_dapm_value_mux:
1474 w->power_check = dapm_generic_check_power; 1481 w->power_check = dapm_generic_check_power;
1475 dapm_new_mux(codec, w); 1482 dapm_new_mux(dapm, w);
1476 break; 1483 break;
1477 case snd_soc_dapm_adc: 1484 case snd_soc_dapm_adc:
1478 case snd_soc_dapm_aif_out: 1485 case snd_soc_dapm_aif_out:
@@ -1484,7 +1491,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1484 break; 1491 break;
1485 case snd_soc_dapm_pga: 1492 case snd_soc_dapm_pga:
1486 w->power_check = dapm_generic_check_power; 1493 w->power_check = dapm_generic_check_power;
1487 dapm_new_pga(codec, w); 1494 dapm_new_pga(dapm, w);
1488 break; 1495 break;
1489 case snd_soc_dapm_input: 1496 case snd_soc_dapm_input:
1490 case snd_soc_dapm_output: 1497 case snd_soc_dapm_output:
@@ -1505,7 +1512,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1505 w->new = 1; 1512 w->new = 1;
1506 } 1513 }
1507 1514
1508 dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP); 1515 dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
1509 return 0; 1516 return 0;
1510} 1517}
1511EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); 1518EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
@@ -1889,7 +1896,7 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
1889 mutex_lock(&codec->mutex); 1896 mutex_lock(&codec->mutex);
1890 1897
1891 ucontrol->value.integer.value[0] = 1898 ucontrol->value.integer.value[0] =
1892 snd_soc_dapm_get_pin_status(codec, pin); 1899 snd_soc_dapm_get_pin_status(&codec->dapm, pin);
1893 1900
1894 mutex_unlock(&codec->mutex); 1901 mutex_unlock(&codec->mutex);
1895 1902
@@ -1912,11 +1919,11 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
1912 mutex_lock(&codec->mutex); 1919 mutex_lock(&codec->mutex);
1913 1920
1914 if (ucontrol->value.integer.value[0]) 1921 if (ucontrol->value.integer.value[0])
1915 snd_soc_dapm_enable_pin(codec, pin); 1922 snd_soc_dapm_enable_pin(&codec->dapm, pin);
1916 else 1923 else
1917 snd_soc_dapm_disable_pin(codec, pin); 1924 snd_soc_dapm_disable_pin(&codec->dapm, pin);
1918 1925
1919 snd_soc_dapm_sync(codec); 1926 snd_soc_dapm_sync(&codec->dapm);
1920 1927
1921 mutex_unlock(&codec->mutex); 1928 mutex_unlock(&codec->mutex);
1922 1929
@@ -1926,14 +1933,14 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
1926 1933
1927/** 1934/**
1928 * snd_soc_dapm_new_control - create new dapm control 1935 * snd_soc_dapm_new_control - create new dapm control
1929 * @codec: audio codec 1936 * @dapm: DAPM context
1930 * @widget: widget template 1937 * @widget: widget template
1931 * 1938 *
1932 * Creates a new dapm control based upon the template. 1939 * Creates a new dapm control based upon the template.
1933 * 1940 *
1934 * Returns 0 for success else error. 1941 * Returns 0 for success else error.
1935 */ 1942 */
1936int snd_soc_dapm_new_control(struct snd_soc_codec *codec, 1943int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
1937 const struct snd_soc_dapm_widget *widget) 1944 const struct snd_soc_dapm_widget *widget)
1938{ 1945{
1939 struct snd_soc_dapm_widget *w; 1946 struct snd_soc_dapm_widget *w;
@@ -1941,11 +1948,12 @@ int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
1941 if ((w = dapm_cnew_widget(widget)) == NULL) 1948 if ((w = dapm_cnew_widget(widget)) == NULL)
1942 return -ENOMEM; 1949 return -ENOMEM;
1943 1950
1944 w->codec = codec; 1951 w->dapm = dapm;
1952 w->codec = dapm->codec;
1945 INIT_LIST_HEAD(&w->sources); 1953 INIT_LIST_HEAD(&w->sources);
1946 INIT_LIST_HEAD(&w->sinks); 1954 INIT_LIST_HEAD(&w->sinks);
1947 INIT_LIST_HEAD(&w->list); 1955 INIT_LIST_HEAD(&w->list);
1948 list_add(&w->list, &codec->dapm_widgets); 1956 list_add(&w->list, &dapm->widgets);
1949 1957
1950 /* machine layer set ups unconnected pins and insertions */ 1958 /* machine layer set ups unconnected pins and insertions */
1951 w->connected = 1; 1959 w->connected = 1;
@@ -1955,7 +1963,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
1955 1963
1956/** 1964/**
1957 * snd_soc_dapm_new_controls - create new dapm controls 1965 * snd_soc_dapm_new_controls - create new dapm controls
1958 * @codec: audio codec 1966 * @dapm: DAPM context
1959 * @widget: widget array 1967 * @widget: widget array
1960 * @num: number of widgets 1968 * @num: number of widgets
1961 * 1969 *
@@ -1963,14 +1971,14 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
1963 * 1971 *
1964 * Returns 0 for success else error. 1972 * Returns 0 for success else error.
1965 */ 1973 */
1966int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, 1974int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
1967 const struct snd_soc_dapm_widget *widget, 1975 const struct snd_soc_dapm_widget *widget,
1968 int num) 1976 int num)
1969{ 1977{
1970 int i, ret; 1978 int i, ret;
1971 1979
1972 for (i = 0; i < num; i++) { 1980 for (i = 0; i < num; i++) {
1973 ret = snd_soc_dapm_new_control(codec, widget); 1981 ret = snd_soc_dapm_new_control(dapm, widget);
1974 if (ret < 0) { 1982 if (ret < 0) {
1975 printk(KERN_ERR 1983 printk(KERN_ERR
1976 "ASoC: Failed to create DAPM control %s: %d\n", 1984 "ASoC: Failed to create DAPM control %s: %d\n",
@@ -1983,29 +1991,12 @@ int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
1983} 1991}
1984EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls); 1992EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
1985 1993
1986 1994static void soc_dapm_stream_event(struct snd_soc_dapm_context *dapm,
1987/**
1988 * snd_soc_dapm_stream_event - send a stream event to the dapm core
1989 * @codec: audio codec
1990 * @stream: stream name
1991 * @event: stream event
1992 *
1993 * Sends a stream event to the dapm core. The core then makes any
1994 * necessary widget power changes.
1995 *
1996 * Returns 0 for success else error.
1997 */
1998int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
1999 const char *stream, int event) 1995 const char *stream, int event)
2000{ 1996{
2001 struct snd_soc_codec *codec = rtd->codec;
2002 struct snd_soc_dapm_widget *w; 1997 struct snd_soc_dapm_widget *w;
2003 1998
2004 if (stream == NULL) 1999 list_for_each_entry(w, &dapm->widgets, list)
2005 return 0;
2006
2007 mutex_lock(&codec->mutex);
2008 list_for_each_entry(w, &codec->dapm_widgets, list)
2009 { 2000 {
2010 if (!w->sname) 2001 if (!w->sname)
2011 continue; 2002 continue;
@@ -2028,7 +2019,30 @@ int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
2028 } 2019 }
2029 } 2020 }
2030 2021
2031 dapm_power_widgets(codec, event); 2022 dapm_power_widgets(dapm, event);
2023}
2024
2025/**
2026 * snd_soc_dapm_stream_event - send a stream event to the dapm core
2027 * @rtd: PCM runtime data
2028 * @stream: stream name
2029 * @event: stream event
2030 *
2031 * Sends a stream event to the dapm core. The core then makes any
2032 * necessary widget power changes.
2033 *
2034 * Returns 0 for success else error.
2035 */
2036int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
2037 const char *stream, int event)
2038{
2039 struct snd_soc_codec *codec = rtd->codec;
2040
2041 if (stream == NULL)
2042 return 0;
2043
2044 mutex_lock(&codec->mutex);
2045 soc_dapm_stream_event(&codec->dapm, stream, event);
2032 mutex_unlock(&codec->mutex); 2046 mutex_unlock(&codec->mutex);
2033 return 0; 2047 return 0;
2034} 2048}
@@ -2036,7 +2050,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
2036 2050
2037/** 2051/**
2038 * snd_soc_dapm_enable_pin - enable pin. 2052 * snd_soc_dapm_enable_pin - enable pin.
2039 * @codec: SoC codec 2053 * @dapm: DAPM context
2040 * @pin: pin name 2054 * @pin: pin name
2041 * 2055 *
2042 * Enables input/output pin and its parents or children widgets iff there is 2056 * Enables input/output pin and its parents or children widgets iff there is
@@ -2044,15 +2058,15 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
2044 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 2058 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2045 * do any widget power switching. 2059 * do any widget power switching.
2046 */ 2060 */
2047int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin) 2061int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
2048{ 2062{
2049 return snd_soc_dapm_set_pin(codec, pin, 1); 2063 return snd_soc_dapm_set_pin(dapm, pin, 1);
2050} 2064}
2051EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); 2065EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
2052 2066
2053/** 2067/**
2054 * snd_soc_dapm_force_enable_pin - force a pin to be enabled 2068 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
2055 * @codec: SoC codec 2069 * @dapm: DAPM context
2056 * @pin: pin name 2070 * @pin: pin name
2057 * 2071 *
2058 * Enables input/output pin regardless of any other state. This is 2072 * Enables input/output pin regardless of any other state. This is
@@ -2062,42 +2076,45 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
2062 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 2076 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2063 * do any widget power switching. 2077 * do any widget power switching.
2064 */ 2078 */
2065int snd_soc_dapm_force_enable_pin(struct snd_soc_codec *codec, const char *pin) 2079int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
2080 const char *pin)
2066{ 2081{
2067 struct snd_soc_dapm_widget *w; 2082 struct snd_soc_dapm_widget *w;
2068 2083
2069 list_for_each_entry(w, &codec->dapm_widgets, list) { 2084 list_for_each_entry(w, &dapm->widgets, list) {
2070 if (!strcmp(w->name, pin)) { 2085 if (!strcmp(w->name, pin)) {
2071 pr_debug("dapm: %s: pin %s\n", codec->name, pin); 2086 pr_debug("dapm: %s: pin %s\n", dapm->codec->name, pin);
2072 w->connected = 1; 2087 w->connected = 1;
2073 w->force = 1; 2088 w->force = 1;
2074 return 0; 2089 return 0;
2075 } 2090 }
2076 } 2091 }
2077 2092
2078 pr_err("dapm: %s: configuring unknown pin %s\n", codec->name, pin); 2093 pr_err("dapm: %s: configuring unknown pin %s\n",
2094 dapm->codec->name, pin);
2079 return -EINVAL; 2095 return -EINVAL;
2080} 2096}
2081EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin); 2097EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
2082 2098
2083/** 2099/**
2084 * snd_soc_dapm_disable_pin - disable pin. 2100 * snd_soc_dapm_disable_pin - disable pin.
2085 * @codec: SoC codec 2101 * @dapm: DAPM context
2086 * @pin: pin name 2102 * @pin: pin name
2087 * 2103 *
2088 * Disables input/output pin and its parents or children widgets. 2104 * Disables input/output pin and its parents or children widgets.
2089 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 2105 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2090 * do any widget power switching. 2106 * do any widget power switching.
2091 */ 2107 */
2092int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin) 2108int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
2109 const char *pin)
2093{ 2110{
2094 return snd_soc_dapm_set_pin(codec, pin, 0); 2111 return snd_soc_dapm_set_pin(dapm, pin, 0);
2095} 2112}
2096EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin); 2113EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
2097 2114
2098/** 2115/**
2099 * snd_soc_dapm_nc_pin - permanently disable pin. 2116 * snd_soc_dapm_nc_pin - permanently disable pin.
2100 * @codec: SoC codec 2117 * @dapm: DAPM context
2101 * @pin: pin name 2118 * @pin: pin name
2102 * 2119 *
2103 * Marks the specified pin as being not connected, disabling it along 2120 * Marks the specified pin as being not connected, disabling it along
@@ -2109,26 +2126,27 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
2109 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 2126 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
2110 * do any widget power switching. 2127 * do any widget power switching.
2111 */ 2128 */
2112int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin) 2129int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
2113{ 2130{
2114 return snd_soc_dapm_set_pin(codec, pin, 0); 2131 return snd_soc_dapm_set_pin(dapm, pin, 0);
2115} 2132}
2116EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin); 2133EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
2117 2134
2118/** 2135/**
2119 * snd_soc_dapm_get_pin_status - get audio pin status 2136 * snd_soc_dapm_get_pin_status - get audio pin status
2120 * @codec: audio codec 2137 * @dapm: DAPM context
2121 * @pin: audio signal pin endpoint (or start point) 2138 * @pin: audio signal pin endpoint (or start point)
2122 * 2139 *
2123 * Get audio pin status - connected or disconnected. 2140 * Get audio pin status - connected or disconnected.
2124 * 2141 *
2125 * Returns 1 for connected otherwise 0. 2142 * Returns 1 for connected otherwise 0.
2126 */ 2143 */
2127int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin) 2144int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
2145 const char *pin)
2128{ 2146{
2129 struct snd_soc_dapm_widget *w; 2147 struct snd_soc_dapm_widget *w;
2130 2148
2131 list_for_each_entry(w, &codec->dapm_widgets, list) { 2149 list_for_each_entry(w, &dapm->widgets, list) {
2132 if (!strcmp(w->name, pin)) 2150 if (!strcmp(w->name, pin))
2133 return w->connected; 2151 return w->connected;
2134 } 2152 }
@@ -2139,7 +2157,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
2139 2157
2140/** 2158/**
2141 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint 2159 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
2142 * @codec: audio codec 2160 * @dapm: DAPM context
2143 * @pin: audio signal pin endpoint (or start point) 2161 * @pin: audio signal pin endpoint (or start point)
2144 * 2162 *
2145 * Mark the given endpoint or pin as ignoring suspend. When the 2163 * Mark the given endpoint or pin as ignoring suspend. When the
@@ -2148,11 +2166,12 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
2148 * normal means at suspend time, it will not be turned on if it was not 2166 * normal means at suspend time, it will not be turned on if it was not
2149 * already enabled. 2167 * already enabled.
2150 */ 2168 */
2151int snd_soc_dapm_ignore_suspend(struct snd_soc_codec *codec, const char *pin) 2169int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
2170 const char *pin)
2152{ 2171{
2153 struct snd_soc_dapm_widget *w; 2172 struct snd_soc_dapm_widget *w;
2154 2173
2155 list_for_each_entry(w, &codec->dapm_widgets, list) { 2174 list_for_each_entry(w, &dapm->widgets, list) {
2156 if (!strcmp(w->name, pin)) { 2175 if (!strcmp(w->name, pin)) {
2157 w->ignore_suspend = 1; 2176 w->ignore_suspend = 1;
2158 return 0; 2177 return 0;
@@ -2170,20 +2189,20 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
2170 * 2189 *
2171 * Free all dapm widgets and resources. 2190 * Free all dapm widgets and resources.
2172 */ 2191 */
2173void snd_soc_dapm_free(struct snd_soc_codec *codec) 2192void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
2174{ 2193{
2175 snd_soc_dapm_sys_remove(codec->dev); 2194 snd_soc_dapm_sys_remove(dapm->dev);
2176 dapm_free_widgets(codec); 2195 dapm_free_widgets(dapm);
2177} 2196}
2178EXPORT_SYMBOL_GPL(snd_soc_dapm_free); 2197EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
2179 2198
2180static void soc_dapm_shutdown_codec(struct snd_soc_codec *codec) 2199static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
2181{ 2200{
2182 struct snd_soc_dapm_widget *w; 2201 struct snd_soc_dapm_widget *w;
2183 LIST_HEAD(down_list); 2202 LIST_HEAD(down_list);
2184 int powerdown = 0; 2203 int powerdown = 0;
2185 2204
2186 list_for_each_entry(w, &codec->dapm_widgets, list) { 2205 list_for_each_entry(w, &dapm->widgets, list) {
2187 if (w->power) { 2206 if (w->power) {
2188 dapm_seq_insert(w, &down_list, dapm_down_seq); 2207 dapm_seq_insert(w, &down_list, dapm_down_seq);
2189 w->power = 0; 2208 w->power = 0;
@@ -2195,9 +2214,9 @@ static void soc_dapm_shutdown_codec(struct snd_soc_codec *codec)
2195 * standby. 2214 * standby.
2196 */ 2215 */
2197 if (powerdown) { 2216 if (powerdown) {
2198 snd_soc_dapm_set_bias_level(NULL, codec, SND_SOC_BIAS_PREPARE); 2217 snd_soc_dapm_set_bias_level(NULL, dapm, SND_SOC_BIAS_PREPARE);
2199 dapm_seq_run(codec, &down_list, 0, dapm_down_seq); 2218 dapm_seq_run(dapm, &down_list, 0, dapm_down_seq);
2200 snd_soc_dapm_set_bias_level(NULL, codec, SND_SOC_BIAS_STANDBY); 2219 snd_soc_dapm_set_bias_level(NULL, dapm, SND_SOC_BIAS_STANDBY);
2201 } 2220 }
2202} 2221}
2203 2222
@@ -2208,10 +2227,10 @@ void snd_soc_dapm_shutdown(struct snd_soc_card *card)
2208{ 2227{
2209 struct snd_soc_codec *codec; 2228 struct snd_soc_codec *codec;
2210 2229
2211 list_for_each_entry(codec, &card->codec_dev_list, list) 2230 list_for_each_entry(codec, &card->codec_dev_list, list) {
2212 soc_dapm_shutdown_codec(codec); 2231 soc_dapm_shutdown_codec(&codec->dapm);
2213 2232 snd_soc_dapm_set_bias_level(card, &codec->dapm, SND_SOC_BIAS_OFF);
2214 snd_soc_dapm_set_bias_level(card, codec, SND_SOC_BIAS_OFF); 2233 }
2215} 2234}
2216 2235
2217/* Module information */ 2236/* Module information */