summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-10-25 17:41:56 +0200
committerMark Brown <broonie@kernel.org>2014-10-28 00:19:59 +0000
commit4a2019480bc5146eb54fc5f0b2ff57b95629a09a (patch)
treeb3fa7c9b9f0720a3e3c7b3d37132ae4e1091a68f /sound/soc/soc-dapm.c
parent130897ac5ac03adb4604d27497c378c64c7b22dd (diff)
downloadblackbird-op-linux-4a2019480bc5146eb54fc5f0b2ff57b95629a09a.tar.gz
blackbird-op-linux-4a2019480bc5146eb54fc5f0b2ff57b95629a09a.zip
ASoC: dapm: Only mark paths dirty when the connection status changed
Rework soc_dapm_{mixer,mux}_update_power() to only mark a path dirty if the connect state if the path has actually changed. This avoids unnecessary power state checks for the widgets involved. Also factor out the common code that is involved in this into a helper function. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f03e0cfc65be..116d4436c575 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1925,12 +1925,31 @@ static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm)
#endif
+/*
+ * soc_dapm_connect_path() - Connects or disconnects a path
+ * @path: The path to update
+ * @connect: The new connect state of the path. True if the path is connected,
+ * false if it is disconneted.
+ * @reason: The reason why the path changed (for debugging only)
+ */
+static void soc_dapm_connect_path(struct snd_soc_dapm_path *path,
+ bool connect, const char *reason)
+{
+ if (path->connect == connect)
+ return;
+
+ path->connect = connect;
+ dapm_mark_dirty(path->source, reason);
+ dapm_mark_dirty(path->sink, reason);
+}
+
/* test and update the power status of a mux widget */
static int soc_dapm_mux_update_power(struct snd_soc_card *card,
struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e)
{
struct snd_soc_dapm_path *path;
int found = 0;
+ bool connect;
lockdep_assert_held(&card->dapm_mutex);
@@ -1941,16 +1960,12 @@ static int soc_dapm_mux_update_power(struct snd_soc_card *card,
found = 1;
/* we now need to match the string in the enum to the path */
- if (!(strcmp(path->name, e->texts[mux]))) {
- path->connect = 1; /* new connection */
- dapm_mark_dirty(path->source, "mux connection");
- } else {
- if (path->connect)
- dapm_mark_dirty(path->source,
- "mux disconnection");
- path->connect = 0; /* old connection must be powered down */
- }
- dapm_mark_dirty(path->sink, "mux change");
+ if (!(strcmp(path->name, e->texts[mux])))
+ connect = true;
+ else
+ connect = false;
+
+ soc_dapm_connect_path(path, connect, "mux update");
}
if (found)
@@ -1989,9 +2004,7 @@ static int soc_dapm_mixer_update_power(struct snd_soc_card *card,
/* find dapm widget path assoc with kcontrol */
dapm_kcontrol_for_each_path(path, kcontrol) {
found = 1;
- path->connect = connect;
- dapm_mark_dirty(path->source, "mixer connection");
- dapm_mark_dirty(path->sink, "mixer update");
+ soc_dapm_connect_path(path, connect, "mixer update");
}
if (found)
OpenPOWER on IntegriCloud