summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd0dfd7)
raw | patch | inline | side by side (parent: dd0dfd7)
author | Misael Lopez Cruz <misael.lopez@ti.com> | |
Sun, 9 Jun 2013 22:12:01 +0000 (17:12 -0500) | ||
committer | Misael Lopez Cruz <misael.lopez@ti.com> | |
Tue, 10 Mar 2015 17:33:12 +0000 (12:33 -0500) |
Extend CODEC configuration to allow passing DT/OF node
or the dev_name.
Previously, it was possible only via dev_name.
This patch is ported from p-ti-linux-3.8.y released kernel branch
tree.(Kernel Version:3.8).
Change-Id: I06d801f13652f1b214c040e65fa88d586a51d65a
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Charulatha Varadarajan <charu@ti.com>
Signed-off-by: Manish Badarkhe <manishvb@ti.com>
or the dev_name.
Previously, it was possible only via dev_name.
This patch is ported from p-ti-linux-3.8.y released kernel branch
tree.(Kernel Version:3.8).
Change-Id: I06d801f13652f1b214c040e65fa88d586a51d65a
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Charulatha Varadarajan <charu@ti.com>
Signed-off-by: Manish Badarkhe <manishvb@ti.com>
include/sound/soc.h | patch | blob | history | |
sound/soc/soc-core.c | patch | blob | history |
diff --git a/include/sound/soc.h b/include/sound/soc.h
index eb330ecf189905f889bd0e659bfb249ff7bfa2dc..74b23dc2b46dfe2cf1e47c30ad213267b6192762 100644 (file)
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
};
struct snd_soc_codec_conf {
+ /*
+ * You MUST specify the conf's codec, either by device name,
+ * or by DT/OF node, but not both.
+ */
const char *dev_name;
+ const struct device_node *codec_of_node;
+
+ struct snd_soc_codec *codec;
/*
* optional map of kcontrol, widget and path name prefixes that are
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1f751066e0c1c087218b61ada2c906c557a3c343..064f29adb1eccd8f9fa835aab1f7caf8df564e28 100644 (file)
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
for (i = 0; i < card->num_configs; i++) {
struct snd_soc_codec_conf *map = &card->codec_conf[i];
- if (map->dev_name && !strcmp(codec->name, map->dev_name)) {
+ if (map->codec == codec) {
codec->name_prefix = map->name_prefix;
break;
}
return 0;
}
+static int snd_soc_init_codec_conf(struct snd_soc_card *card, int num)
+{
+ struct snd_soc_codec *codec;
+ struct snd_soc_codec_conf *codec_conf;
+
+ codec_conf = &card->codec_conf[num];
+ if (!!codec_conf->dev_name == !!codec_conf->codec_of_node) {
+ dev_err(card->dev,
+ "ASoC: Neither/both codec name/of_node are set for %s\n",
+ codec_conf->name_prefix);
+ return -EINVAL;
+ }
+
+ list_for_each_entry(codec, &codec_list, list) {
+ if (codec_conf->codec_of_node) {
+ if (codec->dev->of_node != codec_conf->codec_of_node)
+ continue;
+ } else {
+ if (codec_conf->dev_name &&
+ strcmp(codec->name, codec_conf->dev_name))
+ continue;
+ }
+
+ codec_conf->codec = codec;
+ }
+
+ if (!codec_conf->codec) {
+ dev_err(card->dev,
+ "ASoC: CODEC for conf %s is not registered\n",
+ codec_conf->name_prefix);
+ return -EPROBE_DEFER;
+ }
+
+ return 0;
+}
+
static int snd_soc_instantiate_card(struct snd_soc_card *card)
{
struct snd_soc_codec *codec;
goto base_error;
}
+ /* resolve codec configuration */
+ for (i = 0; i < card->num_configs; i++) {
+ snd_soc_init_codec_conf(card, i);
+ if (ret)
+ goto base_error;
+ }
+
/* initialize the register cache for each available codec */
list_for_each_entry(codec, &codec_list, list) {
if (codec->cache_init)