Lines Matching +full:1 +full:w
69 [snd_soc_dapm_pre] = 1,
110 [snd_soc_dapm_pre] = 1,
183 static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w) in dapm_dirty_widget() argument
185 return !list_empty(&w->dirty); in dapm_dirty_widget()
188 static void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason) in dapm_mark_dirty() argument
190 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
192 if (!dapm_dirty_widget(w)) { 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()
207 struct snd_soc_dapm_widget *w, enum snd_soc_dapm_direction dir) in dapm_widget_invalidate_paths() argument
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()
222 list_for_each_entry(w, &list, work_list) { in dapm_widget_invalidate_paths()
223 snd_soc_dapm_widget_for_each_path(w, dir, p) { 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()
238 * @w: The widget for which to invalidate the cached number of input paths
247 static void dapm_widget_invalidate_input_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_input_paths() argument
249 dapm_widget_invalidate_paths(w, SND_SOC_DAPM_DIR_IN); in dapm_widget_invalidate_input_paths()
255 * @w: The widget for which to invalidate the cached number of output paths
264 static void dapm_widget_invalidate_output_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_output_paths() argument
266 dapm_widget_invalidate_paths(w, SND_SOC_DAPM_DIR_OUT); in dapm_widget_invalidate_output_paths()
303 struct snd_soc_dapm_widget *w; in dapm_mark_endpoints_dirty() local
307 for_each_card_widgets(card, w) { in dapm_mark_endpoints_dirty()
308 if (w->is_ep) { in dapm_mark_endpoints_dirty()
309 dapm_mark_dirty(w, "Rechecking endpoints"); in dapm_mark_endpoints_dirty()
310 if (w->is_ep & SND_SOC_DAPM_EP_SINK) in dapm_mark_endpoints_dirty()
311 dapm_widget_invalidate_output_paths(w); in dapm_mark_endpoints_dirty()
312 if (w->is_ep & SND_SOC_DAPM_EP_SOURCE) in dapm_mark_endpoints_dirty()
313 dapm_widget_invalidate_input_paths(w); in dapm_mark_endpoints_dirty()
325 struct snd_soc_dapm_widget *w; in dapm_cnew_widget() local
327 w = kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); in dapm_cnew_widget()
328 if (!w) in dapm_cnew_widget()
332 * w->name is duplicated in caller, but w->sname isn't. 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()
338 kfree(w); in dapm_cnew_widget()
342 return w; in dapm_cnew_widget()
390 template.mask = (1 << fls(mc->max)) - 1; in dapm_kcontrol_data_alloc()
490 n = data->wlist->num_widgets + 1; in dapm_kcontrol_add_widget()
492 n = 1; in dapm_kcontrol_add_widget()
500 new_wlist->widgets[n - 1] = widget; in dapm_kcontrol_add_widget()
605 struct snd_soc_dapm_widget *w; in dapm_reset() local
611 for_each_card_widgets(card, w) { in dapm_reset()
612 w->new_power = w->power; in dapm_reset()
613 w->power_checked = false; in dapm_reset()
655 dapm_wcache_lookup(struct snd_soc_dapm_widget *w, const char *name) in dapm_wcache_lookup() argument
657 if (w) { in dapm_wcache_lookup()
658 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
662 list_for_each_entry_from(w, wlist, list) { in dapm_wcache_lookup()
663 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
664 return w; in dapm_wcache_lookup()
743 struct snd_soc_dapm_widget *w) in dapm_connect_mux() argument
745 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
787 unsigned int mask = (1 << fls(max)) - 1; in dapm_set_mixer_path_status()
845 struct snd_soc_dapm_widget *w; in dapm_is_shared_kcontrol() local
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()
857 return 1; in dapm_is_shared_kcontrol()
869 static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, in dapm_create_or_share_kcontrol() argument
872 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol()
885 prefix_len = strlen(prefix) + 1; 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()
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()
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()
953 ret = dapm_kcontrol_data_alloc(w, kcontrol, name); in dapm_create_or_share_kcontrol()
963 w->name, name, ret); in dapm_create_or_share_kcontrol()
968 ret = dapm_kcontrol_add_widget(kcontrol, w); in dapm_create_or_share_kcontrol()
970 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
979 static int dapm_new_mixer(struct snd_soc_dapm_widget *w) in dapm_new_mixer() argument
986 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
988 snd_soc_dapm_widget_for_each_source_path(w, path) { 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()
994 ret = dapm_create_or_share_kcontrol(w, 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()
1014 static int dapm_new_mux(struct snd_soc_dapm_widget *w) in dapm_new_mux() argument
1016 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1022 switch (w->id) { in dapm_new_mux()
1035 if (w->num_kcontrols != 1) { in dapm_new_mux()
1038 w->name); 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()
1047 ret = dapm_create_or_share_kcontrol(w, 0); in dapm_new_mux()
1051 snd_soc_dapm_widget_for_each_path(w, dir, path) { in dapm_new_mux()
1053 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1060 static int dapm_new_pga(struct snd_soc_dapm_widget *w) in dapm_new_pga() argument
1064 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1065 int ret = dapm_create_or_share_kcontrol(w, i); in dapm_new_pga()
1074 static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) in dapm_new_dai_link() argument
1077 struct snd_soc_pcm_runtime *rtd = w->priv; in dapm_new_dai_link()
1079 /* create control for links with > 1 config */ 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()
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()
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()
1120 return 1; in snd_soc_dapm_suspend_check()
1132 struct snd_soc_dapm_widget *w; in dapm_widget_list_create() local
1144 list_for_each_entry(w, widgets, work_list) in dapm_widget_list_create()
1145 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1163 widget->endpoints[dir] = -1; in invalidate_paths_ep()
1173 path->walking = 1; in invalidate_paths_ep()
1225 return 1; in is_connected_ep()
1230 path->walking = 1; in is_connected_ep()
1302 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream); in snd_soc_dapm_dai_get_connected_widgets() local
1310 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); in snd_soc_dapm_dai_get_connected_widgets()
1311 paths = is_connected_output_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1314 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_IN); in snd_soc_dapm_dai_get_connected_widgets()
1315 paths = is_connected_input_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1342 int dapm_regulator_event(struct snd_soc_dapm_widget *w, in dapm_regulator_event() argument
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()
1376 int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, in dapm_pinctrl_event() argument
1379 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in dapm_pinctrl_event()
1380 struct pinctrl *p = w->pinctrl; in dapm_pinctrl_event()
1401 int dapm_clock_event(struct snd_soc_dapm_widget *w, in dapm_clock_event() argument
1404 if (!w->clk) 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()
1420 static int dapm_widget_power_check(struct snd_soc_dapm_widget *w) in dapm_widget_power_check() argument
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()
1436 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) in dapm_generic_check_power() argument
1440 DAPM_UPDATE_STAT(w, power_checks); in dapm_generic_check_power()
1442 in = is_connected_input_ep(w, NULL, NULL); in dapm_generic_check_power()
1443 out = is_connected_output_ep(w, NULL, NULL); in dapm_generic_check_power()
1448 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) in dapm_supply_check_power() argument
1452 DAPM_UPDATE_STAT(w, power_checks); in dapm_supply_check_power()
1455 snd_soc_dapm_widget_for_each_sink_path(w, path) { in dapm_supply_check_power()
1456 DAPM_UPDATE_STAT(w, neighbour_checks); in dapm_supply_check_power()
1466 return 1; in dapm_supply_check_power()
1472 static int dapm_always_on_check_power(struct snd_soc_dapm_widget *w) in dapm_always_on_check_power() argument
1474 return w->connected; in dapm_always_on_check_power()
1515 struct snd_soc_dapm_widget *w; in dapm_seq_insert() local
1517 list_for_each_entry(w, list, power_list) in dapm_seq_insert()
1518 if (dapm_seq_compare(new_widget, w, power_up) < 0) { in dapm_seq_insert()
1519 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1527 struct snd_soc_dapm_widget *w, int event) in dapm_seq_check_event() argument
1535 power = 1; in dapm_seq_check_event()
1539 power = 1; in dapm_seq_check_event()
1551 power = 1; in dapm_seq_check_event()
1558 WARN(1, "Unknown event %d\n", event); in dapm_seq_check_event()
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()
1571 trace_snd_soc_dapm_widget_event_start(w, event); in dapm_seq_check_event()
1572 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1573 trace_snd_soc_dapm_widget_event_done(w, 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()
1585 struct snd_soc_dapm_widget *w; in dapm_seq_run_coalesced() local
1590 w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list); in dapm_seq_run_coalesced()
1591 reg = w->reg; in dapm_seq_run_coalesced()
1592 dapm = w->dapm; in dapm_seq_run_coalesced()
1594 list_for_each_entry(w, pending, power_list) { 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()
1606 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1609 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU); in dapm_seq_run_coalesced()
1610 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMD); in dapm_seq_run_coalesced()
1625 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1626 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU); in dapm_seq_run_coalesced()
1627 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD); in dapm_seq_run_coalesced()
1642 struct snd_soc_dapm_widget *w, *n; in dapm_seq_run() local
1645 int cur_sort = -1; in dapm_seq_run()
1646 int cur_subseq = -1; in dapm_seq_run()
1657 list_for_each_entry_safe(w, n, list, power_list) { 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()
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()
1743 struct snd_soc_dapm_widget *w = NULL; in dapm_widget_update() local
1752 for_each_dapm_widgets(wlist, wi, w) { 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()
1761 if (!w) in dapm_widget_update()
1764 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, 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()
1771 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1774 dev_err(w->dapm->dev, in dapm_widget_update()
1776 w->name, ret); in dapm_widget_update()
1779 for_each_dapm_widgets(wlist, wi, w) { 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()
1876 static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, in dapm_power_one_widget() argument
1883 switch (w->id) { in dapm_power_one_widget()
1888 power = 1; in dapm_power_one_widget()
1894 power = dapm_widget_power_check(w); in dapm_power_one_widget()
1896 if (w->power == power) in dapm_power_one_widget()
1899 trace_snd_soc_dapm_widget_power(w, power); in dapm_power_one_widget()
1905 snd_soc_dapm_widget_for_each_source_path(w, path) in dapm_power_one_widget()
1911 if (!w->is_supply) in dapm_power_one_widget()
1912 snd_soc_dapm_widget_for_each_sink_path(w, path) in dapm_power_one_widget()
1917 dapm_seq_insert(w, up_list, true); in dapm_power_one_widget()
1919 dapm_seq_insert(w, down_list, false); in dapm_power_one_widget()
1949 struct snd_soc_dapm_widget *w; in dapm_power_widgets() local
1976 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1977 dapm_power_one_widget(w, &up_list, &down_list); in dapm_power_widgets()
1980 for_each_card_widgets(card, w) { 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()
2044 list_for_each_entry(w, &down_list, power_list) { in dapm_power_widgets()
2045 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMD); in dapm_power_widgets()
2048 list_for_each_entry(w, &up_list, power_list) { in dapm_power_widgets()
2049 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMU); in dapm_power_widgets()
2094 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file() local
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()
2112 in = is_connected_input_ep(w, NULL, NULL); in dapm_widget_power_read_file()
2113 out = is_connected_output_ep(w, NULL, NULL); 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()
2123 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2127 if (w->sname) 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()
2134 snd_soc_dapm_widget_for_each_path(w, dir, p) { in dapm_widget_power_read_file()
2149 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2183 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2210 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
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()
2221 static void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_free_widget() argument
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()
2243 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2247 static inline void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_free_widget() argument
2288 found = 1; in soc_dapm_mux_update_power()
2342 * and all remaining paths (when 'found == 1') are the in soc_dapm_mixer_update_power()
2360 found = 1; in soc_dapm_mixer_update_power()
2378 ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1); in snd_soc_dapm_mixer_update_power()
2391 struct snd_soc_dapm_widget *w; in dapm_widget_show_component() local
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()
2490 * @w: widget to free
2494 void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) in snd_soc_dapm_free_widget() argument
2499 if (!w) in snd_soc_dapm_free_widget()
2502 list_del(&w->list); in snd_soc_dapm_free_widget()
2503 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2510 snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) in snd_soc_dapm_free_widget()
2514 dapm_debugfs_free_widget(w); 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()
2519 kfree(w); in snd_soc_dapm_free_widget()
2526 struct snd_soc_dapm_widget *w, *next_w; in dapm_free_widgets() local
2528 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2529 if (w->dapm != dapm) in dapm_free_widgets()
2531 snd_soc_dapm_free_widget(w); in dapm_free_widgets()
2542 struct snd_soc_dapm_widget *w; in dapm_find_widget() local
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()
2559 return w; in dapm_find_widget()
2561 fallback = w; in dapm_find_widget()
2573 * returns 1 when the value has been updated, 0 when unchanged, or a negative
2579 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in __snd_soc_dapm_set_pin() local
2584 if (!w) { in __snd_soc_dapm_set_pin()
2589 if (w->connected != status) { in __snd_soc_dapm_set_pin()
2590 dapm_mark_dirty(w, "pin configuration"); in __snd_soc_dapm_set_pin()
2591 dapm_widget_invalidate_input_paths(w); in __snd_soc_dapm_set_pin()
2592 dapm_widget_invalidate_output_paths(w); in __snd_soc_dapm_set_pin()
2593 ret = 1; 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()
2660 struct snd_soc_dapm_widget *w, 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()
2675 if (w->channel < channels) in dapm_update_dai_chan()
2690 struct snd_soc_dapm_widget *w; in dapm_update_dai_unlocked() local
2693 w = snd_soc_dai_get_widget(dai, dir); in dapm_update_dai_unlocked()
2695 if (!w) in dapm_update_dai_unlocked()
2701 snd_soc_dapm_widget_for_each_sink_path(w, p) { in dapm_update_dai_unlocked()
2707 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_dai_unlocked()
2737 wname += strlen(component->name_prefix) + 1; /* plus space */ in snd_soc_dapm_widget_name_cmp()
2745 * @w: The widget for which to update the flags
2752 static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) in dapm_update_widget_flags() argument
2758 switch (w->id) { in dapm_update_widget_flags()
2761 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2764 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_widget_flags()
2776 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2779 snd_soc_dapm_widget_for_each_sink_path(w, p) { 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()
2894 path->is_supply = 1; in snd_soc_dapm_add_path()
2898 path->connect = 1; in snd_soc_dapm_add_path()
2950 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; in snd_soc_dapm_add_route() local
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()
2986 wtsink = w; in snd_soc_dapm_add_route()
2987 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2988 wsink = w; in snd_soc_dapm_add_route()
2993 if (sink_ref > 1) 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()
3000 wtsource = w; in snd_soc_dapm_add_route()
3001 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3002 wsource = w; in snd_soc_dapm_add_route()
3007 if (source_ref > 1) in snd_soc_dapm_add_route()
3010 w->name); in snd_soc_dapm_add_route()
3189 path->weak = 1; in snd_soc_dapm_weak_route()
3197 if (count > 1) in snd_soc_dapm_weak_route()
3249 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_widgets() local
3254 for_each_card_widgets(card, w) in snd_soc_dapm_new_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()
3269 switch(w->id) { in snd_soc_dapm_new_widgets()
3273 dapm_new_mixer(w); in snd_soc_dapm_new_widgets()
3277 dapm_new_mux(w); in snd_soc_dapm_new_widgets()
3282 dapm_new_pga(w); in snd_soc_dapm_new_widgets()
3285 dapm_new_dai_link(w); 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()
3302 dapm_mark_dirty(w, "new widget"); in snd_soc_dapm_new_widgets()
3303 dapm_debugfs_add_widget(w); in snd_soc_dapm_new_widgets()
3331 unsigned int mask = (1 << fls(max)) - 1; 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()
3390 unsigned int mask = (1 << width) - 1; in snd_soc_dapm_put_volsw()
3393 int connect, rconnect = -1, change, reg_change = 0; in snd_soc_dapm_put_volsw()
3404 rval = (ucontrol->value.integer.value[1] & mask); in snd_soc_dapm_put_volsw()
3490 ucontrol->value.enumerated.item[1] = val; in snd_soc_dapm_get_enum_double()
3524 if (item[1] > e->items) 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()
3572 uinfo->count = 1; in snd_soc_dapm_info_pin_switch()
3574 uinfo->value.integer.max = 1; in snd_soc_dapm_info_pin_switch()
3631 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control_unlocked() local
3635 if ((w = dapm_cnew_widget(widget)) == NULL) 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()
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()
3670 dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD); 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()
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()
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()
3764 return w; 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()
3772 kfree(w); in snd_soc_dapm_new_control_unlocked()
3790 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control() local
3793 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3796 return w; in snd_soc_dapm_new_control()
3819 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls() local
3820 if (IS_ERR(w)) { in snd_soc_dapm_new_controls()
3821 ret = PTR_ERR(w); in snd_soc_dapm_new_controls()
3832 snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event_pre_pmu() argument
3866 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3877 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3887 substream->hw_opened = 1; 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()
3903 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
3909 fmt = ffs(config->formats) - 1; in snd_soc_dai_link_event_pre_pmu()
3922 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3933 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3955 static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event() argument
3960 struct snd_pcm_substream *substream = w->priv; 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()
3969 ret = snd_soc_dai_link_event_pre_pmu(w, substream); in snd_soc_dai_link_event()
3976 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3985 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3988 snd_soc_dai_digital_mute(sink, 1, SNDRV_PCM_STREAM_PLAYBACK); in snd_soc_dai_link_event()
3993 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
3999 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4005 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
4012 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4025 WARN(1, "Unknown event %d\n", event); in snd_soc_dai_link_event()
4038 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_get() local
4039 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get()
4049 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_put() local
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()
4064 return 1; in snd_soc_dapm_dai_link_put()
4116 strlen(config->stream_name) + 1, in snd_soc_dapm_alloc_kcontrol()
4160 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai() local
4177 if (rtd->dai_link->num_c2c_params > 1) { in snd_soc_dapm_new_dai()
4184 num_kcontrols = 1; in snd_soc_dapm_new_dai()
4205 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4206 if (IS_ERR(w)) { in snd_soc_dapm_new_dai()
4207 ret = PTR_ERR(w); in snd_soc_dapm_new_dai()
4211 w->priv = substream; in snd_soc_dapm_new_dai()
4213 return w; in snd_soc_dapm_new_dai()
4238 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai_widgets() local
4253 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4254 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4255 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4257 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4258 snd_soc_dai_set_widget_playback(dai, w); in snd_soc_dapm_new_dai_widgets()
4269 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4270 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4271 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4273 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4274 snd_soc_dai_set_widget_capture(dai, w); in snd_soc_dapm_new_dai_widgets()
4283 struct snd_soc_dapm_widget *dai_w, *w; in snd_soc_dapm_link_dai_widgets() local
4307 for_each_card_widgets(card, w) { 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()
4324 sink = w; in snd_soc_dapm_link_dai_widgets()
4326 src = w; 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()
4404 struct snd_soc_dapm_widget *w; in soc_dapm_dai_stream_event() local
4406 w = snd_soc_dai_get_widget(dai, stream); in soc_dapm_dai_stream_event()
4408 if (w) { in soc_dapm_dai_stream_event()
4411 dapm_mark_dirty(w, "stream event"); in soc_dapm_dai_stream_event()
4413 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4415 dapm_widget_invalidate_input_paths(w); in soc_dapm_dai_stream_event()
4418 dapm_widget_invalidate_output_paths(w); 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()
4454 if (rtd->dai_link->num_cpus == 1) { in snd_soc_dapm_connect_dai_link_widgets()
4534 rtd->pop_wait = 1; in snd_soc_dapm_stream_stop()
4563 return snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin_unlocked()
4584 ret = snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin()
4609 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked() local
4611 if (!w) { 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()
4622 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
4623 dapm_widget_invalidate_output_paths(w); 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()
4627 dapm_mark_dirty(w, "force enable"); in snd_soc_dapm_force_enable_pin_unlocked()
4762 * Returns 1 for connected otherwise 0.
4767 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status() local
4769 if (w) in snd_soc_dapm_get_pin_status()
4770 return w->connected; in snd_soc_dapm_get_pin_status()
4790 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend() local
4792 if (!w) { in snd_soc_dapm_ignore_suspend()
4797 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4842 struct snd_soc_dapm_widget *w; in soc_dapm_shutdown_dapm() local
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()
4852 dapm_seq_insert(w, &down_list, false); in soc_dapm_shutdown_dapm()
4853 w->new_power = 0; in soc_dapm_shutdown_dapm()
4854 powerdown = 1; in soc_dapm_shutdown_dapm()