aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2014-04-24 08:01:44 -0400
committerMark Brown <broonie@linaro.org>2014-04-24 08:24:03 -0400
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)
1268 kfree(dev); 1268 kfree(dev);
1269} 1269}
1270 1270
1271static int soc_aux_dev_init(struct snd_soc_card *card,
1272 struct snd_soc_codec *codec,
1273 int num)
1274{
1275 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1276 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1277 const char *temp;
1278 int ret;
1279
1280 rtd->card = card;
1281
1282 temp = codec->name_prefix;
1283 codec->name_prefix = NULL;
1284
1285 /* do machine specific initialization */
1286 if (aux_dev->init) {
1287 ret = aux_dev->init(&codec->dapm);
1288 if (ret < 0)
1289 return ret;
1290 }
1291
1292 codec->name_prefix = temp;
1293
1294 rtd->codec = codec;
1295
1296 return 0;
1297}
1298
1299static int soc_dai_link_init(struct snd_soc_card *card,
1300 struct snd_soc_codec *codec,
1301 int num)
1302{
1303 struct snd_soc_dai_link *dai_link = &card->dai_link[num];
1304 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
1305 const char *temp;
1306 int ret;
1307
1308 rtd->card = card;
1309
1310 /* machine controls, routes and widgets are not prefixed */
1311 temp = codec->name_prefix;
1312 codec->name_prefix = NULL;
1313
1314 /* do machine specific initialization */
1315 if (dai_link->init) {
1316 ret = dai_link->init(rtd);
1317 if (ret < 0)
1318 return ret;
1319 }
1320
1321 codec->name_prefix = temp;
1322
1323 rtd->codec = codec;
1324
1325 return 0;
1326}
1327
1271static int soc_post_component_init(struct snd_soc_card *card, 1328static int soc_post_component_init(struct snd_soc_card *card,
1272 struct snd_soc_codec *codec, 1329 struct snd_soc_codec *codec,
1273 int num, int dailess) 1330 int num, int dailess)
@@ -1282,26 +1339,20 @@ static int soc_post_component_init(struct snd_soc_card *card,
1282 dai_link = &card->dai_link[num]; 1339 dai_link = &card->dai_link[num];
1283 rtd = &card->rtd[num]; 1340 rtd = &card->rtd[num];
1284 name = dai_link->name; 1341 name = dai_link->name;
1342 ret = soc_dai_link_init(card, codec, num);
1285 } else { 1343 } else {
1286 aux_dev = &card->aux_dev[num]; 1344 aux_dev = &card->aux_dev[num];
1287 rtd = &card->rtd_aux[num]; 1345 rtd = &card->rtd_aux[num];
1288 name = aux_dev->name; 1346 name = aux_dev->name;
1347 ret = soc_aux_dev_init(card, codec, num);
1289 } 1348 }
1290 rtd->card = card;
1291 1349
1292 /* do machine specific initialization */
1293 if (!dailess && dai_link->init)
1294 ret = dai_link->init(rtd);
1295 else if (dailess && aux_dev->init)
1296 ret = aux_dev->init(&codec->dapm);
1297 if (ret < 0) { 1350 if (ret < 0) {
1298 dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret); 1351 dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret);
1299 return ret; 1352 return ret;
1300 } 1353 }
1301 1354
1302 /* register the rtd device */ 1355 /* register the rtd device */
1303 rtd->codec = codec;
1304
1305 rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL); 1356 rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
1306 if (!rtd->dev) 1357 if (!rtd->dev)
1307 return -ENOMEM; 1358 return -ENOMEM;