summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorVinod G <vinodg@nvidia.com>2011-03-10 15:31:44 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-04-26 15:53:29 -0700
commitdce9a2554a02c53c3ede93f9e2254a3ae2cddbe9 (patch)
treea02c3cc8d8eb7f8031fcdbe06cbabe17adee4a45 /sound
parentda8e1205b98246ded57fe10bba2632d59d202f42 (diff)
arm: tegra: Adding macro to support multiple dais
Macros are added to support multiple dais in the code Original-Change-Id: I2cf39faec57af5dd0170311773f77b1fa4f984d4 Reviewed-on: http://git-master/r/22465 Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com> Tested-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com> Change-Id: I4e04ef5bfe9ace31445ebaa94efa4aab02fd74cd
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/tegra_generic_codec.c90
-rw-r--r--sound/soc/tegra/tegra_i2s.c72
-rw-r--r--sound/soc/tegra/tegra_soc_wm8753.c46
-rw-r--r--sound/soc/tegra/tegra_soc_wm8903.c54
4 files changed, 126 insertions, 136 deletions
diff --git a/sound/soc/tegra/tegra_generic_codec.c b/sound/soc/tegra/tegra_generic_codec.c
index ad8209648de8..9afb910b5162 100644
--- a/sound/soc/tegra/tegra_generic_codec.c
+++ b/sound/soc/tegra/tegra_generic_codec.c
@@ -74,51 +74,47 @@ static struct snd_soc_dai_ops tegra_generic_codec_stub_ops = {
.set_sysclk = tegra_generic_codec_set_dai_sysclk,
};
+#define TEGRA_CREATE_GENERIC_CODEC_DAI(xname, link_id, \
+ ch_min, ch_max, sample_rates) \
+{ \
+ .name = xname, \
+ .id = (link_id), \
+ .playback = { \
+ .stream_name = "Playback", \
+ .channels_min = (ch_min), \
+ .channels_max = (ch_max), \
+ .rates = (sample_rates), \
+ .formats = SNDRV_PCM_FMTBIT_S16_LE, \
+ }, \
+ .capture = { \
+ .stream_name = "Capture", \
+ .channels_min = (ch_min), \
+ .channels_max = (ch_max), \
+ .rates = (sample_rates), \
+ .formats = SNDRV_PCM_FMTBIT_S16_LE, \
+ }, \
+ .ops = &tegra_generic_codec_stub_ops, \
+}
+
struct snd_soc_dai tegra_generic_codec_dai[] = {
- {
- .name = "tegra_generic_voice_codec",
- .id = 0,
- .playback = {
- .stream_name = "Playback",
- .channels_min = 1,
- .channels_max = 1,
- .rates = TEGRA_VOICE_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .capture = {
- .stream_name = "Capture",
- .channels_min = 1,
- .channels_max = 1,
- .rates = TEGRA_VOICE_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .ops = &tegra_generic_codec_stub_ops,
- },
- {
- .name = "tegra_generic_spdif_codec",
- .id = 1,
- .playback = {
- .stream_name = "Playback",
- .channels_min = 2,
- .channels_max = 2,
- .rates = TEGRA_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .capture = {
- .stream_name = "Capture",
- .channels_min = 2,
- .channels_max = 2,
- .rates = TEGRA_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .ops = &tegra_generic_codec_stub_ops,
- }
+#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
+ TEGRA_CREATE_GENERIC_CODEC_DAI("tegra_generic_voice_codec",
+ 0, 1, 1, TEGRA_VOICE_SAMPLE_RATES),
+ TEGRA_CREATE_GENERIC_CODEC_DAI("tegra_generic_spdif_codec",
+ 1, 1, 1, TEGRA_SAMPLE_RATES),
+#else
+ TEGRA_CREATE_GENERIC_CODEC_DAI("tegra_generic_BB_codec",
+ 0, 1, 1, TEGRA_VOICE_SAMPLE_RATES),
+ TEGRA_CREATE_GENERIC_CODEC_DAI("tegra_generic_BT_codec",
+ 1, 1, 1, TEGRA_VOICE_SAMPLE_RATES),
+#endif
};
+
EXPORT_SYMBOL_GPL(tegra_generic_codec_dai);
static int generic_codec_init(struct platform_device *pdev)
{
- int i, ret = 0;
+ int i = 0, ret = 0;
tegra_generic_codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
if (!tegra_generic_codec)
@@ -145,7 +141,8 @@ static int generic_codec_init(struct platform_device *pdev)
goto codec_err;
}
- ret = snd_soc_register_dais(tegra_generic_codec_dai, ARRAY_SIZE(tegra_generic_codec_dai));
+ ret = snd_soc_register_dais(tegra_generic_codec_dai,
+ ARRAY_SIZE(tegra_generic_codec_dai));
if (ret != 0) {
pr_err("codec: failed to register dais\n");
goto dai_err;
@@ -164,18 +161,20 @@ codec_err:
static int generic_codec_remove(struct platform_device *pdev)
{
- int i;
+ int i = 0;
if (!tegra_generic_codec)
return 0;
- snd_soc_unregister_dais(tegra_generic_codec_dai, ARRAY_SIZE(tegra_generic_codec_dai));
+ snd_soc_unregister_dais(tegra_generic_codec_dai,
+ ARRAY_SIZE(tegra_generic_codec_dai));
snd_soc_unregister_codec(tegra_generic_codec);
- kfree(tegra_generic_codec);
- tegra_generic_codec = NULL;
for (i = 0; i < tegra_generic_codec->num_dai; i++)
tegra_generic_codec_dai[i].dev = NULL;
+ kfree(tegra_generic_codec);
+ tegra_generic_codec = NULL;
+
return 0;
}
@@ -184,7 +183,8 @@ static int __init tegra_generic_codec_init(void)
int ret = 0;
tegra_generic_codec_dev =
- platform_device_register_simple("tegra_generic_codec", -1, NULL, 0);
+ platform_device_register_simple("tegra_generic_codec",
+ -1, NULL, 0);
if (!tegra_generic_codec_dev)
return -ENOMEM;
diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index cb2904608697..5c2d5b40a10e 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -375,54 +375,39 @@ static struct snd_soc_dai_ops tegra_i2s_dai_ops = {
.set_sysclk = tegra_i2s_set_dai_sysclk,
};
+#define TEGRA_I2S_CREATE_DAI(link_id, ch_min, ch_max, sample_rates) \
+{ \
+ .name = "tegra-i2s-"#link_id, \
+ .id = (link_id), \
+ .probe = tegra_i2s_probe, \
+ .suspend = tegra_i2s_suspend, \
+ .resume = tegra_i2s_resume, \
+ .playback = { \
+ .channels_min = (ch_min), \
+ .channels_max = (ch_max), \
+ .rates = (sample_rates), \
+ .formats = SNDRV_PCM_FMTBIT_S16_LE, \
+ }, \
+ .capture = { \
+ .channels_min = (ch_min), \
+ .channels_max = (ch_max), \
+ .rates = (sample_rates), \
+ .formats = SNDRV_PCM_FMTBIT_S16_LE, \
+ }, \
+ .ops = &tegra_i2s_dai_ops, \
+}
+
struct snd_soc_dai tegra_i2s_dai[] = {
- {
- .name = "tegra-i2s-1",
#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
- .id = 0,
+ TEGRA_I2S_CREATE_DAI(0, 1, 2, TEGRA_SAMPLE_RATES),
+ TEGRA_I2S_CREATE_DAI(1, 1, 2, TEGRA_SAMPLE_RATES),
#else
- .id = 1,
-#endif
- .probe = tegra_i2s_probe,
- .suspend = tegra_i2s_suspend,
- .resume = tegra_i2s_resume,
- .playback = {
- .channels_min = 1,
- .channels_max = 2,
- .rates = TEGRA_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .capture = {
- .channels_min = 1,
- .channels_max = 2,
- .rates = TEGRA_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .ops = &tegra_i2s_dai_ops,
- },
-#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
- {
- .name = "tegra-i2s-2",
- .id = 1,
- .probe = tegra_i2s_probe,
- .suspend = tegra_i2s_suspend,
- .resume = tegra_i2s_resume,
- .playback = {
- .channels_min = 1,
- .channels_max = 2,
- .rates = TEGRA_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .capture = {
- .channels_min = 1,
- .channels_max = 2,
- .rates = TEGRA_SAMPLE_RATES,
- .formats = SNDRV_PCM_FMTBIT_S16_LE,
- },
- .ops = &tegra_i2s_dai_ops,
- },
+ TEGRA_I2S_CREATE_DAI(1, 2, 2, TEGRA_SAMPLE_RATES),
+ TEGRA_I2S_CREATE_DAI(2, 1, 2, TEGRA_SAMPLE_RATES),
+ TEGRA_I2S_CREATE_DAI(3, 1, 2, TEGRA_SAMPLE_RATES),
#endif
};
+
EXPORT_SYMBOL_GPL(tegra_i2s_dai);
static int tegra_i2s_driver_probe(struct platform_device *pdev)
@@ -508,6 +493,7 @@ static int tegra_i2s_driver_probe(struct platform_device *pdev)
i2s_configure(info);
+
for (i = 0; i < ARRAY_SIZE(tegra_i2s_dai); i++) {
if (tegra_i2s_dai[i].id == pdev->id) {
tegra_i2s_dai[i].dev = &pdev->dev;
diff --git a/sound/soc/tegra/tegra_soc_wm8753.c b/sound/soc/tegra/tegra_soc_wm8753.c
index b285e6f82b33..613a7fb78f86 100644
--- a/sound/soc/tegra/tegra_soc_wm8753.c
+++ b/sound/soc/tegra/tegra_soc_wm8753.c
@@ -687,31 +687,29 @@ failed:
return ret;
}
+#define TEGRA_CREATE_SOC_DAI_LINK(xname, xstreamname, \
+ xcpudai, xcodecdai, xops) \
+{ \
+ .name = xname, \
+ .stream_name = xstreamname, \
+ .cpu_dai = xcpudai, \
+ .codec_dai = xcodecdai, \
+ .init = tegra_codec_init, \
+ .ops = xops, \
+}
+
static struct snd_soc_dai_link tegra_soc_dai[] = {
- {
- .name = "WM8753",
- .stream_name = "WM8753 HiFi",
- .cpu_dai = &tegra_i2s_dai[0],
- .codec_dai = &wm8753_dai[WM8753_DAI_HIFI],
- .init = tegra_codec_init,
- .ops = &tegra_hifi_ops,
- },
- {
- .name = "Tegra-generic",
- .stream_name = "Tegra Generic Voice",
- .cpu_dai = &tegra_i2s_dai[1],
- .codec_dai = &tegra_generic_codec_dai[0],
- .init = tegra_codec_init,
- .ops = &tegra_voice_ops,
- },
- {
- .name = "Tegra-spdif",
- .stream_name = "Tegra Spdif",
- .cpu_dai = &tegra_spdif_dai,
- .codec_dai = &tegra_generic_codec_dai[1],
- .init = tegra_codec_init,
- .ops = &tegra_spdif_ops,
- },
+#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
+ TEGRA_CREATE_SOC_DAI_LINK("WM8753", "WM8753 HiFi",
+ &tegra_i2s_dai[0], &wm8753_dai[WM8753_DAI_HIFI],
+ &tegra_hifi_ops),
+ TEGRA_CREATE_SOC_DAI_LINK("Tegra-generic", "Tegra Generic Voice",
+ &tegra_i2s_dai[1], &tegra_generic_codec_dai[0],
+ &tegra_voice_ops),
+ TEGRA_CREATE_SOC_DAI_LINK("Tegra-spdif", "Tegra Spdif",
+ &tegra_spdif_dai, &tegra_generic_codec_dai[1],
+ &tegra_spdif_ops),
+#endif
};
static struct tegra_audio_data audio_data = {
diff --git a/sound/soc/tegra/tegra_soc_wm8903.c b/sound/soc/tegra/tegra_soc_wm8903.c
index 1c99b768e3ee..923ab38eca2f 100644
--- a/sound/soc/tegra/tegra_soc_wm8903.c
+++ b/sound/soc/tegra/tegra_soc_wm8903.c
@@ -485,32 +485,38 @@ static int tegra_codec_init(struct snd_soc_codec *codec)
return err;
}
+
+#define TEGRA_CREATE_SOC_DAI_LINK(xname, xstreamname, \
+ xcpudai, xcodecdai, xops) \
+{ \
+ .name = xname, \
+ .stream_name = xstreamname, \
+ .cpu_dai = xcpudai, \
+ .codec_dai = xcodecdai, \
+ .init = tegra_codec_init, \
+ .ops = xops, \
+}
+
static struct snd_soc_dai_link tegra_soc_dai[] = {
- {
- .name = "WM8903",
- .stream_name = "WM8903 HiFi",
- .cpu_dai = &tegra_i2s_dai[0],
- .codec_dai = &wm8903_dai,
- .init = tegra_codec_init,
- .ops = &tegra_hifi_ops,
- },
+ TEGRA_CREATE_SOC_DAI_LINK("WM8903", "WM8903 HiFi",
+ &tegra_i2s_dai[0], &wm8903_dai, &tegra_hifi_ops),
+
#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
- {
- .name = "Tegra-generic",
- .stream_name = "Tegra Generic Voice",
- .cpu_dai = &tegra_i2s_dai[1],
- .codec_dai = &tegra_generic_codec_dai[0],
- .init = tegra_codec_init,
- .ops = &tegra_voice_ops,
- },
- {
- .name = "Tegra-spdif",
- .stream_name = "Tegra Spdif",
- .cpu_dai = &tegra_spdif_dai,
- .codec_dai = &tegra_generic_codec_dai[1],
- .init = tegra_codec_init,
- .ops = &tegra_spdif_ops,
- },
+ TEGRA_CREATE_SOC_DAI_LINK("Tegra-generic", "Tegra Generic Voice",
+ &tegra_i2s_dai[1], &tegra_generic_codec_dai[0],
+ &tegra_voice_ops),
+ TEGRA_CREATE_SOC_DAI_LINK("Tegra-spdif", "Tegra Spdif",
+ &tegra_spdif_dai, &tegra_generic_codec_dai[1],
+ &tegra_spdif_ops),
+#else
+/* FIXME: enabled once these device are enumerated
+ TEGRA_CREATE_SOC_DAI_LINK("Tegra-generic-0", "Tegra BB Voice",
+ &tegra_i2s_dai[2], &tegra_generic_codec_dai[0],
+ &tegra_voice_ops),
+ TEGRA_CREATE_SOC_DAI_LINK("Tegra-generic-1", "Tegra BT Voice",
+ &tegra_i2s_dai[3], &tegra_generic_codec_dai[1],
+ &tegra_voice_ops),
+*/
#endif
};