Lines Matching +full:6 +full:- +full:channels +full:- +full:current +full:- +full:sinks

1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
12 // o Platform power domain - can support external components i.e. amps and
15 // o Jack insertion power event initiation - e.g. hp insertion will enable
16 // sinks, dacs, etc
42 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
67 /* dapm power sequences - make this per codec in the future */
81 [snd_soc_dapm_mic] = 6,
82 [snd_soc_dapm_siggen] = 6,
83 [snd_soc_dapm_input] = 6,
84 [snd_soc_dapm_output] = 6,
117 [snd_soc_dapm_sink] = 6,
118 [snd_soc_dapm_pga] = 6,
119 [snd_soc_dapm_buffer] = 6,
120 [snd_soc_dapm_scheduler] = 6,
121 [snd_soc_dapm_effect] = 6,
122 [snd_soc_dapm_src] = 6,
123 [snd_soc_dapm_asrc] = 6,
124 [snd_soc_dapm_encoder] = 6,
125 [snd_soc_dapm_decoder] = 6,
152 if (snd_soc_card_is_instantiated(dapm->card)) in dapm_assert_locked()
185 return !list_empty(&w->dirty); in dapm_dirty_widget()
190 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
193 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
194 w->name, reason); in dapm_mark_dirty()
195 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
214 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_paths()
216 if (w->endpoints[dir] == -1) in dapm_widget_invalidate_paths()
219 list_add_tail(&w->work_list, &list); in dapm_widget_invalidate_paths()
220 w->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
224 if (p->is_supply || p->weak || !p->connect) in dapm_widget_invalidate_paths()
226 node = p->node[rdir]; in dapm_widget_invalidate_paths()
227 if (node->endpoints[dir] != -1) { in dapm_widget_invalidate_paths()
228 node->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
229 list_add_tail(&node->work_list, &list); in dapm_widget_invalidate_paths()
236 * dapm_widget_invalidate_input_paths() - Invalidate the cached number of
253 * dapm_widget_invalidate_output_paths() - Invalidate the cached number of
270 * dapm_path_invalidate() - Invalidates the cached number of inputs and outputs
286 if (p->weak || p->is_supply) in dapm_path_invalidate()
293 * so there is no need to re-check the path. in dapm_path_invalidate()
295 if (p->source->endpoints[SND_SOC_DAPM_DIR_IN] != 0) in dapm_path_invalidate()
296 dapm_widget_invalidate_input_paths(p->sink); in dapm_path_invalidate()
297 if (p->sink->endpoints[SND_SOC_DAPM_DIR_OUT] != 0) in dapm_path_invalidate()
298 dapm_widget_invalidate_output_paths(p->source); in dapm_path_invalidate()
308 if (w->is_ep) { in dapm_mark_endpoints_dirty()
310 if (w->is_ep & SND_SOC_DAPM_EP_SINK) in dapm_mark_endpoints_dirty()
312 if (w->is_ep & SND_SOC_DAPM_EP_SOURCE) in dapm_mark_endpoints_dirty()
332 * w->name is duplicated in caller, but w->sname isn't. in dapm_cnew_widget()
335 if (_widget->sname) { in dapm_cnew_widget()
336 w->sname = kstrdup_const(_widget->sname, GFP_KERNEL); in dapm_cnew_widget()
337 if (!w->sname) { in dapm_cnew_widget()
363 return -ENOMEM; in dapm_kcontrol_data_alloc()
365 INIT_LIST_HEAD(&data->paths); in dapm_kcontrol_data_alloc()
367 switch (widget->id) { in dapm_kcontrol_data_alloc()
371 mc = (struct soc_mixer_control *)kcontrol->private_value; in dapm_kcontrol_data_alloc()
373 if (mc->autodisable) { in dapm_kcontrol_data_alloc()
377 dev_warn(widget->dapm->dev, in dapm_kcontrol_data_alloc()
384 ret = -ENOMEM; in dapm_kcontrol_data_alloc()
389 template.reg = mc->reg; in dapm_kcontrol_data_alloc()
390 template.mask = (1 << fls(mc->max)) - 1; in dapm_kcontrol_data_alloc()
391 template.shift = mc->shift; in dapm_kcontrol_data_alloc()
392 if (mc->invert) in dapm_kcontrol_data_alloc()
393 template.off_val = mc->max; in dapm_kcontrol_data_alloc()
400 data->value = template.on_val; in dapm_kcontrol_data_alloc()
402 data->widget = in dapm_kcontrol_data_alloc()
403 snd_soc_dapm_new_control_unlocked(widget->dapm, in dapm_kcontrol_data_alloc()
406 if (IS_ERR(data->widget)) { in dapm_kcontrol_data_alloc()
407 ret = PTR_ERR(data->widget); in dapm_kcontrol_data_alloc()
414 e = (struct soc_enum *)kcontrol->private_value; in dapm_kcontrol_data_alloc()
416 if (e->autodisable) { in dapm_kcontrol_data_alloc()
422 ret = -ENOMEM; in dapm_kcontrol_data_alloc()
427 template.reg = e->reg; in dapm_kcontrol_data_alloc()
428 template.mask = e->mask; in dapm_kcontrol_data_alloc()
429 template.shift = e->shift_l; in dapm_kcontrol_data_alloc()
435 data->value = template.on_val; in dapm_kcontrol_data_alloc()
437 data->widget = snd_soc_dapm_new_control_unlocked( in dapm_kcontrol_data_alloc()
438 widget->dapm, &template); in dapm_kcontrol_data_alloc()
440 if (IS_ERR(data->widget)) { in dapm_kcontrol_data_alloc()
441 ret = PTR_ERR(data->widget); in dapm_kcontrol_data_alloc()
445 snd_soc_dapm_add_path(widget->dapm, data->widget, in dapm_kcontrol_data_alloc()
447 } else if (e->reg != SND_SOC_NOPM) { in dapm_kcontrol_data_alloc()
448 data->value = soc_dapm_read(widget->dapm, e->reg) & in dapm_kcontrol_data_alloc()
449 (e->mask << e->shift_l); in dapm_kcontrol_data_alloc()
456 kcontrol->private_data = data; in dapm_kcontrol_data_alloc()
469 list_del(&data->paths); in dapm_kcontrol_free()
470 kfree(data->wlist); in dapm_kcontrol_free()
479 return data->wlist; in dapm_kcontrol_get_wlist()
489 if (data->wlist) in dapm_kcontrol_add_widget()
490 n = data->wlist->num_widgets + 1; in dapm_kcontrol_add_widget()
494 new_wlist = krealloc(data->wlist, in dapm_kcontrol_add_widget()
498 return -ENOMEM; in dapm_kcontrol_add_widget()
500 new_wlist->widgets[n - 1] = widget; in dapm_kcontrol_add_widget()
501 new_wlist->num_widgets = n; in dapm_kcontrol_add_widget()
503 data->wlist = new_wlist; in dapm_kcontrol_add_widget()
513 list_add_tail(&path->list_kcontrol, &data->paths); in dapm_kcontrol_add_path()
520 if (!data->widget) in dapm_kcontrol_is_powered()
523 return data->widget->power; in dapm_kcontrol_is_powered()
531 return &data->paths; in dapm_kcontrol_get_path_list()
542 return data->value; in dapm_kcontrol_get_value()
551 if (data->value == value) in dapm_kcontrol_set_value()
554 if (data->widget) { in dapm_kcontrol_set_value()
555 switch (dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->id) { in dapm_kcontrol_set_value()
559 data->widget->on_val = value & data->widget->mask; in dapm_kcontrol_set_value()
563 data->widget->on_val = value >> data->widget->shift; in dapm_kcontrol_set_value()
566 data->widget->on_val = value; in dapm_kcontrol_set_value()
571 data->value = value; in dapm_kcontrol_set_value()
577 * snd_soc_dapm_kcontrol_widget() - Returns the widget associated to a
584 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]; in snd_soc_dapm_kcontrol_widget()
589 * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a
599 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm; in snd_soc_dapm_kcontrol_dapm()
609 memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); in dapm_reset()
612 w->new_power = w->power; in dapm_reset()
613 w->power_checked = false; in dapm_reset()
619 if (!dapm->component) in soc_dapm_prefix()
621 return dapm->component->name_prefix; in soc_dapm_prefix()
626 if (!dapm->component) in soc_dapm_read()
627 return -EIO; in soc_dapm_read()
628 return snd_soc_component_read(dapm->component, reg); in soc_dapm_read()
634 if (!dapm->component) in soc_dapm_update_bits()
635 return -EIO; in soc_dapm_update_bits()
636 return snd_soc_component_update_bits(dapm->component, reg, in soc_dapm_update_bits()
643 if (!dapm->component) in soc_dapm_test_bits()
644 return -EIO; in soc_dapm_test_bits()
645 return snd_soc_component_test_bits(dapm->component, reg, mask, value); in soc_dapm_test_bits()
650 if (dapm->component) in soc_dapm_async_complete()
651 snd_soc_component_async_complete(dapm->component); in soc_dapm_async_complete()
658 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
663 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
675 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
683 * current and the target state will not be entered.
696 if (dapm->component) in snd_soc_dapm_force_bias_level()
697 ret = snd_soc_component_set_bias_level(dapm->component, level); in snd_soc_dapm_force_bias_level()
700 dapm->bias_level = level; in snd_soc_dapm_force_bias_level()
707 * snd_soc_dapm_set_bias_level - set the bias level for the system
718 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_set_bias_level()
727 if (!card || dapm != &card->dapm) in snd_soc_dapm_set_bias_level()
745 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
746 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in dapm_connect_mux()
750 if (e->reg != SND_SOC_NOPM) { in dapm_connect_mux()
752 val = soc_dapm_read(dapm, e->reg); in dapm_connect_mux()
753 val = (val >> e->shift_l) & e->mask; in dapm_connect_mux()
765 i = match_string(e->texts, e->items, control_name); in dapm_connect_mux()
767 return -ENODEV; in dapm_connect_mux()
769 path->name = e->texts[i]; in dapm_connect_mux()
770 path->connect = (i == item); in dapm_connect_mux()
780 p->sink->kcontrol_news[i].private_value; in dapm_set_mixer_path_status()
781 unsigned int reg = mc->reg; in dapm_set_mixer_path_status()
782 unsigned int invert = mc->invert; in dapm_set_mixer_path_status()
785 unsigned int shift = mc->shift; in dapm_set_mixer_path_status()
786 unsigned int max = mc->max; in dapm_set_mixer_path_status()
787 unsigned int mask = (1 << fls(max)) - 1; in dapm_set_mixer_path_status()
788 unsigned int val = soc_dapm_read(p->sink->dapm, reg); in dapm_set_mixer_path_status()
794 * of paths and channels. But since kcontrols only come in dapm_set_mixer_path_status()
796 * channels. in dapm_set_mixer_path_status()
803 if (reg != mc->rreg) in dapm_set_mixer_path_status()
804 val = soc_dapm_read(p->sink->dapm, mc->rreg); in dapm_set_mixer_path_status()
805 val = (val >> mc->rshift) & mask; in dapm_set_mixer_path_status()
810 val = max - val; in dapm_set_mixer_path_status()
811 p->connect = !!val; in dapm_set_mixer_path_status()
819 p->connect = invert; in dapm_set_mixer_path_status()
830 for (i = 0; i < path->sink->num_kcontrols; i++) { in dapm_connect_mixer()
831 if (!strcmp(control_name, path->sink->kcontrol_news[i].name)) { in dapm_connect_mixer()
832 path->name = path->sink->kcontrol_news[i].name; in dapm_connect_mixer()
837 return -ENODEV; in dapm_connect_mixer()
850 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
851 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
853 for (i = 0; i < w->num_kcontrols; i++) { in dapm_is_shared_kcontrol()
854 if (&w->kcontrol_news[i] == kcontrol_new) { in dapm_is_shared_kcontrol()
855 if (w->kcontrols) in dapm_is_shared_kcontrol()
856 *kcontrol = w->kcontrols[i]; in dapm_is_shared_kcontrol()
872 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol()
873 struct snd_card *card = dapm->card->snd_card; in dapm_create_or_share_kcontrol()
889 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
897 switch (w->id) { in dapm_create_or_share_kcontrol()
916 return -EINVAL; in dapm_create_or_share_kcontrol()
919 if (w->no_wname_in_kcontrol_name) in dapm_create_or_share_kcontrol()
930 w->name + prefix_len, in dapm_create_or_share_kcontrol()
931 w->kcontrol_news[kci].name); in dapm_create_or_share_kcontrol()
933 return -ENOMEM; in dapm_create_or_share_kcontrol()
938 name = w->name + prefix_len; in dapm_create_or_share_kcontrol()
941 name = w->kcontrol_news[kci].name; in dapm_create_or_share_kcontrol()
944 kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name, in dapm_create_or_share_kcontrol()
947 ret = -ENOMEM; in dapm_create_or_share_kcontrol()
951 kcontrol->private_free = dapm_kcontrol_free; in dapm_create_or_share_kcontrol()
961 dev_err(dapm->dev, in dapm_create_or_share_kcontrol()
963 w->name, name, ret); in dapm_create_or_share_kcontrol()
970 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
986 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
990 if (path->name != (char *)w->kcontrol_news[i].name) in dapm_new_mixer()
993 if (!w->kcontrols[i]) { in dapm_new_mixer()
999 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
1001 data = snd_kcontrol_chip(w->kcontrols[i]); in dapm_new_mixer()
1002 if (data->widget) in dapm_new_mixer()
1003 snd_soc_dapm_add_path(data->widget->dapm, in dapm_new_mixer()
1004 data->widget, in dapm_new_mixer()
1005 path->source, in dapm_new_mixer()
1016 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1022 switch (w->id) { in dapm_new_mux()
1032 return -EINVAL; in dapm_new_mux()
1035 if (w->num_kcontrols != 1) { in dapm_new_mux()
1036 dev_err(dapm->dev, in dapm_new_mux()
1038 w->name); in dapm_new_mux()
1039 return -EINVAL; in dapm_new_mux()
1042 if (list_empty(&w->edges[dir])) { in dapm_new_mux()
1043 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1044 return -EINVAL; in dapm_new_mux()
1052 if (path->name) in dapm_new_mux()
1053 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1064 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1077 struct snd_soc_pcm_runtime *rtd = w->priv; in dapm_new_dai_link()
1080 if (rtd->dai_link->num_c2c_params <= 1) in dapm_new_dai_link()
1084 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_dai_link()
1085 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link()
1086 struct snd_card *card = dapm->card->snd_card; in dapm_new_dai_link()
1087 struct snd_kcontrol *kcontrol = snd_soc_cnew(&w->kcontrol_news[i], in dapm_new_dai_link()
1088 w, w->name, NULL); in dapm_new_dai_link()
1092 dev_err(dapm->dev, in dapm_new_dai_link()
1094 w->name, w->kcontrol_news[i].name, ret); in dapm_new_dai_link()
1097 kcontrol->private_data = w; in dapm_new_dai_link()
1098 w->kcontrols[i] = kcontrol; in dapm_new_dai_link()
1105 * the ALSA card - when we are suspending the ALSA state for the card
1110 int level = snd_power_get_state(widget->dapm->card->snd_card); in snd_soc_dapm_suspend_check()
1115 if (widget->ignore_suspend) in snd_soc_dapm_suspend_check()
1116 dev_dbg(widget->dapm->dev, "ASoC: %s ignoring suspend\n", in snd_soc_dapm_suspend_check()
1117 widget->name); in snd_soc_dapm_suspend_check()
1118 return widget->ignore_suspend; in snd_soc_dapm_suspend_check()
1142 return -ENOMEM; in dapm_widget_list_create()
1145 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1147 (*list)->num_widgets = i; in dapm_widget_list_create()
1163 widget->endpoints[dir] = -1; in invalidate_paths_ep()
1166 if (path->weak || path->is_supply) in invalidate_paths_ep()
1169 if (path->walking) in invalidate_paths_ep()
1172 if (path->connect) { in invalidate_paths_ep()
1173 path->walking = 1; in invalidate_paths_ep()
1174 invalidate_paths_ep(path->node[dir], dir); in invalidate_paths_ep()
1175 path->walking = 0; in invalidate_paths_ep()
1199 if (widget->endpoints[dir] >= 0) in is_connected_ep()
1200 return widget->endpoints[dir]; in is_connected_ep()
1206 list_add_tail(&widget->work_list, list); in is_connected_ep()
1213 if ((widget->is_ep & SND_SOC_DAPM_DIR_TO_EP(dir)) && widget->connected) { in is_connected_ep()
1214 widget->endpoints[dir] = snd_soc_dapm_suspend_check(widget); in is_connected_ep()
1215 return widget->endpoints[dir]; in is_connected_ep()
1221 if (path->weak || path->is_supply) in is_connected_ep()
1224 if (path->walking) in is_connected_ep()
1229 if (path->connect) { in is_connected_ep()
1230 path->walking = 1; in is_connected_ep()
1231 con += fn(path->node[dir], list, custom_stop_condition); in is_connected_ep()
1232 path->walking = 0; in is_connected_ep()
1236 widget->endpoints[dir] = con; in is_connected_ep()
1278 * snd_soc_dapm_dai_get_connected_widgets - query audio path and it's widgets.
1287 * current mixer and mux kcontrol settings. Creates list of valid widgets.
1301 struct snd_soc_card *card = dai->component->card; in snd_soc_dapm_dai_get_connected_widgets()
1347 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1350 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1351 ret = regulator_allow_bypass(w->regulator, false); in dapm_regulator_event()
1353 dev_warn(w->dapm->dev, in dapm_regulator_event()
1355 w->name, ret); in dapm_regulator_event()
1358 return regulator_enable(w->regulator); in dapm_regulator_event()
1360 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1361 ret = regulator_allow_bypass(w->regulator, true); in dapm_regulator_event()
1363 dev_warn(w->dapm->dev, in dapm_regulator_event()
1365 w->name, ret); in dapm_regulator_event()
1368 return regulator_disable_deferred(w->regulator, w->shift); in dapm_regulator_event()
1379 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in dapm_pinctrl_event()
1380 struct pinctrl *p = w->pinctrl; in dapm_pinctrl_event()
1384 return -EIO; in dapm_pinctrl_event()
1387 s = pinctrl_lookup_state(p, priv->active_state); in dapm_pinctrl_event()
1389 s = pinctrl_lookup_state(p, priv->sleep_state); in dapm_pinctrl_event()
1404 if (!w->clk) in dapm_clock_event()
1405 return -EIO; in dapm_clock_event()
1407 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1410 return clk_prepare_enable(w->clk); in dapm_clock_event()
1412 clk_disable_unprepare(w->clk); in dapm_clock_event()
1422 if (w->power_checked) in dapm_widget_power_check()
1423 return w->new_power; in dapm_widget_power_check()
1425 if (w->force) in dapm_widget_power_check()
1426 w->new_power = 1; in dapm_widget_power_check()
1428 w->new_power = w->power_check(w); in dapm_widget_power_check()
1430 w->power_checked = true; in dapm_widget_power_check()
1432 return w->new_power; in dapm_widget_power_check()
1458 if (path->weak) in dapm_supply_check_power()
1461 if (path->connected && in dapm_supply_check_power()
1462 !path->connected(path->source, path->sink)) in dapm_supply_check_power()
1465 if (dapm_widget_power_check(path->sink)) in dapm_supply_check_power()
1474 return w->connected; in dapm_always_on_check_power()
1491 WARN_ONCE(sort[a->id] == 0, "offset a->id %d not initialized\n", a->id); in dapm_seq_compare()
1492 WARN_ONCE(sort[b->id] == 0, "offset b->id %d not initialized\n", b->id); in dapm_seq_compare()
1494 if (sort[a->id] != sort[b->id]) in dapm_seq_compare()
1495 return sort[a->id] - sort[b->id]; in dapm_seq_compare()
1496 if (a->subseq != b->subseq) { in dapm_seq_compare()
1498 return a->subseq - b->subseq; in dapm_seq_compare()
1500 return b->subseq - a->subseq; in dapm_seq_compare()
1502 if (a->reg != b->reg) in dapm_seq_compare()
1503 return a->reg - b->reg; in dapm_seq_compare()
1504 if (a->dapm != b->dapm) in dapm_seq_compare()
1505 return (unsigned long)a->dapm - (unsigned long)b->dapm; in dapm_seq_compare()
1519 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1523 list_add_tail(&new_widget->power_list, list); in dapm_seq_insert()
1562 if (w->new_power != power) in dapm_seq_check_event()
1565 if (w->event && (w->event_flags & event)) { in dapm_seq_check_event()
1568 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1569 w->name, ev_name); in dapm_seq_check_event()
1570 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1572 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1575 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1576 ev_name, w->name, ret); in dapm_seq_check_event()
1591 reg = w->reg; in dapm_seq_run_coalesced()
1592 dapm = w->dapm; in dapm_seq_run_coalesced()
1595 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1596 w->power = w->new_power; in dapm_seq_run_coalesced()
1598 mask |= w->mask << w->shift; in dapm_seq_run_coalesced()
1599 if (w->power) in dapm_seq_run_coalesced()
1600 value |= w->on_val << w->shift; in dapm_seq_run_coalesced()
1602 value |= w->off_val << w->shift; in dapm_seq_run_coalesced()
1604 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1606 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1618 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1620 value, mask, reg, card->pop_time); in dapm_seq_run_coalesced()
1621 pop_wait(card->pop_time); in dapm_seq_run_coalesced()
1633 * We walk over a pre-sorted list of widgets to apply power to. In
1645 int cur_sort = -1; in dapm_seq_run()
1646 int cur_subseq = -1; in dapm_seq_run()
1661 if (sort[w->id] != cur_sort || w->reg != cur_reg || in dapm_seq_run()
1662 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1666 if (cur_dapm && cur_dapm->component) { in dapm_seq_run()
1670 cur_dapm->component, in dapm_seq_run()
1674 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1678 cur_sort = -1; in dapm_seq_run()
1684 switch (w->id) { in dapm_seq_run()
1686 if (!w->event) in dapm_seq_run()
1690 ret = w->event(w, in dapm_seq_run()
1693 ret = w->event(w, in dapm_seq_run()
1698 if (!w->event) in dapm_seq_run()
1702 ret = w->event(w, in dapm_seq_run()
1705 ret = w->event(w, in dapm_seq_run()
1711 cur_sort = sort[w->id]; in dapm_seq_run()
1712 cur_subseq = w->subseq; in dapm_seq_run()
1713 cur_reg = w->reg; in dapm_seq_run()
1714 cur_dapm = w->dapm; in dapm_seq_run()
1715 list_move(&w->power_list, &pending); in dapm_seq_run()
1720 dev_err(w->dapm->dev, in dapm_seq_run()
1727 if (cur_dapm && cur_dapm->component) { in dapm_seq_run()
1731 cur_dapm->component, in dapm_seq_run()
1741 struct snd_soc_dapm_update *update = card->update; in dapm_widget_update()
1747 if (!update || !dapm_kcontrol_is_powered(update->kcontrol)) in dapm_widget_update()
1750 wlist = dapm_kcontrol_get_wlist(update->kcontrol); in dapm_widget_update()
1753 if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) { in dapm_widget_update()
1754 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); in dapm_widget_update()
1756 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1757 w->name, ret); in dapm_widget_update()
1764 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1765 update->val); in dapm_widget_update()
1767 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1768 w->name, ret); in dapm_widget_update()
1770 if (update->has_second_set) { in dapm_widget_update()
1771 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1772 update->mask2, update->val2); in dapm_widget_update()
1774 dev_err(w->dapm->dev, in dapm_widget_update()
1776 w->name, ret); in dapm_widget_update()
1780 if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) { in dapm_widget_update()
1781 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); in dapm_widget_update()
1783 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1784 w->name, ret); in dapm_widget_update()
1789 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1798 if (d->bias_level == SND_SOC_BIAS_OFF && in dapm_pre_sequence_async()
1799 d->target_bias_level != SND_SOC_BIAS_OFF) { in dapm_pre_sequence_async()
1800 if (d->dev && cookie) in dapm_pre_sequence_async()
1801 pm_runtime_get_sync(d->dev); in dapm_pre_sequence_async()
1805 dev_err(d->dev, in dapm_pre_sequence_async()
1810 if ((d->target_bias_level == SND_SOC_BIAS_ON && in dapm_pre_sequence_async()
1811 d->bias_level != SND_SOC_BIAS_ON) || in dapm_pre_sequence_async()
1812 (d->target_bias_level != SND_SOC_BIAS_ON && in dapm_pre_sequence_async()
1813 d->bias_level == SND_SOC_BIAS_ON)) { in dapm_pre_sequence_async()
1816 dev_err(d->dev, in dapm_pre_sequence_async()
1821 /* Async callback run prior to DAPM sequences - brings to their final
1830 if (d->bias_level == SND_SOC_BIAS_PREPARE && in dapm_post_sequence_async()
1831 (d->target_bias_level == SND_SOC_BIAS_STANDBY || in dapm_post_sequence_async()
1832 d->target_bias_level == SND_SOC_BIAS_OFF)) { in dapm_post_sequence_async()
1835 dev_err(d->dev, "ASoC: Failed to apply standby bias: %d\n", in dapm_post_sequence_async()
1840 if (d->bias_level == SND_SOC_BIAS_STANDBY && in dapm_post_sequence_async()
1841 d->target_bias_level == SND_SOC_BIAS_OFF) { in dapm_post_sequence_async()
1844 dev_err(d->dev, "ASoC: Failed to turn off bias: %d\n", in dapm_post_sequence_async()
1847 if (d->dev && cookie) in dapm_post_sequence_async()
1848 pm_runtime_put(d->dev); in dapm_post_sequence_async()
1852 if (d->bias_level == SND_SOC_BIAS_PREPARE && in dapm_post_sequence_async()
1853 d->target_bias_level == SND_SOC_BIAS_ON) { in dapm_post_sequence_async()
1856 dev_err(d->dev, "ASoC: Failed to apply active bias: %d\n", in dapm_post_sequence_async()
1872 if (power != peer->power) in dapm_widget_set_peer_power()
1883 switch (w->id) { in dapm_power_one_widget()
1896 if (w->power == power) in dapm_power_one_widget()
1906 dapm_widget_set_peer_power(path->source, power, path->connect); in dapm_power_one_widget()
1911 if (!w->is_supply) in dapm_power_one_widget()
1913 dapm_widget_set_peer_power(path->sink, power, path->connect); in dapm_power_one_widget()
1924 if (dapm->idle_bias_off) in dapm_idle_bias_off()
1927 switch (snd_power_get_state(dapm->card->snd_card)) { in dapm_idle_bias_off()
1930 return dapm->suspend_bias_off; in dapm_idle_bias_off()
1940 * A complete path is a route that has valid endpoints i.e.:-
1963 d->target_bias_level = SND_SOC_BIAS_OFF; in dapm_power_widgets()
1965 d->target_bias_level = SND_SOC_BIAS_STANDBY; in dapm_power_widgets()
1976 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1981 switch (w->id) { in dapm_power_widgets()
1987 list_del_init(&w->dirty); in dapm_power_widgets()
1991 if (w->new_power) { in dapm_power_widgets()
1992 d = w->dapm; in dapm_power_widgets()
2001 switch (w->id) { in dapm_power_widgets()
2010 if (d->target_bias_level < SND_SOC_BIAS_STANDBY) in dapm_power_widgets()
2011 d->target_bias_level = SND_SOC_BIAS_STANDBY; in dapm_power_widgets()
2014 d->target_bias_level = SND_SOC_BIAS_ON; in dapm_power_widgets()
2026 if (d->target_bias_level > bias) in dapm_power_widgets()
2027 bias = d->target_bias_level; in dapm_power_widgets()
2030 d->target_bias_level = bias; in dapm_power_widgets()
2035 dapm_pre_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2038 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2062 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2068 dapm_post_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2072 if (!d->component) in dapm_power_widgets()
2075 ret = snd_soc_component_stream_event(d->component, event); in dapm_power_widgets()
2080 pop_dbg(card->dev, card->pop_time, in dapm_power_widgets()
2081 "DAPM sequencing finished, waiting %dms\n", card->pop_time); in dapm_power_widgets()
2082 pop_wait(card->pop_time); in dapm_power_widgets()
2094 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file()
2103 return -ENOMEM; in dapm_widget_power_read_file()
2105 snd_soc_dapm_mutex_lock_root(w->dapm); in dapm_widget_power_read_file()
2108 if (w->is_supply) { in dapm_widget_power_read_file()
2117 w->name, w->power ? "On" : "Off", in dapm_widget_power_read_file()
2118 w->force ? " (forced)" : "", in, out); in dapm_widget_power_read_file()
2120 if (w->reg >= 0) in dapm_widget_power_read_file()
2121 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in dapm_widget_power_read_file()
2122 " - R%d(0x%x) mask 0x%x", in dapm_widget_power_read_file()
2123 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2125 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n"); in dapm_widget_power_read_file()
2127 if (w->sname) in dapm_widget_power_read_file()
2128 ret += scnprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n", in dapm_widget_power_read_file()
2129 w->sname, in dapm_widget_power_read_file()
2130 w->active ? "active" : "inactive"); in dapm_widget_power_read_file()
2135 if (p->connected && !p->connected(p->source, p->sink)) in dapm_widget_power_read_file()
2138 if (!p->connect) in dapm_widget_power_read_file()
2141 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in dapm_widget_power_read_file()
2144 p->name ? p->name : "static", in dapm_widget_power_read_file()
2145 p->node[rdir]->name); in dapm_widget_power_read_file()
2149 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2166 struct snd_soc_dapm_context *dapm = file->private_data; in dapm_bias_read_file()
2169 switch (dapm->bias_level) { in dapm_bias_read_file()
2183 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2204 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); in snd_soc_dapm_debugfs_init()
2206 debugfs_create_file("bias_level", 0444, dapm->debugfs_dapm, dapm, in snd_soc_dapm_debugfs_init()
2212 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget()
2214 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2217 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2223 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_free_widget()
2225 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_free_widget()
2228 debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); in dapm_debugfs_free_widget()
2233 debugfs_remove_recursive(dapm->debugfs_dapm); in dapm_debugfs_cleanup()
2234 dapm->debugfs_dapm = NULL; in dapm_debugfs_cleanup()
2258 * soc_dapm_connect_path() - Connects or disconnects a path
2267 if (path->connect == connect) in soc_dapm_connect_path()
2270 path->connect = connect; in soc_dapm_connect_path()
2271 dapm_mark_dirty(path->source, reason); in soc_dapm_connect_path()
2272 dapm_mark_dirty(path->sink, reason); in soc_dapm_connect_path()
2290 if (e && !(strcmp(path->name, e->texts[mux]))) in soc_dapm_mux_update_power()
2308 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mux_update_power()
2312 card->update = update; in snd_soc_dapm_mux_update_power()
2314 card->update = NULL; in snd_soc_dapm_mux_update_power()
2336 * paths and channels. But since kcontrols only come in soc_dapm_mixer_update_power()
2338 * channels. in soc_dapm_mixer_update_power()
2373 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mixer_update_power()
2377 card->update = update; in snd_soc_dapm_mixer_update_power()
2378 ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1); in snd_soc_dapm_mixer_update_power()
2379 card->update = NULL; in snd_soc_dapm_mixer_update_power()
2398 if (!cmpnt->card) in dapm_widget_show_component()
2401 for_each_card_widgets(cmpnt->card, w) { in dapm_widget_show_component()
2402 if (w->dapm != dapm) in dapm_widget_show_component()
2406 switch (w->id) { in dapm_widget_show_component()
2423 if (w->name) in dapm_widget_show_component()
2425 w->name, w->power ? "On":"Off"); in dapm_widget_show_component()
2459 snd_soc_dapm_mutex_lock_root(rtd->card); in dapm_widget_show()
2462 struct snd_soc_component *cmpnt = codec_dai->component; in dapm_widget_show()
2467 snd_soc_dapm_mutex_unlock(rtd->card); in dapm_widget_show()
2481 list_del(&path->list_node[SND_SOC_DAPM_DIR_IN]); in dapm_free_path()
2482 list_del(&path->list_node[SND_SOC_DAPM_DIR_OUT]); in dapm_free_path()
2483 list_del(&path->list_kcontrol); in dapm_free_path()
2484 list_del(&path->list); in dapm_free_path()
2489 * snd_soc_dapm_free_widget - Free specified widget
2502 list_del(&w->list); in snd_soc_dapm_free_widget()
2503 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2516 kfree(w->kcontrols); in snd_soc_dapm_free_widget()
2517 kfree_const(w->name); in snd_soc_dapm_free_widget()
2518 kfree_const(w->sname); in snd_soc_dapm_free_widget()
2528 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2529 if (w->dapm != dapm) in dapm_free_widgets()
2534 dapm->wcache_sink = NULL; in dapm_free_widgets()
2535 dapm->wcache_source = NULL; in dapm_free_widgets()
2556 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2557 if (!strcmp(w->name, pin_name)) { in dapm_find_widget()
2558 if (w->dapm == dapm) in dapm_find_widget()
2585 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); in __snd_soc_dapm_set_pin()
2586 return -EINVAL; in __snd_soc_dapm_set_pin()
2589 if (w->connected != status) { in __snd_soc_dapm_set_pin()
2596 w->connected = status; in __snd_soc_dapm_set_pin()
2598 w->force = 0; in __snd_soc_dapm_set_pin()
2616 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2632 if (!snd_soc_card_is_instantiated(dapm->card)) in snd_soc_dapm_sync_unlocked()
2635 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); in snd_soc_dapm_sync_unlocked()
2640 * snd_soc_dapm_sync - scan and power dapm paths
2661 int channels) in dapm_update_dai_chan() argument
2663 switch (w->id) { in dapm_update_dai_chan()
2671 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2672 w->channel < channels ? "Connecting" : "Disconnecting", in dapm_update_dai_chan()
2673 p->source->name, p->sink->name); in dapm_update_dai_chan()
2675 if (w->channel < channels) in dapm_update_dai_chan()
2687 int dir = substream->stream; in dapm_update_dai_unlocked()
2688 int channels = params_channels(params); in dapm_update_dai_unlocked() local
2698 dev_dbg(dai->dev, "Update DAI routes for %s %s\n", dai->name, in dapm_update_dai_unlocked()
2702 ret = dapm_update_dai_chan(p, p->sink, channels); in dapm_update_dai_unlocked()
2708 ret = dapm_update_dai_chan(p, p->source, channels); in dapm_update_dai_unlocked()
2723 snd_soc_dapm_mutex_lock(rtd->card); in snd_soc_dapm_update_dai()
2725 snd_soc_dapm_mutex_unlock(rtd->card); in snd_soc_dapm_update_dai()
2733 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); in snd_soc_dapm_widget_name_cmp()
2734 const char *wname = widget->name; in snd_soc_dapm_widget_name_cmp()
2736 if (component->name_prefix) in snd_soc_dapm_widget_name_cmp()
2737 wname += strlen(component->name_prefix) + 1; /* plus space */ in snd_soc_dapm_widget_name_cmp()
2744 * dapm_update_widget_flags() - Re-compute widget sink and source flags
2758 switch (w->id) { in dapm_update_widget_flags()
2761 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2765 if (p->source->id == snd_soc_dapm_micbias || in dapm_update_widget_flags()
2766 p->source->id == snd_soc_dapm_mic || in dapm_update_widget_flags()
2767 p->source->id == snd_soc_dapm_line || in dapm_update_widget_flags()
2768 p->source->id == snd_soc_dapm_output) { in dapm_update_widget_flags()
2776 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2780 if (p->sink->id == snd_soc_dapm_spk || in dapm_update_widget_flags()
2781 p->sink->id == snd_soc_dapm_hp || in dapm_update_widget_flags()
2782 p->sink->id == snd_soc_dapm_line || in dapm_update_widget_flags()
2783 p->sink->id == snd_soc_dapm_input) { in dapm_update_widget_flags()
2792 if (!list_empty(&w->edges[dir])) in dapm_update_widget_flags()
2800 w->is_ep = ep; in dapm_update_widget_flags()
2813 switch (source->id) { in snd_soc_dapm_check_dynamic_path()
2821 switch (sink->id) { in snd_soc_dapm_check_dynamic_path()
2833 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2834 "Direct connection between demux and mixer/mux not supported for path %s -> [%s] -> %s\n", in snd_soc_dapm_check_dynamic_path()
2835 source->name, control, sink->name); in snd_soc_dapm_check_dynamic_path()
2836 return -EINVAL; in snd_soc_dapm_check_dynamic_path()
2838 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2839 "Control not supported for path %s -> [%s] -> %s\n", in snd_soc_dapm_check_dynamic_path()
2840 source->name, control, sink->name); in snd_soc_dapm_check_dynamic_path()
2841 return -EINVAL; in snd_soc_dapm_check_dynamic_path()
2857 if (wsink->is_supply && !wsource->is_supply) { in snd_soc_dapm_add_path()
2858 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2859 "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n", in snd_soc_dapm_add_path()
2860 wsource->name, wsink->name); in snd_soc_dapm_add_path()
2861 return -EINVAL; in snd_soc_dapm_add_path()
2864 if (connected && !wsource->is_supply) { in snd_soc_dapm_add_path()
2865 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2866 "connected() callback only supported for supply widgets (%s -> %s)\n", in snd_soc_dapm_add_path()
2867 wsource->name, wsink->name); in snd_soc_dapm_add_path()
2868 return -EINVAL; in snd_soc_dapm_add_path()
2871 if (wsource->is_supply && control) { in snd_soc_dapm_add_path()
2872 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2873 "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n", in snd_soc_dapm_add_path()
2874 wsource->name, control, wsink->name); in snd_soc_dapm_add_path()
2875 return -EINVAL; in snd_soc_dapm_add_path()
2884 return -ENOMEM; in snd_soc_dapm_add_path()
2886 path->node[SND_SOC_DAPM_DIR_IN] = wsource; in snd_soc_dapm_add_path()
2887 path->node[SND_SOC_DAPM_DIR_OUT] = wsink; in snd_soc_dapm_add_path()
2889 path->connected = connected; in snd_soc_dapm_add_path()
2890 INIT_LIST_HEAD(&path->list); in snd_soc_dapm_add_path()
2891 INIT_LIST_HEAD(&path->list_kcontrol); in snd_soc_dapm_add_path()
2893 if (wsource->is_supply || wsink->is_supply) in snd_soc_dapm_add_path()
2894 path->is_supply = 1; in snd_soc_dapm_add_path()
2898 path->connect = 1; in snd_soc_dapm_add_path()
2900 switch (wsource->id) { in snd_soc_dapm_add_path()
2910 switch (wsink->id) { in snd_soc_dapm_add_path()
2928 list_add(&path->list, &dapm->card->paths); in snd_soc_dapm_add_path()
2931 list_add(&path->list_node[dir], &path->node[dir]->edges[dir]); in snd_soc_dapm_add_path()
2934 dapm_update_widget_flags(path->node[dir]); in snd_soc_dapm_add_path()
2935 dapm_mark_dirty(path->node[dir], "Route added"); in snd_soc_dapm_add_path()
2938 if (snd_soc_card_is_instantiated(dapm->card) && path->connect) in snd_soc_dapm_add_path()
2964 prefix, route->sink); in snd_soc_dapm_add_route()
2967 prefix, route->source); in snd_soc_dapm_add_route()
2970 sink = route->sink; in snd_soc_dapm_add_route()
2971 source = route->source; in snd_soc_dapm_add_route()
2974 wsource = dapm_wcache_lookup(dapm->wcache_source, source); in snd_soc_dapm_add_route()
2975 wsink = dapm_wcache_lookup(dapm->wcache_sink, sink); in snd_soc_dapm_add_route()
2982 * current DAPM context in snd_soc_dapm_add_route()
2984 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
2985 if (!wsink && !(strcmp(w->name, sink))) { in snd_soc_dapm_add_route()
2987 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2994 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
2996 w->name); in snd_soc_dapm_add_route()
2999 if (!wsource && !(strcmp(w->name, source))) { in snd_soc_dapm_add_route()
3001 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3008 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3010 w->name); in snd_soc_dapm_add_route()
3019 ret = -ENODEV; in snd_soc_dapm_add_route()
3027 dapm->wcache_sink = wsink; in snd_soc_dapm_add_route()
3028 dapm->wcache_source = wsource; in snd_soc_dapm_add_route()
3030 ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, in snd_soc_dapm_add_route()
3031 route->connected); in snd_soc_dapm_add_route()
3034 dev_err(dapm->dev, "ASoC: Failed to add route %s%s -%s%s%s> %s%s\n", in snd_soc_dapm_add_route()
3036 !route->control ? "" : "> [", in snd_soc_dapm_add_route()
3037 !route->control ? "" : route->control, in snd_soc_dapm_add_route()
3038 !route->control ? "" : "] -", in snd_soc_dapm_add_route()
3053 if (route->control) { in snd_soc_dapm_del_route()
3054 dev_err(dapm->dev, in snd_soc_dapm_del_route()
3056 return -EINVAL; in snd_soc_dapm_del_route()
3062 prefix, route->sink); in snd_soc_dapm_del_route()
3065 prefix, route->source); in snd_soc_dapm_del_route()
3068 sink = route->sink; in snd_soc_dapm_del_route()
3069 source = route->source; in snd_soc_dapm_del_route()
3073 list_for_each_entry(p, &dapm->card->paths, list) { in snd_soc_dapm_del_route()
3074 if (strcmp(p->source->name, source) != 0) in snd_soc_dapm_del_route()
3076 if (strcmp(p->sink->name, sink) != 0) in snd_soc_dapm_del_route()
3083 struct snd_soc_dapm_widget *wsource = path->source; in snd_soc_dapm_del_route()
3084 struct snd_soc_dapm_widget *wsink = path->sink; in snd_soc_dapm_del_route()
3088 if (path->connect) in snd_soc_dapm_del_route()
3097 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", in snd_soc_dapm_del_route()
3105 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
3136 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
3163 route->source, in snd_soc_dapm_weak_route()
3166 route->sink, in snd_soc_dapm_weak_route()
3172 dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n", in snd_soc_dapm_weak_route()
3173 route->source); in snd_soc_dapm_weak_route()
3174 return -ENODEV; in snd_soc_dapm_weak_route()
3178 dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n", in snd_soc_dapm_weak_route()
3179 route->sink); in snd_soc_dapm_weak_route()
3180 return -ENODEV; in snd_soc_dapm_weak_route()
3183 if (route->control || route->connected) in snd_soc_dapm_weak_route()
3184 dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3185 route->source, route->sink); in snd_soc_dapm_weak_route()
3188 if (path->sink == sink) { in snd_soc_dapm_weak_route()
3189 path->weak = 1; in snd_soc_dapm_weak_route()
3195 dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3196 route->source, route->sink); in snd_soc_dapm_weak_route()
3198 dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3199 count, route->source, route->sink); in snd_soc_dapm_weak_route()
3205 * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
3240 * snd_soc_dapm_new_widgets - add new dapm widgets
3256 if (w->new) in snd_soc_dapm_new_widgets()
3259 if (w->num_kcontrols) { in snd_soc_dapm_new_widgets()
3260 w->kcontrols = kcalloc(w->num_kcontrols, in snd_soc_dapm_new_widgets()
3263 if (!w->kcontrols) { in snd_soc_dapm_new_widgets()
3265 return -ENOMEM; in snd_soc_dapm_new_widgets()
3269 switch(w->id) { in snd_soc_dapm_new_widgets()
3292 if (w->reg >= 0) { in snd_soc_dapm_new_widgets()
3293 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3294 val = val >> w->shift; in snd_soc_dapm_new_widgets()
3295 val &= w->mask; in snd_soc_dapm_new_widgets()
3296 if (val == w->on_val) in snd_soc_dapm_new_widgets()
3297 w->power = 1; in snd_soc_dapm_new_widgets()
3300 w->new = 1; in snd_soc_dapm_new_widgets()
3313 * snd_soc_dapm_get_volsw - dapm mixer get callback
3326 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_get_volsw()
3327 int reg = mc->reg; in snd_soc_dapm_get_volsw()
3328 unsigned int shift = mc->shift; in snd_soc_dapm_get_volsw()
3329 int max = mc->max; in snd_soc_dapm_get_volsw()
3331 unsigned int mask = (1 << fls(max)) - 1; in snd_soc_dapm_get_volsw()
3332 unsigned int invert = mc->invert; in snd_soc_dapm_get_volsw()
3340 if (reg != mc->rreg) in snd_soc_dapm_get_volsw()
3341 reg_val = soc_dapm_read(dapm, mc->rreg); in snd_soc_dapm_get_volsw()
3344 rval = (reg_val >> mc->rshift) & mask; in snd_soc_dapm_get_volsw()
3355 ucontrol->value.integer.value[0] = max - val; in snd_soc_dapm_get_volsw()
3357 ucontrol->value.integer.value[0] = val; in snd_soc_dapm_get_volsw()
3361 ucontrol->value.integer.value[1] = max - rval; in snd_soc_dapm_get_volsw()
3363 ucontrol->value.integer.value[1] = rval; in snd_soc_dapm_get_volsw()
3371 * snd_soc_dapm_put_volsw - dapm mixer set callback
3383 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_volsw()
3385 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_put_volsw()
3386 int reg = mc->reg; in snd_soc_dapm_put_volsw()
3387 unsigned int shift = mc->shift; in snd_soc_dapm_put_volsw()
3388 int max = mc->max; in snd_soc_dapm_put_volsw()
3390 unsigned int mask = (1 << width) - 1; in snd_soc_dapm_put_volsw()
3391 unsigned int invert = mc->invert; in snd_soc_dapm_put_volsw()
3393 int connect, rconnect = -1, change, reg_change = 0; in snd_soc_dapm_put_volsw()
3397 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_dapm_put_volsw()
3401 val = max - val; in snd_soc_dapm_put_volsw()
3404 rval = (ucontrol->value.integer.value[1] & mask); in snd_soc_dapm_put_volsw()
3407 rval = max - rval; in snd_soc_dapm_put_volsw()
3414 dev_warn(dapm->dev, in snd_soc_dapm_put_volsw()
3416 kcontrol->id.name); in snd_soc_dapm_put_volsw()
3421 rval = rval << mc->rshift; in snd_soc_dapm_put_volsw()
3426 reg_change |= soc_dapm_test_bits(dapm, mc->rreg, in snd_soc_dapm_put_volsw()
3427 mask << mc->rshift, in snd_soc_dapm_put_volsw()
3435 update.reg2 = mc->rreg; in snd_soc_dapm_put_volsw()
3436 update.mask2 = mask << mc->rshift; in snd_soc_dapm_put_volsw()
3443 card->update = &update; in snd_soc_dapm_put_volsw()
3449 card->update = NULL; in snd_soc_dapm_put_volsw()
3462 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
3474 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in snd_soc_dapm_get_enum_double()
3478 if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { in snd_soc_dapm_get_enum_double()
3479 reg_val = soc_dapm_read(dapm, e->reg); in snd_soc_dapm_get_enum_double()
3485 val = (reg_val >> e->shift_l) & e->mask; in snd_soc_dapm_get_enum_double()
3486 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); in snd_soc_dapm_get_enum_double()
3487 if (e->shift_l != e->shift_r) { in snd_soc_dapm_get_enum_double()
3488 val = (reg_val >> e->shift_r) & e->mask; in snd_soc_dapm_get_enum_double()
3490 ucontrol->value.enumerated.item[1] = val; in snd_soc_dapm_get_enum_double()
3498 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3510 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_enum_double()
3511 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in snd_soc_dapm_put_enum_double()
3512 unsigned int *item = ucontrol->value.enumerated.item; in snd_soc_dapm_put_enum_double()
3518 if (item[0] >= e->items) in snd_soc_dapm_put_enum_double()
3519 return -EINVAL; in snd_soc_dapm_put_enum_double()
3521 val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; in snd_soc_dapm_put_enum_double()
3522 mask = e->mask << e->shift_l; in snd_soc_dapm_put_enum_double()
3523 if (e->shift_l != e->shift_r) { in snd_soc_dapm_put_enum_double()
3524 if (item[1] > e->items) in snd_soc_dapm_put_enum_double()
3525 return -EINVAL; in snd_soc_dapm_put_enum_double()
3526 val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_r; in snd_soc_dapm_put_enum_double()
3527 mask |= e->mask << e->shift_r; in snd_soc_dapm_put_enum_double()
3534 if (e->reg != SND_SOC_NOPM) in snd_soc_dapm_put_enum_double()
3535 reg_change = soc_dapm_test_bits(dapm, e->reg, mask, val); in snd_soc_dapm_put_enum_double()
3540 update.reg = e->reg; in snd_soc_dapm_put_enum_double()
3543 card->update = &update; in snd_soc_dapm_put_enum_double()
3548 card->update = NULL; in snd_soc_dapm_put_enum_double()
3561 * snd_soc_dapm_info_pin_switch - Info for a pin switch
3571 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_soc_dapm_info_pin_switch()
3572 uinfo->count = 1; in snd_soc_dapm_info_pin_switch()
3573 uinfo->value.integer.min = 0; in snd_soc_dapm_info_pin_switch()
3574 uinfo->value.integer.max = 1; in snd_soc_dapm_info_pin_switch()
3581 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
3590 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_get_pin_switch()
3594 ucontrol->value.integer.value[0] = in snd_soc_dapm_get_pin_switch()
3595 snd_soc_dapm_get_pin_status(&card->dapm, pin); in snd_soc_dapm_get_pin_switch()
3604 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
3613 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_put_pin_switch()
3617 ret = __snd_soc_dapm_set_pin(&card->dapm, pin, in snd_soc_dapm_put_pin_switch()
3618 !!ucontrol->value.integer.value[0]); in snd_soc_dapm_put_pin_switch()
3621 snd_soc_dapm_sync(&card->dapm); in snd_soc_dapm_put_pin_switch()
3633 int ret = -ENOMEM; in snd_soc_dapm_new_control_unlocked()
3640 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name); in snd_soc_dapm_new_control_unlocked()
3642 w->name = kstrdup_const(widget->name, GFP_KERNEL); in snd_soc_dapm_new_control_unlocked()
3643 if (!w->name) in snd_soc_dapm_new_control_unlocked()
3646 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3648 w->regulator = devm_regulator_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3649 if (IS_ERR(w->regulator)) { in snd_soc_dapm_new_control_unlocked()
3650 ret = PTR_ERR(w->regulator); in snd_soc_dapm_new_control_unlocked()
3654 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_new_control_unlocked()
3655 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_new_control_unlocked()
3657 dev_warn(dapm->dev, in snd_soc_dapm_new_control_unlocked()
3659 w->name, ret); in snd_soc_dapm_new_control_unlocked()
3663 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3664 if (IS_ERR(w->pinctrl)) { in snd_soc_dapm_new_control_unlocked()
3665 ret = PTR_ERR(w->pinctrl); in snd_soc_dapm_new_control_unlocked()
3673 w->clk = devm_clk_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3674 if (IS_ERR(w->clk)) { in snd_soc_dapm_new_control_unlocked()
3675 ret = PTR_ERR(w->clk); in snd_soc_dapm_new_control_unlocked()
3683 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3685 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3686 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3689 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3690 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3691 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3695 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3696 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3699 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3700 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3701 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3705 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3706 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3709 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3710 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3736 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3743 w->is_supply = 1; in snd_soc_dapm_new_control_unlocked()
3744 w->power_check = dapm_supply_check_power; in snd_soc_dapm_new_control_unlocked()
3747 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3751 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3752 INIT_LIST_HEAD(&w->list); in snd_soc_dapm_new_control_unlocked()
3753 INIT_LIST_HEAD(&w->dirty); in snd_soc_dapm_new_control_unlocked()
3755 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3758 INIT_LIST_HEAD(&w->edges[dir]); in snd_soc_dapm_new_control_unlocked()
3759 w->endpoints[dir] = -1; in snd_soc_dapm_new_control_unlocked()
3763 w->connected = 1; in snd_soc_dapm_new_control_unlocked()
3767 dev_err_probe(dapm->dev, ret, "ASoC: Failed to request %s\n", in snd_soc_dapm_new_control_unlocked()
3768 w->name); in snd_soc_dapm_new_control_unlocked()
3769 kfree_const(w->name); in snd_soc_dapm_new_control_unlocked()
3771 kfree_const(w->sname); in snd_soc_dapm_new_control_unlocked()
3778 * snd_soc_dapm_new_control - create new dapm control
3801 * snd_soc_dapm_new_controls - create new dapm controls
3855 return -ENOMEM; in snd_soc_dai_link_event_pre_pmu()
3859 ret = -ENOMEM; in snd_soc_dai_link_event_pre_pmu()
3863 substream->runtime = runtime; in snd_soc_dai_link_event_pre_pmu()
3865 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event_pre_pmu()
3867 source = path->source->priv; in snd_soc_dai_link_event_pre_pmu()
3873 snd_soc_dai_activate(source, substream->stream); in snd_soc_dai_link_event_pre_pmu()
3876 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event_pre_pmu()
3878 sink = path->sink->priv; in snd_soc_dai_link_event_pre_pmu()
3884 snd_soc_dai_activate(sink, substream->stream); in snd_soc_dai_link_event_pre_pmu()
3887 substream->hw_opened = 1; in snd_soc_dai_link_event_pre_pmu()
3894 config = rtd->dai_link->c2c_params + rtd->c2c_params_select; in snd_soc_dai_link_event_pre_pmu()
3896 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3897 ret = -EINVAL; in snd_soc_dai_link_event_pre_pmu()
3902 if (!config->formats) { in snd_soc_dai_link_event_pre_pmu()
3903 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
3905 ret = -EINVAL; in snd_soc_dai_link_event_pre_pmu()
3909 fmt = ffs(config->formats) - 1; in snd_soc_dai_link_event_pre_pmu()
3912 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min = in snd_soc_dai_link_event_pre_pmu()
3913 config->rate_min; in snd_soc_dai_link_event_pre_pmu()
3914 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max = in snd_soc_dai_link_event_pre_pmu()
3915 config->rate_max; in snd_soc_dai_link_event_pre_pmu()
3916 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min in snd_soc_dai_link_event_pre_pmu()
3917 = config->channels_min; in snd_soc_dai_link_event_pre_pmu()
3918 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max in snd_soc_dai_link_event_pre_pmu()
3919 = config->channels_max; in snd_soc_dai_link_event_pre_pmu()
3921 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event_pre_pmu()
3923 source = path->source->priv; in snd_soc_dai_link_event_pre_pmu()
3932 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event_pre_pmu()
3934 sink = path->sink->priv; in snd_soc_dai_link_event_pre_pmu()
3943 runtime->format = params_format(params); in snd_soc_dai_link_event_pre_pmu()
3944 runtime->subformat = params_subformat(params); in snd_soc_dai_link_event_pre_pmu()
3945 runtime->channels = params_channels(params); in snd_soc_dai_link_event_pre_pmu()
3946 runtime->rate = params_rate(params); in snd_soc_dai_link_event_pre_pmu()
3960 struct snd_pcm_substream *substream = w->priv; in snd_soc_dai_link_event()
3961 int ret = 0, saved_stream = substream->stream; in snd_soc_dai_link_event()
3963 if (WARN_ON(list_empty(&w->edges[SND_SOC_DAPM_DIR_OUT]) || in snd_soc_dai_link_event()
3964 list_empty(&w->edges[SND_SOC_DAPM_DIR_IN]))) in snd_soc_dai_link_event()
3965 return -EINVAL; in snd_soc_dai_link_event()
3977 sink = path->sink->priv; in snd_soc_dai_link_event()
3986 sink = path->sink->priv; in snd_soc_dai_link_event()
3992 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event()
3994 source = path->source->priv; in snd_soc_dai_link_event()
3998 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event()
4000 sink = path->sink->priv; in snd_soc_dai_link_event()
4004 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event()
4006 source = path->source->priv; in snd_soc_dai_link_event()
4007 snd_soc_dai_deactivate(source, substream->stream); in snd_soc_dai_link_event()
4011 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event()
4013 sink = path->sink->priv; in snd_soc_dai_link_event()
4014 snd_soc_dai_deactivate(sink, substream->stream); in snd_soc_dai_link_event()
4020 kfree(substream->runtime); in snd_soc_dai_link_event()
4021 substream->runtime = NULL; in snd_soc_dai_link_event()
4026 ret = -EINVAL; in snd_soc_dai_link_event()
4031 substream->stream = saved_stream; in snd_soc_dai_link_event()
4039 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get()
4041 ucontrol->value.enumerated.item[0] = rtd->c2c_params_select; in snd_soc_dapm_dai_link_get()
4050 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_put()
4053 if (w->power) in snd_soc_dapm_dai_link_put()
4054 return -EBUSY; in snd_soc_dapm_dai_link_put()
4056 if (ucontrol->value.enumerated.item[0] == rtd->c2c_params_select) in snd_soc_dapm_dai_link_put()
4059 if (ucontrol->value.enumerated.item[0] >= rtd->dai_link->num_c2c_params) in snd_soc_dapm_dai_link_put()
4060 return -EINVAL; in snd_soc_dapm_dai_link_put()
4062 rtd->c2c_params_select = ucontrol->value.enumerated.item[0]; in snd_soc_dapm_dai_link_put()
4075 devm_kfree(card->dev, (void *)*private_value); in snd_soc_dapm_free_kcontrol()
4081 devm_kfree(card->dev, (void *)w_param_text[count]); in snd_soc_dapm_free_kcontrol()
4082 devm_kfree(card->dev, w_param_text); in snd_soc_dapm_free_kcontrol()
4105 if (!config->stream_name) { in snd_soc_dapm_alloc_kcontrol()
4106 dev_warn(card->dapm.dev, in snd_soc_dapm_alloc_kcontrol()
4110 devm_kasprintf(card->dev, GFP_KERNEL, in snd_soc_dapm_alloc_kcontrol()
4114 w_param_text[count] = devm_kmemdup(card->dev, in snd_soc_dapm_alloc_kcontrol()
4115 config->stream_name, in snd_soc_dapm_alloc_kcontrol()
4116 strlen(config->stream_name) + 1, in snd_soc_dapm_alloc_kcontrol()
4128 (unsigned long) devm_kmemdup(card->dev, in snd_soc_dapm_alloc_kcontrol()
4132 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", in snd_soc_dapm_alloc_kcontrol()
4138 kcontrol_news = devm_kmemdup(card->dev, &kcontrol_dai_link[0], in snd_soc_dapm_alloc_kcontrol()
4142 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", in snd_soc_dapm_alloc_kcontrol()
4166 int ret = -ENOMEM; in snd_soc_dapm_new_dai()
4168 link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s", in snd_soc_dapm_new_dai()
4169 rtd->dai_link->name, id); in snd_soc_dapm_new_dai()
4177 if (rtd->dai_link->num_c2c_params > 1) { in snd_soc_dapm_new_dai()
4178 w_param_text = devm_kcalloc(card->dev, in snd_soc_dapm_new_dai()
4179 rtd->dai_link->num_c2c_params, in snd_soc_dapm_new_dai()
4186 rtd->dai_link->c2c_params, in snd_soc_dapm_new_dai()
4187 rtd->dai_link->num_c2c_params, in snd_soc_dapm_new_dai()
4203 dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name); in snd_soc_dapm_new_dai()
4205 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4211 w->priv = substream; in snd_soc_dapm_new_dai()
4216 devm_kfree(card->dev, (void *)template.kcontrol_news); in snd_soc_dapm_new_dai()
4218 rtd->dai_link->num_c2c_params, w_param_text); in snd_soc_dapm_new_dai()
4220 devm_kfree(card->dev, link_name); in snd_soc_dapm_new_dai()
4222 dev_err(rtd->dev, "ASoC: Failed to create %s-%s widget: %d\n", in snd_soc_dapm_new_dai()
4223 rtd->dai_link->name, id, ret); in snd_soc_dapm_new_dai()
4228 * snd_soc_dapm_new_dai_widgets - Create new DAPM widgets
4240 WARN_ON(dapm->dev != dai->dev); in snd_soc_dapm_new_dai_widgets()
4245 if (dai->driver->playback.stream_name) { in snd_soc_dapm_new_dai_widgets()
4247 template.name = dai->driver->playback.stream_name; in snd_soc_dapm_new_dai_widgets()
4248 template.sname = dai->driver->playback.stream_name; in snd_soc_dapm_new_dai_widgets()
4250 dev_dbg(dai->dev, "ASoC: adding %s widget\n", in snd_soc_dapm_new_dai_widgets()
4257 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4261 if (dai->driver->capture.stream_name) { in snd_soc_dapm_new_dai_widgets()
4263 template.name = dai->driver->capture.stream_name; in snd_soc_dapm_new_dai_widgets()
4264 template.sname = dai->driver->capture.stream_name; in snd_soc_dapm_new_dai_widgets()
4266 dev_dbg(dai->dev, "ASoC: adding %s widget\n", in snd_soc_dapm_new_dai_widgets()
4273 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4289 switch (dai_w->id) { in snd_soc_dapm_link_dai_widgets()
4298 if (!dai_w->priv) { in snd_soc_dapm_link_dai_widgets()
4299 dev_dbg(card->dev, "dai widget %s has no DAI\n", in snd_soc_dapm_link_dai_widgets()
4300 dai_w->name); in snd_soc_dapm_link_dai_widgets()
4304 dai = dai_w->priv; in snd_soc_dapm_link_dai_widgets()
4308 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4311 switch (w->id) { in snd_soc_dapm_link_dai_widgets()
4319 if (!w->sname || !strstr(w->sname, dai_w->sname)) in snd_soc_dapm_link_dai_widgets()
4322 if (dai_w->id == snd_soc_dapm_dai_in) { in snd_soc_dapm_link_dai_widgets()
4329 dev_dbg(dai->dev, "%s -> %s\n", src->name, sink->name); in snd_soc_dapm_link_dai_widgets()
4330 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4344 dev_dbg(dapm->dev, "connected DAI link %s:%s -> %s:%s\n", in dapm_connect_dai_routes()
4345 src_dai->component->name, src->name, in dapm_connect_dai_routes()
4346 sink_dai->component->name, sink->name); in dapm_connect_dai_routes()
4361 struct snd_soc_dai_link *dai_link = rtd->dai_link; in dapm_connect_dai_pair()
4384 if (dai_link->c2c_params && !rtd->c2c_widget[stream]) { in dapm_connect_dai_pair()
4385 struct snd_pcm_substream *substream = rtd->pcm->streams[stream].substream; in dapm_connect_dai_pair()
4392 rtd->c2c_widget[stream] = dai; in dapm_connect_dai_pair()
4395 dapm_connect_dai_routes(&card->dapm, src_dai[stream], *src[stream], in dapm_connect_dai_pair()
4396 rtd->c2c_widget[stream], in dapm_connect_dai_pair()
4413 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4423 w->active = 1; in soc_dapm_dai_stream_event()
4424 w->is_ep = ep; in soc_dapm_dai_stream_event()
4427 w->active = 0; in soc_dapm_dai_stream_event()
4428 w->is_ep = 0; in soc_dapm_dai_stream_event()
4449 * CODEC<->CODEC links have no direct connection. in snd_soc_dapm_connect_dai_link_widgets()
4451 if (rtd->dai_link->dynamic) in snd_soc_dapm_connect_dai_link_widgets()
4454 if (rtd->dai_link->num_cpus == 1) { in snd_soc_dapm_connect_dai_link_widgets()
4458 } else if (rtd->dai_link->num_codecs == rtd->dai_link->num_cpus) { in snd_soc_dapm_connect_dai_link_widgets()
4462 } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) { in snd_soc_dapm_connect_dai_link_widgets()
4465 if (!rtd->dai_link->codec_ch_maps) { in snd_soc_dapm_connect_dai_link_widgets()
4466 dev_err(card->dev, "%s: no codec channel mapping table provided\n", in snd_soc_dapm_connect_dai_link_widgets()
4472 cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; in snd_soc_dapm_connect_dai_link_widgets()
4473 if (cpu_id >= rtd->dai_link->num_cpus) { in snd_soc_dapm_connect_dai_link_widgets()
4474 dev_err(card->dev, in snd_soc_dapm_connect_dai_link_widgets()
4476 __func__, rtd->dai_link->name, cpu_id, in snd_soc_dapm_connect_dai_link_widgets()
4477 rtd->dai_link->num_cpus); in snd_soc_dapm_connect_dai_link_widgets()
4484 dev_err(card->dev, in snd_soc_dapm_connect_dai_link_widgets()
4486 __func__, rtd->dai_link->num_codecs, rtd->dai_link->num_cpus); in snd_soc_dapm_connect_dai_link_widgets()
4500 dapm_power_widgets(rtd->card, event); in soc_dapm_stream_event()
4504 * snd_soc_dapm_stream_event - send a stream event to the dapm core
4517 struct snd_soc_card *card = rtd->card; in snd_soc_dapm_stream_event()
4534 rtd->pop_wait = 1; in snd_soc_dapm_stream_stop()
4536 &rtd->delayed_work, in snd_soc_dapm_stream_stop()
4537 msecs_to_jiffies(rtd->pmdown_time)); in snd_soc_dapm_stream_stop()
4548 * snd_soc_dapm_enable_pin_unlocked - enable pin.
4568 * snd_soc_dapm_enable_pin - enable pin.
4593 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
4612 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4613 return -EINVAL; in snd_soc_dapm_force_enable_pin_unlocked()
4616 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4617 if (!w->connected) { in snd_soc_dapm_force_enable_pin_unlocked()
4619 * w->force does not affect the number of input or output paths, in snd_soc_dapm_force_enable_pin_unlocked()
4620 * so we only have to recheck if w->connected is changed in snd_soc_dapm_force_enable_pin_unlocked()
4624 w->connected = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4626 w->force = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4634 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
4661 * snd_soc_dapm_disable_pin_unlocked - disable pin.
4680 * snd_soc_dapm_disable_pin - disable pin.
4705 * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
4728 * snd_soc_dapm_nc_pin - permanently disable pin.
4756 * snd_soc_dapm_get_pin_status - get audio pin status
4760 * Get audio pin status - connected or disconnected.
4770 return w->connected; in snd_soc_dapm_get_pin_status()
4777 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
4793 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_ignore_suspend()
4794 return -EINVAL; in snd_soc_dapm_ignore_suspend()
4797 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4804 * snd_soc_dapm_free - free dapm resources
4813 list_del(&dapm->list); in snd_soc_dapm_free()
4821 dapm->card = card; in snd_soc_dapm_init()
4822 dapm->component = component; in snd_soc_dapm_init()
4823 dapm->bias_level = SND_SOC_BIAS_OFF; in snd_soc_dapm_init()
4826 dapm->dev = component->dev; in snd_soc_dapm_init()
4827 dapm->idle_bias_off = !component->driver->idle_bias_on; in snd_soc_dapm_init()
4828 dapm->suspend_bias_off = component->driver->suspend_bias_off; in snd_soc_dapm_init()
4830 dapm->dev = card->dev; in snd_soc_dapm_init()
4833 INIT_LIST_HEAD(&dapm->list); in snd_soc_dapm_init()
4835 list_add(&dapm->list, &card->dapm_list); in snd_soc_dapm_init()
4841 struct snd_soc_card *card = dapm->card; in soc_dapm_shutdown_dapm()
4848 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4849 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4851 if (w->power) { in soc_dapm_shutdown_dapm()
4853 w->new_power = 0; in soc_dapm_shutdown_dapm()
4862 if (dapm->bias_level == SND_SOC_BIAS_ON) in soc_dapm_shutdown_dapm()
4866 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) in soc_dapm_shutdown_dapm()
4875 * snd_soc_dapm_shutdown - callback for system shutdown
4882 if (dapm != &card->dapm) { in snd_soc_dapm_shutdown()
4884 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4890 soc_dapm_shutdown_dapm(&card->dapm); in snd_soc_dapm_shutdown()
4891 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4892 snd_soc_dapm_set_bias_level(&card->dapm, in snd_soc_dapm_shutdown()