Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120292
b: refs/heads/master
c: c5af3a2
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Dec 9, 2008
1 parent a944d20 commit 5fc8139
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca4513fe06c483bf0111c990059d42f97288605d
refs/heads/master: c5af3a2e192d333997d1e191f3eba7fd2f869681
5 changes: 5 additions & 0 deletions trunk/include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ struct snd_soc_dai_link {
/* SoC card */
struct snd_soc_card {
char *name;
struct device *dev;

struct list_head list;

int instantiated;

int (*probe)(struct platform_device *pdev);
int (*remove)(struct platform_device *pdev);
Expand Down
62 changes: 62 additions & 0 deletions trunk/sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
static struct dentry *debugfs_root;
#endif

static DEFINE_MUTEX(client_mutex);
static LIST_HEAD(card_list);

static int snd_soc_register_card(struct snd_soc_card *card);
static int snd_soc_unregister_card(struct snd_soc_card *card);

/*
* This is a timeout to do a DAPM powerdown after a stream is closed().
* It can be used to eliminate pops between different playback streams, e.g.
Expand Down Expand Up @@ -784,6 +790,14 @@ static int soc_probe(struct platform_device *pdev)
/* Bodge while we push things out of socdev */
card->socdev = socdev;

/* Bodge while we unpick instantiation */
card->dev = &pdev->dev;
ret = snd_soc_register_card(card);
if (ret != 0) {
dev_err(&pdev->dev, "Failed to register card\n");
return ret;
}

if (card->probe) {
ret = card->probe(pdev);
if (ret < 0)
Expand Down Expand Up @@ -863,6 +877,8 @@ static int soc_remove(struct platform_device *pdev)
if (card->remove)
card->remove(pdev);

snd_soc_unregister_card(card);

return 0;
}

Expand Down Expand Up @@ -1957,6 +1973,52 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute)
}
EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);

/**
* snd_soc_register_card - Register a card with the ASoC core
*
* @param card Card to register
*
* Note that currently this is an internal only function: it will be
* exposed to machine drivers after further backporting of ASoC v2
* registration APIs.
*/
static int snd_soc_register_card(struct snd_soc_card *card)
{
if (!card->name || !card->dev)
return -EINVAL;

INIT_LIST_HEAD(&card->list);
card->instantiated = 0;

mutex_lock(&client_mutex);
list_add(&card->list, &card_list);
mutex_unlock(&client_mutex);

dev_dbg(card->dev, "Registered card '%s'\n", card->name);

return 0;
}

/**
* snd_soc_unregister_card - Unregister a card with the ASoC core
*
* @param card Card to unregister
*
* Note that currently this is an internal only function: it will be
* exposed to machine drivers after further backporting of ASoC v2
* registration APIs.
*/
static int snd_soc_unregister_card(struct snd_soc_card *card)
{
mutex_lock(&client_mutex);
list_del(&card->list);
mutex_unlock(&client_mutex);

dev_dbg(card->dev, "Unregistered card '%s'\n", card->name);

return 0;
}

static int __devinit snd_soc_init(void)
{
#ifdef CONFIG_DEBUG_FS
Expand Down

0 comments on commit 5fc8139

Please sign in to comment.