Skip to contentSkip to conversation

ASoC: Extend DAPM to handle cross-device paths

PATCH Applied Jarkko Nikula 3 participants 6 messages Dec 14, 2010 – Dec 15, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Extend DAPM to handle cross-device paths

Hi

Just updated set, i.e. no code changes other than updated to current tree and some comment clarifications.

Last time there were discussion about special n_widgets casing for non-DAPM codecs. Mark suggested to drop them but they are still here as I don't want to break boards having non-DAPM codec with bias control and that casing is trivial to drop when not needed anymore.

Signature · 1 line
Jarkko
#1 lore raw

PATCH 1/3 ASoC: Move DAPM paths from DAPM context to snd_soc_card

Decoupling DAPM paths from DAPM context is a first prerequisite when extending ASoC core to cross-device paths. This patch is almost a nullop and does not allow to construct cross-device setup but the path clean-up part in dapm_free_widgets is prepared to remove cross-device paths between a device being removed and others.

---
 include/sound/soc-dapm.h       |    1 -
 include/sound/soc.h            |    2 +
 sound/soc/codecs/tlv320aic3x.c |    2 +-
 sound/soc/soc-core.c           |    2 +-
 sound/soc/soc-dapm.c           |   41 ++++++++++++++++++++++++++-------------
 5 files changed, 31 insertions(+), 17 deletions(-)
