aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-09 11:29:21 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-16 14:36:29 -0400
commitf04209a7b0a9942aa78f8b27e63a8a5cc097adf8 (patch)
treeb2f07c053c943e370dd2ab39c17fdd5f132e9779 /sound/soc/soc-core.c
parent1eee1b3833d67eb52c0f4d293cbb796a776c5eed (diff)
ASoC: core: Flip master for CODECs in the CPU slot of a CODEC<->CODEC link
When two CODEC DAIs are linked directly to each other then if we give the same master mode settings to both devices things won't work as either neither will drive or they'll drive against each other. Flip the settings for the DAI in the CPU slot of the DAI link. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 98a4f7aa4f01..9eefe9072dfa 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1416,7 +1416,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1416 struct snd_soc_codec_conf *codec_conf; 1416 struct snd_soc_codec_conf *codec_conf;
1417 enum snd_soc_compress_type compress_type; 1417 enum snd_soc_compress_type compress_type;
1418 struct snd_soc_dai_link *dai_link; 1418 struct snd_soc_dai_link *dai_link;
1419 int ret, i, order; 1419 int ret, i, order, dai_fmt;
1420 1420
1421 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); 1421 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
1422 1422
@@ -1525,17 +1525,46 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1525 1525
1526 for (i = 0; i < card->num_links; i++) { 1526 for (i = 0; i < card->num_links; i++) {
1527 dai_link = &card->dai_link[i]; 1527 dai_link = &card->dai_link[i];
1528 dai_fmt = dai_link->dai_fmt;
1528 1529
1529 if (dai_link->dai_fmt) { 1530 if (dai_fmt) {
1530 ret = snd_soc_dai_set_fmt(card->rtd[i].codec_dai, 1531 ret = snd_soc_dai_set_fmt(card->rtd[i].codec_dai,
1531 dai_link->dai_fmt); 1532 dai_fmt);
1532 if (ret != 0 && ret != -ENOTSUPP) 1533 if (ret != 0 && ret != -ENOTSUPP)
1533 dev_warn(card->rtd[i].codec_dai->dev, 1534 dev_warn(card->rtd[i].codec_dai->dev,
1534 "Failed to set DAI format: %d\n", 1535 "Failed to set DAI format: %d\n",
1535 ret); 1536 ret);
1537 }
1538
1539 /* If this is a regular CPU link there will be a platform */
1540 if (dai_fmt && dai_link->platform_name) {
1541 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai,
1542 dai_fmt);
1543 if (ret != 0 && ret != -ENOTSUPP)
1544 dev_warn(card->rtd[i].cpu_dai->dev,
1545 "Failed to set DAI format: %d\n",
1546 ret);
1547 } else if (dai_fmt) {
1548 /* Flip the polarity for the "CPU" end */
1549 dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
1550 switch (dai_link->dai_fmt &
1551 SND_SOC_DAIFMT_MASTER_MASK) {
1552 case SND_SOC_DAIFMT_CBM_CFM:
1553 dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
1554 break;
1555 case SND_SOC_DAIFMT_CBM_CFS:
1556 dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
1557 break;
1558 case SND_SOC_DAIFMT_CBS_CFM:
1559 dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
1560 break;
1561 case SND_SOC_DAIFMT_CBS_CFS:
1562 dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
1563 break;
1564 }
1536 1565
1537 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, 1566 ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai,
1538 dai_link->dai_fmt); 1567 dai_fmt);
1539 if (ret != 0 && ret != -ENOTSUPP) 1568 if (ret != 0 && ret != -ENOTSUPP)
1540 dev_warn(card->rtd[i].cpu_dai->dev, 1569 dev_warn(card->rtd[i].cpu_dai->dev,
1541 "Failed to set DAI format: %d\n", 1570 "Failed to set DAI format: %d\n",