summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorVijay Mali <vmali@nvidia.com>2010-02-10 17:40:27 +0530
committerVijay Mali <vmali@nvidia.com>2010-02-11 14:33:57 +0530
commit89664389b33a8560bc194386d1a2123aa905616e (patch)
tree1fae74779a5d1790ee2e61fd07abf32141d175f4 /sound
parent423c5318facfff78e1351bf64e9abacd1f0d8f84 (diff)
Removing audio codec dependency from ALSA SoC driver
Added stub audio codec in alsa soc driver Removing platform dependent source files. ALSA driver is not doing audio codec initilization. It happens in audiofx. Got rid of unwanted I2C prints which were coming from wm8753 reg_write function. For bug 650664 Getting error while booting NvRmI2Ctransaction Failed:No I2C
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/Kconfig21
-rw-r--r--sound/soc/tegra/Makefile4
-rw-r--r--sound/soc/tegra/tegra_codec_rpc.c186
-rw-r--r--sound/soc/tegra/tegra_harmony.c181
-rw-r--r--sound/soc/tegra/tegra_soc_audio.c (renamed from sound/soc/tegra/tegra_whistler.c)40
5 files changed, 207 insertions, 225 deletions
diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index e41122bd05dd..db522f3f8265 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -3,6 +3,7 @@ config TEGRA_SND_SOC
depends on ARCH_TEGRA
select TEGRA_PCM
select TEGRA_I2S
+ select TEGRA_GENERIC_CODEC
help
Say Y to support ALSA SoC for TEGRA
@@ -14,20 +15,6 @@ config TEGRA_I2S
depends on TEGRA_SND_SOC
tristate "Tegra I2S"
-config TEGRA_SND_WHISTLER
- tristate "SoC alsa driver for whistler"
- depends on TEGRA_SND_SOC && TEGRA_ODM_WHISTLER
- select SND_SOC_WM8753
-
-config SND_SOC_WM8753
- depends on TEGRA_SND_WHISTLER
- tristate "audio codec WM8753"
-
-config TEGRA_SND_HARMONY
- tristate "SoC alsa driver for harmony"
- depends on TEGRA_SND_SOC && TEGRA_ODM_HARMONY
- select SND_SOC_WM8903
-
-config SND_SOC_WM8903
- depends on TEGRA_SND_HARMONY
- tristate "audio codec WM8903"
+config TEGRA_GENERIC_CODEC
+ depends on TEGRA_SND_SOC
+ tristate "Tegra Generic Audio Codec"
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 53665b7552df..81ef7784d5de 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -1,4 +1,4 @@
obj-$(CONFIG_TEGRA_PCM) += tegra_pcm_rpc.o
obj-$(CONFIG_TEGRA_I2S) += tegra_i2s.o tegra_transport.o
-obj-$(CONFIG_TEGRA_SND_WHISTLER) += tegra_whistler.o
-obj-$(CONFIG_TEGRA_SND_HARMONY) += tegra_harmony.o
+obj-$(CONFIG_TEGRA_GENERIC_CODEC) += tegra_soc_audio.o
+obj-$(CONFIG_TEGRA_GENERIC_CODEC) += tegra_codec_rpc.o \ No newline at end of file
diff --git a/sound/soc/tegra/tegra_codec_rpc.c b/sound/soc/tegra/tegra_codec_rpc.c
new file mode 100644
index 000000000000..0e9535bd7d26
--- /dev/null
+++ b/sound/soc/tegra/tegra_codec_rpc.c
@@ -0,0 +1,186 @@
+/*
+ * sound/soc/tegra/tegra_codec_rpc.c
+ *
+ * ALSA SOC driver for NVIDIA Tegra SoCs
+ *
+ * Copyright (C) 2010 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <sound/soc.h>
+#include <sound/pcm.h>
+#include <sound/initval.h>
+
+
+#define CODEC_SAMPLE_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
+ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
+ SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
+ SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
+
+#define CODEC_SAMPLE_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
+ SNDRV_PCM_FMTBIT_S20_3LE |\
+ SNDRV_PCM_FMTBIT_S24_LE)
+
+static int tegra_generic_codec_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+ return 0;
+}
+
+static int tegra_generic_codec_mute(struct snd_soc_dai *dai, int mute)
+{
+ return 0;
+}
+
+static int tegra_generic_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
+ unsigned int fmt)
+{
+ return 0;
+}
+
+static int tegra_generic_codec_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
+ int div_id, int div)
+{
+ return 0;
+}
+
+static int tegra_generic_codec_set_dai_pll(struct snd_soc_dai *codec_dai,
+ int pll_id, unsigned int freq_in, unsigned int freq_out)
+{
+ return 0;
+}
+
+static int tegra_generic_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai,
+ int clk_id, unsigned int freq, int dir)
+{
+ return 0;
+}
+
+struct snd_soc_dai dit_stub_dai = {
+ .name = "tegra-codec-rpc",
+ .playback = {
+ .stream_name = "Playback",
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = CODEC_SAMPLE_RATES,
+ .formats = CODEC_SAMPLE_FORMATS,
+ },
+ .capture = {
+ .stream_name = "Capture",
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = CODEC_SAMPLE_RATES,
+ .formats = CODEC_SAMPLE_FORMATS,
+ },
+ .ops = {
+ .hw_params = tegra_generic_codec_hw_params,
+ .digital_mute = tegra_generic_codec_mute,
+ .set_fmt = tegra_generic_codec_set_dai_fmt,
+ .set_clkdiv = tegra_generic_codec_set_dai_clkdiv,
+ .set_pll = tegra_generic_codec_set_dai_pll,
+ .set_sysclk = tegra_generic_codec_set_dai_sysclk,
+ },
+};
+EXPORT_SYMBOL_GPL(dit_stub_dai);
+
+static int __init dit_modinit(void)
+{
+ return snd_soc_register_dai(&dit_stub_dai);
+}
+
+static void __exit dit_exit(void)
+{
+ snd_soc_unregister_dai(&dit_stub_dai);
+}
+
+module_init(dit_modinit);
+module_exit(dit_exit);
+
+static int codec_soc_probe(struct platform_device *pdev)
+{
+ struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ struct snd_soc_codec *codec;
+ int ret = 0;
+
+ socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
+ if (!socdev->codec)
+ return -ENOMEM;
+
+ codec = socdev->codec;
+ mutex_init(&codec->mutex);
+
+ codec->name = "tegra-generic-codec";
+ codec->owner = THIS_MODULE;
+ codec->dai = &dit_stub_dai;
+ codec->num_dai = 1;
+ codec->write = NULL;
+ codec->read = NULL;
+ INIT_LIST_HEAD(&codec->dapm_widgets);
+ INIT_LIST_HEAD(&codec->dapm_paths);
+ /* Register PCMs. */
+ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
+ if (ret < 0) {
+ printk(KERN_ERR "codec: failed to create pcms\n");
+ goto pcm_err;
+ }
+ /* Register Card. */
+ ret = snd_soc_init_card(socdev);
+ if (ret < 0) {
+ printk(KERN_ERR "codec: failed to register card\n");
+ goto card_err;
+ }
+
+ return ret;
+
+card_err:
+ snd_soc_free_pcms(socdev);
+pcm_err:
+ kfree(socdev->codec);
+
+ return ret;
+}
+
+static int codec_soc_remove(struct platform_device *pdev)
+{
+ struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ struct snd_soc_codec *codec = socdev->codec;
+
+ if (!codec)
+ return 0;
+
+ snd_soc_free_pcms(socdev);
+ kfree(socdev->codec);
+
+ return 0;
+}
+
+#define codec_soc_suspend NULL
+#define codec_soc_resume NULL
+
+struct snd_soc_codec_device soc_codec_dev_tegra_generic_codec = {
+ .probe = codec_soc_probe,
+ .remove = codec_soc_remove,
+ .suspend = codec_soc_suspend,
+ .resume = codec_soc_resume,
+};
+EXPORT_SYMBOL_GPL(soc_codec_dev_tegra_generic_codec);
+
+/* Module information */
+MODULE_DESCRIPTION("Tegra Codec RPC Interface");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/tegra/tegra_harmony.c b/sound/soc/tegra/tegra_harmony.c
deleted file mode 100644
index 8e6bc97bf5e8..000000000000
--- a/sound/soc/tegra/tegra_harmony.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * sound/soc/tegra/tegra_harmony.c
- *
- * ALSA SOC driver for NVIDIA Tegra SoCs
- *
- * Copyright (C) 2010 NVIDIA Corporation
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/i2c.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <sound/tlv.h>
-#include <linux/clk.h>
-
-#include <asm/mach-types.h>
-#include <asm/hardware/scoop.h>
-#include <linux/io.h>
-#include "nvodm_query_discovery.h"
-
-#include "../codecs/wm8903.h"
-#include "../codecs/wm8753.h"
-
-#include "tegra_transport.h"
-
-static struct platform_device *tegra_snd_device;
-NvU64 codec_guid;
-
-#define NVODM_CODEC_MAX_CLOCKS 3
-
-static unsigned int clock_frequencies[NVODM_CODEC_MAX_CLOCKS];
-
-static int set_clock_source_on_codec(NvU64 codec_guid,int IsEnable)
-{
- const NvOdmPeripheralConnectivity *p_connectivity = NULL;
- unsigned int clock_instances[NVODM_CODEC_MAX_CLOCKS];
- unsigned int num_clocks;
-
- p_connectivity = NvOdmPeripheralGetGuid(codec_guid);
- if (p_connectivity == NULL)
- return NV_FALSE;
-
- if (IsEnable) {
- if (!NvOdmExternalClockConfig(codec_guid, NV_FALSE,
- clock_instances,
- clock_frequencies, &num_clocks))
- return NV_FALSE;
- } else {
- if (!NvOdmExternalClockConfig(codec_guid,
- NV_TRUE,
- clock_instances,
- clock_frequencies,
- &num_clocks));
- return NV_FALSE;
- }
- return NV_TRUE;
-}
-
-static int tegra_harmony_hifi_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
-{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
- int err;
-
- err = snd_soc_dai_set_fmt(codec_dai,
- SND_SOC_DAIFMT_I2S | \
- SND_SOC_DAIFMT_NB_IF | \
- SND_SOC_DAIFMT_CBS_CFS);
- if (err < 0) {
- return err;
- }
-
- err = snd_soc_dai_set_sysclk(codec_dai,
- 0,
- clock_frequencies[0]*1000,
- SND_SOC_CLOCK_IN);
-
- if (err<0) {
- return err;
- }
- return 0;
-}
-
-static struct snd_soc_ops tegra_harmony_hifi_ops = {
- .hw_params = tegra_harmony_hifi_hw_params,
-};
-
-static int tegra_wm8903_init(struct snd_soc_codec *codec)
-{
- return 0;
-}
-
-extern struct snd_soc_dai tegra_i2s_rpc_dai;
-extern struct snd_soc_platform tegra_soc_platform;
-
-static struct snd_soc_dai_link tegra_harmony_dai = {
- /* Hifi Playback - for similatious use with voice below */
- .name = "WM8903",
- .stream_name = "WM8903 HiFi",
- .cpu_dai = &tegra_i2s_rpc_dai,
- .codec_dai = &wm8903_dai,
- .init = tegra_wm8903_init,
- .ops = &tegra_harmony_hifi_ops,
-};
-
-static struct snd_soc_card tegra_harmony = {
- .name = "tegra",
- .platform = &tegra_soc_platform,
- .dai_link = &tegra_harmony_dai,
- .num_links = 1,
-};
-
-struct harmony_setup_data {
- int i2c_bus;
- unsigned short i2c_address;
-};
-
-static struct snd_soc_device tegra_harmony_snd_devdata = {
- .card = &tegra_harmony,
- .codec_dev = &soc_codec_dev_wm8903,
-};
-
-static int __init tegra_soc_init(void)
-{
- int ret;
- tegra_snd_device = platform_device_alloc("soc-audio", -1);
- if (!tegra_snd_device)
- return -ENOMEM;
-
- codec_guid = NV_ODM_GUID('w','o','l','f','8','9','0','3');
- platform_set_drvdata(tegra_snd_device, &tegra_harmony_snd_devdata);
- tegra_harmony_snd_devdata.dev = &tegra_snd_device->dev;
-
- ret = platform_device_add(tegra_snd_device);
- if (ret) {
- snd_printk(KERN_ERR "tegra audio device could not be added \n");
- platform_device_put(tegra_snd_device);
- return ret;
- }
-
- set_clock_source_on_codec(codec_guid,NV_TRUE);
- if (ret != 0)
- platform_device_unregister(tegra_snd_device);
-
- return ret;
-}
-
-static void __exit tegra_soc_exit(void)
-{
- set_clock_source_on_codec(codec_guid,0);
- platform_device_unregister(tegra_snd_device);
-}
-
-module_init(tegra_soc_init);
-module_exit(tegra_soc_exit);
-
-/* Module information */
-MODULE_DESCRIPTION("Tegra SoC Sound");
-MODULE_LICENSE("GPL");
diff --git a/sound/soc/tegra/tegra_whistler.c b/sound/soc/tegra/tegra_soc_audio.c
index bed84bb5b3f0..951920df4844 100644
--- a/sound/soc/tegra/tegra_whistler.c
+++ b/sound/soc/tegra/tegra_soc_audio.c
@@ -1,5 +1,5 @@
/*
- * sound/soc/tegra/tegra_harmony.c
+ * sound/soc/tegra/tegra_whistler.c
*
* ALSA SOC driver for NVIDIA Tegra SoCs
*
@@ -37,9 +37,18 @@
#include <asm/hardware/scoop.h>
#include <linux/io.h>
#include "nvodm_query_discovery.h"
-#include "../codecs/wm8753.h"
#include "tegra_transport.h"
+struct codec_setup_data {
+ unsigned dem0_pin;
+ unsigned dem1_pin;
+ unsigned pdad_pin;
+ unsigned pdda_pin;
+};
+
+extern struct snd_soc_codec_device soc_codec_dev_tegra_generic_codec;
+extern struct snd_soc_dai dit_stub_dai;
+
static struct platform_device *tegra_snd_device;
NvU64 codec_guid;
@@ -84,18 +93,6 @@ static int tegra_whistler_hifi_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
return ret;
- /* set the codec system clock for DAC and ADC */
- ret = snd_soc_dai_set_sysclk(codec_dai,
- WM8753_MCLK,
- clock_frequencies[0] * 1000,
- SND_SOC_CLOCK_IN);
- if (ret < 0)
- return ret;
- /* Disabling use of PLL1 since we are using only hifi for now
- We may need it when we use voice */
- ret = snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0);
- if (ret < 0)
- return ret;
return 0;
}
@@ -113,11 +110,10 @@ extern struct snd_soc_dai tegra_i2s_rpc_dai;
extern struct snd_soc_platform tegra_soc_platform;
static struct snd_soc_dai_link tegra_whistler_dai = {
- /* Hifi Playback only for the time being */
- .name = "WM8753",
- .stream_name = "WM8753 HiFi",
+ .name = "tegra-generic-codec",
+ .stream_name = "tegra-codec-rpc",
.cpu_dai = &tegra_i2s_rpc_dai,
- .codec_dai = &wm8753_dai[WM8753_DAI_HIFI],
+ .codec_dai = &dit_stub_dai,
.init = tegra_wm8753_init,
.ops = &tegra_whistler_hifi_ops,
};
@@ -129,15 +125,9 @@ static struct snd_soc_card tegra_whistler = {
.num_links = 1,
};
-static struct wm8753_setup_data whistler_setup_data = {
- .i2c_bus = WHISTLER_CODEC_BUS,
- .i2c_address = WHISTLER_CODEC_ADDRESS,
-};
-
static struct snd_soc_device tegra_whistler_snd_devdata = {
.card = &tegra_whistler,
- .codec_dev = &soc_codec_dev_wm8753,
- .codec_data = &whistler_setup_data,
+ .codec_dev = &soc_codec_dev_tegra_generic_codec,
};
static int __init tegra_soc_init(void)