Lines Matching full:dapm
3 // soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
42 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
51 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
58 snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
62 snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
65 static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg);
67 /* dapm power sequences - make this per codec in the future */
150 static void dapm_assert_locked(struct snd_soc_dapm_context *dapm) in dapm_assert_locked() argument
152 if (snd_soc_card_is_instantiated(dapm->card)) in dapm_assert_locked()
153 snd_soc_dapm_mutex_assert_held(dapm); in dapm_assert_locked()
190 dapm_assert_locked(w->dapm); in dapm_mark_dirty()
193 dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", in dapm_mark_dirty()
195 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); in dapm_mark_dirty()
214 dapm_assert_locked(w->dapm); in dapm_widget_invalidate_paths()
321 /* create a new dapm widget */
377 dev_warn(widget->dapm->dev, in dapm_kcontrol_data_alloc()
403 snd_soc_dapm_new_control_unlocked(widget->dapm, in dapm_kcontrol_data_alloc()
438 widget->dapm, &template); in dapm_kcontrol_data_alloc()
445 snd_soc_dapm_add_path(widget->dapm, data->widget, in dapm_kcontrol_data_alloc()
448 data->value = soc_dapm_read(widget->dapm, e->reg) & in dapm_kcontrol_data_alloc()
589 * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a
599 return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm; in snd_soc_dapm_kcontrol_dapm()
617 static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm) in soc_dapm_prefix() argument
619 if (!dapm->component) in soc_dapm_prefix()
621 return dapm->component->name_prefix; in soc_dapm_prefix()
624 static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg) in soc_dapm_read() argument
626 if (!dapm->component) in soc_dapm_read()
628 return snd_soc_component_read(dapm->component, reg); in soc_dapm_read()
631 static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm, in soc_dapm_update_bits() argument
634 if (!dapm->component) in soc_dapm_update_bits()
636 return snd_soc_component_update_bits(dapm->component, reg, in soc_dapm_update_bits()
640 static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm, in soc_dapm_test_bits() argument
643 if (!dapm->component) in soc_dapm_test_bits()
645 return snd_soc_component_test_bits(dapm->component, reg, mask, value); in soc_dapm_test_bits()
648 static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) in soc_dapm_async_complete() argument
650 if (dapm->component) in soc_dapm_async_complete()
651 snd_soc_component_async_complete(dapm->component); in soc_dapm_async_complete()
658 struct list_head *wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
675 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
676 * @dapm: The DAPM context for which to set the level
679 * Forces the DAPM bias level to a specific state. It will call the bias level
680 * callback of DAPM context with the specified level. This will even happen if
687 * determined by the DAPM core. The function is mainly intended to be used to
689 * initialization can be done, before the DAPM core takes over.
691 int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_bias_level() argument
696 if (dapm->component) in snd_soc_dapm_force_bias_level()
697 ret = snd_soc_component_set_bias_level(dapm->component, level); in snd_soc_dapm_force_bias_level()
700 dapm->bias_level = level; in snd_soc_dapm_force_bias_level()
708 * @dapm: DAPM context
715 static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_set_bias_level() argument
718 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_set_bias_level()
723 ret = snd_soc_card_set_bias_level(card, dapm, level); in snd_soc_dapm_set_bias_level()
727 if (!card || dapm != &card->dapm) in snd_soc_dapm_set_bias_level()
728 ret = snd_soc_dapm_force_bias_level(dapm, level); in snd_soc_dapm_set_bias_level()
733 ret = snd_soc_card_set_bias_level_post(card, dapm, level); in snd_soc_dapm_set_bias_level()
741 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, in dapm_connect_mux() argument
752 val = soc_dapm_read(dapm, e->reg); in dapm_connect_mux()
788 unsigned int val = soc_dapm_read(p->sink->dapm, reg); in dapm_set_mixer_path_status()
804 val = soc_dapm_read(p->sink->dapm, mc->rreg); in dapm_set_mixer_path_status()
824 static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, in dapm_connect_mixer() argument
840 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, in dapm_is_shared_kcontrol() argument
850 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
851 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
872 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol() local
873 struct snd_card *card = dapm->card->snd_card; in dapm_create_or_share_kcontrol()
883 prefix = soc_dapm_prefix(dapm); in dapm_create_or_share_kcontrol()
889 shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[kci], in dapm_create_or_share_kcontrol()
961 dev_err(dapm->dev, in dapm_create_or_share_kcontrol()
962 "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", in dapm_create_or_share_kcontrol()
978 /* create new dapm mixer control */
1003 snd_soc_dapm_add_path(data->widget->dapm, in dapm_new_mixer()
1013 /* create new dapm mux control */
1016 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_mux() local
1036 dev_err(dapm->dev, in dapm_new_mux()
1043 dev_err(dapm->dev, "ASoC: %s %s has no paths\n", type, w->name); in dapm_new_mux()
1059 /* create new dapm volume control */
1073 /* create new dapm dai link control */
1085 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link() local
1086 struct snd_card *card = dapm->card->snd_card; in dapm_new_dai_link()
1092 dev_err(dapm->dev, in dapm_new_dai_link()
1093 "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", in dapm_new_dai_link()
1110 int level = snd_power_get_state(widget->dapm->card->snd_card); in snd_soc_dapm_suspend_check()
1116 dev_dbg(widget->dapm->dev, "ASoC: %s ignoring suspend\n", in snd_soc_dapm_suspend_check()
1246 * This function takes the dapm widget currently being examined and the walk
1264 * This function takes the dapm widget currently being examined and the walk
1285 * Queries DAPM graph as to whether a valid audio stream path exists for
1290 * This function takes the dapm widget currently being examined and the walk
1347 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1353 dev_warn(w->dapm->dev, in dapm_regulator_event()
1363 dev_warn(w->dapm->dev, in dapm_regulator_event()
1407 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1504 if (a->dapm != b->dapm) in dapm_seq_compare()
1505 return (unsigned long)a->dapm - (unsigned long)b->dapm; in dapm_seq_compare()
1510 /* Insert a widget in order into a DAPM power sequence. */
1568 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1570 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1575 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1580 /* Apply the coalesced changes from a DAPM sequence */
1584 struct snd_soc_dapm_context *dapm; in dapm_seq_run_coalesced() local
1592 dapm = w->dapm; in dapm_seq_run_coalesced()
1595 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1604 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1618 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1622 soc_dapm_update_bits(dapm, reg, mask, value); in dapm_seq_run_coalesced()
1631 /* Apply a DAPM power sequence.
1662 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1674 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1714 cur_dapm = w->dapm; in dapm_seq_run()
1720 dev_err(w->dapm->dev, in dapm_seq_run()
1756 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1764 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1767 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1771 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1774 dev_err(w->dapm->dev, in dapm_widget_update()
1775 "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1783 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1789 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1821 /* Async callback run prior to DAPM sequences - brings to their final
1922 static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm) in dapm_idle_bias_off() argument
1924 if (dapm->idle_bias_off) in dapm_idle_bias_off()
1927 switch (snd_power_get_state(dapm->card->snd_card)) { in dapm_idle_bias_off()
1930 return dapm->suspend_bias_off; in dapm_idle_bias_off()
1939 * Scan each dapm widget for complete audio path.
1992 d = w->dapm; in dapm_power_widgets()
2035 dapm_pre_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2038 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2062 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2068 dapm_post_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2070 /* do we need to notify any clients that DAPM event is complete */ in dapm_power_widgets()
2081 "DAPM sequencing finished, waiting %dms\n", card->pop_time); in dapm_power_widgets()
2105 snd_soc_dapm_mutex_lock_root(w->dapm); in dapm_widget_power_read_file()
2149 snd_soc_dapm_mutex_unlock(w->dapm); in dapm_widget_power_read_file()
2166 struct snd_soc_dapm_context *dapm = file->private_data; in dapm_bias_read_file() local
2169 switch (dapm->bias_level) { in dapm_bias_read_file()
2183 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2198 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_debugfs_init() argument
2204 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); in snd_soc_dapm_debugfs_init()
2206 debugfs_create_file("bias_level", 0444, dapm->debugfs_dapm, dapm, in snd_soc_dapm_debugfs_init()
2212 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget() local
2214 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2217 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2223 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_free_widget() local
2225 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_free_widget()
2228 debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); in dapm_debugfs_free_widget()
2231 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) in dapm_debugfs_cleanup() argument
2233 debugfs_remove_recursive(dapm->debugfs_dapm); in dapm_debugfs_cleanup()
2234 dapm->debugfs_dapm = NULL; in dapm_debugfs_cleanup()
2238 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_debugfs_init() argument
2251 static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) in dapm_debugfs_cleanup() argument
2286 /* find dapm widget path assoc with kcontrol */ in soc_dapm_mux_update_power()
2304 int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_mux_update_power() argument
2308 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mux_update_power()
2332 /* find dapm widget path assoc with kcontrol */ in soc_dapm_mixer_update_power()
2369 int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_mixer_update_power() argument
2373 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mixer_update_power()
2390 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt); in dapm_widget_show_component() local
2402 if (w->dapm != dapm) in dapm_widget_show_component()
2432 switch (snd_soc_dapm_get_bias_level(dapm)) { in dapm_widget_show_component()
2451 /* show dapm widget status in sys fs */
2523 /* free all dapm widgets and resources */
2524 static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) in dapm_free_widgets() argument
2528 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2529 if (w->dapm != dapm) in dapm_free_widgets()
2534 dapm->wcache_sink = NULL; in dapm_free_widgets()
2535 dapm->wcache_source = NULL; in dapm_free_widgets()
2539 struct snd_soc_dapm_context *dapm, const char *pin, in dapm_find_widget() argument
2546 const char *prefix = soc_dapm_prefix(dapm); in dapm_find_widget()
2556 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2558 if (w->dapm == dapm) in dapm_find_widget()
2572 * set the DAPM pin status:
2576 static int __snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, in __snd_soc_dapm_set_pin() argument
2579 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in __snd_soc_dapm_set_pin()
2582 dapm_assert_locked(dapm); in __snd_soc_dapm_set_pin()
2585 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); in __snd_soc_dapm_set_pin()
2607 static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_set_pin() argument
2610 int ret = __snd_soc_dapm_set_pin(dapm, pin, status); in snd_soc_dapm_set_pin()
2616 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2617 * @dapm: DAPM context
2619 * Walks all dapm audio paths and powers widgets according to their
2626 int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_sync_unlocked() argument
2630 * silly DAPM runs during card startup. in snd_soc_dapm_sync_unlocked()
2632 if (!snd_soc_card_is_instantiated(dapm->card)) in snd_soc_dapm_sync_unlocked()
2635 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); in snd_soc_dapm_sync_unlocked()
2640 * snd_soc_dapm_sync - scan and power dapm paths
2641 * @dapm: DAPM context
2643 * Walks all dapm audio paths and powers widgets according to their
2648 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_sync() argument
2652 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_sync()
2653 ret = snd_soc_dapm_sync_unlocked(dapm); in snd_soc_dapm_sync()
2654 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_sync()
2671 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2733 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); in snd_soc_dapm_widget_name_cmp()
2761 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2776 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2803 static int snd_soc_dapm_check_dynamic_path(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_check_dynamic_path() argument
2833 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2838 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2847 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_path() argument
2858 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2865 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2872 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2878 ret = snd_soc_dapm_check_dynamic_path(dapm, wsource, wsink, control); in snd_soc_dapm_add_path()
2902 ret = dapm_connect_mux(dapm, path, control, wsource); in snd_soc_dapm_add_path()
2912 ret = dapm_connect_mux(dapm, path, control, wsink); in snd_soc_dapm_add_path()
2919 ret = dapm_connect_mixer(dapm, path, control); in snd_soc_dapm_add_path()
2928 list_add(&path->list, &dapm->card->paths); in snd_soc_dapm_add_path()
2938 if (snd_soc_card_is_instantiated(dapm->card) && path->connect) in snd_soc_dapm_add_path()
2947 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_route() argument
2961 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_add_route()
2974 wsource = dapm_wcache_lookup(dapm->wcache_source, source); in snd_soc_dapm_add_route()
2975 wsink = dapm_wcache_lookup(dapm->wcache_sink, sink); in snd_soc_dapm_add_route()
2982 * current DAPM context in snd_soc_dapm_add_route()
2984 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
2987 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2994 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3001 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
3008 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
3013 /* use widget from another DAPM context if not found from this */ in snd_soc_dapm_add_route()
3027 dapm->wcache_sink = wsink; in snd_soc_dapm_add_route()
3028 dapm->wcache_source = wsource; in snd_soc_dapm_add_route()
3030 ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, in snd_soc_dapm_add_route()
3034 dev_err(dapm->dev, "ASoC: Failed to add route %s%s -%s%s%s> %s%s\n", in snd_soc_dapm_add_route()
3043 static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_del_route() argument
3054 dev_err(dapm->dev, in snd_soc_dapm_del_route()
3059 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_del_route()
3073 list_for_each_entry(p, &dapm->card->paths, list) { in snd_soc_dapm_del_route()
3097 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", in snd_soc_dapm_del_route()
3105 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
3106 * @dapm: DAPM context
3110 * Connects 2 dapm widgets together via a named audio path. The sink is
3117 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_routes() argument
3122 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_add_routes()
3124 int r = snd_soc_dapm_add_route(dapm, route); in snd_soc_dapm_add_routes()
3129 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_add_routes()
3136 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
3137 * @dapm: DAPM context
3141 * Removes routes from the DAPM context.
3143 int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_del_routes() argument
3148 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_del_routes()
3150 snd_soc_dapm_del_route(dapm, route); in snd_soc_dapm_del_routes()
3153 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_del_routes()
3159 static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_weak_route() argument
3162 struct snd_soc_dapm_widget *source = dapm_find_widget(dapm, in snd_soc_dapm_weak_route()
3165 struct snd_soc_dapm_widget *sink = dapm_find_widget(dapm, in snd_soc_dapm_weak_route()
3172 dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n", in snd_soc_dapm_weak_route()
3178 dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n", in snd_soc_dapm_weak_route()
3184 dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3195 dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3198 dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3205 * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
3206 * @dapm: DAPM context
3220 int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_weak_routes() argument
3226 snd_soc_dapm_mutex_lock_root(dapm); in snd_soc_dapm_weak_routes()
3228 int err = snd_soc_dapm_weak_route(dapm, route); in snd_soc_dapm_weak_routes()
3233 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_weak_routes()
3240 * snd_soc_dapm_new_widgets - add new dapm widgets
3241 * @card: card to be checked for new dapm widgets
3243 * Checks the codec for any new dapm widgets and creates them if found.
3293 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3313 * snd_soc_dapm_get_volsw - dapm mixer get callback
3317 * Callback to get the value of a dapm mixer control.
3324 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_get_volsw() local
3335 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_get_volsw()
3337 reg_val = soc_dapm_read(dapm, reg); in snd_soc_dapm_get_volsw()
3341 reg_val = soc_dapm_read(dapm, mc->rreg); in snd_soc_dapm_get_volsw()
3352 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_get_volsw()
3371 * snd_soc_dapm_put_volsw - dapm mixer set callback
3375 * Callback to set the value of a dapm mixer control.
3382 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_put_volsw() local
3383 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_volsw()
3414 dev_warn(dapm->dev, in snd_soc_dapm_put_volsw()
3423 reg_change = soc_dapm_test_bits(dapm, reg, mask << shift, val); in snd_soc_dapm_put_volsw()
3426 reg_change |= soc_dapm_test_bits(dapm, mc->rreg, in snd_soc_dapm_put_volsw()
3462 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
3466 * Callback to get the value of a dapm enumerated double mixer control.
3473 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_get_enum_double() local
3477 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_get_enum_double()
3479 reg_val = soc_dapm_read(dapm, e->reg); in snd_soc_dapm_get_enum_double()
3483 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_get_enum_double()
3498 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3502 * Callback to set the value of a dapm enumerated double mixer control.
3509 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_put_enum_double() local
3510 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_enum_double()
3535 reg_change = soc_dapm_test_bits(dapm, e->reg, mask, val); in snd_soc_dapm_put_enum_double()
3595 snd_soc_dapm_get_pin_status(&card->dapm, pin); in snd_soc_dapm_get_pin_switch()
3617 ret = __snd_soc_dapm_set_pin(&card->dapm, pin, in snd_soc_dapm_put_pin_switch()
3621 snd_soc_dapm_sync(&card->dapm); in snd_soc_dapm_put_pin_switch()
3627 snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_control_unlocked() argument
3638 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_new_control_unlocked()
3648 w->regulator = devm_regulator_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3657 dev_warn(dapm->dev, in snd_soc_dapm_new_control_unlocked()
3663 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3673 w->clk = devm_clk_get(dapm->dev, widget->name); in snd_soc_dapm_new_control_unlocked()
3689 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3699 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3751 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3755 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3767 dev_err_probe(dapm->dev, ret, "ASoC: Failed to request %s\n", in snd_soc_dapm_new_control_unlocked()
3778 * snd_soc_dapm_new_control - create new dapm control
3779 * @dapm: DAPM context
3782 * Creates new DAPM control based upon a template.
3787 snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_control() argument
3792 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_new_control()
3793 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3794 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_new_control()
3801 * snd_soc_dapm_new_controls - create new dapm controls
3802 * @dapm: DAPM context
3806 * Creates new DAPM controls based upon the templates.
3810 int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_controls() argument
3817 snd_soc_dapm_mutex_lock_root(dapm); in snd_soc_dapm_new_controls()
3819 struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls()
3826 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_new_controls()
3896 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3903 dev_warn(w->dapm->dev, "ASoC: Invalid format was specified\n"); in snd_soc_dai_link_event_pre_pmu()
4106 dev_warn(card->dapm.dev, in snd_soc_dapm_alloc_kcontrol()
4205 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4228 * snd_soc_dapm_new_dai_widgets - Create new DAPM widgets
4229 * @dapm: DAPM context
4234 int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_dai_widgets() argument
4240 WARN_ON(dapm->dev != dai->dev); in snd_soc_dapm_new_dai_widgets()
4253 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4269 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4308 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4330 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4337 static void dapm_connect_dai_routes(struct snd_soc_dapm_context *dapm, in dapm_connect_dai_routes() argument
4344 dev_dbg(dapm->dev, "connected DAI link %s:%s -> %s:%s\n", in dapm_connect_dai_routes()
4349 snd_soc_dapm_add_path(dapm, src, dai, NULL, NULL); in dapm_connect_dai_routes()
4353 snd_soc_dapm_add_path(dapm, src, sink, NULL, NULL); in dapm_connect_dai_routes()
4395 dapm_connect_dai_routes(&card->dapm, src_dai[stream], *src[stream], in dapm_connect_dai_pair()
4504 * snd_soc_dapm_stream_event - send a stream event to the dapm core
4509 * Sends a stream event to the dapm core. The core then makes any
4549 * @dapm: DAPM context
4557 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4560 int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_enable_pin_unlocked() argument
4563 return snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin_unlocked()
4569 * @dapm: DAPM context
4575 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4578 int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) in snd_soc_dapm_enable_pin() argument
4582 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_enable_pin()
4584 ret = snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin()
4586 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_enable_pin()
4594 * @dapm: DAPM context
4603 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4606 int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_enable_pin_unlocked() argument
4609 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked()
4612 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4616 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4635 * @dapm: DAPM context
4642 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4645 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_enable_pin() argument
4650 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_force_enable_pin()
4652 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin); in snd_soc_dapm_force_enable_pin()
4654 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_force_enable_pin()
4662 * @dapm: DAPM context
4669 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4672 int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_disable_pin_unlocked() argument
4675 return snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_disable_pin_unlocked()
4681 * @dapm: DAPM context
4686 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4689 int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_disable_pin() argument
4694 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_disable_pin()
4696 ret = snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_disable_pin()
4698 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_disable_pin()
4706 * @dapm: DAPM context
4717 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4720 int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_nc_pin_unlocked() argument
4723 return snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_nc_pin_unlocked()
4729 * @dapm: DAPM context
4738 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4741 int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) in snd_soc_dapm_nc_pin() argument
4745 snd_soc_dapm_mutex_lock(dapm); in snd_soc_dapm_nc_pin()
4747 ret = snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_nc_pin()
4749 snd_soc_dapm_mutex_unlock(dapm); in snd_soc_dapm_nc_pin()
4757 * @dapm: DAPM context
4764 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_get_pin_status() argument
4767 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status()
4777 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
4778 * @dapm: DAPM context
4787 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_ignore_suspend() argument
4790 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend()
4793 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_ignore_suspend()
4804 * snd_soc_dapm_free - free dapm resources
4805 * @dapm: DAPM context
4807 * Free all dapm widgets and resources.
4809 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_free() argument
4811 dapm_debugfs_cleanup(dapm); in snd_soc_dapm_free()
4812 dapm_free_widgets(dapm); in snd_soc_dapm_free()
4813 list_del(&dapm->list); in snd_soc_dapm_free()
4817 void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_init() argument
4821 dapm->card = card; in snd_soc_dapm_init()
4822 dapm->component = component; in snd_soc_dapm_init()
4823 dapm->bias_level = SND_SOC_BIAS_OFF; in snd_soc_dapm_init()
4826 dapm->dev = component->dev; in snd_soc_dapm_init()
4827 dapm->idle_bias_off = !component->driver->idle_bias_on; in snd_soc_dapm_init()
4828 dapm->suspend_bias_off = component->driver->suspend_bias_off; in snd_soc_dapm_init()
4830 dapm->dev = card->dev; in snd_soc_dapm_init()
4833 INIT_LIST_HEAD(&dapm->list); in snd_soc_dapm_init()
4835 list_add(&dapm->list, &card->dapm_list); in snd_soc_dapm_init()
4839 static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) in soc_dapm_shutdown_dapm() argument
4841 struct snd_soc_card *card = dapm->card; in soc_dapm_shutdown_dapm()
4848 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4849 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4862 if (dapm->bias_level == SND_SOC_BIAS_ON) in soc_dapm_shutdown_dapm()
4863 snd_soc_dapm_set_bias_level(dapm, in soc_dapm_shutdown_dapm()
4866 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) in soc_dapm_shutdown_dapm()
4867 snd_soc_dapm_set_bias_level(dapm, in soc_dapm_shutdown_dapm()
4879 struct snd_soc_dapm_context *dapm; in snd_soc_dapm_shutdown() local
4881 for_each_card_dapms(card, dapm) { in snd_soc_dapm_shutdown()
4882 if (dapm != &card->dapm) { in snd_soc_dapm_shutdown()
4883 soc_dapm_shutdown_dapm(dapm); in snd_soc_dapm_shutdown()
4884 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4885 snd_soc_dapm_set_bias_level(dapm, in snd_soc_dapm_shutdown()
4890 soc_dapm_shutdown_dapm(&card->dapm); in snd_soc_dapm_shutdown()
4891 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4892 snd_soc_dapm_set_bias_level(&card->dapm, in snd_soc_dapm_shutdown()