Lines Matching refs:w
146 static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w) in dapm_dirty_widget() argument
148 return !list_empty(&w->dirty); in dapm_dirty_widget()
151 static void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason) in dapm_mark_dirty() argument
153 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
155 if (!dapm_dirty_widget(w)) { in dapm_mark_dirty()
156 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
157 w->name, reason); in dapm_mark_dirty()
158 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
174 static void dapm_widget_invalidate_input_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_input_paths() argument
180 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_input_paths()
182 if (w->inputs == -1) in dapm_widget_invalidate_input_paths()
185 w->inputs = -1; in dapm_widget_invalidate_input_paths()
186 list_add_tail(&w->work_list, &list); in dapm_widget_invalidate_input_paths()
188 list_for_each_entry(w, &list, work_list) { in dapm_widget_invalidate_input_paths()
189 list_for_each_entry(p, &w->sinks, list_source) { in dapm_widget_invalidate_input_paths()
213 static void dapm_widget_invalidate_output_paths(struct snd_soc_dapm_widget *w) in dapm_widget_invalidate_output_paths() argument
219 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_output_paths()
221 if (w->outputs == -1) in dapm_widget_invalidate_output_paths()
224 w->outputs = -1; in dapm_widget_invalidate_output_paths()
225 list_add_tail(&w->work_list, &list); in dapm_widget_invalidate_output_paths()
227 list_for_each_entry(w, &list, work_list) { in dapm_widget_invalidate_output_paths()
228 list_for_each_entry(p, &w->sources, list_sink) { in dapm_widget_invalidate_output_paths()
274 struct snd_soc_dapm_widget *w; in dapm_mark_endpoints_dirty() local
278 list_for_each_entry(w, &card->widgets, list) { in dapm_mark_endpoints_dirty()
279 if (w->is_sink || w->is_source) { in dapm_mark_endpoints_dirty()
280 dapm_mark_dirty(w, "Rechecking endpoints"); in dapm_mark_endpoints_dirty()
281 if (w->is_sink) in dapm_mark_endpoints_dirty()
282 dapm_widget_invalidate_output_paths(w); in dapm_mark_endpoints_dirty()
283 if (w->is_source) in dapm_mark_endpoints_dirty()
284 dapm_widget_invalidate_input_paths(w); in dapm_mark_endpoints_dirty()
478 struct snd_soc_dapm_widget *w; in dapm_reset() local
484 list_for_each_entry(w, &card->widgets, list) { in dapm_reset()
485 w->new_power = w->power; in dapm_reset()
486 w->power_checked = false; in dapm_reset()
648 struct snd_soc_dapm_widget *w; in dapm_is_shared_kcontrol() local
653 list_for_each_entry(w, &dapm->card->widgets, list) { in dapm_is_shared_kcontrol()
654 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
656 for (i = 0; i < w->num_kcontrols; i++) { in dapm_is_shared_kcontrol()
657 if (&w->kcontrol_news[i] == kcontrol_new) { in dapm_is_shared_kcontrol()
658 if (w->kcontrols) in dapm_is_shared_kcontrol()
659 *kcontrol = w->kcontrols[i]; in dapm_is_shared_kcontrol()
672 static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, in dapm_create_or_share_mixmux_kcontrol() argument
675 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_mixmux_kcontrol()
692 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_mixmux_kcontrol()
700 switch (w->id) { in dapm_create_or_share_mixmux_kcontrol()
727 w->name + prefix_len, in dapm_create_or_share_mixmux_kcontrol()
728 w->kcontrol_news[kci].name); in dapm_create_or_share_mixmux_kcontrol()
735 name = w->name + prefix_len; in dapm_create_or_share_mixmux_kcontrol()
738 name = w->kcontrol_news[kci].name; in dapm_create_or_share_mixmux_kcontrol()
741 kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name, in dapm_create_or_share_mixmux_kcontrol()
750 ret = dapm_kcontrol_data_alloc(w, kcontrol); in dapm_create_or_share_mixmux_kcontrol()
760 w->name, name, ret); in dapm_create_or_share_mixmux_kcontrol()
765 ret = dapm_kcontrol_add_widget(kcontrol, w); in dapm_create_or_share_mixmux_kcontrol()
767 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_mixmux_kcontrol()
776 static int dapm_new_mixer(struct snd_soc_dapm_widget *w) in dapm_new_mixer() argument
782 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
784 list_for_each_entry(path, &w->sources, list_sink) { in dapm_new_mixer()
786 if (path->name != (char *)w->kcontrol_news[i].name) in dapm_new_mixer()
789 if (w->kcontrols[i]) { in dapm_new_mixer()
790 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
794 ret = dapm_create_or_share_mixmux_kcontrol(w, i); in dapm_new_mixer()
798 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
806 static int dapm_new_mux(struct snd_soc_dapm_widget *w) in dapm_new_mux() argument
808 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
812 if (w->num_kcontrols != 1) { in dapm_new_mux()
815 w->name); in dapm_new_mux()
819 if (list_empty(&w->sources)) { in dapm_new_mux()
820 dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name); in dapm_new_mux()
824 ret = dapm_create_or_share_mixmux_kcontrol(w, 0); in dapm_new_mux()
828 list_for_each_entry(path, &w->sources, list_sink) { in dapm_new_mux()
830 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
837 static int dapm_new_pga(struct snd_soc_dapm_widget *w) in dapm_new_pga() argument
839 if (w->num_kcontrols) in dapm_new_pga()
840 dev_err(w->dapm->dev, in dapm_new_pga()
841 "ASoC: PGA controls not supported: '%s'\n", w->name); in dapm_new_pga()
847 static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) in dapm_new_dai_link() argument
851 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link()
855 if (w->num_params <= 1) in dapm_new_dai_link()
859 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_dai_link()
860 kcontrol = snd_soc_cnew(&w->kcontrol_news[i], w, in dapm_new_dai_link()
861 w->name, NULL); in dapm_new_dai_link()
866 w->name, w->kcontrol_news[i].name, ret); in dapm_new_dai_link()
869 kcontrol->private_data = w; in dapm_new_dai_link()
870 w->kcontrols[i] = kcontrol; in dapm_new_dai_link()
898 struct snd_soc_dapm_widget *w) in dapm_list_add_widget() argument
910 if (wlist->widgets[i] == w) in dapm_list_add_widget()
920 dev_err(w->dapm->dev, "ASoC: can't allocate widget list for %s\n", in dapm_list_add_widget()
921 w->name); in dapm_list_add_widget()
927 dev_dbg(w->dapm->dev, "ASoC: added %s in widget list pos %d\n", in dapm_list_add_widget()
928 w->name, wlist->num_widgets); in dapm_list_add_widget()
930 wlist->widgets[wlist->num_widgets] = w; in dapm_list_add_widget()
1067 struct snd_soc_dapm_widget *w; in snd_soc_dapm_dai_get_connected_widgets() local
1076 list_for_each_entry(w, &card->widgets, list) { in snd_soc_dapm_dai_get_connected_widgets()
1077 w->inputs = -1; in snd_soc_dapm_dai_get_connected_widgets()
1078 w->outputs = -1; in snd_soc_dapm_dai_get_connected_widgets()
1095 int dapm_regulator_event(struct snd_soc_dapm_widget *w, in dapm_regulator_event() argument
1100 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1103 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1104 ret = regulator_allow_bypass(w->regulator, false); in dapm_regulator_event()
1106 dev_warn(w->dapm->dev, in dapm_regulator_event()
1108 w->name, ret); in dapm_regulator_event()
1111 return regulator_enable(w->regulator); in dapm_regulator_event()
1113 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in dapm_regulator_event()
1114 ret = regulator_allow_bypass(w->regulator, true); in dapm_regulator_event()
1116 dev_warn(w->dapm->dev, in dapm_regulator_event()
1118 w->name, ret); in dapm_regulator_event()
1121 return regulator_disable_deferred(w->regulator, w->shift); in dapm_regulator_event()
1129 int dapm_clock_event(struct snd_soc_dapm_widget *w, in dapm_clock_event() argument
1132 if (!w->clk) in dapm_clock_event()
1135 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1139 return clk_prepare_enable(w->clk); in dapm_clock_event()
1141 clk_disable_unprepare(w->clk); in dapm_clock_event()
1149 static int dapm_widget_power_check(struct snd_soc_dapm_widget *w) in dapm_widget_power_check() argument
1151 if (w->power_checked) in dapm_widget_power_check()
1152 return w->new_power; in dapm_widget_power_check()
1154 if (w->force) in dapm_widget_power_check()
1155 w->new_power = 1; in dapm_widget_power_check()
1157 w->new_power = w->power_check(w); in dapm_widget_power_check()
1159 w->power_checked = true; in dapm_widget_power_check()
1161 return w->new_power; in dapm_widget_power_check()
1166 static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) in dapm_generic_check_power() argument
1170 DAPM_UPDATE_STAT(w, power_checks); in dapm_generic_check_power()
1172 in = is_connected_input_ep(w, NULL); in dapm_generic_check_power()
1173 out = is_connected_output_ep(w, NULL); in dapm_generic_check_power()
1178 static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) in dapm_supply_check_power() argument
1182 DAPM_UPDATE_STAT(w, power_checks); in dapm_supply_check_power()
1185 list_for_each_entry(path, &w->sinks, list_source) { in dapm_supply_check_power()
1186 DAPM_UPDATE_STAT(w, neighbour_checks); in dapm_supply_check_power()
1202 static int dapm_always_on_check_power(struct snd_soc_dapm_widget *w) in dapm_always_on_check_power() argument
1239 struct snd_soc_dapm_widget *w; in dapm_seq_insert() local
1241 list_for_each_entry(w, list, power_list) in dapm_seq_insert()
1242 if (dapm_seq_compare(new_widget, w, power_up) < 0) { in dapm_seq_insert()
1243 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1251 struct snd_soc_dapm_widget *w, int event) in dapm_seq_check_event() argument
1286 if (w->new_power != power) in dapm_seq_check_event()
1289 if (w->event && (w->event_flags & event)) { in dapm_seq_check_event()
1290 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1291 w->name, ev_name); in dapm_seq_check_event()
1292 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1293 trace_snd_soc_dapm_widget_event_start(w, event); in dapm_seq_check_event()
1294 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1295 trace_snd_soc_dapm_widget_event_done(w, event); in dapm_seq_check_event()
1297 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1298 ev_name, w->name, ret); in dapm_seq_check_event()
1307 struct snd_soc_dapm_widget *w; in dapm_seq_run_coalesced() local
1312 w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list); in dapm_seq_run_coalesced()
1313 reg = w->reg; in dapm_seq_run_coalesced()
1314 dapm = w->dapm; in dapm_seq_run_coalesced()
1316 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1317 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1318 w->power = w->new_power; in dapm_seq_run_coalesced()
1320 mask |= w->mask << w->shift; in dapm_seq_run_coalesced()
1321 if (w->power) in dapm_seq_run_coalesced()
1322 value |= w->on_val << w->shift; in dapm_seq_run_coalesced()
1324 value |= w->off_val << w->shift; in dapm_seq_run_coalesced()
1328 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1331 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU); in dapm_seq_run_coalesced()
1332 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMD); in dapm_seq_run_coalesced()
1347 list_for_each_entry(w, pending, power_list) { in dapm_seq_run_coalesced()
1348 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU); in dapm_seq_run_coalesced()
1349 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD); in dapm_seq_run_coalesced()
1364 struct snd_soc_dapm_widget *w, *n; in dapm_seq_run() local
1379 list_for_each_entry_safe(w, n, list, power_list) { in dapm_seq_run()
1383 if (sort[w->id] != cur_sort || w->reg != cur_reg || in dapm_seq_run()
1384 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1396 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1406 switch (w->id) { in dapm_seq_run()
1408 if (!w->event) in dapm_seq_run()
1409 list_for_each_entry_safe_continue(w, n, list, in dapm_seq_run()
1413 ret = w->event(w, in dapm_seq_run()
1416 ret = w->event(w, in dapm_seq_run()
1421 if (!w->event) in dapm_seq_run()
1422 list_for_each_entry_safe_continue(w, n, list, in dapm_seq_run()
1426 ret = w->event(w, in dapm_seq_run()
1429 ret = w->event(w, in dapm_seq_run()
1435 cur_sort = sort[w->id]; in dapm_seq_run()
1436 cur_subseq = w->subseq; in dapm_seq_run()
1437 cur_reg = w->reg; in dapm_seq_run()
1438 cur_dapm = w->dapm; in dapm_seq_run()
1439 list_move(&w->power_list, &pending); in dapm_seq_run()
1444 dev_err(w->dapm->dev, in dapm_seq_run()
1467 struct snd_soc_dapm_widget *w = NULL; in dapm_widget_update() local
1477 w = wlist->widgets[wi]; in dapm_widget_update()
1479 if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) { in dapm_widget_update()
1480 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); in dapm_widget_update()
1482 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1483 w->name, ret); in dapm_widget_update()
1487 if (!w) in dapm_widget_update()
1490 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1493 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1494 w->name, ret); in dapm_widget_update()
1497 w = wlist->widgets[wi]; in dapm_widget_update()
1499 if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) { in dapm_widget_update()
1500 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); in dapm_widget_update()
1502 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1503 w->name, ret); in dapm_widget_update()
1595 static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, in dapm_widget_set_power() argument
1601 if (w->power == power) in dapm_widget_set_power()
1604 trace_snd_soc_dapm_widget_power(w, power); in dapm_widget_set_power()
1609 list_for_each_entry(path, &w->sources, list_sink) in dapm_widget_set_power()
1613 if (!w->is_supply) { in dapm_widget_set_power()
1614 list_for_each_entry(path, &w->sinks, list_source) in dapm_widget_set_power()
1620 dapm_seq_insert(w, up_list, true); in dapm_widget_set_power()
1622 dapm_seq_insert(w, down_list, false); in dapm_widget_set_power()
1625 static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, in dapm_power_one_widget() argument
1631 switch (w->id) { in dapm_power_one_widget()
1633 dapm_seq_insert(w, down_list, false); in dapm_power_one_widget()
1636 dapm_seq_insert(w, up_list, true); in dapm_power_one_widget()
1640 power = dapm_widget_power_check(w); in dapm_power_one_widget()
1642 dapm_widget_set_power(w, power, up_list, down_list); in dapm_power_one_widget()
1674 struct snd_soc_dapm_widget *w; in dapm_power_widgets() local
1700 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
1701 dapm_power_one_widget(w, &up_list, &down_list); in dapm_power_widgets()
1704 list_for_each_entry(w, &card->widgets, list) { in dapm_power_widgets()
1705 switch (w->id) { in dapm_power_widgets()
1711 list_del_init(&w->dirty); in dapm_power_widgets()
1715 if (w->new_power) { in dapm_power_widgets()
1716 d = w->dapm; in dapm_power_widgets()
1725 switch (w->id) { in dapm_power_widgets()
1767 list_for_each_entry(w, &down_list, power_list) { in dapm_power_widgets()
1768 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMD); in dapm_power_widgets()
1771 list_for_each_entry(w, &up_list, power_list) { in dapm_power_widgets()
1772 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMU); in dapm_power_widgets()
1813 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file() local
1814 struct snd_soc_card *card = w->dapm->card; in dapm_widget_power_read_file()
1827 if (w->is_supply) { in dapm_widget_power_read_file()
1831 in = is_connected_input_ep(w, NULL); in dapm_widget_power_read_file()
1832 out = is_connected_output_ep(w, NULL); in dapm_widget_power_read_file()
1836 w->name, w->power ? "On" : "Off", in dapm_widget_power_read_file()
1837 w->force ? " (forced)" : "", in, out); in dapm_widget_power_read_file()
1839 if (w->reg >= 0) in dapm_widget_power_read_file()
1842 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
1846 if (w->sname) in dapm_widget_power_read_file()
1848 w->sname, in dapm_widget_power_read_file()
1849 w->active ? "active" : "inactive"); in dapm_widget_power_read_file()
1851 list_for_each_entry(p, &w->sources, list_sink) { in dapm_widget_power_read_file()
1852 if (p->connected && !p->connected(w, p->source)) in dapm_widget_power_read_file()
1861 list_for_each_entry(p, &w->sinks, list_source) { in dapm_widget_power_read_file()
1862 if (p->connected && !p->connected(w, p->sink)) in dapm_widget_power_read_file()
1945 static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
1947 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget()
1950 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
1953 d = debugfs_create_file(w->name, 0444, in dapm_debugfs_add_widget()
1954 dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
1957 dev_warn(w->dapm->dev, in dapm_debugfs_add_widget()
1959 w->name); in dapm_debugfs_add_widget()
1973 static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) in dapm_debugfs_add_widget() argument
2089 struct snd_soc_dapm_widget *w; in dapm_widget_show_codec() local
2093 list_for_each_entry(w, &codec->component.card->widgets, list) { in dapm_widget_show_codec()
2094 if (w->dapm != &codec->dapm) in dapm_widget_show_codec()
2098 switch (w->id) { in dapm_widget_show_codec()
2113 if (w->name) in dapm_widget_show_codec()
2115 w->name, w->power ? "On":"Off"); in dapm_widget_show_codec()
2179 struct snd_soc_dapm_widget *w, *next_w; in dapm_free_widgets() local
2182 list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { in dapm_free_widgets()
2183 if (w->dapm != dapm) in dapm_free_widgets()
2185 list_del(&w->list); in dapm_free_widgets()
2191 list_for_each_entry_safe(p, next_p, &w->sources, list_sink) in dapm_free_widgets()
2194 list_for_each_entry_safe(p, next_p, &w->sinks, list_source) in dapm_free_widgets()
2197 kfree(w->kcontrols); in dapm_free_widgets()
2198 kfree(w->name); in dapm_free_widgets()
2199 kfree(w); in dapm_free_widgets()
2207 struct snd_soc_dapm_widget *w; in dapm_find_widget() local
2210 list_for_each_entry(w, &dapm->card->widgets, list) { in dapm_find_widget()
2211 if (!strcmp(w->name, pin)) { in dapm_find_widget()
2212 if (w->dapm == dapm) in dapm_find_widget()
2213 return w; in dapm_find_widget()
2215 fallback = w; in dapm_find_widget()
2228 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_set_pin() local
2232 if (!w) { in snd_soc_dapm_set_pin()
2237 if (w->connected != status) { in snd_soc_dapm_set_pin()
2238 dapm_mark_dirty(w, "pin configuration"); in snd_soc_dapm_set_pin()
2239 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_set_pin()
2240 dapm_widget_invalidate_output_paths(w); in snd_soc_dapm_set_pin()
2243 w->connected = status; in snd_soc_dapm_set_pin()
2245 w->force = 0; in snd_soc_dapm_set_pin()
2303 static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) in dapm_update_widget_flags() argument
2307 switch (w->id) { in dapm_update_widget_flags()
2310 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2312 w->is_source = 1; in dapm_update_widget_flags()
2313 list_for_each_entry(p, &w->sources, list_sink) { in dapm_update_widget_flags()
2318 w->is_source = 0; in dapm_update_widget_flags()
2325 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2327 w->is_sink = 1; in dapm_update_widget_flags()
2328 list_for_each_entry(p, &w->sinks, list_source) { in dapm_update_widget_flags()
2333 w->is_sink = 0; in dapm_update_widget_flags()
2339 w->is_sink = !list_empty(&w->sources); in dapm_update_widget_flags()
2340 w->is_source = !list_empty(&w->sinks); in dapm_update_widget_flags()
2441 struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w; in snd_soc_dapm_add_route() local
2467 list_for_each_entry(w, &dapm->card->widgets, list) { in snd_soc_dapm_add_route()
2468 if (!wsink && !(strcmp(w->name, sink))) { in snd_soc_dapm_add_route()
2469 wtsink = w; in snd_soc_dapm_add_route()
2470 if (w->dapm == dapm) in snd_soc_dapm_add_route()
2471 wsink = w; in snd_soc_dapm_add_route()
2474 if (!wsource && !(strcmp(w->name, source))) { in snd_soc_dapm_add_route()
2475 wtsource = w; in snd_soc_dapm_add_route()
2476 if (w->dapm == dapm) in snd_soc_dapm_add_route()
2477 wsource = w; in snd_soc_dapm_add_route()
2721 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_widgets() local
2726 list_for_each_entry(w, &card->widgets, list) in snd_soc_dapm_new_widgets()
2728 if (w->new) in snd_soc_dapm_new_widgets()
2731 if (w->num_kcontrols) { in snd_soc_dapm_new_widgets()
2732 w->kcontrols = kzalloc(w->num_kcontrols * in snd_soc_dapm_new_widgets()
2735 if (!w->kcontrols) { in snd_soc_dapm_new_widgets()
2741 switch(w->id) { in snd_soc_dapm_new_widgets()
2745 dapm_new_mixer(w); in snd_soc_dapm_new_widgets()
2748 dapm_new_mux(w); in snd_soc_dapm_new_widgets()
2752 dapm_new_pga(w); in snd_soc_dapm_new_widgets()
2755 dapm_new_dai_link(w); in snd_soc_dapm_new_widgets()
2762 if (w->reg >= 0) { in snd_soc_dapm_new_widgets()
2763 soc_dapm_read(w->dapm, w->reg, &val); in snd_soc_dapm_new_widgets()
2764 val = val >> w->shift; in snd_soc_dapm_new_widgets()
2765 val &= w->mask; in snd_soc_dapm_new_widgets()
2766 if (val == w->on_val) in snd_soc_dapm_new_widgets()
2767 w->power = 1; in snd_soc_dapm_new_widgets()
2770 w->new = 1; in snd_soc_dapm_new_widgets()
2772 dapm_mark_dirty(w, "new widget"); in snd_soc_dapm_new_widgets()
2773 dapm_debugfs_add_widget(w); in snd_soc_dapm_new_widgets()
3069 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_control() local
3073 if ((w = dapm_cnew_widget(widget)) == NULL) in snd_soc_dapm_new_control()
3076 switch (w->id) { in snd_soc_dapm_new_control()
3078 w->regulator = devm_regulator_get(dapm->dev, w->name); in snd_soc_dapm_new_control()
3079 if (IS_ERR(w->regulator)) { in snd_soc_dapm_new_control()
3080 ret = PTR_ERR(w->regulator); in snd_soc_dapm_new_control()
3082 w->name, ret); in snd_soc_dapm_new_control()
3086 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_new_control()
3087 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_new_control()
3089 dev_warn(w->dapm->dev, in snd_soc_dapm_new_control()
3091 w->name, ret); in snd_soc_dapm_new_control()
3096 w->clk = devm_clk_get(dapm->dev, w->name); in snd_soc_dapm_new_control()
3097 if (IS_ERR(w->clk)) { in snd_soc_dapm_new_control()
3098 ret = PTR_ERR(w->clk); in snd_soc_dapm_new_control()
3100 w->name, ret); in snd_soc_dapm_new_control()
3113 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name); in snd_soc_dapm_new_control()
3115 w->name = kasprintf(GFP_KERNEL, "%s", widget->name); in snd_soc_dapm_new_control()
3116 if (w->name == NULL) { in snd_soc_dapm_new_control()
3117 kfree(w); in snd_soc_dapm_new_control()
3121 switch (w->id) { in snd_soc_dapm_new_control()
3123 w->is_source = 1; in snd_soc_dapm_new_control()
3124 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control()
3128 w->is_source = 1; in snd_soc_dapm_new_control()
3129 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control()
3133 w->is_sink = 1; in snd_soc_dapm_new_control()
3134 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control()
3138 w->is_sink = 1; in snd_soc_dapm_new_control()
3139 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control()
3143 w->is_source = 1; in snd_soc_dapm_new_control()
3144 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control()
3161 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control()
3167 w->is_supply = 1; in snd_soc_dapm_new_control()
3168 w->power_check = dapm_supply_check_power; in snd_soc_dapm_new_control()
3171 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control()
3175 w->dapm = dapm; in snd_soc_dapm_new_control()
3176 INIT_LIST_HEAD(&w->sources); in snd_soc_dapm_new_control()
3177 INIT_LIST_HEAD(&w->sinks); in snd_soc_dapm_new_control()
3178 INIT_LIST_HEAD(&w->list); in snd_soc_dapm_new_control()
3179 INIT_LIST_HEAD(&w->dirty); in snd_soc_dapm_new_control()
3180 list_add(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control()
3182 w->inputs = -1; in snd_soc_dapm_new_control()
3183 w->outputs = -1; in snd_soc_dapm_new_control()
3186 w->connected = 1; in snd_soc_dapm_new_control()
3187 return w; in snd_soc_dapm_new_control()
3204 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_controls() local
3210 w = snd_soc_dapm_new_control(dapm, widget); in snd_soc_dapm_new_controls()
3211 if (!w) { in snd_soc_dapm_new_controls()
3225 static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, in snd_soc_dai_link_event() argument
3230 const struct snd_soc_pcm_stream *config = w->params + w->params_select; in snd_soc_dai_link_event()
3237 WARN_ON(list_empty(&w->sources) || list_empty(&w->sinks))) in snd_soc_dai_link_event()
3241 source_p = list_first_entry(&w->sources, struct snd_soc_dapm_path, in snd_soc_dai_link_event()
3243 sink_p = list_first_entry(&w->sinks, struct snd_soc_dapm_path, in snd_soc_dai_link_event()
3258 dev_warn(w->dapm->dev, "ASoC: Invalid format %llx specified\n", in snd_soc_dai_link_event()
3325 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_get() local
3327 ucontrol->value.enumerated.item[0] = w->params_select; in snd_soc_dapm_dai_link_get()
3335 struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); in snd_soc_dapm_dai_link_put() local
3338 if (w->power) in snd_soc_dapm_dai_link_put()
3341 if (ucontrol->value.enumerated.item[0] == w->params_select) in snd_soc_dapm_dai_link_put()
3344 if (ucontrol->value.enumerated.item[0] >= w->num_params) in snd_soc_dapm_dai_link_put()
3347 w->params_select = ucontrol->value.enumerated.item[0]; in snd_soc_dapm_dai_link_put()
3359 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_pcm() local
3448 w = snd_soc_dapm_new_control(&card->dapm, &template); in snd_soc_dapm_new_pcm()
3449 if (!w) { in snd_soc_dapm_new_pcm()
3456 w->params = params; in snd_soc_dapm_new_pcm()
3457 w->num_params = num_params; in snd_soc_dapm_new_pcm()
3459 ret = snd_soc_dapm_add_path(&card->dapm, source, w, NULL, NULL); in snd_soc_dapm_new_pcm()
3462 return snd_soc_dapm_add_path(&card->dapm, w, sink, NULL, NULL); in snd_soc_dapm_new_pcm()
3465 devm_kfree(card->dev, w); in snd_soc_dapm_new_pcm()
3484 struct snd_soc_dapm_widget *w; in snd_soc_dapm_new_dai_widgets() local
3499 w = snd_soc_dapm_new_control(dapm, &template); in snd_soc_dapm_new_dai_widgets()
3500 if (!w) { in snd_soc_dapm_new_dai_widgets()
3506 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
3507 dai->playback_widget = w; in snd_soc_dapm_new_dai_widgets()
3518 w = snd_soc_dapm_new_control(dapm, &template); in snd_soc_dapm_new_dai_widgets()
3519 if (!w) { in snd_soc_dapm_new_dai_widgets()
3525 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
3526 dai->capture_widget = w; in snd_soc_dapm_new_dai_widgets()
3534 struct snd_soc_dapm_widget *dai_w, *w; in snd_soc_dapm_link_dai_widgets() local
3551 list_for_each_entry(w, &card->widgets, list) { in snd_soc_dapm_link_dai_widgets()
3552 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
3555 switch (w->id) { in snd_soc_dapm_link_dai_widgets()
3563 if (!w->sname || !strstr(w->sname, dai_w->sname)) in snd_soc_dapm_link_dai_widgets()
3568 sink = w; in snd_soc_dapm_link_dai_widgets()
3570 src = w; in snd_soc_dapm_link_dai_widgets()
3574 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
3625 struct snd_soc_dapm_widget *w; in soc_dapm_dai_stream_event() local
3628 w = dai->playback_widget; in soc_dapm_dai_stream_event()
3630 w = dai->capture_widget; in soc_dapm_dai_stream_event()
3632 if (w) { in soc_dapm_dai_stream_event()
3633 dapm_mark_dirty(w, "stream event"); in soc_dapm_dai_stream_event()
3637 w->active = 1; in soc_dapm_dai_stream_event()
3640 w->active = 0; in soc_dapm_dai_stream_event()
3649 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
3650 w->is_source = w->active; in soc_dapm_dai_stream_event()
3651 dapm_widget_invalidate_input_paths(w); in soc_dapm_dai_stream_event()
3653 w->is_sink = w->active; in soc_dapm_dai_stream_event()
3654 dapm_widget_invalidate_output_paths(w); in soc_dapm_dai_stream_event()
3774 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked() local
3776 if (!w) { in snd_soc_dapm_force_enable_pin_unlocked()
3781 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
3782 if (!w->connected) { in snd_soc_dapm_force_enable_pin_unlocked()
3787 dapm_widget_invalidate_input_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
3788 dapm_widget_invalidate_output_paths(w); in snd_soc_dapm_force_enable_pin_unlocked()
3789 w->connected = 1; in snd_soc_dapm_force_enable_pin_unlocked()
3791 w->force = 1; in snd_soc_dapm_force_enable_pin_unlocked()
3792 dapm_mark_dirty(w, "force enable"); in snd_soc_dapm_force_enable_pin_unlocked()
3932 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status() local
3934 if (w) in snd_soc_dapm_get_pin_status()
3935 return w->connected; in snd_soc_dapm_get_pin_status()
3955 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend() local
3957 if (!w) { in snd_soc_dapm_ignore_suspend()
3962 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
3985 struct snd_soc_dapm_widget *w; in soc_dapm_shutdown_dapm() local
3991 list_for_each_entry(w, &dapm->card->widgets, list) { in soc_dapm_shutdown_dapm()
3992 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
3994 if (w->power) { in soc_dapm_shutdown_dapm()
3995 dapm_seq_insert(w, &down_list, false); in soc_dapm_shutdown_dapm()
3996 w->power = 0; in soc_dapm_shutdown_dapm()