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 (dapm->card && dapm->card->instantiated) in dapm_assert_locked()
153 lockdep_assert_held(&dapm->card->dapm_mutex); 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 */
374 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()
663 wlist = &w->dapm->card->widgets; in dapm_wcache_lookup()
684 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
685 * @dapm: The DAPM context for which to set the level
688 * Forces the DAPM bias level to a specific state. It will call the bias level
689 * callback of DAPM context with the specified level. This will even happen if
696 * determined by the DAPM core. The function is mainly intended to be used to
698 * initialization can be done, before the DAPM core takes over.
700 int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_bias_level() argument
705 if (dapm->component) in snd_soc_dapm_force_bias_level()
706 ret = snd_soc_component_set_bias_level(dapm->component, level); in snd_soc_dapm_force_bias_level()
709 dapm->bias_level = level; in snd_soc_dapm_force_bias_level()
717 * @dapm: DAPM context
724 static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_set_bias_level() argument
727 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_set_bias_level()
732 ret = snd_soc_card_set_bias_level(card, dapm, level); in snd_soc_dapm_set_bias_level()
736 if (!card || dapm != &card->dapm) in snd_soc_dapm_set_bias_level()
737 ret = snd_soc_dapm_force_bias_level(dapm, level); in snd_soc_dapm_set_bias_level()
742 ret = snd_soc_card_set_bias_level_post(card, dapm, level); in snd_soc_dapm_set_bias_level()
750 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, in dapm_connect_mux() argument
760 val = soc_dapm_read(dapm, e->reg); in dapm_connect_mux()
797 val = soc_dapm_read(p->sink->dapm, reg); in dapm_set_mixer_path_status()
812 val = soc_dapm_read(p->sink->dapm, mc->rreg); in dapm_set_mixer_path_status()
832 static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, in dapm_connect_mixer() argument
848 static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, in dapm_is_shared_kcontrol() argument
858 for_each_card_widgets(dapm->card, w) { in dapm_is_shared_kcontrol()
859 if (w == kcontrolw || w->dapm != kcontrolw->dapm) in dapm_is_shared_kcontrol()
880 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_create_or_share_kcontrol() local
881 struct snd_card *card = dapm->card->snd_card; in dapm_create_or_share_kcontrol()
891 prefix = soc_dapm_prefix(dapm); in dapm_create_or_share_kcontrol()
897 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 */
1084 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_new_dai_link() local
1085 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()
1252 * This function takes the dapm widget currently being examined and the walk
1270 * This function takes the dapm widget currently being examined and the walk
1291 * Queries DAPM graph as to whether a valid audio stream path exists for
1296 * This function takes the dapm widget currently being examined and the walk
1353 soc_dapm_async_complete(w->dapm); in dapm_regulator_event()
1359 dev_warn(w->dapm->dev, in dapm_regulator_event()
1369 dev_warn(w->dapm->dev, in dapm_regulator_event()
1413 soc_dapm_async_complete(w->dapm); in dapm_clock_event()
1510 if (a->dapm != b->dapm) in dapm_seq_compare()
1511 return (unsigned long)a->dapm - (unsigned long)b->dapm; in dapm_seq_compare()
1516 /* Insert a widget in order into a DAPM power sequence. */
1572 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", in dapm_seq_check_event()
1574 soc_dapm_async_complete(w->dapm); in dapm_seq_check_event()
1579 dev_err(w->dapm->dev, "ASoC: %s: %s event failed: %d\n", in dapm_seq_check_event()
1584 /* Apply the coalesced changes from a DAPM sequence */
1588 struct snd_soc_dapm_context *dapm; in dapm_seq_run_coalesced() local
1596 dapm = w->dapm; in dapm_seq_run_coalesced()
1599 WARN_ON(reg != w->reg || dapm != w->dapm); in dapm_seq_run_coalesced()
1608 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1622 pop_dbg(dapm->dev, card->pop_time, in dapm_seq_run_coalesced()
1626 soc_dapm_update_bits(dapm, reg, mask, value); in dapm_seq_run_coalesced()
1635 /* Apply a DAPM power sequence.
1666 w->dapm != cur_dapm || w->subseq != cur_subseq) { in dapm_seq_run()
1678 if (cur_dapm && w->dapm != cur_dapm) in dapm_seq_run()
1718 cur_dapm = w->dapm; in dapm_seq_run()
1724 dev_err(w->dapm->dev, in dapm_seq_run()
1760 dev_err(w->dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n", in dapm_widget_update()
1768 ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, in dapm_widget_update()
1771 dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1775 ret = soc_dapm_update_bits(w->dapm, update->reg2, in dapm_widget_update()
1778 dev_err(w->dapm->dev, in dapm_widget_update()
1779 "ASoC: %s DAPM update failed: %d\n", in dapm_widget_update()
1787 dev_err(w->dapm->dev, "ASoC: %s DAPM post-event failed: %d\n", in dapm_widget_update()
1793 /* Async callback run prior to DAPM sequences - brings to _PREPARE if
1825 /* Async callback run prior to DAPM sequences - brings to their final
1932 static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm) in dapm_idle_bias_off() argument
1934 if (dapm->idle_bias_off) in dapm_idle_bias_off()
1937 switch (snd_power_get_state(dapm->card->snd_card)) { in dapm_idle_bias_off()
1940 return dapm->suspend_bias_off; in dapm_idle_bias_off()
1949 * Scan each dapm widget for complete audio path.
2002 d = w->dapm; in dapm_power_widgets()
2045 dapm_pre_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2048 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2072 if (d != &card->dapm && d->bias_level != d->target_bias_level) in dapm_power_widgets()
2078 dapm_post_sequence_async(&card->dapm, 0); in dapm_power_widgets()
2080 /* do we need to notify any clients that DAPM event is complete */ in dapm_power_widgets()
2091 "DAPM sequencing finished, waiting %dms\n", card->pop_time); in dapm_power_widgets()
2105 struct snd_soc_card *card = w->dapm->card; in dapm_widget_power_read_file()
2177 struct snd_soc_dapm_context *dapm = file->private_data; in dapm_bias_read_file() local
2180 switch (dapm->bias_level) { in dapm_bias_read_file()
2194 WARN(1, "Unknown bias_level %d\n", dapm->bias_level); in dapm_bias_read_file()
2209 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_debugfs_init() argument
2215 dapm->debugfs_dapm = debugfs_create_dir("dapm", parent); in snd_soc_dapm_debugfs_init()
2217 debugfs_create_file("bias_level", 0444, dapm->debugfs_dapm, dapm, in snd_soc_dapm_debugfs_init()
2223 struct snd_soc_dapm_context *dapm = w->dapm; in dapm_debugfs_add_widget() local
2225 if (!dapm->debugfs_dapm || !w->name) in dapm_debugfs_add_widget()
2228 debugfs_create_file(w->name, 0444, dapm->debugfs_dapm, w, in dapm_debugfs_add_widget()
2232 static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) in dapm_debugfs_cleanup() argument
2234 debugfs_remove_recursive(dapm->debugfs_dapm); in dapm_debugfs_cleanup()
2235 dapm->debugfs_dapm = NULL; in dapm_debugfs_cleanup()
2239 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_debugfs_init() argument
2248 static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) in dapm_debugfs_cleanup() argument
2283 /* find dapm widget path assoc with kcontrol */ in soc_dapm_mux_update_power()
2301 int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_mux_update_power() argument
2305 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mux_update_power()
2329 /* find dapm widget path assoc with kcontrol */ in soc_dapm_mixer_update_power()
2366 int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_mixer_update_power() argument
2370 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_mixer_update_power()
2387 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt); in dapm_widget_show_component() local
2400 if (w->dapm != dapm) in dapm_widget_show_component()
2430 switch (snd_soc_dapm_get_bias_level(dapm)) { in dapm_widget_show_component()
2449 /* show dapm widget status in sys fs */
2509 void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_reset_cache() argument
2511 dapm->path_sink_cache.widget = NULL; in snd_soc_dapm_reset_cache()
2512 dapm->path_source_cache.widget = NULL; in snd_soc_dapm_reset_cache()
2515 /* free all dapm widgets and resources */
2516 static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) in dapm_free_widgets() argument
2520 for_each_card_widgets_safe(dapm->card, w, next_w) { in dapm_free_widgets()
2521 if (w->dapm != dapm) in dapm_free_widgets()
2525 snd_soc_dapm_reset_cache(dapm); in dapm_free_widgets()
2529 struct snd_soc_dapm_context *dapm, const char *pin, in dapm_find_widget() argument
2536 const char *prefix = soc_dapm_prefix(dapm); in dapm_find_widget()
2546 for_each_card_widgets(dapm->card, w) { in dapm_find_widget()
2548 if (w->dapm == dapm) in dapm_find_widget()
2562 * set the DAPM pin status:
2566 static int __snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, in __snd_soc_dapm_set_pin() argument
2569 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in __snd_soc_dapm_set_pin()
2572 dapm_assert_locked(dapm); in __snd_soc_dapm_set_pin()
2575 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); in __snd_soc_dapm_set_pin()
2597 static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_set_pin() argument
2600 int ret = __snd_soc_dapm_set_pin(dapm, pin, status); in snd_soc_dapm_set_pin()
2606 * snd_soc_dapm_sync_unlocked - scan and power dapm paths
2607 * @dapm: DAPM context
2609 * Walks all dapm audio paths and powers widgets according to their
2616 int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_sync_unlocked() argument
2620 * silly DAPM runs during card startup. in snd_soc_dapm_sync_unlocked()
2622 if (!dapm->card || !dapm->card->instantiated) in snd_soc_dapm_sync_unlocked()
2625 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); in snd_soc_dapm_sync_unlocked()
2630 * snd_soc_dapm_sync - scan and power dapm paths
2631 * @dapm: DAPM context
2633 * Walks all dapm audio paths and powers widgets according to their
2638 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_sync() argument
2642 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_sync()
2643 ret = snd_soc_dapm_sync_unlocked(dapm); in snd_soc_dapm_sync()
2644 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_sync()
2661 dev_dbg(w->dapm->dev, "%s DAI route %s -> %s\n", in dapm_update_dai_chan()
2739 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2754 if (w->dapm->card->fully_routed) in dapm_update_widget_flags()
2781 static int snd_soc_dapm_check_dynamic_path(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_check_dynamic_path() argument
2811 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2816 dev_err(dapm->dev, in snd_soc_dapm_check_dynamic_path()
2825 static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_path() argument
2837 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2844 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2851 dev_err(dapm->dev, in snd_soc_dapm_add_path()
2857 ret = snd_soc_dapm_check_dynamic_path(dapm, wsource, wsink, control); in snd_soc_dapm_add_path()
2883 ret = dapm_connect_mux(dapm, path, control, wsource); in snd_soc_dapm_add_path()
2893 ret = dapm_connect_mux(dapm, path, control, wsink); in snd_soc_dapm_add_path()
2900 ret = dapm_connect_mixer(dapm, path, control); in snd_soc_dapm_add_path()
2909 list_add(&path->list, &dapm->card->paths); in snd_soc_dapm_add_path()
2918 if (dapm->card->instantiated && path->connect) in snd_soc_dapm_add_path()
2927 static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_route() argument
2941 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_add_route()
2954 wsource = dapm_wcache_lookup(&dapm->path_source_cache, source); in snd_soc_dapm_add_route()
2955 wsink = dapm_wcache_lookup(&dapm->path_sink_cache, sink); in snd_soc_dapm_add_route()
2962 * current DAPM context in snd_soc_dapm_add_route()
2964 for_each_card_widgets(dapm->card, w) { in snd_soc_dapm_add_route()
2967 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2974 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
2981 if (w->dapm == dapm) { in snd_soc_dapm_add_route()
2988 dev_warn(dapm->dev, in snd_soc_dapm_add_route()
2993 /* use widget from another DAPM context if not found from this */ in snd_soc_dapm_add_route()
3000 dev_err(dapm->dev, "ASoC: no source widget found for %s\n", in snd_soc_dapm_add_route()
3005 dev_err(dapm->dev, "ASoC: no sink widget found for %s\n", in snd_soc_dapm_add_route()
3011 dapm_wcache_update(&dapm->path_sink_cache, wsink); in snd_soc_dapm_add_route()
3012 dapm_wcache_update(&dapm->path_source_cache, wsource); in snd_soc_dapm_add_route()
3014 ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, in snd_soc_dapm_add_route()
3021 dev_warn(dapm->dev, "ASoC: no dapm match for %s --> %s --> %s\n", in snd_soc_dapm_add_route()
3026 static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_del_route() argument
3038 dev_err(dapm->dev, in snd_soc_dapm_del_route()
3043 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_del_route()
3057 list_for_each_entry(p, &dapm->card->paths, list) { in snd_soc_dapm_del_route()
3081 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n", in snd_soc_dapm_del_route()
3089 * snd_soc_dapm_add_routes - Add routes between DAPM widgets
3090 * @dapm: DAPM context
3094 * Connects 2 dapm widgets together via a named audio path. The sink is
3101 int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_add_routes() argument
3106 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_add_routes()
3108 r = snd_soc_dapm_add_route(dapm, route); in snd_soc_dapm_add_routes()
3110 dev_err(dapm->dev, "ASoC: Failed to add route %s -> %s -> %s\n", in snd_soc_dapm_add_routes()
3118 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_add_routes()
3125 * snd_soc_dapm_del_routes - Remove routes between DAPM widgets
3126 * @dapm: DAPM context
3130 * Removes routes from the DAPM context.
3132 int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_del_routes() argument
3137 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_del_routes()
3139 snd_soc_dapm_del_route(dapm, route); in snd_soc_dapm_del_routes()
3142 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_del_routes()
3148 static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_weak_route() argument
3151 struct snd_soc_dapm_widget *source = dapm_find_widget(dapm, in snd_soc_dapm_weak_route()
3154 struct snd_soc_dapm_widget *sink = dapm_find_widget(dapm, in snd_soc_dapm_weak_route()
3161 dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n", in snd_soc_dapm_weak_route()
3167 dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n", in snd_soc_dapm_weak_route()
3173 dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3184 dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3187 dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n", in snd_soc_dapm_weak_route()
3194 * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
3195 * @dapm: DAPM context
3209 int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_weak_routes() argument
3215 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); in snd_soc_dapm_weak_routes()
3217 err = snd_soc_dapm_weak_route(dapm, route); in snd_soc_dapm_weak_routes()
3222 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_weak_routes()
3229 * snd_soc_dapm_new_widgets - add new dapm widgets
3230 * @card: card to be checked for new dapm widgets
3232 * Checks the codec for any new dapm widgets and creates them if found.
3282 val = soc_dapm_read(w->dapm, w->reg); in snd_soc_dapm_new_widgets()
3302 * snd_soc_dapm_get_volsw - dapm mixer get callback
3306 * Callback to get the value of a dapm mixer control.
3313 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_get_volsw() local
3314 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_get_volsw()
3327 reg_val = soc_dapm_read(dapm, reg); in snd_soc_dapm_get_volsw()
3331 reg_val = soc_dapm_read(dapm, mc->rreg); in snd_soc_dapm_get_volsw()
3361 * snd_soc_dapm_put_volsw - dapm mixer set callback
3365 * Callback to set the value of a dapm mixer control.
3372 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_put_volsw() local
3373 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_volsw()
3404 dev_warn(dapm->dev, in snd_soc_dapm_put_volsw()
3413 reg_change = soc_dapm_test_bits(dapm, reg, mask << shift, val); in snd_soc_dapm_put_volsw()
3416 reg_change |= soc_dapm_test_bits(dapm, mc->rreg, in snd_soc_dapm_put_volsw()
3452 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
3456 * Callback to get the value of a dapm enumerated double mixer control.
3463 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_get_enum_double() local
3464 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_get_enum_double()
3470 reg_val = soc_dapm_read(dapm, e->reg); in snd_soc_dapm_get_enum_double()
3489 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3493 * Callback to set the value of a dapm enumerated double mixer control.
3500 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); in snd_soc_dapm_put_enum_double() local
3501 struct snd_soc_card *card = dapm->card; in snd_soc_dapm_put_enum_double()
3526 reg_change = soc_dapm_test_bits(dapm, e->reg, mask, val); in snd_soc_dapm_put_enum_double()
3586 snd_soc_dapm_get_pin_status(&card->dapm, pin); in snd_soc_dapm_get_pin_switch()
3608 ret = __snd_soc_dapm_set_pin(&card->dapm, pin, in snd_soc_dapm_put_pin_switch()
3612 snd_soc_dapm_sync(&card->dapm); in snd_soc_dapm_put_pin_switch()
3618 snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_control_unlocked() argument
3631 w->regulator = devm_regulator_get(dapm->dev, w->name); in snd_soc_dapm_new_control_unlocked()
3640 dev_warn(dapm->dev, in snd_soc_dapm_new_control_unlocked()
3646 w->pinctrl = devm_pinctrl_get(dapm->dev); in snd_soc_dapm_new_control_unlocked()
3656 w->clk = devm_clk_get(dapm->dev, w->name); in snd_soc_dapm_new_control_unlocked()
3666 prefix = soc_dapm_prefix(dapm); in snd_soc_dapm_new_control_unlocked()
3683 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3693 if (!dapm->card->fully_routed) in snd_soc_dapm_new_control_unlocked()
3745 w->dapm = dapm; in snd_soc_dapm_new_control_unlocked()
3749 list_add_tail(&w->list, &dapm->card->widgets); in snd_soc_dapm_new_control_unlocked()
3762 dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n", in snd_soc_dapm_new_control_unlocked()
3771 * snd_soc_dapm_new_control - create new dapm control
3772 * @dapm: DAPM context
3775 * Creates new DAPM control based upon a template.
3780 snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_control() argument
3785 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_new_control()
3786 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_control()
3787 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_new_control()
3794 * snd_soc_dapm_new_controls - create new dapm controls
3795 * @dapm: DAPM context
3799 * Creates new DAPM controls based upon the templates.
3803 int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_controls() argument
3811 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); in snd_soc_dapm_new_controls()
3813 w = snd_soc_dapm_new_control_unlocked(dapm, widget); in snd_soc_dapm_new_controls()
3820 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_new_controls()
3885 dev_err(w->dapm->dev, "ASoC: link config missing\n"); in snd_soc_dai_link_event_pre_pmu()
3894 dev_warn(w->dapm->dev, "ASoC: Invalid format %llx specified\n", in snd_soc_dai_link_event_pre_pmu()
4101 dev_warn(card->dapm.dev, in snd_soc_dapm_alloc_kcontrol()
4201 w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); in snd_soc_dapm_new_dai()
4222 int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_new_dai_widgets() argument
4228 WARN_ON(dapm->dev != dai->dev); in snd_soc_dapm_new_dai_widgets()
4241 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4257 w = snd_soc_dapm_new_control_unlocked(dapm, &template); in snd_soc_dapm_new_dai_widgets()
4295 if (w->dapm != dai_w->dapm) in snd_soc_dapm_link_dai_widgets()
4317 snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); in snd_soc_dapm_link_dai_widgets()
4324 static void dapm_connect_dai_routes(struct snd_soc_dapm_context *dapm, in dapm_connect_dai_routes() argument
4331 dev_dbg(dapm->dev, "connected DAI link %s:%s -> %s:%s\n", in dapm_connect_dai_routes()
4336 snd_soc_dapm_add_path(dapm, src, dai, NULL, NULL); in dapm_connect_dai_routes()
4340 snd_soc_dapm_add_path(dapm, src, sink, NULL, NULL); in dapm_connect_dai_routes()
4373 dapm_connect_dai_routes(&card->dapm, cpu_dai, playback_cpu, in dapm_connect_dai_pair()
4391 dapm_connect_dai_routes(&card->dapm, codec_dai, codec, in dapm_connect_dai_pair()
4477 * snd_soc_dapm_stream_event - send a stream event to the dapm core
4482 * Sends a stream event to the dapm core. The core then makes any
4522 * @dapm: DAPM context
4530 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4533 int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_enable_pin_unlocked() argument
4536 return snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin_unlocked()
4542 * @dapm: DAPM context
4548 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4551 int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) in snd_soc_dapm_enable_pin() argument
4555 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_enable_pin()
4557 ret = snd_soc_dapm_set_pin(dapm, pin, 1); in snd_soc_dapm_enable_pin()
4559 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_enable_pin()
4567 * @dapm: DAPM context
4576 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4579 int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_enable_pin_unlocked() argument
4582 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_force_enable_pin_unlocked()
4585 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4589 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin); in snd_soc_dapm_force_enable_pin_unlocked()
4608 * @dapm: DAPM context
4615 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4618 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_force_enable_pin() argument
4623 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_force_enable_pin()
4625 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin); in snd_soc_dapm_force_enable_pin()
4627 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_force_enable_pin()
4635 * @dapm: DAPM context
4642 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4645 int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_disable_pin_unlocked() argument
4648 return snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_disable_pin_unlocked()
4654 * @dapm: DAPM context
4659 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4662 int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_disable_pin() argument
4667 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_disable_pin()
4669 ret = snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_disable_pin()
4671 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_disable_pin()
4679 * @dapm: DAPM context
4690 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4693 int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_nc_pin_unlocked() argument
4696 return snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_nc_pin_unlocked()
4702 * @dapm: DAPM context
4711 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
4714 int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) in snd_soc_dapm_nc_pin() argument
4718 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); in snd_soc_dapm_nc_pin()
4720 ret = snd_soc_dapm_set_pin(dapm, pin, 0); in snd_soc_dapm_nc_pin()
4722 mutex_unlock(&dapm->card->dapm_mutex); in snd_soc_dapm_nc_pin()
4730 * @dapm: DAPM context
4737 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_get_pin_status() argument
4740 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); in snd_soc_dapm_get_pin_status()
4750 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
4751 * @dapm: DAPM context
4760 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_ignore_suspend() argument
4763 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); in snd_soc_dapm_ignore_suspend()
4766 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin); in snd_soc_dapm_ignore_suspend()
4777 * snd_soc_dapm_free - free dapm resources
4778 * @dapm: DAPM context
4780 * Free all dapm widgets and resources.
4782 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm) in snd_soc_dapm_free() argument
4784 dapm_debugfs_cleanup(dapm); in snd_soc_dapm_free()
4785 dapm_free_widgets(dapm); in snd_soc_dapm_free()
4786 list_del(&dapm->list); in snd_soc_dapm_free()
4790 void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm, in snd_soc_dapm_init() argument
4794 dapm->card = card; in snd_soc_dapm_init()
4795 dapm->component = component; in snd_soc_dapm_init()
4796 dapm->bias_level = SND_SOC_BIAS_OFF; in snd_soc_dapm_init()
4799 dapm->dev = component->dev; in snd_soc_dapm_init()
4800 dapm->idle_bias_off = !component->driver->idle_bias_on, in snd_soc_dapm_init()
4801 dapm->suspend_bias_off = component->driver->suspend_bias_off; in snd_soc_dapm_init()
4803 dapm->dev = card->dev; in snd_soc_dapm_init()
4806 INIT_LIST_HEAD(&dapm->list); in snd_soc_dapm_init()
4808 list_add(&dapm->list, &card->dapm_list); in snd_soc_dapm_init()
4812 static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) in soc_dapm_shutdown_dapm() argument
4814 struct snd_soc_card *card = dapm->card; in soc_dapm_shutdown_dapm()
4821 for_each_card_widgets(dapm->card, w) { in soc_dapm_shutdown_dapm()
4822 if (w->dapm != dapm) in soc_dapm_shutdown_dapm()
4835 if (dapm->bias_level == SND_SOC_BIAS_ON) in soc_dapm_shutdown_dapm()
4836 snd_soc_dapm_set_bias_level(dapm, in soc_dapm_shutdown_dapm()
4839 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) in soc_dapm_shutdown_dapm()
4840 snd_soc_dapm_set_bias_level(dapm, in soc_dapm_shutdown_dapm()
4852 struct snd_soc_dapm_context *dapm; in snd_soc_dapm_shutdown() local
4854 for_each_card_dapms(card, dapm) { in snd_soc_dapm_shutdown()
4855 if (dapm != &card->dapm) { in snd_soc_dapm_shutdown()
4856 soc_dapm_shutdown_dapm(dapm); in snd_soc_dapm_shutdown()
4857 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4858 snd_soc_dapm_set_bias_level(dapm, in snd_soc_dapm_shutdown()
4863 soc_dapm_shutdown_dapm(&card->dapm); in snd_soc_dapm_shutdown()
4864 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) in snd_soc_dapm_shutdown()
4865 snd_soc_dapm_set_bias_level(&card->dapm, in snd_soc_dapm_shutdown()