* [PATCH 1/5] ASoC: Get the card directly from the DAPM context
@ 2011-03-02 19:21 Mark Brown
2011-03-02 19:21 ` [PATCH 2/5] ASoC: Check for a CODEC before dereferencing in DAPM Mark Brown
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Mark Brown @ 2011-03-02 19:21 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
Rather than indirecting through the CODEC we can look the card up directly
from the card pointer in the DAPM context.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/soc-dapm.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index b8e6ab7..8240ab8 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -368,7 +368,7 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
int i, ret = 0;
size_t name_len;
struct snd_soc_dapm_path *path;
- struct snd_card *card = dapm->codec->card->snd_card;
+ struct snd_card *card = dapm->card->snd_card;
/* add kcontrol */
for (i = 0; i < w->num_kcontrols; i++) {
@@ -430,7 +430,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
{
struct snd_soc_dapm_path *path = NULL;
struct snd_kcontrol *kcontrol;
- struct snd_card *card = dapm->codec->card->snd_card;
+ struct snd_card *card = dapm->card->snd_card;
int ret = 0;
if (!w->num_kcontrols) {
@@ -480,7 +480,7 @@ static inline void dapm_clear_walk(struct snd_soc_dapm_context *dapm)
*/
static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
{
- int level = snd_power_get_state(widget->dapm->codec->card->snd_card);
+ int level = snd_power_get_state(widget->dapm->card->snd_card);
switch (level) {
case SNDRV_CTL_POWER_D3hot:
@@ -1083,7 +1083,7 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
*/
static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event)
{
- struct snd_soc_card *card = dapm->codec->card;
+ struct snd_soc_card *card = dapm->card;
struct snd_soc_dapm_widget *w;
struct snd_soc_dapm_context *d;
LIST_HEAD(up_list);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] ASoC: Check for a CODEC before dereferencing in DAPM
2011-03-02 19:21 [PATCH 1/5] ASoC: Get the card directly from the DAPM context Mark Brown
@ 2011-03-02 19:21 ` Mark Brown
2011-03-02 19:21 ` [PATCH 3/5] ASoC: Add a per-card DAPM context Mark Brown
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-03-02 19:21 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
A CODEC pointer is optional (and is checked for in most contexts within
DAPM) - add checks to the few places where it was missed.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/soc-dapm.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8240ab8..570db88 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1517,7 +1517,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
char prefixed_source[80];
int ret = 0;
- if (dapm->codec->name_prefix) {
+ if (dapm->codec && dapm->codec->name_prefix) {
snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
dapm->codec->name_prefix, route->sink);
sink = prefixed_sink;
@@ -2167,14 +2167,14 @@ int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
return -ENOMEM;
name_len = strlen(widget->name) + 1;
- if (dapm->codec->name_prefix)
+ if (dapm->codec && dapm->codec->name_prefix)
name_len += 1 + strlen(dapm->codec->name_prefix);
w->name = kmalloc(name_len, GFP_KERNEL);
if (w->name == NULL) {
kfree(w);
return -ENOMEM;
}
- if (dapm->codec->name_prefix)
+ if (dapm->codec && dapm->codec->name_prefix)
snprintf(w->name, name_len, "%s %s",
dapm->codec->name_prefix, widget->name);
else
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] ASoC: Add a per-card DAPM context
2011-03-02 19:21 [PATCH 1/5] ASoC: Get the card directly from the DAPM context Mark Brown
2011-03-02 19:21 ` [PATCH 2/5] ASoC: Check for a CODEC before dereferencing in DAPM Mark Brown
@ 2011-03-02 19:21 ` Mark Brown
2011-03-02 19:21 ` [PATCH 4/5] ASoC: Allow card DAPM widgets and routes to be set up at registration Mark Brown
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-03-02 19:21 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
This means that rather than adding the board specific DAPM widgets to a
random CODEC DAPM context they can be added to the card itself which is
a bit cleaner. Previously there only was one DAPM context and it was
tied to the single supported CODEC.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 3 +++
sound/soc/soc-core.c | 13 +++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 120fd19..24a35d6 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -730,6 +730,9 @@ struct snd_soc_card {
struct list_head paths;
struct list_head dapm_list;
+ /* Generic DAPM context for the card */
+ struct snd_soc_dapm_context dapm;
+
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_card_root;
struct dentry *debugfs_pop_time;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 64befac..24bfc3ff 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1837,6 +1837,11 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
}
card->snd_card->dev = card->dev;
+ card->dapm.bias_level = SND_SOC_BIAS_OFF;
+ card->dapm.dev = card->dev;
+ card->dapm.card = card;
+ list_add(&card->dapm.list, &card->dapm_list);
+
#ifdef CONFIG_PM_SLEEP
/* deferred resume work */
INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
@@ -1867,6 +1872,14 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
}
}
+ card->dapm.debugfs_dapm = debugfs_create_dir("dapm",
+ card->debugfs_card_root);
+ if (!card->dapm.debugfs_dapm)
+ printk(KERN_WARNING
+ "Failed to create card DAPM debugfs directory\n");
+
+ snd_soc_dapm_debugfs_init(&card->dapm);
+
snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
"%s", card->name);
snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] ASoC: Allow card DAPM widgets and routes to be set up at registration
2011-03-02 19:21 [PATCH 1/5] ASoC: Get the card directly from the DAPM context Mark Brown
2011-03-02 19:21 ` [PATCH 2/5] ASoC: Check for a CODEC before dereferencing in DAPM Mark Brown
2011-03-02 19:21 ` [PATCH 3/5] ASoC: Add a per-card DAPM context Mark Brown
@ 2011-03-02 19:21 ` Mark Brown
2011-03-02 19:21 ` [PATCH 5/5] ASoC: Add a late_probe() callback to cards Mark Brown
2011-03-03 10:34 ` [PATCH 1/5] ASoC: Get the card directly from the DAPM context Liam Girdwood
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-03-02 19:21 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
These will be added after all devices are registered and allow most DAI
init functions in machine drivers to be replaced by simple data.
Regular controls are not supported as the registration function still
works in terms of CODECs.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 8 ++++++++
sound/soc/soc-core.c | 7 +++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 24a35d6..601c41e 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -719,6 +719,14 @@ struct snd_soc_card {
struct snd_soc_pcm_runtime *rtd_aux;
int num_aux_rtd;
+ /*
+ * Card-specific routes and widgets.
+ */
+ struct snd_soc_dapm_widget *dapm_widgets;
+ int num_dapm_widgets;
+ struct snd_soc_dapm_route *dapm_routes;
+ int num_dapm_routes;
+
struct work_struct deferred_resume_work;
/* lists of probed devices belonging to this card */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 24bfc3ff..6a2839c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1872,6 +1872,13 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
}
}
+ if (card->dapm_widgets)
+ snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
+ card->num_dapm_widgets);
+ if (card->dapm_routes)
+ snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
+ card->num_dapm_routes);
+
card->dapm.debugfs_dapm = debugfs_create_dir("dapm",
card->debugfs_card_root);
if (!card->dapm.debugfs_dapm)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] ASoC: Add a late_probe() callback to cards
2011-03-02 19:21 [PATCH 1/5] ASoC: Get the card directly from the DAPM context Mark Brown
` (2 preceding siblings ...)
2011-03-02 19:21 ` [PATCH 4/5] ASoC: Allow card DAPM widgets and routes to be set up at registration Mark Brown
@ 2011-03-02 19:21 ` Mark Brown
2011-03-03 10:34 ` [PATCH 1/5] ASoC: Get the card directly from the DAPM context Liam Girdwood
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-03-02 19:21 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
This is run after the DAPM widgets and routes are added, allowing setup
of things like jacks using the routes. The main card probe() is run before
anything else so can't be used for this purpose.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 1 +
sound/soc/soc-core.c | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 601c41e..a23f5a5 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -683,6 +683,7 @@ struct snd_soc_card {
bool instantiated;
int (*probe)(struct snd_soc_card *card);
+ int (*late_probe)(struct snd_soc_card *card);
int (*remove)(struct snd_soc_card *card);
/* the pre and post PM functions are used to do any PM work before and
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6a2839c..8926d38 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1892,6 +1892,15 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
"%s", card->name);
+ if (card->late_probe) {
+ ret = card->late_probe(card);
+ if (ret < 0) {
+ dev_err(card->dev, "%s late_probe() failed: %d\n",
+ card->name, ret);
+ goto probe_aux_dev_err;
+ }
+ }
+
ret = snd_card_register(card->snd_card);
if (ret < 0) {
printk(KERN_ERR "asoc: failed to register soundcard for %s\n", card->name);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] ASoC: Get the card directly from the DAPM context
2011-03-02 19:21 [PATCH 1/5] ASoC: Get the card directly from the DAPM context Mark Brown
` (3 preceding siblings ...)
2011-03-02 19:21 ` [PATCH 5/5] ASoC: Add a late_probe() callback to cards Mark Brown
@ 2011-03-03 10:34 ` Liam Girdwood
4 siblings, 0 replies; 6+ messages in thread
From: Liam Girdwood @ 2011-03-03 10:34 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches
On Wed, 2011-03-02 at 19:21 +0000, Mark Brown wrote:
> Rather than indirecting through the CODEC we can look the card up directly
> from the card pointer in the DAPM context.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
All
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-03 10:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02 19:21 [PATCH 1/5] ASoC: Get the card directly from the DAPM context Mark Brown
2011-03-02 19:21 ` [PATCH 2/5] ASoC: Check for a CODEC before dereferencing in DAPM Mark Brown
2011-03-02 19:21 ` [PATCH 3/5] ASoC: Add a per-card DAPM context Mark Brown
2011-03-02 19:21 ` [PATCH 4/5] ASoC: Allow card DAPM widgets and routes to be set up at registration Mark Brown
2011-03-02 19:21 ` [PATCH 5/5] ASoC: Add a late_probe() callback to cards Mark Brown
2011-03-03 10:34 ` [PATCH 1/5] ASoC: Get the card directly from the DAPM context Liam Girdwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).