ASoC: dapm: Add widget path iterators

Add helper iterator macros for iterating over the source and sink paths of
widget. This will make it easier to change the implementation later on.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Lars-Peter Clausen 2015-07-26 19:05:00 +02:00 committed by Mark Brown
parent 1ce43acff0
commit e63bfd45ab
3 changed files with 35 additions and 17 deletions

View File

@ -673,4 +673,22 @@ static inline enum snd_soc_bias_level snd_soc_dapm_get_bias_level(
return dapm->bias_level; return dapm->bias_level;
} }
/**
* snd_soc_dapm_widget_for_each_sink_path - Iterates over all paths leaving a
* widget
* @w: The widget
* @p: The path iterator variable
*/
#define snd_soc_dapm_widget_for_each_sink_path(w, p) \
list_for_each_entry(p, &w->sinks, list_source)
/**
* snd_soc_dapm_widget_for_each_source_path - Iterates over all paths leading to
* a widget
* @w: The widget
* @p: The path iterator variable
*/
#define snd_soc_dapm_widget_for_each_source_path(w, p) \
list_for_each_entry(p, &w->sources, list_sink)
#endif #endif

View File

@ -1298,7 +1298,7 @@ int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute)
dev_dbg(dai->dev, "Stream name=%s\n", dev_dbg(dai->dev, "Stream name=%s\n",
dai->playback_widget->name); dai->playback_widget->name);
w = dai->playback_widget; w = dai->playback_widget;
list_for_each_entry(p, &w->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(w, p) {
if (p->connected && !p->connected(w, p->sink)) if (p->connected && !p->connected(w, p->sink))
continue; continue;
@ -1317,7 +1317,7 @@ int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute)
dev_dbg(dai->dev, "Stream name=%s\n", dev_dbg(dai->dev, "Stream name=%s\n",
dai->capture_widget->name); dai->capture_widget->name);
w = dai->capture_widget; w = dai->capture_widget;
list_for_each_entry(p, &w->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(w, p) {
if (p->connected && !p->connected(w, p->sink)) if (p->connected && !p->connected(w, p->sink))
continue; continue;

View File

@ -193,7 +193,7 @@ static void dapm_widget_invalidate_input_paths(struct snd_soc_dapm_widget *w)
list_add_tail(&w->work_list, &list); list_add_tail(&w->work_list, &list);
list_for_each_entry(w, &list, work_list) { list_for_each_entry(w, &list, work_list) {
list_for_each_entry(p, &w->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(w, p) {
if (p->is_supply || p->weak || !p->connect) if (p->is_supply || p->weak || !p->connect)
continue; continue;
sink = p->sink; sink = p->sink;
@ -232,7 +232,7 @@ static void dapm_widget_invalidate_output_paths(struct snd_soc_dapm_widget *w)
list_add_tail(&w->work_list, &list); list_add_tail(&w->work_list, &list);
list_for_each_entry(w, &list, work_list) { list_for_each_entry(w, &list, work_list) {
list_for_each_entry(p, &w->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(w, p) {
if (p->is_supply || p->weak || !p->connect) if (p->is_supply || p->weak || !p->connect)
continue; continue;
source = p->source; source = p->source;
@ -894,7 +894,7 @@ static int dapm_new_mixer(struct snd_soc_dapm_widget *w)
/* add kcontrol */ /* add kcontrol */
for (i = 0; i < w->num_kcontrols; i++) { for (i = 0; i < w->num_kcontrols; i++) {
/* match name */ /* match name */
list_for_each_entry(path, &w->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(w, path) {
/* mixer/mux paths name must match control name */ /* mixer/mux paths name must match control name */
if (path->name != (char *)w->kcontrol_news[i].name) if (path->name != (char *)w->kcontrol_news[i].name)
continue; continue;
@ -958,12 +958,12 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
return ret; return ret;
if (w->id == snd_soc_dapm_mux) { if (w->id == snd_soc_dapm_mux) {
list_for_each_entry(path, &w->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(w, path) {
if (path->name) if (path->name)
dapm_kcontrol_add_path(w->kcontrols[0], path); dapm_kcontrol_add_path(w->kcontrols[0], path);
} }
} else { } else {
list_for_each_entry(path, &w->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(w, path) {
if (path->name) if (path->name)
dapm_kcontrol_add_path(w->kcontrols[0], path); dapm_kcontrol_add_path(w->kcontrols[0], path);
} }
@ -1079,7 +1079,7 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
return widget->outputs; return widget->outputs;
} }
list_for_each_entry(path, &widget->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(widget, path) {
DAPM_UPDATE_STAT(widget, neighbour_checks); DAPM_UPDATE_STAT(widget, neighbour_checks);
if (path->weak || path->is_supply) if (path->weak || path->is_supply)
@ -1126,7 +1126,7 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
return widget->inputs; return widget->inputs;
} }
list_for_each_entry(path, &widget->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(widget, path) {
DAPM_UPDATE_STAT(widget, neighbour_checks); DAPM_UPDATE_STAT(widget, neighbour_checks);
if (path->weak || path->is_supply) if (path->weak || path->is_supply)
@ -1292,7 +1292,7 @@ static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
DAPM_UPDATE_STAT(w, power_checks); DAPM_UPDATE_STAT(w, power_checks);
/* Check if one of our outputs is connected */ /* Check if one of our outputs is connected */
list_for_each_entry(path, &w->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(w, path) {
DAPM_UPDATE_STAT(w, neighbour_checks); DAPM_UPDATE_STAT(w, neighbour_checks);
if (path->weak) if (path->weak)
@ -1716,12 +1716,12 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power,
/* If we changed our power state perhaps our neigbours changed /* If we changed our power state perhaps our neigbours changed
* also. * also.
*/ */
list_for_each_entry(path, &w->sources, list_sink) snd_soc_dapm_widget_for_each_source_path(w, path)
dapm_widget_set_peer_power(path->source, power, path->connect); dapm_widget_set_peer_power(path->source, power, path->connect);
/* Supplies can't affect their outputs, only their inputs */ /* Supplies can't affect their outputs, only their inputs */
if (!w->is_supply) { if (!w->is_supply) {
list_for_each_entry(path, &w->sinks, list_source) snd_soc_dapm_widget_for_each_sink_path(w, path)
dapm_widget_set_peer_power(path->sink, power, dapm_widget_set_peer_power(path->sink, power,
path->connect); path->connect);
} }
@ -1958,7 +1958,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
w->sname, w->sname,
w->active ? "active" : "inactive"); w->active ? "active" : "inactive");
list_for_each_entry(p, &w->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(w, p) {
if (p->connected && !p->connected(w, p->source)) if (p->connected && !p->connected(w, p->source))
continue; continue;
@ -1968,7 +1968,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
p->name ? p->name : "static", p->name ? p->name : "static",
p->source->name); p->source->name);
} }
list_for_each_entry(p, &w->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(w, p) {
if (p->connected && !p->connected(w, p->sink)) if (p->connected && !p->connected(w, p->sink))
continue; continue;
@ -2426,7 +2426,7 @@ static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w)
if (w->dapm->card->fully_routed) if (w->dapm->card->fully_routed)
break; break;
w->is_source = 1; w->is_source = 1;
list_for_each_entry(p, &w->sources, list_sink) { snd_soc_dapm_widget_for_each_source_path(w, p) {
if (p->source->id == snd_soc_dapm_micbias || if (p->source->id == snd_soc_dapm_micbias ||
p->source->id == snd_soc_dapm_mic || p->source->id == snd_soc_dapm_mic ||
p->source->id == snd_soc_dapm_line || p->source->id == snd_soc_dapm_line ||
@ -2441,7 +2441,7 @@ static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w)
if (w->dapm->card->fully_routed) if (w->dapm->card->fully_routed)
break; break;
w->is_sink = 1; w->is_sink = 1;
list_for_each_entry(p, &w->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(w, p) {
if (p->sink->id == snd_soc_dapm_spk || if (p->sink->id == snd_soc_dapm_spk ||
p->sink->id == snd_soc_dapm_hp || p->sink->id == snd_soc_dapm_hp ||
p->sink->id == snd_soc_dapm_line || p->sink->id == snd_soc_dapm_line ||
@ -2841,7 +2841,7 @@ static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm,
dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n", dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n",
route->source, route->sink); route->source, route->sink);
list_for_each_entry(path, &source->sinks, list_source) { snd_soc_dapm_widget_for_each_sink_path(source, path) {
if (path->sink == sink) { if (path->sink == sink) {
path->weak = 1; path->weak = 1;
count++; count++;