summaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c882
1 files changed, 369 insertions, 513 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f26f9e9d7ce7..a37d44cd04c6 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -49,22 +49,6 @@
for ((dir) = SND_SOC_DAPM_DIR_IN; (dir) <= SND_SOC_DAPM_DIR_OUT; \
(dir)++)
-static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
- struct snd_soc_dapm_widget *wsource, struct snd_soc_dapm_widget *wsink,
- const char *control,
- int (*connected)(struct snd_soc_dapm_widget *source,
- struct snd_soc_dapm_widget *sink));
-
-struct snd_soc_dapm_widget *
-snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
- const struct snd_soc_dapm_widget *widget);
-
-struct snd_soc_dapm_widget *
-snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
- const struct snd_soc_dapm_widget *widget);
-
-static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg);
-
/* dapm power sequences - make this per codec in the future */
static int dapm_up_seq[] = {
[snd_soc_dapm_pre] = 1,
@@ -222,7 +206,7 @@ static __always_inline void dapm_widget_invalidate_paths(
list_for_each_entry(w, &list, work_list) {
snd_soc_dapm_widget_for_each_path(w, dir, p) {
- if (p->is_supply || p->weak || !p->connect)
+ if (p->is_supply || !p->connect)
continue;
node = p->node[rdir];
if (node->endpoints[dir] != -1) {
@@ -284,7 +268,7 @@ static void dapm_path_invalidate(struct snd_soc_dapm_path *p)
* Weak paths or supply paths do not influence the number of input or
* output paths of their neighbors.
*/
- if (p->weak || p->is_supply)
+ if (p->is_supply)
return;
/*
@@ -299,7 +283,7 @@ static void dapm_path_invalidate(struct snd_soc_dapm_path *p)
dapm_widget_invalidate_output_paths(p->source);
}
-void dapm_mark_endpoints_dirty(struct snd_soc_card *card)
+void snd_soc_dapm_mark_endpoints_dirty(struct snd_soc_card *card)
{
struct snd_soc_dapm_widget *w;
@@ -354,6 +338,320 @@ struct dapm_kcontrol_data {
struct snd_soc_dapm_widget_list *wlist;
};
+static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg)
+{
+ if (!dapm->component)
+ return -EIO;
+ return snd_soc_component_read(dapm->component, reg);
+}
+
+/* set up initial codec paths */
+static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i,
+ int nth_path)
+{
+ struct soc_mixer_control *mc = (struct soc_mixer_control *)
+ p->sink->kcontrol_news[i].private_value;
+ unsigned int reg = mc->reg;
+ unsigned int invert = mc->invert;
+
+ if (reg != SND_SOC_NOPM) {
+ unsigned int shift = mc->shift;
+ unsigned int max = mc->max;
+ unsigned int mask = (1 << fls(max)) - 1;
+ unsigned int val = soc_dapm_read(p->sink->dapm, reg);
+
+ /*
+ * The nth_path argument allows this function to know
+ * which path of a kcontrol it is setting the initial
+ * status for. Ideally this would support any number
+ * of paths and channels. But since kcontrols only come
+ * in mono and stereo variants, we are limited to 2
+ * channels.
+ *
+ * The following code assumes for stereo controls the
+ * first path is the left channel, and all remaining
+ * paths are the right channel.
+ */
+ if (snd_soc_volsw_is_stereo(mc) && nth_path > 0) {
+ if (reg != mc->rreg)
+ val = soc_dapm_read(p->sink->dapm, mc->rreg);
+ val = (val >> mc->rshift) & mask;
+ } else {
+ val = (val >> shift) & mask;
+ }
+ if (invert)
+ val = max - val;
+ p->connect = !!val;
+ } else {
+ /* since a virtual mixer has no backing registers to
+ * decide which path to connect, it will try to match
+ * with initial state. This is to ensure
+ * that the default mixer choice will be
+ * correctly powered up during initialization.
+ */
+ p->connect = invert;
+ }
+}
+
+/* connect mux widget to its interconnecting audio paths */
+static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
+ struct snd_soc_dapm_path *path, const char *control_name,
+ struct snd_soc_dapm_widget *w)
+{
+ const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0];
+ struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+ unsigned int item;
+ int i;
+
+ if (e->reg != SND_SOC_NOPM) {
+ unsigned int val;
+
+ val = soc_dapm_read(dapm, e->reg);
+ val = (val >> e->shift_l) & e->mask;
+ item = snd_soc_enum_val_to_item(e, val);
+ } else {
+ /* since a virtual mux has no backing registers to
+ * decide which path to connect, it will try to match
+ * with the first enumeration. This is to ensure
+ * that the default mux choice (the first) will be
+ * correctly powered up during initialization.
+ */
+ item = 0;
+ }
+
+ i = match_string(e->texts, e->items, control_name);
+ if (i < 0)
+ return -ENODEV;
+
+ path->name = e->texts[i];
+ path->connect = (i == item);
+ return 0;
+
+}
+
+/* connect mixer widget to its interconnecting audio paths */
+static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
+ struct snd_soc_dapm_path *path, const char *control_name)
+{
+ int i, nth_path = 0;
+
+ /* search for mixer kcontrol */
+ for (i = 0; i < path->sink->num_kcontrols; i++) {
+ if (!strcmp(control_name, path->sink->kcontrol_news[i].name)) {
+ path->name = path->sink->kcontrol_news[i].name;
+ dapm_set_mixer_path_status(path, i, nth_path++);
+ return 0;
+ }
+ }
+ return -ENODEV;
+}
+
+/*
+ * dapm_update_widget_flags() - Re-compute widget sink and source flags
+ * @w: The widget for which to update the flags
+ *
+ * Some widgets have a dynamic category which depends on which neighbors they
+ * are connected to. This function update the category for these widgets.
+ *
+ * This function must be called whenever a path is added or removed to a widget.
+ */
+static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w)
+{
+ enum snd_soc_dapm_direction dir;
+ struct snd_soc_dapm_path *p;
+ unsigned int ep;
+
+ switch (w->id) {
+ case snd_soc_dapm_input:
+ /* On a fully routed card an input is never a source */
+ if (w->dapm->card->fully_routed)
+ return;
+ ep = SND_SOC_DAPM_EP_SOURCE;
+ snd_soc_dapm_widget_for_each_source_path(w, p) {
+ if (p->source->id == snd_soc_dapm_micbias ||
+ p->source->id == snd_soc_dapm_mic ||
+ p->source->id == snd_soc_dapm_line ||
+ p->source->id == snd_soc_dapm_output) {
+ ep = 0;
+ break;
+ }
+ }
+ break;
+ case snd_soc_dapm_output:
+ /* On a fully routed card a output is never a sink */
+ if (w->dapm->card->fully_routed)
+ return;
+ ep = SND_SOC_DAPM_EP_SINK;
+ snd_soc_dapm_widget_for_each_sink_path(w, p) {
+ if (p->sink->id == snd_soc_dapm_spk ||
+ p->sink->id == snd_soc_dapm_hp ||
+ p->sink->id == snd_soc_dapm_line ||
+ p->sink->id == snd_soc_dapm_input) {
+ ep = 0;
+ break;
+ }
+ }
+ break;
+ case snd_soc_dapm_line:
+ ep = 0;
+ snd_soc_dapm_for_each_direction(dir) {
+ if (!list_empty(&w->edges[dir]))
+ ep |= SND_SOC_DAPM_DIR_TO_EP(dir);
+ }
+ break;
+ default:
+ return;
+ }
+
+ w->is_ep = ep;
+}
+
+static int snd_soc_dapm_check_dynamic_path(
+ struct snd_soc_dapm_context *dapm,
+ struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink,
+ const char *control)
+{
+ bool dynamic_source = false;
+ bool dynamic_sink = false;
+
+ if (!control)
+ return 0;
+
+ switch (source->id) {
+ case snd_soc_dapm_demux:
+ dynamic_source = true;
+ break;
+ default:
+ break;
+ }
+
+ switch (sink->id) {
+ case snd_soc_dapm_mux:
+ case snd_soc_dapm_switch:
+ case snd_soc_dapm_mixer:
+ case snd_soc_dapm_mixer_named_ctl:
+ dynamic_sink = true;
+ break;
+ default:
+ break;
+ }
+
+ if (dynamic_source && dynamic_sink) {
+ dev_err(dapm->dev,
+ "Direct connection between demux and mixer/mux not supported for path %s -> [%s] -> %s\n",
+ source->name, control, sink->name);
+ return -EINVAL;
+ } else if (!dynamic_source && !dynamic_sink) {
+ dev_err(dapm->dev,
+ "Control not supported for path %s -> [%s] -> %s\n",
+ source->name, control, sink->name);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int snd_soc_dapm_add_path(
+ struct snd_soc_dapm_context *dapm,
+ struct snd_soc_dapm_widget *wsource, struct snd_soc_dapm_widget *wsink,
+ const char *control,
+ int (*connected)(struct snd_soc_dapm_widget *source,
+ struct snd_soc_dapm_widget *sink))
+{
+ enum snd_soc_dapm_direction dir;
+ struct snd_soc_dapm_path *path;
+ int ret;
+
+ if (wsink->is_supply && !wsource->is_supply) {
+ dev_err(dapm->dev,
+ "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n",
+ wsource->name, wsink->name);
+ return -EINVAL;
+ }
+
+ if (connected && !wsource->is_supply) {
+ dev_err(dapm->dev,
+ "connected() callback only supported for supply widgets (%s -> %s)\n",
+ wsource->name, wsink->name);
+ return -EINVAL;
+ }
+
+ if (wsource->is_supply && control) {
+ dev_err(dapm->dev,
+ "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n",
+ wsource->name, control, wsink->name);
+ return -EINVAL;
+ }
+
+ ret = snd_soc_dapm_check_dynamic_path(dapm, wsource, wsink, control);
+ if (ret)
+ return ret;
+
+ path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
+ if (!path)
+ return -ENOMEM;
+
+ path->node[SND_SOC_DAPM_DIR_IN] = wsource;
+ path->node[SND_SOC_DAPM_DIR_OUT] = wsink;
+
+ path->connected = connected;
+ INIT_LIST_HEAD(&path->list);
+ INIT_LIST_HEAD(&path->list_kcontrol);
+
+ if (wsource->is_supply || wsink->is_supply)
+ path->is_supply = 1;
+
+ /* connect static paths */
+ if (control == NULL) {
+ path->connect = 1;
+ } else {
+ switch (wsource->id) {
+ case snd_soc_dapm_demux:
+ ret = dapm_connect_mux(dapm, path, control, wsource);
+ if (ret)
+ goto err;
+ break;
+ default:
+ break;
+ }
+
+ switch (wsink->id) {
+ case snd_soc_dapm_mux:
+ ret = dapm_connect_mux(dapm, path, control, wsink);
+ if (ret != 0)
+ goto err;
+ break;
+ case snd_soc_dapm_switch:
+ case snd_soc_dapm_mixer:
+ case snd_soc_dapm_mixer_named_ctl:
+ ret = dapm_connect_mixer(dapm, path, control);
+ if (ret != 0)
+ goto err;
+ break;
+ default:
+ break;
+ }
+ }
+
+ list_add(&path->list, &dapm->card->paths);
+
+ snd_soc_dapm_for_each_direction(dir)
+ list_add(&path->list_node[dir], &path->node[dir]->edges[dir]);
+
+ snd_soc_dapm_for_each_direction(dir) {
+ dapm_update_widget_flags(path->node[dir]);
+ dapm_mark_dirty(path->node[dir], "Route added");
+ }
+
+ if (snd_soc_card_is_instantiated(dapm->card) && path->connect)
+ dapm_path_invalidate(path);
+
+ return 0;
+err:
+ kfree(path);
+ return ret;
+}
+
static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
struct snd_kcontrol *kcontrol, const char *ctrl_name)
{
@@ -626,13 +924,6 @@ static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm)
return dapm->component->name_prefix;
}
-static unsigned int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg)
-{
- if (!dapm->component)
- return -EIO;
- return snd_soc_component_read(dapm->component, reg);
-}
-
static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm,
int reg, unsigned int mask, unsigned int value)
{
@@ -739,107 +1030,11 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
out:
trace_snd_soc_bias_level_done(dapm, level);
- return ret;
-}
-
-/* connect mux widget to its interconnecting audio paths */
-static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
- struct snd_soc_dapm_path *path, const char *control_name,
- struct snd_soc_dapm_widget *w)
-{
- const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0];
- struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
- unsigned int item;
- int i;
-
- if (e->reg != SND_SOC_NOPM) {
- unsigned int val;
- val = soc_dapm_read(dapm, e->reg);
- val = (val >> e->shift_l) & e->mask;
- item = snd_soc_enum_val_to_item(e, val);
- } else {
- /* since a virtual mux has no backing registers to
- * decide which path to connect, it will try to match
- * with the first enumeration. This is to ensure
- * that the default mux choice (the first) will be
- * correctly powered up during initialization.
- */
- item = 0;
- }
-
- i = match_string(e->texts, e->items, control_name);
- if (i < 0)
- return -ENODEV;
-
- path->name = e->texts[i];
- path->connect = (i == item);
- return 0;
-
-}
-
-/* set up initial codec paths */
-static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i,
- int nth_path)
-{
- struct soc_mixer_control *mc = (struct soc_mixer_control *)
- p->sink->kcontrol_news[i].private_value;
- unsigned int reg = mc->reg;
- unsigned int invert = mc->invert;
-
- if (reg != SND_SOC_NOPM) {
- unsigned int shift = mc->shift;
- unsigned int max = mc->max;
- unsigned int mask = (1 << fls(max)) - 1;
- unsigned int val = soc_dapm_read(p->sink->dapm, reg);
-
- /*
- * The nth_path argument allows this function to know
- * which path of a kcontrol it is setting the initial
- * status for. Ideally this would support any number
- * of paths and channels. But since kcontrols only come
- * in mono and stereo variants, we are limited to 2
- * channels.
- *
- * The following code assumes for stereo controls the
- * first path is the left channel, and all remaining
- * paths are the right channel.
- */
- if (snd_soc_volsw_is_stereo(mc) && nth_path > 0) {
- if (reg != mc->rreg)
- val = soc_dapm_read(p->sink->dapm, mc->rreg);
- val = (val >> mc->rshift) & mask;
- } else {
- val = (val >> shift) & mask;
- }
- if (invert)
- val = max - val;
- p->connect = !!val;
- } else {
- /* since a virtual mixer has no backing registers to
- * decide which path to connect, it will try to match
- * with initial state. This is to ensure
- * that the default mixer choice will be
- * correctly powered up during initialization.
- */
- p->connect = invert;
- }
-}
-
-/* connect mixer widget to its interconnecting audio paths */
-static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
- struct snd_soc_dapm_path *path, const char *control_name)
-{
- int i, nth_path = 0;
+ /* success */
+ if (ret == 0)
+ snd_soc_dapm_init_bias_level(dapm, level);
- /* search for mixer kcontrol */
- for (i = 0; i < path->sink->num_kcontrols; i++) {
- if (!strcmp(control_name, path->sink->kcontrol_news[i].name)) {
- path->name = path->sink->kcontrol_news[i].name;
- dapm_set_mixer_path_status(path, i, nth_path++);
- return 0;
- }
- }
- return -ENODEV;
+ return ret;
}
static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm,
@@ -1170,7 +1365,7 @@ static void invalidate_paths_ep(struct snd_soc_dapm_widget *widget,
widget->endpoints[dir] = -1;
snd_soc_dapm_widget_for_each_path(widget, rdir, path) {
- if (path->weak || path->is_supply)
+ if (path->is_supply)
continue;
if (path->walking)
@@ -1225,7 +1420,7 @@ static __always_inline int is_connected_ep(struct snd_soc_dapm_widget *widget,
snd_soc_dapm_widget_for_each_path(widget, rdir, path) {
DAPM_UPDATE_STAT(widget, neighbour_checks);
- if (path->weak || path->is_supply)
+ if (path->is_supply)
continue;
if (path->walking)
@@ -1346,8 +1541,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_dai_free_widgets);
/*
* Handler for regulator supply widget.
*/
-int dapm_regulator_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
+int snd_soc_dapm_regulator_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
{
int ret;
@@ -1375,13 +1570,13 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
return regulator_disable_deferred(w->regulator, w->shift);
}
}
-EXPORT_SYMBOL_GPL(dapm_regulator_event);
+EXPORT_SYMBOL_GPL(snd_soc_dapm_regulator_event);
/*
* Handler for pinctrl widget.
*/
-int dapm_pinctrl_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
+int snd_soc_dapm_pinctrl_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_dapm_pinctrl_priv *priv = w->priv;
struct pinctrl *p = w->pinctrl;
@@ -1400,13 +1595,13 @@ int dapm_pinctrl_event(struct snd_soc_dapm_widget *w,
return pinctrl_select_state(p, s);
}
-EXPORT_SYMBOL_GPL(dapm_pinctrl_event);
+EXPORT_SYMBOL_GPL(snd_soc_dapm_pinctrl_event);
/*
* Handler for clock supply widget.
*/
-int dapm_clock_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
+int snd_soc_dapm_clock_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
{
if (!w->clk)
return -EIO;
@@ -1422,7 +1617,7 @@ int dapm_clock_event(struct snd_soc_dapm_widget *w,
return 0;
}
-EXPORT_SYMBOL_GPL(dapm_clock_event);
+EXPORT_SYMBOL_GPL(snd_soc_dapm_clock_event);
static int dapm_widget_power_check(struct snd_soc_dapm_widget *w)
{
@@ -1462,9 +1657,6 @@ static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
snd_soc_dapm_widget_for_each_sink_path(w, path) {
DAPM_UPDATE_STAT(w, neighbour_checks);
- if (path->weak)
- continue;
-
if (path->connected &&
!path->connected(path->source, path->sink))
continue;
@@ -1797,29 +1989,29 @@ static void dapm_widget_update(struct snd_soc_card *card, struct snd_soc_dapm_up
*/
static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
{
- struct snd_soc_dapm_context *d = data;
+ struct snd_soc_dapm_context *dapm = data;
int ret;
/* If we're off and we're not supposed to go into STANDBY */
- if (d->bias_level == SND_SOC_BIAS_OFF &&
- d->target_bias_level != SND_SOC_BIAS_OFF) {
- if (d->dev && cookie)
- pm_runtime_get_sync(d->dev);
+ if (dapm->bias_level == SND_SOC_BIAS_OFF &&
+ dapm->target_bias_level != SND_SOC_BIAS_OFF) {
+ if (dapm->dev && cookie)
+ pm_runtime_get_sync(dapm->dev);
- ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
+ ret = snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_STANDBY);
if (ret != 0)
- dev_err(d->dev,
+ dev_err(dapm->dev,
"ASoC: Failed to turn on bias: %d\n", ret);
}
/* Prepare for a transition to ON or away from ON */
- if ((d->target_bias_level == SND_SOC_BIAS_ON &&
- d->bias_level != SND_SOC_BIAS_ON) ||
- (d->target_bias_level != SND_SOC_BIAS_ON &&
- d->bias_level == SND_SOC_BIAS_ON)) {
- ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE);
+ if ((dapm->target_bias_level == SND_SOC_BIAS_ON &&
+ dapm->bias_level != SND_SOC_BIAS_ON) ||
+ (dapm->target_bias_level != SND_SOC_BIAS_ON &&
+ dapm->bias_level == SND_SOC_BIAS_ON)) {
+ ret = snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_PREPARE);
if (ret != 0)
- dev_err(d->dev,
+ dev_err(dapm->dev,
"ASoC: Failed to prepare bias: %d\n", ret);
}
}
@@ -1829,37 +2021,37 @@ static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
*/
static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
{
- struct snd_soc_dapm_context *d = data;
+ struct snd_soc_dapm_context *dapm = data;
int ret;
/* If we just powered the last thing off drop to standby bias */
- if (d->bias_level == SND_SOC_BIAS_PREPARE &&
- (d->target_bias_level == SND_SOC_BIAS_STANDBY ||
- d->target_bias_level == SND_SOC_BIAS_OFF)) {
- ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
+ if (dapm->bias_level == SND_SOC_BIAS_PREPARE &&
+ (dapm->target_bias_level == SND_SOC_BIAS_STANDBY ||
+ dapm->target_bias_level == SND_SOC_BIAS_OFF)) {
+ ret = snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_STANDBY);
if (ret != 0)
- dev_err(d->dev, "ASoC: Failed to apply standby bias: %d\n",
+ dev_err(dapm->dev, "ASoC: Failed to apply standby bias: %d\n",
ret);
}
/* If we're in standby and can support bias off then do that */
- if (d->bias_level == SND_SOC_BIAS_STANDBY &&
- d->target_bias_level == SND_SOC_BIAS_OFF) {
- ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_OFF);
+ if (dapm->bias_level == SND_SOC_BIAS_STANDBY &&
+ dapm->target_bias_level == SND_SOC_BIAS_OFF) {
+ ret = snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_OFF);
if (ret != 0)
- dev_err(d->dev, "ASoC: Failed to turn off bias: %d\n",
+ dev_err(dapm->dev, "ASoC: Failed to turn off bias: %d\n",
ret);
- if (d->dev && cookie)
- pm_runtime_put(d->dev);
+ if (dapm->dev && cookie)
+ pm_runtime_put(dapm->dev);
}
/* If we just powered up then move to active bias */
- if (d->bias_level == SND_SOC_BIAS_PREPARE &&
- d->target_bias_level == SND_SOC_BIAS_ON) {
- ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_ON);
+ if (dapm->bias_level == SND_SOC_BIAS_PREPARE &&
+ dapm->target_bias_level == SND_SOC_BIAS_ON) {
+ ret = snd_soc_dapm_set_bias_level(dapm, SND_SOC_BIAS_ON);
if (ret != 0)
- dev_err(d->dev, "ASoC: Failed to apply active bias: %d\n",
+ dev_err(dapm->dev, "ASoC: Failed to apply active bias: %d\n",
ret);
}
}
@@ -2440,10 +2632,10 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power);
-static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
+static ssize_t dapm_widget_show_component(struct snd_soc_component *component,
char *buf, int count)
{
- struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
+ struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct snd_soc_dapm_widget *w;
char *state = "not set";
@@ -2451,10 +2643,10 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
* we're checking for that case specifically here but in future
* we will ensure that the dummy component looks like others.
*/
- if (!cmpnt->card)
+ if (!component->card)
return 0;
- for_each_card_widgets(cmpnt->card, w) {
+ for_each_card_widgets(component->card, w) {
if (w->dapm != dapm)
continue;
@@ -2515,9 +2707,9 @@ static ssize_t dapm_widget_show(struct device *dev,
snd_soc_dapm_mutex_lock_root(rtd->card);
for_each_rtd_codec_dais(rtd, i, codec_dai) {
- struct snd_soc_component *cmpnt = codec_dai->component;
+ struct snd_soc_component *component = codec_dai->component;
- count = dapm_widget_show_component(cmpnt, buf, count);
+ count = dapm_widget_show_component(component, buf, count);
}
snd_soc_dapm_mutex_unlock(rtd->card);
@@ -2527,7 +2719,7 @@ static ssize_t dapm_widget_show(struct device *dev,
static DEVICE_ATTR_RO(dapm_widget);
-struct attribute *soc_dapm_dev_attrs[] = {
+struct attribute *snd_soc_dapm_dev_attrs[] = {
&dev_attr_dapm_widget.attr,
NULL
};
@@ -2794,210 +2986,6 @@ int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_widget_name_cmp);
-/*
- * dapm_update_widget_flags() - Re-compute widget sink and source flags
- * @w: The widget for which to update the flags
- *
- * Some widgets have a dynamic category which depends on which neighbors they
- * are connected to. This function update the category for these widgets.
- *
- * This function must be called whenever a path is added or removed to a widget.
- */
-static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w)
-{
- enum snd_soc_dapm_direction dir;
- struct snd_soc_dapm_path *p;
- unsigned int ep;
-
- switch (w->id) {
- case snd_soc_dapm_input:
- /* On a fully routed card an input is never a source */
- if (w->dapm->card->fully_routed)
- return;
- ep = SND_SOC_DAPM_EP_SOURCE;
- snd_soc_dapm_widget_for_each_source_path(w, p) {
- if (p->source->id == snd_soc_dapm_micbias ||
- p->source->id == snd_soc_dapm_mic ||
- p->source->id == snd_soc_dapm_line ||
- p->source->id == snd_soc_dapm_output) {
- ep = 0;
- break;
- }
- }
- break;
- case snd_soc_dapm_output:
- /* On a fully routed card a output is never a sink */
- if (w->dapm->card->fully_routed)
- return;
- ep = SND_SOC_DAPM_EP_SINK;
- snd_soc_dapm_widget_for_each_sink_path(w, p) {
- if (p->sink->id == snd_soc_dapm_spk ||
- p->sink->id == snd_soc_dapm_hp ||
- p->sink->id == snd_soc_dapm_line ||
- p->sink->id == snd_soc_dapm_input) {
- ep = 0;
- break;
- }
- }
- break;
- case snd_soc_dapm_line:
- ep = 0;
- snd_soc_dapm_for_each_direction(dir) {
- if (!list_empty(&w->edges[dir]))
- ep |= SND_SOC_DAPM_DIR_TO_EP(dir);
- }
- break;
- default:
- return;
- }
-
- w->is_ep = ep;
-}
-
-static int snd_soc_dapm_check_dynamic_path(struct snd_soc_dapm_context *dapm,
- struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink,
- const char *control)
-{
- bool dynamic_source = false;
- bool dynamic_sink = false;
-
- if (!control)
- return 0;
-
- switch (source->id) {
- case snd_soc_dapm_demux:
- dynamic_source = true;
- break;
- default:
- break;
- }
-
- switch (sink->id) {
- case snd_soc_dapm_mux:
- case snd_soc_dapm_switch:
- case snd_soc_dapm_mixer:
- case snd_soc_dapm_mixer_named_ctl:
- dynamic_sink = true;
- break;
- default:
- break;
- }
-
- if (dynamic_source && dynamic_sink) {
- dev_err(dapm->dev,
- "Direct connection between demux and mixer/mux not supported for path %s -> [%s] -> %s\n",
- source->name, control, sink->name);
- return -EINVAL;
- } else if (!dynamic_source && !dynamic_sink) {
- dev_err(dapm->dev,
- "Control not supported for path %s -> [%s] -> %s\n",
- source->name, control, sink->name);
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
- struct snd_soc_dapm_widget *wsource, struct snd_soc_dapm_widget *wsink,
- const char *control,
- int (*connected)(struct snd_soc_dapm_widget *source,
- struct snd_soc_dapm_widget *sink))
-{
- enum snd_soc_dapm_direction dir;
- struct snd_soc_dapm_path *path;
- int ret;
-
- if (wsink->is_supply && !wsource->is_supply) {
- dev_err(dapm->dev,
- "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n",
- wsource->name, wsink->name);
- return -EINVAL;
- }
-
- if (connected && !wsource->is_supply) {
- dev_err(dapm->dev,
- "connected() callback only supported for supply widgets (%s -> %s)\n",
- wsource->name, wsink->name);
- return -EINVAL;
- }
-
- if (wsource->is_supply && control) {
- dev_err(dapm->dev,
- "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n",
- wsource->name, control, wsink->name);
- return -EINVAL;
- }
-
- ret = snd_soc_dapm_check_dynamic_path(dapm, wsource, wsink, control);
- if (ret)
- return ret;
-
- path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
- if (!path)
- return -ENOMEM;
-
- path->node[SND_SOC_DAPM_DIR_IN] = wsource;
- path->node[SND_SOC_DAPM_DIR_OUT] = wsink;
-
- path->connected = connected;
- INIT_LIST_HEAD(&path->list);
- INIT_LIST_HEAD(&path->list_kcontrol);
-
- if (wsource->is_supply || wsink->is_supply)
- path->is_supply = 1;
-
- /* connect static paths */
- if (control == NULL) {
- path->connect = 1;
- } else {
- switch (wsource->id) {
- case snd_soc_dapm_demux:
- ret = dapm_connect_mux(dapm, path, control, wsource);
- if (ret)
- goto err;
- break;
- default:
- break;
- }
-
- switch (wsink->id) {
- case snd_soc_dapm_mux:
- ret = dapm_connect_mux(dapm, path, control, wsink);
- if (ret != 0)
- goto err;
- break;
- case snd_soc_dapm_switch:
- case snd_soc_dapm_mixer:
- case snd_soc_dapm_mixer_named_ctl:
- ret = dapm_connect_mixer(dapm, path, control);
- if (ret != 0)
- goto err;
- break;
- default:
- break;
- }
- }
-
- list_add(&path->list, &dapm->card->paths);
-
- snd_soc_dapm_for_each_direction(dir)
- list_add(&path->list_node[dir], &path->node[dir]->edges[dir]);
-
- snd_soc_dapm_for_each_direction(dir) {
- dapm_update_widget_flags(path->node[dir]);
- dapm_mark_dirty(path->node[dir], "Route added");
- }
-
- if (snd_soc_card_is_instantiated(dapm->card) && path->connect)
- dapm_path_invalidate(path);
-
- return 0;
-err:
- kfree(path);
- return ret;
-}
-
static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_route *route)
{
@@ -3210,86 +3198,6 @@ int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_del_routes);
-static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm,
- const struct snd_soc_dapm_route *route)
-{
- struct snd_soc_dapm_widget *source = dapm_find_widget(dapm,
- route->source,
- true);
- struct snd_soc_dapm_widget *sink = dapm_find_widget(dapm,
- route->sink,
- true);
- struct snd_soc_dapm_path *path;
- int count = 0;
-
- if (!source) {
- dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n",
- route->source);
- return -ENODEV;
- }
-
- if (!sink) {
- dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n",
- route->sink);
- return -ENODEV;
- }
-
- if (route->control || route->connected)
- dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n",
- route->source, route->sink);
-
- snd_soc_dapm_widget_for_each_sink_path(source, path) {
- if (path->sink == sink) {
- path->weak = 1;
- count++;
- }
- }
-
- if (count == 0)
- dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n",
- route->source, route->sink);
- if (count > 1)
- dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n",
- count, route->source, route->sink);
-
- return 0;
-}
-
-/**
- * snd_soc_dapm_weak_routes - Mark routes between DAPM widgets as weak
- * @dapm: DAPM context
- * @route: audio routes
- * @num: number of routes
- *
- * Mark existing routes matching those specified in the passed array
- * as being weak, meaning that they are ignored for the purpose of
- * power decisions. The main intended use case is for sidetone paths
- * which couple audio between other independent paths if they are both
- * active in order to make the combination work better at the user
- * level but which aren't intended to be "used".
- *
- * Note that CODEC drivers should not use this as sidetone type paths
- * can frequently also be used as bypass paths.
- */
-int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
- const struct snd_soc_dapm_route *route, int num)
-{
- int i;
- int ret = 0;
-
- snd_soc_dapm_mutex_lock_root(dapm);
- for (i = 0; i < num; i++) {
- int err = snd_soc_dapm_weak_route(dapm, route);
- if (err)
- ret = err;
- route++;
- }
- snd_soc_dapm_mutex_unlock(dapm);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_weak_routes);
-
/**
* snd_soc_dapm_new_widgets - add new dapm widgets
* @card: card to be checked for new dapm widgets
@@ -3764,7 +3672,7 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
}
/* set to sleep_state when initializing */
- dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD);
+ snd_soc_dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD);
break;
case snd_soc_dapm_clock_supply:
w->clk = devm_clk_get(dapm->dev, widget->name);
@@ -4781,57 +4689,6 @@ int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
/**
- * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
- * @dapm: DAPM context
- * @pin: pin name
- *
- * Marks the specified pin as being not connected, disabling it along
- * any parent or child widgets. At present this is identical to
- * snd_soc_dapm_disable_pin() but in future it will be extended to do
- * additional things such as disabling controls which only affect
- * paths through the pin.
- *
- * Requires external locking.
- *
- * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
- * do any widget power switching.
- */
-int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
- const char *pin)
-{
- return snd_soc_dapm_set_pin(dapm, pin, 0);
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin_unlocked);
-
-/**
- * snd_soc_dapm_nc_pin - permanently disable pin.
- * @dapm: DAPM context
- * @pin: pin name
- *
- * Marks the specified pin as being not connected, disabling it along
- * any parent or child widgets. At present this is identical to
- * snd_soc_dapm_disable_pin() but in future it will be extended to do
- * additional things such as disabling controls which only affect
- * paths through the pin.
- *
- * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
- * do any widget power switching.
- */
-int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
-{
- int ret;
-
- snd_soc_dapm_mutex_lock(dapm);
-
- ret = snd_soc_dapm_set_pin(dapm, pin, 0);
-
- snd_soc_dapm_mutex_unlock(dapm);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
-
-/**
* snd_soc_dapm_get_pin_status - get audio pin status
* @dapm: DAPM context
* @pin: audio signal pin endpoint (or start point)
@@ -4891,7 +4748,6 @@ void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
dapm_free_widgets(dapm);
list_del(&dapm->list);
}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm,
struct snd_soc_card *card,