Lines Matching full:w

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()
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()
326 struct snd_soc_dapm_widget *w; in dapm_cnew_widget() local
328 w = kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); in dapm_cnew_widget()
329 if (!w) in dapm_cnew_widget()
333 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, _widget->name); in dapm_cnew_widget()
335 w->name = kstrdup_const(_widget->name, GFP_KERNEL); in dapm_cnew_widget()
336 if (!w->name) { in dapm_cnew_widget()
337 kfree(w); in dapm_cnew_widget()
342 w->sname = kstrdup_const(_widget->sname, GFP_KERNEL); in dapm_cnew_widget()
343 if (!w->sname) { in dapm_cnew_widget()
344 kfree_const(w->name); in dapm_cnew_widget()
345 kfree(w); in dapm_cnew_widget()
349 return w; in dapm_cnew_widget()
612 struct snd_soc_dapm_widget *w; in dapm_reset() local
618 for_each_card_widgets(card, w) { in dapm_reset()
619 w->new_power = w->power; in dapm_reset()
620 w->power_checked = false; in dapm_reset()
662 dapm_wcache_lookup(struct snd_soc_dapm_widget *w, const char *name) in dapm_wcache_lookup() argument
664 if (w) { in dapm_wcache_lookup()
665 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
669 list_for_each_entry_from(w, wlist, list) { in dapm_wcache_lookup()
670 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
671 return w; in dapm_wcache_lookup()
750 struct snd_soc_dapm_widget *w) in dapm_connect_mux() argument
752 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
852 struct snd_soc_dapm_widget *w; in dapm_is_shared_kcontrol() local
857 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
858 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
860 for (i = 0; i < w->num_kcontrols; i++) { in dapm_is_shared_kcontrol()
861 if (&w->kcontrol_news[i] == kcontrol_new) { in dapm_is_shared_kcontrol()
862 if (w->kcontrols) in dapm_is_shared_kcontrol()
863 *kcontrol = w->kcontrols[i]; in dapm_is_shared_kcontrol()
876 static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, in dapm_create_or_share_kcontrol() argument
879 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol()
896 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
904 switch (w->id) { in dapm_create_or_share_kcontrol()
926 if (w->no_wname_in_kcontrol_name) in dapm_create_or_share_kcontrol()
937 w->name + prefix_len, in dapm_create_or_share_kcontrol()
938 w->kcontrol_news[kci].name); in dapm_create_or_share_kcontrol()
945 name = w->name + prefix_len; in dapm_create_or_share_kcontrol()
948 name = w->kcontrol_news[kci].name; in dapm_create_or_share_kcontrol()
951 kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name, in dapm_create_or_share_kcontrol()
960 ret = dapm_kcontrol_data_alloc(w, kcontrol, name); in dapm_create_or_share_kcontrol()
970 w->name, name, ret); in dapm_create_or_share_kcontrol()
975 ret = dapm_kcontrol_add_widget(kcontrol, w); in dapm_create_or_share_kcontrol()
977 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
986 static int dapm_new_mixer(struct snd_soc_dapm_widget *w) in dapm_new_mixer() argument
993 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
995 snd_soc_dapm_widget_for_each_source_path(w, path) { in dapm_new_mixer()
997 if (path->name != (char *)w->kcontrol_news[i].name) in dapm_new_mixer()
1000 if (!w->kcontrols[i]) { in dapm_new_mixer()
1001 ret = dapm_create_or_share_kcontrol(w, i); in dapm_new_mixer()
1006 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
1008 data = snd_kcontrol_chip(w->kcontrols[i]); in dapm_new_mixer()
1021 static int dapm_new_mux(struct snd_soc_dapm_widget *w) in dapm_new_mux() argument
1023 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1029 switch (w->id) { in dapm_new_mux()
1042 if (w->num_kcontrols != 1) { in dapm_new_mux()
1045 w->name); in dapm_new_mux()
1049 if (list_empty(&w->edges[dir])) { in dapm_new_mux()
1050 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1054 ret = dapm_create_or_share_kcontrol(w, 0); in dapm_new_mux()
1058 snd_soc_dapm_widget_for_each_path(w, dir, path) { in dapm_new_mux()
1060 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1067 static int dapm_new_pga(struct snd_soc_dapm_widget *w) in dapm_new_pga() argument
1071 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1072 int ret = dapm_create_or_share_kcontrol(w, i); in dapm_new_pga()
1081 static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) in dapm_new_dai_link() argument
1084 struct snd_soc_pcm_runtime *rtd = w->priv; in dapm_new_dai_link()
1091 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_dai_link()
1092 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link()
1094 struct snd_kcontrol *kcontrol = snd_soc_cnew(&w->kcontrol_news[i], in dapm_new_dai_link()
1095 w, w->name, NULL); in dapm_new_dai_link()
1101 w->name, w->kcontrol_news[i].name, ret); in dapm_new_dai_link()
1104 kcontrol->private_data = w; in dapm_new_dai_link()
1105 w->kcontrols[i] = kcontrol; in dapm_new_dai_link()
1139 struct snd_soc_dapm_widget *w; in dapm_widget_list_create() local
1151 list_for_each_entry(w, widgets, work_list) in dapm_widget_list_create()
1152 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1309 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream); in snd_soc_dapm_dai_get_connected_widgets() local
1317 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); in snd_soc_dapm_dai_get_connected_widgets()
1318 paths = is_connected_output_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1321 invalidate_paths_ep(w, SND_SOC_DAPM_DIR_IN); in snd_soc_dapm_dai_get_connected_widgets()
1322 paths = is_connected_input_ep(w, &widgets, in snd_soc_dapm_dai_get_connected_widgets()
1349 int dapm_regulator_event(struct snd_soc_dapm_widget *w, in dapm_regulator_event() argument
1354 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1357 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1358 ret = regulator_allow_bypass(w->regulator, false); in dapm_regulator_event()
1360 dev_warn(w->dapm->dev, in dapm_regulator_event()
1362 w->name, ret); in dapm_regulator_event()
1365 return regulator_enable(w->regulator); in dapm_regulator_event()
1367 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1368 ret = regulator_allow_bypass(w->regulator, true); in dapm_regulator_event()
1370 dev_warn(w->dapm->dev, in dapm_regulator_event()
1372 w->name, ret); in dapm_regulator_event()
1375 return regulator_disable_deferred(w->regulator, w->shift); in dapm_regulator_event()
1383 int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, in dapm_pinctrl_event() argument
1386 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in dapm_pinctrl_event()
1387 struct pinctrl *p = w->pinctrl; in dapm_pinctrl_event()
1408 int dapm_clock_event(struct snd_soc_dapm_widget *w, in dapm_clock_event() argument
1411 if (!w->clk) in dapm_clock_event()
1414 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1417 return clk_prepare_enable(w->clk); in dapm_clock_event()
1419 clk_disable_unprepare(w->clk); in dapm_clock_event()
1427 static int dapm_widget_power_check(struct snd_soc_dapm_widget *w) in dapm_widget_power_check() argument
1429 if (w->power_checked) in dapm_widget_power_check()
1430 return w->new_power; in dapm_widget_power_check()
1432 if (w->force) in dapm_widget_power_check()
1433 w->new_power = 1; in dapm_widget_power_check()
1435 w->new_power = w->power_check(w); in dapm_widget_power_check()
1437 w->power_checked = true; in dapm_widget_power_check()
1439 return w->new_power; in dapm_widget_power_check()
1443 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) in dapm_generic_check_power() argument
1447 DAPM_UPDATE_STAT(w, power_checks); in dapm_generic_check_power()
1449 in = is_connected_input_ep(w, NULL, NULL); in dapm_generic_check_power()
1450 out = is_connected_output_ep(w, NULL, NULL); in dapm_generic_check_power()
1455 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) in dapm_supply_check_power() argument
1459 DAPM_UPDATE_STAT(w, power_checks); in dapm_supply_check_power()
1462 snd_soc_dapm_widget_for_each_sink_path(w, path) { in dapm_supply_check_power()
1463 DAPM_UPDATE_STAT(w, neighbour_checks); in dapm_supply_check_power()
1479 static int dapm_always_on_check_power(struct snd_soc_dapm_widget *w) in dapm_always_on_check_power() argument
1481 return w->connected; in dapm_always_on_check_power()
1522 struct snd_soc_dapm_widget *w; in dapm_seq_insert() local
1524 list_for_each_entry(w, list, power_list) in dapm_seq_insert()
1525 if (dapm_seq_compare(new_widget, w, power_up) < 0) { in dapm_seq_insert()
1526 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1534 struct snd_soc_dapm_widget *w, int event) in dapm_seq_check_event() argument
1569 if (w->new_power != power) in dapm_seq_check_event()
1572 if (w->event && (w->event_flags & event)) { in dapm_seq_check_event()
1575 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1576 w->name, ev_name); in dapm_seq_check_event()
1577 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1578 trace_snd_soc_dapm_widget_event_start(w, event); in dapm_seq_check_event()
1579 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1580 trace_snd_soc_dapm_widget_event_done(w, event); in dapm_seq_check_event()
1582 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1583 ev_name, w->name, ret); in dapm_seq_check_event()
1592 struct snd_soc_dapm_widget *w; in dapm_seq_run_coalesced() local
1597 w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list); in dapm_seq_run_coalesced()
1598 reg = w->reg; in dapm_seq_run_coalesced()
1599 dapm = w->dapm; in dapm_seq_run_coalesced()
1601 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1602 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1603 w->power = w->new_power; in dapm_seq_run_coalesced()
1605 mask |= w->mask << w->shift; in dapm_seq_run_coalesced()
1606 if (w->power) in dapm_seq_run_coalesced()
1607 value |= w->on_val << w->shift; in dapm_seq_run_coalesced()
1609 value |= w->off_val << w->shift; in dapm_seq_run_coalesced()
1613 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1616 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU); in dapm_seq_run_coalesced()
1617 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMD); in dapm_seq_run_coalesced()
1632 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1633 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU); in dapm_seq_run_coalesced()
1634 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD); in dapm_seq_run_coalesced()
1649 struct snd_soc_dapm_widget *w, *n; in dapm_seq_run() local
1664 list_for_each_entry_safe(w, n, list, power_list) { in dapm_seq_run()
1668 if (sort[w->id] != cur_sort || w->reg != cur_reg || in dapm_seq_run()
1669 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1681 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1691 switch (w->id) { in dapm_seq_run()
1693 if (!w->event) in dapm_seq_run()
1697 ret = w->event(w, in dapm_seq_run()
1700 ret = w->event(w, in dapm_seq_run()
1705 if (!w->event) in dapm_seq_run()
1709 ret = w->event(w, in dapm_seq_run()
1712 ret = w->event(w, in dapm_seq_run()
1718 cur_sort = sort[w->id]; in dapm_seq_run()
1719 cur_subseq = w->subseq; in dapm_seq_run()
1720 cur_reg = w->reg; in dapm_seq_run()
1721 cur_dapm = w->dapm; in dapm_seq_run()
1722 list_move(&w->power_list, &pending); in dapm_seq_run()
1727 dev_err(w->dapm->dev, in dapm_seq_run()
1750 struct snd_soc_dapm_widget *w = NULL; in dapm_widget_update() local
1759 for_each_dapm_widgets(wlist, wi, w) { in dapm_widget_update()
1760 if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) { in dapm_widget_update()
1761 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); in dapm_widget_update()
1763 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1764 w->name, ret); in dapm_widget_update()
1768 if (!w) in dapm_widget_update()
1771 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1774 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1775 w->name, ret); in dapm_widget_update()
1778 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1781 dev_err(w->dapm->dev, in dapm_widget_update()
1783 w->name, ret); in dapm_widget_update()
1786 for_each_dapm_widgets(wlist, wi, w) { in dapm_widget_update()
1787 if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) { in dapm_widget_update()
1788 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); in dapm_widget_update()
1790 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1791 w->name, ret); in dapm_widget_update()
1883 static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, in dapm_power_one_widget() argument
1890 switch (w->id) { in dapm_power_one_widget()
1901 power = dapm_widget_power_check(w); in dapm_power_one_widget()
1903 if (w->power == power) in dapm_power_one_widget()
1906 trace_snd_soc_dapm_widget_power(w, power); in dapm_power_one_widget()
1912 snd_soc_dapm_widget_for_each_source_path(w, path) in dapm_power_one_widget()
1918 if (!w->is_supply) in dapm_power_one_widget()
1919 snd_soc_dapm_widget_for_each_sink_path(w, path) in dapm_power_one_widget()
1924 dapm_seq_insert(w, up_list, true); in dapm_power_one_widget()
1926 dapm_seq_insert(w, down_list, false); in dapm_power_one_widget()
1956 struct snd_soc_dapm_widget *w; in dapm_power_widgets() local
1983 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1984 dapm_power_one_widget(w, &up_list, &down_list); in dapm_power_widgets()
1987 for_each_card_widgets(card, w) { in dapm_power_widgets()
1988 switch (w->id) { in dapm_power_widgets()
1994 list_del_init(&w->dirty); in dapm_power_widgets()
1998 if (w->new_power) { in dapm_power_widgets()
1999 d = w->dapm; in dapm_power_widgets()
2008 switch (w->id) { in dapm_power_widgets()
2051 list_for_each_entry(w, &down_list, power_list) { in dapm_power_widgets()
2052 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMD); in dapm_power_widgets()
2055 list_for_each_entry(w, &up_list, power_list) { in dapm_power_widgets()
2056 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMU); in dapm_power_widgets()
2101 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file() local
2112 snd_soc_dapm_mutex_lock_root(w->dapm); in dapm_widget_power_read_file()
2115 if (w->is_supply) { in dapm_widget_power_read_file()
2119 in = is_connected_input_ep(w, NULL, NULL); in dapm_widget_power_read_file()
2120 out = is_connected_output_ep(w, NULL, NULL); in dapm_widget_power_read_file()
2124 w->name, w->power ? "On" : "Off", in dapm_widget_power_read_file()
2125 w->force ? " (forced)" : "", in, out); in dapm_widget_power_read_file()
2127 if (w->reg >= 0) in dapm_widget_power_read_file()
2130 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2134 if (w->sname) in dapm_widget_power_read_file()
2136 w->sname, in dapm_widget_power_read_file()
2137 w->active ? "active" : "inactive"); in dapm_widget_power_read_file()
2141 snd_soc_dapm_widget_for_each_path(w, dir, p) { in dapm_widget_power_read_file()
2156 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2217 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2219 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget()
2221 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2224 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2228 static void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_free_widget() argument
2230 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_free_widget()
2232 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_free_widget()
2235 debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); in dapm_debugfs_free_widget()
2250 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2254 static inline void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_free_widget() argument
2398 struct snd_soc_dapm_widget *w; in dapm_widget_show_component() local
2408 for_each_card_widgets(cmpnt->card, w) { in dapm_widget_show_component()
2409 if (w->dapm != dapm) in dapm_widget_show_component()
2413 switch (w->id) { in dapm_widget_show_component()
2430 if (w->name) in dapm_widget_show_component()
2432 w->name, w->power ? "On":"Off"); in dapm_widget_show_component()
2497 * @w: widget to free
2501 void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) in snd_soc_dapm_free_widget() argument
2506 if (!w) in snd_soc_dapm_free_widget()
2509 list_del(&w->list); in snd_soc_dapm_free_widget()
2510 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2517 snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) in snd_soc_dapm_free_widget()
2521 dapm_debugfs_free_widget(w); in snd_soc_dapm_free_widget()
2523 kfree(w->kcontrols); in snd_soc_dapm_free_widget()
2524 kfree_const(w->name); in snd_soc_dapm_free_widget()
2525 kfree_const(w->sname); in snd_soc_dapm_free_widget()
2526 kfree(w); in snd_soc_dapm_free_widget()
2533 struct snd_soc_dapm_widget *w, *next_w; in dapm_free_widgets() local
2535 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2536 if (w->dapm != dapm) in dapm_free_widgets()
2538 snd_soc_dapm_free_widget(w); in dapm_free_widgets()
2549 struct snd_soc_dapm_widget *w; in dapm_find_widget() local
2563 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2564 if (!strcmp(w->name, pin_name)) { in dapm_find_widget()
2565 if (w->dapm == dapm) in dapm_find_widget()
2566 return w; in dapm_find_widget()
2568 fallback = w; in dapm_find_widget()
2586 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in __snd_soc_dapm_set_pin() local
2591 if (!w) { in __snd_soc_dapm_set_pin()
2596 if (w->connected != status) { in __snd_soc_dapm_set_pin()
2597 dapm_mark_dirty(w, "pin configuration"); in __snd_soc_dapm_set_pin()
2598 dapm_widget_invalidate_input_paths(w); in __snd_soc_dapm_set_pin()
2599 dapm_widget_invalidate_output_paths(w); in __snd_soc_dapm_set_pin()
2603 w->connected = status; in __snd_soc_dapm_set_pin()
2605 w->force = 0; in __snd_soc_dapm_set_pin()
2667 struct snd_soc_dapm_widget *w, in dapm_update_dai_chan() argument
2670 switch (w->id) { in dapm_update_dai_chan()
2678 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2679 w->channel < channels ? "Connecting" : "Disconnecting", in dapm_update_dai_chan()
2682 if (w->channel < channels) in dapm_update_dai_chan()
2697 struct snd_soc_dapm_widget *w; in dapm_update_dai_unlocked() local
2700 w = snd_soc_dai_get_widget(dai, dir); in dapm_update_dai_unlocked()
2702 if (!w) in dapm_update_dai_unlocked()
2708 snd_soc_dapm_widget_for_each_sink_path(w, p) { in dapm_update_dai_unlocked()
2714 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_dai_unlocked()
2752 * @w: The widget for which to update the flags
2759 static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) in dapm_update_widget_flags() argument
2765 switch (w->id) { in dapm_update_widget_flags()
2768 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2771 snd_soc_dapm_widget_for_each_source_path(w, p) { in dapm_update_widget_flags()
2783 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2786 snd_soc_dapm_widget_for_each_sink_path(w, p) { in dapm_update_widget_flags()
2799 if (!list_empty(&w->edges[dir])) in dapm_update_widget_flags()
2807 w->is_ep = ep; in dapm_update_widget_flags()
2957 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; in snd_soc_dapm_add_route() local
2991 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
2992 if (!wsink && !(strcmp(w->name, sink))) { in snd_soc_dapm_add_route()
2993 wtsink = w; in snd_soc_dapm_add_route()
2994 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2995 wsink = w; in snd_soc_dapm_add_route()
3003 w->name); in snd_soc_dapm_add_route()
3006 if (!wsource && !(strcmp(w->name, source))) { in snd_soc_dapm_add_route()
3007 wtsource = w; in snd_soc_dapm_add_route()
3008 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3009 wsource = w; in snd_soc_dapm_add_route()
3017 w->name); in snd_soc_dapm_add_route()
3256 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_widgets() local
3261 for_each_card_widgets(card, w) in snd_soc_dapm_new_widgets()
3263 if (w->new) in snd_soc_dapm_new_widgets()
3266 if (w->num_kcontrols) { in snd_soc_dapm_new_widgets()
3267 w->kcontrols = kcalloc(w->num_kcontrols, in snd_soc_dapm_new_widgets()
3270 if (!w->kcontrols) { in snd_soc_dapm_new_widgets()
3276 switch(w->id) { in snd_soc_dapm_new_widgets()
3280 dapm_new_mixer(w); in snd_soc_dapm_new_widgets()
3284 dapm_new_mux(w); in snd_soc_dapm_new_widgets()
3289 dapm_new_pga(w); in snd_soc_dapm_new_widgets()
3292 dapm_new_dai_link(w); in snd_soc_dapm_new_widgets()
3299 if (w->reg >= 0) { in snd_soc_dapm_new_widgets()
3300 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3301 val = val >> w->shift; in snd_soc_dapm_new_widgets()
3302 val &= w->mask; in snd_soc_dapm_new_widgets()
3303 if (val == w->on_val) in snd_soc_dapm_new_widgets()
3304 w->power = 1; in snd_soc_dapm_new_widgets()
3307 w->new = 1; in snd_soc_dapm_new_widgets()
3309 dapm_mark_dirty(w, "new widget"); in snd_soc_dapm_new_widgets()
3310 dapm_debugfs_add_widget(w); in snd_soc_dapm_new_widgets()
3638 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control_unlocked() local
3641 w = dapm_cnew_widget(widget, soc_dapm_prefix(dapm)); in snd_soc_dapm_new_control_unlocked()
3642 if (!w) in snd_soc_dapm_new_control_unlocked()
3645 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3647 w->regulator = devm_regulator_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3648 if (IS_ERR(w->regulator)) { in snd_soc_dapm_new_control_unlocked()
3649 ret = PTR_ERR(w->regulator); in snd_soc_dapm_new_control_unlocked()
3653 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_new_control_unlocked()
3654 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_new_control_unlocked()
3658 w->name, ret); in snd_soc_dapm_new_control_unlocked()
3662 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3663 if (IS_ERR(w->pinctrl)) { in snd_soc_dapm_new_control_unlocked()
3664 ret = PTR_ERR(w->pinctrl); in snd_soc_dapm_new_control_unlocked()
3669 dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD); in snd_soc_dapm_new_control_unlocked()
3672 w->clk = devm_clk_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3673 if (IS_ERR(w->clk)) { in snd_soc_dapm_new_control_unlocked()
3674 ret = PTR_ERR(w->clk); in snd_soc_dapm_new_control_unlocked()
3682 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3684 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3685 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3689 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3690 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3694 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3695 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3699 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3700 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3704 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3705 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3708 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3709 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3735 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3742 w->is_supply = 1; in snd_soc_dapm_new_control_unlocked()
3743 w->power_check = dapm_supply_check_power; in snd_soc_dapm_new_control_unlocked()
3746 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3750 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3751 INIT_LIST_HEAD(&w->list); in snd_soc_dapm_new_control_unlocked()
3752 INIT_LIST_HEAD(&w->dirty); in snd_soc_dapm_new_control_unlocked()
3754 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3757 INIT_LIST_HEAD(&w->edges[dir]); in snd_soc_dapm_new_control_unlocked()
3758 w->endpoints[dir] = -1; in snd_soc_dapm_new_control_unlocked()
3762 w->connected = 1; in snd_soc_dapm_new_control_unlocked()
3763 return w; in snd_soc_dapm_new_control_unlocked()
3767 w->name); in snd_soc_dapm_new_control_unlocked()
3768 kfree_const(w->name); in snd_soc_dapm_new_control_unlocked()
3769 kfree_const(w->sname); in snd_soc_dapm_new_control_unlocked()
3770 kfree(w); in snd_soc_dapm_new_control_unlocked()
3788 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control() local
3791 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3794 return w; in snd_soc_dapm_new_control()
3817 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls() local
3818 if (IS_ERR(w)) { in snd_soc_dapm_new_controls()
3819 ret = PTR_ERR(w); in snd_soc_dapm_new_controls()
3830 snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event_pre_pmu() argument
3864 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3875 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3894 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3901 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
3920 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3931 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event_pre_pmu()
3953 static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event() argument
3958 struct snd_pcm_substream *substream = w->priv; in snd_soc_dai_link_event()
3961 if (WARN_ON(list_empty(&w->edges[SND_SOC_DAPM_DIR_OUT]) || in snd_soc_dai_link_event()
3962 list_empty(&w->edges[SND_SOC_DAPM_DIR_IN]))) in snd_soc_dai_link_event()
3967 ret = snd_soc_dai_link_event_pre_pmu(w, substream); in snd_soc_dai_link_event()
3974 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3983 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
3991 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
3997 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4003 snd_soc_dapm_widget_for_each_source_path(w, path) { in snd_soc_dai_link_event()
4010 snd_soc_dapm_widget_for_each_sink_path(w, path) { in snd_soc_dai_link_event()
4035 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_get() local
4036 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get()
4046 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_put() local
4047 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_put()
4050 if (w->power) in snd_soc_dapm_dai_link_put()
4157 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai() local
4202 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4203 if (IS_ERR(w)) { in snd_soc_dapm_new_dai()
4204 ret = PTR_ERR(w); in snd_soc_dapm_new_dai()
4208 w->priv = substream; in snd_soc_dapm_new_dai()
4210 return w; in snd_soc_dapm_new_dai()
4235 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai_widgets() local
4250 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4251 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4252 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4254 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4255 snd_soc_dai_set_widget_playback(dai, w); in snd_soc_dapm_new_dai_widgets()
4266 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4267 if (IS_ERR(w)) in snd_soc_dapm_new_dai_widgets()
4268 return PTR_ERR(w); in snd_soc_dapm_new_dai_widgets()
4270 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4271 snd_soc_dai_set_widget_capture(dai, w); in snd_soc_dapm_new_dai_widgets()
4280 struct snd_soc_dapm_widget *dai_w, *w; in snd_soc_dapm_link_dai_widgets() local
4304 for_each_card_widgets(card, w) { in snd_soc_dapm_link_dai_widgets()
4305 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4308 switch (w->id) { in snd_soc_dapm_link_dai_widgets()
4316 if (!w->sname || !strstr(w->sname, dai_w->sname)) in snd_soc_dapm_link_dai_widgets()
4321 sink = w; in snd_soc_dapm_link_dai_widgets()
4323 src = w; in snd_soc_dapm_link_dai_widgets()
4327 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4401 struct snd_soc_dapm_widget *w; in soc_dapm_dai_stream_event() local
4403 w = snd_soc_dai_get_widget(dai, stream); in soc_dapm_dai_stream_event()
4405 if (w) { in soc_dapm_dai_stream_event()
4408 dapm_mark_dirty(w, "stream event"); in soc_dapm_dai_stream_event()
4410 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4412 dapm_widget_invalidate_input_paths(w); in soc_dapm_dai_stream_event()
4415 dapm_widget_invalidate_output_paths(w); in soc_dapm_dai_stream_event()
4420 w->active = 1; in soc_dapm_dai_stream_event()
4421 w->is_ep = ep; in soc_dapm_dai_stream_event()
4424 w->active = 0; in soc_dapm_dai_stream_event()
4425 w->is_ep = 0; in soc_dapm_dai_stream_event()
4585 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked() local
4587 if (!w) { in snd_soc_dapm_force_enable_pin_unlocked()
4592 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4593 if (!w->connected) { in snd_soc_dapm_force_enable_pin_unlocked()
4595 * w->force does not affect the number of input or output paths, in snd_soc_dapm_force_enable_pin_unlocked()
4596 * so we only have to recheck if w->connected is changed in snd_soc_dapm_force_enable_pin_unlocked()
4598 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
4599 dapm_widget_invalidate_output_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
4600 w->connected = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4602 w->force = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4603 dapm_mark_dirty(w, "force enable"); in snd_soc_dapm_force_enable_pin_unlocked()
4743 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status() local
4745 if (w) in snd_soc_dapm_get_pin_status()
4746 return w->connected; in snd_soc_dapm_get_pin_status()
4766 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend() local
4768 if (!w) { in snd_soc_dapm_ignore_suspend()
4773 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4818 struct snd_soc_dapm_widget *w; in soc_dapm_shutdown_dapm() local
4824 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4825 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4827 if (w->power) { in soc_dapm_shutdown_dapm()
4828 dapm_seq_insert(w, &down_list, false); in soc_dapm_shutdown_dapm()
4829 w->new_power = 0; in soc_dapm_shutdown_dapm()