aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-08-19 09:51:22 -0400
committerMark Brown <broonie@linaro.org>2014-08-19 11:59:45 -0400
commit65d9361f0cb50a20641802ee3075145d72e4409c (patch)
tree9e5fe5df65473ee4e5ef1880d06bcdfa02faebd4
parent61aca5646b736a794d40de29a197144db3f0c5ba (diff)
ASoC: Move AUX dev support to the component level
This patch makes it possible to register arbitrary components as a AUX dev for a card. This was previously only possible for CODEC components. With componentization having made it possible for components to have DAPM contexts and controls there is no reason why AUX devs should be artificially limited to snd_soc_codec devices. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--include/sound/soc.h1
-rw-r--r--sound/soc/soc-core.c48
2 files changed, 37 insertions, 12 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 4a223a895f00..fbc2ad840244 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1140,6 +1140,7 @@ struct snd_soc_pcm_runtime {
1140 struct snd_soc_platform *platform; 1140 struct snd_soc_platform *platform;
1141 struct snd_soc_dai *codec_dai; 1141 struct snd_soc_dai *codec_dai;
1142 struct snd_soc_dai *cpu_dai; 1142 struct snd_soc_dai *cpu_dai;
1143 struct snd_soc_component *component; /* Only valid for AUX dev rtds */
1143 1144
1144 struct snd_soc_dai **codec_dais; 1145 struct snd_soc_dai **codec_dais;
1145 unsigned int num_codecs; 1146 unsigned int num_codecs;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 08fd85e8c751..08c04f4c7e62 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -860,6 +860,23 @@ EXPORT_SYMBOL_GPL(snd_soc_resume);
860static const struct snd_soc_dai_ops null_dai_ops = { 860static const struct snd_soc_dai_ops null_dai_ops = {
861}; 861};
862 862
863static struct snd_soc_component *soc_find_component(
864 const struct device_node *of_node, const char *name)
865{
866 struct snd_soc_component *component;
867
868 list_for_each_entry(component, &component_list, list) {
869 if (of_node) {
870 if (component->dev->of_node == of_node)
871 return component;
872 } else if (strcmp(component->name, name) == 0) {
873 return component;
874 }
875 }
876
877 return NULL;
878}
879
863static struct snd_soc_codec *soc_find_codec( 880static struct snd_soc_codec *soc_find_codec(
864 const struct device_node *codec_of_node, 881 const struct device_node *codec_of_node,
865 const char *codec_name) 882 const char *codec_name)
@@ -1577,17 +1594,24 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
1577{ 1594{
1578 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; 1595 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1579 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; 1596 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1580 const char *codecname = aux_dev->codec_name; 1597 const char *name = aux_dev->codec_name;
1581 1598
1582 rtd->codec = soc_find_codec(aux_dev->codec_of_node, codecname); 1599 rtd->component = soc_find_component(aux_dev->codec_of_node, name);
1583 if (!rtd->codec) { 1600 if (!rtd->component) {
1584 if (aux_dev->codec_of_node) 1601 if (aux_dev->codec_of_node)
1585 codecname = of_node_full_name(aux_dev->codec_of_node); 1602 name = of_node_full_name(aux_dev->codec_of_node);
1586 1603
1587 dev_err(card->dev, "ASoC: %s not registered\n", codecname); 1604 dev_err(card->dev, "ASoC: %s not registered\n", name);
1588 return -EPROBE_DEFER; 1605 return -EPROBE_DEFER;
1589 } 1606 }
1590 1607
1608 /*
1609 * Some places still reference rtd->codec, so we have to keep that
1610 * initialized if the component is a CODEC. Once all those references
1611 * have been removed, this code can be removed as well.
1612 */
1613 rtd->codec = rtd->component->codec;
1614
1591 return 0; 1615 return 0;
1592} 1616}
1593 1617
@@ -1597,18 +1621,18 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1597 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; 1621 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1598 int ret; 1622 int ret;
1599 1623
1600 if (rtd->codec->component.probed) { 1624 if (rtd->component->probed) {
1601 dev_err(rtd->codec->dev, "ASoC: codec already probed\n"); 1625 dev_err(rtd->dev, "ASoC: codec already probed\n");
1602 return -EBUSY; 1626 return -EBUSY;
1603 } 1627 }
1604 1628
1605 ret = soc_probe_component(card, &rtd->codec->component); 1629 ret = soc_probe_component(card, rtd->component);
1606 if (ret < 0) 1630 if (ret < 0)
1607 return ret; 1631 return ret;
1608 1632
1609 /* do machine specific initialization */ 1633 /* do machine specific initialization */
1610 if (aux_dev->init) { 1634 if (aux_dev->init) {
1611 ret = aux_dev->init(&rtd->codec->dapm); 1635 ret = aux_dev->init(snd_soc_component_get_dapm(rtd->component));
1612 if (ret < 0) { 1636 if (ret < 0) {
1613 dev_err(card->dev, "ASoC: failed to init %s: %d\n", 1637 dev_err(card->dev, "ASoC: failed to init %s: %d\n",
1614 aux_dev->name, ret); 1638 aux_dev->name, ret);
@@ -1622,7 +1646,7 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1622static void soc_remove_aux_dev(struct snd_soc_card *card, int num) 1646static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
1623{ 1647{
1624 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; 1648 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1625 struct snd_soc_codec *codec = rtd->codec; 1649 struct snd_soc_component *component = rtd->component;
1626 1650
1627 /* unregister the rtd device */ 1651 /* unregister the rtd device */
1628 if (rtd->dev_registered) { 1652 if (rtd->dev_registered) {
@@ -1631,8 +1655,8 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
1631 rtd->dev_registered = 0; 1655 rtd->dev_registered = 0;
1632 } 1656 }
1633 1657
1634 if (codec && codec->component.probed) 1658 if (component && component->probed)
1635 soc_remove_component(&codec->component); 1659 soc_remove_component(component);
1636} 1660}
1637 1661
1638static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) 1662static int snd_soc_init_codec_cache(struct snd_soc_codec *codec)