include/sound/soc-dapm.h +0 -1
index 041e98b..9d1ff07 100644
@@ -469,7 +469,6 @@ struct snd_soc_dapm_widget {
 /* DAPM context */
 struct snd_soc_dapm_context {
 	struct list_head widgets;
-	struct list_head paths;
 	enum snd_soc_bias_level bias_level;
 	enum snd_soc_bias_level suspend_bias_level;
 	struct delayed_work delayed_work;
include/sound/soc.h +2 -0
index 7e65b01..466895b 100644
@@ -661,6 +661,8 @@ struct snd_soc_card {
 	struct list_head platform_dev_list;
 	struct list_head dai_dev_list;
 
+	struct list_head paths;
+
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs_card_root;
 	struct dentry *debugfs_pop_time;
sound/soc/codecs/tlv320aic3x.c +1 -1
index fc5abdf..899af41 100644
@@ -185,7 +185,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
 
 	if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) {
 		/* find dapm widget path assoc with kcontrol */
-		list_for_each_entry(path, &widget->dapm->paths, list) {
+		list_for_each_entry(path, &widget->dapm->card->paths, list) {
 			if (path->kcontrol != kcontrol)
 				continue;
 
sound/soc/soc-core.c +1 -1
index 1dc4b11..bdb2ca9 100644
@@ -1879,6 +1879,7 @@ static int soc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&card->dai_dev_list);
 	INIT_LIST_HEAD(&card->codec_dev_list);
 	INIT_LIST_HEAD(&card->platform_dev_list);
+	INIT_LIST_HEAD(&card->paths);
 
 	soc_init_card_debugfs(card);
 
@@ -3481,7 +3482,6 @@ int snd_soc_register_codec(struct device *dev,
 		codec->compress_type = SND_SOC_FLAT_COMPRESSION;
 
 	INIT_LIST_HEAD(&codec->dapm.widgets);
-	INIT_LIST_HEAD(&codec->dapm.paths);
 	codec->write = codec_drv->write;
 	codec->read = codec_drv->read;
 	codec->dapm.bias_level = SND_SOC_BIAS_OFF;
sound/soc/soc-dapm.c +27 -14

98 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 2/3 ASoC: Move widgets from DAPM context to snd_soc_card

In reply to Jarkko Nikula

Decoupling widgets from DAPM context is required when extending the ASoC core to cross-device paths. Even the list of widgets are now kept in struct snd_soc_card, the widget listing in sysfs and debugs remain sorted per device.

This patch makes possible to build cross-device paths but does not extend yet the DAPM to handle codec bias and widget power changes of an another device.

Cross-device paths are registered by listing the widgets from device A in a map for device B. In case of conflicting widget names between the devices, a uniform name prefix is needed to separate them. See commit ead9b91 "ASoC: Add optional name_prefix for kcontrol, widget and route names" for help.

An example below shows a path that connects MONO out of A into Line In of B:

static const struct snd_soc_dapm_route mapA[] = {
	{"MONO", NULL, "DAC"},
};
static const struct snd_soc_dapm_route mapB[] = {
	{"Line In", NULL, "MONO"},
};
---
 include/sound/soc-dapm.h  |    2 +-
 include/sound/soc.h       |    1 +
 sound/soc/codecs/wm8960.c |    4 ++-
 sound/soc/soc-core.c      |    2 +-
 sound/soc/soc-dapm.c      |   69 ++++++++++++++++++++++++++++++++-------------
 5 files changed, 55 insertions(+), 23 deletions(-)
include/sound/soc-dapm.h +1 -1
index 9d1ff07..a6f04b1 100644
@@ -468,7 +468,7 @@ struct snd_soc_dapm_widget {
 
 /* DAPM context */
 struct snd_soc_dapm_context {
-	struct list_head widgets;
+	int n_widgets; /* number of widgets in this context */
 	enum snd_soc_bias_level bias_level;
 	enum snd_soc_bias_level suspend_bias_level;
 	struct delayed_work delayed_work;
include/sound/soc.h +1 -0
index 466895b..d5fb861 100644
@@ -661,6 +661,7 @@ struct snd_soc_card {
 	struct list_head platform_dev_list;
 	struct list_head dai_dev_list;
 
+	struct list_head widgets;
 	struct list_head paths;
 
 #ifdef CONFIG_DEBUG_FS
sound/soc/codecs/wm8960.c +3 -1
index 2c5712d..054f573 100644
@@ -418,7 +418,9 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
 	 * list each time to find the desired power state do so now
 	 * and save the result.
 	 */
-	list_for_each_entry(w, &codec->dapm.widgets, list) {
+	list_for_each_entry(w, &codec->card->widgets, list) {
+		if (w->dapm != &codec->dapm)
+			continue;
 		if (strcmp(w->name, "LOUT1 PGA") == 0)
 			wm8960->lout1 = w;
 		if (strcmp(w->name, "ROUT1 PGA") == 0)
sound/soc/soc-core.c +1 -1
index bdb2ca9..bd183a7 100644
@@ -1879,6 +1879,7 @@ static int soc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&card->dai_dev_list);
 	INIT_LIST_HEAD(&card->codec_dev_list);
 	INIT_LIST_HEAD(&card->platform_dev_list);
+	INIT_LIST_HEAD(&card->widgets);
 	INIT_LIST_HEAD(&card->paths);
 
 	soc_init_card_debugfs(card);
@@ -3481,7 +3482,6 @@ int snd_soc_register_codec(struct device *dev,
 	else
 		codec->compress_type = SND_SOC_FLAT_COMPRESSION;
 
-	INIT_LIST_HEAD(&codec->dapm.widgets);
 	codec->write = codec_drv->write;
 	codec->read = codec_drv->read;
 	codec->dapm.bias_level = SND_SOC_BIAS_OFF;
sound/soc/soc-dapm.c +49 -20

171 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#3 lore raw

PATCH 3/3 ASoC: Extend DAPM to handle power changes on cross-device paths

In reply to Jarkko Nikula

Power change event like stream start/stop or kcontrol change in a cross-device path originates from one device but codec bias and widget power changes must be populated to another devices on that path as well.

This patch modifies the dapm_power_widgets so that all the widgets on a sound card are checked for a power change, not just those that are specific to originating device. Also bias management is extended to check all the devices. Only exception in bias management are widgetless codecs whose bias state is changed only if power change is originating from that context.

DAPM context test is added to dapm_seq_run to take care of if power sequence extends to an another device which requires separate register writes.

---
 include/sound/soc-dapm.h |    5 ++
 include/sound/soc.h      |    1 +
 sound/soc/soc-core.c     |    2 +
 sound/soc/soc-dapm.c     |  109 ++++++++++++++++++++++++++-------------------
 4 files changed, 71 insertions(+), 46 deletions(-)
include/sound/soc-dapm.h +5 -0
index a6f04b1..188f8cf 100644
@@ -477,6 +477,11 @@ struct snd_soc_dapm_context {
 	struct device *dev; /* from parent - for debug */
 	struct snd_soc_codec *codec; /* parent codec */
 	struct snd_soc_card *card; /* parent card */
+
+	/* used during DAPM updates */
+	int dev_power;
+	struct list_head list;
+
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs_dapm;
 #endif
include/sound/soc.h +1 -0
index d5fb861..74921f2 100644
@@ -663,6 +663,7 @@ struct snd_soc_card {
 
 	struct list_head widgets;
 	struct list_head paths;
+	struct list_head dapm_list;
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs_card_root;
sound/soc/soc-core.c +2 -0
index bd183a7..a233607 100644
@@ -1427,6 +1427,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
 	/* mark codec as probed and add to card codec list */
 	codec->probed = 1;
 	list_add(&codec->card_list, &card->codec_dev_list);
+	list_add(&codec->dapm.list, &card->dapm_list);
 
 	return ret;
 }
@@ -1881,6 +1882,7 @@ static int soc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&card->platform_dev_list);
 	INIT_LIST_HEAD(&card->widgets);
 	INIT_LIST_HEAD(&card->paths);
+	INIT_LIST_HEAD(&card->dapm_list);
 
 	soc_init_card_debugfs(card);
 
sound/soc/soc-dapm.c +63 -46

193 lines not on this page · raw message

Signature · 1 line
1.7.2.3
Acked-by on the v1 series
#4 lore raw
In reply to Jarkko Nikula
Quoted 11 lines · Jarkko Nikula

Hi

Just updated set, i.e. no code changes other than updated to current tree and some comment clarifications.

Last time there were discussion about special n_widgets casing for non-DAPM codecs. Mark suggested to drop them but they are still here as I don't want to break boards having non-DAPM codec with bias control and that casing is trivial to drop when not needed anymore.

All

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
Applied
#5 lore raw
Quoted 6 lines · Liam Girdwood
Quoted 4 lines · Jarkko Nikula

Last time there were discussion about special n_widgets casing for non-DAPM codecs. Mark suggested to drop them but they are still here as I don't want to break boards having non-DAPM codec with bias control and that casing is trivial to drop when not needed anymore.

I'm pretty sure we just want to make DAPM mandatory here, it's a bunch of extra code fixing these devices up around the core algorithms which gets very little testing.

Quoted 1 line

Applied, thanks.