Lines Matching +full:custom +full:- +full:rtd

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
43 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
68 /* dapm power sequences - make this per codec in the future */
153 if (snd_soc_card_is_instantiated(dapm->card)) in dapm_assert_locked()
186 return !list_empty(&w->dirty); in dapm_dirty_widget()
191 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
194 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
195 w->name, reason); in dapm_mark_dirty()
196 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
215 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_paths()
217 if (w->endpoints[dir] == -1) in dapm_widget_invalidate_paths()
220 list_add_tail(&w->work_list, &list); in dapm_widget_invalidate_paths()
221 w->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
225 if (p->is_supply || p->weak || !p->connect) in dapm_widget_invalidate_paths()
227 node = p->node[rdir]; in dapm_widget_invalidate_paths()
228 if (node->endpoints[dir] != -1) { in dapm_widget_invalidate_paths()
229 node->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
230 list_add_tail(&node->work_list, &list); in dapm_widget_invalidate_paths()
237 * dapm_widget_invalidate_input_paths() - Invalidate the cached number of
254 * dapm_widget_invalidate_output_paths() - Invalidate the cached number of
271 * dapm_path_invalidate() - Invalidates the cached number of inputs and outputs
287 if (p->weak || p->is_supply) in dapm_path_invalidate()
294 * so there is no need to re-check the path. in dapm_path_invalidate()
296 if (p->source->endpoints[SND_SOC_DAPM_DIR_IN] != 0) in dapm_path_invalidate()
297 dapm_widget_invalidate_input_paths(p->sink); in dapm_path_invalidate()
298 if (p->sink->endpoints[SND_SOC_DAPM_DIR_OUT] != 0) in dapm_path_invalidate()
299 dapm_widget_invalidate_output_paths(p->source); in dapm_path_invalidate()
309 if (w->is_ep) { in dapm_mark_endpoints_dirty()
311 if (w->is_ep & SND_SOC_DAPM_EP_SINK) in dapm_mark_endpoints_dirty()
313 if (w->is_ep & SND_SOC_DAPM_EP_SOURCE) in dapm_mark_endpoints_dirty()
334 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, _widget->name); in dapm_cnew_widget()
336 w->name = kstrdup_const(_widget->name, GFP_KERNEL); in dapm_cnew_widget()
337 if (!w->name) in dapm_cnew_widget()
340 if (_widget->sname) { in dapm_cnew_widget()
341 w->sname = kstrdup_const(_widget->sname, GFP_KERNEL); in dapm_cnew_widget()
342 if (!w->sname) { in dapm_cnew_widget()
343 kfree_const(w->name); in dapm_cnew_widget()
369 return -ENOMEM; in dapm_kcontrol_data_alloc()
371 INIT_LIST_HEAD(&data->paths); in dapm_kcontrol_data_alloc()
373 switch (widget->id) { in dapm_kcontrol_data_alloc()
377 mc = (struct soc_mixer_control *)kcontrol->private_value; in dapm_kcontrol_data_alloc()
379 if (mc->autodisable) { in dapm_kcontrol_data_alloc()
383 dev_warn(widget->dapm->dev, in dapm_kcontrol_data_alloc()
390 ret = -ENOMEM; in dapm_kcontrol_data_alloc()
395 template.reg = mc->reg; in dapm_kcontrol_data_alloc()
396 template.mask = (1 << fls(mc->max)) - 1; in dapm_kcontrol_data_alloc()
397 template.shift = mc->shift; in dapm_kcontrol_data_alloc()
398 if (mc->invert) in dapm_kcontrol_data_alloc()
399 template.off_val = mc->max; in dapm_kcontrol_data_alloc()
406 data->value = template.on_val; in dapm_kcontrol_data_alloc()
408 data->widget = in dapm_kcontrol_data_alloc()
409 snd_soc_dapm_new_control_unlocked(widget->dapm, in dapm_kcontrol_data_alloc()
412 if (IS_ERR(data->widget)) { in dapm_kcontrol_data_alloc()
413 ret = PTR_ERR(data->widget); in dapm_kcontrol_data_alloc()
420 e = (struct soc_enum *)kcontrol->private_value; in dapm_kcontrol_data_alloc()
422 if (e->autodisable) { in dapm_kcontrol_data_alloc()
428 ret = -ENOMEM; in dapm_kcontrol_data_alloc()
433 template.reg = e->reg; in dapm_kcontrol_data_alloc()
434 template.mask = e->mask; in dapm_kcontrol_data_alloc()
435 template.shift = e->shift_l; in dapm_kcontrol_data_alloc()
441 data->value = template.on_val; in dapm_kcontrol_data_alloc()
443 data->widget = snd_soc_dapm_new_control_unlocked( in dapm_kcontrol_data_alloc()
444 widget->dapm, &template); in dapm_kcontrol_data_alloc()
446 if (IS_ERR(data->widget)) { in dapm_kcontrol_data_alloc()
447 ret = PTR_ERR(data->widget); in dapm_kcontrol_data_alloc()
451 snd_soc_dapm_add_path(widget->dapm, data->widget, in dapm_kcontrol_data_alloc()
453 } else if (e->reg != SND_SOC_NOPM) { in dapm_kcontrol_data_alloc()
454 data->value = soc_dapm_read(widget->dapm, e->reg) & in dapm_kcontrol_data_alloc()
455 (e->mask << e->shift_l); in dapm_kcontrol_data_alloc()
462 kcontrol->private_data = data; in dapm_kcontrol_data_alloc()
475 list_del(&data->paths); in dapm_kcontrol_free()
476 kfree(data->wlist); in dapm_kcontrol_free()
485 return data->wlist; in dapm_kcontrol_get_wlist()
495 if (data->wlist) in dapm_kcontrol_add_widget()
496 n = data->wlist->num_widgets + 1; in dapm_kcontrol_add_widget()
500 new_wlist = krealloc(data->wlist, in dapm_kcontrol_add_widget()
504 return -ENOMEM; in dapm_kcontrol_add_widget()
506 new_wlist->num_widgets = n; in dapm_kcontrol_add_widget()
507 new_wlist->widgets[n - 1] = widget; in dapm_kcontrol_add_widget()
509 data->wlist = new_wlist; in dapm_kcontrol_add_widget()
519 list_add_tail(&path->list_kcontrol, &data->paths); in dapm_kcontrol_add_path()
526 if (!data->widget) in dapm_kcontrol_is_powered()
529 return data->widget->power; in dapm_kcontrol_is_powered()
537 return &data->paths; in dapm_kcontrol_get_path_list()
548 return data->value; in dapm_kcontrol_get_value()
557 if (data->value == value) in dapm_kcontrol_set_value()
560 if (data->widget) { in dapm_kcontrol_set_value()
561 switch (dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->id) { in dapm_kcontrol_set_value()
565 data->widget->on_val = value & data->widget->mask; in dapm_kcontrol_set_value()
569 data->widget->on_val = value >> data->widget->shift; in dapm_kcontrol_set_value()
572 data->widget->on_val = value; in dapm_kcontrol_set_value()
577 data->value = value; in dapm_kcontrol_set_value()
583 * snd_soc_dapm_kcontrol_widget() - Returns the widget associated to a
590 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]; in snd_soc_dapm_kcontrol_widget()
595 * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a
605 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm; in snd_soc_dapm_kcontrol_dapm()
615 memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); in dapm_reset()
618 w->new_power = w->power; in dapm_reset()
619 w->power_checked = false; in dapm_reset()
625 if (!dapm->component) in soc_dapm_prefix()
627 return dapm->component->name_prefix; in soc_dapm_prefix()
632 if (!dapm->component) in soc_dapm_read()
633 return -EIO; in soc_dapm_read()
634 return snd_soc_component_read(dapm->component, reg); in soc_dapm_read()
640 if (!dapm->component) in soc_dapm_update_bits()
641 return -EIO; in soc_dapm_update_bits()
642 return snd_soc_component_update_bits(dapm->component, reg, in soc_dapm_update_bits()
649 if (!dapm->component) in soc_dapm_test_bits()
650 return -EIO; in soc_dapm_test_bits()
651 return snd_soc_component_test_bits(dapm->component, reg, mask, value); in soc_dapm_test_bits()
656 if (dapm->component) in soc_dapm_async_complete()
657 snd_soc_component_async_complete(dapm->component); in soc_dapm_async_complete()
664 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
669 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
681 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
702 if (dapm->component) in snd_soc_dapm_force_bias_level()
703 ret = snd_soc_component_set_bias_level(dapm->component, level); in snd_soc_dapm_force_bias_level()
706 dapm->bias_level = level; in snd_soc_dapm_force_bias_level()
713 * snd_soc_dapm_set_bias_level - set the bias level for the system
724 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_set_bias_level()
733 if (!card || dapm != &card->dapm) in snd_soc_dapm_set_bias_level()
751 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
752 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in dapm_connect_mux()
756 if (e->reg != SND_SOC_NOPM) { in dapm_connect_mux()
758 val = soc_dapm_read(dapm, e->reg); in dapm_connect_mux()
759 val = (val >> e->shift_l) & e->mask; in dapm_connect_mux()
771 i = match_string(e->texts, e->items, control_name); in dapm_connect_mux()
773 return -ENODEV; in dapm_connect_mux()
775 path->name = e->texts[i]; in dapm_connect_mux()
776 path->connect = (i == item); in dapm_connect_mux()
786 p->sink->kcontrol_news[i].private_value; in dapm_set_mixer_path_status()
787 unsigned int reg = mc->reg; in dapm_set_mixer_path_status()
788 unsigned int invert = mc->invert; in dapm_set_mixer_path_status()
791 unsigned int shift = mc->shift; in dapm_set_mixer_path_status()
792 unsigned int max = mc->max; in dapm_set_mixer_path_status()
793 unsigned int mask = (1 << fls(max)) - 1; in dapm_set_mixer_path_status()
794 unsigned int val = soc_dapm_read(p->sink->dapm, reg); in dapm_set_mixer_path_status()
809 if (reg != mc->rreg) in dapm_set_mixer_path_status()
810 val = soc_dapm_read(p->sink->dapm, mc->rreg); in dapm_set_mixer_path_status()
811 val = (val >> mc->rshift) & mask; in dapm_set_mixer_path_status()
816 val = max - val; in dapm_set_mixer_path_status()
817 p->connect = !!val; in dapm_set_mixer_path_status()
825 p->connect = invert; in dapm_set_mixer_path_status()
836 for (i = 0; i < path->sink->num_kcontrols; i++) { in dapm_connect_mixer()
837 if (!strcmp(control_name, path->sink->kcontrol_news[i].name)) { in dapm_connect_mixer()
838 path->name = path->sink->kcontrol_news[i].name; in dapm_connect_mixer()
843 return -ENODEV; in dapm_connect_mixer()
856 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
857 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
859 for (i = 0; i < w->num_kcontrols; i++) { in dapm_is_shared_kcontrol()
860 if (&w->kcontrol_news[i] == kcontrol_new) { in dapm_is_shared_kcontrol()
861 if (w->kcontrols) in dapm_is_shared_kcontrol()
862 *kcontrol = w->kcontrols[i]; in dapm_is_shared_kcontrol()
878 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol()
879 struct snd_card *card = dapm->card->snd_card; in dapm_create_or_share_kcontrol()
895 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
903 switch (w->id) { in dapm_create_or_share_kcontrol()
922 return -EINVAL; in dapm_create_or_share_kcontrol()
925 if (w->no_wname_in_kcontrol_name) in dapm_create_or_share_kcontrol()
936 w->name + prefix_len, in dapm_create_or_share_kcontrol()
937 w->kcontrol_news[kci].name); in dapm_create_or_share_kcontrol()
939 return -ENOMEM; in dapm_create_or_share_kcontrol()
944 name = w->name + prefix_len; in dapm_create_or_share_kcontrol()
947 name = w->kcontrol_news[kci].name; in dapm_create_or_share_kcontrol()
950 kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name, in dapm_create_or_share_kcontrol()
953 ret = -ENOMEM; in dapm_create_or_share_kcontrol()
957 kcontrol->private_free = dapm_kcontrol_free; in dapm_create_or_share_kcontrol()
967 dev_err(dapm->dev, in dapm_create_or_share_kcontrol()
969 w->name, name, ret); in dapm_create_or_share_kcontrol()
976 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
992 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
996 if (path->name != (char *)w->kcontrol_news[i].name) in dapm_new_mixer()
999 if (!w->kcontrols[i]) { in dapm_new_mixer()
1005 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
1007 data = snd_kcontrol_chip(w->kcontrols[i]); in dapm_new_mixer()
1008 if (data->widget) in dapm_new_mixer()
1009 snd_soc_dapm_add_path(data->widget->dapm, in dapm_new_mixer()
1010 data->widget, in dapm_new_mixer()
1011 path->source, in dapm_new_mixer()
1022 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1028 switch (w->id) { in dapm_new_mux()
1038 return -EINVAL; in dapm_new_mux()
1041 if (w->num_kcontrols != 1) { in dapm_new_mux()
1042 dev_err(dapm->dev, in dapm_new_mux()
1044 w->name); in dapm_new_mux()
1045 return -EINVAL; in dapm_new_mux()
1048 if (list_empty(&w->edges[dir])) { in dapm_new_mux()
1049 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1050 return -EINVAL; in dapm_new_mux()
1058 if (path->name) in dapm_new_mux()
1059 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1070 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1083 struct snd_soc_pcm_runtime *rtd = w->priv; in dapm_new_dai_link() local
1086 if (rtd->dai_link->num_c2c_params <= 1) in dapm_new_dai_link()
1090 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_dai_link()
1091 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link()
1092 struct snd_card *card = dapm->card->snd_card; in dapm_new_dai_link()
1093 struct snd_kcontrol *kcontrol = snd_soc_cnew(&w->kcontrol_news[i], in dapm_new_dai_link()
1094 w, w->name, NULL); in dapm_new_dai_link()
1098 dev_err(dapm->dev, in dapm_new_dai_link()
1100 w->name, w->kcontrol_news[i].name, ret); in dapm_new_dai_link()
1103 kcontrol->private_data = w; in dapm_new_dai_link()
1104 w->kcontrols[i] = kcontrol; in dapm_new_dai_link()
1111 * the ALSA card - when we are suspending the ALSA state for the card
1116 int level = snd_power_get_state(widget->dapm->card->snd_card); in snd_soc_dapm_suspend_check()
1121 if (widget->ignore_suspend) in snd_soc_dapm_suspend_check()
1122 dev_dbg(widget->dapm->dev, "ASoC: %s ignoring suspend\n", in snd_soc_dapm_suspend_check()
1123 widget->name); in snd_soc_dapm_suspend_check()
1124 return widget->ignore_suspend; in snd_soc_dapm_suspend_check()
1148 return -ENOMEM; in dapm_widget_list_create()
1150 (*list)->num_widgets = size; in dapm_widget_list_create()
1153 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1155 (*list)->num_widgets = i; in dapm_widget_list_create()
1171 widget->endpoints[dir] = -1; in invalidate_paths_ep()
1174 if (path->weak || path->is_supply) in invalidate_paths_ep()
1177 if (path->walking) in invalidate_paths_ep()
1180 if (path->connect) { in invalidate_paths_ep()
1181 path->walking = 1; in invalidate_paths_ep()
1182 invalidate_paths_ep(path->node[dir], dir); in invalidate_paths_ep()
1183 path->walking = 0; in invalidate_paths_ep()
1207 if (widget->endpoints[dir] >= 0) in is_connected_ep()
1208 return widget->endpoints[dir]; in is_connected_ep()
1214 list_add_tail(&widget->work_list, list); in is_connected_ep()
1221 if ((widget->is_ep & SND_SOC_DAPM_DIR_TO_EP(dir)) && widget->connected) { in is_connected_ep()
1222 widget->endpoints[dir] = snd_soc_dapm_suspend_check(widget); in is_connected_ep()
1223 return widget->endpoints[dir]; in is_connected_ep()
1229 if (path->weak || path->is_supply) in is_connected_ep()
1232 if (path->walking) in is_connected_ep()
1237 if (path->connect) { in is_connected_ep()
1238 path->walking = 1; in is_connected_ep()
1239 con += fn(path->node[dir], list, custom_stop_condition); in is_connected_ep()
1240 path->walking = 0; in is_connected_ep()
1244 widget->endpoints[dir] = con; in is_connected_ep()
1286 * snd_soc_dapm_dai_get_connected_widgets - query audio path and it's widgets.
1291 * walk based on custom logic.
1309 struct snd_soc_card *card = dai->component->card; in snd_soc_dapm_dai_get_connected_widgets()
1355 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1358 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1359 ret = regulator_allow_bypass(w->regulator, false); in dapm_regulator_event()
1361 dev_warn(w->dapm->dev, in dapm_regulator_event()
1363 w->name, ret); in dapm_regulator_event()
1366 return regulator_enable(w->regulator); in dapm_regulator_event()
1368 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1369 ret = regulator_allow_bypass(w->regulator, true); in dapm_regulator_event()
1371 dev_warn(w->dapm->dev, in dapm_regulator_event()
1373 w->name, ret); in dapm_regulator_event()
1376 return regulator_disable_deferred(w->regulator, w->shift); in dapm_regulator_event()
1387 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in dapm_pinctrl_event()
1388 struct pinctrl *p = w->pinctrl; in dapm_pinctrl_event()
1392 return -EIO; in dapm_pinctrl_event()
1395 s = pinctrl_lookup_state(p, priv->active_state); in dapm_pinctrl_event()
1397 s = pinctrl_lookup_state(p, priv->sleep_state); in dapm_pinctrl_event()
1412 if (!w->clk) in dapm_clock_event()
1413 return -EIO; in dapm_clock_event()
1415 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1418 return clk_prepare_enable(w->clk); in dapm_clock_event()
1420 clk_disable_unprepare(w->clk); in dapm_clock_event()
1430 if (w->power_checked) in dapm_widget_power_check()
1431 return w->new_power; in dapm_widget_power_check()
1433 if (w->force) in dapm_widget_power_check()
1434 w->new_power = 1; in dapm_widget_power_check()
1436 w->new_power = w->power_check(w); in dapm_widget_power_check()
1438 w->power_checked = true; in dapm_widget_power_check()
1440 return w->new_power; in dapm_widget_power_check()
1466 if (path->weak) in dapm_supply_check_power()
1469 if (path->connected && in dapm_supply_check_power()
1470 !path->connected(path->source, path->sink)) in dapm_supply_check_power()
1473 if (dapm_widget_power_check(path->sink)) in dapm_supply_check_power()
1482 return w->connected; in dapm_always_on_check_power()
1499 WARN_ONCE(sort[a->id] == 0, "offset a->id %d not initialized\n", a->id); in dapm_seq_compare()
1500 WARN_ONCE(sort[b->id] == 0, "offset b->id %d not initialized\n", b->id); in dapm_seq_compare()
1502 if (sort[a->id] != sort[b->id]) in dapm_seq_compare()
1503 return sort[a->id] - sort[b->id]; in dapm_seq_compare()
1504 if (a->subseq != b->subseq) { in dapm_seq_compare()
1506 return a->subseq - b->subseq; in dapm_seq_compare()
1508 return b->subseq - a->subseq; in dapm_seq_compare()
1510 if (a->reg != b->reg) in dapm_seq_compare()
1511 return a->reg - b->reg; in dapm_seq_compare()
1512 if (a->dapm != b->dapm) in dapm_seq_compare()
1513 return (unsigned long)a->dapm - (unsigned long)b->dapm; in dapm_seq_compare()
1527 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1531 list_add_tail(&new_widget->power_list, list); in dapm_seq_insert()
1570 if (w->new_power != power) in dapm_seq_check_event()
1573 if (w->event && (w->event_flags & event)) { in dapm_seq_check_event()
1576 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1577 w->name, ev_name); in dapm_seq_check_event()
1578 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1580 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1583 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1584 ev_name, w->name, ret); in dapm_seq_check_event()
1599 reg = w->reg; in dapm_seq_run_coalesced()
1600 dapm = w->dapm; in dapm_seq_run_coalesced()
1603 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1604 w->power = w->new_power; in dapm_seq_run_coalesced()
1606 mask |= w->mask << w->shift; in dapm_seq_run_coalesced()
1607 if (w->power) in dapm_seq_run_coalesced()
1608 value |= w->on_val << w->shift; in dapm_seq_run_coalesced()
1610 value |= w->off_val << w->shift; in dapm_seq_run_coalesced()
1612 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1614 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1626 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1628 value, mask, reg, card->pop_time); in dapm_seq_run_coalesced()
1629 pop_wait(card->pop_time); in dapm_seq_run_coalesced()
1641 * We walk over a pre-sorted list of widgets to apply power to. In
1653 int cur_sort = -1; in dapm_seq_run()
1654 int cur_subseq = -1; in dapm_seq_run()
1669 if (sort[w->id] != cur_sort || w->reg != cur_reg || in dapm_seq_run()
1670 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1674 if (cur_dapm && cur_dapm->component) { in dapm_seq_run()
1678 cur_dapm->component, in dapm_seq_run()
1682 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1686 cur_sort = -1; in dapm_seq_run()
1692 switch (w->id) { in dapm_seq_run()
1694 if (!w->event) in dapm_seq_run()
1698 ret = w->event(w, in dapm_seq_run()
1701 ret = w->event(w, in dapm_seq_run()
1706 if (!w->event) in dapm_seq_run()
1710 ret = w->event(w, in dapm_seq_run()
1713 ret = w->event(w, in dapm_seq_run()
1719 cur_sort = sort[w->id]; in dapm_seq_run()
1720 cur_subseq = w->subseq; in dapm_seq_run()
1721 cur_reg = w->reg; in dapm_seq_run()
1722 cur_dapm = w->dapm; in dapm_seq_run()
1723 list_move(&w->power_list, &pending); in dapm_seq_run()
1728 dev_err(w->dapm->dev, in dapm_seq_run()
1735 if (cur_dapm && cur_dapm->component) { in dapm_seq_run()
1739 cur_dapm->component, in dapm_seq_run()
1749 struct snd_soc_dapm_update *update = card->update; in dapm_widget_update()
1755 if (!update || !dapm_kcontrol_is_powered(update->kcontrol)) in dapm_widget_update()
1758 wlist = dapm_kcontrol_get_wlist(update->kcontrol); in dapm_widget_update()
1761 if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) { in dapm_widget_update()
1762 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); in dapm_widget_update()
1764 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1765 w->name, ret); in dapm_widget_update()
1772 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1773 update->val); in dapm_widget_update()
1775 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1776 w->name, ret); in dapm_widget_update()
1778 if (update->has_second_set) { in dapm_widget_update()
1779 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1780 update->mask2, update->val2); in dapm_widget_update()
1782 dev_err(w->dapm->dev, in dapm_widget_update()
1784 w->name, ret); in dapm_widget_update()
1788 if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) { in dapm_widget_update()
1789 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); in dapm_widget_update()
1791 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1792 w->name, ret); in dapm_widget_update()
1797 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1806 if (d->bias_level == SND_SOC_BIAS_OFF && in dapm_pre_sequence_async()
1807 d->target_bias_level != SND_SOC_BIAS_OFF) { in dapm_pre_sequence_async()
1808 if (d->dev && cookie) in dapm_pre_sequence_async()
1809 pm_runtime_get_sync(d->dev); in dapm_pre_sequence_async()
1813 dev_err(d->dev, in dapm_pre_sequence_async()
1818 if ((d->target_bias_level == SND_SOC_BIAS_ON && in dapm_pre_sequence_async()
1819 d->bias_level != SND_SOC_BIAS_ON) || in dapm_pre_sequence_async()
1820 (d->target_bias_level != SND_SOC_BIAS_ON && in dapm_pre_sequence_async()
1821 d->bias_level == SND_SOC_BIAS_ON)) { in dapm_pre_sequence_async()
1824 dev_err(d->dev, in dapm_pre_sequence_async()
1829 /* Async callback run prior to DAPM sequences - brings to their final
1838 if (d->bias_level == SND_SOC_BIAS_PREPARE && in dapm_post_sequence_async()
1839 (d->target_bias_level == SND_SOC_BIAS_STANDBY || in dapm_post_sequence_async()
1840 d->target_bias_level == SND_SOC_BIAS_OFF)) { in dapm_post_sequence_async()
1843 dev_err(d->dev, "ASoC: Failed to apply standby bias: %d\n", in dapm_post_sequence_async()
1848 if (d->bias_level == SND_SOC_BIAS_STANDBY && in dapm_post_sequence_async()
1849 d->target_bias_level == SND_SOC_BIAS_OFF) { in dapm_post_sequence_async()
1852 dev_err(d->dev, "ASoC: Failed to turn off bias: %d\n", in dapm_post_sequence_async()
1855 if (d->dev && cookie) in dapm_post_sequence_async()
1856 pm_runtime_put(d->dev); in dapm_post_sequence_async()
1860 if (d->bias_level == SND_SOC_BIAS_PREPARE && in dapm_post_sequence_async()
1861 d->target_bias_level == SND_SOC_BIAS_ON) { in dapm_post_sequence_async()
1864 dev_err(d->dev, "ASoC: Failed to apply active bias: %d\n", in dapm_post_sequence_async()
1880 if (power != peer->power) in dapm_widget_set_peer_power()
1891 switch (w->id) { in dapm_power_one_widget()
1904 if (w->power == power) in dapm_power_one_widget()
1914 dapm_widget_set_peer_power(path->source, power, path->connect); in dapm_power_one_widget()
1919 if (!w->is_supply) in dapm_power_one_widget()
1921 dapm_widget_set_peer_power(path->sink, power, path->connect); in dapm_power_one_widget()
1932 if (dapm->idle_bias_off) in dapm_idle_bias_off()
1935 switch (snd_power_get_state(dapm->card->snd_card)) { in dapm_idle_bias_off()
1938 return dapm->suspend_bias_off; in dapm_idle_bias_off()
1948 * A complete path is a route that has valid endpoints i.e.:-
1971 d->target_bias_level = SND_SOC_BIAS_OFF; in dapm_power_widgets()
1973 d->target_bias_level = SND_SOC_BIAS_STANDBY; in dapm_power_widgets()
1984 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1989 switch (w->id) { in dapm_power_widgets()
1995 list_del_init(&w->dirty); in dapm_power_widgets()
1999 if (w->new_power) { in dapm_power_widgets()
2000 d = w->dapm; in dapm_power_widgets()
2009 switch (w->id) { in dapm_power_widgets()
2018 if (d->target_bias_level < SND_SOC_BIAS_STANDBY) in dapm_power_widgets()
2019 d->target_bias_level = SND_SOC_BIAS_STANDBY; in dapm_power_widgets()
2022 d->target_bias_level = SND_SOC_BIAS_ON; in dapm_power_widgets()
2034 if (d->target_bias_level > bias) in dapm_power_widgets()
2035 bias = d->target_bias_level; in dapm_power_widgets()
2038 d->target_bias_level = bias; in dapm_power_widgets()
2043 dapm_pre_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2046 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2070 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2076 dapm_post_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2080 if (!d->component) in dapm_power_widgets()
2083 ret = snd_soc_component_stream_event(d->component, event); in dapm_power_widgets()
2088 pop_dbg(card->dev, card->pop_time, in dapm_power_widgets()
2089 "DAPM sequencing finished, waiting %dms\n", card->pop_time); in dapm_power_widgets()
2090 pop_wait(card->pop_time); in dapm_power_widgets()
2144 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file()
2156 return -ENOMEM; in dapm_widget_power_read_file()
2158 snd_soc_dapm_mutex_lock_root(w->dapm); in dapm_widget_power_read_file()
2161 if (w->is_supply) { in dapm_widget_power_read_file()
2170 w->name, w->power ? "On" : "Off", in dapm_widget_power_read_file()
2171 w->force ? " (forced)" : "", in, out); in dapm_widget_power_read_file()
2173 if (w->reg >= 0) in dapm_widget_power_read_file()
2174 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in dapm_widget_power_read_file()
2175 " - R%d(0x%x) mask 0x%x", in dapm_widget_power_read_file()
2176 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2178 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n"); in dapm_widget_power_read_file()
2180 if (w->sname) in dapm_widget_power_read_file()
2181 ret += scnprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n", in dapm_widget_power_read_file()
2182 w->sname, in dapm_widget_power_read_file()
2183 w->active ? "active" : "inactive"); in dapm_widget_power_read_file()
2185 ret += scnprintf(buf + ret, PAGE_SIZE - ret, " widget-type %s\n", in dapm_widget_power_read_file()
2186 snd_soc_dapm_type_name[w->id]); in dapm_widget_power_read_file()
2191 if (p->connected && !p->connected(p->source, p->sink)) in dapm_widget_power_read_file()
2194 if (!p->connect) in dapm_widget_power_read_file()
2197 c_name = p->node[rdir]->dapm->component ? in dapm_widget_power_read_file()
2198 p->node[rdir]->dapm->component->name : NULL; in dapm_widget_power_read_file()
2199 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in dapm_widget_power_read_file()
2202 p->name ? p->name : "static", in dapm_widget_power_read_file()
2203 p->node[rdir]->name, c_name); in dapm_widget_power_read_file()
2207 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2224 struct snd_soc_dapm_context *dapm = file->private_data; in dapm_bias_read_file()
2227 switch (dapm->bias_level) { in dapm_bias_read_file()
2241 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2262 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); in snd_soc_dapm_debugfs_init()
2264 debugfs_create_file("bias_level", 0444, dapm->debugfs_dapm, dapm, in snd_soc_dapm_debugfs_init()
2270 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget()
2272 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2275 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2281 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_free_widget()
2283 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_free_widget()
2286 debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); in dapm_debugfs_free_widget()
2291 debugfs_remove_recursive(dapm->debugfs_dapm); in dapm_debugfs_cleanup()
2292 dapm->debugfs_dapm = NULL; in dapm_debugfs_cleanup()
2316 * soc_dapm_connect_path() - Connects or disconnects a path
2325 if (path->connect == connect) in soc_dapm_connect_path()
2328 path->connect = connect; in soc_dapm_connect_path()
2329 dapm_mark_dirty(path->source, reason); in soc_dapm_connect_path()
2330 dapm_mark_dirty(path->sink, reason); in soc_dapm_connect_path()
2348 if (e && !(strcmp(path->name, e->texts[mux]))) in soc_dapm_mux_update_power()
2366 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mux_update_power()
2370 card->update = update; in snd_soc_dapm_mux_update_power()
2372 card->update = NULL; in snd_soc_dapm_mux_update_power()
2431 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mixer_update_power()
2435 card->update = update; in snd_soc_dapm_mixer_update_power()
2436 ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1); in snd_soc_dapm_mixer_update_power()
2437 card->update = NULL; in snd_soc_dapm_mixer_update_power()
2456 if (!cmpnt->card) in dapm_widget_show_component()
2459 for_each_card_widgets(cmpnt->card, w) { in dapm_widget_show_component()
2460 if (w->dapm != dapm) in dapm_widget_show_component()
2464 switch (w->id) { in dapm_widget_show_component()
2481 if (w->name) in dapm_widget_show_component()
2483 w->name, w->power ? "On":"Off"); in dapm_widget_show_component()
2513 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); in dapm_widget_show() local
2517 snd_soc_dapm_mutex_lock_root(rtd->card); in dapm_widget_show()
2519 for_each_rtd_codec_dais(rtd, i, codec_dai) { in dapm_widget_show()
2520 struct snd_soc_component *cmpnt = codec_dai->component; in dapm_widget_show()
2525 snd_soc_dapm_mutex_unlock(rtd->card); in dapm_widget_show()
2539 list_del(&path->list_node[SND_SOC_DAPM_DIR_IN]); in dapm_free_path()
2540 list_del(&path->list_node[SND_SOC_DAPM_DIR_OUT]); in dapm_free_path()
2541 list_del(&path->list_kcontrol); in dapm_free_path()
2542 list_del(&path->list); in dapm_free_path()
2547 * snd_soc_dapm_free_widget - Free specified widget
2560 list_del(&w->list); in snd_soc_dapm_free_widget()
2561 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2574 kfree(w->kcontrols); in snd_soc_dapm_free_widget()
2575 kfree_const(w->name); in snd_soc_dapm_free_widget()
2576 kfree_const(w->sname); in snd_soc_dapm_free_widget()
2586 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2587 if (w->dapm != dapm) in dapm_free_widgets()
2592 dapm->wcache_sink = NULL; in dapm_free_widgets()
2593 dapm->wcache_source = NULL; in dapm_free_widgets()
2614 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2615 if (!strcmp(w->name, pin_name)) { in dapm_find_widget()
2616 if (w->dapm == dapm) in dapm_find_widget()
2643 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); in __snd_soc_dapm_set_pin()
2644 return -EINVAL; in __snd_soc_dapm_set_pin()
2647 if (w->connected != status) { in __snd_soc_dapm_set_pin()
2654 w->connected = status; in __snd_soc_dapm_set_pin()
2656 w->force = 0; in __snd_soc_dapm_set_pin()
2674 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2690 if (!snd_soc_card_is_instantiated(dapm->card)) in snd_soc_dapm_sync_unlocked()
2693 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); in snd_soc_dapm_sync_unlocked()
2698 * snd_soc_dapm_sync - scan and power dapm paths
2721 switch (w->id) { in dapm_update_dai_chan()
2729 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2730 w->channel < channels ? "Connecting" : "Disconnecting", in dapm_update_dai_chan()
2731 p->source->name, p->sink->name); in dapm_update_dai_chan()
2733 if (w->channel < channels) in dapm_update_dai_chan()
2745 int dir = substream->stream; in dapm_update_dai_unlocked()
2756 dev_dbg(dai->dev, "Update DAI routes for %s %s\n", dai->name, snd_pcm_direction_name(dir)); in dapm_update_dai_unlocked()
2759 ret = dapm_update_dai_chan(p, p->sink, channels); in dapm_update_dai_unlocked()
2765 ret = dapm_update_dai_chan(p, p->source, channels); in dapm_update_dai_unlocked()
2777 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); in snd_soc_dapm_update_dai() local
2780 snd_soc_dapm_mutex_lock(rtd->card); in snd_soc_dapm_update_dai()
2782 snd_soc_dapm_mutex_unlock(rtd->card); in snd_soc_dapm_update_dai()
2790 struct snd_soc_component *component = widget->dapm->component; in snd_soc_dapm_widget_name_cmp()
2791 const char *wname = widget->name; in snd_soc_dapm_widget_name_cmp()
2793 if (component && component->name_prefix) in snd_soc_dapm_widget_name_cmp()
2794 wname += strlen(component->name_prefix) + 1; /* plus space */ in snd_soc_dapm_widget_name_cmp()
2801 * dapm_update_widget_flags() - Re-compute widget sink and source flags
2815 switch (w->id) { in dapm_update_widget_flags()
2818 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2822 if (p->source->id == snd_soc_dapm_micbias || in dapm_update_widget_flags()
2823 p->source->id == snd_soc_dapm_mic || in dapm_update_widget_flags()
2824 p->source->id == snd_soc_dapm_line || in dapm_update_widget_flags()
2825 p->source->id == snd_soc_dapm_output) { in dapm_update_widget_flags()
2833 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2837 if (p->sink->id == snd_soc_dapm_spk || in dapm_update_widget_flags()
2838 p->sink->id == snd_soc_dapm_hp || in dapm_update_widget_flags()
2839 p->sink->id == snd_soc_dapm_line || in dapm_update_widget_flags()
2840 p->sink->id == snd_soc_dapm_input) { in dapm_update_widget_flags()
2849 if (!list_empty(&w->edges[dir])) in dapm_update_widget_flags()
2857 w->is_ep = ep; in dapm_update_widget_flags()
2870 switch (source->id) { in snd_soc_dapm_check_dynamic_path()
2878 switch (sink->id) { in snd_soc_dapm_check_dynamic_path()
2890 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2891 "Direct connection between demux and mixer/mux not supported for path %s -> [%s] -> %s\n", in snd_soc_dapm_check_dynamic_path()
2892 source->name, control, sink->name); in snd_soc_dapm_check_dynamic_path()
2893 return -EINVAL; in snd_soc_dapm_check_dynamic_path()
2895 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2896 "Control not supported for path %s -> [%s] -> %s\n", in snd_soc_dapm_check_dynamic_path()
2897 source->name, control, sink->name); in snd_soc_dapm_check_dynamic_path()
2898 return -EINVAL; in snd_soc_dapm_check_dynamic_path()
2914 if (wsink->is_supply && !wsource->is_supply) { in snd_soc_dapm_add_path()
2915 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2916 "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n", in snd_soc_dapm_add_path()
2917 wsource->name, wsink->name); in snd_soc_dapm_add_path()
2918 return -EINVAL; in snd_soc_dapm_add_path()
2921 if (connected && !wsource->is_supply) { in snd_soc_dapm_add_path()
2922 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2923 "connected() callback only supported for supply widgets (%s -> %s)\n", in snd_soc_dapm_add_path()
2924 wsource->name, wsink->name); in snd_soc_dapm_add_path()
2925 return -EINVAL; in snd_soc_dapm_add_path()
2928 if (wsource->is_supply && control) { in snd_soc_dapm_add_path()
2929 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2930 "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n", in snd_soc_dapm_add_path()
2931 wsource->name, control, wsink->name); in snd_soc_dapm_add_path()
2932 return -EINVAL; in snd_soc_dapm_add_path()
2941 return -ENOMEM; in snd_soc_dapm_add_path()
2943 path->node[SND_SOC_DAPM_DIR_IN] = wsource; in snd_soc_dapm_add_path()
2944 path->node[SND_SOC_DAPM_DIR_OUT] = wsink; in snd_soc_dapm_add_path()
2946 path->connected = connected; in snd_soc_dapm_add_path()
2947 INIT_LIST_HEAD(&path->list); in snd_soc_dapm_add_path()
2948 INIT_LIST_HEAD(&path->list_kcontrol); in snd_soc_dapm_add_path()
2950 if (wsource->is_supply || wsink->is_supply) in snd_soc_dapm_add_path()
2951 path->is_supply = 1; in snd_soc_dapm_add_path()
2955 path->connect = 1; in snd_soc_dapm_add_path()
2957 switch (wsource->id) { in snd_soc_dapm_add_path()
2967 switch (wsink->id) { in snd_soc_dapm_add_path()
2985 list_add(&path->list, &dapm->card->paths); in snd_soc_dapm_add_path()
2988 list_add(&path->list_node[dir], &path->node[dir]->edges[dir]); in snd_soc_dapm_add_path()
2991 dapm_update_widget_flags(path->node[dir]); in snd_soc_dapm_add_path()
2992 dapm_mark_dirty(path->node[dir], "Route added"); in snd_soc_dapm_add_path()
2995 if (snd_soc_card_is_instantiated(dapm->card) && path->connect) in snd_soc_dapm_add_path()
3021 prefix, route->sink); in snd_soc_dapm_add_route()
3024 prefix, route->source); in snd_soc_dapm_add_route()
3027 sink = route->sink; in snd_soc_dapm_add_route()
3028 source = route->source; in snd_soc_dapm_add_route()
3031 wsource = dapm_wcache_lookup(dapm->wcache_source, source); in snd_soc_dapm_add_route()
3032 wsink = dapm_wcache_lookup(dapm->wcache_sink, sink); in snd_soc_dapm_add_route()
3041 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
3042 if (!wsink && !(strcmp(w->name, sink))) { in snd_soc_dapm_add_route()
3044 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3051 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3053 w->name); in snd_soc_dapm_add_route()
3056 if (!wsource && !(strcmp(w->name, source))) { in snd_soc_dapm_add_route()
3058 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3065 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3067 w->name); in snd_soc_dapm_add_route()
3076 ret = -ENODEV; in snd_soc_dapm_add_route()
3084 dapm->wcache_sink = wsink; in snd_soc_dapm_add_route()
3085 dapm->wcache_source = wsource; in snd_soc_dapm_add_route()
3087 ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, in snd_soc_dapm_add_route()
3088 route->connected); in snd_soc_dapm_add_route()
3091 dev_err(dapm->dev, "ASoC: Failed to add route %s%s -%s%s%s> %s%s\n", in snd_soc_dapm_add_route()
3093 !route->control ? "" : "> [", in snd_soc_dapm_add_route()
3094 !route->control ? "" : route->control, in snd_soc_dapm_add_route()
3095 !route->control ? "" : "] -", in snd_soc_dapm_add_route()
3110 if (route->control) { in snd_soc_dapm_del_route()
3111 dev_err(dapm->dev, in snd_soc_dapm_del_route()
3113 return -EINVAL; in snd_soc_dapm_del_route()
3119 prefix, route->sink); in snd_soc_dapm_del_route()
3122 prefix, route->source); in snd_soc_dapm_del_route()
3125 sink = route->sink; in snd_soc_dapm_del_route()
3126 source = route->source; in snd_soc_dapm_del_route()
3130 list_for_each_entry(p, &dapm->card->paths, list) { in snd_soc_dapm_del_route()
3131 if (strcmp(p->source->name, source) != 0) in snd_soc_dapm_del_route()
3133 if (strcmp(p->sink->name, sink) != 0) in snd_soc_dapm_del_route()
3140 struct snd_soc_dapm_widget *wsource = path->source; in snd_soc_dapm_del_route()
3141 struct snd_soc_dapm_widget *wsink = path->sink; in snd_soc_dapm_del_route()
3145 if (path->connect) in snd_soc_dapm_del_route()
3154 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", in snd_soc_dapm_del_route()
3162 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
3193 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
3220 route->source, in snd_soc_dapm_weak_route()
3223 route->sink, in snd_soc_dapm_weak_route()
3229 dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n", in snd_soc_dapm_weak_route()
3230 route->source); in snd_soc_dapm_weak_route()
3231 return -ENODEV; in snd_soc_dapm_weak_route()
3235 dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n", in snd_soc_dapm_weak_route()
3236 route->sink); in snd_soc_dapm_weak_route()
3237 return -ENODEV; in snd_soc_dapm_weak_route()
3240 if (route->control || route->connected) in snd_soc_dapm_weak_route()
3241 dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3242 route->source, route->sink); in snd_soc_dapm_weak_route()
3245 if (path->sink == sink) { in snd_soc_dapm_weak_route()
3246 path->weak = 1; in snd_soc_dapm_weak_route()
3252 dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3253 route->source, route->sink); in snd_soc_dapm_weak_route()
3255 dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3256 count, route->source, route->sink); in snd_soc_dapm_weak_route()
3262 * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
3297 * snd_soc_dapm_new_widgets - add new dapm widgets
3313 if (w->new) in snd_soc_dapm_new_widgets()
3316 if (w->num_kcontrols) { in snd_soc_dapm_new_widgets()
3317 w->kcontrols = kcalloc(w->num_kcontrols, in snd_soc_dapm_new_widgets()
3320 if (!w->kcontrols) { in snd_soc_dapm_new_widgets()
3322 return -ENOMEM; in snd_soc_dapm_new_widgets()
3326 switch(w->id) { in snd_soc_dapm_new_widgets()
3349 if (w->reg >= 0) { in snd_soc_dapm_new_widgets()
3350 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3351 val = val >> w->shift; in snd_soc_dapm_new_widgets()
3352 val &= w->mask; in snd_soc_dapm_new_widgets()
3353 if (val == w->on_val) in snd_soc_dapm_new_widgets()
3354 w->power = 1; in snd_soc_dapm_new_widgets()
3357 w->new = 1; in snd_soc_dapm_new_widgets()
3370 * snd_soc_dapm_get_volsw - dapm mixer get callback
3383 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_get_volsw()
3384 int reg = mc->reg; in snd_soc_dapm_get_volsw()
3385 unsigned int shift = mc->shift; in snd_soc_dapm_get_volsw()
3386 int max = mc->max; in snd_soc_dapm_get_volsw()
3388 unsigned int mask = (1 << fls(max)) - 1; in snd_soc_dapm_get_volsw()
3389 unsigned int invert = mc->invert; in snd_soc_dapm_get_volsw()
3397 if (reg != mc->rreg) in snd_soc_dapm_get_volsw()
3398 reg_val = soc_dapm_read(dapm, mc->rreg); in snd_soc_dapm_get_volsw()
3401 rval = (reg_val >> mc->rshift) & mask; in snd_soc_dapm_get_volsw()
3412 ucontrol->value.integer.value[0] = max - val; in snd_soc_dapm_get_volsw()
3414 ucontrol->value.integer.value[0] = val; in snd_soc_dapm_get_volsw()
3418 ucontrol->value.integer.value[1] = max - rval; in snd_soc_dapm_get_volsw()
3420 ucontrol->value.integer.value[1] = rval; in snd_soc_dapm_get_volsw()
3428 * snd_soc_dapm_put_volsw - dapm mixer set callback
3440 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_volsw()
3442 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_put_volsw()
3443 int reg = mc->reg; in snd_soc_dapm_put_volsw()
3444 unsigned int shift = mc->shift; in snd_soc_dapm_put_volsw()
3445 int max = mc->max; in snd_soc_dapm_put_volsw()
3447 unsigned int mask = (1 << width) - 1; in snd_soc_dapm_put_volsw()
3448 unsigned int invert = mc->invert; in snd_soc_dapm_put_volsw()
3450 int connect, rconnect = -1, change, reg_change = 0; in snd_soc_dapm_put_volsw()
3454 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_dapm_put_volsw()
3458 val = max - val; in snd_soc_dapm_put_volsw()
3461 rval = (ucontrol->value.integer.value[1] & mask); in snd_soc_dapm_put_volsw()
3464 rval = max - rval; in snd_soc_dapm_put_volsw()
3471 dev_warn(dapm->dev, in snd_soc_dapm_put_volsw()
3473 kcontrol->id.name); in snd_soc_dapm_put_volsw()
3478 rval = rval << mc->rshift; in snd_soc_dapm_put_volsw()
3483 reg_change |= soc_dapm_test_bits(dapm, mc->rreg, in snd_soc_dapm_put_volsw()
3484 mask << mc->rshift, in snd_soc_dapm_put_volsw()
3492 update.reg2 = mc->rreg; in snd_soc_dapm_put_volsw()
3493 update.mask2 = mask << mc->rshift; in snd_soc_dapm_put_volsw()
3500 card->update = &update; in snd_soc_dapm_put_volsw()
3506 card->update = NULL; in snd_soc_dapm_put_volsw()
3519 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
3531 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in snd_soc_dapm_get_enum_double()
3535 if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { in snd_soc_dapm_get_enum_double()
3536 reg_val = soc_dapm_read(dapm, e->reg); in snd_soc_dapm_get_enum_double()
3542 val = (reg_val >> e->shift_l) & e->mask; in snd_soc_dapm_get_enum_double()
3543 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); in snd_soc_dapm_get_enum_double()
3544 if (e->shift_l != e->shift_r) { in snd_soc_dapm_get_enum_double()
3545 val = (reg_val >> e->shift_r) & e->mask; in snd_soc_dapm_get_enum_double()
3547 ucontrol->value.enumerated.item[1] = val; in snd_soc_dapm_get_enum_double()
3555 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3567 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_enum_double()
3568 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in snd_soc_dapm_put_enum_double()
3569 unsigned int *item = ucontrol->value.enumerated.item; in snd_soc_dapm_put_enum_double()
3575 if (item[0] >= e->items) in snd_soc_dapm_put_enum_double()
3576 return -EINVAL; in snd_soc_dapm_put_enum_double()
3578 val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; in snd_soc_dapm_put_enum_double()
3579 mask = e->mask << e->shift_l; in snd_soc_dapm_put_enum_double()
3580 if (e->shift_l != e->shift_r) { in snd_soc_dapm_put_enum_double()
3581 if (item[1] > e->items) in snd_soc_dapm_put_enum_double()
3582 return -EINVAL; in snd_soc_dapm_put_enum_double()
3583 val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_r; in snd_soc_dapm_put_enum_double()
3584 mask |= e->mask << e->shift_r; in snd_soc_dapm_put_enum_double()
3591 if (e->reg != SND_SOC_NOPM) in snd_soc_dapm_put_enum_double()
3592 reg_change = soc_dapm_test_bits(dapm, e->reg, mask, val); in snd_soc_dapm_put_enum_double()
3597 update.reg = e->reg; in snd_soc_dapm_put_enum_double()
3600 card->update = &update; in snd_soc_dapm_put_enum_double()
3605 card->update = NULL; in snd_soc_dapm_put_enum_double()
3618 * snd_soc_dapm_info_pin_switch - Info for a pin switch
3628 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_soc_dapm_info_pin_switch()
3629 uinfo->count = 1; in snd_soc_dapm_info_pin_switch()
3630 uinfo->value.integer.min = 0; in snd_soc_dapm_info_pin_switch()
3631 uinfo->value.integer.max = 1; in snd_soc_dapm_info_pin_switch()
3638 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
3647 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_get_pin_switch()
3651 ucontrol->value.integer.value[0] = in snd_soc_dapm_get_pin_switch()
3652 snd_soc_dapm_get_pin_status(&card->dapm, pin); in snd_soc_dapm_get_pin_switch()
3661 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
3670 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_put_pin_switch()
3674 ret = __snd_soc_dapm_set_pin(&card->dapm, pin, in snd_soc_dapm_put_pin_switch()
3675 !!ucontrol->value.integer.value[0]); in snd_soc_dapm_put_pin_switch()
3678 snd_soc_dapm_sync(&card->dapm); in snd_soc_dapm_put_pin_switch()
3689 int ret = -ENOMEM; in snd_soc_dapm_new_control_unlocked()
3695 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3697 w->regulator = devm_regulator_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3698 if (IS_ERR(w->regulator)) { in snd_soc_dapm_new_control_unlocked()
3699 ret = PTR_ERR(w->regulator); in snd_soc_dapm_new_control_unlocked()
3703 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_new_control_unlocked()
3704 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_new_control_unlocked()
3706 dev_warn(dapm->dev, in snd_soc_dapm_new_control_unlocked()
3708 w->name, ret); in snd_soc_dapm_new_control_unlocked()
3712 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3713 if (IS_ERR(w->pinctrl)) { in snd_soc_dapm_new_control_unlocked()
3714 ret = PTR_ERR(w->pinctrl); in snd_soc_dapm_new_control_unlocked()
3722 w->clk = devm_clk_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3723 if (IS_ERR(w->clk)) { in snd_soc_dapm_new_control_unlocked()
3724 ret = PTR_ERR(w->clk); in snd_soc_dapm_new_control_unlocked()
3732 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3734 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3735 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3738 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3739 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3740 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3744 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3745 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3748 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3749 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3750 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3754 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3755 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3758 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3759 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3785 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3792 w->is_supply = 1; in snd_soc_dapm_new_control_unlocked()
3793 w->power_check = dapm_supply_check_power; in snd_soc_dapm_new_control_unlocked()
3796 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3800 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3801 INIT_LIST_HEAD(&w->list); in snd_soc_dapm_new_control_unlocked()
3802 INIT_LIST_HEAD(&w->dirty); in snd_soc_dapm_new_control_unlocked()
3804 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3807 INIT_LIST_HEAD(&w->edges[dir]); in snd_soc_dapm_new_control_unlocked()
3808 w->endpoints[dir] = -1; in snd_soc_dapm_new_control_unlocked()
3812 w->connected = 1; in snd_soc_dapm_new_control_unlocked()
3816 dev_err_probe(dapm->dev, ret, "ASoC: Failed to request %s\n", in snd_soc_dapm_new_control_unlocked()
3817 w->name); in snd_soc_dapm_new_control_unlocked()
3818 kfree_const(w->name); in snd_soc_dapm_new_control_unlocked()
3819 kfree_const(w->sname); in snd_soc_dapm_new_control_unlocked()
3826 * snd_soc_dapm_new_control - create new dapm control
3849 * snd_soc_dapm_new_controls - create new dapm controls
3885 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); in snd_soc_dai_link_event_pre_pmu() local
3903 return -ENOMEM; in snd_soc_dai_link_event_pre_pmu()
3907 return -ENOMEM; in snd_soc_dai_link_event_pre_pmu()
3909 substream->runtime = runtime; in snd_soc_dai_link_event_pre_pmu()
3911 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event_pre_pmu()
3913 source = path->source->priv; in snd_soc_dai_link_event_pre_pmu()
3919 snd_soc_dai_activate(source, substream->stream); in snd_soc_dai_link_event_pre_pmu()
3922 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event_pre_pmu()
3924 sink = path->sink->priv; in snd_soc_dai_link_event_pre_pmu()
3930 snd_soc_dai_activate(sink, substream->stream); in snd_soc_dai_link_event_pre_pmu()
3933 substream->hw_opened = 1; in snd_soc_dai_link_event_pre_pmu()
3940 config = rtd->dai_link->c2c_params + rtd->c2c_params_select; in snd_soc_dai_link_event_pre_pmu()
3942 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3943 return -EINVAL; in snd_soc_dai_link_event_pre_pmu()
3947 if (!config->formats) { in snd_soc_dai_link_event_pre_pmu()
3948 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
3950 return -EINVAL; in snd_soc_dai_link_event_pre_pmu()
3953 fmt = ffs(config->formats) - 1; in snd_soc_dai_link_event_pre_pmu()
3956 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min = in snd_soc_dai_link_event_pre_pmu()
3957 config->rate_min; in snd_soc_dai_link_event_pre_pmu()
3958 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max = in snd_soc_dai_link_event_pre_pmu()
3959 config->rate_max; in snd_soc_dai_link_event_pre_pmu()
3960 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min in snd_soc_dai_link_event_pre_pmu()
3961 = config->channels_min; in snd_soc_dai_link_event_pre_pmu()
3962 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max in snd_soc_dai_link_event_pre_pmu()
3963 = config->channels_max; in snd_soc_dai_link_event_pre_pmu()
3965 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event_pre_pmu()
3967 source = path->source->priv; in snd_soc_dai_link_event_pre_pmu()
3976 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event_pre_pmu()
3978 sink = path->sink->priv; in snd_soc_dai_link_event_pre_pmu()
3987 runtime->format = params_format(params); in snd_soc_dai_link_event_pre_pmu()
3988 runtime->subformat = params_subformat(params); in snd_soc_dai_link_event_pre_pmu()
3989 runtime->channels = params_channels(params); in snd_soc_dai_link_event_pre_pmu()
3990 runtime->rate = params_rate(params); in snd_soc_dai_link_event_pre_pmu()
4000 struct snd_pcm_substream *substream = w->priv; in snd_soc_dai_link_event()
4001 int ret = 0, saved_stream = substream->stream; in snd_soc_dai_link_event()
4003 if (WARN_ON(list_empty(&w->edges[SND_SOC_DAPM_DIR_OUT]) || in snd_soc_dai_link_event()
4004 list_empty(&w->edges[SND_SOC_DAPM_DIR_IN]))) in snd_soc_dai_link_event()
4005 return -EINVAL; in snd_soc_dai_link_event()
4017 sink = path->sink->priv; in snd_soc_dai_link_event()
4026 sink = path->sink->priv; in snd_soc_dai_link_event()
4032 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event()
4034 source = path->source->priv; in snd_soc_dai_link_event()
4038 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event()
4040 sink = path->sink->priv; in snd_soc_dai_link_event()
4044 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event()
4046 source = path->source->priv; in snd_soc_dai_link_event()
4047 snd_soc_dai_deactivate(source, substream->stream); in snd_soc_dai_link_event()
4051 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event()
4053 sink = path->sink->priv; in snd_soc_dai_link_event()
4054 snd_soc_dai_deactivate(sink, substream->stream); in snd_soc_dai_link_event()
4060 kfree(substream->runtime); in snd_soc_dai_link_event()
4061 substream->runtime = NULL; in snd_soc_dai_link_event()
4066 ret = -EINVAL; in snd_soc_dai_link_event()
4071 substream->stream = saved_stream; in snd_soc_dai_link_event()
4079 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get() local
4081 ucontrol->value.enumerated.item[0] = rtd->c2c_params_select; in snd_soc_dapm_dai_link_get()
4090 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_put() local
4093 if (w->power) in snd_soc_dapm_dai_link_put()
4094 return -EBUSY; in snd_soc_dapm_dai_link_put()
4096 if (ucontrol->value.enumerated.item[0] == rtd->c2c_params_select) in snd_soc_dapm_dai_link_put()
4099 if (ucontrol->value.enumerated.item[0] >= rtd->dai_link->num_c2c_params) in snd_soc_dapm_dai_link_put()
4100 return -EINVAL; in snd_soc_dapm_dai_link_put()
4102 rtd->c2c_params_select = ucontrol->value.enumerated.item[0]; in snd_soc_dapm_dai_link_put()
4115 devm_kfree(card->dev, (void *)*private_value); in snd_soc_dapm_free_kcontrol()
4121 devm_kfree(card->dev, (void *)w_param_text[count]); in snd_soc_dapm_free_kcontrol()
4122 devm_kfree(card->dev, w_param_text); in snd_soc_dapm_free_kcontrol()
4145 if (!config->stream_name) { in snd_soc_dapm_alloc_kcontrol()
4146 dev_warn(card->dapm.dev, in snd_soc_dapm_alloc_kcontrol()
4150 devm_kasprintf(card->dev, GFP_KERNEL, in snd_soc_dapm_alloc_kcontrol()
4154 w_param_text[count] = devm_kmemdup(card->dev, in snd_soc_dapm_alloc_kcontrol()
4155 config->stream_name, in snd_soc_dapm_alloc_kcontrol()
4156 strlen(config->stream_name) + 1, in snd_soc_dapm_alloc_kcontrol()
4168 (unsigned long) devm_kmemdup(card->dev, in snd_soc_dapm_alloc_kcontrol()
4172 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", in snd_soc_dapm_alloc_kcontrol()
4178 kcontrol_news = devm_kmemdup(card->dev, &kcontrol_dai_link[0], in snd_soc_dapm_alloc_kcontrol()
4182 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", in snd_soc_dapm_alloc_kcontrol()
4198 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); in snd_soc_dapm_new_dai() local
4206 int ret = -ENOMEM; in snd_soc_dapm_new_dai()
4208 link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s", in snd_soc_dapm_new_dai()
4209 rtd->dai_link->name, id); in snd_soc_dapm_new_dai()
4217 if (rtd->dai_link->num_c2c_params > 1) { in snd_soc_dapm_new_dai()
4218 w_param_text = devm_kcalloc(card->dev, in snd_soc_dapm_new_dai()
4219 rtd->dai_link->num_c2c_params, in snd_soc_dapm_new_dai()
4226 rtd->dai_link->c2c_params, in snd_soc_dapm_new_dai()
4227 rtd->dai_link->num_c2c_params, in snd_soc_dapm_new_dai()
4243 dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name); in snd_soc_dapm_new_dai()
4245 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4251 w->priv = substream; in snd_soc_dapm_new_dai()
4256 devm_kfree(card->dev, (void *)template.kcontrol_news); in snd_soc_dapm_new_dai()
4258 rtd->dai_link->num_c2c_params, w_param_text); in snd_soc_dapm_new_dai()
4260 devm_kfree(card->dev, link_name); in snd_soc_dapm_new_dai()
4262 dev_err(rtd->dev, "ASoC: Failed to create %s-%s widget: %d\n", in snd_soc_dapm_new_dai()
4263 rtd->dai_link->name, id, ret); in snd_soc_dapm_new_dai()
4268 * snd_soc_dapm_new_dai_widgets - Create new DAPM widgets
4280 WARN_ON(dapm->dev != dai->dev); in snd_soc_dapm_new_dai_widgets()
4285 if (dai->driver->playback.stream_name) { in snd_soc_dapm_new_dai_widgets()
4287 template.name = dai->driver->playback.stream_name; in snd_soc_dapm_new_dai_widgets()
4288 template.sname = dai->driver->playback.stream_name; in snd_soc_dapm_new_dai_widgets()
4290 dev_dbg(dai->dev, "ASoC: adding %s widget\n", in snd_soc_dapm_new_dai_widgets()
4297 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4301 if (dai->driver->capture.stream_name) { in snd_soc_dapm_new_dai_widgets()
4303 template.name = dai->driver->capture.stream_name; in snd_soc_dapm_new_dai_widgets()
4304 template.sname = dai->driver->capture.stream_name; in snd_soc_dapm_new_dai_widgets()
4306 dev_dbg(dai->dev, "ASoC: adding %s widget\n", in snd_soc_dapm_new_dai_widgets()
4313 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4329 switch (dai_w->id) { in snd_soc_dapm_link_dai_widgets()
4338 if (!dai_w->priv) { in snd_soc_dapm_link_dai_widgets()
4339 dev_dbg(card->dev, "dai widget %s has no DAI\n", in snd_soc_dapm_link_dai_widgets()
4340 dai_w->name); in snd_soc_dapm_link_dai_widgets()
4344 dai = dai_w->priv; in snd_soc_dapm_link_dai_widgets()
4348 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4351 switch (w->id) { in snd_soc_dapm_link_dai_widgets()
4359 if (!w->sname || !strstr(w->sname, dai_w->sname)) in snd_soc_dapm_link_dai_widgets()
4362 if (dai_w->id == snd_soc_dapm_dai_in) { in snd_soc_dapm_link_dai_widgets()
4369 dev_dbg(dai->dev, "%s -> %s\n", src->name, sink->name); in snd_soc_dapm_link_dai_widgets()
4370 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4384 dev_dbg(dapm->dev, "connected DAI link %s:%s -> %s:%s\n", in dapm_connect_dai_routes()
4385 src_dai->component->name, src->name, in dapm_connect_dai_routes()
4386 sink_dai->component->name, sink->name); in dapm_connect_dai_routes()
4397 struct snd_soc_pcm_runtime *rtd, in dapm_connect_dai_pair() argument
4401 struct snd_soc_dai_link *dai_link = rtd->dai_link; in dapm_connect_dai_pair()
4424 if (dai_link->c2c_params && !rtd->c2c_widget[stream]) { in dapm_connect_dai_pair()
4425 struct snd_pcm_substream *substream = rtd->pcm->streams[stream].substream; in dapm_connect_dai_pair()
4432 rtd->c2c_widget[stream] = dai; in dapm_connect_dai_pair()
4435 dapm_connect_dai_routes(&card->dapm, src_dai[stream], *src[stream], in dapm_connect_dai_pair()
4436 rtd->c2c_widget[stream], in dapm_connect_dai_pair()
4453 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4463 w->active = 1; in soc_dapm_dai_stream_event()
4464 w->is_ep = ep; in soc_dapm_dai_stream_event()
4467 w->active = 0; in soc_dapm_dai_stream_event()
4468 w->is_ep = 0; in soc_dapm_dai_stream_event()
4481 struct snd_soc_pcm_runtime *rtd; in snd_soc_dapm_connect_dai_link_widgets() local
4486 for_each_card_rtds(card, rtd) { in snd_soc_dapm_connect_dai_link_widgets()
4492 * CODEC<->CODEC links have no direct connection. in snd_soc_dapm_connect_dai_link_widgets()
4494 if (rtd->dai_link->dynamic) in snd_soc_dapm_connect_dai_link_widgets()
4499 * soc.h :: [dai_link->ch_maps Image sample] in snd_soc_dapm_connect_dai_link_widgets()
4501 for_each_rtd_ch_maps(rtd, i, ch_maps) { in snd_soc_dapm_connect_dai_link_widgets()
4502 cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); in snd_soc_dapm_connect_dai_link_widgets()
4503 codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); in snd_soc_dapm_connect_dai_link_widgets()
4505 dapm_connect_dai_pair(card, rtd, codec_dai, cpu_dai); in snd_soc_dapm_connect_dai_link_widgets()
4510 static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, in soc_dapm_stream_event() argument
4516 for_each_rtd_dais(rtd, i, dai) in soc_dapm_stream_event()
4519 dapm_power_widgets(rtd->card, event); in soc_dapm_stream_event()
4523 * snd_soc_dapm_stream_event - send a stream event to the dapm core
4524 * @rtd: PCM runtime data
4533 void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, in snd_soc_dapm_stream_event() argument
4536 struct snd_soc_card *card = rtd->card; in snd_soc_dapm_stream_event()
4539 soc_dapm_stream_event(rtd, stream, event); in snd_soc_dapm_stream_event()
4543 void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream) in snd_soc_dapm_stream_stop() argument
4546 if (snd_soc_runtime_ignore_pmdown_time(rtd)) { in snd_soc_dapm_stream_stop()
4548 snd_soc_dapm_stream_event(rtd, in snd_soc_dapm_stream_stop()
4553 rtd->pop_wait = 1; in snd_soc_dapm_stream_stop()
4555 &rtd->delayed_work, in snd_soc_dapm_stream_stop()
4556 msecs_to_jiffies(rtd->pmdown_time)); in snd_soc_dapm_stream_stop()
4560 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE, in snd_soc_dapm_stream_stop()
4567 * snd_soc_dapm_enable_pin_unlocked - enable pin.
4587 * snd_soc_dapm_enable_pin - enable pin.
4612 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
4631 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4632 return -EINVAL; in snd_soc_dapm_force_enable_pin_unlocked()
4635 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4636 if (!w->connected) { in snd_soc_dapm_force_enable_pin_unlocked()
4638 * w->force does not affect the number of input or output paths, in snd_soc_dapm_force_enable_pin_unlocked()
4639 * so we only have to recheck if w->connected is changed in snd_soc_dapm_force_enable_pin_unlocked()
4643 w->connected = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4645 w->force = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4653 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
4680 * snd_soc_dapm_disable_pin_unlocked - disable pin.
4699 * snd_soc_dapm_disable_pin - disable pin.
4724 * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
4747 * snd_soc_dapm_nc_pin - permanently disable pin.
4775 * snd_soc_dapm_get_pin_status - get audio pin status
4779 * Get audio pin status - connected or disconnected.
4789 return w->connected; in snd_soc_dapm_get_pin_status()
4796 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
4812 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_ignore_suspend()
4813 return -EINVAL; in snd_soc_dapm_ignore_suspend()
4816 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4823 * snd_soc_dapm_free - free dapm resources
4832 list_del(&dapm->list); in snd_soc_dapm_free()
4840 dapm->card = card; in snd_soc_dapm_init()
4841 dapm->component = component; in snd_soc_dapm_init()
4842 dapm->bias_level = SND_SOC_BIAS_OFF; in snd_soc_dapm_init()
4845 dapm->dev = component->dev; in snd_soc_dapm_init()
4846 dapm->idle_bias_off = !component->driver->idle_bias_on; in snd_soc_dapm_init()
4847 dapm->suspend_bias_off = component->driver->suspend_bias_off; in snd_soc_dapm_init()
4849 dapm->dev = card->dev; in snd_soc_dapm_init()
4852 INIT_LIST_HEAD(&dapm->list); in snd_soc_dapm_init()
4854 list_add(&dapm->list, &card->dapm_list); in snd_soc_dapm_init()
4860 struct snd_soc_card *card = dapm->card; in soc_dapm_shutdown_dapm()
4867 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4868 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4870 if (w->power) { in soc_dapm_shutdown_dapm()
4872 w->new_power = 0; in soc_dapm_shutdown_dapm()
4881 if (dapm->bias_level == SND_SOC_BIAS_ON) in soc_dapm_shutdown_dapm()
4885 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) in soc_dapm_shutdown_dapm()
4894 * snd_soc_dapm_shutdown - callback for system shutdown
4901 if (dapm != &card->dapm) { in snd_soc_dapm_shutdown()
4903 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4909 soc_dapm_shutdown_dapm(&card->dapm); in snd_soc_dapm_shutdown()
4910 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4911 snd_soc_dapm_set_bias_level(&card->dapm, in snd_soc_dapm_shutdown()