Lines Matching +full:custom +full:- +full:rtd
1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
12 // o Platform power domain - can support external components i.e. amps and
15 // o Jack insertion power event initiation - e.g. hp insertion will enable
43 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
52 /* dapm power sequences - make this per codec in the future */
137 if (snd_soc_card_is_instantiated(dapm->card)) in dapm_assert_locked()
170 return !list_empty(&w->dirty); in dapm_dirty_widget()
175 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
178 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
179 w->name, reason); in dapm_mark_dirty()
180 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
199 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_paths()
201 if (w->endpoints[dir] == -1) in dapm_widget_invalidate_paths()
204 list_add_tail(&w->work_list, &list); in dapm_widget_invalidate_paths()
205 w->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
209 if (p->is_supply || !p->connect) in dapm_widget_invalidate_paths()
211 node = p->node[rdir]; in dapm_widget_invalidate_paths()
212 if (node->endpoints[dir] != -1) { in dapm_widget_invalidate_paths()
213 node->endpoints[dir] = -1; in dapm_widget_invalidate_paths()
214 list_add_tail(&node->work_list, &list); in dapm_widget_invalidate_paths()
221 * dapm_widget_invalidate_input_paths() - Invalidate the cached number of
238 * dapm_widget_invalidate_output_paths() - Invalidate the cached number of
255 * dapm_path_invalidate() - Invalidates the cached number of inputs and outputs
271 if (p->is_supply) in dapm_path_invalidate()
278 * so there is no need to re-check the path. in dapm_path_invalidate()
280 if (p->source->endpoints[SND_SOC_DAPM_DIR_IN] != 0) in dapm_path_invalidate()
281 dapm_widget_invalidate_input_paths(p->sink); in dapm_path_invalidate()
282 if (p->sink->endpoints[SND_SOC_DAPM_DIR_OUT] != 0) in dapm_path_invalidate()
283 dapm_widget_invalidate_output_paths(p->source); in dapm_path_invalidate()
293 if (w->is_ep) { in snd_soc_dapm_mark_endpoints_dirty()
295 if (w->is_ep & SND_SOC_DAPM_EP_SINK) in snd_soc_dapm_mark_endpoints_dirty()
297 if (w->is_ep & SND_SOC_DAPM_EP_SOURCE) in snd_soc_dapm_mark_endpoints_dirty()
317 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, _widget->name); in dapm_cnew_widget()
319 w->name = kstrdup_const(_widget->name, GFP_KERNEL); in dapm_cnew_widget()
320 if (!w->name) in dapm_cnew_widget()
323 if (_widget->sname) { in dapm_cnew_widget()
324 w->sname = kstrdup_const(_widget->sname, GFP_KERNEL); in dapm_cnew_widget()
325 if (!w->sname) { in dapm_cnew_widget()
326 kfree_const(w->name); in dapm_cnew_widget()
343 if (!dapm->component) in soc_dapm_read()
344 return -EIO; in soc_dapm_read()
345 return snd_soc_component_read(dapm->component, reg); in soc_dapm_read()
353 p->sink->kcontrol_news[i].private_value; in dapm_set_mixer_path_status()
354 unsigned int reg = mc->reg; in dapm_set_mixer_path_status()
355 unsigned int invert = mc->invert; in dapm_set_mixer_path_status()
358 unsigned int shift = mc->shift; in dapm_set_mixer_path_status()
359 unsigned int max = mc->max; in dapm_set_mixer_path_status()
360 unsigned int mask = (1 << fls(max)) - 1; in dapm_set_mixer_path_status()
361 unsigned int val = soc_dapm_read(p->sink->dapm, reg); in dapm_set_mixer_path_status()
376 if (reg != mc->rreg) in dapm_set_mixer_path_status()
377 val = soc_dapm_read(p->sink->dapm, mc->rreg); in dapm_set_mixer_path_status()
378 val = (val >> mc->rshift) & mask; in dapm_set_mixer_path_status()
383 val = max - val; in dapm_set_mixer_path_status()
384 p->connect = !!val; in dapm_set_mixer_path_status()
392 p->connect = invert; in dapm_set_mixer_path_status()
401 const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; in dapm_connect_mux()
402 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in dapm_connect_mux()
406 if (e->reg != SND_SOC_NOPM) { in dapm_connect_mux()
409 val = soc_dapm_read(dapm, e->reg); in dapm_connect_mux()
410 val = (val >> e->shift_l) & e->mask; in dapm_connect_mux()
422 i = match_string(e->texts, e->items, control_name); in dapm_connect_mux()
424 return -ENODEV; in dapm_connect_mux()
426 path->name = e->texts[i]; in dapm_connect_mux()
427 path->connect = (i == item); in dapm_connect_mux()
439 for (i = 0; i < path->sink->num_kcontrols; i++) { in dapm_connect_mixer()
440 if (!strcmp(control_name, path->sink->kcontrol_news[i].name)) { in dapm_connect_mixer()
441 path->name = path->sink->kcontrol_news[i].name; in dapm_connect_mixer()
446 return -ENODEV; in dapm_connect_mixer()
450 * dapm_update_widget_flags() - Re-compute widget sink and source flags
464 switch (w->id) { in dapm_update_widget_flags()
467 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
471 if (p->source->id == snd_soc_dapm_micbias || in dapm_update_widget_flags()
472 p->source->id == snd_soc_dapm_mic || in dapm_update_widget_flags()
473 p->source->id == snd_soc_dapm_line || in dapm_update_widget_flags()
474 p->source->id == snd_soc_dapm_output) { in dapm_update_widget_flags()
482 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
486 if (p->sink->id == snd_soc_dapm_spk || in dapm_update_widget_flags()
487 p->sink->id == snd_soc_dapm_hp || in dapm_update_widget_flags()
488 p->sink->id == snd_soc_dapm_line || in dapm_update_widget_flags()
489 p->sink->id == snd_soc_dapm_input) { in dapm_update_widget_flags()
498 if (!list_empty(&w->edges[dir])) in dapm_update_widget_flags()
506 w->is_ep = ep; in dapm_update_widget_flags()
520 switch (source->id) { in snd_soc_dapm_check_dynamic_path()
528 switch (sink->id) { in snd_soc_dapm_check_dynamic_path()
540 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
541 "Direct connection between demux and mixer/mux not supported for path %s -> [%s] -> %s\n", in snd_soc_dapm_check_dynamic_path()
542 source->name, control, sink->name); in snd_soc_dapm_check_dynamic_path()
543 return -EINVAL; in snd_soc_dapm_check_dynamic_path()
545 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
546 "Control not supported for path %s -> [%s] -> %s\n", in snd_soc_dapm_check_dynamic_path()
547 source->name, control, sink->name); in snd_soc_dapm_check_dynamic_path()
548 return -EINVAL; in snd_soc_dapm_check_dynamic_path()
565 if (wsink->is_supply && !wsource->is_supply) { in snd_soc_dapm_add_path()
566 dev_err(dapm->dev, in snd_soc_dapm_add_path()
567 "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n", in snd_soc_dapm_add_path()
568 wsource->name, wsink->name); in snd_soc_dapm_add_path()
569 return -EINVAL; in snd_soc_dapm_add_path()
572 if (connected && !wsource->is_supply) { in snd_soc_dapm_add_path()
573 dev_err(dapm->dev, in snd_soc_dapm_add_path()
574 "connected() callback only supported for supply widgets (%s -> %s)\n", in snd_soc_dapm_add_path()
575 wsource->name, wsink->name); in snd_soc_dapm_add_path()
576 return -EINVAL; in snd_soc_dapm_add_path()
579 if (wsource->is_supply && control) { in snd_soc_dapm_add_path()
580 dev_err(dapm->dev, in snd_soc_dapm_add_path()
581 "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n", in snd_soc_dapm_add_path()
582 wsource->name, control, wsink->name); in snd_soc_dapm_add_path()
583 return -EINVAL; in snd_soc_dapm_add_path()
592 return -ENOMEM; in snd_soc_dapm_add_path()
594 path->node[SND_SOC_DAPM_DIR_IN] = wsource; in snd_soc_dapm_add_path()
595 path->node[SND_SOC_DAPM_DIR_OUT] = wsink; in snd_soc_dapm_add_path()
597 path->connected = connected; in snd_soc_dapm_add_path()
598 INIT_LIST_HEAD(&path->list); in snd_soc_dapm_add_path()
599 INIT_LIST_HEAD(&path->list_kcontrol); in snd_soc_dapm_add_path()
601 if (wsource->is_supply || wsink->is_supply) in snd_soc_dapm_add_path()
602 path->is_supply = 1; in snd_soc_dapm_add_path()
606 path->connect = 1; in snd_soc_dapm_add_path()
608 switch (wsource->id) { in snd_soc_dapm_add_path()
618 switch (wsink->id) { in snd_soc_dapm_add_path()
636 list_add(&path->list, &dapm->card->paths); in snd_soc_dapm_add_path()
639 list_add(&path->list_node[dir], &path->node[dir]->edges[dir]); in snd_soc_dapm_add_path()
642 dapm_update_widget_flags(path->node[dir]); in snd_soc_dapm_add_path()
643 dapm_mark_dirty(path->node[dir], "Route added"); in snd_soc_dapm_add_path()
646 if (snd_soc_card_is_instantiated(dapm->card) && path->connect) in snd_soc_dapm_add_path()
666 return -ENOMEM; in dapm_kcontrol_data_alloc()
668 INIT_LIST_HEAD(&data->paths); in dapm_kcontrol_data_alloc()
670 switch (widget->id) { in dapm_kcontrol_data_alloc()
674 mc = (struct soc_mixer_control *)kcontrol->private_value; in dapm_kcontrol_data_alloc()
676 if (mc->autodisable) { in dapm_kcontrol_data_alloc()
680 dev_warn(widget->dapm->dev, in dapm_kcontrol_data_alloc()
687 ret = -ENOMEM; in dapm_kcontrol_data_alloc()
692 template.reg = mc->reg; in dapm_kcontrol_data_alloc()
693 template.mask = (1 << fls(mc->max)) - 1; in dapm_kcontrol_data_alloc()
694 template.shift = mc->shift; in dapm_kcontrol_data_alloc()
695 if (mc->invert) in dapm_kcontrol_data_alloc()
696 template.off_val = mc->max; in dapm_kcontrol_data_alloc()
703 data->value = template.on_val; in dapm_kcontrol_data_alloc()
705 data->widget = in dapm_kcontrol_data_alloc()
706 snd_soc_dapm_new_control_unlocked(widget->dapm, in dapm_kcontrol_data_alloc()
709 if (IS_ERR(data->widget)) { in dapm_kcontrol_data_alloc()
710 ret = PTR_ERR(data->widget); in dapm_kcontrol_data_alloc()
717 e = (struct soc_enum *)kcontrol->private_value; in dapm_kcontrol_data_alloc()
719 if (e->autodisable) { in dapm_kcontrol_data_alloc()
725 ret = -ENOMEM; in dapm_kcontrol_data_alloc()
730 template.reg = e->reg; in dapm_kcontrol_data_alloc()
731 template.mask = e->mask; in dapm_kcontrol_data_alloc()
732 template.shift = e->shift_l; in dapm_kcontrol_data_alloc()
738 data->value = template.on_val; in dapm_kcontrol_data_alloc()
740 data->widget = snd_soc_dapm_new_control_unlocked( in dapm_kcontrol_data_alloc()
741 widget->dapm, &template); in dapm_kcontrol_data_alloc()
743 if (IS_ERR(data->widget)) { in dapm_kcontrol_data_alloc()
744 ret = PTR_ERR(data->widget); in dapm_kcontrol_data_alloc()
748 snd_soc_dapm_add_path(widget->dapm, data->widget, in dapm_kcontrol_data_alloc()
750 } else if (e->reg != SND_SOC_NOPM) { in dapm_kcontrol_data_alloc()
751 data->value = soc_dapm_read(widget->dapm, e->reg) & in dapm_kcontrol_data_alloc()
752 (e->mask << e->shift_l); in dapm_kcontrol_data_alloc()
759 kcontrol->private_data = data; in dapm_kcontrol_data_alloc()
772 list_del(&data->paths); in dapm_kcontrol_free()
773 kfree(data->wlist); in dapm_kcontrol_free()
782 return data->wlist; in dapm_kcontrol_get_wlist()
792 if (data->wlist) in dapm_kcontrol_add_widget()
793 n = data->wlist->num_widgets + 1; in dapm_kcontrol_add_widget()
797 new_wlist = krealloc(data->wlist, in dapm_kcontrol_add_widget()
801 return -ENOMEM; in dapm_kcontrol_add_widget()
803 new_wlist->num_widgets = n; in dapm_kcontrol_add_widget()
804 new_wlist->widgets[n - 1] = widget; in dapm_kcontrol_add_widget()
806 data->wlist = new_wlist; in dapm_kcontrol_add_widget()
816 list_add_tail(&path->list_kcontrol, &data->paths); in dapm_kcontrol_add_path()
823 if (!data->widget) in dapm_kcontrol_is_powered()
826 return data->widget->power; in dapm_kcontrol_is_powered()
834 return &data->paths; in dapm_kcontrol_get_path_list()
845 return data->value; in dapm_kcontrol_get_value()
854 if (data->value == value) in dapm_kcontrol_set_value()
857 if (data->widget) { in dapm_kcontrol_set_value()
858 switch (dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->id) { in dapm_kcontrol_set_value()
862 data->widget->on_val = value & data->widget->mask; in dapm_kcontrol_set_value()
866 data->widget->on_val = value >> data->widget->shift; in dapm_kcontrol_set_value()
869 data->widget->on_val = value; in dapm_kcontrol_set_value()
874 data->value = value; in dapm_kcontrol_set_value()
880 * snd_soc_dapm_kcontrol_widget() - Returns the widget associated to a
887 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]; in snd_soc_dapm_kcontrol_widget()
892 * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a
902 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm; in snd_soc_dapm_kcontrol_dapm()
912 memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); in dapm_reset()
915 w->new_power = w->power; in dapm_reset()
916 w->power_checked = false; in dapm_reset()
922 if (!dapm->component) in soc_dapm_prefix()
924 return dapm->component->name_prefix; in soc_dapm_prefix()
930 if (!dapm->component) in soc_dapm_update_bits()
931 return -EIO; in soc_dapm_update_bits()
932 return snd_soc_component_update_bits(dapm->component, reg, in soc_dapm_update_bits()
939 if (!dapm->component) in soc_dapm_test_bits()
940 return -EIO; in soc_dapm_test_bits()
941 return snd_soc_component_test_bits(dapm->component, reg, mask, value); in soc_dapm_test_bits()
946 if (dapm->component) in soc_dapm_async_complete()
947 snd_soc_component_async_complete(dapm->component); in soc_dapm_async_complete()
954 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
959 if (!strcmp(name, w->name)) in dapm_wcache_lookup()
971 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
992 if (dapm->component) in snd_soc_dapm_force_bias_level()
993 ret = snd_soc_component_set_bias_level(dapm->component, level); in snd_soc_dapm_force_bias_level()
996 dapm->bias_level = level; in snd_soc_dapm_force_bias_level()
1003 * snd_soc_dapm_set_bias_level - set the bias level for the system
1014 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_set_bias_level()
1023 if (dapm != &card->dapm) in snd_soc_dapm_set_bias_level()
1050 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
1051 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
1053 for (i = 0; i < w->num_kcontrols; i++) { in dapm_is_shared_kcontrol()
1054 if (&w->kcontrol_news[i] == kcontrol_new) { in dapm_is_shared_kcontrol()
1055 if (w->kcontrols) in dapm_is_shared_kcontrol()
1056 *kcontrol = w->kcontrols[i]; in dapm_is_shared_kcontrol()
1072 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol()
1073 struct snd_card *card = dapm->card->snd_card; in dapm_create_or_share_kcontrol()
1089 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
1097 switch (w->id) { in dapm_create_or_share_kcontrol()
1116 return -EINVAL; in dapm_create_or_share_kcontrol()
1119 if (w->no_wname_in_kcontrol_name) in dapm_create_or_share_kcontrol()
1130 w->name + prefix_len, in dapm_create_or_share_kcontrol()
1131 w->kcontrol_news[kci].name); in dapm_create_or_share_kcontrol()
1133 return -ENOMEM; in dapm_create_or_share_kcontrol()
1138 name = w->name + prefix_len; in dapm_create_or_share_kcontrol()
1141 name = w->kcontrol_news[kci].name; in dapm_create_or_share_kcontrol()
1144 kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name, in dapm_create_or_share_kcontrol()
1147 ret = -ENOMEM; in dapm_create_or_share_kcontrol()
1151 kcontrol->private_free = dapm_kcontrol_free; in dapm_create_or_share_kcontrol()
1161 dev_err(dapm->dev, in dapm_create_or_share_kcontrol()
1163 w->name, name, ret); in dapm_create_or_share_kcontrol()
1170 w->kcontrols[kci] = kcontrol; in dapm_create_or_share_kcontrol()
1186 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_mixer()
1190 if (path->name != (char *)w->kcontrol_news[i].name) in dapm_new_mixer()
1193 if (!w->kcontrols[i]) { in dapm_new_mixer()
1199 dapm_kcontrol_add_path(w->kcontrols[i], path); in dapm_new_mixer()
1201 data = snd_kcontrol_chip(w->kcontrols[i]); in dapm_new_mixer()
1202 if (data->widget) in dapm_new_mixer()
1203 snd_soc_dapm_add_path(data->widget->dapm, in dapm_new_mixer()
1204 data->widget, in dapm_new_mixer()
1205 path->source, in dapm_new_mixer()
1216 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux()
1222 switch (w->id) { in dapm_new_mux()
1232 return -EINVAL; in dapm_new_mux()
1235 if (w->num_kcontrols != 1) { in dapm_new_mux()
1236 dev_err(dapm->dev, in dapm_new_mux()
1238 w->name); in dapm_new_mux()
1239 return -EINVAL; in dapm_new_mux()
1242 if (list_empty(&w->edges[dir])) { in dapm_new_mux()
1243 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1244 return -EINVAL; in dapm_new_mux()
1252 if (path->name) in dapm_new_mux()
1253 dapm_kcontrol_add_path(w->kcontrols[0], path); in dapm_new_mux()
1264 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_pga()
1277 struct snd_soc_pcm_runtime *rtd = w->priv; in dapm_new_dai_link() local
1280 if (rtd->dai_link->num_c2c_params <= 1) in dapm_new_dai_link()
1284 for (i = 0; i < w->num_kcontrols; i++) { in dapm_new_dai_link()
1285 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link()
1286 struct snd_card *card = dapm->card->snd_card; in dapm_new_dai_link()
1287 struct snd_kcontrol *kcontrol = snd_soc_cnew(&w->kcontrol_news[i], in dapm_new_dai_link()
1288 w, w->name, NULL); in dapm_new_dai_link()
1292 dev_err(dapm->dev, in dapm_new_dai_link()
1294 w->name, w->kcontrol_news[i].name, ret); in dapm_new_dai_link()
1297 kcontrol->private_data = w; in dapm_new_dai_link()
1298 w->kcontrols[i] = kcontrol; in dapm_new_dai_link()
1305 * the ALSA card - when we are suspending the ALSA state for the card
1310 int level = snd_power_get_state(widget->dapm->card->snd_card); in snd_soc_dapm_suspend_check()
1315 if (widget->ignore_suspend) in snd_soc_dapm_suspend_check()
1316 dev_dbg(widget->dapm->dev, "ASoC: %s ignoring suspend\n", in snd_soc_dapm_suspend_check()
1317 widget->name); in snd_soc_dapm_suspend_check()
1318 return widget->ignore_suspend; in snd_soc_dapm_suspend_check()
1342 return -ENOMEM; in dapm_widget_list_create()
1344 (*list)->num_widgets = size; in dapm_widget_list_create()
1347 (*list)->widgets[i++] = w; in dapm_widget_list_create()
1349 (*list)->num_widgets = i; in dapm_widget_list_create()
1365 widget->endpoints[dir] = -1; in invalidate_paths_ep()
1368 if (path->is_supply) in invalidate_paths_ep()
1371 if (path->walking) in invalidate_paths_ep()
1374 if (path->connect) { in invalidate_paths_ep()
1375 path->walking = 1; in invalidate_paths_ep()
1376 invalidate_paths_ep(path->node[dir], dir); in invalidate_paths_ep()
1377 path->walking = 0; in invalidate_paths_ep()
1401 if (widget->endpoints[dir] >= 0) in is_connected_ep()
1402 return widget->endpoints[dir]; in is_connected_ep()
1408 list_add_tail(&widget->work_list, list); in is_connected_ep()
1415 if ((widget->is_ep & SND_SOC_DAPM_DIR_TO_EP(dir)) && widget->connected) { in is_connected_ep()
1416 widget->endpoints[dir] = snd_soc_dapm_suspend_check(widget); in is_connected_ep()
1417 return widget->endpoints[dir]; in is_connected_ep()
1423 if (path->is_supply) in is_connected_ep()
1426 if (path->walking) in is_connected_ep()
1431 if (path->connect) { in is_connected_ep()
1432 path->walking = 1; in is_connected_ep()
1433 con += fn(path->node[dir], list, custom_stop_condition); in is_connected_ep()
1434 path->walking = 0; in is_connected_ep()
1438 widget->endpoints[dir] = con; in is_connected_ep()
1480 * snd_soc_dapm_dai_get_connected_widgets - query audio path and it's widgets.
1485 * walk based on custom logic.
1503 struct snd_soc_card *card = dai->component->card; in snd_soc_dapm_dai_get_connected_widgets()
1549 soc_dapm_async_complete(w->dapm); in snd_soc_dapm_regulator_event()
1552 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_regulator_event()
1553 ret = regulator_allow_bypass(w->regulator, false); in snd_soc_dapm_regulator_event()
1555 dev_warn(w->dapm->dev, in snd_soc_dapm_regulator_event()
1557 w->name, ret); in snd_soc_dapm_regulator_event()
1560 return regulator_enable(w->regulator); in snd_soc_dapm_regulator_event()
1562 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_regulator_event()
1563 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_regulator_event()
1565 dev_warn(w->dapm->dev, in snd_soc_dapm_regulator_event()
1567 w->name, ret); in snd_soc_dapm_regulator_event()
1570 return regulator_disable_deferred(w->regulator, w->shift); in snd_soc_dapm_regulator_event()
1581 struct snd_soc_dapm_pinctrl_priv *priv = w->priv; in snd_soc_dapm_pinctrl_event()
1582 struct pinctrl *p = w->pinctrl; in snd_soc_dapm_pinctrl_event()
1586 return -EIO; in snd_soc_dapm_pinctrl_event()
1589 s = pinctrl_lookup_state(p, priv->active_state); in snd_soc_dapm_pinctrl_event()
1591 s = pinctrl_lookup_state(p, priv->sleep_state); in snd_soc_dapm_pinctrl_event()
1606 if (!w->clk) in snd_soc_dapm_clock_event()
1607 return -EIO; in snd_soc_dapm_clock_event()
1609 soc_dapm_async_complete(w->dapm); in snd_soc_dapm_clock_event()
1612 return clk_prepare_enable(w->clk); in snd_soc_dapm_clock_event()
1614 clk_disable_unprepare(w->clk); in snd_soc_dapm_clock_event()
1624 if (w->power_checked) in dapm_widget_power_check()
1625 return w->new_power; in dapm_widget_power_check()
1627 if (w->force) in dapm_widget_power_check()
1628 w->new_power = 1; in dapm_widget_power_check()
1630 w->new_power = w->power_check(w); in dapm_widget_power_check()
1632 w->power_checked = true; in dapm_widget_power_check()
1634 return w->new_power; in dapm_widget_power_check()
1660 if (path->connected && in dapm_supply_check_power()
1661 !path->connected(path->source, path->sink)) in dapm_supply_check_power()
1664 if (dapm_widget_power_check(path->sink)) in dapm_supply_check_power()
1673 return w->connected; in dapm_always_on_check_power()
1690 WARN_ONCE(sort[a->id] == 0, "offset a->id %d not initialized\n", a->id); in dapm_seq_compare()
1691 WARN_ONCE(sort[b->id] == 0, "offset b->id %d not initialized\n", b->id); in dapm_seq_compare()
1693 if (sort[a->id] != sort[b->id]) in dapm_seq_compare()
1694 return sort[a->id] - sort[b->id]; in dapm_seq_compare()
1695 if (a->subseq != b->subseq) { in dapm_seq_compare()
1697 return a->subseq - b->subseq; in dapm_seq_compare()
1699 return b->subseq - a->subseq; in dapm_seq_compare()
1701 if (a->reg != b->reg) in dapm_seq_compare()
1702 return a->reg - b->reg; in dapm_seq_compare()
1703 if (a->dapm != b->dapm) in dapm_seq_compare()
1704 return (unsigned long)a->dapm - (unsigned long)b->dapm; in dapm_seq_compare()
1718 list_add_tail(&new_widget->power_list, &w->power_list); in dapm_seq_insert()
1722 list_add_tail(&new_widget->power_list, list); in dapm_seq_insert()
1761 if (w->new_power != power) in dapm_seq_check_event()
1764 if (w->event && (w->event_flags & event)) { in dapm_seq_check_event()
1767 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1768 w->name, ev_name); in dapm_seq_check_event()
1769 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1771 ret = w->event(w, NULL, event); in dapm_seq_check_event()
1774 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1775 ev_name, w->name, ret); in dapm_seq_check_event()
1790 reg = w->reg; in dapm_seq_run_coalesced()
1791 dapm = w->dapm; in dapm_seq_run_coalesced()
1794 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1795 w->power = w->new_power; in dapm_seq_run_coalesced()
1797 mask |= w->mask << w->shift; in dapm_seq_run_coalesced()
1798 if (w->power) in dapm_seq_run_coalesced()
1799 value |= w->on_val << w->shift; in dapm_seq_run_coalesced()
1801 value |= w->off_val << w->shift; in dapm_seq_run_coalesced()
1803 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1805 w->name, reg, value, mask); in dapm_seq_run_coalesced()
1817 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1819 value, mask, reg, card->pop_time); in dapm_seq_run_coalesced()
1820 pop_wait(card->pop_time); in dapm_seq_run_coalesced()
1832 * We walk over a pre-sorted list of widgets to apply power to. In
1844 int cur_sort = -1; in dapm_seq_run()
1845 int cur_subseq = -1; in dapm_seq_run()
1860 if (sort[w->id] != cur_sort || w->reg != cur_reg || in dapm_seq_run()
1861 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1865 if (cur_dapm && cur_dapm->component) { in dapm_seq_run()
1869 cur_dapm->component, in dapm_seq_run()
1873 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1877 cur_sort = -1; in dapm_seq_run()
1883 switch (w->id) { in dapm_seq_run()
1885 if (!w->event) in dapm_seq_run()
1889 ret = w->event(w, in dapm_seq_run()
1892 ret = w->event(w, in dapm_seq_run()
1897 if (!w->event) in dapm_seq_run()
1901 ret = w->event(w, in dapm_seq_run()
1904 ret = w->event(w, in dapm_seq_run()
1910 cur_sort = sort[w->id]; in dapm_seq_run()
1911 cur_subseq = w->subseq; in dapm_seq_run()
1912 cur_reg = w->reg; in dapm_seq_run()
1913 cur_dapm = w->dapm; in dapm_seq_run()
1914 list_move(&w->power_list, &pending); in dapm_seq_run()
1919 dev_err(w->dapm->dev, in dapm_seq_run()
1926 if (cur_dapm && cur_dapm->component) { in dapm_seq_run()
1930 cur_dapm->component, in dapm_seq_run()
1945 if (!update || !dapm_kcontrol_is_powered(update->kcontrol)) in dapm_widget_update()
1948 wlist = dapm_kcontrol_get_wlist(update->kcontrol); in dapm_widget_update()
1951 if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) { in dapm_widget_update()
1952 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); in dapm_widget_update()
1954 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1955 w->name, ret); in dapm_widget_update()
1962 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1963 update->val); in dapm_widget_update()
1965 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1966 w->name, ret); in dapm_widget_update()
1968 if (update->has_second_set) { in dapm_widget_update()
1969 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1970 update->mask2, update->val2); in dapm_widget_update()
1972 dev_err(w->dapm->dev, in dapm_widget_update()
1974 w->name, ret); in dapm_widget_update()
1978 if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) { in dapm_widget_update()
1979 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); in dapm_widget_update()
1981 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1982 w->name, ret); in dapm_widget_update()
1987 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1996 if (dapm->bias_level == SND_SOC_BIAS_OFF && in dapm_pre_sequence_async()
1997 dapm->target_bias_level != SND_SOC_BIAS_OFF) { in dapm_pre_sequence_async()
1998 if (dapm->dev && cookie) in dapm_pre_sequence_async()
1999 pm_runtime_get_sync(dapm->dev); in dapm_pre_sequence_async()
2003 dev_err(dapm->dev, in dapm_pre_sequence_async()
2008 if ((dapm->target_bias_level == SND_SOC_BIAS_ON && in dapm_pre_sequence_async()
2009 dapm->bias_level != SND_SOC_BIAS_ON) || in dapm_pre_sequence_async()
2010 (dapm->target_bias_level != SND_SOC_BIAS_ON && in dapm_pre_sequence_async()
2011 dapm->bias_level == SND_SOC_BIAS_ON)) { in dapm_pre_sequence_async()
2014 dev_err(dapm->dev, in dapm_pre_sequence_async()
2019 /* Async callback run prior to DAPM sequences - brings to their final
2028 if (dapm->bias_level == SND_SOC_BIAS_PREPARE && in dapm_post_sequence_async()
2029 (dapm->target_bias_level == SND_SOC_BIAS_STANDBY || in dapm_post_sequence_async()
2030 dapm->target_bias_level == SND_SOC_BIAS_OFF)) { in dapm_post_sequence_async()
2033 dev_err(dapm->dev, "ASoC: Failed to apply standby bias: %d\n", in dapm_post_sequence_async()
2038 if (dapm->bias_level == SND_SOC_BIAS_STANDBY && in dapm_post_sequence_async()
2039 dapm->target_bias_level == SND_SOC_BIAS_OFF) { in dapm_post_sequence_async()
2042 dev_err(dapm->dev, "ASoC: Failed to turn off bias: %d\n", in dapm_post_sequence_async()
2045 if (dapm->dev && cookie) in dapm_post_sequence_async()
2046 pm_runtime_put(dapm->dev); in dapm_post_sequence_async()
2050 if (dapm->bias_level == SND_SOC_BIAS_PREPARE && in dapm_post_sequence_async()
2051 dapm->target_bias_level == SND_SOC_BIAS_ON) { in dapm_post_sequence_async()
2054 dev_err(dapm->dev, "ASoC: Failed to apply active bias: %d\n", in dapm_post_sequence_async()
2070 if (power != peer->power) in dapm_widget_set_peer_power()
2081 switch (w->id) { in dapm_power_one_widget()
2094 if (w->power == power) in dapm_power_one_widget()
2104 dapm_widget_set_peer_power(path->source, power, path->connect); in dapm_power_one_widget()
2109 if (!w->is_supply) in dapm_power_one_widget()
2111 dapm_widget_set_peer_power(path->sink, power, path->connect); in dapm_power_one_widget()
2122 if (dapm->idle_bias_off) in dapm_idle_bias_off()
2125 switch (snd_power_get_state(dapm->card->snd_card)) { in dapm_idle_bias_off()
2128 return dapm->suspend_bias_off; in dapm_idle_bias_off()
2138 * A complete path is a route that has valid endpoints i.e.:-
2162 d->target_bias_level = SND_SOC_BIAS_OFF; in dapm_power_widgets()
2164 d->target_bias_level = SND_SOC_BIAS_STANDBY; in dapm_power_widgets()
2175 list_for_each_entry(w, &card->dapm_dirty, dirty) { in dapm_power_widgets()
2180 switch (w->id) { in dapm_power_widgets()
2186 list_del_init(&w->dirty); in dapm_power_widgets()
2190 if (w->new_power) { in dapm_power_widgets()
2191 d = w->dapm; in dapm_power_widgets()
2200 switch (w->id) { in dapm_power_widgets()
2209 if (d->target_bias_level < SND_SOC_BIAS_STANDBY) in dapm_power_widgets()
2210 d->target_bias_level = SND_SOC_BIAS_STANDBY; in dapm_power_widgets()
2213 d->target_bias_level = SND_SOC_BIAS_ON; in dapm_power_widgets()
2225 if (d->target_bias_level > bias) in dapm_power_widgets()
2226 bias = d->target_bias_level; in dapm_power_widgets()
2229 d->target_bias_level = bias; in dapm_power_widgets()
2234 dapm_pre_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2237 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2261 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2267 dapm_post_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2271 if (!d->component) in dapm_power_widgets()
2274 ret = snd_soc_component_stream_event(d->component, event); in dapm_power_widgets()
2279 pop_dbg(card->dev, card->pop_time, in dapm_power_widgets()
2280 "DAPM sequencing finished, waiting %dms\n", card->pop_time); in dapm_power_widgets()
2281 pop_wait(card->pop_time); in dapm_power_widgets()
2335 struct snd_soc_dapm_widget *w = file->private_data; in dapm_widget_power_read_file()
2347 return -ENOMEM; in dapm_widget_power_read_file()
2349 snd_soc_dapm_mutex_lock_root(w->dapm); in dapm_widget_power_read_file()
2352 if (w->is_supply) { in dapm_widget_power_read_file()
2361 w->name, w->power ? "On" : "Off", in dapm_widget_power_read_file()
2362 w->force ? " (forced)" : "", in, out); in dapm_widget_power_read_file()
2364 if (w->reg >= 0) in dapm_widget_power_read_file()
2365 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in dapm_widget_power_read_file()
2366 " - R%d(0x%x) mask 0x%x", in dapm_widget_power_read_file()
2367 w->reg, w->reg, w->mask << w->shift); in dapm_widget_power_read_file()
2369 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n"); in dapm_widget_power_read_file()
2371 if (w->sname) in dapm_widget_power_read_file()
2372 ret += scnprintf(buf + ret, PAGE_SIZE - ret, " stream %s %s\n", in dapm_widget_power_read_file()
2373 w->sname, in dapm_widget_power_read_file()
2374 w->active ? "active" : "inactive"); in dapm_widget_power_read_file()
2376 ret += scnprintf(buf + ret, PAGE_SIZE - ret, " widget-type %s\n", in dapm_widget_power_read_file()
2377 snd_soc_dapm_type_name[w->id]); in dapm_widget_power_read_file()
2382 if (p->connected && !p->connected(p->source, p->sink)) in dapm_widget_power_read_file()
2385 if (!p->connect) in dapm_widget_power_read_file()
2388 c_name = p->node[rdir]->dapm->component ? in dapm_widget_power_read_file()
2389 p->node[rdir]->dapm->component->name : NULL; in dapm_widget_power_read_file()
2390 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in dapm_widget_power_read_file()
2393 p->name ? p->name : "static", in dapm_widget_power_read_file()
2394 p->node[rdir]->name, c_name); in dapm_widget_power_read_file()
2398 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2415 struct snd_soc_dapm_context *dapm = file->private_data; in dapm_bias_read_file()
2418 switch (dapm->bias_level) { in dapm_bias_read_file()
2432 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2453 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); in snd_soc_dapm_debugfs_init()
2455 debugfs_create_file("bias_level", 0444, dapm->debugfs_dapm, dapm, in snd_soc_dapm_debugfs_init()
2461 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget()
2463 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2466 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2472 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_free_widget()
2474 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_free_widget()
2477 debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); in dapm_debugfs_free_widget()
2482 debugfs_remove_recursive(dapm->debugfs_dapm); in dapm_debugfs_cleanup()
2483 dapm->debugfs_dapm = NULL; in dapm_debugfs_cleanup()
2507 * soc_dapm_connect_path() - Connects or disconnects a path
2516 if (path->connect == connect) in soc_dapm_connect_path()
2519 path->connect = connect; in soc_dapm_connect_path()
2520 dapm_mark_dirty(path->source, reason); in soc_dapm_connect_path()
2521 dapm_mark_dirty(path->sink, reason); in soc_dapm_connect_path()
2541 if (e && !(strcmp(path->name, e->texts[mux]))) in soc_dapm_mux_update_power()
2559 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mux_update_power()
2623 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mixer_update_power()
2627 ret = soc_dapm_mixer_update_power(card, kcontrol, update, connect, -1); in snd_soc_dapm_mixer_update_power()
2646 if (!component->card) in dapm_widget_show_component()
2649 for_each_card_widgets(component->card, w) { in dapm_widget_show_component()
2650 if (w->dapm != dapm) in dapm_widget_show_component()
2654 switch (w->id) { in dapm_widget_show_component()
2671 if (w->name) in dapm_widget_show_component()
2673 w->name, w->power ? "On":"Off"); in dapm_widget_show_component()
2703 struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); in dapm_widget_show() local
2707 snd_soc_dapm_mutex_lock_root(rtd->card); in dapm_widget_show()
2709 for_each_rtd_codec_dais(rtd, i, codec_dai) { in dapm_widget_show()
2710 struct snd_soc_component *component = codec_dai->component; in dapm_widget_show()
2715 snd_soc_dapm_mutex_unlock(rtd->card); in dapm_widget_show()
2729 list_del(&path->list_node[SND_SOC_DAPM_DIR_IN]); in dapm_free_path()
2730 list_del(&path->list_node[SND_SOC_DAPM_DIR_OUT]); in dapm_free_path()
2731 list_del(&path->list_kcontrol); in dapm_free_path()
2732 list_del(&path->list); in dapm_free_path()
2737 * snd_soc_dapm_free_widget - Free specified widget
2750 list_del(&w->list); in snd_soc_dapm_free_widget()
2751 list_del(&w->dirty); in snd_soc_dapm_free_widget()
2764 kfree(w->kcontrols); in snd_soc_dapm_free_widget()
2765 kfree_const(w->name); in snd_soc_dapm_free_widget()
2766 kfree_const(w->sname); in snd_soc_dapm_free_widget()
2776 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2777 if (w->dapm != dapm) in dapm_free_widgets()
2782 dapm->wcache_sink = NULL; in dapm_free_widgets()
2783 dapm->wcache_source = NULL; in dapm_free_widgets()
2804 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2805 if (!strcmp(w->name, pin_name)) { in dapm_find_widget()
2806 if (w->dapm == dapm) in dapm_find_widget()
2833 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); in __snd_soc_dapm_set_pin()
2834 return -EINVAL; in __snd_soc_dapm_set_pin()
2837 if (w->connected != status) { in __snd_soc_dapm_set_pin()
2844 w->connected = status; in __snd_soc_dapm_set_pin()
2846 w->force = 0; in __snd_soc_dapm_set_pin()
2864 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2880 if (!snd_soc_card_is_instantiated(dapm->card)) in snd_soc_dapm_sync_unlocked()
2883 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP, NULL); in snd_soc_dapm_sync_unlocked()
2888 * snd_soc_dapm_sync - scan and power dapm paths
2911 switch (w->id) { in dapm_update_dai_chan()
2919 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2920 w->channel < channels ? "Connecting" : "Disconnecting", in dapm_update_dai_chan()
2921 p->source->name, p->sink->name); in dapm_update_dai_chan()
2923 if (w->channel < channels) in dapm_update_dai_chan()
2935 int dir = substream->stream; in dapm_update_dai_unlocked()
2946 dev_dbg(dai->dev, "Update DAI routes for %s %s\n", dai->name, snd_pcm_direction_name(dir)); in dapm_update_dai_unlocked()
2949 ret = dapm_update_dai_chan(p, p->sink, channels); in dapm_update_dai_unlocked()
2955 ret = dapm_update_dai_chan(p, p->source, channels); in dapm_update_dai_unlocked()
2967 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); in snd_soc_dapm_update_dai() local
2970 snd_soc_dapm_mutex_lock(rtd->card); in snd_soc_dapm_update_dai()
2972 snd_soc_dapm_mutex_unlock(rtd->card); in snd_soc_dapm_update_dai()
2979 struct snd_soc_component *component = widget->dapm->component; in snd_soc_dapm_widget_name_cmp()
2980 const char *wname = widget->name; in snd_soc_dapm_widget_name_cmp()
2982 if (component && component->name_prefix) in snd_soc_dapm_widget_name_cmp()
2983 wname += strlen(component->name_prefix) + 1; /* plus space */ in snd_soc_dapm_widget_name_cmp()
3006 prefix, route->sink); in snd_soc_dapm_add_route()
3009 prefix, route->source); in snd_soc_dapm_add_route()
3012 sink = route->sink; in snd_soc_dapm_add_route()
3013 source = route->source; in snd_soc_dapm_add_route()
3016 wsource = dapm_wcache_lookup(dapm->wcache_source, source); in snd_soc_dapm_add_route()
3017 wsink = dapm_wcache_lookup(dapm->wcache_sink, sink); in snd_soc_dapm_add_route()
3026 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
3027 if (!wsink && !(strcmp(w->name, sink))) { in snd_soc_dapm_add_route()
3029 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3036 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3038 w->name); in snd_soc_dapm_add_route()
3041 if (!wsource && !(strcmp(w->name, source))) { in snd_soc_dapm_add_route()
3043 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3050 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3052 w->name); in snd_soc_dapm_add_route()
3061 ret = -ENODEV; in snd_soc_dapm_add_route()
3069 dapm->wcache_sink = wsink; in snd_soc_dapm_add_route()
3070 dapm->wcache_source = wsource; in snd_soc_dapm_add_route()
3072 ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, in snd_soc_dapm_add_route()
3073 route->connected); in snd_soc_dapm_add_route()
3076 dev_err(dapm->dev, "ASoC: Failed to add route %s%s -%s%s%s> %s%s\n", in snd_soc_dapm_add_route()
3078 !route->control ? "" : "> [", in snd_soc_dapm_add_route()
3079 !route->control ? "" : route->control, in snd_soc_dapm_add_route()
3080 !route->control ? "" : "] -", in snd_soc_dapm_add_route()
3095 if (route->control) { in snd_soc_dapm_del_route()
3096 dev_err(dapm->dev, in snd_soc_dapm_del_route()
3098 return -EINVAL; in snd_soc_dapm_del_route()
3104 prefix, route->sink); in snd_soc_dapm_del_route()
3107 prefix, route->source); in snd_soc_dapm_del_route()
3110 sink = route->sink; in snd_soc_dapm_del_route()
3111 source = route->source; in snd_soc_dapm_del_route()
3115 list_for_each_entry(p, &dapm->card->paths, list) { in snd_soc_dapm_del_route()
3116 if (strcmp(p->source->name, source) != 0) in snd_soc_dapm_del_route()
3118 if (strcmp(p->sink->name, sink) != 0) in snd_soc_dapm_del_route()
3125 struct snd_soc_dapm_widget *wsource = path->source; in snd_soc_dapm_del_route()
3126 struct snd_soc_dapm_widget *wsink = path->sink; in snd_soc_dapm_del_route()
3130 if (path->connect) in snd_soc_dapm_del_route()
3139 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", in snd_soc_dapm_del_route()
3147 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
3178 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
3202 * snd_soc_dapm_new_widgets - add new dapm widgets
3218 if (w->new) in snd_soc_dapm_new_widgets()
3221 if (w->num_kcontrols) { in snd_soc_dapm_new_widgets()
3222 w->kcontrols = kcalloc(w->num_kcontrols, in snd_soc_dapm_new_widgets()
3225 if (!w->kcontrols) { in snd_soc_dapm_new_widgets()
3227 return -ENOMEM; in snd_soc_dapm_new_widgets()
3231 switch(w->id) { in snd_soc_dapm_new_widgets()
3254 if (w->reg >= 0) { in snd_soc_dapm_new_widgets()
3255 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3256 val = val >> w->shift; in snd_soc_dapm_new_widgets()
3257 val &= w->mask; in snd_soc_dapm_new_widgets()
3258 if (val == w->on_val) in snd_soc_dapm_new_widgets()
3259 w->power = 1; in snd_soc_dapm_new_widgets()
3262 w->new = 1; in snd_soc_dapm_new_widgets()
3275 * snd_soc_dapm_get_volsw - dapm mixer get callback
3288 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_get_volsw()
3289 int reg = mc->reg; in snd_soc_dapm_get_volsw()
3290 unsigned int shift = mc->shift; in snd_soc_dapm_get_volsw()
3291 int max = mc->max; in snd_soc_dapm_get_volsw()
3293 unsigned int mask = (1 << fls(max)) - 1; in snd_soc_dapm_get_volsw()
3294 unsigned int invert = mc->invert; in snd_soc_dapm_get_volsw()
3302 if (reg != mc->rreg) in snd_soc_dapm_get_volsw()
3303 reg_val = soc_dapm_read(dapm, mc->rreg); in snd_soc_dapm_get_volsw()
3306 rval = (reg_val >> mc->rshift) & mask; in snd_soc_dapm_get_volsw()
3317 ucontrol->value.integer.value[0] = max - val; in snd_soc_dapm_get_volsw()
3319 ucontrol->value.integer.value[0] = val; in snd_soc_dapm_get_volsw()
3323 ucontrol->value.integer.value[1] = max - rval; in snd_soc_dapm_get_volsw()
3325 ucontrol->value.integer.value[1] = rval; in snd_soc_dapm_get_volsw()
3333 * snd_soc_dapm_put_volsw - dapm mixer set callback
3345 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_volsw()
3347 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_put_volsw()
3348 int reg = mc->reg; in snd_soc_dapm_put_volsw()
3349 unsigned int shift = mc->shift; in snd_soc_dapm_put_volsw()
3350 int max = mc->max; in snd_soc_dapm_put_volsw()
3352 unsigned int mask = (1 << width) - 1; in snd_soc_dapm_put_volsw()
3353 unsigned int invert = mc->invert; in snd_soc_dapm_put_volsw()
3355 int connect, rconnect = -1, change, reg_change = 0; in snd_soc_dapm_put_volsw()
3360 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_dapm_put_volsw()
3364 val = max - val; in snd_soc_dapm_put_volsw()
3367 rval = (ucontrol->value.integer.value[1] & mask); in snd_soc_dapm_put_volsw()
3370 rval = max - rval; in snd_soc_dapm_put_volsw()
3377 dev_warn(dapm->dev, in snd_soc_dapm_put_volsw()
3379 kcontrol->id.name); in snd_soc_dapm_put_volsw()
3384 rval = rval << mc->rshift; in snd_soc_dapm_put_volsw()
3389 reg_change |= soc_dapm_test_bits(dapm, mc->rreg, in snd_soc_dapm_put_volsw()
3390 mask << mc->rshift, in snd_soc_dapm_put_volsw()
3398 update.reg2 = mc->rreg; in snd_soc_dapm_put_volsw()
3399 update.mask2 = mask << mc->rshift; in snd_soc_dapm_put_volsw()
3421 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
3433 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in snd_soc_dapm_get_enum_double()
3437 if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { in snd_soc_dapm_get_enum_double()
3438 reg_val = soc_dapm_read(dapm, e->reg); in snd_soc_dapm_get_enum_double()
3444 val = (reg_val >> e->shift_l) & e->mask; in snd_soc_dapm_get_enum_double()
3445 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); in snd_soc_dapm_get_enum_double()
3446 if (e->shift_l != e->shift_r) { in snd_soc_dapm_get_enum_double()
3447 val = (reg_val >> e->shift_r) & e->mask; in snd_soc_dapm_get_enum_double()
3449 ucontrol->value.enumerated.item[1] = val; in snd_soc_dapm_get_enum_double()
3457 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3469 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_enum_double()
3470 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in snd_soc_dapm_put_enum_double()
3471 unsigned int *item = ucontrol->value.enumerated.item; in snd_soc_dapm_put_enum_double()
3478 if (item[0] >= e->items) in snd_soc_dapm_put_enum_double()
3479 return -EINVAL; in snd_soc_dapm_put_enum_double()
3481 val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; in snd_soc_dapm_put_enum_double()
3482 mask = e->mask << e->shift_l; in snd_soc_dapm_put_enum_double()
3483 if (e->shift_l != e->shift_r) { in snd_soc_dapm_put_enum_double()
3484 if (item[1] > e->items) in snd_soc_dapm_put_enum_double()
3485 return -EINVAL; in snd_soc_dapm_put_enum_double()
3486 val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_r; in snd_soc_dapm_put_enum_double()
3487 mask |= e->mask << e->shift_r; in snd_soc_dapm_put_enum_double()
3494 if (e->reg != SND_SOC_NOPM) in snd_soc_dapm_put_enum_double()
3495 reg_change = soc_dapm_test_bits(dapm, e->reg, mask, val); in snd_soc_dapm_put_enum_double()
3500 update.reg = e->reg; in snd_soc_dapm_put_enum_double()
3518 * snd_soc_dapm_info_pin_switch - Info for a pin switch
3528 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_soc_dapm_info_pin_switch()
3529 uinfo->count = 1; in snd_soc_dapm_info_pin_switch()
3530 uinfo->value.integer.min = 0; in snd_soc_dapm_info_pin_switch()
3531 uinfo->value.integer.max = 1; in snd_soc_dapm_info_pin_switch()
3542 ucontrol->value.integer.value[0] = snd_soc_dapm_get_pin_status(dapm, pin); in __snd_soc_dapm_get_pin_switch()
3549 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
3561 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_get_pin_switch()
3563 return __snd_soc_dapm_get_pin_switch(&card->dapm, pin, ucontrol); in snd_soc_dapm_get_pin_switch()
3568 * snd_soc_dapm_get_component_pin_switch - Get information for a pin switch
3580 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_get_component_pin_switch()
3582 return __snd_soc_dapm_get_pin_switch(&component->dapm, pin, ucontrol); in snd_soc_dapm_get_component_pin_switch()
3593 ret = __snd_soc_dapm_set_pin(dapm, pin, !!ucontrol->value.integer.value[0]); in __snd_soc_dapm_put_pin_switch()
3602 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
3614 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_put_pin_switch()
3616 return __snd_soc_dapm_put_pin_switch(&card->dapm, pin, ucontrol); in snd_soc_dapm_put_pin_switch()
3621 * snd_soc_dapm_put_component_pin_switch - Set information for a pin switch
3633 const char *pin = (const char *)kcontrol->private_value; in snd_soc_dapm_put_component_pin_switch()
3635 return __snd_soc_dapm_put_pin_switch(&component->dapm, pin, ucontrol); in snd_soc_dapm_put_component_pin_switch()
3645 int ret = -ENOMEM; in snd_soc_dapm_new_control_unlocked()
3651 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3653 w->regulator = devm_regulator_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3654 if (IS_ERR(w->regulator)) { in snd_soc_dapm_new_control_unlocked()
3655 ret = PTR_ERR(w->regulator); in snd_soc_dapm_new_control_unlocked()
3659 if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { in snd_soc_dapm_new_control_unlocked()
3660 ret = regulator_allow_bypass(w->regulator, true); in snd_soc_dapm_new_control_unlocked()
3662 dev_warn(dapm->dev, in snd_soc_dapm_new_control_unlocked()
3664 w->name, ret); in snd_soc_dapm_new_control_unlocked()
3668 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3669 if (IS_ERR(w->pinctrl)) { in snd_soc_dapm_new_control_unlocked()
3670 ret = PTR_ERR(w->pinctrl); in snd_soc_dapm_new_control_unlocked()
3678 w->clk = devm_clk_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3679 if (IS_ERR(w->clk)) { in snd_soc_dapm_new_control_unlocked()
3680 ret = PTR_ERR(w->clk); in snd_soc_dapm_new_control_unlocked()
3688 switch (w->id) { in snd_soc_dapm_new_control_unlocked()
3690 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3691 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3694 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3695 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3696 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3700 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3701 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3704 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3705 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3706 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3710 w->is_ep = SND_SOC_DAPM_EP_SOURCE; in snd_soc_dapm_new_control_unlocked()
3711 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3714 w->is_ep = SND_SOC_DAPM_EP_SINK; in snd_soc_dapm_new_control_unlocked()
3715 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3741 w->power_check = dapm_generic_check_power; in snd_soc_dapm_new_control_unlocked()
3748 w->is_supply = 1; in snd_soc_dapm_new_control_unlocked()
3749 w->power_check = dapm_supply_check_power; in snd_soc_dapm_new_control_unlocked()
3752 w->power_check = dapm_always_on_check_power; in snd_soc_dapm_new_control_unlocked()
3756 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3757 INIT_LIST_HEAD(&w->list); in snd_soc_dapm_new_control_unlocked()
3758 INIT_LIST_HEAD(&w->dirty); in snd_soc_dapm_new_control_unlocked()
3760 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3763 INIT_LIST_HEAD(&w->edges[dir]); in snd_soc_dapm_new_control_unlocked()
3764 w->endpoints[dir] = -1; in snd_soc_dapm_new_control_unlocked()
3768 w->connected = 1; in snd_soc_dapm_new_control_unlocked()
3772 dev_err_probe(dapm->dev, ret, "ASoC: Failed to request %s\n", in snd_soc_dapm_new_control_unlocked()
3773 w->name); in snd_soc_dapm_new_control_unlocked()
3774 kfree_const(w->name); in snd_soc_dapm_new_control_unlocked()
3775 kfree_const(w->sname); in snd_soc_dapm_new_control_unlocked()
3782 * snd_soc_dapm_new_control - create new dapm control
3805 * snd_soc_dapm_new_controls - create new dapm controls
3841 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); in snd_soc_dai_link_event_pre_pmu() local
3859 return -ENOMEM; in snd_soc_dai_link_event_pre_pmu()
3863 return -ENOMEM; in snd_soc_dai_link_event_pre_pmu()
3865 substream->runtime = runtime; in snd_soc_dai_link_event_pre_pmu()
3867 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event_pre_pmu()
3869 source = path->source->priv; in snd_soc_dai_link_event_pre_pmu()
3875 snd_soc_dai_activate(source, substream->stream); in snd_soc_dai_link_event_pre_pmu()
3878 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event_pre_pmu()
3880 sink = path->sink->priv; in snd_soc_dai_link_event_pre_pmu()
3886 snd_soc_dai_activate(sink, substream->stream); in snd_soc_dai_link_event_pre_pmu()
3889 substream->hw_opened = 1; in snd_soc_dai_link_event_pre_pmu()
3896 config = rtd->dai_link->c2c_params + rtd->c2c_params_select; in snd_soc_dai_link_event_pre_pmu()
3898 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3899 return -EINVAL; in snd_soc_dai_link_event_pre_pmu()
3903 if (!config->formats) { in snd_soc_dai_link_event_pre_pmu()
3904 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
3906 return -EINVAL; in snd_soc_dai_link_event_pre_pmu()
3909 fmt = ffs(config->formats) - 1; in snd_soc_dai_link_event_pre_pmu()
3912 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min = in snd_soc_dai_link_event_pre_pmu()
3913 config->rate_min; in snd_soc_dai_link_event_pre_pmu()
3914 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max = in snd_soc_dai_link_event_pre_pmu()
3915 config->rate_max; in snd_soc_dai_link_event_pre_pmu()
3916 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->min in snd_soc_dai_link_event_pre_pmu()
3917 = config->channels_min; in snd_soc_dai_link_event_pre_pmu()
3918 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max in snd_soc_dai_link_event_pre_pmu()
3919 = config->channels_max; in snd_soc_dai_link_event_pre_pmu()
3921 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event_pre_pmu()
3923 source = path->source->priv; in snd_soc_dai_link_event_pre_pmu()
3932 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event_pre_pmu()
3934 sink = path->sink->priv; in snd_soc_dai_link_event_pre_pmu()
3943 runtime->format = params_format(params); in snd_soc_dai_link_event_pre_pmu()
3944 runtime->subformat = params_subformat(params); in snd_soc_dai_link_event_pre_pmu()
3945 runtime->channels = params_channels(params); in snd_soc_dai_link_event_pre_pmu()
3946 runtime->rate = params_rate(params); in snd_soc_dai_link_event_pre_pmu()
3956 struct snd_pcm_substream *substream = w->priv; in snd_soc_dai_link_event()
3957 int ret = 0, saved_stream = substream->stream; in snd_soc_dai_link_event()
3959 if (WARN_ON(list_empty(&w->edges[SND_SOC_DAPM_DIR_OUT]) || in snd_soc_dai_link_event()
3960 list_empty(&w->edges[SND_SOC_DAPM_DIR_IN]))) in snd_soc_dai_link_event()
3961 return -EINVAL; in snd_soc_dai_link_event()
3973 source = path->source->priv; in snd_soc_dai_link_event()
3979 sink = path->sink->priv; in snd_soc_dai_link_event()
3985 sink = path->sink->priv; in snd_soc_dai_link_event()
3994 sink = path->sink->priv; in snd_soc_dai_link_event()
4000 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event()
4002 source = path->source->priv; in snd_soc_dai_link_event()
4006 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event()
4008 sink = path->sink->priv; in snd_soc_dai_link_event()
4012 substream->stream = SNDRV_PCM_STREAM_CAPTURE; in snd_soc_dai_link_event()
4014 source = path->source->priv; in snd_soc_dai_link_event()
4015 snd_soc_dai_deactivate(source, substream->stream); in snd_soc_dai_link_event()
4019 substream->stream = SNDRV_PCM_STREAM_PLAYBACK; in snd_soc_dai_link_event()
4021 sink = path->sink->priv; in snd_soc_dai_link_event()
4022 snd_soc_dai_deactivate(sink, substream->stream); in snd_soc_dai_link_event()
4028 kfree(substream->runtime); in snd_soc_dai_link_event()
4029 substream->runtime = NULL; in snd_soc_dai_link_event()
4034 ret = -EINVAL; in snd_soc_dai_link_event()
4039 substream->stream = saved_stream; in snd_soc_dai_link_event()
4047 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_get() local
4049 ucontrol->value.enumerated.item[0] = rtd->c2c_params_select; in snd_soc_dapm_dai_link_get()
4058 struct snd_soc_pcm_runtime *rtd = w->priv; in snd_soc_dapm_dai_link_put() local
4061 if (w->power) in snd_soc_dapm_dai_link_put()
4062 return -EBUSY; in snd_soc_dapm_dai_link_put()
4064 if (ucontrol->value.enumerated.item[0] == rtd->c2c_params_select) in snd_soc_dapm_dai_link_put()
4067 if (ucontrol->value.enumerated.item[0] >= rtd->dai_link->num_c2c_params) in snd_soc_dapm_dai_link_put()
4068 return -EINVAL; in snd_soc_dapm_dai_link_put()
4070 rtd->c2c_params_select = ucontrol->value.enumerated.item[0]; in snd_soc_dapm_dai_link_put()
4083 devm_kfree(card->dev, (void *)*private_value); in snd_soc_dapm_free_kcontrol()
4089 devm_kfree(card->dev, (void *)w_param_text[count]); in snd_soc_dapm_free_kcontrol()
4090 devm_kfree(card->dev, w_param_text); in snd_soc_dapm_free_kcontrol()
4113 if (!config->stream_name) { in snd_soc_dapm_alloc_kcontrol()
4114 dev_warn(card->dapm.dev, in snd_soc_dapm_alloc_kcontrol()
4118 devm_kasprintf(card->dev, GFP_KERNEL, in snd_soc_dapm_alloc_kcontrol()
4122 w_param_text[count] = devm_kmemdup(card->dev, in snd_soc_dapm_alloc_kcontrol()
4123 config->stream_name, in snd_soc_dapm_alloc_kcontrol()
4124 strlen(config->stream_name) + 1, in snd_soc_dapm_alloc_kcontrol()
4136 (unsigned long) devm_kmemdup(card->dev, in snd_soc_dapm_alloc_kcontrol()
4140 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", in snd_soc_dapm_alloc_kcontrol()
4146 kcontrol_news = devm_kmemdup(card->dev, &kcontrol_dai_link[0], in snd_soc_dapm_alloc_kcontrol()
4150 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", in snd_soc_dapm_alloc_kcontrol()
4166 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); in snd_soc_dapm_new_dai() local
4174 int ret = -ENOMEM; in snd_soc_dapm_new_dai()
4176 link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s", in snd_soc_dapm_new_dai()
4177 rtd->dai_link->name, id); in snd_soc_dapm_new_dai()
4185 if (rtd->dai_link->num_c2c_params > 1) { in snd_soc_dapm_new_dai()
4186 w_param_text = devm_kcalloc(card->dev, in snd_soc_dapm_new_dai()
4187 rtd->dai_link->num_c2c_params, in snd_soc_dapm_new_dai()
4194 rtd->dai_link->c2c_params, in snd_soc_dapm_new_dai()
4195 rtd->dai_link->num_c2c_params, in snd_soc_dapm_new_dai()
4211 dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name); in snd_soc_dapm_new_dai()
4213 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4219 w->priv = substream; in snd_soc_dapm_new_dai()
4224 devm_kfree(card->dev, (void *)template.kcontrol_news); in snd_soc_dapm_new_dai()
4226 rtd->dai_link->num_c2c_params, w_param_text); in snd_soc_dapm_new_dai()
4228 devm_kfree(card->dev, link_name); in snd_soc_dapm_new_dai()
4230 dev_err(rtd->dev, "ASoC: Failed to create %s-%s widget: %d\n", in snd_soc_dapm_new_dai()
4231 rtd->dai_link->name, id, ret); in snd_soc_dapm_new_dai()
4236 * snd_soc_dapm_new_dai_widgets - Create new DAPM widgets
4248 WARN_ON(dapm->dev != dai->dev); in snd_soc_dapm_new_dai_widgets()
4253 if (dai->driver->playback.stream_name) { in snd_soc_dapm_new_dai_widgets()
4255 template.name = dai->driver->playback.stream_name; in snd_soc_dapm_new_dai_widgets()
4256 template.sname = dai->driver->playback.stream_name; in snd_soc_dapm_new_dai_widgets()
4258 dev_dbg(dai->dev, "ASoC: adding %s widget\n", in snd_soc_dapm_new_dai_widgets()
4265 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4269 if (dai->driver->capture.stream_name) { in snd_soc_dapm_new_dai_widgets()
4271 template.name = dai->driver->capture.stream_name; in snd_soc_dapm_new_dai_widgets()
4272 template.sname = dai->driver->capture.stream_name; in snd_soc_dapm_new_dai_widgets()
4274 dev_dbg(dai->dev, "ASoC: adding %s widget\n", in snd_soc_dapm_new_dai_widgets()
4281 w->priv = dai; in snd_soc_dapm_new_dai_widgets()
4297 switch (dai_w->id) { in snd_soc_dapm_link_dai_widgets()
4306 if (!dai_w->priv) { in snd_soc_dapm_link_dai_widgets()
4307 dev_dbg(card->dev, "dai widget %s has no DAI\n", in snd_soc_dapm_link_dai_widgets()
4308 dai_w->name); in snd_soc_dapm_link_dai_widgets()
4312 dai = dai_w->priv; in snd_soc_dapm_link_dai_widgets()
4316 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4319 switch (w->id) { in snd_soc_dapm_link_dai_widgets()
4327 if (!w->sname || !strstr(w->sname, dai_w->sname)) in snd_soc_dapm_link_dai_widgets()
4330 if (dai_w->id == snd_soc_dapm_dai_in) { in snd_soc_dapm_link_dai_widgets()
4337 dev_dbg(dai->dev, "%s -> %s\n", src->name, sink->name); in snd_soc_dapm_link_dai_widgets()
4338 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4352 dev_dbg(dapm->dev, "connected DAI link %s:%s -> %s:%s\n", in dapm_connect_dai_routes()
4353 src_dai->component->name, src->name, in dapm_connect_dai_routes()
4354 sink_dai->component->name, sink->name); in dapm_connect_dai_routes()
4365 struct snd_soc_pcm_runtime *rtd, in dapm_connect_dai_pair() argument
4369 struct snd_soc_dai_link *dai_link = rtd->dai_link; in dapm_connect_dai_pair()
4392 if (dai_link->c2c_params && !rtd->c2c_widget[stream]) { in dapm_connect_dai_pair()
4393 struct snd_pcm_substream *substream = rtd->pcm->streams[stream].substream; in dapm_connect_dai_pair()
4400 rtd->c2c_widget[stream] = dai; in dapm_connect_dai_pair()
4403 dapm_connect_dai_routes(&card->dapm, src_dai[stream], *src[stream], in dapm_connect_dai_pair()
4404 rtd->c2c_widget[stream], in dapm_connect_dai_pair()
4421 if (w->id == snd_soc_dapm_dai_in) { in soc_dapm_dai_stream_event()
4431 w->active = 1; in soc_dapm_dai_stream_event()
4432 w->is_ep = ep; in soc_dapm_dai_stream_event()
4435 w->active = 0; in soc_dapm_dai_stream_event()
4436 w->is_ep = 0; in soc_dapm_dai_stream_event()
4449 struct snd_soc_pcm_runtime *rtd; in snd_soc_dapm_connect_dai_link_widgets() local
4454 for_each_card_rtds(card, rtd) { in snd_soc_dapm_connect_dai_link_widgets()
4460 * CODEC<->CODEC links have no direct connection. in snd_soc_dapm_connect_dai_link_widgets()
4462 if (rtd->dai_link->dynamic) in snd_soc_dapm_connect_dai_link_widgets()
4467 * soc.h :: [dai_link->ch_maps Image sample] in snd_soc_dapm_connect_dai_link_widgets()
4469 for_each_rtd_ch_maps(rtd, i, ch_maps) { in snd_soc_dapm_connect_dai_link_widgets()
4470 cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); in snd_soc_dapm_connect_dai_link_widgets()
4471 codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); in snd_soc_dapm_connect_dai_link_widgets()
4473 dapm_connect_dai_pair(card, rtd, codec_dai, cpu_dai); in snd_soc_dapm_connect_dai_link_widgets()
4478 static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, in soc_dapm_stream_event() argument
4484 for_each_rtd_dais(rtd, i, dai) in soc_dapm_stream_event()
4487 dapm_power_widgets(rtd->card, event, NULL); in soc_dapm_stream_event()
4491 * snd_soc_dapm_stream_event - send a stream event to the dapm core
4492 * @rtd: PCM runtime data
4501 void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, in snd_soc_dapm_stream_event() argument
4504 struct snd_soc_card *card = rtd->card; in snd_soc_dapm_stream_event()
4507 soc_dapm_stream_event(rtd, stream, event); in snd_soc_dapm_stream_event()
4511 void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream) in snd_soc_dapm_stream_stop() argument
4514 if (snd_soc_runtime_ignore_pmdown_time(rtd)) { in snd_soc_dapm_stream_stop()
4516 snd_soc_dapm_stream_event(rtd, in snd_soc_dapm_stream_stop()
4521 rtd->pop_wait = 1; in snd_soc_dapm_stream_stop()
4523 &rtd->delayed_work, in snd_soc_dapm_stream_stop()
4524 msecs_to_jiffies(rtd->pmdown_time)); in snd_soc_dapm_stream_stop()
4528 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE, in snd_soc_dapm_stream_stop()
4535 * snd_soc_dapm_enable_pin_unlocked - enable pin.
4555 * snd_soc_dapm_enable_pin - enable pin.
4580 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
4599 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4600 return -EINVAL; in snd_soc_dapm_force_enable_pin_unlocked()
4603 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4604 if (!w->connected) { in snd_soc_dapm_force_enable_pin_unlocked()
4606 * w->force does not affect the number of input or output paths, in snd_soc_dapm_force_enable_pin_unlocked()
4607 * so we only have to recheck if w->connected is changed in snd_soc_dapm_force_enable_pin_unlocked()
4611 w->connected = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4613 w->force = 1; in snd_soc_dapm_force_enable_pin_unlocked()
4621 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
4648 * snd_soc_dapm_disable_pin_unlocked - disable pin.
4667 * snd_soc_dapm_disable_pin - disable pin.
4692 * snd_soc_dapm_get_pin_status - get audio pin status
4696 * Get audio pin status - connected or disconnected.
4706 return w->connected; in snd_soc_dapm_get_pin_status()
4713 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
4729 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_ignore_suspend()
4730 return -EINVAL; in snd_soc_dapm_ignore_suspend()
4733 w->ignore_suspend = 1; in snd_soc_dapm_ignore_suspend()
4740 * snd_soc_dapm_free - free dapm resources
4749 list_del(&dapm->list); in snd_soc_dapm_free()
4756 dapm->card = card; in snd_soc_dapm_init()
4757 dapm->component = component; in snd_soc_dapm_init()
4758 dapm->bias_level = SND_SOC_BIAS_OFF; in snd_soc_dapm_init()
4761 dapm->dev = component->dev; in snd_soc_dapm_init()
4762 dapm->idle_bias_off = !component->driver->idle_bias_on; in snd_soc_dapm_init()
4763 dapm->suspend_bias_off = component->driver->suspend_bias_off; in snd_soc_dapm_init()
4765 dapm->dev = card->dev; in snd_soc_dapm_init()
4768 INIT_LIST_HEAD(&dapm->list); in snd_soc_dapm_init()
4770 list_add(&dapm->list, &card->dapm_list); in snd_soc_dapm_init()
4775 struct snd_soc_card *card = dapm->card; in soc_dapm_shutdown_dapm()
4782 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4783 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4785 if (w->power) { in soc_dapm_shutdown_dapm()
4787 w->new_power = 0; in soc_dapm_shutdown_dapm()
4796 if (dapm->bias_level == SND_SOC_BIAS_ON) in soc_dapm_shutdown_dapm()
4800 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) in soc_dapm_shutdown_dapm()
4809 * snd_soc_dapm_shutdown - callback for system shutdown
4816 if (dapm != &card->dapm) { in snd_soc_dapm_shutdown()
4818 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4824 soc_dapm_shutdown_dapm(&card->dapm); in snd_soc_dapm_shutdown()
4825 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4826 snd_soc_dapm_set_bias_level(&card->dapm, in snd_soc_dapm_shutdown()