diff options
| author | Evan Wilson <evan@oliodevices.com> | 2015-02-27 11:59:16 -0800 |
|---|---|---|
| committer | Evan Wilson <evan@oliodevices.com> | 2015-02-27 11:59:16 -0800 |
| commit | f2c764c7e49a49608da72320bf1fd58a11249181 (patch) | |
| tree | ac11c5889c54d891d39a975177b6721ff5fcb6db | |
| parent | 942f11ae6b97f2972d78097970c4b243fb48e476 (diff) | |
| download | olio-linux-3.10-f2c764c7e49a49608da72320bf1fd58a11249181.tar.xz olio-linux-3.10-f2c764c7e49a49608da72320bf1fd58a11249181.zip | |
alsa: soc: omap3h1: Adding microphone support for omap3h1 using the admp441 digital mic.
Note: The generic dmic codec is now changed to only support 24-bit microphones.
This may break functionality for other dmics
Change-Id: Id5006e6932de1878933a2691b7f1e90490766670
| -rw-r--r-- | arch/arm/mach-omap2/board-omap3h1.c | 9 | ||||
| -rw-r--r-- | sound/soc/codecs/dmic.c | 3 | ||||
| -rw-r--r-- | sound/soc/omap/Kconfig | 8 | ||||
| -rw-r--r-- | sound/soc/omap/Makefile | 2 | ||||
| -rw-r--r-- | sound/soc/omap/omap3h1.c | 147 |
5 files changed, 168 insertions, 1 deletions
diff --git a/arch/arm/mach-omap2/board-omap3h1.c b/arch/arm/mach-omap2/board-omap3h1.c index 6a1d1f3c99f..416f2c3f6be 100644 --- a/arch/arm/mach-omap2/board-omap3h1.c +++ b/arch/arm/mach-omap2/board-omap3h1.c @@ -190,6 +190,11 @@ static struct platform_device bcm20702_bluetooth_device = { .id = -1, }; +static struct platform_device omap3h1_dmic_codec = { + .name = "dmic-codec", + .id = -1, +}; + /* --------------------------------------------------------------------------- */ /* USB settings */ @@ -290,6 +295,8 @@ static struct regulator_init_data tps65910_vibrator = { .consumer_supplies = tps65910_vibrator_supply, }; + + /* --------------------------------------------------------------------------- */ @@ -454,6 +461,7 @@ static struct tps65910_board omap3h1_tps65910_pdata = { .tps65910_pmic_init_data[TPS65910_REG_VDAC] = &tps65910_dummy, .tps65910_pmic_init_data[TPS65910_REG_VAUX1] = &tps65910_dummy, /* 2v85 */ .tps65910_pmic_init_data[TPS65910_REG_VDD3] = &tps65910_dummy, + }; static struct i2c_board_info __initdata omap3h1_i2c1_board_info[] = { @@ -516,6 +524,7 @@ static struct platform_device *omap3h1_devices[] __initdata = { &omap3h1_vbat, &bcm20702_bluetooth_device, &nop_phy_device, + &omap3h1_dmic_codec, }; #ifdef CONFIG_OMAP_MUX diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index 66967ba6f75..12f74fb3de7 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -32,11 +32,12 @@ static struct snd_soc_dai_driver dmic_dai = { .capture = { .stream_name = "Capture", .channels_min = 1, - .channels_max = 8, + .channels_max = 2, .rates = SNDRV_PCM_RATE_CONTINUOUS, .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE, + .sig_bits = 24 }, }; diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 77157ed6efd..66d98e26a24 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -26,6 +26,14 @@ config SND_OMAP_SOC_MCPDM config SND_OMAP_SOC_HDMI tristate +config SND_OMAP_SOC_OMAP3_H1 + tristate "SoC Audio support for OMAP3 H1 Board" + depends on SND_OMAP_SOC && MACH_OMAP3_H1 + select SND_OMAP_SOC_MCBSP + select SND_SOC_DMIC + help + Say Y if you want to add support for SoC audio on the Olio H1 board. + config SND_OMAP_SOC_N810 tristate "SoC Audio support for Nokia N810" depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 7272bf4da6d..15d3e0105ef 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile @@ -21,6 +21,7 @@ snd-soc-omap-c55-objs := omap-c55audio.o snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o snd-soc-omap-twl4030-objs := omap-twl4030.o snd-soc-omap3pandora-objs := omap3pandora.o +snd-soc-omap3h1-objs := omap3h1.o snd-soc-omap-hdmi-card-objs := omap-hdmi-card.o obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o @@ -33,4 +34,5 @@ obj-$(CONFIG_SND_OMAP_SOC_C55) += snd-soc-omap-c55.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_TWL4030) += snd-soc-omap-twl4030.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o +obj-$(CONFIG_SND_OMAP_SOC_OMAP3_H1) += snd-soc-omap3h1.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_HDMI) += snd-soc-omap-hdmi-card.o diff --git a/sound/soc/omap/omap3h1.c b/sound/soc/omap/omap3h1.c new file mode 100644 index 00000000000..179c53d4655 --- /dev/null +++ b/sound/soc/omap/omap3h1.c @@ -0,0 +1,147 @@ +/* + * omap3h1.c -- SoC audio for OMAP3 H1 + * + * Author: Evan Wilson <evan@oliodevices.com> + * + * Adapted from omap3pandora + * Author: Steve Sakoman <steve@sakoman.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#define DEBUG +#include <linux/clk.h> +#include <linux/platform_device.h> +#include <linux/module.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/soc.h> + +#include <asm/mach-types.h> +#include <linux/platform_data/asoc-ti-mcbsp.h> + +#include "omap-mcbsp.h" + +static int omap3h1_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 *cpu_dai = rtd->cpu_dai; + //unsigned int fmt; + int ret = 0; + unsigned int freq; + + //freq = 256 * params_rate(params); + // We are triggering from the 96 MHz FSCK + pr_info("ASoc OMAP3H1: setting system clock to: %d", freq); + ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_FCLK, + 96000000, SND_SOC_CLOCK_OUT); + if (ret < 0) { + printk(KERN_ERR "can't set DMIC cpu system clock\n"); + return ret; + } + + // Set the divider so that our clock rate is ~3KHz, this is about 48KHz sampling frequency on the mic + // (32-bit/channel, 2 channels, 48 Khz sampling) + ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_MCBSP_CLKGDV, 32); + if (ret < 0) { + pr_err("ASoc OMAP3H1: can't set SRG clock divider\n"); + return ret; + } + + return 0; +} + +static struct snd_soc_ops omap3h1_ops = { + .hw_params = omap3h1_hw_params, +}; + +//static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { +// SND_SOC_DAPM_MIC("Digital Mic", NULL), +//}; +// +//static const struct snd_soc_dapm_route dmic_audio_map[] = { +// {"DMic", NULL, "Digital Mic"}, +//}; + +/* Digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link omap3h1_dai = { + .name = "DMIC", + .stream_name = "DMIC Capture", + .cpu_dai_name = "omap-mcbsp.3", + .codec_dai_name = "dmic-hifi", + .platform_name = "omap-pcm-audio", + .codec_name = "dmic-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ops = &omap3h1_ops, +}; + +/* Audio machine driver */ +static struct snd_soc_card snd_soc_omap3h1 = { + .name = "omap3h1", + .owner = THIS_MODULE, + .dai_link = &omap3h1_dai, + .num_links = 1, + +// .dapm_widgets = dmic_dapm_widgets, +// .num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets), +// .dapm_routes = dmic_audio_map, +// .num_dapm_routes = ARRAY_SIZE(dmic_audio_map), +}; + +static struct platform_device *omap3h1_snd_device; + +static int __init omap3h1_soc_init(void) +{ + int ret; + + if (!(machine_is_omap3_h1())) + return -ENODEV; + pr_info("OMAP3 H1 SoC init\n"); + + omap3h1_snd_device = platform_device_alloc("soc-audio", -1); + if (!omap3h1_snd_device) { + printk(KERN_ERR "Platform device allocation failed\n"); + return -ENOMEM; + } + + platform_set_drvdata(omap3h1_snd_device, &snd_soc_omap3h1); + + ret = platform_device_add(omap3h1_snd_device); + if (ret) + goto err1; + + return 0; + +err1: + printk(KERN_ERR "Unable to add platform device\n"); + platform_device_put(omap3h1_snd_device); + + return ret; +} + +static void __exit omap3h1_soc_exit(void) +{ + platform_device_unregister(omap3h1_snd_device); +} + +module_init(omap3h1_soc_init); +module_exit(omap3h1_soc_exit); + +MODULE_AUTHOR("Evan Wilson <evan@oliodevices.com"); +MODULE_DESCRIPTION("ALSA SoC OMAP3 H1"); +MODULE_LICENSE("GPL"); |