From 7df6f2551f2255f55adab7338a3a1e6594a12f63 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 18 Jan 2012 12:18:23 +0100 Subject: ASoC: omap-dmic: Use core to set the msbits constraint Core can set the msbits constraint in behalf of the dai. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-dmic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 0855c1cfa7f..4dcb5a7e40e 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c @@ -113,12 +113,10 @@ static int omap_dmic_dai_startup(struct snd_pcm_substream *substream, mutex_lock(&dmic->mutex); - if (!dai->active) { - snd_pcm_hw_constraint_msbits(substream->runtime, 0, 32, 24); + if (!dai->active) dmic->active = 1; - } else { + else ret = -EBUSY; - } mutex_unlock(&dmic->mutex); @@ -445,6 +443,7 @@ static struct snd_soc_dai_driver omap_dmic_dai = { .channels_max = 6, .rates = SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, .formats = SNDRV_PCM_FMTBIT_S32_LE, + .sig_bits = 24, }, .ops = &omap_dmic_dai_ops, }; -- cgit v1.2.3 From b4badd4960c9937fcbdcab2a57f0dd7e4ad45c8e Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 18 Jan 2012 12:18:24 +0100 Subject: ASoC: omap-mcpdm: Set 24msbits constraint McPDM internal FIFO is 24 bit wide. From the 32 bit sample 8 bit is discarded. Let application know about this via msbits constraint. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-mcpdm.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 0e25df4fa9e..39705561131 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -419,12 +419,14 @@ static struct snd_soc_dai_driver omap_mcpdm_dai = { .channels_max = 5, .rates = OMAP_MCPDM_RATES, .formats = OMAP_MCPDM_FORMATS, + .sig_bits = 24, }, .capture = { .channels_min = 1, .channels_max = 3, .rates = OMAP_MCPDM_RATES, .formats = OMAP_MCPDM_FORMATS, + .sig_bits = 24, }, .ops = &omap_mcpdm_dai_ops, }; -- cgit v1.2.3 From 8747a6b7d5685ebb64f1ec4d58d9b1969df3e34d Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 7 Dec 2011 15:31:26 +0200 Subject: ASoC: sdp4430: Correct author e-mail address Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/sdp4430.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c index 175ba9a04ed..ceadb137bf4 100644 --- a/sound/soc/omap/sdp4430.c +++ b/sound/soc/omap/sdp4430.c @@ -1,7 +1,7 @@ /* * sdp4430.c -- SoC audio for TI OMAP4430 SDP * - * Author: Misael Lopez Cruz + * Author: Misael Lopez Cruz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -273,7 +273,7 @@ static void __exit sdp4430_soc_exit(void) } module_exit(sdp4430_soc_exit); -MODULE_AUTHOR("Misael Lopez Cruz "); +MODULE_AUTHOR("Misael Lopez Cruz "); MODULE_DESCRIPTION("ALSA SoC SDP4430"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From e15422edd463fbba7f38ffd8a2e2ca8564da1160 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 7 Dec 2011 15:38:38 +0200 Subject: ASoC: OMAP4: Rename the sdp4430 machine driver The same machine driver will support other boards with similar audio configuration (OMAP4, ABE, twl6040). Rename the driver to have more generic name. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/Kconfig | 2 +- sound/soc/omap/Makefile | 4 +- sound/soc/omap/omap-abe-twl6040.c | 279 ++++++++++++++++++++++++++++++++++++++ sound/soc/omap/sdp4430.c | 279 -------------------------------------- 4 files changed, 282 insertions(+), 282 deletions(-) create mode 100644 sound/soc/omap/omap-abe-twl6040.c delete mode 100644 sound/soc/omap/sdp4430.c (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index fb1bf2581ef..4eae92987fe 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -97,7 +97,7 @@ config SND_OMAP_SOC_SDP3430 Say Y if you want to add support for SoC audio on Texas Instruments SDP3430. -config SND_OMAP_SOC_SDP4430 +config SND_OMAP_SOC_OMAP_ABE_TWL6040 tristate "SoC Audio support for Texas Instruments SDP4430" depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP select SND_OMAP_SOC_DMIC diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 1fd723fb559..123ac18303e 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile @@ -20,7 +20,7 @@ snd-soc-overo-objs := overo.o snd-soc-omap3evm-objs := omap3evm.o snd-soc-am3517evm-objs := am3517evm.o snd-soc-sdp3430-objs := sdp3430.o -snd-soc-sdp4430-objs := sdp4430.o +snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o snd-soc-omap3pandora-objs := omap3pandora.o snd-soc-omap3beagle-objs := omap3beagle.o snd-soc-zoom2-objs := zoom2.o @@ -36,7 +36,7 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o -obj-$(CONFIG_SND_OMAP_SOC_SDP4430) += snd-soc-sdp4430.o +obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c new file mode 100644 index 00000000000..ceadb137bf4 --- /dev/null +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -0,0 +1,279 @@ +/* + * sdp4430.c -- SoC audio for TI OMAP4430 SDP + * + * Author: Misael Lopez Cruz + * + * 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 + * + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "omap-dmic.h" +#include "omap-mcpdm.h" +#include "omap-pcm.h" +#include "../codecs/twl6040.h" + +static int sdp4430_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->codec_dai; + int clk_id, freq; + int ret; + + clk_id = twl6040_get_clk_id(rtd->codec); + if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) + freq = 38400000; + else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) + freq = 32768; + else + return -EINVAL; + + /* set the codec mclk */ + ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq, + SND_SOC_CLOCK_IN); + if (ret) { + printk(KERN_ERR "can't set codec system clock\n"); + return ret; + } + return ret; +} + +static struct snd_soc_ops sdp4430_ops = { + .hw_params = sdp4430_hw_params, +}; + +static int sdp4430_dmic_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; + int ret = 0; + + ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_SYSCLK_PAD_CLKS, + 19200000, SND_SOC_CLOCK_IN); + if (ret < 0) { + printk(KERN_ERR "can't set DMIC cpu system clock\n"); + return ret; + } + ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_ABE_DMIC_CLK, 2400000, + SND_SOC_CLOCK_OUT); + if (ret < 0) { + printk(KERN_ERR "can't set DMIC output clock\n"); + return ret; + } + return 0; +} + +static struct snd_soc_ops sdp4430_dmic_ops = { + .hw_params = sdp4430_dmic_hw_params, +}; + +/* Headset jack */ +static struct snd_soc_jack hs_jack; + +/*Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin hs_jack_pins[] = { + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, + { + .pin = "Headset Stereophone", + .mask = SND_JACK_HEADPHONE, + }, +}; + +/* SDP4430 machine DAPM */ +static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { + SND_SOC_DAPM_MIC("Ext Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_HP("Headset Stereophone", NULL), + SND_SOC_DAPM_SPK("Earphone Spk", NULL), + SND_SOC_DAPM_INPUT("FM Stereo In"), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + /* External Mics: MAINMIC, SUBMIC with bias*/ + {"MAINMIC", NULL, "Main Mic Bias"}, + {"SUBMIC", NULL, "Main Mic Bias"}, + {"Main Mic Bias", NULL, "Ext Mic"}, + + /* External Speakers: HFL, HFR */ + {"Ext Spk", NULL, "HFL"}, + {"Ext Spk", NULL, "HFR"}, + + /* Headset Mic: HSMIC with bias */ + {"HSMIC", NULL, "Headset Mic Bias"}, + {"Headset Mic Bias", NULL, "Headset Mic"}, + + /* Headset Stereophone (Headphone): HSOL, HSOR */ + {"Headset Stereophone", NULL, "HSOL"}, + {"Headset Stereophone", NULL, "HSOR"}, + + /* Earphone speaker */ + {"Earphone Spk", NULL, "EP"}, + + /* Aux/FM Stereo In: AFML, AFMR */ + {"AFML", NULL, "FM Stereo In"}, + {"AFMR", NULL, "FM Stereo In"}, +}; + +static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + int ret, hs_trim; + + /* + * Configure McPDM offset cancellation based on the HSOTRIM value from + * twl6040. + */ + hs_trim = twl6040_get_trim_value(codec, TWL6040_TRIM_HSOTRIM); + omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim), + TWL6040_HSF_TRIM_RIGHT(hs_trim)); + + /* Headset jack detection */ + ret = snd_soc_jack_new(codec, "Headset Jack", + SND_JACK_HEADSET, &hs_jack); + if (ret) + return ret; + + ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), + hs_jack_pins); + + if (machine_is_omap_4430sdp()) + twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); + else + snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); + + return ret; +} + +static const struct snd_soc_dapm_widget sdp4430_dmic_dapm_widgets[] = { + SND_SOC_DAPM_MIC("Digital Mic", NULL), +}; + +static const struct snd_soc_dapm_route dmic_audio_map[] = { + {"DMic", NULL, "Digital Mic1 Bias"}, + {"Digital Mic1 Bias", NULL, "Digital Mic"}, +}; + +static int sdp4430_dmic_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dapm_context *dapm = &codec->dapm; + int ret; + + ret = snd_soc_dapm_new_controls(dapm, sdp4430_dmic_dapm_widgets, + ARRAY_SIZE(sdp4430_dmic_dapm_widgets)); + if (ret) + return ret; + + return snd_soc_dapm_add_routes(dapm, dmic_audio_map, + ARRAY_SIZE(dmic_audio_map)); +} + +/* Digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link sdp4430_dai[] = { + { + .name = "TWL6040", + .stream_name = "TWL6040", + .cpu_dai_name = "omap-mcpdm", + .codec_dai_name = "twl6040-legacy", + .platform_name = "omap-pcm-audio", + .codec_name = "twl6040-codec", + .init = sdp4430_twl6040_init, + .ops = &sdp4430_ops, + }, + { + .name = "DMIC", + .stream_name = "DMIC Capture", + .cpu_dai_name = "omap-dmic", + .codec_dai_name = "dmic-hifi", + .platform_name = "omap-pcm-audio", + .codec_name = "dmic-codec", + .init = sdp4430_dmic_init, + .ops = &sdp4430_dmic_ops, + }, +}; + +/* Audio machine driver */ +static struct snd_soc_card snd_soc_sdp4430 = { + .name = "SDP4430", + .owner = THIS_MODULE, + .dai_link = sdp4430_dai, + .num_links = ARRAY_SIZE(sdp4430_dai), + + .dapm_widgets = sdp4430_twl6040_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sdp4430_twl6040_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), +}; + +static struct platform_device *sdp4430_snd_device; + +static int __init sdp4430_soc_init(void) +{ + int ret; + + if (!machine_is_omap_4430sdp()) + return -ENODEV; + printk(KERN_INFO "SDP4430 SoC init\n"); + + sdp4430_snd_device = platform_device_alloc("soc-audio", -1); + if (!sdp4430_snd_device) { + printk(KERN_ERR "Platform device allocation failed\n"); + return -ENOMEM; + } + + platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); + + ret = platform_device_add(sdp4430_snd_device); + if (ret) + goto err; + + return 0; + +err: + printk(KERN_ERR "Unable to add platform device\n"); + platform_device_put(sdp4430_snd_device); + return ret; +} +module_init(sdp4430_soc_init); + +static void __exit sdp4430_soc_exit(void) +{ + platform_device_unregister(sdp4430_snd_device); +} +module_exit(sdp4430_soc_exit); + +MODULE_AUTHOR("Misael Lopez Cruz "); +MODULE_DESCRIPTION("ALSA SoC SDP4430"); +MODULE_LICENSE("GPL"); + diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c deleted file mode 100644 index ceadb137bf4..00000000000 --- a/sound/soc/omap/sdp4430.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * sdp4430.c -- SoC audio for TI OMAP4430 SDP - * - * Author: Misael Lopez Cruz - * - * 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 - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "omap-dmic.h" -#include "omap-mcpdm.h" -#include "omap-pcm.h" -#include "../codecs/twl6040.h" - -static int sdp4430_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->codec_dai; - int clk_id, freq; - int ret; - - clk_id = twl6040_get_clk_id(rtd->codec); - if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) - freq = 38400000; - else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) - freq = 32768; - else - return -EINVAL; - - /* set the codec mclk */ - ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq, - SND_SOC_CLOCK_IN); - if (ret) { - printk(KERN_ERR "can't set codec system clock\n"); - return ret; - } - return ret; -} - -static struct snd_soc_ops sdp4430_ops = { - .hw_params = sdp4430_hw_params, -}; - -static int sdp4430_dmic_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; - int ret = 0; - - ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_SYSCLK_PAD_CLKS, - 19200000, SND_SOC_CLOCK_IN); - if (ret < 0) { - printk(KERN_ERR "can't set DMIC cpu system clock\n"); - return ret; - } - ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_ABE_DMIC_CLK, 2400000, - SND_SOC_CLOCK_OUT); - if (ret < 0) { - printk(KERN_ERR "can't set DMIC output clock\n"); - return ret; - } - return 0; -} - -static struct snd_soc_ops sdp4430_dmic_ops = { - .hw_params = sdp4430_dmic_hw_params, -}; - -/* Headset jack */ -static struct snd_soc_jack hs_jack; - -/*Headset jack detection DAPM pins */ -static struct snd_soc_jack_pin hs_jack_pins[] = { - { - .pin = "Headset Mic", - .mask = SND_JACK_MICROPHONE, - }, - { - .pin = "Headset Stereophone", - .mask = SND_JACK_HEADPHONE, - }, -}; - -/* SDP4430 machine DAPM */ -static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { - SND_SOC_DAPM_MIC("Ext Mic", NULL), - SND_SOC_DAPM_SPK("Ext Spk", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_HP("Headset Stereophone", NULL), - SND_SOC_DAPM_SPK("Earphone Spk", NULL), - SND_SOC_DAPM_INPUT("FM Stereo In"), -}; - -static const struct snd_soc_dapm_route audio_map[] = { - /* External Mics: MAINMIC, SUBMIC with bias*/ - {"MAINMIC", NULL, "Main Mic Bias"}, - {"SUBMIC", NULL, "Main Mic Bias"}, - {"Main Mic Bias", NULL, "Ext Mic"}, - - /* External Speakers: HFL, HFR */ - {"Ext Spk", NULL, "HFL"}, - {"Ext Spk", NULL, "HFR"}, - - /* Headset Mic: HSMIC with bias */ - {"HSMIC", NULL, "Headset Mic Bias"}, - {"Headset Mic Bias", NULL, "Headset Mic"}, - - /* Headset Stereophone (Headphone): HSOL, HSOR */ - {"Headset Stereophone", NULL, "HSOL"}, - {"Headset Stereophone", NULL, "HSOR"}, - - /* Earphone speaker */ - {"Earphone Spk", NULL, "EP"}, - - /* Aux/FM Stereo In: AFML, AFMR */ - {"AFML", NULL, "FM Stereo In"}, - {"AFMR", NULL, "FM Stereo In"}, -}; - -static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - int ret, hs_trim; - - /* - * Configure McPDM offset cancellation based on the HSOTRIM value from - * twl6040. - */ - hs_trim = twl6040_get_trim_value(codec, TWL6040_TRIM_HSOTRIM); - omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim), - TWL6040_HSF_TRIM_RIGHT(hs_trim)); - - /* Headset jack detection */ - ret = snd_soc_jack_new(codec, "Headset Jack", - SND_JACK_HEADSET, &hs_jack); - if (ret) - return ret; - - ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), - hs_jack_pins); - - if (machine_is_omap_4430sdp()) - twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); - else - snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); - - return ret; -} - -static const struct snd_soc_dapm_widget sdp4430_dmic_dapm_widgets[] = { - SND_SOC_DAPM_MIC("Digital Mic", NULL), -}; - -static const struct snd_soc_dapm_route dmic_audio_map[] = { - {"DMic", NULL, "Digital Mic1 Bias"}, - {"Digital Mic1 Bias", NULL, "Digital Mic"}, -}; - -static int sdp4430_dmic_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - int ret; - - ret = snd_soc_dapm_new_controls(dapm, sdp4430_dmic_dapm_widgets, - ARRAY_SIZE(sdp4430_dmic_dapm_widgets)); - if (ret) - return ret; - - return snd_soc_dapm_add_routes(dapm, dmic_audio_map, - ARRAY_SIZE(dmic_audio_map)); -} - -/* Digital audio interface glue - connects codec <--> CPU */ -static struct snd_soc_dai_link sdp4430_dai[] = { - { - .name = "TWL6040", - .stream_name = "TWL6040", - .cpu_dai_name = "omap-mcpdm", - .codec_dai_name = "twl6040-legacy", - .platform_name = "omap-pcm-audio", - .codec_name = "twl6040-codec", - .init = sdp4430_twl6040_init, - .ops = &sdp4430_ops, - }, - { - .name = "DMIC", - .stream_name = "DMIC Capture", - .cpu_dai_name = "omap-dmic", - .codec_dai_name = "dmic-hifi", - .platform_name = "omap-pcm-audio", - .codec_name = "dmic-codec", - .init = sdp4430_dmic_init, - .ops = &sdp4430_dmic_ops, - }, -}; - -/* Audio machine driver */ -static struct snd_soc_card snd_soc_sdp4430 = { - .name = "SDP4430", - .owner = THIS_MODULE, - .dai_link = sdp4430_dai, - .num_links = ARRAY_SIZE(sdp4430_dai), - - .dapm_widgets = sdp4430_twl6040_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sdp4430_twl6040_dapm_widgets), - .dapm_routes = audio_map, - .num_dapm_routes = ARRAY_SIZE(audio_map), -}; - -static struct platform_device *sdp4430_snd_device; - -static int __init sdp4430_soc_init(void) -{ - int ret; - - if (!machine_is_omap_4430sdp()) - return -ENODEV; - printk(KERN_INFO "SDP4430 SoC init\n"); - - sdp4430_snd_device = platform_device_alloc("soc-audio", -1); - if (!sdp4430_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); - - ret = platform_device_add(sdp4430_snd_device); - if (ret) - goto err; - - return 0; - -err: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(sdp4430_snd_device); - return ret; -} -module_init(sdp4430_soc_init); - -static void __exit sdp4430_soc_exit(void) -{ - platform_device_unregister(sdp4430_snd_device); -} -module_exit(sdp4430_soc_exit); - -MODULE_AUTHOR("Misael Lopez Cruz "); -MODULE_DESCRIPTION("ALSA SoC SDP4430"); -MODULE_LICENSE("GPL"); - -- cgit v1.2.3 From 13f81d65959eb3512b39e8c338e81e018d1c515b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 7 Dec 2011 15:54:50 +0200 Subject: ASoC: omap-abe-twl6040: Correct internal prefix, Kconfig entry Change the internal prefixes within the driver from sdp4430. At he same time correct the Kconfig text as well. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/Kconfig | 7 +++-- sound/soc/omap/omap-abe-twl6040.c | 65 ++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 35 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 4eae92987fe..98410b833f1 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -98,15 +98,16 @@ config SND_OMAP_SOC_SDP3430 SDP3430. config SND_OMAP_SOC_OMAP_ABE_TWL6040 - tristate "SoC Audio support for Texas Instruments SDP4430" + tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP select SND_OMAP_SOC_DMIC select SND_OMAP_SOC_MCPDM select SND_SOC_TWL6040 select SND_SOC_DMIC help - Say Y if you want to add support for SoC audio on Texas Instruments - SDP4430. + Say Y if you want to add support for SoC audio on OMAP boards using + ABE and twl6040 codec. This driver currently supports: + - SDP4430/Blaze boards config SND_OMAP_SOC_OMAP4_HDMI tristate "SoC Audio support for Texas Instruments OMAP4 HDMI" diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index ceadb137bf4..376ca351e09 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -1,5 +1,6 @@ /* - * sdp4430.c -- SoC audio for TI OMAP4430 SDP + * omap-abe-twl6040.c -- SoC audio for TI OMAP based boards with ABE and + * twl6040 codec * * Author: Misael Lopez Cruz * @@ -38,7 +39,7 @@ #include "omap-pcm.h" #include "../codecs/twl6040.h" -static int sdp4430_hw_params(struct snd_pcm_substream *substream, +static int omap_abe_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -64,11 +65,11 @@ static int sdp4430_hw_params(struct snd_pcm_substream *substream, return ret; } -static struct snd_soc_ops sdp4430_ops = { - .hw_params = sdp4430_hw_params, +static struct snd_soc_ops omap_abe_ops = { + .hw_params = omap_abe_hw_params, }; -static int sdp4430_dmic_hw_params(struct snd_pcm_substream *substream, +static int omap_abe_dmic_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -90,8 +91,8 @@ static int sdp4430_dmic_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_ops sdp4430_dmic_ops = { - .hw_params = sdp4430_dmic_hw_params, +static struct snd_soc_ops omap_abe_dmic_ops = { + .hw_params = omap_abe_dmic_hw_params, }; /* Headset jack */ @@ -110,7 +111,7 @@ static struct snd_soc_jack_pin hs_jack_pins[] = { }; /* SDP4430 machine DAPM */ -static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { +static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = { SND_SOC_DAPM_MIC("Ext Mic", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -145,7 +146,7 @@ static const struct snd_soc_dapm_route audio_map[] = { {"AFMR", NULL, "FM Stereo In"}, }; -static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) +static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; int ret, hs_trim; @@ -175,7 +176,7 @@ static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) return ret; } -static const struct snd_soc_dapm_widget sdp4430_dmic_dapm_widgets[] = { +static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { SND_SOC_DAPM_MIC("Digital Mic", NULL), }; @@ -184,14 +185,14 @@ static const struct snd_soc_dapm_route dmic_audio_map[] = { {"Digital Mic1 Bias", NULL, "Digital Mic"}, }; -static int sdp4430_dmic_init(struct snd_soc_pcm_runtime *rtd) +static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; int ret; - ret = snd_soc_dapm_new_controls(dapm, sdp4430_dmic_dapm_widgets, - ARRAY_SIZE(sdp4430_dmic_dapm_widgets)); + ret = snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets, + ARRAY_SIZE(dmic_dapm_widgets)); if (ret) return ret; @@ -208,8 +209,8 @@ static struct snd_soc_dai_link sdp4430_dai[] = { .codec_dai_name = "twl6040-legacy", .platform_name = "omap-pcm-audio", .codec_name = "twl6040-codec", - .init = sdp4430_twl6040_init, - .ops = &sdp4430_ops, + .init = omap_abe_twl6040_init, + .ops = &omap_abe_ops, }, { .name = "DMIC", @@ -218,27 +219,27 @@ static struct snd_soc_dai_link sdp4430_dai[] = { .codec_dai_name = "dmic-hifi", .platform_name = "omap-pcm-audio", .codec_name = "dmic-codec", - .init = sdp4430_dmic_init, - .ops = &sdp4430_dmic_ops, + .init = omap_abe_dmic_init, + .ops = &omap_abe_dmic_ops, }, }; /* Audio machine driver */ -static struct snd_soc_card snd_soc_sdp4430 = { +static struct snd_soc_card omap_abe_card = { .name = "SDP4430", .owner = THIS_MODULE, .dai_link = sdp4430_dai, .num_links = ARRAY_SIZE(sdp4430_dai), - .dapm_widgets = sdp4430_twl6040_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sdp4430_twl6040_dapm_widgets), + .dapm_widgets = twl6040_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(twl6040_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), }; -static struct platform_device *sdp4430_snd_device; +static struct platform_device *omap_abe_snd_device; -static int __init sdp4430_soc_init(void) +static int __init omap_abe_soc_init(void) { int ret; @@ -246,15 +247,15 @@ static int __init sdp4430_soc_init(void) return -ENODEV; printk(KERN_INFO "SDP4430 SoC init\n"); - sdp4430_snd_device = platform_device_alloc("soc-audio", -1); - if (!sdp4430_snd_device) { + omap_abe_snd_device = platform_device_alloc("soc-audio", -1); + if (!omap_abe_snd_device) { printk(KERN_ERR "Platform device allocation failed\n"); return -ENOMEM; } - platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); + platform_set_drvdata(omap_abe_snd_device, &omap_abe_card); - ret = platform_device_add(sdp4430_snd_device); + ret = platform_device_add(omap_abe_snd_device); if (ret) goto err; @@ -262,18 +263,18 @@ static int __init sdp4430_soc_init(void) err: printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(sdp4430_snd_device); + platform_device_put(omap_abe_snd_device); return ret; } -module_init(sdp4430_soc_init); +module_init(omap_abe_soc_init); -static void __exit sdp4430_soc_exit(void) +static void __exit omap_abe_soc_exit(void) { - platform_device_unregister(sdp4430_snd_device); + platform_device_unregister(omap_abe_snd_device); } -module_exit(sdp4430_soc_exit); +module_exit(omap_abe_soc_exit); MODULE_AUTHOR("Misael Lopez Cruz "); -MODULE_DESCRIPTION("ALSA SoC SDP4430"); +MODULE_DESCRIPTION("ALSA SoC for OMAP boards with ABE and twl6040 codec"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From d1be1d2fd1158b45dca99e3924621e1068c87b82 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 8 Dec 2011 11:07:42 +0200 Subject: ASoC: omap-abe-twl6040: Convert to platform deriver Convert the OMAP4 ABE/TWL6040 machine driver to platform driver. For the card name use the string provided via platform data. The card's name for OMAP4 SDP4430 has been changed: SDP4430 -> OMAP4-SDP4430 Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/omap-abe-twl6040.c | 60 +++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 24 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 376ca351e09..6b7047066f4 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -226,7 +227,6 @@ static struct snd_soc_dai_link sdp4430_dai[] = { /* Audio machine driver */ static struct snd_soc_card omap_abe_card = { - .name = "SDP4430", .owner = THIS_MODULE, .dai_link = sdp4430_dai, .num_links = ARRAY_SIZE(sdp4430_dai), @@ -237,44 +237,56 @@ static struct snd_soc_card omap_abe_card = { .num_dapm_routes = ARRAY_SIZE(audio_map), }; -static struct platform_device *omap_abe_snd_device; - -static int __init omap_abe_soc_init(void) +static __devinit int omap_abe_probe(struct platform_device *pdev) { + struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev); + struct snd_soc_card *card = &omap_abe_card; int ret; - if (!machine_is_omap_4430sdp()) - return -ENODEV; - printk(KERN_INFO "SDP4430 SoC init\n"); + card->dev = &pdev->dev; - omap_abe_snd_device = platform_device_alloc("soc-audio", -1); - if (!omap_abe_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; + if (!pdata) { + dev_err(&pdev->dev, "Missing pdata\n"); + return -ENODEV; } - platform_set_drvdata(omap_abe_snd_device, &omap_abe_card); + if (pdata->card_name) { + card->name = pdata->card_name; + } else { + dev_err(&pdev->dev, "Card name is not provided\n"); + return -ENODEV; + } - ret = platform_device_add(omap_abe_snd_device); + ret = snd_soc_register_card(card); if (ret) - goto err; - - return 0; + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); -err: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(omap_abe_snd_device); return ret; } -module_init(omap_abe_soc_init); -static void __exit omap_abe_soc_exit(void) +static int __devexit omap_abe_remove(struct platform_device *pdev) { - platform_device_unregister(omap_abe_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_exit(omap_abe_soc_exit); + +static struct platform_driver omap_abe_driver = { + .driver = { + .name = "omap-abe-twl6040", + .owner = THIS_MODULE, + .pm = &snd_soc_pm_ops, + }, + .probe = omap_abe_probe, + .remove = __devexit_p(omap_abe_remove), +}; + +module_platform_driver(omap_abe_driver); MODULE_AUTHOR("Misael Lopez Cruz "); MODULE_DESCRIPTION("ALSA SoC for OMAP boards with ABE and twl6040 codec"); MODULE_LICENSE("GPL"); - +MODULE_ALIAS("platform:omap-abe-twl6040"); -- cgit v1.2.3 From 778cee7afd063b1321dd9a2d2ecd8822d76bb33a Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 22 Dec 2011 12:47:21 +0200 Subject: ASoC: twl6040: Convert MICBIAS to SUPPLY widget In order to avoid breakage change the omap-abe-twl6040 machine driver's routing. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/omap-abe-twl6040.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 6b7047066f4..ca7152cb6a2 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -123,17 +123,17 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = { static const struct snd_soc_dapm_route audio_map[] = { /* External Mics: MAINMIC, SUBMIC with bias*/ - {"MAINMIC", NULL, "Main Mic Bias"}, - {"SUBMIC", NULL, "Main Mic Bias"}, - {"Main Mic Bias", NULL, "Ext Mic"}, + {"MAINMIC", NULL, "Ext Mic"}, + {"SUBMIC", NULL, "Ext Mic"}, + {"Ext Mic", NULL, "Main Mic Bias"}, /* External Speakers: HFL, HFR */ {"Ext Spk", NULL, "HFL"}, {"Ext Spk", NULL, "HFR"}, /* Headset Mic: HSMIC with bias */ - {"HSMIC", NULL, "Headset Mic Bias"}, - {"Headset Mic Bias", NULL, "Headset Mic"}, + {"HSMIC", NULL, "Headset Mic"}, + {"Headset Mic", NULL, "Headset Mic Bias"}, /* Headset Stereophone (Headphone): HSOL, HSOR */ {"Headset Stereophone", NULL, "HSOL"}, @@ -182,8 +182,8 @@ static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { }; static const struct snd_soc_dapm_route dmic_audio_map[] = { - {"DMic", NULL, "Digital Mic1 Bias"}, - {"Digital Mic1 Bias", NULL, "Digital Mic"}, + {"DMic", NULL, "Digital Mic"}, + {"Digital Mic", NULL, "Digital Mic1 Bias"}, }; static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd) -- cgit v1.2.3 From b3208839106476fe31b4bf3e6a2470cae509b2a5 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 22 Dec 2011 12:55:49 +0200 Subject: ASoC: omap-abe-twl6040: Add complete DAPM routing SDP4430 is a reference platform, and as such it has all possible audio routing implemented. Correct the DAPM routing to be complete. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/omap-abe-twl6040.c | 46 ++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index ca7152cb6a2..f2b5fec8f68 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -113,38 +113,48 @@ static struct snd_soc_jack_pin hs_jack_pins[] = { /* SDP4430 machine DAPM */ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = { - SND_SOC_DAPM_MIC("Ext Mic", NULL), - SND_SOC_DAPM_SPK("Ext Spk", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), + /* Outputs */ SND_SOC_DAPM_HP("Headset Stereophone", NULL), SND_SOC_DAPM_SPK("Earphone Spk", NULL), - SND_SOC_DAPM_INPUT("FM Stereo In"), + SND_SOC_DAPM_SPK("Ext Spk", NULL), + SND_SOC_DAPM_LINE("Line Out", NULL), + SND_SOC_DAPM_SPK("Vibrator", NULL), + + /* Inputs */ + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Main Handset Mic", NULL), + SND_SOC_DAPM_MIC("Sub Handset Mic", NULL), + SND_SOC_DAPM_LINE("Line In", NULL), }; static const struct snd_soc_dapm_route audio_map[] = { - /* External Mics: MAINMIC, SUBMIC with bias*/ - {"MAINMIC", NULL, "Ext Mic"}, - {"SUBMIC", NULL, "Ext Mic"}, - {"Ext Mic", NULL, "Main Mic Bias"}, + /* Routings for outputs */ + {"Headset Stereophone", NULL, "HSOL"}, + {"Headset Stereophone", NULL, "HSOR"}, + + {"Earphone Spk", NULL, "EP"}, - /* External Speakers: HFL, HFR */ {"Ext Spk", NULL, "HFL"}, {"Ext Spk", NULL, "HFR"}, - /* Headset Mic: HSMIC with bias */ + {"Line Out", NULL, "AUXL"}, + {"Line Out", NULL, "AUXR"}, + + {"Vibrator", NULL, "VIBRAL"}, + {"Vibrator", NULL, "VIBRAR"}, + + /* Routings for inputs */ {"HSMIC", NULL, "Headset Mic"}, {"Headset Mic", NULL, "Headset Mic Bias"}, - /* Headset Stereophone (Headphone): HSOL, HSOR */ - {"Headset Stereophone", NULL, "HSOL"}, - {"Headset Stereophone", NULL, "HSOR"}, + {"MAINMIC", NULL, "Main Handset Mic"}, + {"Main Handset Mic", NULL, "Main Mic Bias"}, - /* Earphone speaker */ - {"Earphone Spk", NULL, "EP"}, + {"SUBMIC", NULL, "Sub Handset Mic"}, + {"Sub Handset Mic", NULL, "Main Mic Bias"}, - /* Aux/FM Stereo In: AFML, AFMR */ - {"AFML", NULL, "FM Stereo In"}, - {"AFMR", NULL, "FM Stereo In"}, + {"AFML", NULL, "Line In"}, + {"AFMR", NULL, "Line In"}, }; static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) -- cgit v1.2.3 From 8d946dd7dc5cc3f0eae3d6df2c9e927497e38850 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 22 Dec 2011 13:10:02 +0200 Subject: ASoC: omap-abe-twl6040: DAI link selection based on platform data We can have machines without DMIC connected. In this case there is no need to create amother (unusable) capture PCM on the card. The existence of the DMIC connection can be checked via pdata->has_dmic. Select the correct dai_link structure for the card based on pdata->has_dmic. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/omap-abe-twl6040.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index f2b5fec8f68..5b781f904cd 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -212,7 +212,7 @@ static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd) } /* Digital audio interface glue - connects codec <--> CPU */ -static struct snd_soc_dai_link sdp4430_dai[] = { +static struct snd_soc_dai_link twl6040_dmic_dai[] = { { .name = "TWL6040", .stream_name = "TWL6040", @@ -235,11 +235,22 @@ static struct snd_soc_dai_link sdp4430_dai[] = { }, }; +static struct snd_soc_dai_link twl6040_only_dai[] = { + { + .name = "TWL6040", + .stream_name = "TWL6040", + .cpu_dai_name = "omap-mcpdm", + .codec_dai_name = "twl6040-legacy", + .platform_name = "omap-pcm-audio", + .codec_name = "twl6040-codec", + .init = omap_abe_twl6040_init, + .ops = &omap_abe_ops, + }, +}; + /* Audio machine driver */ static struct snd_soc_card omap_abe_card = { .owner = THIS_MODULE, - .dai_link = sdp4430_dai, - .num_links = ARRAY_SIZE(sdp4430_dai), .dapm_widgets = twl6040_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(twl6040_dapm_widgets), @@ -267,6 +278,14 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) return -ENODEV; } + if (pdata->has_dmic) { + card->dai_link = twl6040_dmic_dai; + card->num_links = ARRAY_SIZE(twl6040_dmic_dai); + } else { + card->dai_link = twl6040_only_dai; + card->num_links = ARRAY_SIZE(twl6040_only_dai); + } + ret = snd_soc_register_card(card); if (ret) dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", -- cgit v1.2.3 From 4ca07cb0cf698151a21e9a9e68a67ca9656d3632 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 22 Dec 2011 13:58:01 +0200 Subject: ASoC: omap-abe-twl6040: Configure card according to platform data Disable the not connected pins on the board based on the received platform data. DO not register the jack function on boards, which does not have means to detect it (jack is always connected). Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/omap-abe-twl6040.c | 44 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 5b781f904cd..1da26031e26 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -157,10 +157,32 @@ static const struct snd_soc_dapm_route audio_map[] = { {"AFMR", NULL, "Line In"}, }; +static inline void twl6040_disconnect_pin(struct snd_soc_dapm_context *dapm, + int connected, char *pin) +{ + if (!connected) + snd_soc_dapm_disable_pin(dapm, pin); +} + static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; - int ret, hs_trim; + struct snd_soc_card *card = codec->card; + struct snd_soc_dapm_context *dapm = &codec->dapm; + struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); + int hs_trim; + int ret = 0; + + /* Disable not connected paths if not used */ + twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone"); + twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk"); + twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk"); + twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out"); + twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator"); + twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic"); + twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic"); + twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic"); + twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In"); /* * Configure McPDM offset cancellation based on the HSOTRIM value from @@ -170,19 +192,17 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim), TWL6040_HSF_TRIM_RIGHT(hs_trim)); - /* Headset jack detection */ - ret = snd_soc_jack_new(codec, "Headset Jack", - SND_JACK_HEADSET, &hs_jack); - if (ret) - return ret; - - ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), - hs_jack_pins); + /* Headset jack detection only if it is supported */ + if (pdata->jack_detection) { + ret = snd_soc_jack_new(codec, "Headset Jack", + SND_JACK_HEADSET, &hs_jack); + if (ret) + return ret; - if (machine_is_omap_4430sdp()) + ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), + hs_jack_pins); twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); - else - snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); + } return ret; } -- cgit v1.2.3 From 62ba98ce4a74ef606e6a7f6c8541fc5e3127f944 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 24 Jan 2012 12:36:10 +0200 Subject: ASoC: omap-abe-twl6040: Use provided MCLK frequency from pdata Avoid using hardwired configuration for MCLK frequency. Different board design might use other MCLK frequency. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/omap-abe-twl6040.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 1da26031e26..93bb8eee22b 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -45,12 +45,15 @@ static int omap_abe_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_card *card = codec->card; + struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); int clk_id, freq; int ret; clk_id = twl6040_get_clk_id(rtd->codec); if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) - freq = 38400000; + freq = pdata->mclk_freq; else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) freq = 32768; else @@ -298,6 +301,11 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) return -ENODEV; } + if (!pdata->mclk_freq) { + dev_err(&pdev->dev, "MCLK frequency missing\n"); + return -ENODEV; + } + if (pdata->has_dmic) { card->dai_link = twl6040_dmic_dai; card->num_links = ARRAY_SIZE(twl6040_dmic_dai); -- cgit v1.2.3 From 6b21ed851624a03f11ea9ed3f229f56419e03686 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 22 Dec 2011 14:19:05 +0200 Subject: ASoC: Kconfig: OMAP4: Enable support for PandaBoards Enable ASoC audio support for OMAP4 based machines with twl6040 codec via the omap-abe-twl6040 machine driver. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown --- sound/soc/omap/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 98410b833f1..47b23fea20c 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -99,7 +99,7 @@ config SND_OMAP_SOC_SDP3430 config SND_OMAP_SOC_OMAP_ABE_TWL6040 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" - depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP + depends on TWL4030_CORE && SND_OMAP_SOC && ARCH_OMAP4 select SND_OMAP_SOC_DMIC select SND_OMAP_SOC_MCPDM select SND_SOC_TWL6040 @@ -108,6 +108,8 @@ config SND_OMAP_SOC_OMAP_ABE_TWL6040 Say Y if you want to add support for SoC audio on OMAP boards using ABE and twl6040 codec. This driver currently supports: - SDP4430/Blaze boards + - PandaBoard (4430) + - PandaBoardES (4460) config SND_OMAP_SOC_OMAP4_HDMI tristate "SoC Audio support for Texas Instruments OMAP4 HDMI" -- cgit v1.2.3 From 022658beab5581ecc1d325d60857f2fc464da22f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 3 Feb 2012 17:43:09 +0000 Subject: ASoC: core: Add support for DAI and machine kcontrols. Currently ASoC can only add kcontrols using codec and platform component device handles. It's also desirable to add kcontrols for DAIs (i.e. McBSP) and for SoC card machine drivers too. This allows the kcontrol to have a direct handle to the parent ASoC component DAI/SoC Card/Platform/Codec device and hence easily get it's private data. This change makes snd_soc_add_controls() static and wraps it in the folowing calls (card and dai are new) :- snd_soc_add_card_controls() snd_soc_add_codec_controls() snd_soc_add_dai_controls() snd_soc_add_platform_controls() This patch also does a lot of small mechanical changes in individual codec drivers to replace snd_soc_add_controls() with snd_soc_add_codec_controls(). It also updates the McBSP DAI driver to use snd_soc_add_dai_controls(). Finally, it updates the existing machine drivers that register controls to either :- 1) Use snd_soc_add_card_controls() where no direct codec control is required. 2) Use snd_soc_add_codec_controls() where there is direct codec control. In the case of 1) above we also update the machine drivers to get the correct component data pointers from the kcontrol (rather than getting the machine pointer via the codec pointer). Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/omap/ams-delta.c | 2 +- sound/soc/omap/n810.c | 15 +++++++-------- sound/soc/omap/omap-mcbsp.c | 8 ++++---- sound/soc/omap/omap-mcbsp.h | 2 +- sound/soc/omap/rx51.c | 25 ++++++++++++------------- 5 files changed, 25 insertions(+), 27 deletions(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index a67f4370bc9..78563bbbbf0 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -570,7 +570,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_disable_pin(dapm, "AGCOUT"); /* Add virtual switch */ - ret = snd_soc_add_controls(codec, ams_delta_audio_controls, + ret = snd_soc_add_codec_controls(codec, ams_delta_audio_controls, ARRAY_SIZE(ams_delta_audio_controls)); if (ret) dev_warn(card->dev, diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 597be412f1e..1490227cd37 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -55,9 +55,8 @@ static int n810_spk_func; static int n810_jack_func; static int n810_dmic_func; -static void n810_ext_control(struct snd_soc_codec *codec) +static void n810_ext_control(struct snd_soc_dapm_context *dapm) { - struct snd_soc_dapm_context *dapm = &codec->dapm; int hp = 0, line1l = 0; switch (n810_jack_func) { @@ -102,7 +101,7 @@ static int n810_startup(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); - n810_ext_control(codec); + n810_ext_control(&codec->dapm); return clk_enable(sys_clkout2); } @@ -142,13 +141,13 @@ static int n810_get_spk(struct snd_kcontrol *kcontrol, static int n810_set_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (n810_spk_func == ucontrol->value.integer.value[0]) return 0; n810_spk_func = ucontrol->value.integer.value[0]; - n810_ext_control(codec); + n810_ext_control(&card->dapm); return 1; } @@ -164,13 +163,13 @@ static int n810_get_jack(struct snd_kcontrol *kcontrol, static int n810_set_jack(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (n810_jack_func == ucontrol->value.integer.value[0]) return 0; n810_jack_func = ucontrol->value.integer.value[0]; - n810_ext_control(codec); + n810_ext_control(&card->dapm); return 1; } @@ -186,7 +185,7 @@ static int n810_get_input(struct snd_kcontrol *kcontrol, static int n810_set_input(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (n810_dmic_func == ucontrol->value.integer.value[0]) return 0; diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 017371913ec..1287b870f22 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -744,17 +744,17 @@ static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = { omap_mcbsp3_set_st_ch1_volume), }; -int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id) +int omap_mcbsp_st_add_controls(struct snd_soc_dai *dai) { if (!cpu_is_omap34xx()) return -ENODEV; - switch (mcbsp_id) { + switch (dai->id) { case 1: /* McBSP 2 */ - return snd_soc_add_controls(codec, omap_mcbsp2_st_controls, + return snd_soc_add_dai_controls(dai, omap_mcbsp2_st_controls, ARRAY_SIZE(omap_mcbsp2_st_controls)); case 2: /* McBSP 3 */ - return snd_soc_add_controls(codec, omap_mcbsp3_st_controls, + return snd_soc_add_dai_controls(dai, omap_mcbsp3_st_controls, ARRAY_SIZE(omap_mcbsp3_st_controls)); default: break; diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h index 65cde9d3807..476fe2add70 100644 --- a/sound/soc/omap/omap-mcbsp.h +++ b/sound/soc/omap/omap-mcbsp.h @@ -59,6 +59,6 @@ enum omap_mcbsp_div { #define NUM_LINKS 5 #endif -int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id); +int omap_mcbsp_st_add_controls(struct snd_soc_dai *dai); #endif diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index fada6ef43ee..58936c730a8 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -59,9 +59,8 @@ static int rx51_spk_func; static int rx51_dmic_func; static int rx51_jack_func; -static void rx51_ext_control(struct snd_soc_codec *codec) +static void rx51_ext_control(struct snd_soc_dapm_context *dapm) { - struct snd_soc_dapm_context *dapm = &codec->dapm; int hp = 0, hs = 0, tvout = 0; switch (rx51_jack_func) { @@ -102,11 +101,11 @@ static int rx51_startup(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_card *card = rtd->card; snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); - rx51_ext_control(codec); + rx51_ext_control(&card->dapm); return 0; } @@ -138,13 +137,13 @@ static int rx51_get_spk(struct snd_kcontrol *kcontrol, static int rx51_set_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (rx51_spk_func == ucontrol->value.integer.value[0]) return 0; rx51_spk_func = ucontrol->value.integer.value[0]; - rx51_ext_control(codec); + rx51_ext_control(&card->dapm); return 1; } @@ -184,13 +183,13 @@ static int rx51_get_input(struct snd_kcontrol *kcontrol, static int rx51_set_input(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (rx51_dmic_func == ucontrol->value.integer.value[0]) return 0; rx51_dmic_func = ucontrol->value.integer.value[0]; - rx51_ext_control(codec); + rx51_ext_control(&card->dapm); return 1; } @@ -206,13 +205,13 @@ static int rx51_get_jack(struct snd_kcontrol *kcontrol, static int rx51_set_jack(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); if (rx51_jack_func == ucontrol->value.integer.value[0]) return 0; rx51_jack_func = ucontrol->value.integer.value[0]; - rx51_ext_control(codec); + rx51_ext_control(&card->dapm); return 1; } @@ -297,7 +296,7 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_nc_pin(dapm, "LINE1R"); /* Add RX-51 specific controls */ - err = snd_soc_add_controls(codec, aic34_rx51_controls, + err = snd_soc_add_card_controls(rtd->card, aic34_rx51_controls, ARRAY_SIZE(aic34_rx51_controls)); if (err < 0) return err; @@ -314,7 +313,7 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) return err; snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42); - err = omap_mcbsp_st_add_controls(codec, 1); + err = omap_mcbsp_st_add_controls(rtd->cpu_dai); if (err < 0) return err; @@ -335,7 +334,7 @@ static int rx51_aic34b_init(struct snd_soc_dapm_context *dapm) { int err; - err = snd_soc_add_controls(dapm->codec, aic34_rx51_controlsb, + err = snd_soc_add_card_controls(dapm->card, aic34_rx51_controlsb, ARRAY_SIZE(aic34_rx51_controlsb)); if (err < 0) return err; -- cgit v1.2.3 From 625136eb4a98e82f27c5d9dcb1b8cf8e0bb5bcef Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 10 Feb 2012 14:54:37 +0800 Subject: ASoC: Fix build error in sound/soc/omap/n810.c Fix below build error which is introduced by commit 022658 "ASoC: core: Add support for DAI and machine kcontrols". CC [M] sound/soc/omap/n810.o sound/soc/omap/n810.c: In function 'n810_set_input': sound/soc/omap/n810.c:194: error: 'codec' undeclared (first use in this function) sound/soc/omap/n810.c:194: error: (Each undeclared identifier is reported only once sound/soc/omap/n810.c:194: error: for each function it appears in.) sound/soc/omap/n810.c:188: warning: unused variable 'card' make[3]: *** [sound/soc/omap/n810.o] Error 1 make[2]: *** [sound/soc/omap] Error 2 make[1]: *** [sound/soc] Error 2 make: *** [sound] Error 2 Signed-off-by: Axel Lin Acked-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/omap/n810.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc/omap') diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 1490227cd37..c292bf0fd19 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -191,7 +191,7 @@ static int n810_set_input(struct snd_kcontrol *kcontrol, return 0; n810_dmic_func = ucontrol->value.integer.value[0]; - n810_ext_control(codec); + n810_ext_control(&card->dapm); return 1; } -- cgit v1.2.3