From 3afb1b3e6fa358d8c7e652b80be6d0cde07b4b40 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 May 2011 00:01:58 +0200 Subject: ASoC: Fix NULL vs. 0 warning in SSM2602 sparse complains if 0 is used as a NULL pointer constant. Signed-off-by: Mark Brown Acked-by: Mike Frysinger Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 70099c9..84f4ad5 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -137,7 +137,7 @@ SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1), SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SSM2602_PWR, 2, 1), SND_SOC_DAPM_PGA("Line Input", SSM2602_PWR, 0, 1, NULL, 0), -SND_SOC_DAPM_SUPPLY("Digital Core Power", SSM2602_ACTIVE, 0, 0, 0, 0), +SND_SOC_DAPM_SUPPLY("Digital Core Power", SSM2602_ACTIVE, 0, 0, NULL, 0), SND_SOC_DAPM_OUTPUT("LOUT"), SND_SOC_DAPM_OUTPUT("ROUT"), -- cgit v0.10.2 From 051e994e9506e64259df34e91b028fe2470fbf2a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 May 2011 13:47:47 +0200 Subject: ASoC: Don't squash 16x8 registers down to 8 bits Currently we'll force all registers to fit in 8 bits before passing down to the I/O function. Looks like a cut'n'paste bug. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 687beec..6e5e30a 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -319,7 +319,6 @@ static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg, data[0] = (reg >> 8) & 0xff; data[1] = reg & 0xff; data[2] = value; - reg &= 0xff; return do_hw_write(codec, reg, value, data, 3); } -- cgit v0.10.2 From 063b7cc43fb2413238095b81f9b4a2ee2c52056b Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 10 May 2011 23:55:21 +0200 Subject: ASoC: Remove byte swap in 4x12 SPI write snd_soc_4_12_spi_write() contains a byte swap. Since this code was written for an Analog CODEC on a Blackfin reference board it appears that this is done because while Blackfin is little endian the CODEC is big endian (as are most CODECs). Push this up into the generic 4x12 write function and use cpu_to_be16() to do the byte swap so things are more regular and things work on both CPU endiannesses. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 6e5e30a..73907e5 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -101,12 +101,11 @@ static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec, static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { - u8 data[2]; + u16 data; - data[0] = (reg << 4) | ((value >> 8) & 0x000f); - data[1] = value & 0x00ff; + data = cpu_to_be16((reg << 12) | (value & 0xffffff)); - return do_hw_write(codec, reg, value, data, 2); + return do_hw_write(codec, reg, value, &data, 2); } #if defined(CONFIG_SPI_MASTER) @@ -115,8 +114,8 @@ static int snd_soc_4_12_spi_write(void *control_data, const char *data, { u8 msg[2]; - msg[0] = data[1]; - msg[1] = data[0]; + msg[0] = data[0]; + msg[1] = data[1]; return do_spi_write(control_data, msg, len); } -- cgit v0.10.2 From 6e28f976ec73aec688bf89a63ac719ba765e9360 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 10 May 2011 23:33:48 +0200 Subject: ASoC: Use spi_write() for SPI writes do_spi_write() is just an open coded copy of do_spi_write() so we can delete it and just call spi_write() directly. Indeed, as a result of recent refactoring all the SPI write functions are just very long wrappers around spi_write() which don't add anything except for some pointless copies so we can just use spi_write() as the hw_write operation directly. It should be as type safe to do this as it is to do the same thing with I2C and it saves us a bunch of code. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 73907e5..01e5b98 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -20,30 +20,6 @@ #include -#if defined(CONFIG_SPI_MASTER) -static int do_spi_write(void *control_data, const void *msg, - int len) -{ - struct spi_device *spi = control_data; - struct spi_transfer t; - struct spi_message m; - - if (len <= 0) - return 0; - - spi_message_init(&m); - memset(&t, 0, sizeof t); - - t.tx_buf = msg; - t.len = len; - - spi_message_add_tail(&t, &m); - spi_sync(spi, &m); - - return len; -} -#endif - static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value, const void *data, int len) { @@ -108,21 +84,6 @@ static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg, return do_hw_write(codec, reg, value, &data, 2); } -#if defined(CONFIG_SPI_MASTER) -static int snd_soc_4_12_spi_write(void *control_data, const char *data, - int len) -{ - u8 msg[2]; - - msg[0] = data[0]; - msg[1] = data[1]; - - return do_spi_write(control_data, msg, len); -} -#else -#define snd_soc_4_12_spi_write NULL -#endif - static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec, unsigned int reg) { @@ -140,21 +101,6 @@ static int snd_soc_7_9_write(struct snd_soc_codec *codec, unsigned int reg, return do_hw_write(codec, reg, value, data, 2); } -#if defined(CONFIG_SPI_MASTER) -static int snd_soc_7_9_spi_write(void *control_data, const char *data, - int len) -{ - u8 msg[2]; - - msg[0] = data[0]; - msg[1] = data[1]; - - return do_spi_write(control_data, msg, len); -} -#else -#define snd_soc_7_9_spi_write NULL -#endif - static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { @@ -173,21 +119,6 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec, return do_hw_read(codec, reg); } -#if defined(CONFIG_SPI_MASTER) -static int snd_soc_8_8_spi_write(void *control_data, const char *data, - int len) -{ - u8 msg[2]; - - msg[0] = data[0]; - msg[1] = data[1]; - - return do_spi_write(control_data, msg, len); -} -#else -#define snd_soc_8_8_spi_write NULL -#endif - static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { @@ -206,22 +137,6 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec, return do_hw_read(codec, reg); } -#if defined(CONFIG_SPI_MASTER) -static int snd_soc_8_16_spi_write(void *control_data, const char *data, - int len) -{ - u8 msg[3]; - - msg[0] = data[0]; - msg[1] = data[1]; - msg[2] = data[2]; - - return do_spi_write(control_data, msg, len); -} -#else -#define snd_soc_8_16_spi_write NULL -#endif - #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) static unsigned int do_i2c_read(struct snd_soc_codec *codec, void *reg, int reglen, @@ -322,22 +237,6 @@ static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg, return do_hw_write(codec, reg, value, data, 3); } -#if defined(CONFIG_SPI_MASTER) -static int snd_soc_16_8_spi_write(void *control_data, const char *data, - int len) -{ - u8 msg[3]; - - msg[0] = data[0]; - msg[1] = data[1]; - msg[2] = data[2]; - - return do_spi_write(control_data, msg, len); -} -#else -#define snd_soc_16_8_spi_write NULL -#endif - #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) static unsigned int snd_soc_16_16_read_i2c(struct snd_soc_codec *codec, unsigned int r) @@ -374,23 +273,6 @@ static int snd_soc_16_16_write(struct snd_soc_codec *codec, unsigned int reg, return do_hw_write(codec, reg, value, data, 4); } -#if defined(CONFIG_SPI_MASTER) -static int snd_soc_16_16_spi_write(void *control_data, const char *data, - int len) -{ - u8 msg[4]; - - msg[0] = data[0]; - msg[1] = data[1]; - msg[2] = data[2]; - msg[3] = data[3]; - - return do_spi_write(control_data, msg, len); -} -#else -#define snd_soc_16_16_spi_write NULL -#endif - /* Primitive bulk write support for soc-cache. The data pointed to by * `data' needs to already be in the form the hardware expects * including any leading register specific data. Any data written @@ -420,7 +302,7 @@ static int snd_soc_hw_bulk_write_raw(struct snd_soc_codec *codec, unsigned int r #endif #if defined(CONFIG_SPI_MASTER) case SND_SOC_SPI: - ret = do_spi_write(codec->control_data, data, len); + ret = spi_write(codec->control_data, data, len); break; #endif default: @@ -439,43 +321,36 @@ static struct { int addr_bits; int data_bits; int (*write)(struct snd_soc_codec *codec, unsigned int, unsigned int); - int (*spi_write)(void *, const char *, int); unsigned int (*read)(struct snd_soc_codec *, unsigned int); unsigned int (*i2c_read)(struct snd_soc_codec *, unsigned int); } io_types[] = { { .addr_bits = 4, .data_bits = 12, .write = snd_soc_4_12_write, .read = snd_soc_4_12_read, - .spi_write = snd_soc_4_12_spi_write, }, { .addr_bits = 7, .data_bits = 9, .write = snd_soc_7_9_write, .read = snd_soc_7_9_read, - .spi_write = snd_soc_7_9_spi_write, }, { .addr_bits = 8, .data_bits = 8, .write = snd_soc_8_8_write, .read = snd_soc_8_8_read, .i2c_read = snd_soc_8_8_read_i2c, - .spi_write = snd_soc_8_8_spi_write, }, { .addr_bits = 8, .data_bits = 16, .write = snd_soc_8_16_write, .read = snd_soc_8_16_read, .i2c_read = snd_soc_8_16_read_i2c, - .spi_write = snd_soc_8_16_spi_write, }, { .addr_bits = 16, .data_bits = 8, .write = snd_soc_16_8_write, .read = snd_soc_16_8_read, .i2c_read = snd_soc_16_8_read_i2c, - .spi_write = snd_soc_16_8_spi_write, }, { .addr_bits = 16, .data_bits = 16, .write = snd_soc_16_16_write, .read = snd_soc_16_16_read, .i2c_read = snd_soc_16_16_read_i2c, - .spi_write = snd_soc_16_16_spi_write, }, }; @@ -536,8 +411,9 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, break; case SND_SOC_SPI: - if (io_types[i].spi_write) - codec->hw_write = io_types[i].spi_write; +#ifdef CONFIG_SPI_MASTER + codec->hw_write = (hw_write_t)spi_write; +#endif codec->control_data = container_of(codec->dev, struct spi_device, -- cgit v0.10.2 From ca629928b9d5b28789c4b59729113e9d2b1bc7c0 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 May 2011 14:34:53 +0200 Subject: ASoC: Disable WM8994/58 microphone detection over suspend It will be non-functional with the basises and clocks off anyway, if the system needs microphone detection enabled over suspend then it should be causing the CODEC to ignore suspend using the APIs for that to prevent the biases being disabled. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index b6d47e7..e6dfa10 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -2416,8 +2416,19 @@ static struct snd_soc_dai_driver wm8994_dai[] = { static int wm8994_suspend(struct snd_soc_codec *codec, pm_message_t state) { struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994 *control = codec->control_data; int i, ret; + switch (control->type) { + case WM8994: + snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, 0); + break; + case WM8958: + snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + WM8958_MICD_ENA, 0); + break; + } + for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { memcpy(&wm8994->fll_suspend[i], &wm8994->fll[i], sizeof(struct wm8994_fll_config)); @@ -2435,6 +2446,7 @@ static int wm8994_suspend(struct snd_soc_codec *codec, pm_message_t state) static int wm8994_resume(struct snd_soc_codec *codec) { struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994 *control = codec->control_data; int i, ret; unsigned int val, mask; @@ -2473,6 +2485,19 @@ static int wm8994_resume(struct snd_soc_codec *codec) i + 1, ret); } + switch (control->type) { + case WM8994: + if (wm8994->micdet[0].jack || wm8994->micdet[1].jack) + snd_soc_update_bits(codec, WM8994_MICBIAS, + WM8994_MICD_ENA, WM8994_MICD_ENA); + break; + case WM8958: + if (wm8994->jack_cb) + snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + WM8958_MICD_ENA, WM8958_MICD_ENA); + break; + } + return 0; } #else -- cgit v0.10.2 From 93864cf04283eb2899ef13ded472a9f24538303f Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 3 May 2011 18:11:36 +0300 Subject: ASoC: tlv320dac33: Update e-mail address Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Signed-off-by: Liam Girdwood diff --git a/include/sound/tlv320dac33-plat.h b/include/sound/tlv320dac33-plat.h index 6c66496..0b94192 100644 --- a/include/sound/tlv320dac33-plat.h +++ b/include/sound/tlv320dac33-plat.h @@ -1,7 +1,7 @@ /* * Platform header for Texas Instruments TLV320DAC33 codec driver * - * Author: Peter Ujfalusi + * Author: Peter Ujfalusi * * Copyright: (C) 2009 Nokia Corporation * diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 90c361e..faa5e9f 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -1,7 +1,7 @@ /* * ALSA SoC Texas Instruments TLV320DAC33 codec driver * - * Author: Peter Ujfalusi + * Author: Peter Ujfalusi * * Copyright: (C) 2009 Nokia Corporation * @@ -1658,5 +1658,5 @@ module_exit(dac33_module_exit); MODULE_DESCRIPTION("ASoC TLV320DAC33 codec driver"); -MODULE_AUTHOR("Peter Ujfalusi "); +MODULE_AUTHOR("Peter Ujfalusi "); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/tlv320dac33.h b/sound/soc/codecs/tlv320dac33.h index 7c318b5..ed69670 100644 --- a/sound/soc/codecs/tlv320dac33.h +++ b/sound/soc/codecs/tlv320dac33.h @@ -1,7 +1,7 @@ /* * ALSA SoC Texas Instruments TLV320DAC33 codec driver * - * Author: Peter Ujfalusi + * Author: Peter Ujfalusi * * Copyright: (C) 2009 Nokia Corporation * -- cgit v0.10.2 From b4079ef40a5ae87dc0d29bded7a682b1cbe626ad Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 3 May 2011 18:12:41 +0300 Subject: ASoC: tpa6130a2: Update e-mail address Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Signed-off-by: Liam Girdwood diff --git a/include/sound/tpa6130a2-plat.h b/include/sound/tpa6130a2-plat.h index e29fde6..89beccb 100644 --- a/include/sound/tpa6130a2-plat.h +++ b/include/sound/tpa6130a2-plat.h @@ -3,7 +3,7 @@ * * Copyright (C) Nokia Corporation * - * Written by Peter Ujfalusi + * Author: Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 1f1ac81..239e0c4 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -3,7 +3,7 @@ * * Copyright (C) Nokia Corporation * - * Author: Peter Ujfalusi + * Author: Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -495,7 +495,7 @@ static void __exit tpa6130a2_exit(void) i2c_del_driver(&tpa6130a2_i2c_driver); } -MODULE_AUTHOR("Peter Ujfalusi"); +MODULE_AUTHOR("Peter Ujfalusi "); MODULE_DESCRIPTION("TPA6130A2 Headphone amplifier driver"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/tpa6130a2.h b/sound/soc/codecs/tpa6130a2.h index 5df49c8..4174440 100644 --- a/sound/soc/codecs/tpa6130a2.h +++ b/sound/soc/codecs/tpa6130a2.h @@ -3,7 +3,7 @@ * * Copyright (C) Nokia Corporation * - * Author: Peter Ujfalusi + * Author: Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License -- cgit v0.10.2 From 56a874291606f996da26063f7e90ef2864884bc8 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 3 May 2011 18:14:06 +0300 Subject: ASoC: omap-mcbsp: Update e-mail address Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Acked-by: Jarkko Nikula Signed-off-by: Liam Girdwood diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 2175f09..afbc7be 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -4,7 +4,7 @@ * Copyright (C) 2008 Nokia Corporation * * Contact: Jarkko Nikula - * Peter Ujfalusi + * Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h index 37dc721..9a7dedd 100644 --- a/sound/soc/omap/omap-mcbsp.h +++ b/sound/soc/omap/omap-mcbsp.h @@ -4,7 +4,7 @@ * Copyright (C) 2008 Nokia Corporation * * Contact: Jarkko Nikula - * Peter Ujfalusi + * Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License -- cgit v0.10.2 From 1c7687b9958369e4e41018f4e2b4e0f901e13722 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 3 May 2011 18:14:43 +0300 Subject: ASoC: omap-pcm: Update e-mail address Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Acked-by: Jarkko Nikula Signed-off-by: Liam Girdwood diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 8caeb8d..0c6eb30 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -4,7 +4,7 @@ * Copyright (C) 2008 Nokia Corporation * * Contact: Jarkko Nikula - * Peter Ujfalusi + * Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h index fea0515..a0ed1db 100644 --- a/sound/soc/omap/omap-pcm.h +++ b/sound/soc/omap/omap-pcm.h @@ -4,7 +4,7 @@ * Copyright (C) 2008 Nokia Corporation * * Contact: Jarkko Nikula - * Peter Ujfalusi + * Peter Ujfalusi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License -- cgit v0.10.2 From 0ac3a014b8cb0ea9a80d4f5c551ad1a7fa258a3c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 3 May 2011 18:15:10 +0300 Subject: ASoC: RX51: Update e-mail address Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Acked-by: Jarkko Nikula Signed-off-by: Liam Girdwood diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index d098622..0aae998 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 - 2009 Nokia Corporation * - * Contact: Peter Ujfalusi + * Contact: Peter Ujfalusi * Eduardo Valentin * Jarkko Nikula * -- cgit v0.10.2 From 3be79d13753058901814ae93043c290c5a9fdda5 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 2 May 2011 14:16:29 +0300 Subject: MAINTAINERS: Update e-mail address for asoc/twl4030 Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Signed-off-by: Liam Girdwood diff --git a/MAINTAINERS b/MAINTAINERS index 9f926c0..03cfc1c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6093,7 +6093,7 @@ F: drivers/mmc/host/tifm_sd.c F: include/linux/tifm.h TI TWL4030 SERIES SOC CODEC DRIVER -M: Peter Ujfalusi +M: Peter Ujfalusi L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Maintained F: sound/soc/codecs/twl4030* -- cgit v0.10.2 From 9e53d856af0db8acc8a1bc6a9e3298f6bbb8944b Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 8 May 2011 09:48:24 -0700 Subject: ASoC: fix wm8958-dsp2 printk format warnings Fix printk format warnings in wm8958-dsp2.c: sound/soc/codecs/wm8958-dsp2.c:103: warning: format '%d' expects type 'int', but argument 4 has type 'size_t' sound/soc/codecs/wm8958-dsp2.c:111: warning: format '%d' expects type 'int', but argument 3 has type 'size_t' sound/soc/codecs/wm8958-dsp2.c:144: warning: format '%d' expects type 'int', but argument 5 has type 'size_t' Signed-off-by: Randy Dunlap Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 74983ee..5d4bc7a 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -99,7 +99,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, len = fw->size - len; while (len) { if (len < 12) { - dev_err(codec->dev, "%s short data block of %d\n", + dev_err(codec->dev, "%s short data block of %zd\n", name, len); goto err; } @@ -107,7 +107,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, memcpy(&data32, data + 4, sizeof(data32)); block_len = be32_to_cpu(data32); if (block_len + 8 > len) { - dev_err(codec->dev, "%d byte block longer than file\n", + dev_err(codec->dev, "%zd byte block longer than file\n", block_len); goto err; } @@ -141,7 +141,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, case WM_FW_BLOCK_I: case WM_FW_BLOCK_A: case WM_FW_BLOCK_C: - dev_dbg(codec->dev, "%s: %d bytes of %x@%x\n", name, + dev_dbg(codec->dev, "%s: %zd bytes of %x@%x\n", name, block_len, (data32 >> 24) & 0xff, data32 & 0xffffff); -- cgit v0.10.2 From 22de71ba03311cdc1063757c50a1488cb90a1fca Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 12 May 2011 16:14:04 +0100 Subject: ASoC: core - allow ASoC more flexible machine name Allow ASoC machine drivers to register a driver name and a longname. This allows user space to determine the flavour of machine driver. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/include/sound/soc.h b/include/sound/soc.h index b27c7a2..f1de3e0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -702,6 +702,8 @@ struct snd_soc_aux_dev { /* SoC card */ struct snd_soc_card { const char *name; + const char *long_name; + const char *driver_name; struct device *dev; struct snd_card *snd_card; struct module *owner; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a477e21..c1a4cf4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1926,9 +1926,11 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) card->num_dapm_routes); snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), - "%s", card->name); - snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), "%s", card->name); + snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), + "%s", card->long_name ? card->long_name : card->name); + snprintf(card->snd_card->driver, sizeof(card->snd_card->driver), + "%s", card->driver_name); if (card->late_probe) { ret = card->late_probe(card); -- cgit v0.10.2 From d5e4b0adf6e694f9a8fb31f51fc381bd8be17eae Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Thu, 12 May 2011 16:26:20 +0100 Subject: ASoC: DMIC codec - Add input widget Digital microphones can have some additional elements in their audio path (like microphone bias). An input widget is required for digital microphone CODEC driver to allow external connections in machine drivers. Signed-off-by: Misael Lopez Cruz Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index 57e9dac..f9a8773 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -39,7 +39,31 @@ static struct snd_soc_dai_driver dmic_dai = { }, }; -static struct snd_soc_codec_driver soc_dmic = {}; +static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { + SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0, + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_INPUT("DMic"), +}; + +static const struct snd_soc_dapm_route intercon[] = { + {"DMIC AIF", NULL, "DMic"}, +}; + +static int dmic_probe(struct snd_soc_codec *codec) +{ + struct snd_soc_dapm_context *dapm = &codec->dapm; + + snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets, + ARRAY_SIZE(dmic_dapm_widgets)); + snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); + snd_soc_dapm_new_widgets(dapm); + + return 0; +} + +static struct snd_soc_codec_driver soc_dmic = { + .probe = dmic_probe, +}; static int __devinit dmic_dev_probe(struct platform_device *pdev) { -- cgit v0.10.2 From 1f71a3ba8f845d2b2538e79bafb99ac835c84ea6 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 28 Mar 2011 19:23:23 +0100 Subject: ASoC: twl6040 - fix LINEGAIN volume control Fix the TWL6040 LINEGAIN volume control to match the TRM. Acked-by: Mark Brown Signed-off-by: Liam Girdwood diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 255901c..4c33663 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -960,9 +960,9 @@ static DECLARE_TLV_DB_SCALE(mic_amp_tlv, -600, 600, 0); /* * AFMGAIN volume control: - * from 18 to 24 dB in 6 dB steps + * from -18 to 24 dB in 6 dB steps */ -static DECLARE_TLV_DB_SCALE(afm_amp_tlv, 1800, 600, 0); +static DECLARE_TLV_DB_SCALE(afm_amp_tlv, -1800, 600, 0); /* * HSGAIN volume control: @@ -1049,7 +1049,7 @@ static const struct snd_kcontrol_new twl6040_snd_controls[] = { /* AFM gains */ SOC_DOUBLE_TLV("Aux FM Volume", - TWL6040_REG_LINEGAIN, 0, 4, 0xF, 0, afm_amp_tlv), + TWL6040_REG_LINEGAIN, 0, 3, 7, 0, afm_amp_tlv), /* Playback gains */ SOC_TWL6040_DOUBLE_TLV("Headset Playback Volume", -- cgit v0.10.2 From 63405ce85a4d902bd64ccb4477473d661ae52c95 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 12 May 2011 18:49:15 +0100 Subject: MAINTAINERS: ASoC and Regulator email address change. Update my email address to new employer. Acked-by: Mark Brown Signed-off-by: Liam Girdwood diff --git a/MAINTAINERS b/MAINTAINERS index 03cfc1c..75318bf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5840,7 +5840,7 @@ F: include/sound/ F: sound/ SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC) -M: Liam Girdwood +M: Liam Girdwood M: Mark Brown T: git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git L: alsa-devel@alsa-project.org (moderated for non-subscribers) @@ -6736,7 +6736,7 @@ F: drivers/scsi/vmw_pvscsi.c F: drivers/scsi/vmw_pvscsi.h VOLTAGE AND CURRENT REGULATOR FRAMEWORK -M: Liam Girdwood +M: Liam Girdwood M: Mark Brown W: http://opensource.wolfsonmicro.com/node/15 W: http://www.slimlogic.co.uk/?p=48 -- cgit v0.10.2 From b417382419c67fda6463e02eafb8efebd5f8759e Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 12 May 2011 13:04:55 +0300 Subject: ASoC: omap-pcm: Period wakeup disabling on OMAP2+ Allow disabling ALSA period wakeup interrupts. This can only be done on OMAP2+ (2/3/4), since there we can chain the DMA. Signed-off-by: Peter Ujfalusi Acked-by: Mark Brown Acked-by: Jarkko Nikula Signed-off-by: Liam Girdwood diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 0c6eb30..e6a6b99 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -37,7 +37,8 @@ static const struct snd_pcm_hardware omap_pcm_hardware = { SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_RESUME, + SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, .period_bytes_min = 32, @@ -195,7 +196,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) if ((cpu_is_omap1510())) omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ | OMAP_DMA_LAST_IRQ | OMAP_DMA_BLOCK_IRQ); - else + else if (!substream->runtime->no_period_wakeup) omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ); if (!(cpu_class_is_omap1())) { -- cgit v0.10.2 From d491297752c3a36f6cfabd4cd578c0cfa2098044 Mon Sep 17 00:00:00 2001 From: Sanjeev Premi Date: Wed, 11 May 2011 19:25:35 +0530 Subject: ASoC: omap-mcbsp: Remove restrictive checks for cpu type Current checks for cpu type were too restrictive leading to failures for other silicons in same family. The problem was found while testing audio playback on AM37x and AM35x processors. But should exist on OMAP36xx as well. Signed-off-by: Sanjeev Premi cc: Mark Brown cc: Liam Girdwood cc: Jarkko Nikula Acked-by: Jarkko Nikula Acked-by: Peter Ujfalusi Acked-by: Mark Brown Signed-off-by: Liam Girdwood diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index afbc7be..07b7723 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -146,7 +146,7 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, * 2 channels (stereo): size is 128 / 2 = 64 frames (2 * 64 words) * 4 channels: size is 128 / 4 = 32 frames (4 * 32 words) */ - if (cpu_is_omap343x() || cpu_is_omap44xx()) { + if (cpu_is_omap34xx() || cpu_is_omap44xx()) { /* * Rule for the buffer size. We should not allow * smaller buffer than the FIFO size to avoid underruns @@ -258,7 +258,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - if (cpu_is_omap343x()) { + if (cpu_is_omap34xx()) { dma_data->set_threshold = omap_mcbsp_set_threshold; /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ if (omap_mcbsp_get_dma_op_mode(bus_id) == -- cgit v0.10.2 From f7391fce6a1553ed3375ee4d73f2deaa3fd69732 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 May 2011 19:25:42 +0200 Subject: ASoC: Reintroduce do_spi_write() There is an unfortunate difference in return values between spi_write() and i2c_master_send() so we need an adaptor function to translate. Reported-by: Lars-Peter Clausen Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 01e5b98..06b7b81 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -20,6 +20,20 @@ #include +#ifdef CONFIG_SPI_MASTER +static int do_spi_write(void *control, const char *data, int len) +{ + struct spi_device *spi = control; + int ret; + + ret = spi_write(spi, data, len); + if (ret < 0) + return ret; + + return len; +} +#endif + static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value, const void *data, int len) { @@ -412,7 +426,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, case SND_SOC_SPI: #ifdef CONFIG_SPI_MASTER - codec->hw_write = (hw_write_t)spi_write; + codec->hw_write = do_spi_write; #endif codec->control_data = container_of(codec->dev, -- cgit v0.10.2 From 770939c37feb4b9c88f4de8482ff922af64d20ee Mon Sep 17 00:00:00 2001 From: Jin Park Date: Thu, 12 May 2011 14:58:36 +0900 Subject: ASoC: codecs: max98088: Fixed invalid register definitions in mixer controls Fixed invalid register definitions in mixer controls such as left speaker mixer, left hp mixer and left rec mixer. Signed-off-by: Jin Park Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index bb58bdb..87cd5f6 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -808,10 +808,10 @@ static const struct snd_kcontrol_new max98088_snd_controls[] = { /* Left speaker mixer switch */ static const struct snd_kcontrol_new max98088_left_speaker_mixer_controls[] = { - SOC_DAPM_SINGLE("Left DAC1 Switch", M98088_REG_2B_MIX_SPK_LEFT, 7, 1, 0), - SOC_DAPM_SINGLE("Right DAC1 Switch", M98088_REG_2B_MIX_SPK_LEFT, 0, 1, 0), - SOC_DAPM_SINGLE("Left DAC2 Switch", M98088_REG_2B_MIX_SPK_LEFT, 7, 1, 0), - SOC_DAPM_SINGLE("Right DAC2 Switch", M98088_REG_2B_MIX_SPK_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Left DAC1 Switch", M98088_REG_2B_MIX_SPK_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Right DAC1 Switch", M98088_REG_2B_MIX_SPK_LEFT, 7, 1, 0), + SOC_DAPM_SINGLE("Left DAC2 Switch", M98088_REG_2B_MIX_SPK_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Right DAC2 Switch", M98088_REG_2B_MIX_SPK_LEFT, 7, 1, 0), SOC_DAPM_SINGLE("MIC1 Switch", M98088_REG_2B_MIX_SPK_LEFT, 5, 1, 0), SOC_DAPM_SINGLE("MIC2 Switch", M98088_REG_2B_MIX_SPK_LEFT, 6, 1, 0), SOC_DAPM_SINGLE("INA1 Switch", M98088_REG_2B_MIX_SPK_LEFT, 1, 1, 0), @@ -836,10 +836,10 @@ static const struct snd_kcontrol_new max98088_right_speaker_mixer_controls[] = { /* Left headphone mixer switch */ static const struct snd_kcontrol_new max98088_left_hp_mixer_controls[] = { - SOC_DAPM_SINGLE("Left DAC1 Switch", M98088_REG_25_MIX_HP_LEFT, 7, 1, 0), - SOC_DAPM_SINGLE("Right DAC1 Switch", M98088_REG_25_MIX_HP_LEFT, 0, 1, 0), - SOC_DAPM_SINGLE("Left DAC2 Switch", M98088_REG_25_MIX_HP_LEFT, 7, 1, 0), - SOC_DAPM_SINGLE("Right DAC2 Switch", M98088_REG_25_MIX_HP_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Left DAC1 Switch", M98088_REG_25_MIX_HP_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Right DAC1 Switch", M98088_REG_25_MIX_HP_LEFT, 7, 1, 0), + SOC_DAPM_SINGLE("Left DAC2 Switch", M98088_REG_25_MIX_HP_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Right DAC2 Switch", M98088_REG_25_MIX_HP_LEFT, 7, 1, 0), SOC_DAPM_SINGLE("MIC1 Switch", M98088_REG_25_MIX_HP_LEFT, 5, 1, 0), SOC_DAPM_SINGLE("MIC2 Switch", M98088_REG_25_MIX_HP_LEFT, 6, 1, 0), SOC_DAPM_SINGLE("INA1 Switch", M98088_REG_25_MIX_HP_LEFT, 1, 1, 0), @@ -864,10 +864,10 @@ static const struct snd_kcontrol_new max98088_right_hp_mixer_controls[] = { /* Left earpiece/receiver mixer switch */ static const struct snd_kcontrol_new max98088_left_rec_mixer_controls[] = { - SOC_DAPM_SINGLE("Left DAC1 Switch", M98088_REG_28_MIX_REC_LEFT, 7, 1, 0), - SOC_DAPM_SINGLE("Right DAC1 Switch", M98088_REG_28_MIX_REC_LEFT, 0, 1, 0), - SOC_DAPM_SINGLE("Left DAC2 Switch", M98088_REG_28_MIX_REC_LEFT, 7, 1, 0), - SOC_DAPM_SINGLE("Right DAC2 Switch", M98088_REG_28_MIX_REC_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Left DAC1 Switch", M98088_REG_28_MIX_REC_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Right DAC1 Switch", M98088_REG_28_MIX_REC_LEFT, 7, 1, 0), + SOC_DAPM_SINGLE("Left DAC2 Switch", M98088_REG_28_MIX_REC_LEFT, 0, 1, 0), + SOC_DAPM_SINGLE("Right DAC2 Switch", M98088_REG_28_MIX_REC_LEFT, 7, 1, 0), SOC_DAPM_SINGLE("MIC1 Switch", M98088_REG_28_MIX_REC_LEFT, 5, 1, 0), SOC_DAPM_SINGLE("MIC2 Switch", M98088_REG_28_MIX_REC_LEFT, 6, 1, 0), SOC_DAPM_SINGLE("INA1 Switch", M98088_REG_28_MIX_REC_LEFT, 1, 1, 0), -- cgit v0.10.2 From 938b4fbc916667cbe0410c325e7163c99a08c05f Mon Sep 17 00:00:00 2001 From: Jin Park Date: Thu, 12 May 2011 14:58:37 +0900 Subject: ASoC: codecs: max98088: Moved the EX Limiter Mode from dapm widget to control Moved the EX Limiter Mode from dapm widget to control, because it was not required DAPM route. Signed-off-by: Jin Park Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 87cd5f6..16eb906 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -656,8 +656,6 @@ static const struct soc_enum max98088_exmode_enum = ARRAY_SIZE(max98088_exmode_texts), max98088_exmode_texts, max98088_exmode_values); -static const struct snd_kcontrol_new max98088_exmode_controls = - SOC_DAPM_VALUE_ENUM("Route", max98088_exmode_enum); static const char *max98088_ex_thresh[] = { /* volts PP */ "0.6", "1.2", "1.8", "2.4", "3.0", "3.6", "4.2", "4.8"}; @@ -783,6 +781,7 @@ static const struct snd_kcontrol_new max98088_snd_controls[] = { SOC_SINGLE("EQ1 Switch", M98088_REG_49_CFG_LEVEL, 0, 1, 0), SOC_SINGLE("EQ2 Switch", M98088_REG_49_CFG_LEVEL, 1, 1, 0), + SOC_ENUM("EX Limiter Mode", max98088_exmode_enum), SOC_ENUM("EX Limiter Threshold", max98088_ex_thresh_enum), SOC_ENUM("DAI1 Filter Mode", max98088_filter_mode_enum), @@ -1094,9 +1093,6 @@ static const struct snd_soc_dapm_widget max98088_dapm_widgets[] = { SND_SOC_DAPM_MICBIAS("MICBIAS", M98088_REG_4C_PWR_EN_IN, 3, 0), - SND_SOC_DAPM_MUX("EX Limiter Mode", SND_SOC_NOPM, 0, 0, - &max98088_exmode_controls), - SND_SOC_DAPM_OUTPUT("HPL"), SND_SOC_DAPM_OUTPUT("HPR"), SND_SOC_DAPM_OUTPUT("SPKL"), -- cgit v0.10.2 From 25709f6d83cc23d6f2912194c77ebf850310223e Mon Sep 17 00:00:00 2001 From: Jin Park Date: Thu, 12 May 2011 14:58:38 +0900 Subject: ASoC: codecs: max98088: Added digital mute function in DAI1 and DAI2 Added digital mute function in DAI1 and DAI2. Signed-off-by: Jin Park Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 16eb906..4173b67 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -1566,6 +1566,36 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai, return 0; } +static int max98088_dai1_digital_mute(struct snd_soc_dai *codec_dai, int mute) +{ + struct snd_soc_codec *codec = codec_dai->codec; + int reg; + + if (mute) + reg = M98088_DAI_MUTE; + else + reg = 0; + + snd_soc_update_bits(codec, M98088_REG_2F_LVL_DAI1_PLAY, + M98088_DAI_MUTE_MASK, reg); + return 0; +} + +static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute) +{ + struct snd_soc_codec *codec = codec_dai->codec; + int reg; + + if (mute) + reg = M98088_DAI_MUTE; + else + reg = 0; + + snd_soc_update_bits(codec, M98088_REG_31_LVL_DAI2_PLAY, + M98088_DAI_MUTE_MASK, reg); + return 0; +} + static void max98088_sync_cache(struct snd_soc_codec *codec) { u16 *reg_cache = codec->reg_cache; @@ -1627,12 +1657,14 @@ static struct snd_soc_dai_ops max98088_dai1_ops = { .set_sysclk = max98088_dai_set_sysclk, .set_fmt = max98088_dai1_set_fmt, .hw_params = max98088_dai1_hw_params, + .digital_mute = max98088_dai1_digital_mute, }; static struct snd_soc_dai_ops max98088_dai2_ops = { .set_sysclk = max98088_dai_set_sysclk, .set_fmt = max98088_dai2_set_fmt, .hw_params = max98088_dai2_hw_params, + .digital_mute = max98088_dai2_digital_mute, }; static struct snd_soc_dai_driver max98088_dai[] = { diff --git a/sound/soc/codecs/max98088.h b/sound/soc/codecs/max98088.h index 56554c7..be89a4f 100644 --- a/sound/soc/codecs/max98088.h +++ b/sound/soc/codecs/max98088.h @@ -133,6 +133,19 @@ #define M98088_REC_LINEMODE (1<<7) #define M98088_REC_LINEMODE_MASK (1<<7) +/* M98088_REG_2D_MIX_SPK_CNTL */ + #define M98088_MIX_SPKR_GAIN_MASK (3<<2) + #define M98088_MIX_SPKR_GAIN_SHIFT 2 + #define M98088_MIX_SPKL_GAIN_MASK (3<<0) + #define M98088_MIX_SPKL_GAIN_SHIFT 0 + +/* M98088_REG_2F_LVL_DAI1_PLAY, M98088_REG_31_LVL_DAI2_PLAY */ + #define M98088_DAI_MUTE (1<<7) + #define M98088_DAI_MUTE_MASK (1<<7) + #define M98088_DAI_VOICE_GAIN_MASK (3<<4) + #define M98088_DAI_ATTENUATION_MASK (0xF<<0) + #define M98088_DAI_ATTENUATION_SHIFT 0 + /* M98088_REG_35_LVL_MIC1, M98088_REG_36_LVL_MIC2 */ #define M98088_MICPRE_MASK (3<<5) #define M98088_MICPRE_SHIFT 5 -- cgit v0.10.2 From d0b48af6c2b887354d0893e598d92911ce52620e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 14 May 2011 17:21:28 -0700 Subject: ASoC: Ensure output PGA is enabled for line outputs in wm_hubs Also fix a left/right typo while we're at it. Signed-off-by: Mark Brown Acked-by: Liam Girdwood Date: Sun, 15 May 2011 12:18:38 -0700 Subject: ASoC: Add some missing volume update bit sets for wm_hubs devices Signed-off-by: Mark Brown Acked-by: Liam Girdwood Cc: stable@kernel.org diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index c7c2fec..e55b298 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -836,17 +836,21 @@ int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, WM8993_IN2_VU, WM8993_IN2_VU); + snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_LEFT, + WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, - WM8993_HPOUT1L_ZC, WM8993_HPOUT1L_ZC); + WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC, + WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC); snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, - WM8993_MIXOUTL_ZC, WM8993_MIXOUTL_ZC); + WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU, + WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU); snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); -- cgit v0.10.2 From d7fdae7c6533b9a409158c736781cdd352b76793 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 15 May 2011 18:02:53 -0700 Subject: ASoC: Skip noop reconfiguration of WM8958 DSP2 algorithms If we're setting the currently applied value for one of the DSP algorithm configurations we can just skip all the handling as the control set is a noop. This ensures we do not disrupt a running DSP. Signed-off-by: Mark Brown Acked-by: Liam Girdwood Cc: stable@kernel.org diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 5d4bc7a..ca26779 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -508,6 +508,9 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) + return 0; + if (ucontrol->value.integer.value[0] > 1) return -EINVAL; @@ -628,6 +631,9 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) + return 0; + if (ucontrol->value.integer.value[0] > 1) return -EINVAL; @@ -689,6 +695,16 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + if (hpf < 3) { + if (wm8994->hpf1_ena[hpf % 3] == + ucontrol->value.integer.value[0]) + return 0; + } else { + if (wm8994->hpf2_ena[hpf % 3] == + ucontrol->value.integer.value[0]) + return 0; + } + if (ucontrol->value.integer.value[0] > 1) return -EINVAL; @@ -782,6 +798,9 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) + return 0; + if (ucontrol->value.integer.value[0] > 1) return -EINVAL; -- cgit v0.10.2 From fa63e477ddb09075f68cd5fe4db8f8045627a787 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 15 May 2011 18:18:56 -0700 Subject: ASoC: Don't restart an already running WM8958 DSP2 Don't want to upset the DSP. Signed-off-by: Mark Brown Acked-by: Liam Girdwood Cc: stable@kernel.org diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index ca26779..0293763 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -362,6 +362,10 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) path, wm8994->dsp_active, start, pwr_reg, reg); if (start && ena) { + /* If the DSP is already running then noop */ + if (reg & WM8958_DSP2_ENA) + return; + /* If either AIFnCLK is not yet enabled postpone */ if (!(snd_soc_read(codec, WM8994_AIF1_CLOCKING_1) & WM8994_AIF1CLK_ENA_MASK) && -- cgit v0.10.2 From 9d03545d886bedd2c81b8f28ae0cc68c356d02f7 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Fri, 13 May 2011 19:16:52 +0300 Subject: ASoC: Fix wrong data type access in a few codec drivers Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol") changed the control private data type that is passed to snd_soc_cnew when creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type. Signed-off-by: Jarkko Nikula Tested-by: Stephen Warren Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 6c43c13..c3d96fc 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -157,7 +157,8 @@ static int aic3x_read(struct snd_soc_codec *codec, unsigned int reg, static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int reg = mc->reg; diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 957cd66..43e3d76 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -382,7 +382,8 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); u16 reg; diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index 056aef9..9e5ff78 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c @@ -718,7 +718,8 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w, static int class_w_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); int ret; diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index e6dfa10..970a95c 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -877,7 +877,8 @@ static const char *hp_mux_text[] = { static int wm8994_put_hp_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget *w = wlist->widgets[0]; struct snd_soc_codec *codec = w->codec; int ret; @@ -1004,7 +1005,8 @@ SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING, static int wm8994_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget *w = wlist->widgets[0]; struct snd_soc_codec *codec = w->codec; int ret; diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index 67eaaec..5ad873f 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -305,11 +305,11 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source, static int wm8995_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *w; + struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_widget *w = wlist->widgets[0]; struct snd_soc_codec *codec; int ret; - w = snd_kcontrol_chip(kcontrol); codec = w->codec; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); wm8995_update_class_w(codec); -- cgit v0.10.2 From 34e268d87d60da7968d7300aae7d575be9d16ae7 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Thu, 12 May 2011 16:50:10 -0700 Subject: ASoC: Silence DEBUG_STRICT_USER_COPY_CHECKS=y warning Enabling DEBUG_STRICT_USER_COPY_CHECKS causes the following warning: In file included from arch/x86/include/asm/uaccess.h:573, from include/linux/poll.h:14, from include/sound/pcm.h:29, from include/sound/ac97_codec.h:31, from sound/soc/soc-core.c:34: In function 'copy_from_user', inlined from 'codec_reg_write_file' at sound/soc/soc-core.c:252: arch/x86/include/asm/uaccess_64.h:65: warning: call to 'copy_from_user_overflow' declared with attribute warning: copy_from_user() buffer size is not provably correct presumably due to buf_size being signed causing GCC to fail to see that buf_size can't become negative. Acked-by: Liam Girdwood Signed-off-by: Stephen Boyd Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c1a4cf4..5968745 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -242,7 +242,7 @@ static ssize_t codec_reg_write_file(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { char buf[32]; - int buf_size; + size_t buf_size; char *start = buf; unsigned long reg, value; int step = 1; -- cgit v0.10.2 From 539494253547d078089cc15490e83f6e5f2e7213 Mon Sep 17 00:00:00 2001 From: Taylor Hutt Date: Tue, 17 May 2011 18:03:54 -0700 Subject: ASoC: Max98095: Move existing NULL check before pointer dereference. Visual inspection shows that max98095_put_eq_enum() and max98095_put_bq_enum() each have a possible NULL deref of 'pdata'. This change moves the NULL check above the use. Signed-off-by: Taylor Hutt Acked-by: Peter Hsiang Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index a6cc94e..e1d282d 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -1872,16 +1872,14 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, BUG_ON(channel > 1); - cdata = &max98095->dai[channel]; + if (!pdata || !max98095->eq_textcnt) + return 0; if (sel >= pdata->eq_cfgcnt) return -EINVAL; + cdata = &max98095->dai[channel]; cdata->eq_sel = sel; - - if (!pdata || !max98095->eq_textcnt) - return 0; - fs = cdata->rate; /* Find the selected configuration with nearest sample rate */ @@ -2020,16 +2018,14 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, BUG_ON(channel > 1); - cdata = &max98095->dai[channel]; + if (!pdata || !max98095->bq_textcnt) + return 0; if (sel >= pdata->bq_cfgcnt) return -EINVAL; + cdata = &max98095->dai[channel]; cdata->bq_sel = sel; - - if (!pdata || !max98095->bq_textcnt) - return 0; - fs = cdata->rate; /* Find the selected configuration with nearest sample rate */ -- cgit v0.10.2 From 00d2701070c91728988bbfa414a346a23acd8275 Mon Sep 17 00:00:00 2001 From: Dmitry Artamonow Date: Wed, 18 May 2011 19:25:09 +0400 Subject: ASoC: Asahi Kasei AK4641 codec driver A driver for the AK4641 codec used in iPAQ hx4700 and Glofiish M800 among others. Signed-off-by: Harald Welte Signed-off-by: Philipp Zabel Signed-off-by: Dmitry Artamonow Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/include/sound/ak4641.h b/include/sound/ak4641.h new file mode 100644 index 0000000..96d1991 --- /dev/null +++ b/include/sound/ak4641.h @@ -0,0 +1,26 @@ +/* + * AK4641 ALSA SoC Codec driver + * + * Copyright 2009 Philipp Zabel + * + * 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. + */ + +#ifndef __AK4641_H +#define __AK4641_H + +/** + * struct ak4641_platform_data - platform specific AK4641 configuration + * @gpio_power: GPIO to control external power to AK4641 + * @gpio_npdn: GPIO connected to AK4641 nPDN pin + * + * Both GPIO parameters are optional. + */ +struct ak4641_platform_data { + int gpio_power; + int gpio_npdn; +}; + +#endif /* __AK4641_H */ diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2a69718..98175a0 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -20,6 +20,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ADS117X select SND_SOC_AK4104 if SPI_MASTER select SND_SOC_AK4535 if I2C + select SND_SOC_AK4641 if I2C select SND_SOC_AK4642 if I2C select SND_SOC_AK4671 if I2C select SND_SOC_ALC5623 if I2C @@ -139,6 +140,9 @@ config SND_SOC_AK4104 config SND_SOC_AK4535 tristate +config SND_SOC_AK4641 + tristate + config SND_SOC_AK4642 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 4cb2f42..fd85584 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -7,6 +7,7 @@ snd-soc-ad73311-objs := ad73311.o snd-soc-ads117x-objs := ads117x.o snd-soc-ak4104-objs := ak4104.o snd-soc-ak4535-objs := ak4535.o +snd-soc-ak4641-objs := ak4641.o snd-soc-ak4642-objs := ak4642.o snd-soc-ak4671-objs := ak4671.o snd-soc-cq93vc-objs := cq93vc.o @@ -97,6 +98,7 @@ obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o +obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c new file mode 100644 index 0000000..ed96f247c --- /dev/null +++ b/sound/soc/codecs/ak4641.c @@ -0,0 +1,664 @@ +/* + * ak4641.c -- AK4641 ALSA Soc Audio driver + * + * Copyright (C) 2008 Harald Welte + * Copyright (C) 2011 Dmitry Artamonow + * + * Based on ak4535.c by Richard Purdie + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ak4641.h" + +/* codec private data */ +struct ak4641_priv { + struct snd_soc_codec *codec; + unsigned int sysclk; + int deemph; + int playback_fs; +}; + +/* + * ak4641 register cache + */ +static const u8 ak4641_reg[AK4641_CACHEREGNUM] = { + 0x00, 0x80, 0x00, 0x80, + 0x02, 0x00, 0x11, 0x05, + 0x00, 0x00, 0x36, 0x10, + 0x00, 0x00, 0x57, 0x00, + 0x88, 0x88, 0x08, 0x08 +}; + +static const int deemph_settings[] = {44100, 0, 48000, 32000}; + +static int ak4641_set_deemph(struct snd_soc_codec *codec) +{ + struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + int i, best = 0; + + for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) { + /* if deemphasis is on, select the nearest available rate */ + if (ak4641->deemph && deemph_settings[i] != 0 && + abs(deemph_settings[i] - ak4641->playback_fs) < + abs(deemph_settings[best] - ak4641->playback_fs)) + best = i; + + if (!ak4641->deemph && deemph_settings[i] == 0) + best = i; + } + + dev_dbg(codec->dev, "Set deemphasis %d\n", best); + + return snd_soc_update_bits(codec, AK4641_DAC, 0x3, best); +} + +static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + int deemph = ucontrol->value.enumerated.item[0]; + + if (deemph > 1) + return -EINVAL; + + ak4641->deemph = deemph; + + return ak4641_set_deemph(codec); +} + +static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.enumerated.item[0] = ak4641->deemph; + return 0; +}; + +static const char *ak4641_mono_out[] = {"(L + R)/2", "Hi-Z"}; +static const char *ak4641_hp_out[] = {"Stereo", "Mono"}; +static const char *ak4641_mic_select[] = {"Internal", "External"}; +static const char *ak4641_mic_or_dac[] = {"Microphone", "Voice DAC"}; + + +static const DECLARE_TLV_DB_SCALE(mono_gain_tlv, -1700, 2300, 0); +static const DECLARE_TLV_DB_SCALE(mic_boost_tlv, 0, 2000, 0); +static const DECLARE_TLV_DB_SCALE(eq_tlv, -1050, 150, 0); +static const DECLARE_TLV_DB_SCALE(master_tlv, -12750, 50, 0); +static const DECLARE_TLV_DB_SCALE(mic_stereo_sidetone_tlv, -2700, 300, 0); +static const DECLARE_TLV_DB_SCALE(mic_mono_sidetone_tlv, -400, 400, 0); +static const DECLARE_TLV_DB_SCALE(capture_tlv, -800, 50, 0); +static const DECLARE_TLV_DB_SCALE(alc_tlv, -800, 50, 0); +static const DECLARE_TLV_DB_SCALE(aux_in_tlv, -2100, 300, 0); + + +static const struct soc_enum ak4641_mono_out_enum = + SOC_ENUM_SINGLE(AK4641_SIG1, 6, 2, ak4641_mono_out); +static const struct soc_enum ak4641_hp_out_enum = + SOC_ENUM_SINGLE(AK4641_MODE2, 2, 2, ak4641_hp_out); +static const struct soc_enum ak4641_mic_select_enum = + SOC_ENUM_SINGLE(AK4641_MIC, 1, 2, ak4641_mic_select); +static const struct soc_enum ak4641_mic_or_dac_enum = + SOC_ENUM_SINGLE(AK4641_BTIF, 4, 2, ak4641_mic_or_dac); + +static const struct snd_kcontrol_new ak4641_snd_controls[] = { + SOC_ENUM("Mono 1 Output", ak4641_mono_out_enum), + SOC_SINGLE_TLV("Mono 1 Gain Volume", AK4641_SIG1, 7, 1, 1, + mono_gain_tlv), + SOC_ENUM("Headphone Output", ak4641_hp_out_enum), + SOC_SINGLE_BOOL_EXT("Playback Deemphasis Switch", 0, + ak4641_get_deemph, ak4641_put_deemph), + + SOC_SINGLE_TLV("Mic Boost Volume", AK4641_MIC, 0, 1, 0, mic_boost_tlv), + + SOC_SINGLE("ALC Operation Time", AK4641_TIMER, 0, 3, 0), + SOC_SINGLE("ALC Recovery Time", AK4641_TIMER, 2, 3, 0), + SOC_SINGLE("ALC ZC Time", AK4641_TIMER, 4, 3, 0), + + SOC_SINGLE("ALC 1 Switch", AK4641_ALC1, 5, 1, 0), + + SOC_SINGLE_TLV("ALC Volume", AK4641_ALC2, 0, 71, 0, alc_tlv), + SOC_SINGLE("Left Out Enable Switch", AK4641_SIG2, 1, 1, 0), + SOC_SINGLE("Right Out Enable Switch", AK4641_SIG2, 0, 1, 0), + + SOC_SINGLE_TLV("Capture Volume", AK4641_PGA, 0, 71, 0, capture_tlv), + + SOC_DOUBLE_R_TLV("Master Playback Volume", AK4641_LATT, + AK4641_RATT, 0, 255, 1, master_tlv), + + SOC_SINGLE_TLV("AUX In Volume", AK4641_VOL, 0, 15, 0, aux_in_tlv), + + SOC_SINGLE("Equalizer Switch", AK4641_DAC, 2, 1, 0), + SOC_SINGLE_TLV("EQ1 100 Hz Volume", AK4641_EQLO, 0, 15, 1, eq_tlv), + SOC_SINGLE_TLV("EQ2 250 Hz Volume", AK4641_EQLO, 4, 15, 1, eq_tlv), + SOC_SINGLE_TLV("EQ3 1 kHz Volume", AK4641_EQMID, 0, 15, 1, eq_tlv), + SOC_SINGLE_TLV("EQ4 3.5 kHz Volume", AK4641_EQMID, 4, 15, 1, eq_tlv), + SOC_SINGLE_TLV("EQ5 10 kHz Volume", AK4641_EQHI, 0, 15, 1, eq_tlv), +}; + +/* Mono 1 Mixer */ +static const struct snd_kcontrol_new ak4641_mono1_mixer_controls[] = { + SOC_DAPM_SINGLE_TLV("Mic Mono Sidetone Volume", AK4641_VOL, 7, 1, 0, + mic_mono_sidetone_tlv), + SOC_DAPM_SINGLE("Mic Mono Sidetone Switch", AK4641_SIG1, 4, 1, 0), + SOC_DAPM_SINGLE("Mono Playback Switch", AK4641_SIG1, 5, 1, 0), +}; + +/* Stereo Mixer */ +static const struct snd_kcontrol_new ak4641_stereo_mixer_controls[] = { + SOC_DAPM_SINGLE_TLV("Mic Sidetone Volume", AK4641_VOL, 4, 7, 0, + mic_stereo_sidetone_tlv), + SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4641_SIG2, 4, 1, 0), + SOC_DAPM_SINGLE("Playback Switch", AK4641_SIG2, 7, 1, 0), + SOC_DAPM_SINGLE("Aux Bypass Switch", AK4641_SIG2, 5, 1, 0), +}; + +/* Input Mixer */ +static const struct snd_kcontrol_new ak4641_input_mixer_controls[] = { + SOC_DAPM_SINGLE("Mic Capture Switch", AK4641_MIC, 2, 1, 0), + SOC_DAPM_SINGLE("Aux Capture Switch", AK4641_MIC, 5, 1, 0), +}; + +/* Mic mux */ +static const struct snd_kcontrol_new ak4641_mic_mux_control = + SOC_DAPM_ENUM("Mic Select", ak4641_mic_select_enum); + +/* Input mux */ +static const struct snd_kcontrol_new ak4641_input_mux_control = + SOC_DAPM_ENUM("Input Select", ak4641_mic_or_dac_enum); + +/* mono 2 switch */ +static const struct snd_kcontrol_new ak4641_mono2_control = + SOC_DAPM_SINGLE("Switch", AK4641_SIG1, 0, 1, 0); + +/* ak4641 dapm widgets */ +static const struct snd_soc_dapm_widget ak4641_dapm_widgets[] = { + SND_SOC_DAPM_MIXER("Stereo Mixer", SND_SOC_NOPM, 0, 0, + &ak4641_stereo_mixer_controls[0], + ARRAY_SIZE(ak4641_stereo_mixer_controls)), + SND_SOC_DAPM_MIXER("Mono1 Mixer", SND_SOC_NOPM, 0, 0, + &ak4641_mono1_mixer_controls[0], + ARRAY_SIZE(ak4641_mono1_mixer_controls)), + SND_SOC_DAPM_MIXER("Input Mixer", SND_SOC_NOPM, 0, 0, + &ak4641_input_mixer_controls[0], + ARRAY_SIZE(ak4641_input_mixer_controls)), + SND_SOC_DAPM_MUX("Mic Mux", SND_SOC_NOPM, 0, 0, + &ak4641_mic_mux_control), + SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, + &ak4641_input_mux_control), + SND_SOC_DAPM_SWITCH("Mono 2 Enable", SND_SOC_NOPM, 0, 0, + &ak4641_mono2_control), + + SND_SOC_DAPM_OUTPUT("LOUT"), + SND_SOC_DAPM_OUTPUT("ROUT"), + SND_SOC_DAPM_OUTPUT("MOUT1"), + SND_SOC_DAPM_OUTPUT("MOUT2"), + SND_SOC_DAPM_OUTPUT("MICOUT"), + + SND_SOC_DAPM_ADC("ADC", "HiFi Capture", AK4641_PM1, 0, 0), + SND_SOC_DAPM_PGA("Mic", AK4641_PM1, 1, 0, NULL, 0), + SND_SOC_DAPM_PGA("AUX In", AK4641_PM1, 2, 0, NULL, 0), + SND_SOC_DAPM_PGA("Mono Out", AK4641_PM1, 3, 0, NULL, 0), + SND_SOC_DAPM_PGA("Line Out", AK4641_PM1, 4, 0, NULL, 0), + + SND_SOC_DAPM_DAC("DAC", "HiFi Playback", AK4641_PM2, 0, 0), + SND_SOC_DAPM_PGA("Mono Out 2", AK4641_PM2, 3, 0, NULL, 0), + + SND_SOC_DAPM_ADC("Voice ADC", "Voice Capture", AK4641_BTIF, 0, 0), + SND_SOC_DAPM_ADC("Voice DAC", "Voice Playback", AK4641_BTIF, 1, 0), + + SND_SOC_DAPM_MICBIAS("Mic Int Bias", AK4641_MIC, 3, 0), + SND_SOC_DAPM_MICBIAS("Mic Ext Bias", AK4641_MIC, 4, 0), + + SND_SOC_DAPM_INPUT("MICIN"), + SND_SOC_DAPM_INPUT("MICEXT"), + SND_SOC_DAPM_INPUT("AUX"), + SND_SOC_DAPM_INPUT("AIN"), +}; + +static const struct snd_soc_dapm_route ak4641_audio_map[] = { + /* Stereo Mixer */ + {"Stereo Mixer", "Playback Switch", "DAC"}, + {"Stereo Mixer", "Mic Sidetone Switch", "Input Mux"}, + {"Stereo Mixer", "Aux Bypass Switch", "AUX In"}, + + /* Mono 1 Mixer */ + {"Mono1 Mixer", "Mic Mono Sidetone Switch", "Input Mux"}, + {"Mono1 Mixer", "Mono Playback Switch", "DAC"}, + + /* Mic */ + {"Mic", NULL, "AIN"}, + {"Mic Mux", "Internal", "Mic Int Bias"}, + {"Mic Mux", "External", "Mic Ext Bias"}, + {"Mic Int Bias", NULL, "MICIN"}, + {"Mic Ext Bias", NULL, "MICEXT"}, + {"MICOUT", NULL, "Mic Mux"}, + + /* Input Mux */ + {"Input Mux", "Microphone", "Mic"}, + {"Input Mux", "Voice DAC", "Voice DAC"}, + + /* Line Out */ + {"LOUT", NULL, "Line Out"}, + {"ROUT", NULL, "Line Out"}, + {"Line Out", NULL, "Stereo Mixer"}, + + /* Mono 1 Out */ + {"MOUT1", NULL, "Mono Out"}, + {"Mono Out", NULL, "Mono1 Mixer"}, + + /* Mono 2 Out */ + {"MOUT2", NULL, "Mono 2 Enable"}, + {"Mono 2 Enable", "Switch", "Mono Out 2"}, + {"Mono Out 2", NULL, "Stereo Mixer"}, + + {"Voice ADC", NULL, "Mono 2 Enable"}, + + /* Aux In */ + {"AUX In", NULL, "AUX"}, + + /* ADC */ + {"ADC", NULL, "Input Mixer"}, + {"Input Mixer", "Mic Capture Switch", "Mic"}, + {"Input Mixer", "Aux Capture Switch", "AUX In"}, +}; + +static int ak4641_set_dai_sysclk(struct snd_soc_dai *codec_dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + + ak4641->sysclk = freq; + return 0; +} + +static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->codec; + struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + int rate = params_rate(params), fs = 256; + u8 mode2; + + if (rate) + fs = ak4641->sysclk / rate; + else + return -EINVAL; + + /* set fs */ + switch (fs) { + case 1024: + mode2 = (0x2 << 5); + break; + case 512: + mode2 = (0x1 << 5); + break; + case 256: + mode2 = (0x0 << 5); + break; + default: + dev_err(codec->dev, "Error: unsupported fs=%d\n", fs); + return -EINVAL; + } + + snd_soc_update_bits(codec, AK4641_MODE2, (0x3 << 5), mode2); + + /* Update de-emphasis filter for the new rate */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ak4641->playback_fs = rate; + ak4641_set_deemph(codec); + }; + + return 0; +} + +static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + u8 btif; + + /* interface format */ + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + btif = (0x3 << 5); + break; + case SND_SOC_DAIFMT_LEFT_J: + btif = (0x2 << 5); + break; + case SND_SOC_DAIFMT_DSP_A: /* MSB after FRM */ + btif = (0x0 << 5); + break; + case SND_SOC_DAIFMT_DSP_B: /* MSB during FRM */ + btif = (0x1 << 5); + break; + default: + return -EINVAL; + } + + return snd_soc_update_bits(codec, AK4641_BTIF, (0x3 << 5), btif); +} + +static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + u8 mode1 = 0; + + /* interface format */ + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + mode1 = 0x02; + break; + case SND_SOC_DAIFMT_LEFT_J: + mode1 = 0x01; + break; + default: + return -EINVAL; + } + + return snd_soc_write(codec, AK4641_MODE1, mode1); +} + +static int ak4641_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + + return snd_soc_update_bits(codec, AK4641_DAC, 0x20, mute ? 0x20 : 0); +} + +static int ak4641_set_bias_level(struct snd_soc_codec *codec, + enum snd_soc_bias_level level) +{ + struct ak4641_platform_data *pdata = codec->dev->platform_data; + int ret; + + switch (level) { + case SND_SOC_BIAS_ON: + /* unmute */ + snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0); + break; + case SND_SOC_BIAS_PREPARE: + /* mute */ + snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0x20); + break; + case SND_SOC_BIAS_STANDBY: + if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { + if (pdata && gpio_is_valid(pdata->gpio_power)) + gpio_set_value(pdata->gpio_power, 1); + mdelay(1); + if (pdata && gpio_is_valid(pdata->gpio_npdn)) + gpio_set_value(pdata->gpio_npdn, 1); + mdelay(1); + + ret = snd_soc_cache_sync(codec); + if (ret) { + dev_err(codec->dev, + "Failed to sync cache: %d\n", ret); + return ret; + } + } + snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0x80); + snd_soc_update_bits(codec, AK4641_PM2, 0x80, 0); + break; + case SND_SOC_BIAS_OFF: + snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0); + if (pdata && gpio_is_valid(pdata->gpio_npdn)) + gpio_set_value(pdata->gpio_npdn, 0); + if (pdata && gpio_is_valid(pdata->gpio_power)) + gpio_set_value(pdata->gpio_power, 0); + codec->cache_sync = 1; + break; + } + codec->dapm.bias_level = level; + return 0; +} + +#define AK4641_RATES (SNDRV_PCM_RATE_8000_48000) +#define AK4641_RATES_BT (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ + SNDRV_PCM_RATE_16000) +#define AK4641_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) + +static struct snd_soc_dai_ops ak4641_i2s_dai_ops = { + .hw_params = ak4641_i2s_hw_params, + .set_fmt = ak4641_i2s_set_dai_fmt, + .digital_mute = ak4641_mute, + .set_sysclk = ak4641_set_dai_sysclk, +}; + +static struct snd_soc_dai_ops ak4641_pcm_dai_ops = { + .hw_params = NULL, /* rates are controlled by BT chip */ + .set_fmt = ak4641_pcm_set_dai_fmt, + .digital_mute = ak4641_mute, + .set_sysclk = ak4641_set_dai_sysclk, +}; + +struct snd_soc_dai_driver ak4641_dai[] = { +{ + .name = "ak4641-hifi", + .id = 1, + .playback = { + .stream_name = "HiFi Playback", + .channels_min = 1, + .channels_max = 2, + .rates = AK4641_RATES, + .formats = AK4641_FORMATS, + }, + .capture = { + .stream_name = "HiFi Capture", + .channels_min = 1, + .channels_max = 2, + .rates = AK4641_RATES, + .formats = AK4641_FORMATS, + }, + .ops = &ak4641_i2s_dai_ops, + .symmetric_rates = 1, +}, +{ + .name = "ak4641-voice", + .id = 1, + .playback = { + .stream_name = "Voice Playback", + .channels_min = 1, + .channels_max = 1, + .rates = AK4641_RATES_BT, + .formats = AK4641_FORMATS, + }, + .capture = { + .stream_name = "Voice Capture", + .channels_min = 1, + .channels_max = 1, + .rates = AK4641_RATES_BT, + .formats = AK4641_FORMATS, + }, + .ops = &ak4641_pcm_dai_ops, + .symmetric_rates = 1, +}, +}; + +static int ak4641_suspend(struct snd_soc_codec *codec, pm_message_t state) +{ + ak4641_set_bias_level(codec, SND_SOC_BIAS_OFF); + return 0; +} + +static int ak4641_resume(struct snd_soc_codec *codec) +{ + ak4641_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + return 0; +} + +static int ak4641_probe(struct snd_soc_codec *codec) +{ + struct ak4641_platform_data *pdata = codec->dev->platform_data; + int ret; + + + if (pdata) { + if (gpio_is_valid(pdata->gpio_power)) { + ret = gpio_request_one(pdata->gpio_power, + GPIOF_OUT_INIT_LOW, "ak4641 power"); + if (ret) + goto err_out; + } + if (gpio_is_valid(pdata->gpio_npdn)) { + ret = gpio_request_one(pdata->gpio_npdn, + GPIOF_OUT_INIT_LOW, "ak4641 npdn"); + if (ret) + goto err_gpio; + + udelay(1); /* > 150 ns */ + gpio_set_value(pdata->gpio_npdn, 1); + } + } + + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); + if (ret != 0) { + dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); + goto err_register; + } + + /* power on device */ + ak4641_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + + return 0; + +err_register: + if (pdata) { + if (gpio_is_valid(pdata->gpio_power)) + gpio_set_value(pdata->gpio_power, 0); + if (gpio_is_valid(pdata->gpio_npdn)) + gpio_free(pdata->gpio_npdn); + } +err_gpio: + if (pdata && gpio_is_valid(pdata->gpio_power)) + gpio_free(pdata->gpio_power); +err_out: + return ret; +} + +static int ak4641_remove(struct snd_soc_codec *codec) +{ + struct ak4641_platform_data *pdata = codec->dev->platform_data; + + ak4641_set_bias_level(codec, SND_SOC_BIAS_OFF); + + if (pdata) { + if (gpio_is_valid(pdata->gpio_power)) { + gpio_set_value(pdata->gpio_power, 0); + gpio_free(pdata->gpio_power); + } + if (gpio_is_valid(pdata->gpio_npdn)) + gpio_free(pdata->gpio_npdn); + } + return 0; +} + + +static struct snd_soc_codec_driver soc_codec_dev_ak4641 = { + .probe = ak4641_probe, + .remove = ak4641_remove, + .suspend = ak4641_suspend, + .resume = ak4641_resume, + .controls = ak4641_snd_controls, + .num_controls = ARRAY_SIZE(ak4641_snd_controls), + .dapm_widgets = ak4641_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), + .dapm_routes = ak4641_audio_map, + .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), + .set_bias_level = ak4641_set_bias_level, + .reg_cache_size = ARRAY_SIZE(ak4641_reg), + .reg_word_size = sizeof(u8), + .reg_cache_default = ak4641_reg, + .reg_cache_step = 1, +}; + + +static int __devinit ak4641_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct ak4641_priv *ak4641; + int ret; + + ak4641 = kzalloc(sizeof(struct ak4641_priv), GFP_KERNEL); + if (!ak4641) + return -ENOMEM; + + i2c_set_clientdata(i2c, ak4641); + + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4641, + ak4641_dai, ARRAY_SIZE(ak4641_dai)); + if (ret < 0) + kfree(ak4641); + + return ret; +} + +static int __devexit ak4641_i2c_remove(struct i2c_client *i2c) +{ + snd_soc_unregister_codec(&i2c->dev); + kfree(i2c_get_clientdata(i2c)); + return 0; +} + +static const struct i2c_device_id ak4641_i2c_id[] = { + { "ak4641", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ak4641_i2c_id); + +static struct i2c_driver ak4641_i2c_driver = { + .driver = { + .name = "ak4641", + .owner = THIS_MODULE, + }, + .probe = ak4641_i2c_probe, + .remove = __devexit_p(ak4641_i2c_remove), + .id_table = ak4641_i2c_id, +}; + +static int __init ak4641_modinit(void) +{ + int ret; + + ret = i2c_add_driver(&ak4641_i2c_driver); + if (ret != 0) + pr_err("Failed to register AK4641 I2C driver: %d\n", ret); + + return ret; +} +module_init(ak4641_modinit); + +static void __exit ak4641_exit(void) +{ + i2c_del_driver(&ak4641_i2c_driver); +} +module_exit(ak4641_exit); + +MODULE_DESCRIPTION("SoC AK4641 driver"); +MODULE_AUTHOR("Harald Welte "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/ak4641.h b/sound/soc/codecs/ak4641.h new file mode 100644 index 0000000..4a26324 --- /dev/null +++ b/sound/soc/codecs/ak4641.h @@ -0,0 +1,47 @@ +/* + * ak4641.h -- AK4641 SoC Audio driver + * + * Copyright 2008 Harald Welte + * + * Based on ak4535.h + * + * 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. + */ + +#ifndef _AK4641_H +#define _AK4641_H + +/* AK4641 register space */ + +#define AK4641_PM1 0x00 +#define AK4641_PM2 0x01 +#define AK4641_SIG1 0x02 +#define AK4641_SIG2 0x03 +#define AK4641_MODE1 0x04 +#define AK4641_MODE2 0x05 +#define AK4641_DAC 0x06 +#define AK4641_MIC 0x07 +#define AK4641_TIMER 0x08 +#define AK4641_ALC1 0x09 +#define AK4641_ALC2 0x0a +#define AK4641_PGA 0x0b +#define AK4641_LATT 0x0c +#define AK4641_RATT 0x0d +#define AK4641_VOL 0x0e +#define AK4641_STATUS 0x0f +#define AK4641_EQLO 0x10 +#define AK4641_EQMID 0x11 +#define AK4641_EQHI 0x12 +#define AK4641_BTIF 0x13 + +#define AK4641_CACHEREGNUM 0x14 + + + +#define AK4641_DAI_HIFI 0 +#define AK4641_DAI_VOICE 1 + + +#endif -- cgit v0.10.2 From c26f642e2683fb1a367686bc0bac9f5947885cb6 Mon Sep 17 00:00:00 2001 From: Dmitry Artamonow Date: Wed, 18 May 2011 19:25:10 +0400 Subject: ASoC: add iPAQ hx4700 machine driver AK4641 connected via I2S and I2C, jack detection via GPIO. Signed-off-by: Philipp Zabel Signed-off-by: Dmitry Artamonow Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index 580f485..33ebc46 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig @@ -155,6 +155,15 @@ config SND_SOC_RAUMFELD help Say Y if you want to add support for SoC audio on Raumfeld devices +config SND_PXA2XX_SOC_HX4700 + tristate "SoC Audio support for HP iPAQ hx4700" + depends on SND_PXA2XX_SOC && MACH_H4700 + select SND_PXA2XX_SOC_I2S + select SND_SOC_AK4641 + help + Say Y if you want to add support for SoC audio on the + HP iPAQ hx4700. + config SND_PXA2XX_SOC_MAGICIAN tristate "SoC Audio support for HTC Magician" depends on SND_PXA2XX_SOC && MACH_MAGICIAN diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 0766016..af35762 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile @@ -22,6 +22,7 @@ snd-soc-palm27x-objs := palm27x.o snd-soc-saarb-objs := saarb.o snd-soc-tavorevb3-objs := tavorevb3.o snd-soc-zylonite-objs := zylonite.o +snd-soc-hx4700-objs := hx4700.o snd-soc-magician-objs := magician.o snd-soc-mioa701-objs := mioa701_wm9713.o snd-soc-z2-objs := z2.o @@ -37,6 +38,7 @@ obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o +obj-$(CONFIG_SND_PXA2XX_SOC_HX4700) += snd-soc-hx4700.o obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o obj-$(CONFIG_SND_PXA2XX_SOC_Z2) += snd-soc-z2.o diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c new file mode 100644 index 0000000..65c1248 --- /dev/null +++ b/sound/soc/pxa/hx4700.c @@ -0,0 +1,255 @@ +/* + * SoC audio for HP iPAQ hx4700 + * + * Copyright (c) 2009 Philipp Zabel + * + * 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. + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include "pxa2xx-i2s.h" + +#include "../codecs/ak4641.h" + +static struct snd_soc_jack hs_jack; + +/* Headphones jack detection DAPM pin */ +static struct snd_soc_jack_pin hs_jack_pin[] = { + { + .pin = "Headphone Jack", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Speaker", + /* disable speaker when hp jack is inserted */ + .mask = SND_JACK_HEADPHONE, + .invert = 1, + }, +}; + +/* Headphones jack detection GPIO */ +static struct snd_soc_jack_gpio hs_jack_gpio = { + .gpio = GPIO75_HX4700_EARPHONE_nDET, + .invert = true, + .name = "hp-gpio", + .report = SND_JACK_HEADPHONE, + .debounce_time = 200, +}; + +/* + * iPAQ hx4700 uses I2S for capture and playback. + */ +static int hx4700_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; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + int ret = 0; + + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, + SND_SOC_DAIFMT_MSB | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS); + if (ret < 0) + return ret; + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, + SND_SOC_DAIFMT_MSB | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS); + if (ret < 0) + return ret; + + /* set the I2S system clock as output */ + ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0, + SND_SOC_CLOCK_OUT); + if (ret < 0) + return ret; + + /* inform codec driver about clock freq * + * (PXA I2S always uses divider 256) */ + ret = snd_soc_dai_set_sysclk(codec_dai, 0, 256 * params_rate(params), + SND_SOC_CLOCK_IN); + if (ret < 0) + return ret; + + return 0; +} + +static struct snd_soc_ops hx4700_ops = { + .hw_params = hx4700_hw_params, +}; + +static int hx4700_spk_power(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + gpio_set_value(GPIO107_HX4700_SPK_nSD, !!SND_SOC_DAPM_EVENT_ON(event)); + return 0; +} + +static int hx4700_hp_power(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + gpio_set_value(GPIO92_HX4700_HP_DRIVER, !!SND_SOC_DAPM_EVENT_ON(event)); + return 0; +} + +/* hx4700 machine dapm widgets */ +static const struct snd_soc_dapm_widget hx4700_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", hx4700_hp_power), + SND_SOC_DAPM_SPK("Speaker", hx4700_spk_power), + SND_SOC_DAPM_MIC("Built-in Microphone", NULL), +}; + +/* hx4700 machine audio_map */ +static const struct snd_soc_dapm_route hx4700_audio_map[] = { + + /* Headphone connected to LOUT, ROUT */ + {"Headphone Jack", NULL, "LOUT"}, + {"Headphone Jack", NULL, "ROUT"}, + + /* Speaker connected to MOUT2 */ + {"Speaker", NULL, "MOUT2"}, + + /* Microphone connected to MICIN */ + {"MICIN", NULL, "Built-in Microphone"}, + {"AIN", NULL, "MICOUT"}, +}; + +/* + * Logic for a ak4641 as connected on a HP iPAQ hx4700 + */ +static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dapm_context *dapm = &codec->dapm; + int err; + + /* NC codec pins */ + /* FIXME: is anything connected here? */ + snd_soc_dapm_nc_pin(dapm, "MOUT1"); + snd_soc_dapm_nc_pin(dapm, "MICEXT"); + snd_soc_dapm_nc_pin(dapm, "AUX"); + + /* Jack detection API stuff */ + err = snd_soc_jack_new(codec, "Headphone Jack", + SND_JACK_HEADPHONE, &hs_jack); + if (err) + return err; + + err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pin), + hs_jack_pin); + if (err) + return err; + + err = snd_soc_jack_add_gpios(&hs_jack, 1, &hs_jack_gpio); + + return err; +} + +/* hx4700 digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link hx4700_dai = { + .name = "ak4641", + .stream_name = "AK4641", + .cpu_dai_name = "pxa2xx-i2s", + .codec_dai_name = "ak4641-hifi", + .platform_name = "pxa-pcm-audio", + .codec_name = "ak4641.0-0012", + .init = hx4700_ak4641_init, + .ops = &hx4700_ops, +}; + +/* hx4700 audio machine driver */ +static struct snd_soc_card snd_soc_card_hx4700 = { + .name = "iPAQ hx4700", + .dai_link = &hx4700_dai, + .num_links = 1, + .dapm_widgets = hx4700_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(hx4700_dapm_widgets), + .dapm_routes = hx4700_audio_map, + .num_dapm_routes = ARRAY_SIZE(hx4700_audio_map), +}; + +static struct gpio hx4700_audio_gpios[] = { + { GPIO107_HX4700_SPK_nSD, GPIOF_OUT_INIT_HIGH, "SPK_POWER" }, + { GPIO92_HX4700_HP_DRIVER, GPIOF_OUT_INIT_LOW, "EP_POWER" }, +}; + +static int __devinit hx4700_audio_probe(struct platform_device *pdev) +{ + int ret; + + if (!machine_is_h4700()) + return -ENODEV; + + ret = gpio_request_array(hx4700_audio_gpios, + ARRAY_SIZE(hx4700_audio_gpios)); + if (ret) + return ret; + + snd_soc_card_hx4700.dev = &pdev->dev; + ret = snd_soc_register_card(&snd_soc_card_hx4700); + if (ret) + return ret; + + return 0; +} + +static int __devexit hx4700_audio_remove(struct platform_device *pdev) +{ + snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio); + snd_soc_unregister_card(&snd_soc_card_hx4700); + + gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0); + gpio_set_value(GPIO107_HX4700_SPK_nSD, 0); + + gpio_free_array(hx4700_audio_gpios, ARRAY_SIZE(hx4700_audio_gpios)); + return 0; +} + +static struct platform_driver hx4700_audio_driver = { + .driver = { + .name = "hx4700-audio", + .owner = THIS_MODULE, + .pm = &snd_soc_pm_ops, + }, + .probe = hx4700_audio_probe, + .remove = __devexit_p(hx4700_audio_remove), +}; + +static int __init hx4700_modinit(void) +{ + return platform_driver_register(&hx4700_audio_driver); +} +module_init(hx4700_modinit); + +static void __exit hx4700_modexit(void) +{ + platform_driver_unregister(&hx4700_audio_driver); +} + +module_exit(hx4700_modexit); + +MODULE_AUTHOR("Philipp Zabel"); +MODULE_DESCRIPTION("ALSA SoC iPAQ hx4700"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:hx4700-audio"); -- cgit v0.10.2 From a0c8326397262f1817ee6c5212ad6adf43e3df36 Mon Sep 17 00:00:00 2001 From: Ben Gardiner Date: Wed, 18 May 2011 09:27:45 -0400 Subject: ASoC: davinci-mcasp: enable ping-pong SRAM buffers The davinci-i2s driver copies the platform data for playback and capture sram sizes which is in turn used by davinci-pcm to allocate ping-pong buffers. Copy also the platform data in davinci-mcasp probe. Signed-off-by: Ben Gardiner Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 4ddc6d3..8566238 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -909,6 +909,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; dma_data->asp_chan_q = pdata->asp_chan_q; dma_data->ram_chan_q = pdata->ram_chan_q; + dma_data->sram_size = pdata->sram_size_playback; dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset + mem->start); @@ -925,6 +926,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; dma_data->asp_chan_q = pdata->asp_chan_q; dma_data->ram_chan_q = pdata->ram_chan_q; + dma_data->sram_size = pdata->sram_size_capture; dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset + mem->start); -- cgit v0.10.2 From 6ae759e889d9fd1733f4392f5083ac8c899253c5 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 19 May 2011 17:44:46 -0600 Subject: ASoC: spdif-dit: Add missing MODULE_* MODULE_ALIAS is required so that the module will auto-load based on a platform_device registration in the board file. While we're at it, add some other MODULE_*. Signed-off-by: Stephen Warren Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/spdif_transciever.c b/sound/soc/codecs/spdif_transciever.c index 4c32b54..6a1a7e7 100644 --- a/sound/soc/codecs/spdif_transciever.c +++ b/sound/soc/codecs/spdif_transciever.c @@ -21,7 +21,7 @@ #include #include -MODULE_LICENSE("GPL"); +#define DRV_NAME "spdif-dit" #define STUB_RATES SNDRV_PCM_RATE_8000_96000 #define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE @@ -56,7 +56,7 @@ static struct platform_driver spdif_dit_driver = { .probe = spdif_dit_probe, .remove = spdif_dit_remove, .driver = { - .name = "spdif-dit", + .name = DRV_NAME, .owner = THIS_MODULE, }, }; @@ -74,3 +74,7 @@ static void __exit dit_exit(void) module_init(dit_modinit); module_exit(dit_exit); +MODULE_AUTHOR("Steve Chen "); +MODULE_DESCRIPTION("SPDIF dummy codec driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME); -- cgit v0.10.2 From 0dfe8da4921fdae6b9c77e320731e490d4b15a99 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 16 May 2011 14:19:27 -0600 Subject: ASoC: Tegra: Fix compile when debugfs not enabled The prototype of the inline dummy version of tegra_i2s_debug_add was not consistent with the real version. Reported-by: Rhyland-Klein Signed-off-by: Stephen Warren Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c index 4f5e2c9..6b817e2 100644 --- a/sound/soc/tegra/tegra_i2s.c +++ b/sound/soc/tegra/tegra_i2s.c @@ -114,7 +114,7 @@ static void tegra_i2s_debug_remove(struct tegra_i2s *i2s) debugfs_remove(i2s->debug); } #else -static inline void tegra_i2s_debug_add(struct tegra_i2s *i2s) +static inline void tegra_i2s_debug_add(struct tegra_i2s *i2s, int id) { } -- cgit v0.10.2 From 2b39535b9e54888649923beaab443af212b6c0fd Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Fri, 20 May 2011 15:47:40 +0300 Subject: ASoC: core: Don't set "(null)" as a driver name Commit 22de71b ("ASoC: core - allow ASoC more flexible machine name") writes "(null)" to driver name string in struct snd_card if card->driver_name is NULL. This causes segmentation faults with some user space ALSA utilities like aplay and arecord. Fix this by using the card->name if no driver name is specified. Signed-off-by: Jarkko Nikula Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 5968745..bb7cd58 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1930,7 +1930,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), "%s", card->long_name ? card->long_name : card->name); snprintf(card->snd_card->driver, sizeof(card->snd_card->driver), - "%s", card->driver_name); + "%s", card->driver_name ? card->driver_name : card->name); if (card->late_probe) { ret = card->late_probe(card); -- cgit v0.10.2 From 477a66948ef8683f182682cc68e8520baf8a5b43 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 24 May 2011 14:10:32 +0200 Subject: ASoC: fix raumfeld platform Commit f0fba2ad (ASoC: multi-component - ASoC Multi-Component Support) broke support for Raumfeld platforms as it didn't take into account the different hardware features on individual devices. In particular, Raumfeld speakers have no S/PDIF output, so the members of the snd_soc_card struct must be set dynamically. Signed-off-by: Daniel Mack Acked-by: Liam Girdwood Signed-off-by: Mark Brown Cc: stable@kernel.org diff --git a/sound/soc/pxa/raumfeld.c b/sound/soc/pxa/raumfeld.c index 2afabaf..1a591f1 100644 --- a/sound/soc/pxa/raumfeld.c +++ b/sound/soc/pxa/raumfeld.c @@ -151,13 +151,13 @@ static struct snd_soc_ops raumfeld_cs4270_ops = { .hw_params = raumfeld_cs4270_hw_params, }; -static int raumfeld_line_suspend(struct snd_soc_card *card) +static int raumfeld_analog_suspend(struct snd_soc_card *card) { raumfeld_enable_audio(false); return 0; } -static int raumfeld_line_resume(struct snd_soc_card *card) +static int raumfeld_analog_resume(struct snd_soc_card *card) { raumfeld_enable_audio(true); return 0; @@ -225,32 +225,53 @@ static struct snd_soc_ops raumfeld_ak4104_ops = { .hw_params = raumfeld_ak4104_hw_params, }; -static struct snd_soc_dai_link raumfeld_dai[] = { +#define DAI_LINK_CS4270 \ +{ \ + .name = "CS4270", \ + .stream_name = "CS4270", \ + .cpu_dai_name = "pxa-ssp-dai.0", \ + .platform_name = "pxa-pcm-audio", \ + .codec_dai_name = "cs4270-hifi", \ + .codec_name = "cs4270-codec.0-0048", \ + .ops = &raumfeld_cs4270_ops, \ +} + +#define DAI_LINK_AK4104 \ +{ \ + .name = "ak4104", \ + .stream_name = "Playback", \ + .cpu_dai_name = "pxa-ssp-dai.1", \ + .codec_dai_name = "ak4104-hifi", \ + .platform_name = "pxa-pcm-audio", \ + .ops = &raumfeld_ak4104_ops, \ + .codec_name = "spi0.0", \ +} + +static struct snd_soc_dai_link snd_soc_raumfeld_connector_dai[] = { - .name = "ak4104", - .stream_name = "Playback", - .cpu_dai_name = "pxa-ssp-dai.1", - .codec_dai_name = "ak4104-hifi", - .platform_name = "pxa-pcm-audio", - .ops = &raumfeld_ak4104_ops, - .codec_name = "ak4104-codec.0", -}, + DAI_LINK_CS4270, + DAI_LINK_AK4104, +}; + +static struct snd_soc_dai_link snd_soc_raumfeld_speaker_dai[] = { - .name = "CS4270", - .stream_name = "CS4270", - .cpu_dai_name = "pxa-ssp-dai.0", - .platform_name = "pxa-pcm-audio", - .codec_dai_name = "cs4270-hifi", - .codec_name = "cs4270-codec.0-0048", - .ops = &raumfeld_cs4270_ops, -},}; - -static struct snd_soc_card snd_soc_raumfeld = { - .name = "Raumfeld", - .dai_link = raumfeld_dai, - .suspend_post = raumfeld_line_suspend, - .resume_pre = raumfeld_line_resume, - .num_links = ARRAY_SIZE(raumfeld_dai), + DAI_LINK_CS4270, +}; + +static struct snd_soc_card snd_soc_raumfeld_connector = { + .name = "Raumfeld Connector", + .dai_link = snd_soc_raumfeld_connector_dai, + .num_links = ARRAY_SIZE(snd_soc_raumfeld_connector_dai), + .suspend_post = raumfeld_analog_suspend, + .resume_pre = raumfeld_analog_resume, +}; + +static struct snd_soc_card snd_soc_raumfeld_speaker = { + .name = "Raumfeld Speaker", + .dai_link = snd_soc_raumfeld_speaker_dai, + .num_links = ARRAY_SIZE(snd_soc_raumfeld_speaker_dai), + .suspend_post = raumfeld_analog_suspend, + .resume_pre = raumfeld_analog_resume, }; static struct platform_device *raumfeld_audio_device; @@ -271,22 +292,25 @@ static int __init raumfeld_audio_init(void) set_max9485_clk(MAX9485_MCLK_FREQ_122880); - /* Register LINE and SPDIF */ + /* Register analog device */ raumfeld_audio_device = platform_device_alloc("soc-audio", 0); if (!raumfeld_audio_device) return -ENOMEM; - platform_set_drvdata(raumfeld_audio_device, - &snd_soc_raumfeld); - ret = platform_device_add(raumfeld_audio_device); - - /* no S/PDIF on Speakers */ if (machine_is_raumfeld_speaker()) + platform_set_drvdata(raumfeld_audio_device, + &snd_soc_raumfeld_speaker); + + if (machine_is_raumfeld_connector()) + platform_set_drvdata(raumfeld_audio_device, + &snd_soc_raumfeld_connector); + + ret = platform_device_add(raumfeld_audio_device); + if (ret < 0) return ret; raumfeld_enable_audio(true); - - return ret; + return 0; } static void __exit raumfeld_audio_exit(void) -- cgit v0.10.2 From 61b61e3c5c9bf37ca2915ac981f444989ab22f10 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 24 May 2011 13:57:43 +0100 Subject: ASoC: core - fix module reference counting for CPU DAIs Currently CODEC and platform drivers have their module reference count incremented soc_probe_dai_link() whilst CPU DAI drivers have their reference count incremented in soc_bind_dai_link(). CPU DAIs should have their reference count incremented in soc_probe_dai_link() just like the CODEC and platform drivers. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index bb7cd58..07991d4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1306,10 +1306,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) /* no, then find CPU DAI from registered DAIs*/ list_for_each_entry(cpu_dai, &dai_list, list) { if (!strcmp(cpu_dai->name, dai_link->cpu_dai_name)) { - - if (!try_module_get(cpu_dai->dev->driver->owner)) - return -ENODEV; - rtd->cpu_dai = cpu_dai; goto find_codec; } @@ -1621,12 +1617,17 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num) rtd->pmdown_time = pmdown_time; /* probe the cpu_dai */ + if (!cpu_dai->probed) { + if (!try_module_get(cpu_dai->dev->driver->owner)) + return -ENODEV; + if (cpu_dai->driver->probe) { ret = cpu_dai->driver->probe(cpu_dai); if (ret < 0) { printk(KERN_ERR "asoc: failed to probe CPU DAI %s\n", cpu_dai->name); + module_put(cpu_dai->dev->driver->owner); return ret; } } -- cgit v0.10.2 From 92505299a131b47992d318f2875d5629ac870d87 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 24 May 2011 17:38:52 +0100 Subject: ASoC: core - remove superfluous new line. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 07991d4..d75043e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1617,7 +1617,6 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num) rtd->pmdown_time = pmdown_time; /* probe the cpu_dai */ - if (!cpu_dai->probed) { if (!try_module_get(cpu_dai->dev->driver->owner)) return -ENODEV; -- cgit v0.10.2 From 5a195b445020f6042c2096e5eb63ef900e7871ea Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Tue, 24 May 2011 11:50:57 +0200 Subject: ASoC: wm8731: fix wm8731_check_osc() connected condition The crystal oscillator is only enabled if the WM8731_SYSCLK_XTAL master clock is specified. Fix the connected() struct snd_soc_dapm_route function to take this into account. Oscillator is not enabled on machine that need it otherwise. Machine drivers have to make sure that they use the proper SYSCLK value. Signed-off-by: Nicolas Ferre Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 6dec7ce..2dc964b 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -198,7 +198,7 @@ static int wm8731_check_osc(struct snd_soc_dapm_widget *source, { struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(source->codec); - return wm8731->sysclk_type == WM8731_SYSCLK_MCLK; + return wm8731->sysclk_type == WM8731_SYSCLK_XTAL; } static const struct snd_soc_dapm_route wm8731_intercon[] = { -- cgit v0.10.2 From 6bb74a7293d73556321fd37aefe67f6086dc25d1 Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Tue, 24 May 2011 11:51:16 +0200 Subject: ASoC: sam9g20_wm8731: use the proper SYSCKL value at91sam9g20 is providing master clock to wm8731: not using a crystal but an external MCLK. We can avoid conflict and save power using WM8731_SYSCLK_MCLK as we do not need oscillator to be powered. Signed-off-by: Nicolas Ferre Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 28afbbf..95572d2 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -146,7 +146,7 @@ static int at91sam9g20ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) "at91sam9g20ek_wm8731 " ": at91sam9g20ek_wm8731_init() called\n"); - ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, + ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_MCLK, MCLK_RATE, SND_SOC_CLOCK_IN); if (ret < 0) { printk(KERN_ERR "Failed to set WM8731 SYSCLK: %d\n", ret); -- cgit v0.10.2 From 65afc4118d67f4b0934e6dc72d9b27397aea0354 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Thu, 26 May 2011 10:32:41 +0200 Subject: ASoC: Remove duplicate linux/delay.h inclusion. It's enough to include linux/delay.h just once in sound/soc/codecs/wm8915.c, so remove the duplicate. Signed-off-by: Jesper Juhl Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm8915.c b/sound/soc/codecs/wm8915.c index ccc9bd8..a0b1a72 100644 --- a/sound/soc/codecs/wm8915.c +++ b/sound/soc/codecs/wm8915.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include -- cgit v0.10.2 From 979f486944174760400f797d509c05a018132b98 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 26 May 2011 10:54:12 +0800 Subject: ASoC: wm1250-ev1: Define "WM1250 Output" with SND_SOC_DAPM_OUTPUT Codec output pin should be defined with SND_SOC_DAPM_OUTPUT. Signed-off-by: Axel Lin Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c index 14d0716..bcc2089 100644 --- a/sound/soc/codecs/wm1250-ev1.c +++ b/sound/soc/codecs/wm1250-ev1.c @@ -22,7 +22,7 @@ SND_SOC_DAPM_ADC("ADC", "wm1250-ev1 Capture", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_DAC("DAC", "wm1250-ev1 Playback", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_INPUT("WM1250 Input"), -SND_SOC_DAPM_INPUT("WM1250 Output"), +SND_SOC_DAPM_OUTPUT("WM1250 Output"), }; static const struct snd_soc_dapm_route wm1250_ev1_dapm_routes[] = { -- cgit v0.10.2 From ea77b94774b3cc67162d74894b49af7eb17071f0 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Thu, 26 May 2011 16:32:18 +0300 Subject: ASoC: Fix power down for widgetless per-card DAPM context case Commit 52ba67b ("ASoC: Force all DAPM contexts into the same bias state") powers up all the DAPM contexts in a card if any DAPM context becomes active. Unfortunately power down newer happens if per-card DAPM context doesn't have any widgets. Reason for this is that power state of per-card DAPM context without widgets is never cleared and thus all the DAPM contexts remain permanently active. Test for widgetless calling DAPM context in dapm_power_widgets() doesn't work for per-card DAPM context since power change is never originating from widgetless per-card DAPM context. Fix this by pre-clearing power state flag of non-codec DAPM context at the beginning of power sequence. Signed-off-by: Jarkko Nikula Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 456617e..999bb08 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1110,7 +1110,7 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) trace_snd_soc_dapm_start(card); list_for_each_entry(d, &card->dapm_list, list) - if (d->n_widgets) + if (d->n_widgets || d->codec == NULL) d->dev_power = 0; /* Check which widgets we need to power and store them in -- cgit v0.10.2 From 1007da0604b1d2f064bfecece0f131d57237b03f Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 26 May 2011 09:57:33 -0600 Subject: ASoC: Fix dapm_is_shared_kcontrol so everything isn't shared Commit af46800 ("ASoC: Implement mux control sharing") introduced function dapm_is_shared_kcontrol. When this function returns true, the naming of DAPM controls is derived from the kcontrol_new. Otherwise, the name comes from the widget (and possibly a widget's naming prefix). A bug in the implementation of dapm_is_shared_kcontrol made it return 1 in all cases. Hence, that commit caused a change in control naming for all controls instead of just shared controls. Specifically, a control is always considered shared because it is always compared against itself. Solve this by never comparing against the widget containing the control being created. Equally, controls should never be shared between DAPM contexts; when the same codec is instantiated multiple times, the same kcontrol_new will be used. However, the control should no be shared between the multiple instances. I tested that with the Tegra WM8903 driver: * Shared is now mostly 0 as expected, and sometimes 1. * The expected controls are still generated after this change. However, I don't have any systems that have a widget/control naming prefix, so I can't test that aspect. Thanks for Jarkko Nikula for pointing out how to fix this. Reported-by: Liam Girdwood Tested-by: Jarkko Nikula Signed-off-by: Stephen Warren Acked-by: Liam Girdwood Signed-off-by: Mark Brown diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 999bb08..776e6f4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -325,6 +325,7 @@ static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, } static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, + struct snd_soc_dapm_widget *kcontrolw, const struct snd_kcontrol_new *kcontrol_new, struct snd_kcontrol **kcontrol) { @@ -334,6 +335,8 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, *kcontrol = NULL; list_for_each_entry(w, &dapm->card->widgets, list) { + if (w == kcontrolw || w->dapm != kcontrolw->dapm) + continue; for (i = 0; i < w->num_kcontrols; i++) { if (&w->kcontrol_news[i] == kcontrol_new) { if (w->kcontrols) @@ -468,7 +471,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm, return -EINVAL; } - shared = dapm_is_shared_kcontrol(dapm, &w->kcontrol_news[0], + shared = dapm_is_shared_kcontrol(dapm, w, &w->kcontrol_news[0], &kcontrol); if (kcontrol) { wlist = kcontrol->private_data; -- cgit v0.10.2 From ea02c63d57d7ec099f66ddb2942b4022e865cd5f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 27 May 2011 21:56:16 +0800 Subject: ASoC: Fix wm_hubs input PGA ZC bits Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index e55b298..9e370d1 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -215,23 +215,23 @@ static const struct snd_kcontrol_new analogue_snd_controls[] = { SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, inpga_tlv), SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), -SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), +SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 6, 1, 0), SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, inpga_tlv), SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), -SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), +SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 6, 1, 0), SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, inpga_tlv), SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), -SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), +SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 6, 1, 0), SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, inpga_tlv), SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), -SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), +SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 6, 1, 0), SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0, inmix_sw_tlv), -- cgit v0.10.2