Lines Matching full:w

181 static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w)  in dapm_dirty_widget()  argument
183 return !list_empty(&w->dirty); in dapm_dirty_widget()
186 static void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason) in dapm_mark_dirty() argument
188 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
190 if (!dapm_dirty_widget(w)) { in dapm_mark_dirty()
191 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
192 w->name, reason); in dapm_mark_dirty()
193 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
205 struct snd_soc_dapm_widget *w, enum snd_soc_dapm_direction dir) in dapm_widget_invalidate_paths() argument
212 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_paths()
214 if (w->endpoints[dir] == -1) in dapm_widget_invalidate_paths()
217 list_add_tail(&w->work_list, &list); in dapm_widget_invalidate_paths()
218 w->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
220 list_for_each_entry(w, &list, work_list) { in dapm_widget_invalidate_paths()
221 snd_soc_dapm_widget_for_each_path(w, dir, p) { in dapm_widget_invalidate_paths()
236 * @w: The widget for which to invalidate the cached number of input paths
245 static void dapm_widget_invalidate_input_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_input_paths() argument
247 dapm_widget_invalidate_paths(w, SND_SOC_DAPM_DIR_IN); in dapm_widget_invalidate_input_paths()
253 * @w: The widget for which to invalidate the cached number of output paths
262 static void dapm_widget_invalidate_output_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_output_paths() argument
264 dapm_widget_invalidate_paths(w, SND_SOC_DAPM_DIR_OUT); in dapm_widget_invalidate_output_paths()
301 struct snd_soc_dapm_widget *w; in dapm_mark_endpoints_dirty() local
305 for_each_card_widgets(card, w) { in dapm_mark_endpoints_dirty()
306 if (w->is_ep) { in dapm_mark_endpoints_dirty()
307 dapm_mark_dirty(w, "Rechecking endpoints"); in dapm_mark_endpoints_dirty()
308 if (w->is_ep & SND_SOC_DAPM_EP_SINK) in dapm_mark_endpoints_dirty()
309 dapm_widget_invalidate_output_paths(w); in dapm_mark_endpoints_dirty()
310 if (w->is_ep & SND_SOC_DAPM_EP_SOURCE) in dapm_mark_endpoints_dirty()
311 dapm_widget_invalidate_input_paths(w); in dapm_mark_endpoints_dirty()
323 struct snd_soc_dapm_widget *w; in dapm_cnew_widget() local
325 w = kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); in dapm_cnew_widget()
326 if (!w) in dapm_cnew_widget()
330 * w->name is duplicated in caller, but w->sname isn't. in dapm_cnew_widget()
334 w->sname = kstrdup_const(_widget->sname, GFP_KERNEL); in dapm_cnew_widget()
335 if (!w->sname) { in dapm_cnew_widget()
336 kfree(w); in dapm_cnew_widget()
340 return w; in dapm_cnew_widget()
600 struct snd_soc_dapm_widget *w; in dapm_reset() local
606 for_each_card_widgets(card, w) { in dapm_reset()
607 w->new_power = w->power; in dapm_reset()
608 w->power_checked = false; in dapm_reset()
652 struct snd_soc_dapm_widget *w = wcache->widget; in dapm_wcache_lookup() local
654 if (w) { in dapm_wcache_lookup()
655 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
659 list_for_each_entry_from(w, wlist, list) { in dapm_wcache_lookup()
660 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
661 return w; in dapm_wcache_lookup()
672 struct snd_soc_dapm_widget *w) in dapm_wcache_update() argument
674 wcache->widget = w; in dapm_wcache_update()
746 struct snd_soc_dapm_widget *w) in dapm_connect_mux() argument
748 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
848 struct snd_soc_dapm_widget *w; in dapm_is_shared_kcontrol() local
853 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
854 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
856 for (i = 0; i < w->num_kcontrols; i++) { in dapm_is_shared_kcontrol()
857 if (&w->kcontrol_news[i] == kcontrol_new) { in dapm_is_shared_kcontrol()
858 if (w->kcontrols) in dapm_is_shared_kcontrol()
859 *kcontrol = w->kcontrols[i]; in dapm_is_shared_kcontrol()
872 static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, in dapm_create_or_share_kcontrol() argument
875 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol()
892 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
900 switch (w->id) { in dapm_create_or_share_kcontrol()
931 w->name + prefix_len, in dapm_create_or_share_kcontrol()
932 w->kcontrol_news[kci].name); in dapm_create_or_share_kcontrol()
939 name = w->name + prefix_len; in dapm_create_or_share_kcontrol()
942 name = w->kcontrol_news[kci].name; in dapm_create_or_share_kcontrol()
945 kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name, in dapm_create_or_share_kcontrol()
954 ret = dapm_kcontrol_data_alloc(w, kcontrol, name); in dapm_create_or_share_kcontrol()
964 w->name, name, ret); in dapm_create_or_share_kcontrol()
969 ret = dapm_kcontrol_add_widget(kcontrol, w); in dapm_create_or_share_kcontrol()
971 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
980 static int dapm_new_mixer(struct snd_soc_dapm_widget *w) in dapm_new_mixer() argument
987 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
989 snd_soc_dapm_widget_for_each_source_path(w, path) { in dapm_new_mixer()
991 if (path->name != (char *)w->kcontrol_news[i].name) in dapm_new_mixer()
994 if (!w->kcontrols[i]) { in dapm_new_mixer()
995 ret = dapm_create_or_share_kcontrol(w, i); in dapm_new_mixer()
1000 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
1002 data = snd_kcontrol_chip(w->kcontrols[i]); in dapm_new_mixer()
1015 static int dapm_new_mux(struct snd_soc_dapm_widget *w) in dapm_new_mux() argument
1017 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1023 switch (w->id) { in dapm_new_mux()
1036 if (w->num_kcontrols != 1) { in dapm_new_mux()
1039 w->name); in dapm_new_mux()
1043 if (list_empty(&w->edges[dir])) { in dapm_new_mux()
1044 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1048 ret = dapm_create_or_share_kcontrol(w, 0); in dapm_new_mux()
1052 snd_soc_dapm_widget_for_each_path(w, dir, path) { in dapm_new_mux()
1054 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1061 static int dapm_new_pga(struct snd_soc_dapm_widget *w) in dapm_new_pga() argument
1065 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1066 int ret = dapm_create_or_share_kcontrol(w, i); in dapm_new_pga()
1075 static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) in dapm_new_dai_link() argument
1078 struct snd_soc_pcm_runtime *rtd = w->priv; in dapm_new_dai_link()
1085 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_dai_link()
1086 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link()
1088 struct snd_kcontrol *kcontrol = snd_soc_cnew(&w->kcontrol_news[i], in dapm_new_dai_link()
1089 w, w->name, NULL); in dapm_new_dai_link()
1095 w->name, w->kcontrol_news[i].name, ret); in dapm_new_dai_link()
1098 kcontrol->private_data = w; in dapm_new_dai_link()
1099 w->kcontrols[i] = kcontrol; in dapm_new_dai_link()
1133 struct snd_soc_dapm_widget *w; in dapm_widget_list_create() local
1145 list_for_each_entry(w, widgets, work_list) in dapm_widget_list_create()
1146 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1303 struct snd_soc_dapm_widget *w; in snd_soc_dapm_dai_get_connected_widgets() local
1311 w = dai->playback_widget; in snd_soc_dapm_dai_get_connected_widgets()
1312 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); in snd_soc_dapm_dai_get_connected_widgets()
1313 paths = is_connected_output_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1316 w = dai->capture_widget; in snd_soc_dapm_dai_get_connected_widgets()
1317 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_IN); in snd_soc_dapm_dai_get_connected_widgets()
1318 paths = is_connected_input_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1343 int dapm_regulator_event(struct snd_soc_dapm_widget *w, in dapm_regulator_event() argument
1348 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1351 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1352 ret = regulator_allow_bypass(w->regulator, false); in dapm_regulator_event()
1354 dev_warn(w->dapm->dev, in dapm_regulator_event()
1356 w->name, ret); in dapm_regulator_event()
1359 return regulator_enable(w->regulator); in dapm_regulator_event()
1361 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1362 ret = regulator_allow_bypass(w->regulator, true); in dapm_regulator_event()
1364 dev_warn(w->dapm->dev, in dapm_regulator_event()
1366 w->name, ret); in dapm_regulator_event()
1369 return regulator_disable_deferred(w->regulator, w->shift); in dapm_regulator_event()
1377 int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, in dapm_pinctrl_event() argument
1380 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in dapm_pinctrl_event()
1381 struct pinctrl *p = w->pinctrl; in dapm_pinctrl_event()
1402 int dapm_clock_event(struct snd_soc_dapm_widget *w, in dapm_clock_event() argument
1405 if (!w->clk) in dapm_clock_event()
1408 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1411 return clk_prepare_enable(w->clk); in dapm_clock_event()
1413 clk_disable_unprepare(w->clk); in dapm_clock_event()
1421 static int dapm_widget_power_check(struct snd_soc_dapm_widget *w) in dapm_widget_power_check() argument
1423 if (w->power_checked) in dapm_widget_power_check()
1424 return w->new_power; in dapm_widget_power_check()
1426 if (w->force) in dapm_widget_power_check()
1427 w->new_power = 1; in dapm_widget_power_check()
1429 w->new_power = w->power_check(w); in dapm_widget_power_check()
1431 w->power_checked = true; in dapm_widget_power_check()
1433 return w->new_power; in dapm_widget_power_check()
1437 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) in dapm_generic_check_power() argument
1441 DAPM_UPDATE_STAT(w, power_checks); in dapm_generic_check_power()
1443 in = is_connected_input_ep(w, NULL, NULL); in dapm_generic_check_power()
1444 out = is_connected_output_ep(w, NULL, NULL); in dapm_generic_check_power()
1449 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) in dapm_supply_check_power() argument
1453 DAPM_UPDATE_STAT(w, power_checks); in dapm_supply_check_power()
1456 snd_soc_dapm_widget_for_each_sink_path(w, path) { in dapm_supply_check_power()
1457 DAPM_UPDATE_STAT(w, neighbour_checks); in dapm_supply_check_power()
1473 static int dapm_always_on_check_power(struct snd_soc_dapm_widget *w) in dapm_always_on_check_power() argument
1475 return w->connected; in dapm_always_on_check_power()
1516 struct snd_soc_dapm_widget *w; in dapm_seq_insert() local
1518 list_for_each_entry(w, list, power_list) in dapm_seq_insert()
1519 if (dapm_seq_compare(new_widget, w, power_up) < 0) { in dapm_seq_insert()
1520 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1528 struct snd_soc_dapm_widget *w, int event) in dapm_seq_check_event() argument
1563 if (w->new_power != power) in dapm_seq_check_event()
1566 if (w->event && (w->event_flags & event)) { in dapm_seq_check_event()
1569 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1570 w->name, ev_name); in dapm_seq_check_event()
1571 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1572 trace_snd_soc_dapm_widget_event_start(w, event); in dapm_seq_check_event()
1573 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1574 trace_snd_soc_dapm_widget_event_done(w, event); in dapm_seq_check_event()
1576 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1577 ev_name, w->name, ret); in dapm_seq_check_event()
1586 struct snd_soc_dapm_widget *w; in dapm_seq_run_coalesced() local
1591 w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list); in dapm_seq_run_coalesced()
1592 reg = w->reg; in dapm_seq_run_coalesced()
1593 dapm = w->dapm; in dapm_seq_run_coalesced()
1595 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1596 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1597 w->power = w->new_power; in dapm_seq_run_coalesced()
1599 mask |= w->mask << w->shift; in dapm_seq_run_coalesced()
1600 if (w->power) in dapm_seq_run_coalesced()
1601 value |= w->on_val << w->shift; in dapm_seq_run_coalesced()
1603 value |= w->off_val << w->shift; in dapm_seq_run_coalesced()
1607 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1610 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU); in dapm_seq_run_coalesced()
1611 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMD); in dapm_seq_run_coalesced()
1626 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1627 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU); in dapm_seq_run_coalesced()
1628 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD); in dapm_seq_run_coalesced()
1643 struct snd_soc_dapm_widget *w, *n; in dapm_seq_run() local
1658 list_for_each_entry_safe(w, n, list, power_list) { in dapm_seq_run()
1662 if (sort[w->id] != cur_sort || w->reg != cur_reg || in dapm_seq_run()
1663 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1675 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1685 switch (w->id) { in dapm_seq_run()
1687 if (!w->event) in dapm_seq_run()
1688 list_for_each_entry_safe_continue(w, n, list, in dapm_seq_run()
1692 ret = w->event(w, in dapm_seq_run()
1695 ret = w->event(w, in dapm_seq_run()
1700 if (!w->event) in dapm_seq_run()
1701 list_for_each_entry_safe_continue(w, n, list, in dapm_seq_run()
1705 ret = w->event(w, in dapm_seq_run()
1708 ret = w->event(w, in dapm_seq_run()
1714 cur_sort = sort[w->id]; in dapm_seq_run()
1715 cur_subseq = w->subseq; in dapm_seq_run()
1716 cur_reg = w->reg; in dapm_seq_run()
1717 cur_dapm = w->dapm; in dapm_seq_run()
1718 list_move(&w->power_list, &pending); in dapm_seq_run()
1723 dev_err(w->dapm->dev, in dapm_seq_run()
1746 struct snd_soc_dapm_widget *w = NULL; in dapm_widget_update() local
1755 for_each_dapm_widgets(wlist, wi, w) { in dapm_widget_update()
1756 if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) { in dapm_widget_update()
1757 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); in dapm_widget_update()
1759 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1760 w->name, ret); in dapm_widget_update()
1764 if (!w) in dapm_widget_update()
1767 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1770 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1771 w->name, ret); in dapm_widget_update()
1774 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1777 dev_err(w->dapm->dev, in dapm_widget_update()
1779 w->name, ret); in dapm_widget_update()
1782 for_each_dapm_widgets(wlist, wi, w) { in dapm_widget_update()
1783 if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) { in dapm_widget_update()
1784 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); in dapm_widget_update()
1786 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1787 w->name, ret); in dapm_widget_update()
1879 static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, in dapm_widget_set_power() argument
1885 if (w->power == power) in dapm_widget_set_power()
1888 trace_snd_soc_dapm_widget_power(w, power); in dapm_widget_set_power()
1893 snd_soc_dapm_widget_for_each_source_path(w, path) in dapm_widget_set_power()
1897 if (!w->is_supply) { in dapm_widget_set_power()
1898 snd_soc_dapm_widget_for_each_sink_path(w, path) in dapm_widget_set_power()
1904 dapm_seq_insert(w, up_list, true); in dapm_widget_set_power()
1906 dapm_seq_insert(w, down_list, false); in dapm_widget_set_power()
1909 static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, in dapm_power_one_widget() argument
1915 switch (w->id) { in dapm_power_one_widget()
1917 dapm_seq_insert(w, down_list, false); in dapm_power_one_widget()
1920 dapm_seq_insert(w, up_list, true); in dapm_power_one_widget()
1924 power = dapm_widget_power_check(w); in dapm_power_one_widget()
1926 dapm_widget_set_power(w, power, up_list, down_list); in dapm_power_one_widget()
1958 struct snd_soc_dapm_widget *w; in dapm_power_widgets() local
1985 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1986 dapm_power_one_widget(w, &up_list, &down_list); in dapm_power_widgets()
1989 for_each_card_widgets(card, w) { in dapm_power_widgets()
1990 switch (w->id) { in dapm_power_widgets()
1996 list_del_init(&w->dirty); in dapm_power_widgets()
2000 if (w->new_power) { in dapm_power_widgets()
2001 d = w->dapm; in dapm_power_widgets()
2010 switch (w->id) { in dapm_power_widgets()
2053 list_for_each_entry(w, &down_list, power_list) { in dapm_power_widgets()
2054 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMD); in dapm_power_widgets()
2057 list_for_each_entry(w, &up_list, power_list) { in dapm_power_widgets()
2058 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMU); in dapm_power_widgets()
2103 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file() local
2104 struct snd_soc_card *card = w->dapm->card; in dapm_widget_power_read_file()
2118 if (w->is_supply) { in dapm_widget_power_read_file()
2122 in = is_connected_input_ep(w, NULL, NULL); in dapm_widget_power_read_file()
2123 out = is_connected_output_ep(w, NULL, NULL); in dapm_widget_power_read_file()
2127 w->name, w->power ? "On" : "Off", in dapm_widget_power_read_file()
2128 w->force ? " (forced)" : "", in, out); in dapm_widget_power_read_file()
2130 if (w->reg >= 0) in dapm_widget_power_read_file()
2133 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2137 if (w->sname) in dapm_widget_power_read_file()
2139 w->sname, in dapm_widget_power_read_file()
2140 w->active ? "active" : "inactive"); in dapm_widget_power_read_file()
2144 snd_soc_dapm_widget_for_each_path(w, dir, p) { in dapm_widget_power_read_file()
2220 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2222 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget()
2224 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2227 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2243 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2387 struct snd_soc_dapm_widget *w; in dapm_widget_show_component() local
2398 for_each_card_widgets(cmpnt->card, w) { in dapm_widget_show_component()
2399 if (w->dapm != dapm) in dapm_widget_show_component()
2403 switch (w->id) { in dapm_widget_show_component()
2420 if (w->name) in dapm_widget_show_component()
2422 w->name, w->power ? "On":"Off"); in dapm_widget_show_component()
2485 void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) in snd_soc_dapm_free_widget() argument
2490 list_del(&w->list); in snd_soc_dapm_free_widget()
2491 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2498 snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) in snd_soc_dapm_free_widget()
2502 kfree(w->kcontrols); in snd_soc_dapm_free_widget()
2503 kfree_const(w->name); in snd_soc_dapm_free_widget()
2504 kfree_const(w->sname); in snd_soc_dapm_free_widget()
2505 kfree(w); in snd_soc_dapm_free_widget()
2517 struct snd_soc_dapm_widget *w, *next_w; in dapm_free_widgets() local
2519 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2520 if (w->dapm != dapm) in dapm_free_widgets()
2522 snd_soc_dapm_free_widget(w); in dapm_free_widgets()
2531 struct snd_soc_dapm_widget *w; in dapm_find_widget() local
2545 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2546 if (!strcmp(w->name, pin_name)) { in dapm_find_widget()
2547 if (w->dapm == dapm) in dapm_find_widget()
2548 return w; in dapm_find_widget()
2550 fallback = w; in dapm_find_widget()
2563 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_set_pin() local
2568 if (!w) { in snd_soc_dapm_set_pin()
2573 if (w->connected != status) { in snd_soc_dapm_set_pin()
2574 dapm_mark_dirty(w, "pin configuration"); in snd_soc_dapm_set_pin()
2575 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_set_pin()
2576 dapm_widget_invalidate_output_paths(w); in snd_soc_dapm_set_pin()
2580 w->connected = status; in snd_soc_dapm_set_pin()
2582 w->force = 0; in snd_soc_dapm_set_pin()
2632 struct snd_soc_dapm_widget *w, in dapm_update_dai_chan() argument
2635 switch (w->id) { in dapm_update_dai_chan()
2643 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2644 w->channel < channels ? "Connecting" : "Disconnecting", in dapm_update_dai_chan()
2647 if (w->channel < channels) in dapm_update_dai_chan()
2662 struct snd_soc_dapm_widget *w; in dapm_update_dai_unlocked() local
2665 w = snd_soc_dai_get_widget(dai, dir); in dapm_update_dai_unlocked()
2667 if (!w) in dapm_update_dai_unlocked()
2673 snd_soc_dapm_widget_for_each_sink_path(w, p) { in dapm_update_dai_unlocked()
2679 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_dai_unlocked()
2705 * @w: The widget for which to update the flags
2712 static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) in dapm_update_widget_flags() argument
2718 switch (w->id) { in dapm_update_widget_flags()
2721 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2724 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_widget_flags()
2736 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2739 snd_soc_dapm_widget_for_each_sink_path(w, p) { in dapm_update_widget_flags()
2752 if (!list_empty(&w->edges[dir])) in dapm_update_widget_flags()
2760 w->is_ep = ep; in dapm_update_widget_flags()
2912 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; in snd_soc_dapm_add_route() local
2946 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
2947 if (!wsink && !(strcmp(w->name, sink))) { in snd_soc_dapm_add_route()
2948 wtsink = w; in snd_soc_dapm_add_route()
2949 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2950 wsink = w; in snd_soc_dapm_add_route()
2958 w->name); in snd_soc_dapm_add_route()
2961 if (!wsource && !(strcmp(w->name, source))) { in snd_soc_dapm_add_route()
2962 wtsource = w; in snd_soc_dapm_add_route()
2963 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2964 wsource = w; in snd_soc_dapm_add_route()
2972 w->name); in snd_soc_dapm_add_route()
3219 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_widgets() local
3224 for_each_card_widgets(card, w) in snd_soc_dapm_new_widgets()
3226 if (w->new) in snd_soc_dapm_new_widgets()
3229 if (w->num_kcontrols) { in snd_soc_dapm_new_widgets()
3230 w->kcontrols = kcalloc(w->num_kcontrols, in snd_soc_dapm_new_widgets()
3233 if (!w->kcontrols) { in snd_soc_dapm_new_widgets()
3239 switch(w->id) { in snd_soc_dapm_new_widgets()
3243 dapm_new_mixer(w); in snd_soc_dapm_new_widgets()
3247 dapm_new_mux(w); in snd_soc_dapm_new_widgets()
3252 dapm_new_pga(w); in snd_soc_dapm_new_widgets()
3255 dapm_new_dai_link(w); in snd_soc_dapm_new_widgets()
3262 if (w->reg >= 0) { in snd_soc_dapm_new_widgets()
3263 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3264 val = val >> w->shift; in snd_soc_dapm_new_widgets()
3265 val &= w->mask; in snd_soc_dapm_new_widgets()
3266 if (val == w->on_val) in snd_soc_dapm_new_widgets()
3267 w->power = 1; in snd_soc_dapm_new_widgets()
3270 w->new = 1; in snd_soc_dapm_new_widgets()
3272 dapm_mark_dirty(w, "new widget"); in snd_soc_dapm_new_widgets()
3273 dapm_debugfs_add_widget(w); in snd_soc_dapm_new_widgets()
3605 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control_unlocked() local
3609 if ((w = dapm_cnew_widget(widget)) == NULL) in snd_soc_dapm_new_control_unlocked()
3612 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3614 w->regulator = devm_regulator_get(dapm->dev, w->name); in snd_soc_dapm_new_control_unlocked()
3615 if (IS_ERR(w->regulator)) { in snd_soc_dapm_new_control_unlocked()
3616 ret = PTR_ERR(w->regulator); in snd_soc_dapm_new_control_unlocked()
3620 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_new_control_unlocked()
3621 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_new_control_unlocked()
3625 w->name, ret); in snd_soc_dapm_new_control_unlocked()
3629 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3630 if (IS_ERR(w->pinctrl)) { in snd_soc_dapm_new_control_unlocked()
3631 ret = PTR_ERR(w->pinctrl); in snd_soc_dapm_new_control_unlocked()
3636 dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD); in snd_soc_dapm_new_control_unlocked()
3639 w->clk = devm_clk_get(dapm->dev, w->name); in snd_soc_dapm_new_control_unlocked()
3640 if (IS_ERR(w->clk)) { in snd_soc_dapm_new_control_unlocked()
3641 ret = PTR_ERR(w->clk); in snd_soc_dapm_new_control_unlocked()
3651 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name); in snd_soc_dapm_new_control_unlocked()
3653 w->name = kstrdup_const(widget->name, GFP_KERNEL); in snd_soc_dapm_new_control_unlocked()
3654 if (w->name == NULL) { in snd_soc_dapm_new_control_unlocked()
3655 kfree_const(w->sname); in snd_soc_dapm_new_control_unlocked()
3656 kfree(w); in snd_soc_dapm_new_control_unlocked()
3660 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3662 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3663 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3667 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3668 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3672 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3673 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3677 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3678 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3682 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3683 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3686 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3687 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3713 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3720 w->is_supply = 1; in snd_soc_dapm_new_control_unlocked()
3721 w->power_check = dapm_supply_check_power; in snd_soc_dapm_new_control_unlocked()
3724 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3728 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3729 INIT_LIST_HEAD(&w->list); in snd_soc_dapm_new_control_unlocked()
3730 INIT_LIST_HEAD(&w->dirty); in snd_soc_dapm_new_control_unlocked()
3732 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3735 INIT_LIST_HEAD(&w->edges[dir]); in snd_soc_dapm_new_control_unlocked()
3736 w->endpoints[dir] = -1; in snd_soc_dapm_new_control_unlocked()
3740 w->connected = 1; in snd_soc_dapm_new_control_unlocked()
3741 return w; in snd_soc_dapm_new_control_unlocked()
3746 w->name, ret); in snd_soc_dapm_new_control_unlocked()
3748 kfree_const(w->sname); in snd_soc_dapm_new_control_unlocked()
3749 kfree(w); in snd_soc_dapm_new_control_unlocked()
3766 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control() local
3769 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3772 return w; in snd_soc_dapm_new_control()
3795 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls() local
3796 if (IS_ERR(w)) { in snd_soc_dapm_new_controls()
3797 ret = PTR_ERR(w); in snd_soc_dapm_new_controls()
3808 snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event_pre_pmu() argument
3833 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3844 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3863 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3872 dev_warn(w->dapm->dev, "ASoC: Invalid format %llx specified\n", in snd_soc_dai_link_event_pre_pmu()
3890 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3901 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3921 static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event() argument
3926 struct snd_pcm_substream *substream = w->priv; in snd_soc_dai_link_event()
3929 if (WARN_ON(list_empty(&w->edges[SND_SOC_DAPM_DIR_OUT]) || in snd_soc_dai_link_event()
3930 list_empty(&w->edges[SND_SOC_DAPM_DIR_IN]))) in snd_soc_dai_link_event()
3935 ret = snd_soc_dai_link_event_pre_pmu(w, substream); in snd_soc_dai_link_event()
3942 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3951 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3959 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
3965 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3971 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
3978 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4003 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_get() local
4004 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get()
4014 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_put() local
4015 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_put()
4018 if (w->power) in snd_soc_dapm_dai_link_put()
4125 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai() local
4171 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4172 if (IS_ERR(w)) { in snd_soc_dapm_new_dai()
4173 ret = PTR_ERR(w); in snd_soc_dapm_new_dai()
4179 w->priv = substream; in snd_soc_dapm_new_dai()
4181 return w; in snd_soc_dapm_new_dai()
4196 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai_widgets() local
4211 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4212 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4213 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4215 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4216 dai->playback_widget = w; in snd_soc_dapm_new_dai_widgets()
4227 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4228 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4229 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4231 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4232 dai->capture_widget = w; in snd_soc_dapm_new_dai_widgets()
4240 struct snd_soc_dapm_widget *dai_w, *w; in snd_soc_dapm_link_dai_widgets() local
4264 for_each_card_widgets(card, w) { in snd_soc_dapm_link_dai_widgets()
4265 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4268 switch (w->id) { in snd_soc_dapm_link_dai_widgets()
4276 if (!w->sname || !strstr(w->sname, dai_w->sname)) in snd_soc_dapm_link_dai_widgets()
4281 sink = w; in snd_soc_dapm_link_dai_widgets()
4283 src = w; in snd_soc_dapm_link_dai_widgets()
4287 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4370 struct snd_soc_dapm_widget *w; in soc_dapm_dai_stream_event() local
4372 w = snd_soc_dai_get_widget(dai, stream); in soc_dapm_dai_stream_event()
4374 if (w) { in soc_dapm_dai_stream_event()
4377 dapm_mark_dirty(w, "stream event"); in soc_dapm_dai_stream_event()
4379 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4381 dapm_widget_invalidate_input_paths(w); in soc_dapm_dai_stream_event()
4384 dapm_widget_invalidate_output_paths(w); in soc_dapm_dai_stream_event()
4389 w->active = 1; in soc_dapm_dai_stream_event()
4390 w->is_ep = ep; in soc_dapm_dai_stream_event()
4393 w->active = 0; in soc_dapm_dai_stream_event()
4394 w->is_ep = 0; in soc_dapm_dai_stream_event()
4553 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked() local
4555 if (!w) { in snd_soc_dapm_force_enable_pin_unlocked()
4560 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4561 if (!w->connected) { in snd_soc_dapm_force_enable_pin_unlocked()
4563 * w->force does not affect the number of input or output paths, in snd_soc_dapm_force_enable_pin_unlocked()
4564 * so we only have to recheck if w->connected is changed in snd_soc_dapm_force_enable_pin_unlocked()
4566 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
4567 dapm_widget_invalidate_output_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
4568 w->connected = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4570 w->force = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4571 dapm_mark_dirty(w, "force enable"); in snd_soc_dapm_force_enable_pin_unlocked()
4711 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status() local
4713 if (w) in snd_soc_dapm_get_pin_status()
4714 return w->connected; in snd_soc_dapm_get_pin_status()
4734 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend() local
4736 if (!w) { in snd_soc_dapm_ignore_suspend()
4741 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4786 struct snd_soc_dapm_widget *w; in soc_dapm_shutdown_dapm() local
4792 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4793 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4795 if (w->power) { in soc_dapm_shutdown_dapm()
4796 dapm_seq_insert(w, &down_list, false); in soc_dapm_shutdown_dapm()
4797 w->new_power = 0; in soc_dapm_shutdown_dapm()