Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 371809
b: refs/heads/master
c: 995f297
h: refs/heads/master
i:
  371807: 7fabd70
v: v3
  • Loading branch information
Mark Brown committed Mar 26, 2013
1 parent 59f0657 commit 05902f4
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8abfc2608ba6f6c4bae0931149504fe33d1332a6
refs/heads/master: 995f297298f2337a5f9794271dc225d17cdb2c15
20 changes: 20 additions & 0 deletions trunk/include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ struct snd_soc_dai_link;
struct snd_soc_platform_driver;
struct snd_soc_codec;
struct snd_soc_codec_driver;
struct snd_soc_component;
struct snd_soc_component_driver;
struct soc_enum;
struct snd_soc_jack;
struct snd_soc_jack_zone;
Expand Down Expand Up @@ -377,6 +379,10 @@ int snd_soc_register_codec(struct device *dev,
const struct snd_soc_codec_driver *codec_drv,
struct snd_soc_dai_driver *dai_drv, int num_dai);
void snd_soc_unregister_codec(struct device *dev);
int snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *cmpnt_drv,
struct snd_soc_dai_driver *dai_drv, int num_dai);
void snd_soc_unregister_component(struct device *dev);
int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
unsigned int reg);
int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
Expand Down Expand Up @@ -841,6 +847,20 @@ struct snd_soc_platform {
#endif
};

struct snd_soc_component_driver {
const char *name;
};

struct snd_soc_component {
const char *name;
int id;
int num_dai;
struct device *dev;
struct list_head list;

const struct snd_soc_component_driver *driver;
};

struct snd_soc_dai_link {
/* config - must be set by machine driver */
const char *name; /* Codec name */
Expand Down
12 changes: 8 additions & 4 deletions trunk/sound/soc/sh/fsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,10 @@ static struct snd_soc_platform_driver fsi_soc_platform = {
.pcm_free = fsi_pcm_free,
};

static const struct snd_soc_component_driver fsi_soc_component = {
.name = "fsi",
};

/*
* platform function
*/
Expand Down Expand Up @@ -2046,10 +2050,10 @@ static int fsi_probe(struct platform_device *pdev)
goto exit_fsib;
}

ret = snd_soc_register_dais(&pdev->dev, fsi_soc_dai,
ARRAY_SIZE(fsi_soc_dai));
ret = snd_soc_register_component(&pdev->dev, &fsi_soc_component,
fsi_soc_dai, ARRAY_SIZE(fsi_soc_dai));
if (ret < 0) {
dev_err(&pdev->dev, "cannot snd dai register\n");
dev_err(&pdev->dev, "cannot snd component register\n");
goto exit_snd_soc;
}

Expand All @@ -2074,7 +2078,7 @@ static int fsi_remove(struct platform_device *pdev)

pm_runtime_disable(&pdev->dev);

snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(fsi_soc_dai));
snd_soc_unregister_component(&pdev->dev);
snd_soc_unregister_platform(&pdev->dev);

fsi_stream_remove(&master->fsia);
Expand Down
77 changes: 77 additions & 0 deletions trunk/sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static DEFINE_MUTEX(client_mutex);
static LIST_HEAD(dai_list);
static LIST_HEAD(platform_list);
static LIST_HEAD(codec_list);
static LIST_HEAD(component_list);

/*
* This is a timeout to do a DAPM powerdown after a stream is closed().
Expand Down Expand Up @@ -4137,6 +4138,82 @@ void snd_soc_unregister_codec(struct device *dev)
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);


/**
* snd_soc_register_component - Register a component with the ASoC core
*
*/
int snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *cmpnt_drv,
struct snd_soc_dai_driver *dai_drv,
int num_dai)
{
struct snd_soc_component *cmpnt;
int ret;

dev_dbg(dev, "component register %s\n", dev_name(dev));

cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL);
if (!cmpnt) {
dev_err(dev, "ASoC: Failed to allocate memory\n");
return -ENOMEM;
}

cmpnt->name = fmt_single_name(dev, &cmpnt->id);
if (!cmpnt->name) {
dev_err(dev, "ASoC: Failed to simplifying name\n");
return -ENOMEM;
}

cmpnt->dev = dev;
cmpnt->driver = cmpnt_drv;
cmpnt->num_dai = num_dai;

ret = snd_soc_register_dais(dev, dai_drv, num_dai);
if (ret < 0) {
dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret);
goto error_component_name;
}

mutex_lock(&client_mutex);
list_add(&cmpnt->list, &component_list);
mutex_unlock(&client_mutex);

dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name);

return ret;

error_component_name:
kfree(cmpnt->name);

return ret;
}

/**
* snd_soc_unregister_component - Unregister a component from the ASoC core
*
*/
void snd_soc_unregister_component(struct device *dev)
{
struct snd_soc_component *cmpnt;

list_for_each_entry(cmpnt, &component_list, list) {
if (dev == cmpnt->dev)
goto found;
}
return;

found:
snd_soc_unregister_dais(dev, cmpnt->num_dai);

mutex_lock(&client_mutex);
list_del(&cmpnt->list);
mutex_unlock(&client_mutex);

dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
kfree(cmpnt->name);
}

/* Retrieve a card's name from device tree */
int snd_soc_of_parse_card_name(struct snd_soc_card *card,
const char *propname)
Expand Down

0 comments on commit 05902f4

Please sign in to comment.