diff options
author | Misael Lopez Cruz <misael.lopez@ti.com> | 2014-03-21 11:27:28 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-04-14 15:37:25 -0400 |
commit | 02c9c7b91c2831b7f4e43c9931007e46f856b659 (patch) | |
tree | 9ec19bf37636467c4e418ebcbfbc7b0dcd369d74 | |
parent | 2436a723f3e1fbca517c9318efe9af5ecf7cbcbb (diff) |
ASoC: core: Add function for ac97 codec registration
Add codec registration specific function in preparation
for DAI-multicodec support.
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.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4c0f7dccbd83..42c5835ba92f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1552,14 +1552,15 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | #ifdef CONFIG_SND_SOC_AC97_BUS | 1554 | #ifdef CONFIG_SND_SOC_AC97_BUS |
1555 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | 1555 | static int soc_register_ac97_codec(struct snd_soc_codec *codec, |
1556 | struct snd_soc_dai *codec_dai) | ||
1556 | { | 1557 | { |
1557 | int ret; | 1558 | int ret; |
1558 | 1559 | ||
1559 | /* Only instantiate AC97 if not already done by the adaptor | 1560 | /* Only instantiate AC97 if not already done by the adaptor |
1560 | * for the generic AC97 subsystem. | 1561 | * for the generic AC97 subsystem. |
1561 | */ | 1562 | */ |
1562 | if (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) { | 1563 | if (codec_dai->driver->ac97_control && !codec->ac97_registered) { |
1563 | /* | 1564 | /* |
1564 | * It is possible that the AC97 device is already registered to | 1565 | * It is possible that the AC97 device is already registered to |
1565 | * the device subsystem. This happens when the device is created | 1566 | * the device subsystem. This happens when the device is created |
@@ -1568,28 +1569,38 @@ static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | |||
1568 | * | 1569 | * |
1569 | * In those cases we don't try to register the device again. | 1570 | * In those cases we don't try to register the device again. |
1570 | */ | 1571 | */ |
1571 | if (!rtd->codec->ac97_created) | 1572 | if (!codec->ac97_created) |
1572 | return 0; | 1573 | return 0; |
1573 | 1574 | ||
1574 | ret = soc_ac97_dev_register(rtd->codec); | 1575 | ret = soc_ac97_dev_register(codec); |
1575 | if (ret < 0) { | 1576 | if (ret < 0) { |
1576 | dev_err(rtd->codec->dev, | 1577 | dev_err(codec->dev, |
1577 | "ASoC: AC97 device register failed: %d\n", ret); | 1578 | "ASoC: AC97 device register failed: %d\n", ret); |
1578 | return ret; | 1579 | return ret; |
1579 | } | 1580 | } |
1580 | 1581 | ||
1581 | rtd->codec->ac97_registered = 1; | 1582 | codec->ac97_registered = 1; |
1582 | } | 1583 | } |
1583 | return 0; | 1584 | return 0; |
1584 | } | 1585 | } |
1585 | 1586 | ||
1586 | static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec) | 1587 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) |
1588 | { | ||
1589 | return soc_register_ac97_codec(rtd->codec, rtd->codec_dai); | ||
1590 | } | ||
1591 | |||
1592 | static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) | ||
1587 | { | 1593 | { |
1588 | if (codec->ac97_registered) { | 1594 | if (codec->ac97_registered) { |
1589 | soc_ac97_dev_unregister(codec); | 1595 | soc_ac97_dev_unregister(codec); |
1590 | codec->ac97_registered = 0; | 1596 | codec->ac97_registered = 0; |
1591 | } | 1597 | } |
1592 | } | 1598 | } |
1599 | |||
1600 | static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | ||
1601 | { | ||
1602 | soc_unregister_ac97_codec(rtd->codec); | ||
1603 | } | ||
1593 | #endif | 1604 | #endif |
1594 | 1605 | ||
1595 | static int soc_check_aux_dev(struct snd_soc_card *card, int num) | 1606 | static int soc_check_aux_dev(struct snd_soc_card *card, int num) |
@@ -1888,7 +1899,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
1888 | dev_err(card->dev, | 1899 | dev_err(card->dev, |
1889 | "ASoC: failed to register AC97: %d\n", ret); | 1900 | "ASoC: failed to register AC97: %d\n", ret); |
1890 | while (--i >= 0) | 1901 | while (--i >= 0) |
1891 | soc_unregister_ac97_dai_link(card->rtd[i].codec); | 1902 | soc_unregister_ac97_dai_link(&card->rtd[i]); |
1892 | goto probe_aux_dev_err; | 1903 | goto probe_aux_dev_err; |
1893 | } | 1904 | } |
1894 | } | 1905 | } |
@@ -2324,7 +2335,7 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) | |||
2324 | { | 2335 | { |
2325 | mutex_lock(&codec->mutex); | 2336 | mutex_lock(&codec->mutex); |
2326 | #ifdef CONFIG_SND_SOC_AC97_BUS | 2337 | #ifdef CONFIG_SND_SOC_AC97_BUS |
2327 | soc_unregister_ac97_dai_link(codec); | 2338 | soc_unregister_ac97_codec(codec); |
2328 | #endif | 2339 | #endif |
2329 | kfree(codec->ac97->bus); | 2340 | kfree(codec->ac97->bus); |
2330 | kfree(codec->ac97); | 2341 | kfree(codec->ac97); |