2 * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 * o Changes power status of internal codec blocks depending on the
14 * dynamic configuration of codec internal audio paths and active
16 * o Platform power domain - can support external components i.e. amps and
17 * mic/headphone insertion events.
18 * o Automatic Mic Bias support
19 * o Jack insertion power event initiation - e.g. hp insertion will enable
21 * o Delayed power down of audio subsystem to reduce pops between a quick
26 #include <linux/module.h>
27 #include <linux/moduleparam.h>
28 #include <linux/init.h>
29 #include <linux/async.h>
30 #include <linux/delay.h>
32 #include <linux/bitops.h>
33 #include <linux/platform_device.h>
34 #include <linux/jiffies.h>
35 #include <linux/debugfs.h>
36 #include <linux/pm_runtime.h>
37 #include <linux/regulator/consumer.h>
38 #include <linux/clk.h>
39 #include <linux/slab.h>
40 #include <sound/core.h>
41 #include <sound/pcm.h>
42 #include <sound/pcm_params.h>
43 #include <sound/soc.h>
44 #include <sound/initval.h>
46 #include <trace/events/asoc.h>
48 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
50 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context
*dapm
,
51 struct snd_soc_dapm_widget
*wsource
, struct snd_soc_dapm_widget
*wsink
,
53 int (*connected
)(struct snd_soc_dapm_widget
*source
,
54 struct snd_soc_dapm_widget
*sink
));
55 static struct snd_soc_dapm_widget
*
56 snd_soc_dapm_new_control(struct snd_soc_dapm_context
*dapm
,
57 const struct snd_soc_dapm_widget
*widget
);
59 /* dapm power sequences - make this per codec in the future */
60 static int dapm_up_seq
[] = {
61 [snd_soc_dapm_pre
] = 0,
62 [snd_soc_dapm_regulator_supply
] = 1,
63 [snd_soc_dapm_clock_supply
] = 1,
64 [snd_soc_dapm_supply
] = 2,
65 [snd_soc_dapm_micbias
] = 3,
66 [snd_soc_dapm_dai_link
] = 2,
67 [snd_soc_dapm_dai_in
] = 4,
68 [snd_soc_dapm_dai_out
] = 4,
69 [snd_soc_dapm_aif_in
] = 4,
70 [snd_soc_dapm_aif_out
] = 4,
71 [snd_soc_dapm_mic
] = 5,
72 [snd_soc_dapm_mux
] = 6,
73 [snd_soc_dapm_dac
] = 7,
74 [snd_soc_dapm_switch
] = 8,
75 [snd_soc_dapm_mixer
] = 8,
76 [snd_soc_dapm_mixer_named_ctl
] = 8,
77 [snd_soc_dapm_pga
] = 9,
78 [snd_soc_dapm_adc
] = 10,
79 [snd_soc_dapm_out_drv
] = 11,
80 [snd_soc_dapm_hp
] = 11,
81 [snd_soc_dapm_spk
] = 11,
82 [snd_soc_dapm_line
] = 11,
83 [snd_soc_dapm_kcontrol
] = 12,
84 [snd_soc_dapm_post
] = 13,
87 static int dapm_down_seq
[] = {
88 [snd_soc_dapm_pre
] = 0,
89 [snd_soc_dapm_kcontrol
] = 1,
90 [snd_soc_dapm_adc
] = 2,
91 [snd_soc_dapm_hp
] = 3,
92 [snd_soc_dapm_spk
] = 3,
93 [snd_soc_dapm_line
] = 3,
94 [snd_soc_dapm_out_drv
] = 3,
95 [snd_soc_dapm_pga
] = 4,
96 [snd_soc_dapm_switch
] = 5,
97 [snd_soc_dapm_mixer_named_ctl
] = 5,
98 [snd_soc_dapm_mixer
] = 5,
99 [snd_soc_dapm_dac
] = 6,
100 [snd_soc_dapm_mic
] = 7,
101 [snd_soc_dapm_micbias
] = 8,
102 [snd_soc_dapm_mux
] = 9,
103 [snd_soc_dapm_aif_in
] = 10,
104 [snd_soc_dapm_aif_out
] = 10,
105 [snd_soc_dapm_dai_in
] = 10,
106 [snd_soc_dapm_dai_out
] = 10,
107 [snd_soc_dapm_dai_link
] = 11,
108 [snd_soc_dapm_supply
] = 12,
109 [snd_soc_dapm_clock_supply
] = 13,
110 [snd_soc_dapm_regulator_supply
] = 13,
111 [snd_soc_dapm_post
] = 14,
114 static void dapm_assert_locked(struct snd_soc_dapm_context
*dapm
)
116 if (dapm
->card
&& dapm
->card
->instantiated
)
117 lockdep_assert_held(&dapm
->card
->dapm_mutex
);
120 static void pop_wait(u32 pop_time
)
123 schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time
));
126 static void pop_dbg(struct device
*dev
, u32 pop_time
, const char *fmt
, ...)
134 buf
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
139 vsnprintf(buf
, PAGE_SIZE
, fmt
, args
);
140 dev_info(dev
, "%s", buf
);
146 static bool dapm_dirty_widget(struct snd_soc_dapm_widget
*w
)
148 return !list_empty(&w
->dirty
);
151 static void dapm_mark_dirty(struct snd_soc_dapm_widget
*w
, const char *reason
)
153 dapm_assert_locked(w
->dapm
);
155 if (!dapm_dirty_widget(w
)) {
156 dev_vdbg(w
->dapm
->dev
, "Marking %s dirty due to %s\n",
158 list_add_tail(&w
->dirty
, &w
->dapm
->card
->dapm_dirty
);
162 void dapm_mark_io_dirty(struct snd_soc_dapm_context
*dapm
)
164 struct snd_soc_card
*card
= dapm
->card
;
165 struct snd_soc_dapm_widget
*w
;
167 mutex_lock(&card
->dapm_mutex
);
169 list_for_each_entry(w
, &card
->widgets
, list
) {
171 case snd_soc_dapm_input
:
172 case snd_soc_dapm_output
:
173 dapm_mark_dirty(w
, "Rechecking inputs and outputs");
180 mutex_unlock(&card
->dapm_mutex
);
182 EXPORT_SYMBOL_GPL(dapm_mark_io_dirty
);
184 /* create a new dapm widget */
185 static inline struct snd_soc_dapm_widget
*dapm_cnew_widget(
186 const struct snd_soc_dapm_widget
*_widget
)
188 return kmemdup(_widget
, sizeof(*_widget
), GFP_KERNEL
);
191 struct dapm_kcontrol_data
{
193 struct snd_soc_dapm_widget
*widget
;
194 struct list_head paths
;
195 struct snd_soc_dapm_widget_list
*wlist
;
198 static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget
*widget
,
199 struct snd_kcontrol
*kcontrol
)
201 struct dapm_kcontrol_data
*data
;
202 struct soc_mixer_control
*mc
;
204 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
206 dev_err(widget
->dapm
->dev
,
207 "ASoC: can't allocate kcontrol data for %s\n",
212 INIT_LIST_HEAD(&data
->paths
);
214 switch (widget
->id
) {
215 case snd_soc_dapm_switch
:
216 case snd_soc_dapm_mixer
:
217 case snd_soc_dapm_mixer_named_ctl
:
218 mc
= (struct soc_mixer_control
*)kcontrol
->private_value
;
220 if (mc
->autodisable
) {
221 struct snd_soc_dapm_widget
template;
223 memset(&template, 0, sizeof(template));
224 template.reg
= mc
->reg
;
225 template.mask
= (1 << fls(mc
->max
)) - 1;
226 template.shift
= mc
->shift
;
228 template.off_val
= mc
->max
;
230 template.off_val
= 0;
231 template.on_val
= template.off_val
;
232 template.id
= snd_soc_dapm_kcontrol
;
233 template.name
= kcontrol
->id
.name
;
235 data
->value
= template.on_val
;
237 data
->widget
= snd_soc_dapm_new_control(widget
->dapm
,
249 kcontrol
->private_data
= data
;
254 static void dapm_kcontrol_free(struct snd_kcontrol
*kctl
)
256 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kctl
);
261 static struct snd_soc_dapm_widget_list
*dapm_kcontrol_get_wlist(
262 const struct snd_kcontrol
*kcontrol
)
264 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
269 static int dapm_kcontrol_add_widget(struct snd_kcontrol
*kcontrol
,
270 struct snd_soc_dapm_widget
*widget
)
272 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
273 struct snd_soc_dapm_widget_list
*new_wlist
;
277 n
= data
->wlist
->num_widgets
+ 1;
281 new_wlist
= krealloc(data
->wlist
,
282 sizeof(*new_wlist
) + sizeof(widget
) * n
, GFP_KERNEL
);
286 new_wlist
->widgets
[n
- 1] = widget
;
287 new_wlist
->num_widgets
= n
;
289 data
->wlist
= new_wlist
;
294 static void dapm_kcontrol_add_path(const struct snd_kcontrol
*kcontrol
,
295 struct snd_soc_dapm_path
*path
)
297 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
299 list_add_tail(&path
->list_kcontrol
, &data
->paths
);
302 snd_soc_dapm_add_path(data
->widget
->dapm
, data
->widget
,
303 path
->source
, NULL
, NULL
);
307 static bool dapm_kcontrol_is_powered(const struct snd_kcontrol
*kcontrol
)
309 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
314 return data
->widget
->power
;
317 static struct list_head
*dapm_kcontrol_get_path_list(
318 const struct snd_kcontrol
*kcontrol
)
320 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
325 #define dapm_kcontrol_for_each_path(path, kcontrol) \
326 list_for_each_entry(path, dapm_kcontrol_get_path_list(kcontrol), \
329 static unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol
*kcontrol
)
331 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
336 static bool dapm_kcontrol_set_value(const struct snd_kcontrol
*kcontrol
,
339 struct dapm_kcontrol_data
*data
= snd_kcontrol_chip(kcontrol
);
341 if (data
->value
== value
)
345 data
->widget
->on_val
= value
;
353 * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol
354 * @kcontrol: The kcontrol
356 struct snd_soc_codec
*snd_soc_dapm_kcontrol_codec(struct snd_kcontrol
*kcontrol
)
358 return dapm_kcontrol_get_wlist(kcontrol
)->widgets
[0]->codec
;
360 EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_codec
);
362 static void dapm_reset(struct snd_soc_card
*card
)
364 struct snd_soc_dapm_widget
*w
;
366 lockdep_assert_held(&card
->dapm_mutex
);
368 memset(&card
->dapm_stats
, 0, sizeof(card
->dapm_stats
));
370 list_for_each_entry(w
, &card
->widgets
, list
) {
371 w
->new_power
= w
->power
;
372 w
->power_checked
= false;
378 static int soc_widget_read(struct snd_soc_dapm_widget
*w
, int reg
,
382 *value
= snd_soc_read(w
->codec
, reg
);
384 } else if (w
->platform
) {
385 *value
= snd_soc_platform_read(w
->platform
, reg
);
389 dev_err(w
->dapm
->dev
, "ASoC: no valid widget read method\n");
393 static int soc_widget_write(struct snd_soc_dapm_widget
*w
, int reg
,
397 return snd_soc_write(w
->codec
, reg
, val
);
398 else if (w
->platform
)
399 return snd_soc_platform_write(w
->platform
, reg
, val
);
401 dev_err(w
->dapm
->dev
, "ASoC: no valid widget write method\n");
405 static inline void soc_widget_lock(struct snd_soc_dapm_widget
*w
)
407 if (w
->codec
&& !w
->codec
->using_regmap
)
408 mutex_lock(&w
->codec
->mutex
);
409 else if (w
->platform
)
410 mutex_lock(&w
->platform
->mutex
);
413 static inline void soc_widget_unlock(struct snd_soc_dapm_widget
*w
)
415 if (w
->codec
&& !w
->codec
->using_regmap
)
416 mutex_unlock(&w
->codec
->mutex
);
417 else if (w
->platform
)
418 mutex_unlock(&w
->platform
->mutex
);
421 static void soc_dapm_async_complete(struct snd_soc_dapm_context
*dapm
)
423 if (dapm
->codec
&& dapm
->codec
->using_regmap
)
424 regmap_async_complete(dapm
->codec
->control_data
);
427 static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget
*w
,
428 unsigned short reg
, unsigned int mask
, unsigned int value
)
431 unsigned int old
, new;
434 if (w
->codec
&& w
->codec
->using_regmap
) {
435 ret
= regmap_update_bits_check_async(w
->codec
->control_data
,
442 ret
= soc_widget_read(w
, reg
, &old
);
444 soc_widget_unlock(w
);
448 new = (old
& ~mask
) | (value
& mask
);
451 ret
= soc_widget_write(w
, reg
, new);
453 soc_widget_unlock(w
);
457 soc_widget_unlock(w
);
464 * snd_soc_dapm_set_bias_level - set the bias level for the system
465 * @dapm: DAPM context
466 * @level: level to configure
468 * Configure the bias (power) levels for the SoC audio device.
470 * Returns 0 for success else error.
472 static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context
*dapm
,
473 enum snd_soc_bias_level level
)
475 struct snd_soc_card
*card
= dapm
->card
;
478 trace_snd_soc_bias_level_start(card
, level
);
480 if (card
&& card
->set_bias_level
)
481 ret
= card
->set_bias_level(card
, dapm
, level
);
486 if (dapm
->codec
->driver
->set_bias_level
)
487 ret
= dapm
->codec
->driver
->set_bias_level(dapm
->codec
,
490 dapm
->bias_level
= level
;
491 } else if (!card
|| dapm
!= &card
->dapm
) {
492 dapm
->bias_level
= level
;
498 if (card
&& card
->set_bias_level_post
)
499 ret
= card
->set_bias_level_post(card
, dapm
, level
);
501 trace_snd_soc_bias_level_done(card
, level
);
506 /* connect mux widget to its interconnecting audio paths */
507 static int dapm_connect_mux(struct snd_soc_dapm_context
*dapm
,
508 struct snd_soc_dapm_widget
*src
, struct snd_soc_dapm_widget
*dest
,
509 struct snd_soc_dapm_path
*path
, const char *control_name
,
510 const struct snd_kcontrol_new
*kcontrol
)
512 struct soc_enum
*e
= (struct soc_enum
*)kcontrol
->private_value
;
513 unsigned int val
, item
;
516 if (e
->reg
!= SND_SOC_NOPM
) {
517 soc_widget_read(dest
, e
->reg
, &val
);
518 val
= (val
>> e
->shift_l
) & e
->mask
;
519 item
= snd_soc_enum_val_to_item(e
, val
);
521 /* since a virtual mux has no backing registers to
522 * decide which path to connect, it will try to match
523 * with the first enumeration. This is to ensure
524 * that the default mux choice (the first) will be
525 * correctly powered up during initialization.
530 for (i
= 0; i
< e
->items
; i
++) {
531 if (!(strcmp(control_name
, e
->texts
[i
]))) {
532 list_add(&path
->list
, &dapm
->card
->paths
);
533 list_add(&path
->list_sink
, &dest
->sources
);
534 list_add(&path
->list_source
, &src
->sinks
);
535 path
->name
= (char*)e
->texts
[i
];
547 /* set up initial codec paths */
548 static void dapm_set_mixer_path_status(struct snd_soc_dapm_widget
*w
,
549 struct snd_soc_dapm_path
*p
, int i
)
551 struct soc_mixer_control
*mc
= (struct soc_mixer_control
*)
552 w
->kcontrol_news
[i
].private_value
;
553 unsigned int reg
= mc
->reg
;
554 unsigned int shift
= mc
->shift
;
555 unsigned int max
= mc
->max
;
556 unsigned int mask
= (1 << fls(max
)) - 1;
557 unsigned int invert
= mc
->invert
;
560 if (reg
!= SND_SOC_NOPM
) {
561 soc_widget_read(w
, reg
, &val
);
562 val
= (val
>> shift
) & mask
;
571 /* connect mixer widget to its interconnecting audio paths */
572 static int dapm_connect_mixer(struct snd_soc_dapm_context
*dapm
,
573 struct snd_soc_dapm_widget
*src
, struct snd_soc_dapm_widget
*dest
,
574 struct snd_soc_dapm_path
*path
, const char *control_name
)
578 /* search for mixer kcontrol */
579 for (i
= 0; i
< dest
->num_kcontrols
; i
++) {
580 if (!strcmp(control_name
, dest
->kcontrol_news
[i
].name
)) {
581 list_add(&path
->list
, &dapm
->card
->paths
);
582 list_add(&path
->list_sink
, &dest
->sources
);
583 list_add(&path
->list_source
, &src
->sinks
);
584 path
->name
= dest
->kcontrol_news
[i
].name
;
585 dapm_set_mixer_path_status(dest
, path
, i
);
592 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context
*dapm
,
593 struct snd_soc_dapm_widget
*kcontrolw
,
594 const struct snd_kcontrol_new
*kcontrol_new
,
595 struct snd_kcontrol
**kcontrol
)
597 struct snd_soc_dapm_widget
*w
;
602 list_for_each_entry(w
, &dapm
->card
->widgets
, list
) {
603 if (w
== kcontrolw
|| w
->dapm
!= kcontrolw
->dapm
)
605 for (i
= 0; i
< w
->num_kcontrols
; i
++) {
606 if (&w
->kcontrol_news
[i
] == kcontrol_new
) {
608 *kcontrol
= w
->kcontrols
[i
];
618 * Determine if a kcontrol is shared. If it is, look it up. If it isn't,
619 * create it. Either way, add the widget into the control's widget list
621 static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget
*w
,
624 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
625 struct snd_card
*card
= dapm
->card
->snd_card
;
629 struct snd_kcontrol
*kcontrol
;
630 bool wname_in_long_name
, kcname_in_long_name
;
636 prefix
= dapm
->codec
->name_prefix
;
641 prefix_len
= strlen(prefix
) + 1;
645 shared
= dapm_is_shared_kcontrol(dapm
, w
, &w
->kcontrol_news
[kci
],
650 wname_in_long_name
= false;
651 kcname_in_long_name
= true;
654 case snd_soc_dapm_switch
:
655 case snd_soc_dapm_mixer
:
656 wname_in_long_name
= true;
657 kcname_in_long_name
= true;
659 case snd_soc_dapm_mixer_named_ctl
:
660 wname_in_long_name
= false;
661 kcname_in_long_name
= true;
663 case snd_soc_dapm_mux
:
664 wname_in_long_name
= true;
665 kcname_in_long_name
= false;
672 if (wname_in_long_name
&& kcname_in_long_name
) {
674 * The control will get a prefix from the control
675 * creation process but we're also using the same
676 * prefix for widgets so cut the prefix off the
677 * front of the widget name.
679 long_name
= kasprintf(GFP_KERNEL
, "%s %s",
680 w
->name
+ prefix_len
,
681 w
->kcontrol_news
[kci
].name
);
682 if (long_name
== NULL
)
686 } else if (wname_in_long_name
) {
688 name
= w
->name
+ prefix_len
;
691 name
= w
->kcontrol_news
[kci
].name
;
694 kcontrol
= snd_soc_cnew(&w
->kcontrol_news
[kci
], NULL
, name
,
699 kcontrol
->private_free
= dapm_kcontrol_free
;
701 ret
= dapm_kcontrol_data_alloc(w
, kcontrol
);
703 snd_ctl_free_one(kcontrol
);
707 ret
= snd_ctl_add(card
, kcontrol
);
710 "ASoC: failed to add widget %s dapm kcontrol %s: %d\n",
716 ret
= dapm_kcontrol_add_widget(kcontrol
, w
);
720 w
->kcontrols
[kci
] = kcontrol
;
725 /* create new dapm mixer control */
726 static int dapm_new_mixer(struct snd_soc_dapm_widget
*w
)
729 struct snd_soc_dapm_path
*path
;
732 for (i
= 0; i
< w
->num_kcontrols
; i
++) {
734 list_for_each_entry(path
, &w
->sources
, list_sink
) {
735 /* mixer/mux paths name must match control name */
736 if (path
->name
!= (char *)w
->kcontrol_news
[i
].name
)
739 if (w
->kcontrols
[i
]) {
740 dapm_kcontrol_add_path(w
->kcontrols
[i
], path
);
744 ret
= dapm_create_or_share_mixmux_kcontrol(w
, i
);
748 dapm_kcontrol_add_path(w
->kcontrols
[i
], path
);
755 /* create new dapm mux control */
756 static int dapm_new_mux(struct snd_soc_dapm_widget
*w
)
758 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
759 struct snd_soc_dapm_path
*path
;
762 if (w
->num_kcontrols
!= 1) {
764 "ASoC: mux %s has incorrect number of controls\n",
769 if (list_empty(&w
->sources
)) {
770 dev_err(dapm
->dev
, "ASoC: mux %s has no paths\n", w
->name
);
774 ret
= dapm_create_or_share_mixmux_kcontrol(w
, 0);
778 list_for_each_entry(path
, &w
->sources
, list_sink
)
779 dapm_kcontrol_add_path(w
->kcontrols
[0], path
);
784 /* create new dapm volume control */
785 static int dapm_new_pga(struct snd_soc_dapm_widget
*w
)
787 if (w
->num_kcontrols
)
788 dev_err(w
->dapm
->dev
,
789 "ASoC: PGA controls not supported: '%s'\n", w
->name
);
794 /* reset 'walked' bit for each dapm path */
795 static void dapm_clear_walk_output(struct snd_soc_dapm_context
*dapm
,
796 struct list_head
*sink
)
798 struct snd_soc_dapm_path
*p
;
800 list_for_each_entry(p
, sink
, list_source
) {
803 dapm_clear_walk_output(dapm
, &p
->sink
->sinks
);
808 static void dapm_clear_walk_input(struct snd_soc_dapm_context
*dapm
,
809 struct list_head
*source
)
811 struct snd_soc_dapm_path
*p
;
813 list_for_each_entry(p
, source
, list_sink
) {
816 dapm_clear_walk_input(dapm
, &p
->source
->sources
);
822 /* We implement power down on suspend by checking the power state of
823 * the ALSA card - when we are suspending the ALSA state for the card
826 static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget
*widget
)
828 int level
= snd_power_get_state(widget
->dapm
->card
->snd_card
);
831 case SNDRV_CTL_POWER_D3hot
:
832 case SNDRV_CTL_POWER_D3cold
:
833 if (widget
->ignore_suspend
)
834 dev_dbg(widget
->dapm
->dev
, "ASoC: %s ignoring suspend\n",
836 return widget
->ignore_suspend
;
842 /* add widget to list if it's not already in the list */
843 static int dapm_list_add_widget(struct snd_soc_dapm_widget_list
**list
,
844 struct snd_soc_dapm_widget
*w
)
846 struct snd_soc_dapm_widget_list
*wlist
;
847 int wlistsize
, wlistentries
, i
;
854 /* is this widget already in the list */
855 for (i
= 0; i
< wlist
->num_widgets
; i
++) {
856 if (wlist
->widgets
[i
] == w
)
860 /* allocate some new space */
861 wlistentries
= wlist
->num_widgets
+ 1;
862 wlistsize
= sizeof(struct snd_soc_dapm_widget_list
) +
863 wlistentries
* sizeof(struct snd_soc_dapm_widget
*);
864 *list
= krealloc(wlist
, wlistsize
, GFP_KERNEL
);
866 dev_err(w
->dapm
->dev
, "ASoC: can't allocate widget list for %s\n",
872 /* insert the widget */
873 dev_dbg(w
->dapm
->dev
, "ASoC: added %s in widget list pos %d\n",
874 w
->name
, wlist
->num_widgets
);
876 wlist
->widgets
[wlist
->num_widgets
] = w
;
877 wlist
->num_widgets
++;
882 * Recursively check for a completed path to an active or physically connected
883 * output widget. Returns number of complete paths.
885 static int is_connected_output_ep(struct snd_soc_dapm_widget
*widget
,
886 struct snd_soc_dapm_widget_list
**list
)
888 struct snd_soc_dapm_path
*path
;
891 if (widget
->outputs
>= 0)
892 return widget
->outputs
;
894 DAPM_UPDATE_STAT(widget
, path_checks
);
896 switch (widget
->id
) {
897 case snd_soc_dapm_supply
:
898 case snd_soc_dapm_regulator_supply
:
899 case snd_soc_dapm_clock_supply
:
900 case snd_soc_dapm_kcontrol
:
906 switch (widget
->id
) {
907 case snd_soc_dapm_adc
:
908 case snd_soc_dapm_aif_out
:
909 case snd_soc_dapm_dai_out
:
910 if (widget
->active
) {
911 widget
->outputs
= snd_soc_dapm_suspend_check(widget
);
912 return widget
->outputs
;
918 if (widget
->connected
) {
919 /* connected pin ? */
920 if (widget
->id
== snd_soc_dapm_output
&& !widget
->ext
) {
921 widget
->outputs
= snd_soc_dapm_suspend_check(widget
);
922 return widget
->outputs
;
925 /* connected jack or spk ? */
926 if (widget
->id
== snd_soc_dapm_hp
||
927 widget
->id
== snd_soc_dapm_spk
||
928 (widget
->id
== snd_soc_dapm_line
&&
929 !list_empty(&widget
->sources
))) {
930 widget
->outputs
= snd_soc_dapm_suspend_check(widget
);
931 return widget
->outputs
;
935 list_for_each_entry(path
, &widget
->sinks
, list_source
) {
936 DAPM_UPDATE_STAT(widget
, neighbour_checks
);
947 trace_snd_soc_dapm_output_path(widget
, path
);
949 if (path
->sink
&& path
->connect
) {
953 /* do we need to add this widget to the list ? */
956 err
= dapm_list_add_widget(list
, path
->sink
);
958 dev_err(widget
->dapm
->dev
,
959 "ASoC: could not add widget %s\n",
966 con
+= is_connected_output_ep(path
->sink
, list
);
972 widget
->outputs
= con
;
978 * Recursively check for a completed path to an active or physically connected
979 * input widget. Returns number of complete paths.
981 static int is_connected_input_ep(struct snd_soc_dapm_widget
*widget
,
982 struct snd_soc_dapm_widget_list
**list
)
984 struct snd_soc_dapm_path
*path
;
987 if (widget
->inputs
>= 0)
988 return widget
->inputs
;
990 DAPM_UPDATE_STAT(widget
, path_checks
);
992 switch (widget
->id
) {
993 case snd_soc_dapm_supply
:
994 case snd_soc_dapm_regulator_supply
:
995 case snd_soc_dapm_clock_supply
:
996 case snd_soc_dapm_kcontrol
:
1002 /* active stream ? */
1003 switch (widget
->id
) {
1004 case snd_soc_dapm_dac
:
1005 case snd_soc_dapm_aif_in
:
1006 case snd_soc_dapm_dai_in
:
1007 if (widget
->active
) {
1008 widget
->inputs
= snd_soc_dapm_suspend_check(widget
);
1009 return widget
->inputs
;
1015 if (widget
->connected
) {
1016 /* connected pin ? */
1017 if (widget
->id
== snd_soc_dapm_input
&& !widget
->ext
) {
1018 widget
->inputs
= snd_soc_dapm_suspend_check(widget
);
1019 return widget
->inputs
;
1022 /* connected VMID/Bias for lower pops */
1023 if (widget
->id
== snd_soc_dapm_vmid
) {
1024 widget
->inputs
= snd_soc_dapm_suspend_check(widget
);
1025 return widget
->inputs
;
1028 /* connected jack ? */
1029 if (widget
->id
== snd_soc_dapm_mic
||
1030 (widget
->id
== snd_soc_dapm_line
&&
1031 !list_empty(&widget
->sinks
))) {
1032 widget
->inputs
= snd_soc_dapm_suspend_check(widget
);
1033 return widget
->inputs
;
1036 /* signal generator */
1037 if (widget
->id
== snd_soc_dapm_siggen
) {
1038 widget
->inputs
= snd_soc_dapm_suspend_check(widget
);
1039 return widget
->inputs
;
1043 list_for_each_entry(path
, &widget
->sources
, list_sink
) {
1044 DAPM_UPDATE_STAT(widget
, neighbour_checks
);
1055 trace_snd_soc_dapm_input_path(widget
, path
);
1057 if (path
->source
&& path
->connect
) {
1061 /* do we need to add this widget to the list ? */
1064 err
= dapm_list_add_widget(list
, path
->source
);
1066 dev_err(widget
->dapm
->dev
,
1067 "ASoC: could not add widget %s\n",
1074 con
+= is_connected_input_ep(path
->source
, list
);
1080 widget
->inputs
= con
;
1086 * snd_soc_dapm_get_connected_widgets - query audio path and it's widgets.
1087 * @dai: the soc DAI.
1088 * @stream: stream direction.
1089 * @list: list of active widgets for this stream.
1091 * Queries DAPM graph as to whether an valid audio stream path exists for
1092 * the initial stream specified by name. This takes into account
1093 * current mixer and mux kcontrol settings. Creates list of valid widgets.
1095 * Returns the number of valid paths or negative error.
1097 int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai
*dai
, int stream
,
1098 struct snd_soc_dapm_widget_list
**list
)
1100 struct snd_soc_card
*card
= dai
->card
;
1103 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
1106 if (stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
1107 paths
= is_connected_output_ep(dai
->playback_widget
, list
);
1108 dapm_clear_walk_output(&card
->dapm
,
1109 &dai
->playback_widget
->sinks
);
1111 paths
= is_connected_input_ep(dai
->capture_widget
, list
);
1112 dapm_clear_walk_input(&card
->dapm
,
1113 &dai
->capture_widget
->sources
);
1116 trace_snd_soc_dapm_connected(paths
, stream
);
1117 mutex_unlock(&card
->dapm_mutex
);
1123 * Handler for generic register modifier widget.
1125 int dapm_reg_event(struct snd_soc_dapm_widget
*w
,
1126 struct snd_kcontrol
*kcontrol
, int event
)
1130 if (SND_SOC_DAPM_EVENT_ON(event
))
1135 soc_widget_update_bits_locked(w
, -(w
->reg
+ 1),
1136 w
->mask
<< w
->shift
, val
<< w
->shift
);
1140 EXPORT_SYMBOL_GPL(dapm_reg_event
);
1143 * Handler for regulator supply widget.
1145 int dapm_regulator_event(struct snd_soc_dapm_widget
*w
,
1146 struct snd_kcontrol
*kcontrol
, int event
)
1150 soc_dapm_async_complete(w
->dapm
);
1152 if (SND_SOC_DAPM_EVENT_ON(event
)) {
1153 if (w
->on_val
& SND_SOC_DAPM_REGULATOR_BYPASS
) {
1154 ret
= regulator_allow_bypass(w
->regulator
, false);
1156 dev_warn(w
->dapm
->dev
,
1157 "ASoC: Failed to unbypass %s: %d\n",
1161 return regulator_enable(w
->regulator
);
1163 if (w
->on_val
& SND_SOC_DAPM_REGULATOR_BYPASS
) {
1164 ret
= regulator_allow_bypass(w
->regulator
, true);
1166 dev_warn(w
->dapm
->dev
,
1167 "ASoC: Failed to bypass %s: %d\n",
1171 return regulator_disable_deferred(w
->regulator
, w
->shift
);
1174 EXPORT_SYMBOL_GPL(dapm_regulator_event
);
1177 * Handler for clock supply widget.
1179 int dapm_clock_event(struct snd_soc_dapm_widget
*w
,
1180 struct snd_kcontrol
*kcontrol
, int event
)
1185 soc_dapm_async_complete(w
->dapm
);
1187 #ifdef CONFIG_HAVE_CLK
1188 if (SND_SOC_DAPM_EVENT_ON(event
)) {
1189 return clk_prepare_enable(w
->clk
);
1191 clk_disable_unprepare(w
->clk
);
1197 EXPORT_SYMBOL_GPL(dapm_clock_event
);
1199 static int dapm_widget_power_check(struct snd_soc_dapm_widget
*w
)
1201 if (w
->power_checked
)
1202 return w
->new_power
;
1207 w
->new_power
= w
->power_check(w
);
1209 w
->power_checked
= true;
1211 return w
->new_power
;
1214 /* Generic check to see if a widget should be powered.
1216 static int dapm_generic_check_power(struct snd_soc_dapm_widget
*w
)
1220 DAPM_UPDATE_STAT(w
, power_checks
);
1222 in
= is_connected_input_ep(w
, NULL
);
1223 dapm_clear_walk_input(w
->dapm
, &w
->sources
);
1224 out
= is_connected_output_ep(w
, NULL
);
1225 dapm_clear_walk_output(w
->dapm
, &w
->sinks
);
1226 return out
!= 0 && in
!= 0;
1229 /* Check to see if an ADC has power */
1230 static int dapm_adc_check_power(struct snd_soc_dapm_widget
*w
)
1234 DAPM_UPDATE_STAT(w
, power_checks
);
1237 in
= is_connected_input_ep(w
, NULL
);
1238 dapm_clear_walk_input(w
->dapm
, &w
->sources
);
1241 return dapm_generic_check_power(w
);
1245 /* Check to see if a DAC has power */
1246 static int dapm_dac_check_power(struct snd_soc_dapm_widget
*w
)
1250 DAPM_UPDATE_STAT(w
, power_checks
);
1253 out
= is_connected_output_ep(w
, NULL
);
1254 dapm_clear_walk_output(w
->dapm
, &w
->sinks
);
1257 return dapm_generic_check_power(w
);
1261 /* Check to see if a power supply is needed */
1262 static int dapm_supply_check_power(struct snd_soc_dapm_widget
*w
)
1264 struct snd_soc_dapm_path
*path
;
1266 DAPM_UPDATE_STAT(w
, power_checks
);
1268 /* Check if one of our outputs is connected */
1269 list_for_each_entry(path
, &w
->sinks
, list_source
) {
1270 DAPM_UPDATE_STAT(w
, neighbour_checks
);
1275 if (path
->connected
&&
1276 !path
->connected(path
->source
, path
->sink
))
1282 if (dapm_widget_power_check(path
->sink
))
1289 static int dapm_always_on_check_power(struct snd_soc_dapm_widget
*w
)
1294 static int dapm_seq_compare(struct snd_soc_dapm_widget
*a
,
1295 struct snd_soc_dapm_widget
*b
,
1303 sort
= dapm_down_seq
;
1305 if (sort
[a
->id
] != sort
[b
->id
])
1306 return sort
[a
->id
] - sort
[b
->id
];
1307 if (a
->subseq
!= b
->subseq
) {
1309 return a
->subseq
- b
->subseq
;
1311 return b
->subseq
- a
->subseq
;
1313 if (a
->reg
!= b
->reg
)
1314 return a
->reg
- b
->reg
;
1315 if (a
->dapm
!= b
->dapm
)
1316 return (unsigned long)a
->dapm
- (unsigned long)b
->dapm
;
1321 /* Insert a widget in order into a DAPM power sequence. */
1322 static void dapm_seq_insert(struct snd_soc_dapm_widget
*new_widget
,
1323 struct list_head
*list
,
1326 struct snd_soc_dapm_widget
*w
;
1328 list_for_each_entry(w
, list
, power_list
)
1329 if (dapm_seq_compare(new_widget
, w
, power_up
) < 0) {
1330 list_add_tail(&new_widget
->power_list
, &w
->power_list
);
1334 list_add_tail(&new_widget
->power_list
, list
);
1337 static void dapm_seq_check_event(struct snd_soc_card
*card
,
1338 struct snd_soc_dapm_widget
*w
, int event
)
1340 const char *ev_name
;
1344 case SND_SOC_DAPM_PRE_PMU
:
1345 ev_name
= "PRE_PMU";
1348 case SND_SOC_DAPM_POST_PMU
:
1349 ev_name
= "POST_PMU";
1352 case SND_SOC_DAPM_PRE_PMD
:
1353 ev_name
= "PRE_PMD";
1356 case SND_SOC_DAPM_POST_PMD
:
1357 ev_name
= "POST_PMD";
1360 case SND_SOC_DAPM_WILL_PMU
:
1361 ev_name
= "WILL_PMU";
1364 case SND_SOC_DAPM_WILL_PMD
:
1365 ev_name
= "WILL_PMD";
1369 WARN(1, "Unknown event %d\n", event
);
1373 if (w
->new_power
!= power
)
1376 if (w
->event
&& (w
->event_flags
& event
)) {
1377 pop_dbg(w
->dapm
->dev
, card
->pop_time
, "pop test : %s %s\n",
1379 soc_dapm_async_complete(w
->dapm
);
1380 trace_snd_soc_dapm_widget_event_start(w
, event
);
1381 ret
= w
->event(w
, NULL
, event
);
1382 trace_snd_soc_dapm_widget_event_done(w
, event
);
1384 dev_err(w
->dapm
->dev
, "ASoC: %s: %s event failed: %d\n",
1385 ev_name
, w
->name
, ret
);
1389 /* Apply the coalesced changes from a DAPM sequence */
1390 static void dapm_seq_run_coalesced(struct snd_soc_card
*card
,
1391 struct list_head
*pending
)
1393 struct snd_soc_dapm_widget
*w
;
1395 unsigned int value
= 0;
1396 unsigned int mask
= 0;
1398 reg
= list_first_entry(pending
, struct snd_soc_dapm_widget
,
1401 list_for_each_entry(w
, pending
, power_list
) {
1402 WARN_ON(reg
!= w
->reg
);
1403 w
->power
= w
->new_power
;
1405 mask
|= w
->mask
<< w
->shift
;
1407 value
|= w
->on_val
<< w
->shift
;
1409 value
|= w
->off_val
<< w
->shift
;
1411 pop_dbg(w
->dapm
->dev
, card
->pop_time
,
1412 "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n",
1413 w
->name
, reg
, value
, mask
);
1415 /* Check for events */
1416 dapm_seq_check_event(card
, w
, SND_SOC_DAPM_PRE_PMU
);
1417 dapm_seq_check_event(card
, w
, SND_SOC_DAPM_PRE_PMD
);
1421 /* Any widget will do, they should all be updating the
1424 w
= list_first_entry(pending
, struct snd_soc_dapm_widget
,
1427 pop_dbg(w
->dapm
->dev
, card
->pop_time
,
1428 "pop test : Applying 0x%x/0x%x to %x in %dms\n",
1429 value
, mask
, reg
, card
->pop_time
);
1430 pop_wait(card
->pop_time
);
1431 soc_widget_update_bits_locked(w
, reg
, mask
, value
);
1434 list_for_each_entry(w
, pending
, power_list
) {
1435 dapm_seq_check_event(card
, w
, SND_SOC_DAPM_POST_PMU
);
1436 dapm_seq_check_event(card
, w
, SND_SOC_DAPM_POST_PMD
);
1440 /* Apply a DAPM power sequence.
1442 * We walk over a pre-sorted list of widgets to apply power to. In
1443 * order to minimise the number of writes to the device required
1444 * multiple widgets will be updated in a single write where possible.
1445 * Currently anything that requires more than a single write is not
1448 static void dapm_seq_run(struct snd_soc_card
*card
,
1449 struct list_head
*list
, int event
, bool power_up
)
1451 struct snd_soc_dapm_widget
*w
, *n
;
1452 struct snd_soc_dapm_context
*d
;
1455 int cur_subseq
= -1;
1456 int cur_reg
= SND_SOC_NOPM
;
1457 struct snd_soc_dapm_context
*cur_dapm
= NULL
;
1464 sort
= dapm_down_seq
;
1466 list_for_each_entry_safe(w
, n
, list
, power_list
) {
1469 /* Do we need to apply any queued changes? */
1470 if (sort
[w
->id
] != cur_sort
|| w
->reg
!= cur_reg
||
1471 w
->dapm
!= cur_dapm
|| w
->subseq
!= cur_subseq
) {
1472 if (!list_empty(&pending
))
1473 dapm_seq_run_coalesced(card
, &pending
);
1475 if (cur_dapm
&& cur_dapm
->seq_notifier
) {
1476 for (i
= 0; i
< ARRAY_SIZE(dapm_up_seq
); i
++)
1477 if (sort
[i
] == cur_sort
)
1478 cur_dapm
->seq_notifier(cur_dapm
,
1483 if (cur_dapm
&& w
->dapm
!= cur_dapm
)
1484 soc_dapm_async_complete(cur_dapm
);
1486 INIT_LIST_HEAD(&pending
);
1488 cur_subseq
= INT_MIN
;
1489 cur_reg
= SND_SOC_NOPM
;
1494 case snd_soc_dapm_pre
:
1496 list_for_each_entry_safe_continue(w
, n
, list
,
1499 if (event
== SND_SOC_DAPM_STREAM_START
)
1501 NULL
, SND_SOC_DAPM_PRE_PMU
);
1502 else if (event
== SND_SOC_DAPM_STREAM_STOP
)
1504 NULL
, SND_SOC_DAPM_PRE_PMD
);
1507 case snd_soc_dapm_post
:
1509 list_for_each_entry_safe_continue(w
, n
, list
,
1512 if (event
== SND_SOC_DAPM_STREAM_START
)
1514 NULL
, SND_SOC_DAPM_POST_PMU
);
1515 else if (event
== SND_SOC_DAPM_STREAM_STOP
)
1517 NULL
, SND_SOC_DAPM_POST_PMD
);
1521 /* Queue it up for application */
1522 cur_sort
= sort
[w
->id
];
1523 cur_subseq
= w
->subseq
;
1526 list_move(&w
->power_list
, &pending
);
1531 dev_err(w
->dapm
->dev
,
1532 "ASoC: Failed to apply widget power: %d\n", ret
);
1535 if (!list_empty(&pending
))
1536 dapm_seq_run_coalesced(card
, &pending
);
1538 if (cur_dapm
&& cur_dapm
->seq_notifier
) {
1539 for (i
= 0; i
< ARRAY_SIZE(dapm_up_seq
); i
++)
1540 if (sort
[i
] == cur_sort
)
1541 cur_dapm
->seq_notifier(cur_dapm
,
1545 list_for_each_entry(d
, &card
->dapm_list
, list
) {
1546 soc_dapm_async_complete(d
);
1550 static void dapm_widget_update(struct snd_soc_card
*card
)
1552 struct snd_soc_dapm_update
*update
= card
->update
;
1553 struct snd_soc_dapm_widget_list
*wlist
;
1554 struct snd_soc_dapm_widget
*w
= NULL
;
1558 if (!update
|| !dapm_kcontrol_is_powered(update
->kcontrol
))
1561 wlist
= dapm_kcontrol_get_wlist(update
->kcontrol
);
1563 for (wi
= 0; wi
< wlist
->num_widgets
; wi
++) {
1564 w
= wlist
->widgets
[wi
];
1566 if (w
->event
&& (w
->event_flags
& SND_SOC_DAPM_PRE_REG
)) {
1567 ret
= w
->event(w
, update
->kcontrol
, SND_SOC_DAPM_PRE_REG
);
1569 dev_err(w
->dapm
->dev
, "ASoC: %s DAPM pre-event failed: %d\n",
1577 ret
= soc_widget_update_bits_locked(w
, update
->reg
, update
->mask
,
1580 dev_err(w
->dapm
->dev
, "ASoC: %s DAPM update failed: %d\n",
1583 for (wi
= 0; wi
< wlist
->num_widgets
; wi
++) {
1584 w
= wlist
->widgets
[wi
];
1586 if (w
->event
&& (w
->event_flags
& SND_SOC_DAPM_POST_REG
)) {
1587 ret
= w
->event(w
, update
->kcontrol
, SND_SOC_DAPM_POST_REG
);
1589 dev_err(w
->dapm
->dev
, "ASoC: %s DAPM post-event failed: %d\n",
1595 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1596 * they're changing state.
1598 static void dapm_pre_sequence_async(void *data
, async_cookie_t cookie
)
1600 struct snd_soc_dapm_context
*d
= data
;
1603 /* If we're off and we're not supposed to be go into STANDBY */
1604 if (d
->bias_level
== SND_SOC_BIAS_OFF
&&
1605 d
->target_bias_level
!= SND_SOC_BIAS_OFF
) {
1607 pm_runtime_get_sync(d
->dev
);
1609 ret
= snd_soc_dapm_set_bias_level(d
, SND_SOC_BIAS_STANDBY
);
1612 "ASoC: Failed to turn on bias: %d\n", ret
);
1615 /* Prepare for a transition to ON or away from ON */
1616 if ((d
->target_bias_level
== SND_SOC_BIAS_ON
&&
1617 d
->bias_level
!= SND_SOC_BIAS_ON
) ||
1618 (d
->target_bias_level
!= SND_SOC_BIAS_ON
&&
1619 d
->bias_level
== SND_SOC_BIAS_ON
)) {
1620 ret
= snd_soc_dapm_set_bias_level(d
, SND_SOC_BIAS_PREPARE
);
1623 "ASoC: Failed to prepare bias: %d\n", ret
);
1627 /* Async callback run prior to DAPM sequences - brings to their final
1630 static void dapm_post_sequence_async(void *data
, async_cookie_t cookie
)
1632 struct snd_soc_dapm_context
*d
= data
;
1635 /* If we just powered the last thing off drop to standby bias */
1636 if (d
->bias_level
== SND_SOC_BIAS_PREPARE
&&
1637 (d
->target_bias_level
== SND_SOC_BIAS_STANDBY
||
1638 d
->target_bias_level
== SND_SOC_BIAS_OFF
)) {
1639 ret
= snd_soc_dapm_set_bias_level(d
, SND_SOC_BIAS_STANDBY
);
1641 dev_err(d
->dev
, "ASoC: Failed to apply standby bias: %d\n",
1645 /* If we're in standby and can support bias off then do that */
1646 if (d
->bias_level
== SND_SOC_BIAS_STANDBY
&&
1647 d
->target_bias_level
== SND_SOC_BIAS_OFF
) {
1648 ret
= snd_soc_dapm_set_bias_level(d
, SND_SOC_BIAS_OFF
);
1650 dev_err(d
->dev
, "ASoC: Failed to turn off bias: %d\n",
1654 pm_runtime_put(d
->dev
);
1657 /* If we just powered up then move to active bias */
1658 if (d
->bias_level
== SND_SOC_BIAS_PREPARE
&&
1659 d
->target_bias_level
== SND_SOC_BIAS_ON
) {
1660 ret
= snd_soc_dapm_set_bias_level(d
, SND_SOC_BIAS_ON
);
1662 dev_err(d
->dev
, "ASoC: Failed to apply active bias: %d\n",
1667 static void dapm_widget_set_peer_power(struct snd_soc_dapm_widget
*peer
,
1668 bool power
, bool connect
)
1670 /* If a connection is being made or broken then that update
1671 * will have marked the peer dirty, otherwise the widgets are
1672 * not connected and this update has no impact. */
1676 /* If the peer is already in the state we're moving to then we
1677 * won't have an impact on it. */
1678 if (power
!= peer
->power
)
1679 dapm_mark_dirty(peer
, "peer state change");
1682 static void dapm_widget_set_power(struct snd_soc_dapm_widget
*w
, bool power
,
1683 struct list_head
*up_list
,
1684 struct list_head
*down_list
)
1686 struct snd_soc_dapm_path
*path
;
1688 if (w
->power
== power
)
1691 trace_snd_soc_dapm_widget_power(w
, power
);
1693 /* If we changed our power state perhaps our neigbours changed
1696 list_for_each_entry(path
, &w
->sources
, list_sink
) {
1698 dapm_widget_set_peer_power(path
->source
, power
,
1703 case snd_soc_dapm_supply
:
1704 case snd_soc_dapm_regulator_supply
:
1705 case snd_soc_dapm_clock_supply
:
1706 case snd_soc_dapm_kcontrol
:
1707 /* Supplies can't affect their outputs, only their inputs */
1710 list_for_each_entry(path
, &w
->sinks
, list_source
) {
1712 dapm_widget_set_peer_power(path
->sink
, power
,
1720 dapm_seq_insert(w
, up_list
, true);
1722 dapm_seq_insert(w
, down_list
, false);
1725 static void dapm_power_one_widget(struct snd_soc_dapm_widget
*w
,
1726 struct list_head
*up_list
,
1727 struct list_head
*down_list
)
1732 case snd_soc_dapm_pre
:
1733 dapm_seq_insert(w
, down_list
, false);
1735 case snd_soc_dapm_post
:
1736 dapm_seq_insert(w
, up_list
, true);
1740 power
= dapm_widget_power_check(w
);
1742 dapm_widget_set_power(w
, power
, up_list
, down_list
);
1748 * Scan each dapm widget for complete audio path.
1749 * A complete path is a route that has valid endpoints i.e.:-
1751 * o DAC to output pin.
1752 * o Input Pin to ADC.
1753 * o Input pin to Output pin (bypass, sidetone)
1754 * o DAC to ADC (loopback).
1756 static int dapm_power_widgets(struct snd_soc_card
*card
, int event
)
1758 struct snd_soc_dapm_widget
*w
;
1759 struct snd_soc_dapm_context
*d
;
1761 LIST_HEAD(down_list
);
1762 ASYNC_DOMAIN_EXCLUSIVE(async_domain
);
1763 enum snd_soc_bias_level bias
;
1765 lockdep_assert_held(&card
->dapm_mutex
);
1767 trace_snd_soc_dapm_start(card
);
1769 list_for_each_entry(d
, &card
->dapm_list
, list
) {
1770 if (d
->idle_bias_off
)
1771 d
->target_bias_level
= SND_SOC_BIAS_OFF
;
1773 d
->target_bias_level
= SND_SOC_BIAS_STANDBY
;
1778 /* Check which widgets we need to power and store them in
1779 * lists indicating if they should be powered up or down. We
1780 * only check widgets that have been flagged as dirty but note
1781 * that new widgets may be added to the dirty list while we
1784 list_for_each_entry(w
, &card
->dapm_dirty
, dirty
) {
1785 dapm_power_one_widget(w
, &up_list
, &down_list
);
1788 list_for_each_entry(w
, &card
->widgets
, list
) {
1790 case snd_soc_dapm_pre
:
1791 case snd_soc_dapm_post
:
1792 /* These widgets always need to be powered */
1795 list_del_init(&w
->dirty
);
1802 /* Supplies and micbiases only bring the
1803 * context up to STANDBY as unless something
1804 * else is active and passing audio they
1805 * generally don't require full power. Signal
1806 * generators are virtual pins and have no
1807 * power impact themselves.
1810 case snd_soc_dapm_siggen
:
1811 case snd_soc_dapm_vmid
:
1813 case snd_soc_dapm_supply
:
1814 case snd_soc_dapm_regulator_supply
:
1815 case snd_soc_dapm_clock_supply
:
1816 case snd_soc_dapm_micbias
:
1817 if (d
->target_bias_level
< SND_SOC_BIAS_STANDBY
)
1818 d
->target_bias_level
= SND_SOC_BIAS_STANDBY
;
1821 d
->target_bias_level
= SND_SOC_BIAS_ON
;
1828 /* Force all contexts in the card to the same bias state if
1829 * they're not ground referenced.
1831 bias
= SND_SOC_BIAS_OFF
;
1832 list_for_each_entry(d
, &card
->dapm_list
, list
)
1833 if (d
->target_bias_level
> bias
)
1834 bias
= d
->target_bias_level
;
1835 list_for_each_entry(d
, &card
->dapm_list
, list
)
1836 if (!d
->idle_bias_off
)
1837 d
->target_bias_level
= bias
;
1839 trace_snd_soc_dapm_walk_done(card
);
1841 /* Run card bias changes at first */
1842 dapm_pre_sequence_async(&card
->dapm
, 0);
1843 /* Run other bias changes in parallel */
1844 list_for_each_entry(d
, &card
->dapm_list
, list
) {
1845 if (d
!= &card
->dapm
)
1846 async_schedule_domain(dapm_pre_sequence_async
, d
,
1849 async_synchronize_full_domain(&async_domain
);
1851 list_for_each_entry(w
, &down_list
, power_list
) {
1852 dapm_seq_check_event(card
, w
, SND_SOC_DAPM_WILL_PMD
);
1855 list_for_each_entry(w
, &up_list
, power_list
) {
1856 dapm_seq_check_event(card
, w
, SND_SOC_DAPM_WILL_PMU
);
1859 /* Power down widgets first; try to avoid amplifying pops. */
1860 dapm_seq_run(card
, &down_list
, event
, false);
1862 dapm_widget_update(card
);
1865 dapm_seq_run(card
, &up_list
, event
, true);
1867 /* Run all the bias changes in parallel */
1868 list_for_each_entry(d
, &card
->dapm_list
, list
) {
1869 if (d
!= &card
->dapm
)
1870 async_schedule_domain(dapm_post_sequence_async
, d
,
1873 async_synchronize_full_domain(&async_domain
);
1874 /* Run card bias changes at last */
1875 dapm_post_sequence_async(&card
->dapm
, 0);
1877 /* do we need to notify any clients that DAPM event is complete */
1878 list_for_each_entry(d
, &card
->dapm_list
, list
) {
1879 if (d
->stream_event
)
1880 d
->stream_event(d
, event
);
1883 pop_dbg(card
->dev
, card
->pop_time
,
1884 "DAPM sequencing finished, waiting %dms\n", card
->pop_time
);
1885 pop_wait(card
->pop_time
);
1887 trace_snd_soc_dapm_done(card
);
1892 #ifdef CONFIG_DEBUG_FS
1893 static ssize_t
dapm_widget_power_read_file(struct file
*file
,
1894 char __user
*user_buf
,
1895 size_t count
, loff_t
*ppos
)
1897 struct snd_soc_dapm_widget
*w
= file
->private_data
;
1901 struct snd_soc_dapm_path
*p
= NULL
;
1903 buf
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
1907 in
= is_connected_input_ep(w
, NULL
);
1908 dapm_clear_walk_input(w
->dapm
, &w
->sources
);
1909 out
= is_connected_output_ep(w
, NULL
);
1910 dapm_clear_walk_output(w
->dapm
, &w
->sinks
);
1912 ret
= snprintf(buf
, PAGE_SIZE
, "%s: %s%s in %d out %d",
1913 w
->name
, w
->power
? "On" : "Off",
1914 w
->force
? " (forced)" : "", in
, out
);
1917 ret
+= snprintf(buf
+ ret
, PAGE_SIZE
- ret
,
1918 " - R%d(0x%x) mask 0x%x",
1919 w
->reg
, w
->reg
, w
->mask
<< w
->shift
);
1921 ret
+= snprintf(buf
+ ret
, PAGE_SIZE
- ret
, "\n");
1924 ret
+= snprintf(buf
+ ret
, PAGE_SIZE
- ret
, " stream %s %s\n",
1926 w
->active
? "active" : "inactive");
1928 list_for_each_entry(p
, &w
->sources
, list_sink
) {
1929 if (p
->connected
&& !p
->connected(w
, p
->source
))
1933 ret
+= snprintf(buf
+ ret
, PAGE_SIZE
- ret
,
1934 " in \"%s\" \"%s\"\n",
1935 p
->name
? p
->name
: "static",
1938 list_for_each_entry(p
, &w
->sinks
, list_source
) {
1939 if (p
->connected
&& !p
->connected(w
, p
->sink
))
1943 ret
+= snprintf(buf
+ ret
, PAGE_SIZE
- ret
,
1944 " out \"%s\" \"%s\"\n",
1945 p
->name
? p
->name
: "static",
1949 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, ret
);
1955 static const struct file_operations dapm_widget_power_fops
= {
1956 .open
= simple_open
,
1957 .read
= dapm_widget_power_read_file
,
1958 .llseek
= default_llseek
,
1961 static ssize_t
dapm_bias_read_file(struct file
*file
, char __user
*user_buf
,
1962 size_t count
, loff_t
*ppos
)
1964 struct snd_soc_dapm_context
*dapm
= file
->private_data
;
1967 switch (dapm
->bias_level
) {
1968 case SND_SOC_BIAS_ON
:
1971 case SND_SOC_BIAS_PREPARE
:
1972 level
= "Prepare\n";
1974 case SND_SOC_BIAS_STANDBY
:
1975 level
= "Standby\n";
1977 case SND_SOC_BIAS_OFF
:
1981 WARN(1, "Unknown bias_level %d\n", dapm
->bias_level
);
1982 level
= "Unknown\n";
1986 return simple_read_from_buffer(user_buf
, count
, ppos
, level
,
1990 static const struct file_operations dapm_bias_fops
= {
1991 .open
= simple_open
,
1992 .read
= dapm_bias_read_file
,
1993 .llseek
= default_llseek
,
1996 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context
*dapm
,
1997 struct dentry
*parent
)
2001 dapm
->debugfs_dapm
= debugfs_create_dir("dapm", parent
);
2003 if (!dapm
->debugfs_dapm
) {
2005 "ASoC: Failed to create DAPM debugfs directory\n");
2009 d
= debugfs_create_file("bias_level", 0444,
2010 dapm
->debugfs_dapm
, dapm
,
2014 "ASoC: Failed to create bias level debugfs file\n");
2017 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget
*w
)
2019 struct snd_soc_dapm_context
*dapm
= w
->dapm
;
2022 if (!dapm
->debugfs_dapm
|| !w
->name
)
2025 d
= debugfs_create_file(w
->name
, 0444,
2026 dapm
->debugfs_dapm
, w
,
2027 &dapm_widget_power_fops
);
2029 dev_warn(w
->dapm
->dev
,
2030 "ASoC: Failed to create %s debugfs file\n",
2034 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context
*dapm
)
2036 debugfs_remove_recursive(dapm
->debugfs_dapm
);
2040 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context
*dapm
,
2041 struct dentry
*parent
)
2045 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget
*w
)
2049 static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context
*dapm
)
2055 /* test and update the power status of a mux widget */
2056 static int soc_dapm_mux_update_power(struct snd_soc_card
*card
,
2057 struct snd_kcontrol
*kcontrol
, int mux
, struct soc_enum
*e
)
2059 struct snd_soc_dapm_path
*path
;
2062 lockdep_assert_held(&card
->dapm_mutex
);
2064 /* find dapm widget path assoc with kcontrol */
2065 dapm_kcontrol_for_each_path(path
, kcontrol
) {
2066 if (!path
->name
|| !e
->texts
[mux
])
2070 /* we now need to match the string in the enum to the path */
2071 if (!(strcmp(path
->name
, e
->texts
[mux
]))) {
2072 path
->connect
= 1; /* new connection */
2073 dapm_mark_dirty(path
->source
, "mux connection");
2076 dapm_mark_dirty(path
->source
,
2077 "mux disconnection");
2078 path
->connect
= 0; /* old connection must be powered down */
2080 dapm_mark_dirty(path
->sink
, "mux change");
2084 dapm_power_widgets(card
, SND_SOC_DAPM_STREAM_NOP
);
2089 int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context
*dapm
,
2090 struct snd_kcontrol
*kcontrol
, int mux
, struct soc_enum
*e
,
2091 struct snd_soc_dapm_update
*update
)
2093 struct snd_soc_card
*card
= dapm
->card
;
2096 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
2097 card
->update
= update
;
2098 ret
= soc_dapm_mux_update_power(card
, kcontrol
, mux
, e
);
2099 card
->update
= NULL
;
2100 mutex_unlock(&card
->dapm_mutex
);
2102 soc_dpcm_runtime_update(card
);
2105 EXPORT_SYMBOL_GPL(snd_soc_dapm_mux_update_power
);
2107 /* test and update the power status of a mixer or switch widget */
2108 static int soc_dapm_mixer_update_power(struct snd_soc_card
*card
,
2109 struct snd_kcontrol
*kcontrol
, int connect
)
2111 struct snd_soc_dapm_path
*path
;
2114 lockdep_assert_held(&card
->dapm_mutex
);
2116 /* find dapm widget path assoc with kcontrol */
2117 dapm_kcontrol_for_each_path(path
, kcontrol
) {
2119 path
->connect
= connect
;
2120 dapm_mark_dirty(path
->source
, "mixer connection");
2121 dapm_mark_dirty(path
->sink
, "mixer update");
2125 dapm_power_widgets(card
, SND_SOC_DAPM_STREAM_NOP
);
2130 int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context
*dapm
,
2131 struct snd_kcontrol
*kcontrol
, int connect
,
2132 struct snd_soc_dapm_update
*update
)
2134 struct snd_soc_card
*card
= dapm
->card
;
2137 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
2138 card
->update
= update
;
2139 ret
= soc_dapm_mixer_update_power(card
, kcontrol
, connect
);
2140 card
->update
= NULL
;
2141 mutex_unlock(&card
->dapm_mutex
);
2143 soc_dpcm_runtime_update(card
);
2146 EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power
);
2148 /* show dapm widget status in sys fs */
2149 static ssize_t
dapm_widget_show(struct device
*dev
,
2150 struct device_attribute
*attr
, char *buf
)
2152 struct snd_soc_pcm_runtime
*rtd
= dev_get_drvdata(dev
);
2153 struct snd_soc_codec
*codec
=rtd
->codec
;
2154 struct snd_soc_dapm_widget
*w
;
2156 char *state
= "not set";
2158 list_for_each_entry(w
, &codec
->card
->widgets
, list
) {
2159 if (w
->dapm
!= &codec
->dapm
)
2162 /* only display widgets that burnm power */
2164 case snd_soc_dapm_hp
:
2165 case snd_soc_dapm_mic
:
2166 case snd_soc_dapm_spk
:
2167 case snd_soc_dapm_line
:
2168 case snd_soc_dapm_micbias
:
2169 case snd_soc_dapm_dac
:
2170 case snd_soc_dapm_adc
:
2171 case snd_soc_dapm_pga
:
2172 case snd_soc_dapm_out_drv
:
2173 case snd_soc_dapm_mixer
:
2174 case snd_soc_dapm_mixer_named_ctl
:
2175 case snd_soc_dapm_supply
:
2176 case snd_soc_dapm_regulator_supply
:
2177 case snd_soc_dapm_clock_supply
:
2179 count
+= sprintf(buf
+ count
, "%s: %s\n",
2180 w
->name
, w
->power
? "On":"Off");
2187 switch (codec
->dapm
.bias_level
) {
2188 case SND_SOC_BIAS_ON
:
2191 case SND_SOC_BIAS_PREPARE
:
2194 case SND_SOC_BIAS_STANDBY
:
2197 case SND_SOC_BIAS_OFF
:
2201 count
+= sprintf(buf
+ count
, "PM State: %s\n", state
);
2206 static DEVICE_ATTR(dapm_widget
, 0444, dapm_widget_show
, NULL
);
2208 int snd_soc_dapm_sys_add(struct device
*dev
)
2210 return device_create_file(dev
, &dev_attr_dapm_widget
);
2213 static void snd_soc_dapm_sys_remove(struct device
*dev
)
2215 device_remove_file(dev
, &dev_attr_dapm_widget
);
2218 static void dapm_free_path(struct snd_soc_dapm_path
*path
)
2220 list_del(&path
->list_sink
);
2221 list_del(&path
->list_source
);
2222 list_del(&path
->list_kcontrol
);
2223 list_del(&path
->list
);
2227 /* free all dapm widgets and resources */
2228 static void dapm_free_widgets(struct snd_soc_dapm_context
*dapm
)
2230 struct snd_soc_dapm_widget
*w
, *next_w
;
2231 struct snd_soc_dapm_path
*p
, *next_p
;
2233 list_for_each_entry_safe(w
, next_w
, &dapm
->card
->widgets
, list
) {
2234 if (w
->dapm
!= dapm
)
2238 * remove source and sink paths associated to this widget.
2239 * While removing the path, remove reference to it from both
2240 * source and sink widgets so that path is removed only once.
2242 list_for_each_entry_safe(p
, next_p
, &w
->sources
, list_sink
)
2245 list_for_each_entry_safe(p
, next_p
, &w
->sinks
, list_source
)
2248 kfree(w
->kcontrols
);
2254 static struct snd_soc_dapm_widget
*dapm_find_widget(
2255 struct snd_soc_dapm_context
*dapm
, const char *pin
,
2256 bool search_other_contexts
)
2258 struct snd_soc_dapm_widget
*w
;
2259 struct snd_soc_dapm_widget
*fallback
= NULL
;
2261 list_for_each_entry(w
, &dapm
->card
->widgets
, list
) {
2262 if (!strcmp(w
->name
, pin
)) {
2263 if (w
->dapm
== dapm
)
2270 if (search_other_contexts
)
2276 static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context
*dapm
,
2277 const char *pin
, int status
)
2279 struct snd_soc_dapm_widget
*w
= dapm_find_widget(dapm
, pin
, true);
2281 dapm_assert_locked(dapm
);
2284 dev_err(dapm
->dev
, "ASoC: DAPM unknown pin %s\n", pin
);
2288 if (w
->connected
!= status
)
2289 dapm_mark_dirty(w
, "pin configuration");
2291 w
->connected
= status
;
2299 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2300 * @dapm: DAPM context
2302 * Walks all dapm audio paths and powers widgets according to their
2303 * stream or path usage.
2305 * Requires external locking.
2307 * Returns 0 for success.
2309 int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context
*dapm
)
2312 * Suppress early reports (eg, jacks syncing their state) to avoid
2313 * silly DAPM runs during card startup.
2315 if (!dapm
->card
|| !dapm
->card
->instantiated
)
2318 return dapm_power_widgets(dapm
->card
, SND_SOC_DAPM_STREAM_NOP
);
2320 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_unlocked
);
2323 * snd_soc_dapm_sync - scan and power dapm paths
2324 * @dapm: DAPM context
2326 * Walks all dapm audio paths and powers widgets according to their
2327 * stream or path usage.
2329 * Returns 0 for success.
2331 int snd_soc_dapm_sync(struct snd_soc_dapm_context
*dapm
)
2335 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
2336 ret
= snd_soc_dapm_sync_unlocked(dapm
);
2337 mutex_unlock(&dapm
->card
->dapm_mutex
);
2340 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync
);
2342 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context
*dapm
,
2343 struct snd_soc_dapm_widget
*wsource
, struct snd_soc_dapm_widget
*wsink
,
2344 const char *control
,
2345 int (*connected
)(struct snd_soc_dapm_widget
*source
,
2346 struct snd_soc_dapm_widget
*sink
))
2348 struct snd_soc_dapm_path
*path
;
2351 path
= kzalloc(sizeof(struct snd_soc_dapm_path
), GFP_KERNEL
);
2355 path
->source
= wsource
;
2357 path
->connected
= connected
;
2358 INIT_LIST_HEAD(&path
->list
);
2359 INIT_LIST_HEAD(&path
->list_kcontrol
);
2360 INIT_LIST_HEAD(&path
->list_source
);
2361 INIT_LIST_HEAD(&path
->list_sink
);
2363 /* check for external widgets */
2364 if (wsink
->id
== snd_soc_dapm_input
) {
2365 if (wsource
->id
== snd_soc_dapm_micbias
||
2366 wsource
->id
== snd_soc_dapm_mic
||
2367 wsource
->id
== snd_soc_dapm_line
||
2368 wsource
->id
== snd_soc_dapm_output
)
2371 if (wsource
->id
== snd_soc_dapm_output
) {
2372 if (wsink
->id
== snd_soc_dapm_spk
||
2373 wsink
->id
== snd_soc_dapm_hp
||
2374 wsink
->id
== snd_soc_dapm_line
||
2375 wsink
->id
== snd_soc_dapm_input
)
2379 dapm_mark_dirty(wsource
, "Route added");
2380 dapm_mark_dirty(wsink
, "Route added");
2382 /* connect static paths */
2383 if (control
== NULL
) {
2384 list_add(&path
->list
, &dapm
->card
->paths
);
2385 list_add(&path
->list_sink
, &wsink
->sources
);
2386 list_add(&path
->list_source
, &wsource
->sinks
);
2391 /* connect dynamic paths */
2392 switch (wsink
->id
) {
2393 case snd_soc_dapm_adc
:
2394 case snd_soc_dapm_dac
:
2395 case snd_soc_dapm_pga
:
2396 case snd_soc_dapm_out_drv
:
2397 case snd_soc_dapm_input
:
2398 case snd_soc_dapm_output
:
2399 case snd_soc_dapm_siggen
:
2400 case snd_soc_dapm_micbias
:
2401 case snd_soc_dapm_vmid
:
2402 case snd_soc_dapm_pre
:
2403 case snd_soc_dapm_post
:
2404 case snd_soc_dapm_supply
:
2405 case snd_soc_dapm_regulator_supply
:
2406 case snd_soc_dapm_clock_supply
:
2407 case snd_soc_dapm_aif_in
:
2408 case snd_soc_dapm_aif_out
:
2409 case snd_soc_dapm_dai_in
:
2410 case snd_soc_dapm_dai_out
:
2411 case snd_soc_dapm_dai_link
:
2412 case snd_soc_dapm_kcontrol
:
2413 list_add(&path
->list
, &dapm
->card
->paths
);
2414 list_add(&path
->list_sink
, &wsink
->sources
);
2415 list_add(&path
->list_source
, &wsource
->sinks
);
2418 case snd_soc_dapm_mux
:
2419 ret
= dapm_connect_mux(dapm
, wsource
, wsink
, path
, control
,
2420 &wsink
->kcontrol_news
[0]);
2424 case snd_soc_dapm_switch
:
2425 case snd_soc_dapm_mixer
:
2426 case snd_soc_dapm_mixer_named_ctl
:
2427 ret
= dapm_connect_mixer(dapm
, wsource
, wsink
, path
, control
);
2431 case snd_soc_dapm_hp
:
2432 case snd_soc_dapm_mic
:
2433 case snd_soc_dapm_line
:
2434 case snd_soc_dapm_spk
:
2435 list_add(&path
->list
, &dapm
->card
->paths
);
2436 list_add(&path
->list_sink
, &wsink
->sources
);
2437 list_add(&path
->list_source
, &wsource
->sinks
);
2448 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context
*dapm
,
2449 const struct snd_soc_dapm_route
*route
,
2450 unsigned int is_prefixed
)
2452 struct snd_soc_dapm_widget
*wsource
= NULL
, *wsink
= NULL
, *w
;
2453 struct snd_soc_dapm_widget
*wtsource
= NULL
, *wtsink
= NULL
;
2456 char prefixed_sink
[80];
2457 char prefixed_source
[80];
2460 if (dapm
->codec
&& dapm
->codec
->name_prefix
&& !is_prefixed
) {
2461 snprintf(prefixed_sink
, sizeof(prefixed_sink
), "%s %s",
2462 dapm
->codec
->name_prefix
, route
->sink
);
2463 sink
= prefixed_sink
;
2464 snprintf(prefixed_source
, sizeof(prefixed_source
), "%s %s",
2465 dapm
->codec
->name_prefix
, route
->source
);
2466 source
= prefixed_source
;
2469 source
= route
->source
;
2473 * find src and dest widgets over all widgets but favor a widget from
2474 * current DAPM context
2476 list_for_each_entry(w
, &dapm
->card
->widgets
, list
) {
2477 if (!wsink
&& !(strcmp(w
->name
, sink
))) {
2479 if (w
->dapm
== dapm
)
2483 if (!wsource
&& !(strcmp(w
->name
, source
))) {
2485 if (w
->dapm
== dapm
)
2489 /* use widget from another DAPM context if not found from this */
2495 if (wsource
== NULL
) {
2496 dev_err(dapm
->dev
, "ASoC: no source widget found for %s\n",
2500 if (wsink
== NULL
) {
2501 dev_err(dapm
->dev
, "ASoC: no sink widget found for %s\n",
2506 ret
= snd_soc_dapm_add_path(dapm
, wsource
, wsink
, route
->control
,
2513 dev_warn(dapm
->dev
, "ASoC: no dapm match for %s --> %s --> %s\n",
2514 source
, route
->control
, sink
);
2518 static int snd_soc_dapm_del_route(struct snd_soc_dapm_context
*dapm
,
2519 const struct snd_soc_dapm_route
*route
)
2521 struct snd_soc_dapm_path
*path
, *p
;
2524 char prefixed_sink
[80];
2525 char prefixed_source
[80];
2527 if (route
->control
) {
2529 "ASoC: Removal of routes with controls not supported\n");
2533 if (dapm
->codec
&& dapm
->codec
->name_prefix
) {
2534 snprintf(prefixed_sink
, sizeof(prefixed_sink
), "%s %s",
2535 dapm
->codec
->name_prefix
, route
->sink
);
2536 sink
= prefixed_sink
;
2537 snprintf(prefixed_source
, sizeof(prefixed_source
), "%s %s",
2538 dapm
->codec
->name_prefix
, route
->source
);
2539 source
= prefixed_source
;
2542 source
= route
->source
;
2546 list_for_each_entry(p
, &dapm
->card
->paths
, list
) {
2547 if (strcmp(p
->source
->name
, source
) != 0)
2549 if (strcmp(p
->sink
->name
, sink
) != 0)
2556 dapm_mark_dirty(path
->source
, "Route removed");
2557 dapm_mark_dirty(path
->sink
, "Route removed");
2559 dapm_free_path(path
);
2561 dev_warn(dapm
->dev
, "ASoC: Route %s->%s does not exist\n",
2569 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
2570 * @dapm: DAPM context
2571 * @route: audio routes
2572 * @num: number of routes
2574 * Connects 2 dapm widgets together via a named audio path. The sink is
2575 * the widget receiving the audio signal, whilst the source is the sender
2576 * of the audio signal.
2578 * Returns 0 for success else error. On error all resources can be freed
2579 * with a call to snd_soc_card_free().
2581 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context
*dapm
,
2582 const struct snd_soc_dapm_route
*route
, int num
)
2586 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_INIT
);
2587 for (i
= 0; i
< num
; i
++) {
2588 r
= snd_soc_dapm_add_route(dapm
, route
, false);
2590 dev_err(dapm
->dev
, "ASoC: Failed to add route %s -> %s -> %s\n",
2592 route
->control
? route
->control
: "direct",
2598 mutex_unlock(&dapm
->card
->dapm_mutex
);
2602 EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes
);
2605 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
2606 * @dapm: DAPM context
2607 * @route: audio routes
2608 * @num: number of routes
2610 * Removes routes from the DAPM context.
2612 int snd_soc_dapm_del_routes(struct snd_soc_dapm_context
*dapm
,
2613 const struct snd_soc_dapm_route
*route
, int num
)
2617 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_INIT
);
2618 for (i
= 0; i
< num
; i
++) {
2619 snd_soc_dapm_del_route(dapm
, route
);
2622 mutex_unlock(&dapm
->card
->dapm_mutex
);
2626 EXPORT_SYMBOL_GPL(snd_soc_dapm_del_routes
);
2628 static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context
*dapm
,
2629 const struct snd_soc_dapm_route
*route
)
2631 struct snd_soc_dapm_widget
*source
= dapm_find_widget(dapm
,
2634 struct snd_soc_dapm_widget
*sink
= dapm_find_widget(dapm
,
2637 struct snd_soc_dapm_path
*path
;
2641 dev_err(dapm
->dev
, "ASoC: Unable to find source %s for weak route\n",
2647 dev_err(dapm
->dev
, "ASoC: Unable to find sink %s for weak route\n",
2652 if (route
->control
|| route
->connected
)
2653 dev_warn(dapm
->dev
, "ASoC: Ignoring control for weak route %s->%s\n",
2654 route
->source
, route
->sink
);
2656 list_for_each_entry(path
, &source
->sinks
, list_source
) {
2657 if (path
->sink
== sink
) {
2664 dev_err(dapm
->dev
, "ASoC: No path found for weak route %s->%s\n",
2665 route
->source
, route
->sink
);
2667 dev_warn(dapm
->dev
, "ASoC: %d paths found for weak route %s->%s\n",
2668 count
, route
->source
, route
->sink
);
2674 * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
2675 * @dapm: DAPM context
2676 * @route: audio routes
2677 * @num: number of routes
2679 * Mark existing routes matching those specified in the passed array
2680 * as being weak, meaning that they are ignored for the purpose of
2681 * power decisions. The main intended use case is for sidetone paths
2682 * which couple audio between other independent paths if they are both
2683 * active in order to make the combination work better at the user
2684 * level but which aren't intended to be "used".
2686 * Note that CODEC drivers should not use this as sidetone type paths
2687 * can frequently also be used as bypass paths.
2689 int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context
*dapm
,
2690 const struct snd_soc_dapm_route
*route
, int num
)
2695 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_INIT
);
2696 for (i
= 0; i
< num
; i
++) {
2697 err
= snd_soc_dapm_weak_route(dapm
, route
);
2702 mutex_unlock(&dapm
->card
->dapm_mutex
);
2706 EXPORT_SYMBOL_GPL(snd_soc_dapm_weak_routes
);
2709 * snd_soc_dapm_new_widgets - add new dapm widgets
2710 * @dapm: DAPM context
2712 * Checks the codec for any new dapm widgets and creates them if found.
2714 * Returns 0 for success.
2716 int snd_soc_dapm_new_widgets(struct snd_soc_card
*card
)
2718 struct snd_soc_dapm_widget
*w
;
2721 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_INIT
);
2723 list_for_each_entry(w
, &card
->widgets
, list
)
2728 if (w
->num_kcontrols
) {
2729 w
->kcontrols
= kzalloc(w
->num_kcontrols
*
2730 sizeof(struct snd_kcontrol
*),
2732 if (!w
->kcontrols
) {
2733 mutex_unlock(&card
->dapm_mutex
);
2739 case snd_soc_dapm_switch
:
2740 case snd_soc_dapm_mixer
:
2741 case snd_soc_dapm_mixer_named_ctl
:
2744 case snd_soc_dapm_mux
:
2747 case snd_soc_dapm_pga
:
2748 case snd_soc_dapm_out_drv
:
2755 /* Read the initial power state from the device */
2757 soc_widget_read(w
, w
->reg
, &val
);
2758 val
= val
>> w
->shift
;
2760 if (val
== w
->on_val
)
2766 dapm_mark_dirty(w
, "new widget");
2767 dapm_debugfs_add_widget(w
);
2770 dapm_power_widgets(card
, SND_SOC_DAPM_STREAM_NOP
);
2771 mutex_unlock(&card
->dapm_mutex
);
2774 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets
);
2777 * snd_soc_dapm_get_volsw - dapm mixer get callback
2778 * @kcontrol: mixer control
2779 * @ucontrol: control element information
2781 * Callback to get the value of a dapm mixer control.
2783 * Returns 0 for success.
2785 int snd_soc_dapm_get_volsw(struct snd_kcontrol
*kcontrol
,
2786 struct snd_ctl_elem_value
*ucontrol
)
2788 struct snd_soc_codec
*codec
= snd_soc_dapm_kcontrol_codec(kcontrol
);
2789 struct snd_soc_card
*card
= codec
->card
;
2790 struct soc_mixer_control
*mc
=
2791 (struct soc_mixer_control
*)kcontrol
->private_value
;
2793 unsigned int shift
= mc
->shift
;
2795 unsigned int mask
= (1 << fls(max
)) - 1;
2796 unsigned int invert
= mc
->invert
;
2799 if (snd_soc_volsw_is_stereo(mc
))
2800 dev_warn(codec
->dapm
.dev
,
2801 "ASoC: Control '%s' is stereo, which is not supported\n",
2804 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
2805 if (dapm_kcontrol_is_powered(kcontrol
) && reg
!= SND_SOC_NOPM
)
2806 val
= (snd_soc_read(codec
, reg
) >> shift
) & mask
;
2808 val
= dapm_kcontrol_get_value(kcontrol
);
2809 mutex_unlock(&card
->dapm_mutex
);
2812 ucontrol
->value
.integer
.value
[0] = max
- val
;
2814 ucontrol
->value
.integer
.value
[0] = val
;
2818 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw
);
2821 * snd_soc_dapm_put_volsw - dapm mixer set callback
2822 * @kcontrol: mixer control
2823 * @ucontrol: control element information
2825 * Callback to set the value of a dapm mixer control.
2827 * Returns 0 for success.
2829 int snd_soc_dapm_put_volsw(struct snd_kcontrol
*kcontrol
,
2830 struct snd_ctl_elem_value
*ucontrol
)
2832 struct snd_soc_codec
*codec
= snd_soc_dapm_kcontrol_codec(kcontrol
);
2833 struct snd_soc_card
*card
= codec
->card
;
2834 struct soc_mixer_control
*mc
=
2835 (struct soc_mixer_control
*)kcontrol
->private_value
;
2837 unsigned int shift
= mc
->shift
;
2839 unsigned int mask
= (1 << fls(max
)) - 1;
2840 unsigned int invert
= mc
->invert
;
2842 int connect
, change
;
2843 struct snd_soc_dapm_update update
;
2846 if (snd_soc_volsw_is_stereo(mc
))
2847 dev_warn(codec
->dapm
.dev
,
2848 "ASoC: Control '%s' is stereo, which is not supported\n",
2851 val
= (ucontrol
->value
.integer
.value
[0] & mask
);
2857 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
2859 change
= dapm_kcontrol_set_value(kcontrol
, val
);
2861 if (reg
!= SND_SOC_NOPM
) {
2862 mask
= mask
<< shift
;
2865 change
= snd_soc_test_bits(codec
, reg
, mask
, val
);
2869 if (reg
!= SND_SOC_NOPM
) {
2870 update
.kcontrol
= kcontrol
;
2875 card
->update
= &update
;
2878 ret
= soc_dapm_mixer_update_power(card
, kcontrol
, connect
);
2880 card
->update
= NULL
;
2883 mutex_unlock(&card
->dapm_mutex
);
2886 soc_dpcm_runtime_update(card
);
2890 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw
);
2893 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
2894 * @kcontrol: mixer control
2895 * @ucontrol: control element information
2897 * Callback to get the value of a dapm enumerated double mixer control.
2899 * Returns 0 for success.
2901 int snd_soc_dapm_get_enum_double(struct snd_kcontrol
*kcontrol
,
2902 struct snd_ctl_elem_value
*ucontrol
)
2904 struct snd_soc_codec
*codec
= snd_soc_dapm_kcontrol_codec(kcontrol
);
2905 struct soc_enum
*e
= (struct soc_enum
*)kcontrol
->private_value
;
2906 unsigned int reg_val
, val
;
2908 if (e
->reg
!= SND_SOC_NOPM
)
2909 reg_val
= snd_soc_read(codec
, e
->reg
);
2911 reg_val
= dapm_kcontrol_get_value(kcontrol
);
2913 val
= (reg_val
>> e
->shift_l
) & e
->mask
;
2914 ucontrol
->value
.enumerated
.item
[0] = snd_soc_enum_val_to_item(e
, val
);
2915 if (e
->shift_l
!= e
->shift_r
) {
2916 val
= (reg_val
>> e
->shift_r
) & e
->mask
;
2917 val
= snd_soc_enum_val_to_item(e
, val
);
2918 ucontrol
->value
.enumerated
.item
[1] = val
;
2923 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double
);
2926 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
2927 * @kcontrol: mixer control
2928 * @ucontrol: control element information
2930 * Callback to set the value of a dapm enumerated double mixer control.
2932 * Returns 0 for success.
2934 int snd_soc_dapm_put_enum_double(struct snd_kcontrol
*kcontrol
,
2935 struct snd_ctl_elem_value
*ucontrol
)
2937 struct snd_soc_codec
*codec
= snd_soc_dapm_kcontrol_codec(kcontrol
);
2938 struct snd_soc_card
*card
= codec
->card
;
2939 struct soc_enum
*e
= (struct soc_enum
*)kcontrol
->private_value
;
2940 unsigned int *item
= ucontrol
->value
.enumerated
.item
;
2941 unsigned int val
, change
;
2943 struct snd_soc_dapm_update update
;
2946 if (item
[0] >= e
->items
)
2949 val
= snd_soc_enum_item_to_val(e
, item
[0]) << e
->shift_l
;
2950 mask
= e
->mask
<< e
->shift_l
;
2951 if (e
->shift_l
!= e
->shift_r
) {
2952 if (item
[1] > e
->items
)
2954 val
|= snd_soc_enum_item_to_val(e
, item
[1]) << e
->shift_l
;
2955 mask
|= e
->mask
<< e
->shift_r
;
2958 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
2960 if (e
->reg
!= SND_SOC_NOPM
)
2961 change
= snd_soc_test_bits(codec
, e
->reg
, mask
, val
);
2963 change
= dapm_kcontrol_set_value(kcontrol
, val
);
2966 if (e
->reg
!= SND_SOC_NOPM
) {
2967 update
.kcontrol
= kcontrol
;
2968 update
.reg
= e
->reg
;
2971 card
->update
= &update
;
2974 ret
= soc_dapm_mux_update_power(card
, kcontrol
, item
[0], e
);
2976 card
->update
= NULL
;
2979 mutex_unlock(&card
->dapm_mutex
);
2982 soc_dpcm_runtime_update(card
);
2986 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double
);
2989 * snd_soc_dapm_info_pin_switch - Info for a pin switch
2991 * @kcontrol: mixer control
2992 * @uinfo: control element information
2994 * Callback to provide information about a pin switch control.
2996 int snd_soc_dapm_info_pin_switch(struct snd_kcontrol
*kcontrol
,
2997 struct snd_ctl_elem_info
*uinfo
)
2999 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
3001 uinfo
->value
.integer
.min
= 0;
3002 uinfo
->value
.integer
.max
= 1;
3006 EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch
);
3009 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
3011 * @kcontrol: mixer control
3014 int snd_soc_dapm_get_pin_switch(struct snd_kcontrol
*kcontrol
,
3015 struct snd_ctl_elem_value
*ucontrol
)
3017 struct snd_soc_card
*card
= snd_kcontrol_chip(kcontrol
);
3018 const char *pin
= (const char *)kcontrol
->private_value
;
3020 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
3022 ucontrol
->value
.integer
.value
[0] =
3023 snd_soc_dapm_get_pin_status(&card
->dapm
, pin
);
3025 mutex_unlock(&card
->dapm_mutex
);
3029 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch
);
3032 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
3034 * @kcontrol: mixer control
3037 int snd_soc_dapm_put_pin_switch(struct snd_kcontrol
*kcontrol
,
3038 struct snd_ctl_elem_value
*ucontrol
)
3040 struct snd_soc_card
*card
= snd_kcontrol_chip(kcontrol
);
3041 const char *pin
= (const char *)kcontrol
->private_value
;
3043 if (ucontrol
->value
.integer
.value
[0])
3044 snd_soc_dapm_enable_pin(&card
->dapm
, pin
);
3046 snd_soc_dapm_disable_pin(&card
->dapm
, pin
);
3048 snd_soc_dapm_sync(&card
->dapm
);
3051 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch
);
3053 static struct snd_soc_dapm_widget
*
3054 snd_soc_dapm_new_control(struct snd_soc_dapm_context
*dapm
,
3055 const struct snd_soc_dapm_widget
*widget
)
3057 struct snd_soc_dapm_widget
*w
;
3060 if ((w
= dapm_cnew_widget(widget
)) == NULL
)
3064 case snd_soc_dapm_regulator_supply
:
3065 w
->regulator
= devm_regulator_get(dapm
->dev
, w
->name
);
3066 if (IS_ERR(w
->regulator
)) {
3067 ret
= PTR_ERR(w
->regulator
);
3068 dev_err(dapm
->dev
, "ASoC: Failed to request %s: %d\n",
3073 if (w
->on_val
& SND_SOC_DAPM_REGULATOR_BYPASS
) {
3074 ret
= regulator_allow_bypass(w
->regulator
, true);
3076 dev_warn(w
->dapm
->dev
,
3077 "ASoC: Failed to bypass %s: %d\n",
3081 case snd_soc_dapm_clock_supply
:
3082 #ifdef CONFIG_CLKDEV_LOOKUP
3083 w
->clk
= devm_clk_get(dapm
->dev
, w
->name
);
3084 if (IS_ERR(w
->clk
)) {
3085 ret
= PTR_ERR(w
->clk
);
3086 dev_err(dapm
->dev
, "ASoC: Failed to request %s: %d\n",
3098 if (dapm
->codec
&& dapm
->codec
->name_prefix
)
3099 w
->name
= kasprintf(GFP_KERNEL
, "%s %s",
3100 dapm
->codec
->name_prefix
, widget
->name
);
3102 w
->name
= kasprintf(GFP_KERNEL
, "%s", widget
->name
);
3104 if (w
->name
== NULL
) {
3110 case snd_soc_dapm_switch
:
3111 case snd_soc_dapm_mixer
:
3112 case snd_soc_dapm_mixer_named_ctl
:
3113 w
->power_check
= dapm_generic_check_power
;
3115 case snd_soc_dapm_mux
:
3116 w
->power_check
= dapm_generic_check_power
;
3118 case snd_soc_dapm_dai_out
:
3119 w
->power_check
= dapm_adc_check_power
;
3121 case snd_soc_dapm_dai_in
:
3122 w
->power_check
= dapm_dac_check_power
;
3124 case snd_soc_dapm_adc
:
3125 case snd_soc_dapm_aif_out
:
3126 case snd_soc_dapm_dac
:
3127 case snd_soc_dapm_aif_in
:
3128 case snd_soc_dapm_pga
:
3129 case snd_soc_dapm_out_drv
:
3130 case snd_soc_dapm_input
:
3131 case snd_soc_dapm_output
:
3132 case snd_soc_dapm_micbias
:
3133 case snd_soc_dapm_spk
:
3134 case snd_soc_dapm_hp
:
3135 case snd_soc_dapm_mic
:
3136 case snd_soc_dapm_line
:
3137 case snd_soc_dapm_dai_link
:
3138 w
->power_check
= dapm_generic_check_power
;
3140 case snd_soc_dapm_supply
:
3141 case snd_soc_dapm_regulator_supply
:
3142 case snd_soc_dapm_clock_supply
:
3143 case snd_soc_dapm_kcontrol
:
3144 w
->power_check
= dapm_supply_check_power
;
3147 w
->power_check
= dapm_always_on_check_power
;
3152 w
->codec
= dapm
->codec
;
3153 w
->platform
= dapm
->platform
;
3154 INIT_LIST_HEAD(&w
->sources
);
3155 INIT_LIST_HEAD(&w
->sinks
);
3156 INIT_LIST_HEAD(&w
->list
);
3157 INIT_LIST_HEAD(&w
->dirty
);
3158 list_add(&w
->list
, &dapm
->card
->widgets
);
3160 /* machine layer set ups unconnected pins and insertions */
3166 * snd_soc_dapm_new_controls - create new dapm controls
3167 * @dapm: DAPM context
3168 * @widget: widget array
3169 * @num: number of widgets
3171 * Creates new DAPM controls based upon the templates.
3173 * Returns 0 for success else error.
3175 int snd_soc_dapm_new_controls(struct snd_soc_dapm_context
*dapm
,
3176 const struct snd_soc_dapm_widget
*widget
,
3179 struct snd_soc_dapm_widget
*w
;
3183 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_INIT
);
3184 for (i
= 0; i
< num
; i
++) {
3185 w
= snd_soc_dapm_new_control(dapm
, widget
);
3188 "ASoC: Failed to create DAPM control %s\n",
3195 mutex_unlock(&dapm
->card
->dapm_mutex
);
3198 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls
);
3200 static int snd_soc_dai_link_event(struct snd_soc_dapm_widget
*w
,
3201 struct snd_kcontrol
*kcontrol
, int event
)
3203 struct snd_soc_dapm_path
*source_p
, *sink_p
;
3204 struct snd_soc_dai
*source
, *sink
;
3205 const struct snd_soc_pcm_stream
*config
= w
->params
;
3206 struct snd_pcm_substream substream
;
3207 struct snd_pcm_hw_params
*params
= NULL
;
3211 if (WARN_ON(!config
) ||
3212 WARN_ON(list_empty(&w
->sources
) || list_empty(&w
->sinks
)))
3215 /* We only support a single source and sink, pick the first */
3216 source_p
= list_first_entry(&w
->sources
, struct snd_soc_dapm_path
,
3218 sink_p
= list_first_entry(&w
->sinks
, struct snd_soc_dapm_path
,
3221 if (WARN_ON(!source_p
|| !sink_p
) ||
3222 WARN_ON(!sink_p
->source
|| !source_p
->sink
) ||
3223 WARN_ON(!source_p
->source
|| !sink_p
->sink
))
3226 source
= source_p
->source
->priv
;
3227 sink
= sink_p
->sink
->priv
;
3229 /* Be a little careful as we don't want to overflow the mask array */
3230 if (config
->formats
) {
3231 fmt
= ffs(config
->formats
) - 1;
3233 dev_warn(w
->dapm
->dev
, "ASoC: Invalid format %llx specified\n",
3238 /* Currently very limited parameter selection */
3239 params
= kzalloc(sizeof(*params
), GFP_KERNEL
);
3244 snd_mask_set(hw_param_mask(params
, SNDRV_PCM_HW_PARAM_FORMAT
), fmt
);
3246 hw_param_interval(params
, SNDRV_PCM_HW_PARAM_RATE
)->min
=
3248 hw_param_interval(params
, SNDRV_PCM_HW_PARAM_RATE
)->max
=
3251 hw_param_interval(params
, SNDRV_PCM_HW_PARAM_CHANNELS
)->min
3252 = config
->channels_min
;
3253 hw_param_interval(params
, SNDRV_PCM_HW_PARAM_CHANNELS
)->max
3254 = config
->channels_max
;
3256 memset(&substream
, 0, sizeof(substream
));
3259 case SND_SOC_DAPM_PRE_PMU
:
3260 if (source
->driver
->ops
&& source
->driver
->ops
->hw_params
) {
3261 substream
.stream
= SNDRV_PCM_STREAM_CAPTURE
;
3262 ret
= source
->driver
->ops
->hw_params(&substream
,
3265 dev_err(source
->dev
,
3266 "ASoC: hw_params() failed: %d\n", ret
);
3271 if (sink
->driver
->ops
&& sink
->driver
->ops
->hw_params
) {
3272 substream
.stream
= SNDRV_PCM_STREAM_PLAYBACK
;
3273 ret
= sink
->driver
->ops
->hw_params(&substream
, params
,
3277 "ASoC: hw_params() failed: %d\n", ret
);
3283 case SND_SOC_DAPM_POST_PMU
:
3284 ret
= snd_soc_dai_digital_mute(sink
, 0,
3285 SNDRV_PCM_STREAM_PLAYBACK
);
3286 if (ret
!= 0 && ret
!= -ENOTSUPP
)
3287 dev_warn(sink
->dev
, "ASoC: Failed to unmute: %d\n", ret
);
3291 case SND_SOC_DAPM_PRE_PMD
:
3292 ret
= snd_soc_dai_digital_mute(sink
, 1,
3293 SNDRV_PCM_STREAM_PLAYBACK
);
3294 if (ret
!= 0 && ret
!= -ENOTSUPP
)
3295 dev_warn(sink
->dev
, "ASoC: Failed to mute: %d\n", ret
);
3300 WARN(1, "Unknown event %d\n", event
);
3309 int snd_soc_dapm_new_pcm(struct snd_soc_card
*card
,
3310 const struct snd_soc_pcm_stream
*params
,
3311 struct snd_soc_dapm_widget
*source
,
3312 struct snd_soc_dapm_widget
*sink
)
3314 struct snd_soc_dapm_route routes
[2];
3315 struct snd_soc_dapm_widget
template;
3316 struct snd_soc_dapm_widget
*w
;
3320 len
= strlen(source
->name
) + strlen(sink
->name
) + 2;
3321 link_name
= devm_kzalloc(card
->dev
, len
, GFP_KERNEL
);
3324 snprintf(link_name
, len
, "%s-%s", source
->name
, sink
->name
);
3326 memset(&template, 0, sizeof(template));
3327 template.reg
= SND_SOC_NOPM
;
3328 template.id
= snd_soc_dapm_dai_link
;
3329 template.name
= link_name
;
3330 template.event
= snd_soc_dai_link_event
;
3331 template.event_flags
= SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMU
|
3332 SND_SOC_DAPM_PRE_PMD
;
3334 dev_dbg(card
->dev
, "ASoC: adding %s widget\n", link_name
);
3336 w
= snd_soc_dapm_new_control(&card
->dapm
, &template);
3338 dev_err(card
->dev
, "ASoC: Failed to create %s widget\n",
3345 memset(&routes
, 0, sizeof(routes
));
3347 routes
[0].source
= source
->name
;
3348 routes
[0].sink
= link_name
;
3349 routes
[1].source
= link_name
;
3350 routes
[1].sink
= sink
->name
;
3352 return snd_soc_dapm_add_routes(&card
->dapm
, routes
,
3353 ARRAY_SIZE(routes
));
3356 int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context
*dapm
,
3357 struct snd_soc_dai
*dai
)
3359 struct snd_soc_dapm_widget
template;
3360 struct snd_soc_dapm_widget
*w
;
3362 WARN_ON(dapm
->dev
!= dai
->dev
);
3364 memset(&template, 0, sizeof(template));
3365 template.reg
= SND_SOC_NOPM
;
3367 if (dai
->driver
->playback
.stream_name
) {
3368 template.id
= snd_soc_dapm_dai_in
;
3369 template.name
= dai
->driver
->playback
.stream_name
;
3370 template.sname
= dai
->driver
->playback
.stream_name
;
3372 dev_dbg(dai
->dev
, "ASoC: adding %s widget\n",
3375 w
= snd_soc_dapm_new_control(dapm
, &template);
3377 dev_err(dapm
->dev
, "ASoC: Failed to create %s widget\n",
3378 dai
->driver
->playback
.stream_name
);
3383 dai
->playback_widget
= w
;
3386 if (dai
->driver
->capture
.stream_name
) {
3387 template.id
= snd_soc_dapm_dai_out
;
3388 template.name
= dai
->driver
->capture
.stream_name
;
3389 template.sname
= dai
->driver
->capture
.stream_name
;
3391 dev_dbg(dai
->dev
, "ASoC: adding %s widget\n",
3394 w
= snd_soc_dapm_new_control(dapm
, &template);
3396 dev_err(dapm
->dev
, "ASoC: Failed to create %s widget\n",
3397 dai
->driver
->capture
.stream_name
);
3402 dai
->capture_widget
= w
;
3408 int snd_soc_dapm_link_dai_widgets(struct snd_soc_card
*card
)
3410 struct snd_soc_dapm_widget
*dai_w
, *w
;
3411 struct snd_soc_dai
*dai
;
3413 /* For each DAI widget... */
3414 list_for_each_entry(dai_w
, &card
->widgets
, list
) {
3415 switch (dai_w
->id
) {
3416 case snd_soc_dapm_dai_in
:
3417 case snd_soc_dapm_dai_out
:
3425 /* ...find all widgets with the same stream and link them */
3426 list_for_each_entry(w
, &card
->widgets
, list
) {
3427 if (w
->dapm
!= dai_w
->dapm
)
3431 case snd_soc_dapm_dai_in
:
3432 case snd_soc_dapm_dai_out
:
3438 if (!w
->sname
|| !strstr(w
->sname
, dai_w
->name
))
3441 if (dai
->driver
->playback
.stream_name
&&
3443 dai
->driver
->playback
.stream_name
)) {
3444 dev_dbg(dai
->dev
, "%s -> %s\n",
3445 dai
->playback_widget
->name
, w
->name
);
3447 snd_soc_dapm_add_path(w
->dapm
,
3448 dai
->playback_widget
, w
, NULL
, NULL
);
3451 if (dai
->driver
->capture
.stream_name
&&
3453 dai
->driver
->capture
.stream_name
)) {
3454 dev_dbg(dai
->dev
, "%s -> %s\n",
3455 w
->name
, dai
->capture_widget
->name
);
3457 snd_soc_dapm_add_path(w
->dapm
, w
,
3458 dai
->capture_widget
, NULL
, NULL
);
3466 void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card
*card
)
3468 struct snd_soc_pcm_runtime
*rtd
= card
->rtd
;
3469 struct snd_soc_dai
*cpu_dai
, *codec_dai
;
3470 struct snd_soc_dapm_route r
;
3473 memset(&r
, 0, sizeof(r
));
3475 /* for each BE DAI link... */
3476 for (i
= 0; i
< card
->num_rtd
; i
++) {
3477 rtd
= &card
->rtd
[i
];
3478 cpu_dai
= rtd
->cpu_dai
;
3479 codec_dai
= rtd
->codec_dai
;
3482 * dynamic FE links have no fixed DAI mapping.
3483 * CODEC<->CODEC links have no direct connection.
3485 if (rtd
->dai_link
->dynamic
|| rtd
->dai_link
->params
)
3488 /* there is no point in connecting BE DAI links with dummies */
3489 if (snd_soc_dai_is_dummy(codec_dai
) ||
3490 snd_soc_dai_is_dummy(cpu_dai
))
3493 /* connect BE DAI playback if widgets are valid */
3494 if (codec_dai
->playback_widget
&& cpu_dai
->playback_widget
) {
3495 r
.source
= cpu_dai
->playback_widget
->name
;
3496 r
.sink
= codec_dai
->playback_widget
->name
;
3497 dev_dbg(rtd
->dev
, "connected DAI link %s:%s -> %s:%s\n",
3498 cpu_dai
->codec
->name
, r
.source
,
3499 codec_dai
->platform
->name
, r
.sink
);
3501 snd_soc_dapm_add_route(&card
->dapm
, &r
, true);
3504 /* connect BE DAI capture if widgets are valid */
3505 if (codec_dai
->capture_widget
&& cpu_dai
->capture_widget
) {
3506 r
.source
= codec_dai
->capture_widget
->name
;
3507 r
.sink
= cpu_dai
->capture_widget
->name
;
3508 dev_dbg(rtd
->dev
, "connected DAI link %s:%s -> %s:%s\n",
3509 codec_dai
->codec
->name
, r
.source
,
3510 cpu_dai
->platform
->name
, r
.sink
);
3512 snd_soc_dapm_add_route(&card
->dapm
, &r
, true);
3518 static void soc_dapm_stream_event(struct snd_soc_pcm_runtime
*rtd
, int stream
,
3522 struct snd_soc_dapm_widget
*w_cpu
, *w_codec
;
3523 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
3524 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
3526 if (stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
3527 w_cpu
= cpu_dai
->playback_widget
;
3528 w_codec
= codec_dai
->playback_widget
;
3530 w_cpu
= cpu_dai
->capture_widget
;
3531 w_codec
= codec_dai
->capture_widget
;
3536 dapm_mark_dirty(w_cpu
, "stream event");
3539 case SND_SOC_DAPM_STREAM_START
:
3542 case SND_SOC_DAPM_STREAM_STOP
:
3545 case SND_SOC_DAPM_STREAM_SUSPEND
:
3546 case SND_SOC_DAPM_STREAM_RESUME
:
3547 case SND_SOC_DAPM_STREAM_PAUSE_PUSH
:
3548 case SND_SOC_DAPM_STREAM_PAUSE_RELEASE
:
3555 dapm_mark_dirty(w_codec
, "stream event");
3558 case SND_SOC_DAPM_STREAM_START
:
3559 w_codec
->active
= 1;
3561 case SND_SOC_DAPM_STREAM_STOP
:
3562 w_codec
->active
= 0;
3564 case SND_SOC_DAPM_STREAM_SUSPEND
:
3565 case SND_SOC_DAPM_STREAM_RESUME
:
3566 case SND_SOC_DAPM_STREAM_PAUSE_PUSH
:
3567 case SND_SOC_DAPM_STREAM_PAUSE_RELEASE
:
3572 dapm_power_widgets(rtd
->card
, event
);
3576 * snd_soc_dapm_stream_event - send a stream event to the dapm core
3577 * @rtd: PCM runtime data
3578 * @stream: stream name
3579 * @event: stream event
3581 * Sends a stream event to the dapm core. The core then makes any
3582 * necessary widget power changes.
3584 * Returns 0 for success else error.
3586 void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime
*rtd
, int stream
,
3589 struct snd_soc_card
*card
= rtd
->card
;
3591 mutex_lock_nested(&card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
3592 soc_dapm_stream_event(rtd
, stream
, event
);
3593 mutex_unlock(&card
->dapm_mutex
);
3597 * snd_soc_dapm_enable_pin_unlocked - enable pin.
3598 * @dapm: DAPM context
3601 * Enables input/output pin and its parents or children widgets iff there is
3602 * a valid audio route and active audio stream.
3604 * Requires external locking.
3606 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3607 * do any widget power switching.
3609 int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context
*dapm
,
3612 return snd_soc_dapm_set_pin(dapm
, pin
, 1);
3614 EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin_unlocked
);
3617 * snd_soc_dapm_enable_pin - enable pin.
3618 * @dapm: DAPM context
3621 * Enables input/output pin and its parents or children widgets iff there is
3622 * a valid audio route and active audio stream.
3624 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3625 * do any widget power switching.
3627 int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context
*dapm
, const char *pin
)
3631 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
3633 ret
= snd_soc_dapm_set_pin(dapm
, pin
, 1);
3635 mutex_unlock(&dapm
->card
->dapm_mutex
);
3639 EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin
);
3642 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
3643 * @dapm: DAPM context
3646 * Enables input/output pin regardless of any other state. This is
3647 * intended for use with microphone bias supplies used in microphone
3650 * Requires external locking.
3652 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3653 * do any widget power switching.
3655 int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context
*dapm
,
3658 struct snd_soc_dapm_widget
*w
= dapm_find_widget(dapm
, pin
, true);
3661 dev_err(dapm
->dev
, "ASoC: unknown pin %s\n", pin
);
3665 dev_dbg(w
->dapm
->dev
, "ASoC: force enable pin %s\n", pin
);
3668 dapm_mark_dirty(w
, "force enable");
3672 EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin_unlocked
);
3675 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
3676 * @dapm: DAPM context
3679 * Enables input/output pin regardless of any other state. This is
3680 * intended for use with microphone bias supplies used in microphone
3683 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3684 * do any widget power switching.
3686 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context
*dapm
,
3691 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
3693 ret
= snd_soc_dapm_force_enable_pin_unlocked(dapm
, pin
);
3695 mutex_unlock(&dapm
->card
->dapm_mutex
);
3699 EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin
);
3702 * snd_soc_dapm_disable_pin_unlocked - disable pin.
3703 * @dapm: DAPM context
3706 * Disables input/output pin and its parents or children widgets.
3708 * Requires external locking.
3710 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3711 * do any widget power switching.
3713 int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context
*dapm
,
3716 return snd_soc_dapm_set_pin(dapm
, pin
, 0);
3718 EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin_unlocked
);
3721 * snd_soc_dapm_disable_pin - disable pin.
3722 * @dapm: DAPM context
3725 * Disables input/output pin and its parents or children widgets.
3727 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3728 * do any widget power switching.
3730 int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context
*dapm
,
3735 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
3737 ret
= snd_soc_dapm_set_pin(dapm
, pin
, 0);
3739 mutex_unlock(&dapm
->card
->dapm_mutex
);
3743 EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin
);
3746 * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
3747 * @dapm: DAPM context
3750 * Marks the specified pin as being not connected, disabling it along
3751 * any parent or child widgets. At present this is identical to
3752 * snd_soc_dapm_disable_pin() but in future it will be extended to do
3753 * additional things such as disabling controls which only affect
3754 * paths through the pin.
3756 * Requires external locking.
3758 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3759 * do any widget power switching.
3761 int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context
*dapm
,
3764 return snd_soc_dapm_set_pin(dapm
, pin
, 0);
3766 EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin_unlocked
);
3769 * snd_soc_dapm_nc_pin - permanently disable pin.
3770 * @dapm: DAPM context
3773 * Marks the specified pin as being not connected, disabling it along
3774 * any parent or child widgets. At present this is identical to
3775 * snd_soc_dapm_disable_pin() but in future it will be extended to do
3776 * additional things such as disabling controls which only affect
3777 * paths through the pin.
3779 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3780 * do any widget power switching.
3782 int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context
*dapm
, const char *pin
)
3786 mutex_lock_nested(&dapm
->card
->dapm_mutex
, SND_SOC_DAPM_CLASS_RUNTIME
);
3788 ret
= snd_soc_dapm_set_pin(dapm
, pin
, 0);
3790 mutex_unlock(&dapm
->card
->dapm_mutex
);
3794 EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin
);
3797 * snd_soc_dapm_get_pin_status - get audio pin status
3798 * @dapm: DAPM context
3799 * @pin: audio signal pin endpoint (or start point)
3801 * Get audio pin status - connected or disconnected.
3803 * Returns 1 for connected otherwise 0.
3805 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context
*dapm
,
3808 struct snd_soc_dapm_widget
*w
= dapm_find_widget(dapm
, pin
, true);
3811 return w
->connected
;
3815 EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status
);
3818 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
3819 * @dapm: DAPM context
3820 * @pin: audio signal pin endpoint (or start point)
3822 * Mark the given endpoint or pin as ignoring suspend. When the
3823 * system is disabled a path between two endpoints flagged as ignoring
3824 * suspend will not be disabled. The path must already be enabled via
3825 * normal means at suspend time, it will not be turned on if it was not
3828 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context
*dapm
,
3831 struct snd_soc_dapm_widget
*w
= dapm_find_widget(dapm
, pin
, false);
3834 dev_err(dapm
->dev
, "ASoC: unknown pin %s\n", pin
);
3838 w
->ignore_suspend
= 1;
3842 EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend
);
3844 static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card
*card
,
3845 struct snd_soc_dapm_widget
*w
)
3847 struct snd_soc_dapm_path
*p
;
3849 list_for_each_entry(p
, &card
->paths
, list
) {
3850 if ((p
->source
== w
) || (p
->sink
== w
)) {
3852 "... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n",
3853 p
->source
->name
, p
->source
->id
, p
->source
->dapm
,
3854 p
->sink
->name
, p
->sink
->id
, p
->sink
->dapm
);
3856 /* Connected to something other than the codec */
3857 if (p
->source
->dapm
!= p
->sink
->dapm
)
3860 * Loopback connection from codec external pin to
3861 * codec external pin
3863 if (p
->sink
->id
== snd_soc_dapm_input
) {
3864 switch (p
->source
->id
) {
3865 case snd_soc_dapm_output
:
3866 case snd_soc_dapm_micbias
:
3879 * snd_soc_dapm_auto_nc_codec_pins - call snd_soc_dapm_nc_pin for unused pins
3880 * @codec: The codec whose pins should be processed
3882 * Automatically call snd_soc_dapm_nc_pin() for any external pins in the codec
3883 * which are unused. Pins are used if they are connected externally to the
3884 * codec, whether that be to some other device, or a loop-back connection to
3887 void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec
*codec
)
3889 struct snd_soc_card
*card
= codec
->card
;
3890 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
3891 struct snd_soc_dapm_widget
*w
;
3893 dev_dbg(codec
->dev
, "ASoC: Auto NC: DAPMs: card:%p codec:%p\n",
3894 &card
->dapm
, &codec
->dapm
);
3896 list_for_each_entry(w
, &card
->widgets
, list
) {
3897 if (w
->dapm
!= dapm
)
3900 case snd_soc_dapm_input
:
3901 case snd_soc_dapm_output
:
3902 case snd_soc_dapm_micbias
:
3903 dev_dbg(codec
->dev
, "ASoC: Auto NC: Checking widget %s\n",
3905 if (!snd_soc_dapm_widget_in_card_paths(card
, w
)) {
3907 "... Not in map; disabling\n");
3908 snd_soc_dapm_nc_pin(dapm
, w
->name
);
3918 * snd_soc_dapm_free - free dapm resources
3919 * @dapm: DAPM context
3921 * Free all dapm widgets and resources.
3923 void snd_soc_dapm_free(struct snd_soc_dapm_context
*dapm
)
3925 snd_soc_dapm_sys_remove(dapm
->dev
);
3926 dapm_debugfs_cleanup(dapm
);
3927 dapm_free_widgets(dapm
);
3928 list_del(&dapm
->list
);
3930 EXPORT_SYMBOL_GPL(snd_soc_dapm_free
);
3932 static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context
*dapm
)
3934 struct snd_soc_card
*card
= dapm
->card
;
3935 struct snd_soc_dapm_widget
*w
;
3936 LIST_HEAD(down_list
);
3939 mutex_lock(&card
->dapm_mutex
);
3941 list_for_each_entry(w
, &dapm
->card
->widgets
, list
) {
3942 if (w
->dapm
!= dapm
)
3945 dapm_seq_insert(w
, &down_list
, false);
3951 /* If there were no widgets to power down we're already in
3955 if (dapm
->bias_level
== SND_SOC_BIAS_ON
)
3956 snd_soc_dapm_set_bias_level(dapm
,
3957 SND_SOC_BIAS_PREPARE
);
3958 dapm_seq_run(card
, &down_list
, 0, false);
3959 if (dapm
->bias_level
== SND_SOC_BIAS_PREPARE
)
3960 snd_soc_dapm_set_bias_level(dapm
,
3961 SND_SOC_BIAS_STANDBY
);
3964 mutex_unlock(&card
->dapm_mutex
);
3968 * snd_soc_dapm_shutdown - callback for system shutdown
3970 void snd_soc_dapm_shutdown(struct snd_soc_card
*card
)
3972 struct snd_soc_dapm_context
*dapm
;
3974 list_for_each_entry(dapm
, &card
->dapm_list
, list
) {
3975 if (dapm
!= &card
->dapm
) {
3976 soc_dapm_shutdown_dapm(dapm
);
3977 if (dapm
->bias_level
== SND_SOC_BIAS_STANDBY
)
3978 snd_soc_dapm_set_bias_level(dapm
,
3983 soc_dapm_shutdown_dapm(&card
->dapm
);
3984 if (card
->dapm
.bias_level
== SND_SOC_BIAS_STANDBY
)
3985 snd_soc_dapm_set_bias_level(&card
->dapm
,
3989 /* Module information */
3990 MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
3991 MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC");
3992 MODULE_LICENSE("GPL");