ASoC: Move DAPM paths from DAPM context to snd_soc_card
Subsystems (4)
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 | 2 +- include/sound/soc.h | 2 + sound/soc/codecs/tlv320aic3x.c | 2 +- sound/soc/soc-core.c | 3 +- sound/soc/soc-dapm.c | 41 ++++++++++++++++++++++++++------------- 5 files changed, 33 insertions(+), 17 deletions(-)
include/sound/soc-dapm.h +1 -1
@@ -466,7 +466,6 @@ struct snd_soc_dapm_widget {struct snd_soc_dapm_context {u32 pop_time;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;
@@ -474,6 +473,7 @@ 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 */ #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_dapm;#endif
include/sound/soc.h +2 -0
@@ -589,6 +589,8 @@ struct snd_soc_card {struct list_head codec_dev_list;struct list_head platform_dev_list;struct list_head dai_dev_list; + +struct list_head paths; };/* SoC machine DAI configuration, glues a codec and cpu DAI together */
sound/soc/codecs/tlv320aic3x.c +1 -1
@@ -183,7 +183,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 +2 -1
@@ -1406,6 +1406,7 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num)/* probe the CODEC */ if (!codec->probed) { + codec->dapm->card = card;if (codec->driver->probe) { ret = codec->driver->probe (codec);if (ret <0 ) {
@@ -1662,6 +1663,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); ret =snd_soc_register_card (card);if (ret !=0 ) {
@@ -2964,7 +2966,6 @@ static struct snd_soc_dapm_context *soc_new_dapm_context(struct device *dev) dapm =kzalloc (sizeof (struct snd_soc_dapm_context ),GFP_KERNEL );if (dapm) {INIT_LIST_HEAD (&dapm->widgets); -INIT_LIST_HEAD (&dapm->paths); dapm->bias_level =SND_SOC_BIAS_OFF ; dapm->dev = dev; }
sound/soc/soc-dapm.c +27 -14
97 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 2/3 ASoC: Move widgets from DAPM context to snd_soc_card
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. 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 | 70 +++++++++++++++++++++++++++++++------------- 5 files changed, 55 insertions(+), 24 deletions(-)
include/sound/soc-dapm.h +1 -1
@@ -465,7 +465,7 @@ struct snd_soc_dapm_widget {/* DAPM context */ struct snd_soc_dapm_context {u32 pop_time; -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
@@ -590,6 +590,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; };
sound/soc/codecs/wm8960.c +3 -1
@@ -417,7 +417,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
@@ -1663,6 +1663,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); ret =snd_soc_register_card (card);
@@ -2965,7 +2966,6 @@ static struct snd_soc_dapm_context *soc_new_dapm_context(struct device *dev) dapm =kzalloc (sizeof (struct snd_soc_dapm_context ),GFP_KERNEL );if (dapm) { -INIT_LIST_HEAD (&dapm->widgets); dapm->bias_level =SND_SOC_BIAS_OFF ; dapm->dev = dev; }
sound/soc/soc-dapm.c +49 -21
171 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Re: [RFC_ii/iv 2/3] ASoC: Move widgets from DAPM context to snd_soc_card
Quoted 4 lines · 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 also looks good.
PATCH 3/3 ASoC: Extend DAPM to handle power changes on cross-device paths
In reply to Jarkko NikulaPower 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 implements this by modifying the dapm_power_widgets so that it checks all the widgets on snd_soc_card that needs power change. Also all DAPM contexts are traversed if there is a need to change bias state of them. Only exception is widgetless codec whose bias state is changed only if power change is originating from that context.
Functions dapm_seq_run and dapm_seq_run_coalesced are modified so that a new write is issued when the sequence extends to an another device and DAPM context of a widget instead of originating DAPM context is used when doing pop waits and register writes.
--- include/sound/soc-dapm.h | 3 + include/sound/soc.h | 1 + sound/soc/soc-core.c | 2 + sound/soc/soc-dapm.c | 107 +++++++++++++++++++++++++-------------------- 4 files changed, 65 insertions(+), 48 deletions(-)
include/sound/soc-dapm.h +3 -0
@@ -477,6 +477,9 @@ struct snd_soc_dapm_context {#ifdef CONFIG_DEBUG_FS struct dentry *debugfs_dapm;#endif +/* used during DAPM updates */ +int sys_power; + struct list_head list; };#endif
include/sound/soc.h +1 -0
@@ -592,6 +592,7 @@ struct snd_soc_card {struct list_head widgets;struct list_head paths; +struct list_head dapm_list; };/* SoC machine DAI configuration, glues a codec and cpu DAI together */
sound/soc/soc-core.c +2 -0
@@ -1421,6 +1421,7 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num)/* 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); }/* probe the platform */
@@ -1665,6 +1666,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); ret =snd_soc_register_card (card);if (ret !=0 ) {
sound/soc/soc-dapm.c +59 -48
218 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Re: [RFC_ii/iv 3/3] ASoC: Extend DAPM to handle power changes on cross-device paths
Quoted 4 lines · Jarkko Nikula
Functions
dapm_seq_runanddapm_seq_run_coalescedare modified so that a new write is issued when the sequence extends to an another device and DAPM context of a widget instead of originating DAPM context is used when doing pop waits and register writes.
I'm having a hard time parsing this bit of the changelog, I'm afraid. What I'd expect is that the comparison operation used for coalescing would be extended to compare based on the CODEC/DAPM context too and the split per device should naturally fall out of that. I didn't notice the comparison being updated?
Otherwise this looks pretty good, these are stylistic things:
sound/soc/soc-dapm.c static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm, · line 762
Quoted 6 lines
sound/soc/soc-dapm.c +1
-1/* power down pre event */ if (!w->power && w->event && (w->event_flags &SND_SOC_DAPM_PRE_PMD )) { -pop_dbg (dapm->pop_time,"pop test : %s PRE_PMD\n" , +pop_dbg (w->dapm->pop_time,"pop test : %s PRE_PMD\n" , w->name);
We probably need to start putting the dev_names in these.
sound/soc/soc-dapm.c static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) · line 935
Quoted 3 lines
sound/soc/soc-dapm.c +1
-1if (power) - sys_power =1 ; + w->dapm->sys_power =1 ;
sys_power needs to be renamed - probably dev_power or something.
sound/soc/soc-dapm.c static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) · line 992
Quoted 13 lines
sound/soc/soc-dapm.c +7
-6-/* If we're changing to all on or all off then prepare */ -if ((sys_power && dapm->bias_level ==SND_SOC_BIAS_STANDBY ) || - (!sys_power && dapm->bias_level ==SND_SOC_BIAS_ON )) { - ret =snd_soc_dapm_set_bias_level (card, dapm,SND_SOC_BIAS_PREPARE ); -if (ret !=0 ) -pr_err ("Failed to prepare bias: %d\n" , ret); +/* If we're changing to all on or all off then prepare */ +if ((d->sys_power && d->bias_level ==SND_SOC_BIAS_STANDBY ) || + (!d->sys_power && d->bias_level ==SND_SOC_BIAS_ON )) { + ret =snd_soc_dapm_set_bias_level (card, d,SND_SOC_BIAS_PREPARE ); +if (ret !=0 ) +pr_err ("Failed to prepare bias: %d\n" , ret); + }
We can switch these over to dev_ prints now, I think.
Re: [RFC_ii/iv 3/3] ASoC: Extend DAPM to handle power changes on cross-device paths
Quoted 7 lines · On Fri, 29 Oct 2010 14:03:10 -0700 Mark Brown…
Quoted 4 lines · Jarkko Nikula
Functions
dapm_seq_runanddapm_seq_run_coalescedare modified so that a new write is issued when the sequence extends to an another device and DAPM context of a widget instead of originating DAPM context is used when doing pop waits and register writes.
Quoted 6 lines
I'm having a hard time parsing this bit of the changelog, I'm afraid. What I'd expect is that the comparison operation used for coalescing would be extended to compare based on the CODEC/DAPM context too and the split per device should naturally fall out of that. I didn't notice the comparison being updated?
It was these diffs for dapm_seq_run:
/* Do we need to apply any queued changes? */
- if (sort[w->id] != cur_sort || w->reg != cur_reg) {
+ if (sort[w->id] != cur_sort || w->reg != cur_reg ||+ w->dapm != cur_dapm) {
if (!list_empty(&pending))
dapm_seq_run_coalesced(dapm, &pending);
So if DAPM is different the dapm_seq_run_coalesced is run now and next iterations are done for another DAPM context.
Looking at this now I think I can leave out dapm_seq_run_coalesced changes by changing the line above to dapm_seq_run_coalesced(cur_dapm, &pending). I'll check it for the next version.
Quoted 2 lines
Otherwise this looks pretty good, these are stylistic things:
Good notes. I'll change them.
Signature · 1 line
Jarkko
Re: [RFC_ii/iv 3/3] ASoC: Extend DAPM to handle power changes on cross-device paths
Quoted 23 lines · Jarkko Nikula
Quoted 7 lines · Mark Brown
Quoted 4 lines · Jarkko Nikula
Functions
dapm_seq_runanddapm_seq_run_coalescedare modified so that a new write is issued when the sequence extends to an another device and DAPM context of a widget instead of originating DAPM context is used when doing pop waits and register writes.Quoted 5 lines
I'm having a hard time parsing this bit of the changelog, I'm afraid. What I'd expect is that the comparison operation used for coalescing would be extended to compare based on the CODEC/DAPM context too and the split per device should naturally fall out of that. I didn't notice the comparison being updated?
It was these diffs for
dapm_seq_run:/* Do we need to apply any queued changes? */sound/soc/soc-dapm.c +2
-1-if (sort[w->id] != cur_sort || w->reg != cur_reg) { +if (sort[w->id] != cur_sort || w->reg != cur_reg || + w->dapm != cur_dapm) {if (!list_empty (&pending))dapm_seq_run_coalesced (dapm, &pending);
Quoted 2 lines
So if DAPM is different the
dapm_seq_run_coalescedis run now and next iterations are done for another DAPM context.
Pretty much - that was the code I was looking for but you were talking about only the execution code, not the comparison operation.
Quoted 7 lines · Jarkko Nikula
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_widgetsis prepared to remove cross-device paths between a device being removed and others.Signed-off-by Jarkko Nikula <[email protected]>
This looks good to me.