Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283985
b: refs/heads/master
c: a4a54dd
h: refs/heads/master
i:
  283983: de69244
v: v3
  • Loading branch information
Stephen Warren authored and Mark Brown committed Dec 20, 2011
1 parent a23b0d8 commit 3a694eb
Show file tree
Hide file tree
Showing 3 changed files with 60 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: bec4fa05e25f7e78ec67df389539acc6bb352a2a
refs/heads/master: a4a54dd5bb1bb01010f46147d6d8b452255957bf
2 changes: 2 additions & 0 deletions trunk/include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,8 @@ void snd_soc_util_exit(void);

int snd_soc_of_parse_card_name(struct snd_soc_card *card,
const char *propname);
int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname);

#include <sound/soc-dai.h>

Expand Down
57 changes: 57 additions & 0 deletions trunk/sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3342,6 +3342,63 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
}
EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);

int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname)
{
struct device_node *np = card->dev->of_node;
int num_routes;
struct snd_soc_dapm_route *routes;
int i, ret;

num_routes = of_property_count_strings(np, propname);
if (num_routes & 1) {
dev_err(card->dev,
"Property '%s's length is not even\n",
propname);
return -EINVAL;
}
num_routes /= 2;
if (!num_routes) {
dev_err(card->dev,
"Property '%s's length is zero\n",
propname);
return -EINVAL;
}

routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
GFP_KERNEL);
if (!routes) {
dev_err(card->dev,
"Could not allocate DAPM route table\n");
return -EINVAL;
}

for (i = 0; i < num_routes; i++) {
ret = of_property_read_string_index(np, propname,
2 * i, &routes[i].sink);
if (ret) {
dev_err(card->dev,
"Property '%s' index %d could not be read: %d\n",
propname, 2 * i, ret);
return -EINVAL;
}
ret = of_property_read_string_index(np, propname,
(2 * i) + 1, &routes[i].source);
if (ret) {
dev_err(card->dev,
"Property '%s' index %d could not be read: %d\n",
propname, (2 * i) + 1, ret);
return -EINVAL;
}
}

card->num_dapm_routes = num_routes;
card->dapm_routes = routes;

return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);

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

0 comments on commit 3a694eb

Please sign in to comment.