Lines Matching full:dapm

3 // soc-dapm.c  --  ALSA SoC Dynamic Audio Power Management
43 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
52 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
59 snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
63 snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
66 static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg);
68 /* dapm power sequences - make this per codec in the future */
151 static void dapm_assert_locked(struct snd_soc_dapm_context *dapm) in dapm_assert_locked() argument
153 if (snd_soc_card_is_instantiated(dapm->card)) in dapm_assert_locked()
154 snd_soc_dapm_mutex_assert_held(dapm); in dapm_assert_locked()
191 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
194 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
196 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
215 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_paths()
322 /* create a new dapm widget */
383 dev_warn(widget->dapm->dev, in dapm_kcontrol_data_alloc()
409 snd_soc_dapm_new_control_unlocked(widget->dapm, in dapm_kcontrol_data_alloc()
444 widget->dapm, &template); in dapm_kcontrol_data_alloc()
451 snd_soc_dapm_add_path(widget->dapm, data->widget, in dapm_kcontrol_data_alloc()
454 data->value = soc_dapm_read(widget->dapm, e->reg) & in dapm_kcontrol_data_alloc()
595 * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a
605 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm; in snd_soc_dapm_kcontrol_dapm()
623 static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm) in soc_dapm_prefix() argument
625 if (!dapm->component) in soc_dapm_prefix()
627 return dapm->component->name_prefix; in soc_dapm_prefix()
630 static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg) in soc_dapm_read() argument
632 if (!dapm->component) in soc_dapm_read()
634 return snd_soc_component_read(dapm->component, reg); in soc_dapm_read()
637 static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm, in soc_dapm_update_bits() argument
640 if (!dapm->component) in soc_dapm_update_bits()
642 return snd_soc_component_update_bits(dapm->component, reg, in soc_dapm_update_bits()
646 static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm, in soc_dapm_test_bits() argument
649 if (!dapm->component) in soc_dapm_test_bits()
651 return snd_soc_component_test_bits(dapm->component, reg, mask, value); in soc_dapm_test_bits()
654 static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) in soc_dapm_async_complete() argument
656 if (dapm->component) in soc_dapm_async_complete()
657 snd_soc_component_async_complete(dapm->component); in soc_dapm_async_complete()
664 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
681 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
682 * @dapm: The DAPM context for which to set the level
685 * Forces the DAPM bias level to a specific state. It will call the bias level
686 * callback of DAPM context with the specified level. This will even happen if
693 * determined by the DAPM core. The function is mainly intended to be used to
695 * initialization can be done, before the DAPM core takes over.
697 int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_bias_level() argument
702 if (dapm->component) in snd_soc_dapm_force_bias_level()
703 ret = snd_soc_component_set_bias_level(dapm->component, level); in snd_soc_dapm_force_bias_level()
706 dapm->bias_level = level; in snd_soc_dapm_force_bias_level()
714 * @dapm: DAPM context
721 static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_set_bias_level() argument
724 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_set_bias_level()
727 trace_snd_soc_bias_level_start(dapm, level); in snd_soc_dapm_set_bias_level()
729 ret = snd_soc_card_set_bias_level(card, dapm, level); in snd_soc_dapm_set_bias_level()
733 if (dapm != &card->dapm) in snd_soc_dapm_set_bias_level()
734 ret = snd_soc_dapm_force_bias_level(dapm, level); in snd_soc_dapm_set_bias_level()
739 ret = snd_soc_card_set_bias_level_post(card, dapm, level); in snd_soc_dapm_set_bias_level()
741 trace_snd_soc_bias_level_done(dapm, level); in snd_soc_dapm_set_bias_level()
747 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, in dapm_connect_mux() argument
758 val = soc_dapm_read(dapm, e->reg); in dapm_connect_mux()
794 unsigned int val = soc_dapm_read(p->sink->dapm, reg); in dapm_set_mixer_path_status()
810 val = soc_dapm_read(p->sink->dapm, mc->rreg); in dapm_set_mixer_path_status()
830 static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, in dapm_connect_mixer() argument
846 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, in dapm_is_shared_kcontrol() argument
856 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
857 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
878 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol() local
879 struct snd_card *card = dapm->card->snd_card; in dapm_create_or_share_kcontrol()
889 prefix = soc_dapm_prefix(dapm); in dapm_create_or_share_kcontrol()
895 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
967 dev_err(dapm->dev, in dapm_create_or_share_kcontrol()
968 "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", in dapm_create_or_share_kcontrol()
984 /* create new dapm mixer control */
1009 snd_soc_dapm_add_path(data->widget->dapm, in dapm_new_mixer()
1019 /* create new dapm mux control */
1022 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux() local
1042 dev_err(dapm->dev, in dapm_new_mux()
1049 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1065 /* create new dapm volume control */
1079 /* create new dapm dai link control */
1091 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link() local
1092 struct snd_card *card = dapm->card->snd_card; in dapm_new_dai_link()
1098 dev_err(dapm->dev, in dapm_new_dai_link()
1099 "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", in dapm_new_dai_link()
1116 int level = snd_power_get_state(widget->dapm->card->snd_card); in snd_soc_dapm_suspend_check()
1122 dev_dbg(widget->dapm->dev, "ASoC: %s ignoring suspend\n", in snd_soc_dapm_suspend_check()
1254 * This function takes the dapm widget currently being examined and the walk
1272 * This function takes the dapm widget currently being examined and the walk
1293 * Queries DAPM graph as to whether a valid audio stream path exists for
1298 * This function takes the dapm widget currently being examined and the walk
1355 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1361 dev_warn(w->dapm->dev, in dapm_regulator_event()
1371 dev_warn(w->dapm->dev, in dapm_regulator_event()
1415 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1512 if (a->dapm != b->dapm) in dapm_seq_compare()
1513 return (unsigned long)a->dapm - (unsigned long)b->dapm; in dapm_seq_compare()
1518 /* Insert a widget in order into a DAPM power sequence. */
1576 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1578 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1583 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1588 /* Apply the coalesced changes from a DAPM sequence */
1592 struct snd_soc_dapm_context *dapm; in dapm_seq_run_coalesced() local
1600 dapm = w->dapm; in dapm_seq_run_coalesced()
1603 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1612 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1626 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1630 soc_dapm_update_bits(dapm, reg, mask, value); in dapm_seq_run_coalesced()
1639 /* Apply a DAPM power sequence.
1670 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1682 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1722 cur_dapm = w->dapm; in dapm_seq_run()
1728 dev_err(w->dapm->dev, in dapm_seq_run()
1764 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1772 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1775 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1779 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1782 dev_err(w->dapm->dev, in dapm_widget_update()
1783 "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1791 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1797 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1829 /* Async callback run prior to DAPM sequences - brings to their final
1930 static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm) in dapm_idle_bias_off() argument
1932 if (dapm->idle_bias_off) in dapm_idle_bias_off()
1935 switch (snd_power_get_state(dapm->card->snd_card)) { in dapm_idle_bias_off()
1938 return dapm->suspend_bias_off; in dapm_idle_bias_off()
1947 * Scan each dapm widget for complete audio path.
2000 d = w->dapm; in dapm_power_widgets()
2043 dapm_pre_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2046 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2070 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2076 dapm_post_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2078 /* do we need to notify any clients that DAPM event is complete */ in dapm_power_widgets()
2089 "DAPM sequencing finished, waiting %dms\n", card->pop_time); in dapm_power_widgets()
2158 snd_soc_dapm_mutex_lock_root(w->dapm); in dapm_widget_power_read_file()
2197 c_name = p->node[rdir]->dapm->component ? in dapm_widget_power_read_file()
2198 p->node[rdir]->dapm->component->name : NULL; in dapm_widget_power_read_file()
2207 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2224 struct snd_soc_dapm_context *dapm = file->private_data; in dapm_bias_read_file() local
2227 switch (dapm->bias_level) { in dapm_bias_read_file()
2241 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2256 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_debugfs_init() argument
2262 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); in snd_soc_dapm_debugfs_init()
2264 debugfs_create_file("bias_level", 0444, dapm->debugfs_dapm, dapm, in snd_soc_dapm_debugfs_init()
2270 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget() local
2272 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2275 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2281 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_free_widget() local
2283 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_free_widget()
2286 debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); in dapm_debugfs_free_widget()
2289 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) in dapm_debugfs_cleanup() argument
2291 debugfs_remove_recursive(dapm->debugfs_dapm); in dapm_debugfs_cleanup()
2292 dapm->debugfs_dapm = NULL; in dapm_debugfs_cleanup()
2296 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_debugfs_init() argument
2309 static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) in dapm_debugfs_cleanup() argument
2344 /* find dapm widget path assoc with kcontrol */ in soc_dapm_mux_update_power()
2362 int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_mux_update_power() argument
2366 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mux_update_power()
2390 /* find dapm widget path assoc with kcontrol */ in soc_dapm_mixer_update_power()
2427 int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_mixer_update_power() argument
2431 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mixer_update_power()
2448 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt); in dapm_widget_show_component() local
2460 if (w->dapm != dapm) in dapm_widget_show_component()
2490 switch (snd_soc_dapm_get_bias_level(dapm)) { in dapm_widget_show_component()
2509 /* show dapm widget status in sys fs */
2581 /* free all dapm widgets and resources */
2582 static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) in dapm_free_widgets() argument
2586 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2587 if (w->dapm != dapm) in dapm_free_widgets()
2592 dapm->wcache_sink = NULL; in dapm_free_widgets()
2593 dapm->wcache_source = NULL; in dapm_free_widgets()
2597 struct snd_soc_dapm_context *dapm, const char *pin, in dapm_find_widget() argument
2604 const char *prefix = soc_dapm_prefix(dapm); in dapm_find_widget()
2614 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2616 if (w->dapm == dapm) in dapm_find_widget()
2630 * set the DAPM pin status:
2634 static int __snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, in __snd_soc_dapm_set_pin() argument
2637 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in __snd_soc_dapm_set_pin()
2640 dapm_assert_locked(dapm); in __snd_soc_dapm_set_pin()
2643 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); in __snd_soc_dapm_set_pin()
2665 static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_set_pin() argument
2668 int ret = __snd_soc_dapm_set_pin(dapm, pin, status); in snd_soc_dapm_set_pin()
2674 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2675 * @dapm: DAPM context
2677 * Walks all dapm audio paths and powers widgets according to their
2684 int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_sync_unlocked() argument
2688 * silly DAPM runs during card startup. in snd_soc_dapm_sync_unlocked()
2690 if (!snd_soc_card_is_instantiated(dapm->card)) in snd_soc_dapm_sync_unlocked()
2693 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); in snd_soc_dapm_sync_unlocked()
2698 * snd_soc_dapm_sync - scan and power dapm paths
2699 * @dapm: DAPM context
2701 * Walks all dapm audio paths and powers widgets according to their
2706 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_sync() argument
2710 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_sync()
2711 ret = snd_soc_dapm_sync_unlocked(dapm); in snd_soc_dapm_sync()
2712 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_sync()
2729 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2790 struct snd_soc_component *component = widget->dapm->component; in snd_soc_dapm_widget_name_cmp()
2818 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2833 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2860 static int snd_soc_dapm_check_dynamic_path(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_check_dynamic_path() argument
2890 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2895 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2904 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_path() argument
2915 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2922 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2929 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2935 ret = snd_soc_dapm_check_dynamic_path(dapm, wsource, wsink, control); in snd_soc_dapm_add_path()
2959 ret = dapm_connect_mux(dapm, path, control, wsource); in snd_soc_dapm_add_path()
2969 ret = dapm_connect_mux(dapm, path, control, wsink); in snd_soc_dapm_add_path()
2976 ret = dapm_connect_mixer(dapm, path, control); in snd_soc_dapm_add_path()
2985 list_add(&path->list, &dapm->card->paths); in snd_soc_dapm_add_path()
2995 if (snd_soc_card_is_instantiated(dapm->card) && path->connect) in snd_soc_dapm_add_path()
3004 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_route() argument
3018 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_add_route()
3031 wsource = dapm_wcache_lookup(dapm->wcache_source, source); in snd_soc_dapm_add_route()
3032 wsink = dapm_wcache_lookup(dapm->wcache_sink, sink); in snd_soc_dapm_add_route()
3039 * current DAPM context in snd_soc_dapm_add_route()
3041 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
3044 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3051 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3058 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3065 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3070 /* use widget from another DAPM context if not found from this */ in snd_soc_dapm_add_route()
3084 dapm->wcache_sink = wsink; in snd_soc_dapm_add_route()
3085 dapm->wcache_source = wsource; in snd_soc_dapm_add_route()
3087 ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, in snd_soc_dapm_add_route()
3091 dev_err(dapm->dev, "ASoC: Failed to add route %s%s -%s%s%s> %s%s\n", in snd_soc_dapm_add_route()
3100 static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_del_route() argument
3111 dev_err(dapm->dev, in snd_soc_dapm_del_route()
3116 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_del_route()
3130 list_for_each_entry(p, &dapm->card->paths, list) { in snd_soc_dapm_del_route()
3154 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", in snd_soc_dapm_del_route()
3162 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
3163 * @dapm: DAPM context
3167 * Connects 2 dapm widgets together via a named audio path. The sink is
3174 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_routes() argument
3179 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_add_routes()
3181 int r = snd_soc_dapm_add_route(dapm, route); in snd_soc_dapm_add_routes()
3186 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_add_routes()
3193 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
3194 * @dapm: DAPM context
3198 * Removes routes from the DAPM context.
3200 int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_del_routes() argument
3205 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_del_routes()
3207 snd_soc_dapm_del_route(dapm, route); in snd_soc_dapm_del_routes()
3210 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_del_routes()
3216 static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_weak_route() argument
3219 struct snd_soc_dapm_widget *source = dapm_find_widget(dapm, in snd_soc_dapm_weak_route()
3222 struct snd_soc_dapm_widget *sink = dapm_find_widget(dapm, in snd_soc_dapm_weak_route()
3229 dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n", in snd_soc_dapm_weak_route()
3235 dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n", in snd_soc_dapm_weak_route()
3241 dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3252 dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3255 dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3262 * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
3263 * @dapm: DAPM context
3277 int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_weak_routes() argument
3283 snd_soc_dapm_mutex_lock_root(dapm); in snd_soc_dapm_weak_routes()
3285 int err = snd_soc_dapm_weak_route(dapm, route); in snd_soc_dapm_weak_routes()
3290 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_weak_routes()
3297 * snd_soc_dapm_new_widgets - add new dapm widgets
3298 * @card: card to be checked for new dapm widgets
3300 * Checks the codec for any new dapm widgets and creates them if found.
3350 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3370 * snd_soc_dapm_get_volsw - dapm mixer get callback
3374 * Callback to get the value of a dapm mixer control.
3381 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_get_volsw() local
3392 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_get_volsw()
3394 reg_val = soc_dapm_read(dapm, reg); in snd_soc_dapm_get_volsw()
3398 reg_val = soc_dapm_read(dapm, mc->rreg); in snd_soc_dapm_get_volsw()
3409 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_get_volsw()
3428 * snd_soc_dapm_put_volsw - dapm mixer set callback
3432 * Callback to set the value of a dapm mixer control.
3439 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_put_volsw() local
3440 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_volsw()
3471 dev_warn(dapm->dev, in snd_soc_dapm_put_volsw()
3480 reg_change = soc_dapm_test_bits(dapm, reg, mask << shift, val); in snd_soc_dapm_put_volsw()
3483 reg_change |= soc_dapm_test_bits(dapm, mc->rreg, in snd_soc_dapm_put_volsw()
3519 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
3523 * Callback to get the value of a dapm enumerated double mixer control.
3530 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_get_enum_double() local
3534 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_get_enum_double()
3536 reg_val = soc_dapm_read(dapm, e->reg); in snd_soc_dapm_get_enum_double()
3540 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_get_enum_double()
3555 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3559 * Callback to set the value of a dapm enumerated double mixer control.
3566 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_put_enum_double() local
3567 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_enum_double()
3592 reg_change = soc_dapm_test_bits(dapm, e->reg, mask, val); in snd_soc_dapm_put_enum_double()
3652 snd_soc_dapm_get_pin_status(&card->dapm, pin); in snd_soc_dapm_get_pin_switch()
3674 ret = __snd_soc_dapm_set_pin(&card->dapm, pin, in snd_soc_dapm_put_pin_switch()
3678 snd_soc_dapm_sync(&card->dapm); in snd_soc_dapm_put_pin_switch()
3684 snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_control_unlocked() argument
3691 w = dapm_cnew_widget(widget, soc_dapm_prefix(dapm)); in snd_soc_dapm_new_control_unlocked()
3697 w->regulator = devm_regulator_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3706 dev_warn(dapm->dev, in snd_soc_dapm_new_control_unlocked()
3712 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3722 w->clk = devm_clk_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3738 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3748 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3800 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3804 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3816 dev_err_probe(dapm->dev, ret, "ASoC: Failed to request %s\n", in snd_soc_dapm_new_control_unlocked()
3826 * snd_soc_dapm_new_control - create new dapm control
3827 * @dapm: DAPM context
3830 * Creates new DAPM control based upon a template.
3835 snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_control() argument
3840 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_new_control()
3841 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3842 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_new_control()
3849 * snd_soc_dapm_new_controls - create new dapm controls
3850 * @dapm: DAPM context
3854 * Creates new DAPM controls based upon the templates.
3858 int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_controls() argument
3865 snd_soc_dapm_mutex_lock_root(dapm); in snd_soc_dapm_new_controls()
3867 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls()
3874 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_new_controls()
3942 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3948 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
4158 dev_warn(card->dapm.dev, in snd_soc_dapm_alloc_kcontrol()
4257 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4280 * snd_soc_dapm_new_dai_widgets - Create new DAPM widgets
4281 * @dapm: DAPM context
4286 int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_dai_widgets() argument
4292 WARN_ON(dapm->dev != dai->dev); in snd_soc_dapm_new_dai_widgets()
4305 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4321 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4360 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4382 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4389 static void dapm_connect_dai_routes(struct snd_soc_dapm_context *dapm, in dapm_connect_dai_routes() argument
4396 dev_dbg(dapm->dev, "connected DAI link %s:%s -> %s:%s\n", in dapm_connect_dai_routes()
4401 snd_soc_dapm_add_path(dapm, src, dai, NULL, NULL); in dapm_connect_dai_routes()
4405 snd_soc_dapm_add_path(dapm, src, sink, NULL, NULL); in dapm_connect_dai_routes()
4447 dapm_connect_dai_routes(&card->dapm, src_dai[stream], *src[stream], in dapm_connect_dai_pair()
4535 * snd_soc_dapm_stream_event - send a stream event to the dapm core
4540 * Sends a stream event to the dapm core. The core then makes any
4580 * @dapm: DAPM context
4588 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4591 int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_enable_pin_unlocked() argument
4594 return snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin_unlocked()
4600 * @dapm: DAPM context
4606 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4609 int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) in snd_soc_dapm_enable_pin() argument
4613 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_enable_pin()
4615 ret = snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin()
4617 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_enable_pin()
4625 * @dapm: DAPM context
4634 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4637 int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_enable_pin_unlocked() argument
4640 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked()
4643 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4647 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4666 * @dapm: DAPM context
4673 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4676 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_enable_pin() argument
4681 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_force_enable_pin()
4683 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin); in snd_soc_dapm_force_enable_pin()
4685 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_force_enable_pin()
4693 * @dapm: DAPM context
4700 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4703 int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_disable_pin_unlocked() argument
4706 return snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_disable_pin_unlocked()
4712 * @dapm: DAPM context
4717 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4720 int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_disable_pin() argument
4725 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_disable_pin()
4727 ret = snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_disable_pin()
4729 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_disable_pin()
4737 * @dapm: DAPM context
4748 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4751 int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_nc_pin_unlocked() argument
4754 return snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_nc_pin_unlocked()
4760 * @dapm: DAPM context
4769 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4772 int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) in snd_soc_dapm_nc_pin() argument
4776 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_nc_pin()
4778 ret = snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_nc_pin()
4780 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_nc_pin()
4788 * @dapm: DAPM context
4795 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_get_pin_status() argument
4798 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status()
4808 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
4809 * @dapm: DAPM context
4818 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_ignore_suspend() argument
4821 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend()
4824 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_ignore_suspend()
4835 * snd_soc_dapm_free - free dapm resources
4836 * @dapm: DAPM context
4838 * Free all dapm widgets and resources.
4840 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_free() argument
4842 dapm_debugfs_cleanup(dapm); in snd_soc_dapm_free()
4843 dapm_free_widgets(dapm); in snd_soc_dapm_free()
4844 list_del(&dapm->list); in snd_soc_dapm_free()
4848 void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_init() argument
4852 dapm->card = card; in snd_soc_dapm_init()
4853 dapm->component = component; in snd_soc_dapm_init()
4854 dapm->bias_level = SND_SOC_BIAS_OFF; in snd_soc_dapm_init()
4857 dapm->dev = component->dev; in snd_soc_dapm_init()
4858 dapm->idle_bias_off = !component->driver->idle_bias_on; in snd_soc_dapm_init()
4859 dapm->suspend_bias_off = component->driver->suspend_bias_off; in snd_soc_dapm_init()
4861 dapm->dev = card->dev; in snd_soc_dapm_init()
4864 INIT_LIST_HEAD(&dapm->list); in snd_soc_dapm_init()
4866 list_add(&dapm->list, &card->dapm_list); in snd_soc_dapm_init()
4870 static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) in soc_dapm_shutdown_dapm() argument
4872 struct snd_soc_card *card = dapm->card; in soc_dapm_shutdown_dapm()
4879 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4880 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4893 if (dapm->bias_level == SND_SOC_BIAS_ON) in soc_dapm_shutdown_dapm()
4894 snd_soc_dapm_set_bias_level(dapm, in soc_dapm_shutdown_dapm()
4897 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) in soc_dapm_shutdown_dapm()
4898 snd_soc_dapm_set_bias_level(dapm, in soc_dapm_shutdown_dapm()
4910 struct snd_soc_dapm_context *dapm; in snd_soc_dapm_shutdown() local
4912 for_each_card_dapms(card, dapm) { in snd_soc_dapm_shutdown()
4913 if (dapm != &card->dapm) { in snd_soc_dapm_shutdown()
4914 soc_dapm_shutdown_dapm(dapm); in snd_soc_dapm_shutdown()
4915 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4916 snd_soc_dapm_set_bias_level(dapm, in snd_soc_dapm_shutdown()
4921 soc_dapm_shutdown_dapm(&card->dapm); in snd_soc_dapm_shutdown()
4922 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4923 snd_soc_dapm_set_bias_level(&card->dapm, in snd_soc_dapm_shutdown()