summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2014-04-24 14:01:44 +0200
committerMark Brown <broonie@linaro.org>2014-04-24 13:24:03 +0100
commit503ae5e036824935d9e214b9819a618499733bdf (patch)
tree2fbfa473e0423f1e42769cccf3910ddd99cf5d24
parent02c9c7b91c2831b7f4e43c9931007e46f856b659 (diff)
ASoC: core: Add helpers for dai link and aux dev init
Separate DAI link and aux dev initialization in preparation for DAI multicodec support. Since aux dev will remain using single codecs but DAI links will be able to support multiple codecs. No functional change. Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com> [fparent@baylibre.com: Adapt to 3.14+] Signed-off-by: Fabien Parent <fparent@baylibre.com> Signed-off-by: Benoit Cousson <bcousson@baylibre.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/soc-core.c67
1 files changed, 59 insertions, 8 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 42c5835ba92f..b2d889667ab4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1268,6 +1268,63 @@ static void rtd_release(struct device *dev)
kfree(dev);
}
+static int soc_aux_dev_init(struct snd_soc_card *card,
+ struct snd_soc_codec *codec,
+ int num)
+{
+ struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
+ struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
+ const char *temp;
+ int ret;
+
+ rtd->card = card;
+
+ temp = codec->name_prefix;
+ codec->name_prefix = NULL;
+
+ /* do machine specific initialization */
+ if (aux_dev->init) {
+ ret = aux_dev->init(&codec->dapm);
+ if (ret < 0)
+ return ret;
+ }
+
+ codec->name_prefix = temp;
+
+ rtd->codec = codec;
+
+ return 0;
+}
+
+static int soc_dai_link_init(struct snd_soc_card *card,
+ struct snd_soc_codec *codec,
+ int num)
+{
+ struct snd_soc_dai_link *dai_link = &card->dai_link[num];
+ struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
+ const char *temp;
+ int ret;
+
+ rtd->card = card;
+
+ /* machine controls, routes and widgets are not prefixed */
+ temp = codec->name_prefix;
+ codec->name_prefix = NULL;
+
+ /* do machine specific initialization */
+ if (dai_link->init) {
+ ret = dai_link->init(rtd);
+ if (ret < 0)
+ return ret;
+ }
+
+ codec->name_prefix = temp;
+
+ rtd->codec = codec;
+
+ return 0;
+}
+
static int soc_post_component_init(struct snd_soc_card *card,
struct snd_soc_codec *codec,
int num, int dailess)
@@ -1282,26 +1339,20 @@ static int soc_post_component_init(struct snd_soc_card *card,
dai_link = &card->dai_link[num];
rtd = &card->rtd[num];
name = dai_link->name;
+ ret = soc_dai_link_init(card, codec, num);
} else {
aux_dev = &card->aux_dev[num];
rtd = &card->rtd_aux[num];
name = aux_dev->name;
+ ret = soc_aux_dev_init(card, codec, num);
}
- rtd->card = card;
- /* do machine specific initialization */
- if (!dailess && dai_link->init)
- ret = dai_link->init(rtd);
- else if (dailess && aux_dev->init)
- ret = aux_dev->init(&codec->dapm);
if (ret < 0) {
dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret);
return ret;
}
/* register the rtd device */
- rtd->codec = codec;
-
rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (!rtd->dev)
return -ENOMEM;