Lines Matching full:w
184 static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w) in dapm_dirty_widget() argument
186 return !list_empty(&w->dirty); in dapm_dirty_widget()
189 static void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason) in dapm_mark_dirty() argument
191 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
193 if (!dapm_dirty_widget(w)) { 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()
208 struct snd_soc_dapm_widget *w, enum snd_soc_dapm_direction dir) in dapm_widget_invalidate_paths() argument
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()
223 list_for_each_entry(w, &list, work_list) { in dapm_widget_invalidate_paths()
224 snd_soc_dapm_widget_for_each_path(w, dir, p) { in dapm_widget_invalidate_paths()
239 * @w: The widget for which to invalidate the cached number of input paths
248 static void dapm_widget_invalidate_input_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_input_paths() argument
250 dapm_widget_invalidate_paths(w, SND_SOC_DAPM_DIR_IN); in dapm_widget_invalidate_input_paths()
256 * @w: The widget for which to invalidate the cached number of output paths
265 static void dapm_widget_invalidate_output_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_output_paths() argument
267 dapm_widget_invalidate_paths(w, SND_SOC_DAPM_DIR_OUT); in dapm_widget_invalidate_output_paths()
304 struct snd_soc_dapm_widget *w; in dapm_mark_endpoints_dirty() local
308 for_each_card_widgets(card, w) { in dapm_mark_endpoints_dirty()
309 if (w->is_ep) { in dapm_mark_endpoints_dirty()
310 dapm_mark_dirty(w, "Rechecking endpoints"); in dapm_mark_endpoints_dirty()
311 if (w->is_ep & SND_SOC_DAPM_EP_SINK) in dapm_mark_endpoints_dirty()
312 dapm_widget_invalidate_output_paths(w); in dapm_mark_endpoints_dirty()
313 if (w->is_ep & SND_SOC_DAPM_EP_SOURCE) in dapm_mark_endpoints_dirty()
314 dapm_widget_invalidate_input_paths(w); in dapm_mark_endpoints_dirty()
327 struct snd_soc_dapm_widget *w __free(kfree) = kmemdup(_widget, in dapm_cnew_widget()
330 if (!w) in dapm_cnew_widget()
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()
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()
348 return_ptr(w); in dapm_cnew_widget()
611 struct snd_soc_dapm_widget *w; in dapm_reset() local
617 for_each_card_widgets(card, w) { in dapm_reset()
618 w->new_power = w->power; in dapm_reset()
619 w->power_checked = false; in dapm_reset()
661 dapm_wcache_lookup(struct snd_soc_dapm_widget *w, const char *name) in dapm_wcache_lookup() argument
663 if (w) { in dapm_wcache_lookup()
664 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
668 list_for_each_entry_from(w, wlist, list) { in dapm_wcache_lookup()
669 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
670 return w; in dapm_wcache_lookup()
749 struct snd_soc_dapm_widget *w) in dapm_connect_mux() argument
751 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
851 struct snd_soc_dapm_widget *w; in dapm_is_shared_kcontrol() local
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()
875 static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, in dapm_create_or_share_kcontrol() argument
878 struct snd_soc_dapm_context *dapm = w->dapm; 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()
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()
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()
959 ret = dapm_kcontrol_data_alloc(w, kcontrol, name); in dapm_create_or_share_kcontrol()
969 w->name, name, ret); in dapm_create_or_share_kcontrol()
974 ret = dapm_kcontrol_add_widget(kcontrol, w); in dapm_create_or_share_kcontrol()
976 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
985 static int dapm_new_mixer(struct snd_soc_dapm_widget *w) in dapm_new_mixer() argument
992 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
994 snd_soc_dapm_widget_for_each_source_path(w, path) { 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()
1000 ret = dapm_create_or_share_kcontrol(w, 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()
1020 static int dapm_new_mux(struct snd_soc_dapm_widget *w) in dapm_new_mux() argument
1022 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1028 switch (w->id) { in dapm_new_mux()
1041 if (w->num_kcontrols != 1) { in dapm_new_mux()
1044 w->name); 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()
1053 ret = dapm_create_or_share_kcontrol(w, 0); in dapm_new_mux()
1057 snd_soc_dapm_widget_for_each_path(w, dir, path) { in dapm_new_mux()
1059 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1066 static int dapm_new_pga(struct snd_soc_dapm_widget *w) in dapm_new_pga() argument
1070 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1071 int ret = dapm_create_or_share_kcontrol(w, i); in dapm_new_pga()
1080 static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) in dapm_new_dai_link() argument
1083 struct snd_soc_pcm_runtime *rtd = w->priv; 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()
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()
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()
1138 struct snd_soc_dapm_widget *w; in dapm_widget_list_create() local
1152 list_for_each_entry(w, widgets, work_list) in dapm_widget_list_create()
1153 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1310 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream); in snd_soc_dapm_dai_get_connected_widgets() local
1318 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); in snd_soc_dapm_dai_get_connected_widgets()
1319 paths = is_connected_output_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1322 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_IN); in snd_soc_dapm_dai_get_connected_widgets()
1323 paths = is_connected_input_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1350 int dapm_regulator_event(struct snd_soc_dapm_widget *w, in dapm_regulator_event() argument
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()
1384 int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, in dapm_pinctrl_event() argument
1387 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in dapm_pinctrl_event()
1388 struct pinctrl *p = w->pinctrl; in dapm_pinctrl_event()
1409 int dapm_clock_event(struct snd_soc_dapm_widget *w, in dapm_clock_event() argument
1412 if (!w->clk) 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()
1428 static int dapm_widget_power_check(struct snd_soc_dapm_widget *w) in dapm_widget_power_check() argument
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()
1444 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) in dapm_generic_check_power() argument
1448 DAPM_UPDATE_STAT(w, power_checks); in dapm_generic_check_power()
1450 in = is_connected_input_ep(w, NULL, NULL); in dapm_generic_check_power()
1451 out = is_connected_output_ep(w, NULL, NULL); in dapm_generic_check_power()
1456 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) in dapm_supply_check_power() argument
1460 DAPM_UPDATE_STAT(w, power_checks); in dapm_supply_check_power()
1463 snd_soc_dapm_widget_for_each_sink_path(w, path) { in dapm_supply_check_power()
1464 DAPM_UPDATE_STAT(w, neighbour_checks); in dapm_supply_check_power()
1480 static int dapm_always_on_check_power(struct snd_soc_dapm_widget *w) in dapm_always_on_check_power() argument
1482 return w->connected; in dapm_always_on_check_power()
1523 struct snd_soc_dapm_widget *w; in dapm_seq_insert() local
1525 list_for_each_entry(w, list, power_list) in dapm_seq_insert()
1526 if (dapm_seq_compare(new_widget, w, power_up) < 0) { in dapm_seq_insert()
1527 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1535 struct snd_soc_dapm_widget *w, int event) in dapm_seq_check_event() argument
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()
1579 trace_snd_soc_dapm_widget_event_start(w, event); in dapm_seq_check_event()
1580 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1581 trace_snd_soc_dapm_widget_event_done(w, 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()
1593 struct snd_soc_dapm_widget *w; in dapm_seq_run_coalesced() local
1598 w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list); in dapm_seq_run_coalesced()
1599 reg = w->reg; in dapm_seq_run_coalesced()
1600 dapm = w->dapm; in dapm_seq_run_coalesced()
1602 list_for_each_entry(w, pending, power_list) { 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()
1614 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1617 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU); in dapm_seq_run_coalesced()
1618 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMD); in dapm_seq_run_coalesced()
1633 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1634 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU); in dapm_seq_run_coalesced()
1635 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD); in dapm_seq_run_coalesced()
1650 struct snd_soc_dapm_widget *w, *n; in dapm_seq_run() local
1665 list_for_each_entry_safe(w, n, list, power_list) { 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()
1682 if (cur_dapm && w->dapm != cur_dapm) 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()
1751 struct snd_soc_dapm_widget *w = NULL; in dapm_widget_update() local
1760 for_each_dapm_widgets(wlist, wi, w) { 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()
1769 if (!w) in dapm_widget_update()
1772 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, 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()
1779 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1782 dev_err(w->dapm->dev, in dapm_widget_update()
1784 w->name, ret); in dapm_widget_update()
1787 for_each_dapm_widgets(wlist, wi, w) { 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()
1884 static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, in dapm_power_one_widget() argument
1891 switch (w->id) { in dapm_power_one_widget()
1902 power = dapm_widget_power_check(w); in dapm_power_one_widget()
1904 if (w->power == power) in dapm_power_one_widget()
1907 trace_snd_soc_dapm_widget_power(w, power); in dapm_power_one_widget()
1913 snd_soc_dapm_widget_for_each_source_path(w, path) in dapm_power_one_widget()
1919 if (!w->is_supply) in dapm_power_one_widget()
1920 snd_soc_dapm_widget_for_each_sink_path(w, path) in dapm_power_one_widget()
1925 dapm_seq_insert(w, up_list, true); in dapm_power_one_widget()
1927 dapm_seq_insert(w, down_list, false); in dapm_power_one_widget()
1957 struct snd_soc_dapm_widget *w; in dapm_power_widgets() local
1984 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1985 dapm_power_one_widget(w, &up_list, &down_list); in dapm_power_widgets()
1988 for_each_card_widgets(card, w) { 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()
2052 list_for_each_entry(w, &down_list, power_list) { in dapm_power_widgets()
2053 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMD); in dapm_power_widgets()
2056 list_for_each_entry(w, &up_list, power_list) { in dapm_power_widgets()
2057 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMU); in dapm_power_widgets()
2144 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file() local
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()
2165 in = is_connected_input_ep(w, NULL, NULL); in dapm_widget_power_read_file()
2166 out = is_connected_output_ep(w, NULL, NULL); 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()
2176 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2180 if (w->sname) 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()
2186 snd_soc_dapm_type_name[w->id]); in dapm_widget_power_read_file()
2190 snd_soc_dapm_widget_for_each_path(w, dir, p) { in dapm_widget_power_read_file()
2207 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2268 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
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()
2279 static void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_free_widget() argument
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()
2301 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2305 static inline void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_free_widget() argument
2449 struct snd_soc_dapm_widget *w; in dapm_widget_show_component() local
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()
2548 * @w: widget to free
2552 void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) in snd_soc_dapm_free_widget() argument
2557 if (!w) in snd_soc_dapm_free_widget()
2560 list_del(&w->list); in snd_soc_dapm_free_widget()
2561 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2568 snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) in snd_soc_dapm_free_widget()
2572 dapm_debugfs_free_widget(w); 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()
2577 kfree(w); in snd_soc_dapm_free_widget()
2584 struct snd_soc_dapm_widget *w, *next_w; in dapm_free_widgets() local
2586 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2587 if (w->dapm != dapm) in dapm_free_widgets()
2589 snd_soc_dapm_free_widget(w); in dapm_free_widgets()
2600 struct snd_soc_dapm_widget *w; in dapm_find_widget() local
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()
2617 return w; in dapm_find_widget()
2619 fallback = w; in dapm_find_widget()
2637 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in __snd_soc_dapm_set_pin() local
2642 if (!w) { in __snd_soc_dapm_set_pin()
2647 if (w->connected != status) { in __snd_soc_dapm_set_pin()
2648 dapm_mark_dirty(w, "pin configuration"); in __snd_soc_dapm_set_pin()
2649 dapm_widget_invalidate_input_paths(w); in __snd_soc_dapm_set_pin()
2650 dapm_widget_invalidate_output_paths(w); 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()
2718 struct snd_soc_dapm_widget *w, in dapm_update_dai_chan() argument
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()
2733 if (w->channel < channels) in dapm_update_dai_chan()
2748 struct snd_soc_dapm_widget *w; in dapm_update_dai_unlocked() local
2751 w = snd_soc_dai_get_widget(dai, dir); in dapm_update_dai_unlocked()
2753 if (!w) in dapm_update_dai_unlocked()
2758 snd_soc_dapm_widget_for_each_sink_path(w, p) { in dapm_update_dai_unlocked()
2764 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_dai_unlocked()
2802 * @w: The widget for which to update the flags
2809 static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) in dapm_update_widget_flags() argument
2815 switch (w->id) { in dapm_update_widget_flags()
2818 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2821 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_widget_flags()
2833 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2836 snd_soc_dapm_widget_for_each_sink_path(w, p) { 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()
3007 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; in snd_soc_dapm_add_route() local
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()
3043 wtsink = w; in snd_soc_dapm_add_route()
3044 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3045 wsink = w; 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()
3057 wtsource = w; in snd_soc_dapm_add_route()
3058 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3059 wsource = w; in snd_soc_dapm_add_route()
3067 w->name); in snd_soc_dapm_add_route()
3306 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_widgets() local
3311 for_each_card_widgets(card, w) in snd_soc_dapm_new_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()
3326 switch(w->id) { in snd_soc_dapm_new_widgets()
3330 dapm_new_mixer(w); in snd_soc_dapm_new_widgets()
3334 dapm_new_mux(w); in snd_soc_dapm_new_widgets()
3339 dapm_new_pga(w); in snd_soc_dapm_new_widgets()
3342 dapm_new_dai_link(w); 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()
3359 dapm_mark_dirty(w, "new widget"); in snd_soc_dapm_new_widgets()
3360 dapm_debugfs_add_widget(w); in snd_soc_dapm_new_widgets()
3688 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control_unlocked() local
3691 w = dapm_cnew_widget(widget, soc_dapm_prefix(dapm)); in snd_soc_dapm_new_control_unlocked()
3692 if (!w) 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()
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()
3719 dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD); 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()
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()
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()
3813 return w; 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()
3820 kfree(w); in snd_soc_dapm_new_control_unlocked()
3838 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control() local
3841 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3844 return w; in snd_soc_dapm_new_control()
3867 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls() local
3868 if (IS_ERR(w)) { in snd_soc_dapm_new_controls()
3869 ret = PTR_ERR(w); in snd_soc_dapm_new_controls()
3880 snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event_pre_pmu() argument
3912 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3923 snd_soc_dapm_widget_for_each_sink_path(w, path) { 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()
3948 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
3966 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3977 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3995 static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event() argument
4000 struct snd_pcm_substream *substream = w->priv; 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()
4009 ret = snd_soc_dai_link_event_pre_pmu(w, substream); in snd_soc_dai_link_event()
4016 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4025 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4033 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
4039 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4045 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
4052 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4078 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_get() local
4079 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get()
4089 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_put() local
4090 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_put()
4093 if (w->power) in snd_soc_dapm_dai_link_put()
4200 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai() local
4245 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4246 if (IS_ERR(w)) { in snd_soc_dapm_new_dai()
4247 ret = PTR_ERR(w); in snd_soc_dapm_new_dai()
4251 w->priv = substream; in snd_soc_dapm_new_dai()
4253 return w; in snd_soc_dapm_new_dai()
4278 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai_widgets() local
4293 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4294 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4295 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4297 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4298 snd_soc_dai_set_widget_playback(dai, w); in snd_soc_dapm_new_dai_widgets()
4309 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4310 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4311 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4313 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4314 snd_soc_dai_set_widget_capture(dai, w); in snd_soc_dapm_new_dai_widgets()
4323 struct snd_soc_dapm_widget *dai_w, *w; in snd_soc_dapm_link_dai_widgets() local
4347 for_each_card_widgets(card, w) { 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()
4364 sink = w; in snd_soc_dapm_link_dai_widgets()
4366 src = w; 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()
4444 struct snd_soc_dapm_widget *w; in soc_dapm_dai_stream_event() local
4446 w = snd_soc_dai_get_widget(dai, stream); in soc_dapm_dai_stream_event()
4448 if (w) { in soc_dapm_dai_stream_event()
4451 dapm_mark_dirty(w, "stream event"); in soc_dapm_dai_stream_event()
4453 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4455 dapm_widget_invalidate_input_paths(w); in soc_dapm_dai_stream_event()
4458 dapm_widget_invalidate_output_paths(w); 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()
4628 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked() local
4630 if (!w) { 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()
4641 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
4642 dapm_widget_invalidate_output_paths(w); 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()
4646 dapm_mark_dirty(w, "force enable"); in snd_soc_dapm_force_enable_pin_unlocked()
4786 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status() local
4788 if (w) in snd_soc_dapm_get_pin_status()
4789 return w->connected; in snd_soc_dapm_get_pin_status()
4809 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend() local
4811 if (!w) { in snd_soc_dapm_ignore_suspend()
4816 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4861 struct snd_soc_dapm_widget *w; in soc_dapm_shutdown_dapm() local
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()
4871 dapm_seq_insert(w, &down_list, false); in soc_dapm_shutdown_dapm()
4872 w->new_power = 0; in soc_dapm_shutdown_dapm()