aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/atmel/atmel-pcm.c2
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c6
-rw-r--r--sound/soc/au1x/psc-ac97.c1
-rw-r--r--sound/soc/au1x/psc-i2s.c1
-rw-r--r--sound/soc/blackfin/bf5xx-ac97-pcm.c2
-rw-r--r--sound/soc/blackfin/bf5xx-ac97.c1
-rw-r--r--sound/soc/blackfin/bf5xx-i2s-pcm.c2
-rw-r--r--sound/soc/blackfin/bf5xx-tdm-pcm.c2
-rw-r--r--sound/soc/codecs/ac97.c16
-rw-r--r--sound/soc/codecs/ad1836.c1
-rw-r--r--sound/soc/codecs/ad1938.c1
-rw-r--r--sound/soc/codecs/ad1980.c1
-rw-r--r--sound/soc/codecs/ad73311.c1
-rw-r--r--sound/soc/codecs/ads117x.c1
-rw-r--r--sound/soc/codecs/ak4104.c7
-rw-r--r--sound/soc/codecs/ak4535.c1
-rw-r--r--sound/soc/codecs/ak4642.c1
-rw-r--r--sound/soc/codecs/ak4671.c1
-rw-r--r--sound/soc/codecs/cs4270.c1
-rw-r--r--sound/soc/codecs/cx20442.c1
-rw-r--r--sound/soc/codecs/da7210.c1
-rw-r--r--sound/soc/codecs/pcm3008.c1
-rw-r--r--sound/soc/codecs/ssm2602.c1
-rw-r--r--sound/soc/codecs/stac9766.c1
-rw-r--r--sound/soc/codecs/tlv320aic23.c1
-rw-r--r--sound/soc/codecs/tlv320aic26.c1
-rw-r--r--sound/soc/codecs/tlv320aic3x.c1
-rw-r--r--sound/soc/codecs/tlv320dac33.c11
-rw-r--r--sound/soc/codecs/tpa6130a2.c1
-rw-r--r--sound/soc/codecs/twl4030.c1
-rw-r--r--sound/soc/codecs/uda134x.c1
-rw-r--r--sound/soc/codecs/uda1380.c2
-rw-r--r--sound/soc/codecs/wm2000.c2
-rw-r--r--sound/soc/codecs/wm8350.c9
-rw-r--r--sound/soc/codecs/wm8400.c1
-rw-r--r--sound/soc/codecs/wm8510.c1
-rw-r--r--sound/soc/codecs/wm8523.c1
-rw-r--r--sound/soc/codecs/wm8580.c1
-rw-r--r--sound/soc/codecs/wm8711.c1
-rw-r--r--sound/soc/codecs/wm8727.c1
-rw-r--r--sound/soc/codecs/wm8728.c1
-rw-r--r--sound/soc/codecs/wm8731.c1
-rw-r--r--sound/soc/codecs/wm8750.c1
-rw-r--r--sound/soc/codecs/wm8753.c1
-rw-r--r--sound/soc/codecs/wm8776.c1
-rw-r--r--sound/soc/codecs/wm8900.c1
-rw-r--r--sound/soc/codecs/wm8903.c1
-rw-r--r--sound/soc/codecs/wm8904.c1
-rw-r--r--sound/soc/codecs/wm8940.c1
-rw-r--r--sound/soc/codecs/wm8955.c1
-rw-r--r--sound/soc/codecs/wm8960.c1
-rw-r--r--sound/soc/codecs/wm8961.c1
-rw-r--r--sound/soc/codecs/wm8971.c1
-rw-r--r--sound/soc/codecs/wm8974.c1
-rw-r--r--sound/soc/codecs/wm8978.c1
-rw-r--r--sound/soc/codecs/wm8988.c1
-rw-r--r--sound/soc/codecs/wm8990.c3
-rw-r--r--sound/soc/codecs/wm8993.c1
-rw-r--r--sound/soc/codecs/wm8994.c59
-rw-r--r--sound/soc/codecs/wm9081.c1
-rw-r--r--sound/soc/codecs/wm9705.c1
-rw-r--r--sound/soc/codecs/wm9712.c1
-rw-r--r--sound/soc/codecs/wm9713.c1
-rw-r--r--sound/soc/codecs/wm_hubs.c83
-rw-r--r--sound/soc/codecs/wm_hubs.h1
-rw-r--r--sound/soc/davinci/davinci-i2s.c4
-rw-r--r--sound/soc/davinci/davinci-mcasp.c4
-rw-r--r--sound/soc/davinci/davinci-pcm.c4
-rw-r--r--sound/soc/fsl/fsl_dma.c1
-rw-r--r--sound/soc/fsl/fsl_ssi.c1
-rw-r--r--sound/soc/fsl/mpc5200_dma.c1
-rw-r--r--sound/soc/fsl/mpc8610_hpcd.c1
-rw-r--r--sound/soc/fsl/soc-of-simple.c1
-rw-r--r--sound/soc/imx/Kconfig2
-rw-r--r--sound/soc/imx/imx-pcm-dma-mx2.c24
-rw-r--r--sound/soc/imx/imx-pcm-fiq.c56
-rw-r--r--sound/soc/imx/imx-ssi.c11
-rw-r--r--sound/soc/omap/mcpdm.c1
-rw-r--r--sound/soc/omap/omap-mcbsp.c148
-rw-r--r--sound/soc/omap/omap-mcbsp.h4
-rw-r--r--sound/soc/omap/omap-mcpdm.c3
-rw-r--r--sound/soc/omap/omap-pcm.c22
-rw-r--r--sound/soc/pxa/pxa-ssp.c117
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.c17
-rw-r--r--sound/soc/pxa/pxa2xx-i2s.c7
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c4
-rw-r--r--sound/soc/s3c24xx/s3c-ac97.c21
-rw-r--r--sound/soc/s3c24xx/s3c-dma.c4
-rw-r--r--sound/soc/s3c24xx/s3c-i2s-v2.c13
-rw-r--r--sound/soc/s3c24xx/s3c-pcm.c7
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.c19
-rw-r--r--sound/soc/s3c24xx/s3c64xx-i2s.c4
-rw-r--r--sound/soc/s6000/s6000-i2s.c4
-rw-r--r--sound/soc/s6000/s6000-pcm.c40
-rw-r--r--sound/soc/sh/Kconfig1
-rw-r--r--sound/soc/sh/dma-sh7760.c1
-rw-r--r--sound/soc/sh/fsi.c1
-rw-r--r--sound/soc/sh/siu.h2
-rw-r--r--sound/soc/sh/siu_dai.c1
-rw-r--r--sound/soc/sh/siu_pcm.c3
-rw-r--r--sound/soc/soc-core.c18
-rw-r--r--sound/soc/soc-dapm.c1
-rw-r--r--sound/soc/txx9/txx9aclc-ac97.c1
-rw-r--r--sound/soc/txx9/txx9aclc.c1
104 files changed, 592 insertions, 240 deletions
diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c
index 9ef6b96373f5..3e6628c8e665 100644
--- a/sound/soc/atmel/atmel-pcm.c
+++ b/sound/soc/atmel/atmel-pcm.c
@@ -180,7 +180,7 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
180 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 180 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
181 runtime->dma_bytes = params_buffer_bytes(params); 181 runtime->dma_bytes = params_buffer_bytes(params);
182 182
183 prtd->params = rtd->dai->cpu_dai->dma_data; 183 prtd->params = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
184 prtd->params->dma_intr_handler = atmel_pcm_dma_irq; 184 prtd->params->dma_intr_handler = atmel_pcm_dma_irq;
185 185
186 prtd->dma_buffer = runtime->dma_addr; 186 prtd->dma_buffer = runtime->dma_addr;
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index e588e63f18d2..0b59806905d1 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -363,12 +363,12 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
363 ssc_p->dma_params[dir] = dma_params; 363 ssc_p->dma_params[dir] = dma_params;
364 364
365 /* 365 /*
366 * The cpu_dai->dma_data field is only used to communicate the 366 * The snd_soc_pcm_stream->dma_data field is only used to communicate
367 * appropriate DMA parameters to the pcm driver hw_params() 367 * the appropriate DMA parameters to the pcm driver hw_params()
368 * function. It should not be used for other purposes 368 * function. It should not be used for other purposes
369 * as it is common to all substreams. 369 * as it is common to all substreams.
370 */ 370 */
371 rtd->dai->cpu_dai->dma_data = dma_params; 371 snd_soc_dai_set_dma_data(rtd->dai->cpu_dai, substream, dma_params);
372 372
373 channels = params_channels(params); 373 channels = params_channels(params);
374 374
diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c
index 340311d7fed5..a61ccd2d505f 100644
--- a/sound/soc/au1x/psc-ac97.c
+++ b/sound/soc/au1x/psc-ac97.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/slab.h>
20#include <linux/device.h> 21#include <linux/device.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c
index 0cf2ca61c776..495be6e71931 100644
--- a/sound/soc/au1x/psc-i2s.c
+++ b/sound/soc/au1x/psc-i2s.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h>
21#include <linux/suspend.h> 22#include <linux/suspend.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c
index 67cbfe7283da..5e7aacf3bb5a 100644
--- a/sound/soc/blackfin/bf5xx-ac97-pcm.c
+++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c
@@ -29,8 +29,8 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/slab.h>
33#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/gfp.h>
34 34
35#include <sound/core.h> 35#include <sound/core.h>
36#include <sound/pcm.h> 36#include <sound/pcm.h>
diff --git a/sound/soc/blackfin/bf5xx-ac97.c b/sound/soc/blackfin/bf5xx-ac97.c
index e69322978739..523b7fc33f4e 100644
--- a/sound/soc/blackfin/bf5xx-ac97.c
+++ b/sound/soc/blackfin/bf5xx-ac97.c
@@ -16,6 +16,7 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/wait.h> 17#include <linux/wait.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/slab.h>
19 20
20#include <sound/core.h> 21#include <sound/core.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c
index c6c6a4a7d948..1d2a1adf2575 100644
--- a/sound/soc/blackfin/bf5xx-i2s-pcm.c
+++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c
@@ -29,8 +29,8 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/slab.h>
33#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/gfp.h>
34 34
35#include <sound/core.h> 35#include <sound/core.h>
36#include <sound/pcm.h> 36#include <sound/pcm.h>
diff --git a/sound/soc/blackfin/bf5xx-tdm-pcm.c b/sound/soc/blackfin/bf5xx-tdm-pcm.c
index 5e03bb2f3cd7..6bac1ac1a315 100644
--- a/sound/soc/blackfin/bf5xx-tdm-pcm.c
+++ b/sound/soc/blackfin/bf5xx-tdm-pcm.c
@@ -29,8 +29,8 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/slab.h>
33#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/gfp.h>
34 34
35#include <sound/core.h> 35#include <sound/core.h>
36#include <sound/pcm.h> 36#include <sound/pcm.h>
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index a1bbe16b7f96..1f5e57a4bb7a 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/slab.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/device.h> 18#include <linux/device.h>
18#include <sound/core.h> 19#include <sound/core.h>
@@ -80,9 +81,11 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
80static int ac97_soc_probe(struct platform_device *pdev) 81static int ac97_soc_probe(struct platform_device *pdev)
81{ 82{
82 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 83 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
84 struct snd_soc_card *card = socdev->card;
83 struct snd_soc_codec *codec; 85 struct snd_soc_codec *codec;
84 struct snd_ac97_bus *ac97_bus; 86 struct snd_ac97_bus *ac97_bus;
85 struct snd_ac97_template ac97_template; 87 struct snd_ac97_template ac97_template;
88 int i;
86 int ret = 0; 89 int ret = 0;
87 90
88 printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION); 91 printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
@@ -102,12 +105,6 @@ static int ac97_soc_probe(struct platform_device *pdev)
102 INIT_LIST_HEAD(&codec->dapm_widgets); 105 INIT_LIST_HEAD(&codec->dapm_widgets);
103 INIT_LIST_HEAD(&codec->dapm_paths); 106 INIT_LIST_HEAD(&codec->dapm_paths);
104 107
105 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
106 if (ret < 0) {
107 printk(KERN_ERR "ASoC: failed to init gen ac97 glue\n");
108 goto err;
109 }
110
111 /* register pcms */ 108 /* register pcms */
112 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 109 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
113 if (ret < 0) 110 if (ret < 0)
@@ -123,6 +120,13 @@ static int ac97_soc_probe(struct platform_device *pdev)
123 if (ret < 0) 120 if (ret < 0)
124 goto bus_err; 121 goto bus_err;
125 122
123 for (i = 0; i < card->num_links; i++) {
124 if (card->dai_link[i].codec_dai->ac97_control) {
125 snd_ac97_dev_add_pdata(codec->ac97,
126 card->dai_link[i].cpu_dai->ac97_pdata);
127 }
128 }
129
126 return 0; 130 return 0;
127 131
128bus_err: 132bus_err:
diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c
index 3c80137d5938..11b62dee842c 100644
--- a/sound/soc/codecs/ad1836.c
+++ b/sound/soc/codecs/ad1836.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
20#include <linux/module.h> 21#include <linux/module.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
22#include <linux/device.h> 23#include <linux/device.h>
diff --git a/sound/soc/codecs/ad1938.c b/sound/soc/codecs/ad1938.c
index c233810d463d..240cd155b313 100644
--- a/sound/soc/codecs/ad1938.c
+++ b/sound/soc/codecs/ad1938.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/kernel.h> 32#include <linux/kernel.h>
32#include <linux/device.h> 33#include <linux/device.h>
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c
index 39c0f7584e65..042072738cdc 100644
--- a/sound/soc/codecs/ad1980.c
+++ b/sound/soc/codecs/ad1980.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/device.h> 18#include <linux/device.h>
diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c
index d2fcc601722c..475807bea2c2 100644
--- a/sound/soc/codecs/ad73311.c
+++ b/sound/soc/codecs/ad73311.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/slab.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/device.h> 17#include <linux/device.h>
diff --git a/sound/soc/codecs/ads117x.c b/sound/soc/codecs/ads117x.c
index cc96411ca3e6..f8e75edb27b7 100644
--- a/sound/soc/codecs/ads117x.c
+++ b/sound/soc/codecs/ads117x.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/slab.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/device.h> 16#include <linux/device.h>
16#include <sound/core.h> 17#include <sound/core.h>
diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c
index b9ef7e45891d..bdeb10dfd887 100644
--- a/sound/soc/codecs/ak4104.c
+++ b/sound/soc/codecs/ak4104.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/slab.h>
13#include <sound/core.h> 14#include <sound/core.h>
14#include <sound/soc.h> 15#include <sound/soc.h>
15#include <sound/initval.h> 16#include <sound/initval.h>
@@ -90,12 +91,10 @@ static int ak4104_spi_write(struct snd_soc_codec *codec, unsigned int reg,
90 if (reg >= codec->reg_cache_size) 91 if (reg >= codec->reg_cache_size)
91 return -EINVAL; 92 return -EINVAL;
92 93
93 reg &= AK4104_REG_MASK;
94 reg |= AK4104_WRITE;
95
96 /* only write to the hardware if value has changed */ 94 /* only write to the hardware if value has changed */
97 if (cache[reg] != value) { 95 if (cache[reg] != value) {
98 u8 tmp[2] = { reg, value }; 96 u8 tmp[2] = { (reg & AK4104_REG_MASK) | AK4104_WRITE, value };
97
99 if (spi_write(spi, tmp, sizeof(tmp))) { 98 if (spi_write(spi, tmp, sizeof(tmp))) {
100 dev_err(&spi->dev, "SPI write failed\n"); 99 dev_err(&spi->dev, "SPI write failed\n");
101 return -EIO; 100 return -EIO;
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c
index ff966567e2ba..352d1d08dbd9 100644
--- a/sound/soc/codecs/ak4535.c
+++ b/sound/soc/codecs/ak4535.c
@@ -19,6 +19,7 @@
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 3ef16bbc8c83..729859cf6ca8 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -29,6 +29,7 @@
29#include <linux/pm.h> 29#include <linux/pm.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/slab.h>
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/pcm.h> 34#include <sound/pcm.h>
34#include <sound/pcm_params.h> 35#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c
index 82fca284d007..926797a014c7 100644
--- a/sound/soc/codecs/ak4671.c
+++ b/sound/soc/codecs/ak4671.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/slab.h>
18#include <sound/soc.h> 19#include <sound/soc.h>
19#include <sound/soc-dapm.h> 20#include <sound/soc-dapm.h>
20#include <sound/initval.h> 21#include <sound/initval.h>
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index dfbeb2db61b3..81a62d198b70 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26#include <sound/core.h> 27#include <sound/core.h>
27#include <sound/soc.h> 28#include <sound/soc.h>
28#include <sound/initval.h> 29#include <sound/initval.h>
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index e000cdfec1ec..9f169c477108 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/tty.h> 16#include <linux/tty.h>
17#include <linux/slab.h>
17 18
18#include <sound/core.h> 19#include <sound/core.h>
19#include <sound/initval.h> 20#include <sound/initval.h>
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index cf2975a7294a..366daf1d044e 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -23,6 +23,7 @@
23#include <linux/pm.h> 23#include <linux/pm.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26#include <sound/core.h> 27#include <sound/core.h>
27#include <sound/pcm.h> 28#include <sound/pcm.h>
28#include <sound/pcm_params.h> 29#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c
index 2afcd0a8669d..5a5f187a2657 100644
--- a/sound/soc/codecs/pcm3008.c
+++ b/sound/soc/codecs/pcm3008.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/initval.h> 25#include <sound/initval.h>
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index d2ff1cde6883..29d0906a924a 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -33,6 +33,7 @@
33#include <linux/pm.h> 33#include <linux/pm.h>
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/slab.h>
36#include <sound/core.h> 37#include <sound/core.h>
37#include <sound/pcm.h> 38#include <sound/pcm.h>
38#include <sound/pcm_params.h> 39#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 81b8c9dfe7fc..3293629dcb3b 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/device.h> 20#include <linux/device.h>
20#include <sound/core.h> 21#include <sound/core.h>
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index da589d8664d0..776b79cde904 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -25,6 +25,7 @@
25#include <linux/pm.h> 25#include <linux/pm.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/slab.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include <sound/pcm.h> 30#include <sound/pcm.h>
30#include <sound/pcm_params.h> 31#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index 357b609196e3..b5b7d6a03844 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -13,6 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/sysfs.h> 14#include <linux/sysfs.h>
15#include <linux/spi/spi.h> 15#include <linux/spi/spi.h>
16#include <linux/slab.h>
16#include <sound/core.h> 17#include <sound/core.h>
17#include <sound/pcm.h> 18#include <sound/pcm.h>
18#include <sound/pcm_params.h> 19#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index e4b946a19ea3..4a6d56c3fed9 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -39,6 +39,7 @@
39#include <linux/pm.h> 39#include <linux/pm.h>
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/platform_device.h> 41#include <linux/platform_device.h>
42#include <linux/slab.h>
42#include <sound/core.h> 43#include <sound/core.h>
43#include <sound/pcm.h> 44#include <sound/pcm.h>
44#include <sound/pcm_params.h> 45#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index f9f367d29a90..d1e0e81ef30c 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -31,6 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/regulator/consumer.h> 33#include <linux/regulator/consumer.h>
34#include <linux/slab.h>
34#include <sound/core.h> 35#include <sound/core.h>
35#include <sound/pcm.h> 36#include <sound/pcm.h>
36#include <sound/pcm_params.h> 37#include <sound/pcm_params.h>
@@ -778,7 +779,7 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream)
778 if (dac33->fifo_mode) { 779 if (dac33->fifo_mode) {
779 /* Generic for all FIFO modes */ 780 /* Generic for all FIFO modes */
780 /* 50-51 : ASRC Control registers */ 781 /* 50-51 : ASRC Control registers */
781 dac33_write(codec, DAC33_ASRC_CTRL_A, (1 << 4)); /* div=2 */ 782 dac33_write(codec, DAC33_ASRC_CTRL_A, DAC33_SRCLKDIV(1));
782 dac33_write(codec, DAC33_ASRC_CTRL_B, 1); /* ??? */ 783 dac33_write(codec, DAC33_ASRC_CTRL_B, 1); /* ??? */
783 784
784 /* Write registers 0x34 and 0x35 (MSB, LSB) */ 785 /* Write registers 0x34 and 0x35 (MSB, LSB) */
@@ -1038,11 +1039,7 @@ static int dac33_set_dai_fmt(struct snd_soc_dai *codec_dai,
1038 case SND_SOC_DAIFMT_DSP_A: 1039 case SND_SOC_DAIFMT_DSP_A:
1039 aictrl_a |= DAC33_AFMT_DSP; 1040 aictrl_a |= DAC33_AFMT_DSP;
1040 aictrl_b &= ~DAC33_DATA_DELAY_MASK; 1041 aictrl_b &= ~DAC33_DATA_DELAY_MASK;
1041 aictrl_b |= DAC33_DATA_DELAY(1); /* 1 bit delay */ 1042 aictrl_b |= DAC33_DATA_DELAY(0);
1042 break;
1043 case SND_SOC_DAIFMT_DSP_B:
1044 aictrl_a |= DAC33_AFMT_DSP;
1045 aictrl_b &= ~DAC33_DATA_DELAY_MASK; /* No delay */
1046 break; 1043 break;
1047 case SND_SOC_DAIFMT_RIGHT_J: 1044 case SND_SOC_DAIFMT_RIGHT_J:
1048 aictrl_a |= DAC33_AFMT_RIGHT_J; 1045 aictrl_a |= DAC33_AFMT_RIGHT_J;
@@ -1066,7 +1063,7 @@ static void dac33_init_chip(struct snd_soc_codec *codec)
1066{ 1063{
1067 /* 44-46: DAC Control Registers */ 1064 /* 44-46: DAC Control Registers */
1068 /* A : DAC sample rate Fsref/1.5 */ 1065 /* A : DAC sample rate Fsref/1.5 */
1069 dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(1)); 1066 dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(0));
1070 /* B : DAC src=normal, not muted */ 1067 /* B : DAC src=normal, not muted */
1071 dac33_write(codec, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT | 1068 dac33_write(codec, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT |
1072 DAC33_DACSRCL_LEFT); 1069 DAC33_DACSRCL_LEFT);
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 958d49c969ac..569ad8758a84 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -26,6 +26,7 @@
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/regulator/consumer.h> 28#include <linux/regulator/consumer.h>
29#include <linux/slab.h>
29#include <sound/tpa6130a2-plat.h> 30#include <sound/tpa6130a2-plat.h>
30#include <sound/soc.h> 31#include <sound/soc.h>
31#include <sound/soc-dapm.h> 32#include <sound/soc-dapm.h>
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 6f5d4af20052..520ffd6536c3 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -27,6 +27,7 @@
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/i2c/twl.h> 29#include <linux/i2c/twl.h>
30#include <linux/slab.h>
30#include <sound/core.h> 31#include <sound/core.h>
31#include <sound/pcm.h> 32#include <sound/pcm.h>
32#include <sound/pcm_params.h> 33#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c
index 3e99fe5131dd..a8dcd5a5bbcb 100644
--- a/sound/soc/codecs/uda134x.c
+++ b/sound/soc/codecs/uda134x.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/slab.h>
18#include <sound/pcm.h> 19#include <sound/pcm.h>
19#include <sound/pcm_params.h> 20#include <sound/pcm_params.h>
20#include <sound/soc.h> 21#include <sound/soc.h>
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index a2763c2e7348..9cd0a66b7663 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -137,7 +137,7 @@ static void uda1380_flush_work(struct work_struct *work)
137{ 137{
138 int bit, reg; 138 int bit, reg;
139 139
140 for_each_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { 140 for_each_set_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) {
141 reg = 0x10 + bit; 141 reg = 0x10 + bit;
142 pr_debug("uda1380: flush reg %x val %x:\n", reg, 142 pr_debug("uda1380: flush reg %x val %x:\n", reg,
143 uda1380_read_reg_cache(uda1380_codec, reg)); 143 uda1380_read_reg_cache(uda1380_codec, reg));
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 217b02680597..002e289d1255 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -23,7 +23,6 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/version.h>
27#include <linux/kernel.h> 26#include <linux/kernel.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/firmware.h> 28#include <linux/firmware.h>
@@ -32,6 +31,7 @@
32#include <linux/i2c.h> 31#include <linux/i2c.h>
33#include <linux/platform_device.h> 32#include <linux/platform_device.h>
34#include <linux/debugfs.h> 33#include <linux/debugfs.h>
34#include <linux/slab.h>
35#include <sound/core.h> 35#include <sound/core.h>
36#include <sound/pcm.h> 36#include <sound/pcm.h>
37#include <sound/pcm_params.h> 37#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index 718ef912e758..2e0772f9c456 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/slab.h>
16#include <linux/delay.h> 17#include <linux/delay.h>
17#include <linux/pm.h> 18#include <linux/pm.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
@@ -1349,7 +1350,7 @@ static irqreturn_t wm8350_hp_jack_handler(int irq, void *data)
1349 int mask; 1350 int mask;
1350 struct wm8350_jack_data *jack = NULL; 1351 struct wm8350_jack_data *jack = NULL;
1351 1352
1352 switch (irq) { 1353 switch (irq - wm8350->irq_base) {
1353 case WM8350_IRQ_CODEC_JCK_DET_L: 1354 case WM8350_IRQ_CODEC_JCK_DET_L:
1354 jack = &priv->hpl; 1355 jack = &priv->hpl;
1355 mask = WM8350_JACK_L_LVL; 1356 mask = WM8350_JACK_L_LVL;
@@ -1424,7 +1425,7 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
1424 wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); 1425 wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena);
1425 1426
1426 /* Sync status */ 1427 /* Sync status */
1427 wm8350_hp_jack_handler(irq, priv); 1428 wm8350_hp_jack_handler(irq + wm8350->irq_base, priv);
1428 1429
1429 return 0; 1430 return 0;
1430} 1431}
@@ -1521,8 +1522,8 @@ static int wm8350_remove(struct platform_device *pdev)
1521 WM8350_JDL_ENA | WM8350_JDR_ENA); 1522 WM8350_JDL_ENA | WM8350_JDR_ENA);
1522 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); 1523 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA);
1523 1524
1524 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); 1525 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv);
1525 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); 1526 wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv);
1526 1527
1527 priv->hpl.jack = NULL; 1528 priv->hpl.jack = NULL;
1528 priv->hpr.jack = NULL; 1529 priv->hpr.jack = NULL;
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c
index b432f4d4a324..6acc885cf9b7 100644
--- a/sound/soc/codecs/wm8400.c
+++ b/sound/soc/codecs/wm8400.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/delay.h> 19#include <linux/delay.h>
19#include <linux/pm.h> 20#include <linux/pm.h>
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index af8cb6995a1f..9000b1d19afb 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c
index d3a61d7ea0c5..19cd47293424 100644
--- a/sound/soc/codecs/wm8523.c
+++ b/sound/soc/codecs/wm8523.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regulator/consumer.h> 21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c
index d077df6f5e75..8cc9042965eb 100644
--- a/sound/soc/codecs/wm8580.c
+++ b/sound/soc/codecs/wm8580.c
@@ -25,6 +25,7 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
28#include <linux/slab.h>
28 29
29#include <sound/core.h> 30#include <sound/core.h>
30#include <sound/pcm.h> 31#include <sound/pcm.h>
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c
index 24a35603bcf7..8ca3812f2f2f 100644
--- a/sound/soc/codecs/wm8711.c
+++ b/sound/soc/codecs/wm8711.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/slab.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8727.c b/sound/soc/codecs/wm8727.c
index 63a254e293ca..1072621e93fd 100644
--- a/sound/soc/codecs/wm8727.c
+++ b/sound/soc/codecs/wm8727.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/slab.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/device.h> 19#include <linux/device.h>
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c
index 3fb653ba363a..07adc375a706 100644
--- a/sound/soc/codecs/wm8728.c
+++ b/sound/soc/codecs/wm8728.c
@@ -18,6 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 5a2619dbf283..e7c6bf163185 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/slab.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <linux/regulator/consumer.h> 23#include <linux/regulator/consumer.h>
23#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 475c67ac7818..2916ed4d3844 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/slab.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index c2444e7c8480..613199a0f799 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -40,6 +40,7 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/platform_device.h> 41#include <linux/platform_device.h>
42#include <linux/spi/spi.h> 42#include <linux/spi/spi.h>
43#include <linux/slab.h>
43#include <sound/core.h> 44#include <sound/core.h>
44#include <sound/pcm.h> 45#include <sound/pcm.h>
45#include <sound/pcm_params.h> 46#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index 44e7d9d82f87..60b1b3e1094b 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/slab.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c
index dbc368c08263..b7fd96adac64 100644
--- a/sound/soc/codecs/wm8900.c
+++ b/sound/soc/codecs/wm8900.c
@@ -24,6 +24,7 @@
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/slab.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/pcm.h> 29#include <sound/pcm.h>
29#include <sound/pcm_params.h> 30#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 3595bd57c4eb..fa5f99fde68b 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -23,6 +23,7 @@
23#include <linux/pm.h> 23#include <linux/pm.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26#include <sound/core.h> 27#include <sound/core.h>
27#include <sound/pcm.h> 28#include <sound/pcm.h>
28#include <sound/pcm_params.h> 29#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 593e47d0e0eb..c6f0abcc5711 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regulator/consumer.h> 21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c
index 31e39ffd1d8e..0c04b476487f 100644
--- a/sound/soc/codecs/wm8940.c
+++ b/sound/soc/codecs/wm8940.c
@@ -30,6 +30,7 @@
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/spi/spi.h> 32#include <linux/spi/spi.h>
33#include <linux/slab.h>
33#include <sound/core.h> 34#include <sound/core.h>
34#include <sound/pcm.h> 35#include <sound/pcm.h>
35#include <sound/pcm_params.h> 36#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c
index 615dab2b62ef..c8d7a809af4d 100644
--- a/sound/soc/codecs/wm8955.c
+++ b/sound/soc/codecs/wm8955.c
@@ -18,6 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regulator/consumer.h> 20#include <linux/regulator/consumer.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index d07bcc1e1c60..f1e63e01b04d 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -15,6 +15,7 @@
15#include <linux/pm.h> 15#include <linux/pm.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/slab.h>
18#include <sound/core.h> 19#include <sound/core.h>
19#include <sound/pcm.h> 20#include <sound/pcm.h>
20#include <sound/pcm_params.h> 21#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c
index d2342c5e0425..50634ab76a5c 100644
--- a/sound/soc/codecs/wm8961.c
+++ b/sound/soc/codecs/wm8961.c
@@ -18,6 +18,7 @@
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index d9540d55fc89..a65b781af512 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -20,6 +20,7 @@
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/slab.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
25#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
index ee637af4737a..69708c4cc004 100644
--- a/sound/soc/codecs/wm8974.c
+++ b/sound/soc/codecs/wm8974.c
@@ -18,6 +18,7 @@
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index 28bb59ea6ea1..526f56b09066 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -19,6 +19,7 @@
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index 2862e4dced27..bb18c3ecfeb9 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index a54dc77b7f34..831f4730bfd5 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -18,6 +18,7 @@
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
@@ -990,7 +991,7 @@ static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
990 reg = snd_soc_read(codec, WM8990_CLOCKING_2); 991 reg = snd_soc_read(codec, WM8990_CLOCKING_2);
991 snd_soc_write(codec, WM8990_CLOCKING_2, reg | WM8990_SYSCLK_SRC); 992 snd_soc_write(codec, WM8990_CLOCKING_2, reg | WM8990_SYSCLK_SRC);
992 993
993 /* set up N , fractional mode and pre-divisor if neccessary */ 994 /* set up N , fractional mode and pre-divisor if necessary */
994 snd_soc_write(codec, WM8990_PLL1, pll_div.n | WM8990_SDM | 995 snd_soc_write(codec, WM8990_PLL1, pll_div.n | WM8990_SDM |
995 (pll_div.div2?WM8990_PRESCALE:0)); 996 (pll_div.div2?WM8990_PRESCALE:0));
996 snd_soc_write(codec, WM8990_PLL2, (u8)(pll_div.k>>8)); 997 snd_soc_write(codec, WM8990_PLL2, (u8)(pll_div.k>>8));
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index bf022f68b84f..03e8b1a6a56c 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -18,6 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/regulator/consumer.h> 19#include <linux/regulator/consumer.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 29f3771c33a4..9da0724cd47a 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regulator/consumer.h> 21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
@@ -3007,34 +3008,39 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
3007 break; 3008 break;
3008 3009
3009 case SND_SOC_BIAS_OFF: 3010 case SND_SOC_BIAS_OFF:
3010 /* Switch over to startup biases */ 3011 if (codec->bias_level == SND_SOC_BIAS_STANDBY) {
3011 snd_soc_update_bits(codec, WM8994_ANTIPOP_2, 3012 /* Switch over to startup biases */
3012 WM8994_BIAS_SRC | WM8994_STARTUP_BIAS_ENA | 3013 snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
3013 WM8994_VMID_BUF_ENA | 3014 WM8994_BIAS_SRC |
3014 WM8994_VMID_RAMP_MASK, 3015 WM8994_STARTUP_BIAS_ENA |
3015 WM8994_BIAS_SRC | WM8994_STARTUP_BIAS_ENA | 3016 WM8994_VMID_BUF_ENA |
3016 WM8994_VMID_BUF_ENA | 3017 WM8994_VMID_RAMP_MASK,
3017 (1 << WM8994_VMID_RAMP_SHIFT)); 3018 WM8994_BIAS_SRC |
3018 3019 WM8994_STARTUP_BIAS_ENA |
3019 /* Disable main biases */ 3020 WM8994_VMID_BUF_ENA |
3020 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, 3021 (1 << WM8994_VMID_RAMP_SHIFT));
3021 WM8994_BIAS_ENA | WM8994_VMID_SEL_MASK, 0);
3022 3022
3023 /* Discharge line */ 3023 /* Disable main biases */
3024 snd_soc_update_bits(codec, WM8994_ANTIPOP_1, 3024 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
3025 WM8994_LINEOUT1_DISCH | 3025 WM8994_BIAS_ENA |
3026 WM8994_LINEOUT2_DISCH, 3026 WM8994_VMID_SEL_MASK, 0);
3027 WM8994_LINEOUT1_DISCH |
3028 WM8994_LINEOUT2_DISCH);
3029 3027
3030 msleep(5); 3028 /* Discharge line */
3029 snd_soc_update_bits(codec, WM8994_ANTIPOP_1,
3030 WM8994_LINEOUT1_DISCH |
3031 WM8994_LINEOUT2_DISCH,
3032 WM8994_LINEOUT1_DISCH |
3033 WM8994_LINEOUT2_DISCH);
3031 3034
3032 /* Switch off startup biases */ 3035 msleep(5);
3033 snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
3034 WM8994_BIAS_SRC | WM8994_STARTUP_BIAS_ENA |
3035 WM8994_VMID_BUF_ENA |
3036 WM8994_VMID_RAMP_MASK, 0);
3037 3036
3037 /* Switch off startup biases */
3038 snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
3039 WM8994_BIAS_SRC |
3040 WM8994_STARTUP_BIAS_ENA |
3041 WM8994_VMID_BUF_ENA |
3042 WM8994_VMID_RAMP_MASK, 0);
3043 }
3038 break; 3044 break;
3039 } 3045 }
3040 codec->bias_level = level; 3046 codec->bias_level = level;
@@ -3401,7 +3407,7 @@ struct snd_soc_dai wm8994_dai[] = {
3401 .rates = WM8994_RATES, 3407 .rates = WM8994_RATES,
3402 .formats = WM8994_FORMATS, 3408 .formats = WM8994_FORMATS,
3403 }, 3409 },
3404 .playback = { 3410 .capture = {
3405 .stream_name = "AIF3 Capture", 3411 .stream_name = "AIF3 Capture",
3406 .channels_min = 2, 3412 .channels_min = 2,
3407 .channels_max = 2, 3413 .channels_max = 2,
@@ -3730,11 +3736,12 @@ static int wm8994_codec_probe(struct platform_device *pdev)
3730 case 3: 3736 case 3:
3731 wm8994->hubs.dcs_codes = -5; 3737 wm8994->hubs.dcs_codes = -5;
3732 wm8994->hubs.hp_startup_mode = 1; 3738 wm8994->hubs.hp_startup_mode = 1;
3739 wm8994->hubs.dcs_readback_mode = 1;
3733 break; 3740 break;
3734 default: 3741 default:
3742 wm8994->hubs.dcs_readback_mode = 1;
3735 break; 3743 break;
3736 } 3744 }
3737
3738 3745
3739 /* Remember if AIFnLRCLK is configured as a GPIO. This should be 3746 /* Remember if AIFnLRCLK is configured as a GPIO. This should be
3740 * configured on init - if a system wants to do this dynamically 3747 * configured on init - if a system wants to do this dynamically
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c
index c468497314ba..3a184fcb702b 100644
--- a/sound/soc/codecs/wm9081.c
+++ b/sound/soc/codecs/wm9081.c
@@ -18,6 +18,7 @@
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
23#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index ec54c6da9856..8793341849d1 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/slab.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/device.h> 16#include <linux/device.h>
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index e237bf615129..2f48a8aae22c 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/slab.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/device.h> 17#include <linux/device.h>
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index ceb86b4ddb25..2fca514fde58 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/slab.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/device.h> 21#include <linux/device.h>
21#include <sound/core.h> 22#include <sound/core.h>
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 0ad9f5d536c6..e1f225a3ac46 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -62,21 +62,27 @@ static const char *speaker_mode_text[] = {
62static const struct soc_enum speaker_mode = 62static const struct soc_enum speaker_mode =
63 SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text); 63 SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text);
64 64
65static void wait_for_dc_servo(struct snd_soc_codec *codec) 65static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
66{ 66{
67 unsigned int reg; 67 unsigned int reg;
68 int count = 0; 68 int count = 0;
69 unsigned int val;
70
71 val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;
72
73 /* Trigger the command */
74 snd_soc_write(codec, WM8993_DC_SERVO_0, val);
69 75
70 dev_dbg(codec->dev, "Waiting for DC servo...\n"); 76 dev_dbg(codec->dev, "Waiting for DC servo...\n");
71 77
72 do { 78 do {
73 count++; 79 count++;
74 msleep(1); 80 msleep(1);
75 reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_0); 81 reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
76 dev_dbg(codec->dev, "DC servo: %x\n", reg); 82 dev_dbg(codec->dev, "DC servo: %x\n", reg);
77 } while (reg & WM8993_DCS_DATAPATH_BUSY); 83 } while (reg & op && count < 400);
78 84
79 if (reg & WM8993_DCS_DATAPATH_BUSY) 85 if (reg & op)
80 dev_err(codec->dev, "Timed out waiting for DC Servo\n"); 86 dev_err(codec->dev, "Timed out waiting for DC Servo\n");
81} 87}
82 88
@@ -86,51 +92,58 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec)
86static void calibrate_dc_servo(struct snd_soc_codec *codec) 92static void calibrate_dc_servo(struct snd_soc_codec *codec)
87{ 93{
88 struct wm_hubs_data *hubs = codec->private_data; 94 struct wm_hubs_data *hubs = codec->private_data;
89 u16 reg, dcs_cfg; 95 u16 reg, reg_l, reg_r, dcs_cfg;
90 96
91 /* Set for 32 series updates */ 97 /* Set for 32 series updates */
92 snd_soc_update_bits(codec, WM8993_DC_SERVO_1, 98 snd_soc_update_bits(codec, WM8993_DC_SERVO_1,
93 WM8993_DCS_SERIES_NO_01_MASK, 99 WM8993_DCS_SERIES_NO_01_MASK,
94 32 << WM8993_DCS_SERIES_NO_01_SHIFT); 100 32 << WM8993_DCS_SERIES_NO_01_SHIFT);
95 101 wait_for_dc_servo(codec,
96 /* Enable the DC servo. Write all bits to avoid triggering startup 102 WM8993_DCS_TRIG_SERIES_0 | WM8993_DCS_TRIG_SERIES_1);
97 * or write calibration.
98 */
99 snd_soc_update_bits(codec, WM8993_DC_SERVO_0,
100 0xFFFF,
101 WM8993_DCS_ENA_CHAN_0 |
102 WM8993_DCS_ENA_CHAN_1 |
103 WM8993_DCS_TRIG_SERIES_1 |
104 WM8993_DCS_TRIG_SERIES_0);
105
106 wait_for_dc_servo(codec);
107 103
108 /* Apply correction to DC servo result */ 104 /* Apply correction to DC servo result */
109 if (hubs->dcs_codes) { 105 if (hubs->dcs_codes) {
110 dev_dbg(codec->dev, "Applying %d code DC servo correction\n", 106 dev_dbg(codec->dev, "Applying %d code DC servo correction\n",
111 hubs->dcs_codes); 107 hubs->dcs_codes);
112 108
109 /* Different chips in the family support different
110 * readback methods.
111 */
112 switch (hubs->dcs_readback_mode) {
113 case 0:
114 reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1)
115 & WM8993_DCS_INTEG_CHAN_0_MASK;;
116 reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2)
117 & WM8993_DCS_INTEG_CHAN_1_MASK;
118 break;
119 case 1:
120 reg = snd_soc_read(codec, WM8993_DC_SERVO_3);
121 reg_l = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK)
122 >> WM8993_DCS_DAC_WR_VAL_1_SHIFT;
123 reg_r = reg & WM8993_DCS_DAC_WR_VAL_0_MASK;
124 break;
125 default:
126 WARN(1, "Unknown DCS readback method");
127 break;
128 }
129
113 /* HPOUT1L */ 130 /* HPOUT1L */
114 reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1) & 131 if (reg_l + hubs->dcs_codes > 0 &&
115 WM8993_DCS_INTEG_CHAN_0_MASK;; 132 reg_l + hubs->dcs_codes < 0xff)
116 reg += hubs->dcs_codes; 133 reg_l += hubs->dcs_codes;
117 dcs_cfg = reg << WM8993_DCS_DAC_WR_VAL_1_SHIFT; 134 dcs_cfg = reg_l << WM8993_DCS_DAC_WR_VAL_1_SHIFT;
118 135
119 /* HPOUT1R */ 136 /* HPOUT1R */
120 reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2) & 137 if (reg_r + hubs->dcs_codes > 0 &&
121 WM8993_DCS_INTEG_CHAN_1_MASK; 138 reg_r + hubs->dcs_codes < 0xff)
122 reg += hubs->dcs_codes; 139 reg_r += hubs->dcs_codes;
123 dcs_cfg |= reg; 140 dcs_cfg |= reg_r;
124 141
125 /* Do it */ 142 /* Do it */
126 snd_soc_write(codec, WM8993_DC_SERVO_3, dcs_cfg); 143 snd_soc_write(codec, WM8993_DC_SERVO_3, dcs_cfg);
127 snd_soc_update_bits(codec, WM8993_DC_SERVO_0, 144 wait_for_dc_servo(codec,
128 WM8993_DCS_TRIG_DAC_WR_0 | 145 WM8993_DCS_TRIG_DAC_WR_0 |
129 WM8993_DCS_TRIG_DAC_WR_1, 146 WM8993_DCS_TRIG_DAC_WR_1);
130 WM8993_DCS_TRIG_DAC_WR_0 |
131 WM8993_DCS_TRIG_DAC_WR_1);
132
133 wait_for_dc_servo(codec);
134 } 147 }
135} 148}
136 149
@@ -141,10 +154,16 @@ static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol,
141 struct snd_ctl_elem_value *ucontrol) 154 struct snd_ctl_elem_value *ucontrol)
142{ 155{
143 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 156 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
157 struct wm_hubs_data *hubs = codec->private_data;
144 int ret; 158 int ret;
145 159
146 ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); 160 ret = snd_soc_put_volsw_2r(kcontrol, ucontrol);
147 161
162 /* If we're applying an offset correction then updating the
163 * callibration would be likely to introduce further offsets. */
164 if (hubs->dcs_codes)
165 return ret;
166
148 /* Only need to do this if the outputs are active */ 167 /* Only need to do this if the outputs are active */
149 if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1) 168 if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1)
150 & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) 169 & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA))
diff --git a/sound/soc/codecs/wm_hubs.h b/sound/soc/codecs/wm_hubs.h
index 420104fe9c90..e51c16683589 100644
--- a/sound/soc/codecs/wm_hubs.h
+++ b/sound/soc/codecs/wm_hubs.h
@@ -21,6 +21,7 @@ extern const unsigned int wm_hubs_spkmix_tlv[];
21/* This *must* be the first element of the codec->private_data struct */ 21/* This *must* be the first element of the codec->private_data struct */
22struct wm_hubs_data { 22struct wm_hubs_data {
23 int dcs_codes; 23 int dcs_codes;
24 int dcs_readback_mode;
24 int hp_startup_mode; 25 int hp_startup_mode;
25}; 26};
26 27
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 6362ca05506e..adadcd3aa1b1 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/slab.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
16#include <linux/io.h> 17#include <linux/io.h>
17#include <linux/clk.h> 18#include <linux/clk.h>
@@ -585,7 +586,8 @@ static int davinci_i2s_probe(struct platform_device *pdev)
585 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start; 586 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start;
586 587
587 davinci_i2s_dai.private_data = dev; 588 davinci_i2s_dai.private_data = dev;
588 davinci_i2s_dai.dma_data = dev->dma_params; 589 davinci_i2s_dai.capture.dma_data = dev->dma_params;
590 davinci_i2s_dai.playback.dma_data = dev->dma_params;
589 ret = snd_soc_register_dai(&davinci_i2s_dai); 591 ret = snd_soc_register_dai(&davinci_i2s_dai);
590 if (ret != 0) 592 if (ret != 0)
591 goto err_free_mem; 593 goto err_free_mem;
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index ab6518d86f18..79f0f4ad242c 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/slab.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/clk.h> 24#include <linux/clk.h>
@@ -917,7 +918,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
917 918
918 dma_data->channel = res->start; 919 dma_data->channel = res->start;
919 davinci_mcasp_dai[pdata->op_mode].private_data = dev; 920 davinci_mcasp_dai[pdata->op_mode].private_data = dev;
920 davinci_mcasp_dai[pdata->op_mode].dma_data = dev->dma_params; 921 davinci_mcasp_dai[pdata->op_mode].capture.dma_data = dev->dma_params;
922 davinci_mcasp_dai[pdata->op_mode].playback.dma_data = dev->dma_params;
921 davinci_mcasp_dai[pdata->op_mode].dev = &pdev->dev; 923 davinci_mcasp_dai[pdata->op_mode].dev = &pdev->dev;
922 ret = snd_soc_register_dai(&davinci_mcasp_dai[pdata->op_mode]); 924 ret = snd_soc_register_dai(&davinci_mcasp_dai[pdata->op_mode]);
923 925
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index 80c7fdf2f521..2dc406f42fe7 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -649,8 +649,10 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream)
649 struct snd_pcm_hardware *ppcm; 649 struct snd_pcm_hardware *ppcm;
650 int ret = 0; 650 int ret = 0;
651 struct snd_soc_pcm_runtime *rtd = substream->private_data; 651 struct snd_soc_pcm_runtime *rtd = substream->private_data;
652 struct davinci_pcm_dma_params *pa = rtd->dai->cpu_dai->dma_data; 652 struct davinci_pcm_dma_params *pa;
653 struct davinci_pcm_dma_params *params; 653 struct davinci_pcm_dma_params *params;
654
655 pa = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
654 if (!pa) 656 if (!pa)
655 return -ENODEV; 657 return -ENODEV;
656 params = &pa[substream->stream]; 658 params = &pa[substream->stream];
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index b1a3a278819f..410c7496a18d 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -19,6 +19,7 @@
19#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/gfp.h>
22 23
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 93f0f38a32c9..762c1b8e8e4e 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -14,6 +14,7 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/slab.h>
17 18
18#include <sound/core.h> 19#include <sound/core.h>
19#include <sound/pcm.h> 20#include <sound/pcm.h>
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index 30ed568afb2e..d639e55c5124 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/of_device.h> 10#include <linux/of_device.h>
11#include <linux/slab.h>
11 12
12#include <sound/soc.h> 13#include <sound/soc.h>
13 14
diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c
index ef67d1cdffe7..83de1c81c8c4 100644
--- a/sound/soc/fsl/mpc8610_hpcd.c
+++ b/sound/soc/fsl/mpc8610_hpcd.c
@@ -9,6 +9,7 @@
9 * express or implied. 9 * express or implied.
10 */ 10 */
11 11
12#include <linux/slab.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/interrupt.h> 14#include <linux/interrupt.h>
14#include <linux/of_device.h> 15#include <linux/of_device.h>
diff --git a/sound/soc/fsl/soc-of-simple.c b/sound/soc/fsl/soc-of-simple.c
index 8bc5cd9e972f..3bc13fd89096 100644
--- a/sound/soc/fsl/soc-of-simple.c
+++ b/sound/soc/fsl/soc-of-simple.c
@@ -12,6 +12,7 @@
12#include <linux/bitops.h> 12#include <linux/bitops.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/of.h> 14#include <linux/of.h>
15#include <linux/slab.h>
15#include <sound/core.h> 16#include <sound/core.h>
16#include <sound/pcm.h> 17#include <sound/pcm.h>
17#include <sound/pcm_params.h> 18#include <sound/pcm_params.h>
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig
index c7d0fd9b7de8..7174b4c710de 100644
--- a/sound/soc/imx/Kconfig
+++ b/sound/soc/imx/Kconfig
@@ -1,6 +1,6 @@
1config SND_IMX_SOC 1config SND_IMX_SOC
2 tristate "SoC Audio for Freescale i.MX CPUs" 2 tristate "SoC Audio for Freescale i.MX CPUs"
3 depends on ARCH_MXC && BROKEN 3 depends on ARCH_MXC
4 select SND_PCM 4 select SND_PCM
5 select FIQ 5 select FIQ
6 select SND_SOC_AC97_BUS 6 select SND_SOC_AC97_BUS
diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c
index 19452e44afdc..2b31ac673ea4 100644
--- a/sound/soc/imx/imx-pcm-dma-mx2.c
+++ b/sound/soc/imx/imx-pcm-dma-mx2.c
@@ -19,6 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h>
22 23
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/initval.h> 25#include <sound/initval.h>
@@ -70,7 +71,12 @@ static void imx_ssi_dma_callback(int channel, void *data)
70 71
71static void snd_imx_dma_err_callback(int channel, void *data, int err) 72static void snd_imx_dma_err_callback(int channel, void *data, int err)
72{ 73{
73 pr_err("DMA error callback called\n"); 74 struct snd_pcm_substream *substream = data;
75 struct snd_soc_pcm_runtime *rtd = substream->private_data;
76 struct imx_pcm_dma_params *dma_params = rtd->dai->cpu_dai->dma_data;
77 struct snd_pcm_runtime *runtime = substream->runtime;
78 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
79 int ret;
74 80
75 pr_err("DMA timeout on channel %d -%s%s%s%s\n", 81 pr_err("DMA timeout on channel %d -%s%s%s%s\n",
76 channel, 82 channel,
@@ -78,16 +84,26 @@ static void snd_imx_dma_err_callback(int channel, void *data, int err)
78 err & IMX_DMA_ERR_REQUEST ? " request" : "", 84 err & IMX_DMA_ERR_REQUEST ? " request" : "",
79 err & IMX_DMA_ERR_TRANSFER ? " transfer" : "", 85 err & IMX_DMA_ERR_TRANSFER ? " transfer" : "",
80 err & IMX_DMA_ERR_BUFFER ? " buffer" : ""); 86 err & IMX_DMA_ERR_BUFFER ? " buffer" : "");
87
88 imx_dma_disable(iprtd->dma);
89 ret = imx_dma_setup_sg(iprtd->dma, iprtd->sg_list, iprtd->sg_count,
90 IMX_DMA_LENGTH_LOOP, dma_params->dma_addr,
91 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
92 DMA_MODE_WRITE : DMA_MODE_READ);
93 if (!ret)
94 imx_dma_enable(iprtd->dma);
81} 95}
82 96
83static int imx_ssi_dma_alloc(struct snd_pcm_substream *substream) 97static int imx_ssi_dma_alloc(struct snd_pcm_substream *substream)
84{ 98{
85 struct snd_soc_pcm_runtime *rtd = substream->private_data; 99 struct snd_soc_pcm_runtime *rtd = substream->private_data;
86 struct imx_pcm_dma_params *dma_params = rtd->dai->cpu_dai->dma_data; 100 struct imx_pcm_dma_params *dma_params;
87 struct snd_pcm_runtime *runtime = substream->runtime; 101 struct snd_pcm_runtime *runtime = substream->runtime;
88 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 102 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
89 int ret; 103 int ret;
90 104
105 dma_params = snd_soc_get_dma_data(rtd->dai->cpu_dai, substream);
106
91 iprtd->dma = imx_dma_request_by_prio(DRV_NAME, DMA_PRIO_HIGH); 107 iprtd->dma = imx_dma_request_by_prio(DRV_NAME, DMA_PRIO_HIGH);
92 if (iprtd->dma < 0) { 108 if (iprtd->dma < 0) {
93 pr_err("Failed to claim the audio DMA\n"); 109 pr_err("Failed to claim the audio DMA\n");
@@ -192,10 +208,12 @@ static int snd_imx_pcm_prepare(struct snd_pcm_substream *substream)
192{ 208{
193 struct snd_pcm_runtime *runtime = substream->runtime; 209 struct snd_pcm_runtime *runtime = substream->runtime;
194 struct snd_soc_pcm_runtime *rtd = substream->private_data; 210 struct snd_soc_pcm_runtime *rtd = substream->private_data;
195 struct imx_pcm_dma_params *dma_params = rtd->dai->cpu_dai->dma_data; 211 struct imx_pcm_dma_params *dma_params;
196 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 212 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
197 int err; 213 int err;
198 214
215 dma_params = snd_soc_get_dma_data(rtd->dai->cpu_dai, substream);
216
199 iprtd->substream = substream; 217 iprtd->substream = substream;
200 iprtd->buf = (unsigned int *)substream->dma_buffer.area; 218 iprtd->buf = (unsigned int *)substream->dma_buffer.area;
201 iprtd->period_cnt = 0; 219 iprtd->period_cnt = 0;
diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/imx/imx-pcm-fiq.c
index d9cb9849b033..6b518e07eea9 100644
--- a/sound/soc/imx/imx-pcm-fiq.c
+++ b/sound/soc/imx/imx-pcm-fiq.c
@@ -19,6 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h>
22 23
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/initval.h> 25#include <sound/initval.h>
@@ -38,23 +39,24 @@ struct imx_pcm_runtime_data {
38 unsigned long offset; 39 unsigned long offset;
39 unsigned long last_offset; 40 unsigned long last_offset;
40 unsigned long size; 41 unsigned long size;
41 struct timer_list timer; 42 struct hrtimer hrt;
42 int poll_time; 43 int poll_time_ns;
44 struct snd_pcm_substream *substream;
45 atomic_t running;
43}; 46};
44 47
45static inline void imx_ssi_set_next_poll(struct imx_pcm_runtime_data *iprtd) 48static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
46{ 49{
47 iprtd->timer.expires = jiffies + iprtd->poll_time; 50 struct imx_pcm_runtime_data *iprtd =
48} 51 container_of(hrt, struct imx_pcm_runtime_data, hrt);
49 52 struct snd_pcm_substream *substream = iprtd->substream;
50static void imx_ssi_timer_callback(unsigned long data)
51{
52 struct snd_pcm_substream *substream = (void *)data;
53 struct snd_pcm_runtime *runtime = substream->runtime; 53 struct snd_pcm_runtime *runtime = substream->runtime;
54 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
55 struct pt_regs regs; 54 struct pt_regs regs;
56 unsigned long delta; 55 unsigned long delta;
57 56
57 if (!atomic_read(&iprtd->running))
58 return HRTIMER_NORESTART;
59
58 get_fiq_regs(&regs); 60 get_fiq_regs(&regs);
59 61
60 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 62 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -71,16 +73,14 @@ static void imx_ssi_timer_callback(unsigned long data)
71 73
72 /* If we've transferred at least a period then report it and 74 /* If we've transferred at least a period then report it and
73 * reset our poll time */ 75 * reset our poll time */
74 if (delta >= runtime->period_size) { 76 if (delta >= iprtd->period) {
75 snd_pcm_period_elapsed(substream); 77 snd_pcm_period_elapsed(substream);
76 iprtd->last_offset = iprtd->offset; 78 iprtd->last_offset = iprtd->offset;
77
78 imx_ssi_set_next_poll(iprtd);
79 } 79 }
80 80
81 /* Restart the timer; if we didn't report we'll run on the next tick */ 81 hrtimer_forward_now(hrt, ns_to_ktime(iprtd->poll_time_ns));
82 add_timer(&iprtd->timer);
83 82
83 return HRTIMER_RESTART;
84} 84}
85 85
86static struct fiq_handler fh = { 86static struct fiq_handler fh = {
@@ -98,8 +98,8 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream,
98 iprtd->period = params_period_bytes(params) ; 98 iprtd->period = params_period_bytes(params) ;
99 iprtd->offset = 0; 99 iprtd->offset = 0;
100 iprtd->last_offset = 0; 100 iprtd->last_offset = 0;
101 iprtd->poll_time = HZ / (params_rate(params) / params_period_size(params)); 101 iprtd->poll_time_ns = 1000000000 / params_rate(params) *
102 102 params_period_size(params);
103 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 103 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
104 104
105 return 0; 105 return 0;
@@ -134,8 +134,9 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
134 case SNDRV_PCM_TRIGGER_START: 134 case SNDRV_PCM_TRIGGER_START:
135 case SNDRV_PCM_TRIGGER_RESUME: 135 case SNDRV_PCM_TRIGGER_RESUME:
136 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 136 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
137 imx_ssi_set_next_poll(iprtd); 137 atomic_set(&iprtd->running, 1);
138 add_timer(&iprtd->timer); 138 hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns),
139 HRTIMER_MODE_REL);
139 if (++fiq_enable == 1) 140 if (++fiq_enable == 1)
140 enable_fiq(imx_pcm_fiq); 141 enable_fiq(imx_pcm_fiq);
141 142
@@ -144,11 +145,11 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
144 case SNDRV_PCM_TRIGGER_STOP: 145 case SNDRV_PCM_TRIGGER_STOP:
145 case SNDRV_PCM_TRIGGER_SUSPEND: 146 case SNDRV_PCM_TRIGGER_SUSPEND:
146 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 147 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
147 del_timer(&iprtd->timer); 148 atomic_set(&iprtd->running, 0);
149
148 if (--fiq_enable == 0) 150 if (--fiq_enable == 0)
149 disable_fiq(imx_pcm_fiq); 151 disable_fiq(imx_pcm_fiq);
150 152
151
152 break; 153 break;
153 default: 154 default:
154 return -EINVAL; 155 return -EINVAL;
@@ -179,7 +180,7 @@ static struct snd_pcm_hardware snd_imx_hardware = {
179 .buffer_bytes_max = IMX_SSI_DMABUF_SIZE, 180 .buffer_bytes_max = IMX_SSI_DMABUF_SIZE,
180 .period_bytes_min = 128, 181 .period_bytes_min = 128,
181 .period_bytes_max = 16 * 1024, 182 .period_bytes_max = 16 * 1024,
182 .periods_min = 2, 183 .periods_min = 4,
183 .periods_max = 255, 184 .periods_max = 255,
184 .fifo_size = 0, 185 .fifo_size = 0,
185}; 186};
@@ -193,9 +194,11 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
193 iprtd = kzalloc(sizeof(*iprtd), GFP_KERNEL); 194 iprtd = kzalloc(sizeof(*iprtd), GFP_KERNEL);
194 runtime->private_data = iprtd; 195 runtime->private_data = iprtd;
195 196
196 init_timer(&iprtd->timer); 197 iprtd->substream = substream;
197 iprtd->timer.data = (unsigned long)substream; 198
198 iprtd->timer.function = imx_ssi_timer_callback; 199 atomic_set(&iprtd->running, 0);
200 hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
201 iprtd->hrt.function = snd_hrtimer_callback;
199 202
200 ret = snd_pcm_hw_constraint_integer(substream->runtime, 203 ret = snd_pcm_hw_constraint_integer(substream->runtime,
201 SNDRV_PCM_HW_PARAM_PERIODS); 204 SNDRV_PCM_HW_PARAM_PERIODS);
@@ -211,7 +214,8 @@ static int snd_imx_close(struct snd_pcm_substream *substream)
211 struct snd_pcm_runtime *runtime = substream->runtime; 214 struct snd_pcm_runtime *runtime = substream->runtime;
212 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 215 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
213 216
214 del_timer_sync(&iprtd->timer); 217 hrtimer_cancel(&iprtd->hrt);
218
215 kfree(iprtd); 219 kfree(iprtd);
216 220
217 return 0; 221 return 0;
diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c
index 56f46a75d297..80b4fee2442b 100644
--- a/sound/soc/imx/imx-ssi.c
+++ b/sound/soc/imx/imx-ssi.c
@@ -39,6 +39,7 @@
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/platform_device.h> 41#include <linux/platform_device.h>
42#include <linux/slab.h>
42 43
43#include <sound/core.h> 44#include <sound/core.h>
44#include <sound/initval.h> 45#include <sound/initval.h>
@@ -234,17 +235,20 @@ static int imx_ssi_hw_params(struct snd_pcm_substream *substream,
234 struct snd_soc_dai *cpu_dai) 235 struct snd_soc_dai *cpu_dai)
235{ 236{
236 struct imx_ssi *ssi = cpu_dai->private_data; 237 struct imx_ssi *ssi = cpu_dai->private_data;
238 struct imx_pcm_dma_params *dma_data;
237 u32 reg, sccr; 239 u32 reg, sccr;
238 240
239 /* Tx/Rx config */ 241 /* Tx/Rx config */
240 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 242 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
241 reg = SSI_STCCR; 243 reg = SSI_STCCR;
242 cpu_dai->dma_data = &ssi->dma_params_tx; 244 dma_data = &ssi->dma_params_tx;
243 } else { 245 } else {
244 reg = SSI_SRCCR; 246 reg = SSI_SRCCR;
245 cpu_dai->dma_data = &ssi->dma_params_rx; 247 dma_data = &ssi->dma_params_rx;
246 } 248 }
247 249
250 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
251
248 sccr = readl(ssi->base + reg) & ~SSI_STCCR_WL_MASK; 252 sccr = readl(ssi->base + reg) & ~SSI_STCCR_WL_MASK;
249 253
250 /* DAI data (word) size */ 254 /* DAI data (word) size */
@@ -652,7 +656,8 @@ static int imx_ssi_probe(struct platform_device *pdev)
652 dai->private_data = ssi; 656 dai->private_data = ssi;
653 657
654 if ((cpu_is_mx27() || cpu_is_mx21()) && 658 if ((cpu_is_mx27() || cpu_is_mx21()) &&
655 !(ssi->flags & IMX_SSI_USE_AC97)) { 659 !(ssi->flags & IMX_SSI_USE_AC97) &&
660 (ssi->flags & IMX_SSI_DMA)) {
656 ssi->flags |= IMX_SSI_DMA; 661 ssi->flags |= IMX_SSI_DMA;
657 platform = imx_ssi_dma_mx2_init(pdev, ssi); 662 platform = imx_ssi_dma_mx2_init(pdev, ssi);
658 } else 663 } else
diff --git a/sound/soc/omap/mcpdm.c b/sound/soc/omap/mcpdm.c
index ad8df6cfae88..1dab4c14874d 100644
--- a/sound/soc/omap/mcpdm.c
+++ b/sound/soc/omap/mcpdm.c
@@ -25,6 +25,7 @@
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/slab.h>
28#include <linux/interrupt.h> 29#include <linux/interrupt.h>
29#include <linux/err.h> 30#include <linux/err.h>
30#include <linux/clk.h> 31#include <linux/clk.h>
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index d29725664185..8ad9dc901007 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -39,6 +39,14 @@
39 39
40#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) 40#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000)
41 41
42#define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
43 xhandler_get, xhandler_put) \
44{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
45 .info = omap_mcbsp_st_info_volsw, \
46 .get = xhandler_get, .put = xhandler_put, \
47 .private_value = (unsigned long) &(struct soc_mixer_control) \
48 {.min = xmin, .max = xmax} }
49
42struct omap_mcbsp_data { 50struct omap_mcbsp_data {
43 unsigned int bus_id; 51 unsigned int bus_id;
44 struct omap_mcbsp_reg_cfg regs; 52 struct omap_mcbsp_reg_cfg regs;
@@ -82,11 +90,11 @@ static const int omap1_dma_reqs[][2] = {};
82static const unsigned long omap1_mcbsp_port[][2] = {}; 90static const unsigned long omap1_mcbsp_port[][2] = {};
83#endif 91#endif
84 92
85#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) 93#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
86static const int omap24xx_dma_reqs[][2] = { 94static const int omap24xx_dma_reqs[][2] = {
87 { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX }, 95 { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX },
88 { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX }, 96 { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX },
89#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 97#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
90 { OMAP24XX_DMA_MCBSP3_TX, OMAP24XX_DMA_MCBSP3_RX }, 98 { OMAP24XX_DMA_MCBSP3_TX, OMAP24XX_DMA_MCBSP3_RX },
91 { OMAP24XX_DMA_MCBSP4_TX, OMAP24XX_DMA_MCBSP4_RX }, 99 { OMAP24XX_DMA_MCBSP4_TX, OMAP24XX_DMA_MCBSP4_RX },
92 { OMAP24XX_DMA_MCBSP5_TX, OMAP24XX_DMA_MCBSP5_RX }, 100 { OMAP24XX_DMA_MCBSP5_TX, OMAP24XX_DMA_MCBSP5_RX },
@@ -124,7 +132,7 @@ static const unsigned long omap2430_mcbsp_port[][2] = {
124static const unsigned long omap2430_mcbsp_port[][2] = {}; 132static const unsigned long omap2430_mcbsp_port[][2] = {};
125#endif 133#endif
126 134
127#if defined(CONFIG_ARCH_OMAP34XX) 135#if defined(CONFIG_ARCH_OMAP3)
128static const unsigned long omap34xx_mcbsp_port[][2] = { 136static const unsigned long omap34xx_mcbsp_port[][2] = {
129 { OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR, 137 { OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR,
130 OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR }, 138 OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR },
@@ -289,7 +297,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
289 omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; 297 omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode;
290 omap_mcbsp_dai_dma_params[id][substream->stream].data_type = 298 omap_mcbsp_dai_dma_params[id][substream->stream].data_type =
291 OMAP_DMA_DATA_TYPE_S16; 299 OMAP_DMA_DATA_TYPE_S16;
292 cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream]; 300
301 snd_soc_dai_set_dma_data(cpu_dai, substream,
302 &omap_mcbsp_dai_dma_params[id][substream->stream]);
293 303
294 if (mcbsp_data->configured) { 304 if (mcbsp_data->configured) {
295 /* McBSP already configured by another stream */ 305 /* McBSP already configured by another stream */
@@ -639,6 +649,136 @@ struct snd_soc_dai omap_mcbsp_dai[] = {
639 649
640EXPORT_SYMBOL_GPL(omap_mcbsp_dai); 650EXPORT_SYMBOL_GPL(omap_mcbsp_dai);
641 651
652int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_info *uinfo)
654{
655 struct soc_mixer_control *mc =
656 (struct soc_mixer_control *)kcontrol->private_value;
657 int max = mc->max;
658 int min = mc->min;
659
660 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
661 uinfo->count = 1;
662 uinfo->value.integer.min = min;
663 uinfo->value.integer.max = max;
664 return 0;
665}
666
667#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel) \
668static int \
669omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc, \
670 struct snd_ctl_elem_value *uc) \
671{ \
672 struct soc_mixer_control *mc = \
673 (struct soc_mixer_control *)kc->private_value; \
674 int max = mc->max; \
675 int min = mc->min; \
676 int val = uc->value.integer.value[0]; \
677 \
678 if (val < min || val > max) \
679 return -EINVAL; \
680 \
681 /* OMAP McBSP implementation uses index values 0..4 */ \
682 return omap_st_set_chgain((id)-1, channel, val); \
683}
684
685#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel) \
686static int \
687omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc, \
688 struct snd_ctl_elem_value *uc) \
689{ \
690 s16 chgain; \
691 \
692 if (omap_st_get_chgain((id)-1, channel, &chgain)) \
693 return -EAGAIN; \
694 \
695 uc->value.integer.value[0] = chgain; \
696 return 0; \
697}
698
699OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0)
700OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1)
701OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0)
702OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1)
703OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0)
704OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1)
705OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0)
706OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1)
707
708static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol,
709 struct snd_ctl_elem_value *ucontrol)
710{
711 struct soc_mixer_control *mc =
712 (struct soc_mixer_control *)kcontrol->private_value;
713 u8 value = ucontrol->value.integer.value[0];
714
715 if (value == omap_st_is_enabled(mc->reg))
716 return 0;
717
718 if (value)
719 omap_st_enable(mc->reg);
720 else
721 omap_st_disable(mc->reg);
722
723 return 1;
724}
725
726static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
728{
729 struct soc_mixer_control *mc =
730 (struct soc_mixer_control *)kcontrol->private_value;
731
732 ucontrol->value.integer.value[0] = omap_st_is_enabled(mc->reg);
733 return 0;
734}
735
736static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
737 SOC_SINGLE_EXT("McBSP2 Sidetone Switch", 1, 0, 1, 0,
738 omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
739 OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 0 Volume",
740 -32768, 32767,
741 omap_mcbsp2_get_st_ch0_volume,
742 omap_mcbsp2_set_st_ch0_volume),
743 OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
744 -32768, 32767,
745 omap_mcbsp2_get_st_ch1_volume,
746 omap_mcbsp2_set_st_ch1_volume),
747};
748
749static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = {
750 SOC_SINGLE_EXT("McBSP3 Sidetone Switch", 2, 0, 1, 0,
751 omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
752 OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume",
753 -32768, 32767,
754 omap_mcbsp3_get_st_ch0_volume,
755 omap_mcbsp3_set_st_ch0_volume),
756 OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
757 -32768, 32767,
758 omap_mcbsp3_get_st_ch1_volume,
759 omap_mcbsp3_set_st_ch1_volume),
760};
761
762int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id)
763{
764 if (!cpu_is_omap34xx())
765 return -ENODEV;
766
767 switch (mcbsp_id) {
768 case 1: /* McBSP 2 */
769 return snd_soc_add_controls(codec, omap_mcbsp2_st_controls,
770 ARRAY_SIZE(omap_mcbsp2_st_controls));
771 case 2: /* McBSP 3 */
772 return snd_soc_add_controls(codec, omap_mcbsp3_st_controls,
773 ARRAY_SIZE(omap_mcbsp3_st_controls));
774 default:
775 break;
776 }
777
778 return -EINVAL;
779}
780EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
781
642static int __init snd_omap_mcbsp_init(void) 782static int __init snd_omap_mcbsp_init(void)
643{ 783{
644 return snd_soc_register_dais(omap_mcbsp_dai, 784 return snd_soc_register_dais(omap_mcbsp_dai,
diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h
index 647d2f981ab0..6c363e5f4387 100644
--- a/sound/soc/omap/omap-mcbsp.h
+++ b/sound/soc/omap/omap-mcbsp.h
@@ -50,11 +50,13 @@ enum omap_mcbsp_div {
50#undef NUM_LINKS 50#undef NUM_LINKS
51#define NUM_LINKS 3 51#define NUM_LINKS 3
52#endif 52#endif
53#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 53#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
54#undef NUM_LINKS 54#undef NUM_LINKS
55#define NUM_LINKS 5 55#define NUM_LINKS 5
56#endif 56#endif
57 57
58extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS]; 58extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS];
59 59
60int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id);
61
60#endif 62#endif
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index 25f19e4728bf..b7f4f7e015f3 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -150,7 +150,8 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
150 int stream = substream->stream; 150 int stream = substream->stream;
151 int channels, err, link_mask = 0; 151 int channels, err, link_mask = 0;
152 152
153 cpu_dai->dma_data = &omap_mcpdm_dai_dma_params[stream]; 153 snd_soc_dai_set_dma_data(cpu_dai, substream,
154 &omap_mcpdm_dai_dma_params[stream]);
154 155
155 channels = params_channels(params); 156 channels = params_channels(params);
156 switch (channels) { 157 switch (channels) {
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 825db385f01f..1e521904ea64 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/slab.h>
26#include <sound/core.h> 27#include <sound/core.h>
27#include <sound/pcm.h> 28#include <sound/pcm.h>
28#include <sound/pcm_params.h> 29#include <sound/pcm_params.h>
@@ -60,12 +61,11 @@ static void omap_pcm_dma_irq(int ch, u16 stat, void *data)
60 struct omap_runtime_data *prtd = runtime->private_data; 61 struct omap_runtime_data *prtd = runtime->private_data;
61 unsigned long flags; 62 unsigned long flags;
62 63
63 if ((cpu_is_omap1510()) && 64 if ((cpu_is_omap1510())) {
64 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)) {
65 /* 65 /*
66 * OMAP1510 doesn't fully support DMA progress counter 66 * OMAP1510 doesn't fully support DMA progress counter
67 * and there is no software emulation implemented yet, 67 * and there is no software emulation implemented yet,
68 * so have to maintain our own playback progress counter 68 * so have to maintain our own progress counters
69 * that can be used by omap_pcm_pointer() instead. 69 * that can be used by omap_pcm_pointer() instead.
70 */ 70 */
71 spin_lock_irqsave(&prtd->lock, flags); 71 spin_lock_irqsave(&prtd->lock, flags);
@@ -100,9 +100,11 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
100 struct snd_pcm_runtime *runtime = substream->runtime; 100 struct snd_pcm_runtime *runtime = substream->runtime;
101 struct snd_soc_pcm_runtime *rtd = substream->private_data; 101 struct snd_soc_pcm_runtime *rtd = substream->private_data;
102 struct omap_runtime_data *prtd = runtime->private_data; 102 struct omap_runtime_data *prtd = runtime->private_data;
103 struct omap_pcm_dma_data *dma_data = rtd->dai->cpu_dai->dma_data; 103 struct omap_pcm_dma_data *dma_data;
104 int err = 0; 104 int err = 0;
105 105
106 dma_data = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
107
106 /* return if this is a bufferless transfer e.g. 108 /* return if this is a bufferless transfer e.g.
107 * codec <--> BT codec or GSM modem -- lg FIXME */ 109 * codec <--> BT codec or GSM modem -- lg FIXME */
108 if (!dma_data) 110 if (!dma_data)
@@ -189,8 +191,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
189 dma_params.frame_count = runtime->periods; 191 dma_params.frame_count = runtime->periods;
190 omap_set_dma_params(prtd->dma_ch, &dma_params); 192 omap_set_dma_params(prtd->dma_ch, &dma_params);
191 193
192 if ((cpu_is_omap1510()) && 194 if ((cpu_is_omap1510()))
193 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK))
194 omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ | 195 omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ |
195 OMAP_DMA_LAST_IRQ | OMAP_DMA_BLOCK_IRQ); 196 OMAP_DMA_LAST_IRQ | OMAP_DMA_BLOCK_IRQ);
196 else 197 else
@@ -248,14 +249,15 @@ static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream)
248 dma_addr_t ptr; 249 dma_addr_t ptr;
249 snd_pcm_uframes_t offset; 250 snd_pcm_uframes_t offset;
250 251
251 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { 252 if (cpu_is_omap1510()) {
253 offset = prtd->period_index * runtime->period_size;
254 } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
252 ptr = omap_get_dma_dst_pos(prtd->dma_ch); 255 ptr = omap_get_dma_dst_pos(prtd->dma_ch);
253 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr); 256 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
254 } else if (!(cpu_is_omap1510())) { 257 } else {
255 ptr = omap_get_dma_src_pos(prtd->dma_ch); 258 ptr = omap_get_dma_src_pos(prtd->dma_ch);
256 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr); 259 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
257 } else 260 }
258 offset = prtd->period_index * runtime->period_size;
259 261
260 if (offset >= runtime->buffer_size) 262 if (offset >= runtime->buffer_size)
261 offset = 0; 263 offset = 0;
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index e69397f40f72..544fd9566f4d 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/clk.h> 21#include <linux/clk.h>
21#include <linux/io.h> 22#include <linux/io.h>
@@ -42,11 +43,14 @@
42 * SSP audio private data 43 * SSP audio private data
43 */ 44 */
44struct ssp_priv { 45struct ssp_priv {
45 struct ssp_dev dev; 46 struct ssp_device *ssp;
46 unsigned int sysclk; 47 unsigned int sysclk;
47 int dai_fmt; 48 int dai_fmt;
48#ifdef CONFIG_PM 49#ifdef CONFIG_PM
49 struct ssp_state state; 50 uint32_t cr0;
51 uint32_t cr1;
52 uint32_t to;
53 uint32_t psp;
50#endif 54#endif
51}; 55};
52 56
@@ -61,6 +65,22 @@ static void dump_registers(struct ssp_device *ssp)
61 ssp_read_reg(ssp, SSACD)); 65 ssp_read_reg(ssp, SSACD));
62} 66}
63 67
68static void ssp_enable(struct ssp_device *ssp)
69{
70 uint32_t sscr0;
71
72 sscr0 = __raw_readl(ssp->mmio_base + SSCR0) | SSCR0_SSE;
73 __raw_writel(sscr0, ssp->mmio_base + SSCR0);
74}
75
76static void ssp_disable(struct ssp_device *ssp)
77{
78 uint32_t sscr0;
79
80 sscr0 = __raw_readl(ssp->mmio_base + SSCR0) & ~SSCR0_SSE;
81 __raw_writel(sscr0, ssp->mmio_base + SSCR0);
82}
83
64struct pxa2xx_pcm_dma_data { 84struct pxa2xx_pcm_dma_data {
65 struct pxa2xx_pcm_dma_params params; 85 struct pxa2xx_pcm_dma_params params;
66 char name[20]; 86 char name[20];
@@ -94,19 +114,17 @@ static int pxa_ssp_startup(struct snd_pcm_substream *substream,
94 struct snd_soc_pcm_runtime *rtd = substream->private_data; 114 struct snd_soc_pcm_runtime *rtd = substream->private_data;
95 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 115 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
96 struct ssp_priv *priv = cpu_dai->private_data; 116 struct ssp_priv *priv = cpu_dai->private_data;
117 struct ssp_device *ssp = priv->ssp;
97 int ret = 0; 118 int ret = 0;
98 119
99 if (!cpu_dai->active) { 120 if (!cpu_dai->active) {
100 priv->dev.port = cpu_dai->id + 1; 121 clk_enable(ssp->clk);
101 priv->dev.irq = NO_IRQ; 122 ssp_disable(ssp);
102 clk_enable(priv->dev.ssp->clk);
103 ssp_disable(&priv->dev);
104 } 123 }
105 124
106 if (cpu_dai->dma_data) { 125 kfree(snd_soc_dai_get_dma_data(cpu_dai, substream));
107 kfree(cpu_dai->dma_data); 126 snd_soc_dai_set_dma_data(cpu_dai, substream, NULL);
108 cpu_dai->dma_data = NULL; 127
109 }
110 return ret; 128 return ret;
111} 129}
112 130
@@ -116,16 +134,15 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
116 struct snd_soc_pcm_runtime *rtd = substream->private_data; 134 struct snd_soc_pcm_runtime *rtd = substream->private_data;
117 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 135 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
118 struct ssp_priv *priv = cpu_dai->private_data; 136 struct ssp_priv *priv = cpu_dai->private_data;
137 struct ssp_device *ssp = priv->ssp;
119 138
120 if (!cpu_dai->active) { 139 if (!cpu_dai->active) {
121 ssp_disable(&priv->dev); 140 ssp_disable(ssp);
122 clk_disable(priv->dev.ssp->clk); 141 clk_disable(ssp->clk);
123 } 142 }
124 143
125 if (cpu_dai->dma_data) { 144 kfree(snd_soc_dai_get_dma_data(cpu_dai, substream));
126 kfree(cpu_dai->dma_data); 145 snd_soc_dai_set_dma_data(cpu_dai, substream, NULL);
127 cpu_dai->dma_data = NULL;
128 }
129} 146}
130 147
131#ifdef CONFIG_PM 148#ifdef CONFIG_PM
@@ -133,27 +150,39 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
133static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) 150static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
134{ 151{
135 struct ssp_priv *priv = cpu_dai->private_data; 152 struct ssp_priv *priv = cpu_dai->private_data;
153 struct ssp_device *ssp = priv->ssp;
136 154
137 if (!cpu_dai->active) 155 if (!cpu_dai->active)
138 clk_enable(priv->dev.ssp->clk); 156 clk_enable(ssp->clk);
139 157
140 ssp_save_state(&priv->dev, &priv->state); 158 priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0);
141 clk_disable(priv->dev.ssp->clk); 159 priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1);
160 priv->to = __raw_readl(ssp->mmio_base + SSTO);
161 priv->psp = __raw_readl(ssp->mmio_base + SSPSP);
142 162
163 ssp_disable(ssp);
164 clk_disable(ssp->clk);
143 return 0; 165 return 0;
144} 166}
145 167
146static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) 168static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
147{ 169{
148 struct ssp_priv *priv = cpu_dai->private_data; 170 struct ssp_priv *priv = cpu_dai->private_data;
171 struct ssp_device *ssp = priv->ssp;
172 uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE;
149 173
150 clk_enable(priv->dev.ssp->clk); 174 clk_enable(ssp->clk);
151 ssp_restore_state(&priv->dev, &priv->state); 175
176 __raw_writel(sssr, ssp->mmio_base + SSSR);
177 __raw_writel(priv->cr0 & ~SSCR0_SSE, ssp->mmio_base + SSCR0);
178 __raw_writel(priv->cr1, ssp->mmio_base + SSCR1);
179 __raw_writel(priv->to, ssp->mmio_base + SSTO);
180 __raw_writel(priv->psp, ssp->mmio_base + SSPSP);
152 181
153 if (cpu_dai->active) 182 if (cpu_dai->active)
154 ssp_enable(&priv->dev); 183 ssp_enable(ssp);
155 else 184 else
156 clk_disable(priv->dev.ssp->clk); 185 clk_disable(ssp->clk);
157 186
158 return 0; 187 return 0;
159} 188}
@@ -203,7 +232,7 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
203 int clk_id, unsigned int freq, int dir) 232 int clk_id, unsigned int freq, int dir)
204{ 233{
205 struct ssp_priv *priv = cpu_dai->private_data; 234 struct ssp_priv *priv = cpu_dai->private_data;
206 struct ssp_device *ssp = priv->dev.ssp; 235 struct ssp_device *ssp = priv->ssp;
207 int val; 236 int val;
208 237
209 u32 sscr0 = ssp_read_reg(ssp, SSCR0) & 238 u32 sscr0 = ssp_read_reg(ssp, SSCR0) &
@@ -244,11 +273,11 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
244 /* The SSP clock must be disabled when changing SSP clock mode 273 /* The SSP clock must be disabled when changing SSP clock mode
245 * on PXA2xx. On PXA3xx it must be enabled when doing so. */ 274 * on PXA2xx. On PXA3xx it must be enabled when doing so. */
246 if (!cpu_is_pxa3xx()) 275 if (!cpu_is_pxa3xx())
247 clk_disable(priv->dev.ssp->clk); 276 clk_disable(ssp->clk);
248 val = ssp_read_reg(ssp, SSCR0) | sscr0; 277 val = ssp_read_reg(ssp, SSCR0) | sscr0;
249 ssp_write_reg(ssp, SSCR0, val); 278 ssp_write_reg(ssp, SSCR0, val);
250 if (!cpu_is_pxa3xx()) 279 if (!cpu_is_pxa3xx())
251 clk_enable(priv->dev.ssp->clk); 280 clk_enable(ssp->clk);
252 281
253 return 0; 282 return 0;
254} 283}
@@ -260,7 +289,7 @@ static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai *cpu_dai,
260 int div_id, int div) 289 int div_id, int div)
261{ 290{
262 struct ssp_priv *priv = cpu_dai->private_data; 291 struct ssp_priv *priv = cpu_dai->private_data;
263 struct ssp_device *ssp = priv->dev.ssp; 292 struct ssp_device *ssp = priv->ssp;
264 int val; 293 int val;
265 294
266 switch (div_id) { 295 switch (div_id) {
@@ -311,7 +340,7 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id,
311 int source, unsigned int freq_in, unsigned int freq_out) 340 int source, unsigned int freq_in, unsigned int freq_out)
312{ 341{
313 struct ssp_priv *priv = cpu_dai->private_data; 342 struct ssp_priv *priv = cpu_dai->private_data;
314 struct ssp_device *ssp = priv->dev.ssp; 343 struct ssp_device *ssp = priv->ssp;
315 u32 ssacd = ssp_read_reg(ssp, SSACD) & ~0x70; 344 u32 ssacd = ssp_read_reg(ssp, SSACD) & ~0x70;
316 345
317#if defined(CONFIG_PXA3xx) 346#if defined(CONFIG_PXA3xx)
@@ -380,7 +409,7 @@ static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai,
380 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) 409 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
381{ 410{
382 struct ssp_priv *priv = cpu_dai->private_data; 411 struct ssp_priv *priv = cpu_dai->private_data;
383 struct ssp_device *ssp = priv->dev.ssp; 412 struct ssp_device *ssp = priv->ssp;
384 u32 sscr0; 413 u32 sscr0;
385 414
386 sscr0 = ssp_read_reg(ssp, SSCR0); 415 sscr0 = ssp_read_reg(ssp, SSCR0);
@@ -415,7 +444,7 @@ static int pxa_ssp_set_dai_tristate(struct snd_soc_dai *cpu_dai,
415 int tristate) 444 int tristate)
416{ 445{
417 struct ssp_priv *priv = cpu_dai->private_data; 446 struct ssp_priv *priv = cpu_dai->private_data;
418 struct ssp_device *ssp = priv->dev.ssp; 447 struct ssp_device *ssp = priv->ssp;
419 u32 sscr1; 448 u32 sscr1;
420 449
421 sscr1 = ssp_read_reg(ssp, SSCR1); 450 sscr1 = ssp_read_reg(ssp, SSCR1);
@@ -437,7 +466,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
437 unsigned int fmt) 466 unsigned int fmt)
438{ 467{
439 struct ssp_priv *priv = cpu_dai->private_data; 468 struct ssp_priv *priv = cpu_dai->private_data;
440 struct ssp_device *ssp = priv->dev.ssp; 469 struct ssp_device *ssp = priv->ssp;
441 u32 sscr0; 470 u32 sscr0;
442 u32 sscr1; 471 u32 sscr1;
443 u32 sspsp; 472 u32 sspsp;
@@ -532,25 +561,29 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
532 struct snd_soc_pcm_runtime *rtd = substream->private_data; 561 struct snd_soc_pcm_runtime *rtd = substream->private_data;
533 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 562 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
534 struct ssp_priv *priv = cpu_dai->private_data; 563 struct ssp_priv *priv = cpu_dai->private_data;
535 struct ssp_device *ssp = priv->dev.ssp; 564 struct ssp_device *ssp = priv->ssp;
536 int chn = params_channels(params); 565 int chn = params_channels(params);
537 u32 sscr0; 566 u32 sscr0;
538 u32 sspsp; 567 u32 sspsp;
539 int width = snd_pcm_format_physical_width(params_format(params)); 568 int width = snd_pcm_format_physical_width(params_format(params));
540 int ttsa = ssp_read_reg(ssp, SSTSA) & 0xf; 569 int ttsa = ssp_read_reg(ssp, SSTSA) & 0xf;
570 struct pxa2xx_pcm_dma_params *dma_data;
571
572 dma_data = snd_soc_dai_get_dma_data(dai, substream);
541 573
542 /* generate correct DMA params */ 574 /* generate correct DMA params */
543 if (cpu_dai->dma_data) 575 kfree(dma_data);
544 kfree(cpu_dai->dma_data);
545 576
546 /* Network mode with one active slot (ttsa == 1) can be used 577 /* Network mode with one active slot (ttsa == 1) can be used
547 * to force 16-bit frame width on the wire (for S16_LE), even 578 * to force 16-bit frame width on the wire (for S16_LE), even
548 * with two channels. Use 16-bit DMA transfers for this case. 579 * with two channels. Use 16-bit DMA transfers for this case.
549 */ 580 */
550 cpu_dai->dma_data = ssp_get_dma_params(ssp, 581 dma_data = ssp_get_dma_params(ssp,
551 ((chn == 2) && (ttsa != 1)) || (width == 32), 582 ((chn == 2) && (ttsa != 1)) || (width == 32),
552 substream->stream == SNDRV_PCM_STREAM_PLAYBACK); 583 substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
553 584
585 snd_soc_dai_set_dma_data(dai, substream, dma_data);
586
554 /* we can only change the settings if the port is not in use */ 587 /* we can only change the settings if the port is not in use */
555 if (ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) 588 if (ssp_read_reg(ssp, SSCR0) & SSCR0_SSE)
556 return 0; 589 return 0;
@@ -642,12 +675,12 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
642 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 675 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
643 int ret = 0; 676 int ret = 0;
644 struct ssp_priv *priv = cpu_dai->private_data; 677 struct ssp_priv *priv = cpu_dai->private_data;
645 struct ssp_device *ssp = priv->dev.ssp; 678 struct ssp_device *ssp = priv->ssp;
646 int val; 679 int val;
647 680
648 switch (cmd) { 681 switch (cmd) {
649 case SNDRV_PCM_TRIGGER_RESUME: 682 case SNDRV_PCM_TRIGGER_RESUME:
650 ssp_enable(&priv->dev); 683 ssp_enable(ssp);
651 break; 684 break;
652 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 685 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
653 val = ssp_read_reg(ssp, SSCR1); 686 val = ssp_read_reg(ssp, SSCR1);
@@ -666,7 +699,7 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
666 else 699 else
667 val |= SSCR1_RSRE; 700 val |= SSCR1_RSRE;
668 ssp_write_reg(ssp, SSCR1, val); 701 ssp_write_reg(ssp, SSCR1, val);
669 ssp_enable(&priv->dev); 702 ssp_enable(ssp);
670 break; 703 break;
671 case SNDRV_PCM_TRIGGER_STOP: 704 case SNDRV_PCM_TRIGGER_STOP:
672 val = ssp_read_reg(ssp, SSCR1); 705 val = ssp_read_reg(ssp, SSCR1);
@@ -677,7 +710,7 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
677 ssp_write_reg(ssp, SSCR1, val); 710 ssp_write_reg(ssp, SSCR1, val);
678 break; 711 break;
679 case SNDRV_PCM_TRIGGER_SUSPEND: 712 case SNDRV_PCM_TRIGGER_SUSPEND:
680 ssp_disable(&priv->dev); 713 ssp_disable(ssp);
681 break; 714 break;
682 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 715 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
683 val = ssp_read_reg(ssp, SSCR1); 716 val = ssp_read_reg(ssp, SSCR1);
@@ -707,8 +740,8 @@ static int pxa_ssp_probe(struct platform_device *pdev,
707 if (!priv) 740 if (!priv)
708 return -ENOMEM; 741 return -ENOMEM;
709 742
710 priv->dev.ssp = ssp_request(dai->id + 1, "SoC audio"); 743 priv->ssp = ssp_request(dai->id + 1, "SoC audio");
711 if (priv->dev.ssp == NULL) { 744 if (priv->ssp == NULL) {
712 ret = -ENODEV; 745 ret = -ENODEV;
713 goto err_priv; 746 goto err_priv;
714 } 747 }
@@ -727,7 +760,7 @@ static void pxa_ssp_remove(struct platform_device *pdev,
727 struct snd_soc_dai *dai) 760 struct snd_soc_dai *dai)
728{ 761{
729 struct ssp_priv *priv = dai->private_data; 762 struct ssp_priv *priv = dai->private_data;
730 ssp_free(priv->dev.ssp); 763 ssp_free(priv->ssp);
731} 764}
732 765
733#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 766#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index e9ae7b3a7e00..d314115e3dd7 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -122,11 +122,14 @@ static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream,
122{ 122{
123 struct snd_soc_pcm_runtime *rtd = substream->private_data; 123 struct snd_soc_pcm_runtime *rtd = substream->private_data;
124 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 124 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
125 struct pxa2xx_pcm_dma_params *dma_data;
125 126
126 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 127 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
127 cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out; 128 dma_data = &pxa2xx_ac97_pcm_stereo_out;
128 else 129 else
129 cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_in; 130 dma_data = &pxa2xx_ac97_pcm_stereo_in;
131
132 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
130 133
131 return 0; 134 return 0;
132} 135}
@@ -137,11 +140,14 @@ static int pxa2xx_ac97_hw_aux_params(struct snd_pcm_substream *substream,
137{ 140{
138 struct snd_soc_pcm_runtime *rtd = substream->private_data; 141 struct snd_soc_pcm_runtime *rtd = substream->private_data;
139 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 142 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
143 struct pxa2xx_pcm_dma_params *dma_data;
140 144
141 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 145 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
142 cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out; 146 dma_data = &pxa2xx_ac97_pcm_aux_mono_out;
143 else 147 else
144 cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_in; 148 dma_data = &pxa2xx_ac97_pcm_aux_mono_in;
149
150 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
145 151
146 return 0; 152 return 0;
147} 153}
@@ -156,7 +162,8 @@ static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream,
156 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 162 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
157 return -ENODEV; 163 return -ENODEV;
158 else 164 else
159 cpu_dai->dma_data = &pxa2xx_ac97_pcm_mic_mono_in; 165 snd_soc_dai_set_dma_data(cpu_dai, substream,
166 &pxa2xx_ac97_pcm_mic_mono_in);
160 167
161 return 0; 168 return 0;
162} 169}
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
index 6b8f655d1ad8..c1a5275721e4 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -164,6 +164,7 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream,
164{ 164{
165 struct snd_soc_pcm_runtime *rtd = substream->private_data; 165 struct snd_soc_pcm_runtime *rtd = substream->private_data;
166 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 166 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
167 struct pxa2xx_pcm_dma_params *dma_data;
167 168
168 BUG_ON(IS_ERR(clk_i2s)); 169 BUG_ON(IS_ERR(clk_i2s));
169 clk_enable(clk_i2s); 170 clk_enable(clk_i2s);
@@ -171,9 +172,11 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream,
171 pxa_i2s_wait(); 172 pxa_i2s_wait();
172 173
173 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 174 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
174 cpu_dai->dma_data = &pxa2xx_i2s_pcm_stereo_out; 175 dma_data = &pxa2xx_i2s_pcm_stereo_out;
175 else 176 else
176 cpu_dai->dma_data = &pxa2xx_i2s_pcm_stereo_in; 177 dma_data = &pxa2xx_i2s_pcm_stereo_in;
178
179 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
177 180
178 /* is port used by another stream */ 181 /* is port used by another stream */
179 if (!(SACR0 & SACR0_ENB)) { 182 if (!(SACR0 & SACR0_ENB)) {
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index d38e39575f51..adc7e6f15f93 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -25,9 +25,11 @@ static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
25 struct snd_pcm_runtime *runtime = substream->runtime; 25 struct snd_pcm_runtime *runtime = substream->runtime;
26 struct pxa2xx_runtime_data *prtd = runtime->private_data; 26 struct pxa2xx_runtime_data *prtd = runtime->private_data;
27 struct snd_soc_pcm_runtime *rtd = substream->private_data; 27 struct snd_soc_pcm_runtime *rtd = substream->private_data;
28 struct pxa2xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data; 28 struct pxa2xx_pcm_dma_params *dma;
29 int ret; 29 int ret;
30 30
31 dma = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
32
31 /* return if this is a bufferless transfer e.g. 33 /* return if this is a bufferless transfer e.g.
32 * codec <--> BT codec or GSM modem -- lg FIXME */ 34 * codec <--> BT codec or GSM modem -- lg FIXME */
33 if (!dma) 35 if (!dma)
diff --git a/sound/soc/s3c24xx/s3c-ac97.c b/sound/soc/s3c24xx/s3c-ac97.c
index ee8ed9d7e703..ecf4fd04ae96 100644
--- a/sound/soc/s3c24xx/s3c-ac97.c
+++ b/sound/soc/s3c24xx/s3c-ac97.c
@@ -224,11 +224,14 @@ static int s3c_ac97_hw_params(struct snd_pcm_substream *substream,
224{ 224{
225 struct snd_soc_pcm_runtime *rtd = substream->private_data; 225 struct snd_soc_pcm_runtime *rtd = substream->private_data;
226 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 226 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
227 struct s3c_dma_params *dma_data;
227 228
228 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 229 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
229 cpu_dai->dma_data = &s3c_ac97_pcm_out; 230 dma_data = &s3c_ac97_pcm_out;
230 else 231 else
231 cpu_dai->dma_data = &s3c_ac97_pcm_in; 232 dma_data = &s3c_ac97_pcm_in;
233
234 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
232 235
233 return 0; 236 return 0;
234} 237}
@@ -238,8 +241,8 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd,
238{ 241{
239 u32 ac_glbctrl; 242 u32 ac_glbctrl;
240 struct snd_soc_pcm_runtime *rtd = substream->private_data; 243 struct snd_soc_pcm_runtime *rtd = substream->private_data;
241 int channel = ((struct s3c_dma_params *) 244 struct s3c_dma_params *dma_data =
242 rtd->dai->cpu_dai->dma_data)->channel; 245 snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
243 246
244 ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); 247 ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL);
245 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) 248 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
@@ -265,7 +268,7 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd,
265 268
266 writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); 269 writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL);
267 270
268 s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); 271 s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED);
269 272
270 return 0; 273 return 0;
271} 274}
@@ -280,7 +283,7 @@ static int s3c_ac97_hw_mic_params(struct snd_pcm_substream *substream,
280 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 283 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
281 return -ENODEV; 284 return -ENODEV;
282 else 285 else
283 cpu_dai->dma_data = &s3c_ac97_mic_in; 286 snd_soc_dai_set_dma_data(cpu_dai, substream, &s3c_ac97_mic_in);
284 287
285 return 0; 288 return 0;
286} 289}
@@ -290,8 +293,8 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream,
290{ 293{
291 u32 ac_glbctrl; 294 u32 ac_glbctrl;
292 struct snd_soc_pcm_runtime *rtd = substream->private_data; 295 struct snd_soc_pcm_runtime *rtd = substream->private_data;
293 int channel = ((struct s3c_dma_params *) 296 struct s3c_dma_params *dma_data =
294 rtd->dai->cpu_dai->dma_data)->channel; 297 snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
295 298
296 ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); 299 ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL);
297 ac_glbctrl &= ~S3C_AC97_GLBCTRL_MICINTM_MASK; 300 ac_glbctrl &= ~S3C_AC97_GLBCTRL_MICINTM_MASK;
@@ -311,7 +314,7 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream,
311 314
312 writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); 315 writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL);
313 316
314 s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); 317 s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED);
315 318
316 return 0; 319 return 0;
317} 320}
diff --git a/sound/soc/s3c24xx/s3c-dma.c b/sound/soc/s3c24xx/s3c-dma.c
index 7725e26d6c91..1b61c23ff300 100644
--- a/sound/soc/s3c24xx/s3c-dma.c
+++ b/sound/soc/s3c24xx/s3c-dma.c
@@ -145,10 +145,12 @@ static int s3c_dma_hw_params(struct snd_pcm_substream *substream,
145 struct snd_pcm_runtime *runtime = substream->runtime; 145 struct snd_pcm_runtime *runtime = substream->runtime;
146 struct s3c24xx_runtime_data *prtd = runtime->private_data; 146 struct s3c24xx_runtime_data *prtd = runtime->private_data;
147 struct snd_soc_pcm_runtime *rtd = substream->private_data; 147 struct snd_soc_pcm_runtime *rtd = substream->private_data;
148 struct s3c_dma_params *dma = rtd->dai->cpu_dai->dma_data;
149 unsigned long totbytes = params_buffer_bytes(params); 148 unsigned long totbytes = params_buffer_bytes(params);
149 struct s3c_dma_params *dma =
150 snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
150 int ret = 0; 151 int ret = 0;
151 152
153
152 pr_debug("Entered %s\n", __func__); 154 pr_debug("Entered %s\n", __func__);
153 155
154 /* return if this is a bufferless transfer e.g. 156 /* return if this is a bufferless transfer e.g.
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c
index e994d8374fe6..88515946b6c0 100644
--- a/sound/soc/s3c24xx/s3c-i2s-v2.c
+++ b/sound/soc/s3c24xx/s3c-i2s-v2.c
@@ -339,14 +339,17 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream,
339 struct snd_soc_pcm_runtime *rtd = substream->private_data; 339 struct snd_soc_pcm_runtime *rtd = substream->private_data;
340 struct snd_soc_dai_link *dai = rtd->dai; 340 struct snd_soc_dai_link *dai = rtd->dai;
341 struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai); 341 struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai);
342 struct s3c_dma_params *dma_data;
342 u32 iismod; 343 u32 iismod;
343 344
344 pr_debug("Entered %s\n", __func__); 345 pr_debug("Entered %s\n", __func__);
345 346
346 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 347 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
347 dai->cpu_dai->dma_data = i2s->dma_playback; 348 dma_data = i2s->dma_playback;
348 else 349 else
349 dai->cpu_dai->dma_data = i2s->dma_capture; 350 dma_data = i2s->dma_capture;
351
352 snd_soc_dai_set_dma_data(dai->cpu_dai, substream, dma_data);
350 353
351 /* Working copies of register */ 354 /* Working copies of register */
352 iismod = readl(i2s->regs + S3C2412_IISMOD); 355 iismod = readl(i2s->regs + S3C2412_IISMOD);
@@ -394,8 +397,8 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
394 int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); 397 int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
395 unsigned long irqs; 398 unsigned long irqs;
396 int ret = 0; 399 int ret = 0;
397 int channel = ((struct s3c_dma_params *) 400 struct s3c_dma_params *dma_data =
398 rtd->dai->cpu_dai->dma_data)->channel; 401 snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
399 402
400 pr_debug("Entered %s\n", __func__); 403 pr_debug("Entered %s\n", __func__);
401 404
@@ -431,7 +434,7 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
431 * of the auto reload mechanism of S3C24XX. 434 * of the auto reload mechanism of S3C24XX.
432 * This call won't bother S3C64XX. 435 * This call won't bother S3C64XX.
433 */ 436 */
434 s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); 437 s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED);
435 438
436 break; 439 break;
437 440
diff --git a/sound/soc/s3c24xx/s3c-pcm.c b/sound/soc/s3c24xx/s3c-pcm.c
index a98f40c3cd29..326f0a9e7e30 100644
--- a/sound/soc/s3c24xx/s3c-pcm.c
+++ b/sound/soc/s3c24xx/s3c-pcm.c
@@ -178,6 +178,7 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
178 struct snd_soc_pcm_runtime *rtd = substream->private_data; 178 struct snd_soc_pcm_runtime *rtd = substream->private_data;
179 struct snd_soc_dai_link *dai = rtd->dai; 179 struct snd_soc_dai_link *dai = rtd->dai;
180 struct s3c_pcm_info *pcm = to_info(dai->cpu_dai); 180 struct s3c_pcm_info *pcm = to_info(dai->cpu_dai);
181 struct s3c_dma_params *dma_data;
181 void __iomem *regs = pcm->regs; 182 void __iomem *regs = pcm->regs;
182 struct clk *clk; 183 struct clk *clk;
183 int sclk_div, sync_div; 184 int sclk_div, sync_div;
@@ -187,9 +188,11 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
187 dev_dbg(pcm->dev, "Entered %s\n", __func__); 188 dev_dbg(pcm->dev, "Entered %s\n", __func__);
188 189
189 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 190 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
190 dai->cpu_dai->dma_data = pcm->dma_playback; 191 dma_data = pcm->dma_playback;
191 else 192 else
192 dai->cpu_dai->dma_data = pcm->dma_capture; 193 dma_data = pcm->dma_capture;
194
195 snd_soc_dai_set_dma_data(dai->cpu_dai, substream, dma_data);
193 196
194 /* Strictly check for sample size */ 197 /* Strictly check for sample size */
195 switch (params_format(params)) { 198 switch (params_format(params)) {
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c
index 0bc5950b9f02..c3ac890a3986 100644
--- a/sound/soc/s3c24xx/s3c24xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.c
@@ -242,14 +242,17 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
242 struct snd_soc_dai *dai) 242 struct snd_soc_dai *dai)
243{ 243{
244 struct snd_soc_pcm_runtime *rtd = substream->private_data; 244 struct snd_soc_pcm_runtime *rtd = substream->private_data;
245 struct s3c_dma_params *dma_data;
245 u32 iismod; 246 u32 iismod;
246 247
247 pr_debug("Entered %s\n", __func__); 248 pr_debug("Entered %s\n", __func__);
248 249
249 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 250 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
250 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out; 251 dma_data = &s3c24xx_i2s_pcm_stereo_out;
251 else 252 else
252 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_in; 253 dma_data = &s3c24xx_i2s_pcm_stereo_in;
254
255 snd_soc_dai_set_dma_data(rtd->dai->cpu_dai, substream, dma_data);
253 256
254 /* Working copies of register */ 257 /* Working copies of register */
255 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); 258 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
@@ -258,13 +261,11 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
258 switch (params_format(params)) { 261 switch (params_format(params)) {
259 case SNDRV_PCM_FORMAT_S8: 262 case SNDRV_PCM_FORMAT_S8:
260 iismod &= ~S3C2410_IISMOD_16BIT; 263 iismod &= ~S3C2410_IISMOD_16BIT;
261 ((struct s3c_dma_params *) 264 dma_data->dma_size = 1;
262 rtd->dai->cpu_dai->dma_data)->dma_size = 1;
263 break; 265 break;
264 case SNDRV_PCM_FORMAT_S16_LE: 266 case SNDRV_PCM_FORMAT_S16_LE:
265 iismod |= S3C2410_IISMOD_16BIT; 267 iismod |= S3C2410_IISMOD_16BIT;
266 ((struct s3c_dma_params *) 268 dma_data->dma_size = 2;
267 rtd->dai->cpu_dai->dma_data)->dma_size = 2;
268 break; 269 break;
269 default: 270 default:
270 return -EINVAL; 271 return -EINVAL;
@@ -280,8 +281,8 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
280{ 281{
281 int ret = 0; 282 int ret = 0;
282 struct snd_soc_pcm_runtime *rtd = substream->private_data; 283 struct snd_soc_pcm_runtime *rtd = substream->private_data;
283 int channel = ((struct s3c_dma_params *) 284 struct s3c_dma_params *dma_data =
284 rtd->dai->cpu_dai->dma_data)->channel; 285 snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
285 286
286 pr_debug("Entered %s\n", __func__); 287 pr_debug("Entered %s\n", __func__);
287 288
@@ -300,7 +301,7 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
300 else 301 else
301 s3c24xx_snd_txctrl(1); 302 s3c24xx_snd_txctrl(1);
302 303
303 s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); 304 s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED);
304 break; 305 break;
305 case SNDRV_PCM_TRIGGER_STOP: 306 case SNDRV_PCM_TRIGGER_STOP:
306 case SNDRV_PCM_TRIGGER_SUSPEND: 307 case SNDRV_PCM_TRIGGER_SUSPEND:
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c
index 93ed3aad1631..a72c251401ac 100644
--- a/sound/soc/s3c24xx/s3c64xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c64xx-i2s.c
@@ -22,8 +22,8 @@
22#include <sound/soc.h> 22#include <sound/soc.h>
23 23
24#include <plat/regs-s3c2412-iis.h> 24#include <plat/regs-s3c2412-iis.h>
25#include <plat/gpio-bank-d.h> 25#include <mach/gpio-bank-d.h>
26#include <plat/gpio-bank-e.h> 26#include <mach/gpio-bank-e.h>
27#include <plat/gpio-cfg.h> 27#include <plat/gpio-cfg.h>
28 28
29#include <mach/map.h> 29#include <mach/map.h>
diff --git a/sound/soc/s6000/s6000-i2s.c b/sound/soc/s6000/s6000-i2s.c
index c5cda187ecab..5b9ac1759bd2 100644
--- a/sound/soc/s6000/s6000-i2s.c
+++ b/sound/soc/s6000/s6000-i2s.c
@@ -16,6 +16,7 @@
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/slab.h>
19 20
20#include <sound/core.h> 21#include <sound/core.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
@@ -518,7 +519,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev)
518 519
519 s6000_i2s_dai.dev = &pdev->dev; 520 s6000_i2s_dai.dev = &pdev->dev;
520 s6000_i2s_dai.private_data = dev; 521 s6000_i2s_dai.private_data = dev;
521 s6000_i2s_dai.dma_data = &dev->dma_params; 522 s6000_i2s_dai.capture.dma_data = &dev->dma_params;
523 s6000_i2s_dai.playback.dma_data = &dev->dma_params;
522 524
523 dev->sifbase = sifmem->start; 525 dev->sifbase = sifmem->start;
524 dev->scbbase = mmio; 526 dev->scbbase = mmio;
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
index 1d61109e09fa..9c7f7f00cebb 100644
--- a/sound/soc/s6000/s6000-pcm.c
+++ b/sound/soc/s6000/s6000-pcm.c
@@ -58,13 +58,15 @@ static void s6000_pcm_enqueue_dma(struct snd_pcm_substream *substream)
58 struct snd_pcm_runtime *runtime = substream->runtime; 58 struct snd_pcm_runtime *runtime = substream->runtime;
59 struct s6000_runtime_data *prtd = runtime->private_data; 59 struct s6000_runtime_data *prtd = runtime->private_data;
60 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 60 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
61 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 61 struct s6000_pcm_dma_params *par;
62 int channel; 62 int channel;
63 unsigned int period_size; 63 unsigned int period_size;
64 unsigned int dma_offset; 64 unsigned int dma_offset;
65 dma_addr_t dma_pos; 65 dma_addr_t dma_pos;
66 dma_addr_t src, dst; 66 dma_addr_t src, dst;
67 67
68 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
69
68 period_size = snd_pcm_lib_period_bytes(substream); 70 period_size = snd_pcm_lib_period_bytes(substream);
69 dma_offset = prtd->period * period_size; 71 dma_offset = prtd->period * period_size;
70 dma_pos = runtime->dma_addr + dma_offset; 72 dma_pos = runtime->dma_addr + dma_offset;
@@ -101,7 +103,8 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data)
101{ 103{
102 struct snd_pcm *pcm = data; 104 struct snd_pcm *pcm = data;
103 struct snd_soc_pcm_runtime *runtime = pcm->private_data; 105 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
104 struct s6000_pcm_dma_params *params = runtime->dai->cpu_dai->dma_data; 106 struct s6000_pcm_dma_params *params =
107 snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
105 struct s6000_runtime_data *prtd; 108 struct s6000_runtime_data *prtd;
106 unsigned int has_xrun; 109 unsigned int has_xrun;
107 int i, ret = IRQ_NONE; 110 int i, ret = IRQ_NONE;
@@ -172,11 +175,13 @@ static int s6000_pcm_start(struct snd_pcm_substream *substream)
172{ 175{
173 struct s6000_runtime_data *prtd = substream->runtime->private_data; 176 struct s6000_runtime_data *prtd = substream->runtime->private_data;
174 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 177 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
175 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 178 struct s6000_pcm_dma_params *par;
176 unsigned long flags; 179 unsigned long flags;
177 int srcinc; 180 int srcinc;
178 u32 dma; 181 u32 dma;
179 182
183 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
184
180 spin_lock_irqsave(&prtd->lock, flags); 185 spin_lock_irqsave(&prtd->lock, flags);
181 186
182 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 187 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -212,10 +217,12 @@ static int s6000_pcm_stop(struct snd_pcm_substream *substream)
212{ 217{
213 struct s6000_runtime_data *prtd = substream->runtime->private_data; 218 struct s6000_runtime_data *prtd = substream->runtime->private_data;
214 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 219 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
215 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 220 struct s6000_pcm_dma_params *par;
216 unsigned long flags; 221 unsigned long flags;
217 u32 channel; 222 u32 channel;
218 223
224 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
225
219 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 226 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
220 channel = par->dma_out; 227 channel = par->dma_out;
221 else 228 else
@@ -236,9 +243,11 @@ static int s6000_pcm_stop(struct snd_pcm_substream *substream)
236static int s6000_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 243static int s6000_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
237{ 244{
238 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 245 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
239 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 246 struct s6000_pcm_dma_params *par;
240 int ret; 247 int ret;
241 248
249 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
250
242 ret = par->trigger(substream, cmd, 0); 251 ret = par->trigger(substream, cmd, 0);
243 if (ret < 0) 252 if (ret < 0)
244 return ret; 253 return ret;
@@ -275,13 +284,15 @@ static int s6000_pcm_prepare(struct snd_pcm_substream *substream)
275static snd_pcm_uframes_t s6000_pcm_pointer(struct snd_pcm_substream *substream) 284static snd_pcm_uframes_t s6000_pcm_pointer(struct snd_pcm_substream *substream)
276{ 285{
277 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 286 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
278 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 287 struct s6000_pcm_dma_params *par;
279 struct snd_pcm_runtime *runtime = substream->runtime; 288 struct snd_pcm_runtime *runtime = substream->runtime;
280 struct s6000_runtime_data *prtd = runtime->private_data; 289 struct s6000_runtime_data *prtd = runtime->private_data;
281 unsigned long flags; 290 unsigned long flags;
282 unsigned int offset; 291 unsigned int offset;
283 dma_addr_t count; 292 dma_addr_t count;
284 293
294 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
295
285 spin_lock_irqsave(&prtd->lock, flags); 296 spin_lock_irqsave(&prtd->lock, flags);
286 297
287 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 298 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -305,11 +316,12 @@ static snd_pcm_uframes_t s6000_pcm_pointer(struct snd_pcm_substream *substream)
305static int s6000_pcm_open(struct snd_pcm_substream *substream) 316static int s6000_pcm_open(struct snd_pcm_substream *substream)
306{ 317{
307 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 318 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
308 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 319 struct s6000_pcm_dma_params *par;
309 struct snd_pcm_runtime *runtime = substream->runtime; 320 struct snd_pcm_runtime *runtime = substream->runtime;
310 struct s6000_runtime_data *prtd; 321 struct s6000_runtime_data *prtd;
311 int ret; 322 int ret;
312 323
324 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
313 snd_soc_set_runtime_hwparams(substream, &s6000_pcm_hardware); 325 snd_soc_set_runtime_hwparams(substream, &s6000_pcm_hardware);
314 326
315 ret = snd_pcm_hw_constraint_step(runtime, 0, 327 ret = snd_pcm_hw_constraint_step(runtime, 0,
@@ -364,7 +376,7 @@ static int s6000_pcm_hw_params(struct snd_pcm_substream *substream,
364 struct snd_pcm_hw_params *hw_params) 376 struct snd_pcm_hw_params *hw_params)
365{ 377{
366 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 378 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
367 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 379 struct s6000_pcm_dma_params *par;
368 int ret; 380 int ret;
369 ret = snd_pcm_lib_malloc_pages(substream, 381 ret = snd_pcm_lib_malloc_pages(substream,
370 params_buffer_bytes(hw_params)); 382 params_buffer_bytes(hw_params));
@@ -373,6 +385,8 @@ static int s6000_pcm_hw_params(struct snd_pcm_substream *substream,
373 return ret; 385 return ret;
374 } 386 }
375 387
388 par = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
389
376 if (par->same_rate) { 390 if (par->same_rate) {
377 spin_lock(&par->lock); 391 spin_lock(&par->lock);
378 if (par->rate == -1 || 392 if (par->rate == -1 ||
@@ -392,7 +406,8 @@ static int s6000_pcm_hw_params(struct snd_pcm_substream *substream,
392static int s6000_pcm_hw_free(struct snd_pcm_substream *substream) 406static int s6000_pcm_hw_free(struct snd_pcm_substream *substream)
393{ 407{
394 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; 408 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
395 struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; 409 struct s6000_pcm_dma_params *par =
410 snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
396 411
397 spin_lock(&par->lock); 412 spin_lock(&par->lock);
398 par->in_use &= ~(1 << substream->stream); 413 par->in_use &= ~(1 << substream->stream);
@@ -417,7 +432,8 @@ static struct snd_pcm_ops s6000_pcm_ops = {
417static void s6000_pcm_free(struct snd_pcm *pcm) 432static void s6000_pcm_free(struct snd_pcm *pcm)
418{ 433{
419 struct snd_soc_pcm_runtime *runtime = pcm->private_data; 434 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
420 struct s6000_pcm_dma_params *params = runtime->dai->cpu_dai->dma_data; 435 struct s6000_pcm_dma_params *params =
436 snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
421 437
422 free_irq(params->irq, pcm); 438 free_irq(params->irq, pcm);
423 snd_pcm_lib_preallocate_free_for_all(pcm); 439 snd_pcm_lib_preallocate_free_for_all(pcm);
@@ -429,9 +445,11 @@ static int s6000_pcm_new(struct snd_card *card,
429 struct snd_soc_dai *dai, struct snd_pcm *pcm) 445 struct snd_soc_dai *dai, struct snd_pcm *pcm)
430{ 446{
431 struct snd_soc_pcm_runtime *runtime = pcm->private_data; 447 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
432 struct s6000_pcm_dma_params *params = runtime->dai->cpu_dai->dma_data; 448 struct s6000_pcm_dma_params *params;
433 int res; 449 int res;
434 450
451 params = snd_soc_dai_get_dma_data(soc_runtime->dai->cpu_dai, substream);
452
435 if (!card->dev->dma_mask) 453 if (!card->dev->dma_mask)
436 card->dev->dma_mask = &s6000_pcm_dmamask; 454 card->dev->dma_mask = &s6000_pcm_dmamask;
437 if (!card->dev->coherent_dma_mask) 455 if (!card->dev->coherent_dma_mask)
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig
index 106674979b53..f07f6d8b93e1 100644
--- a/sound/soc/sh/Kconfig
+++ b/sound/soc/sh/Kconfig
@@ -32,6 +32,7 @@ config SND_SOC_SH4_SIU
32 select DMA_ENGINE 32 select DMA_ENGINE
33 select DMADEVICES 33 select DMADEVICES
34 select SH_DMAE 34 select SH_DMAE
35 select FW_LOADER
35 36
36## 37##
37## Boards 38## Boards
diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c
index baddb1242c71..0d8bdf07729c 100644
--- a/sound/soc/sh/dma-sh7760.c
+++ b/sound/soc/sh/dma-sh7760.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/gfp.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 993abb730dfa..8dc966f45c36 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -19,6 +19,7 @@
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/pm_runtime.h> 20#include <linux/pm_runtime.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/initval.h> 25#include <sound/initval.h>
diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h
index 9cc04ab2bce7..c0bfab8fed3d 100644
--- a/sound/soc/sh/siu.h
+++ b/sound/soc/sh/siu.h
@@ -72,7 +72,7 @@ struct siu_firmware {
72#include <linux/interrupt.h> 72#include <linux/interrupt.h>
73#include <linux/io.h> 73#include <linux/io.h>
74 74
75#include <asm/dma-sh.h> 75#include <asm/dmaengine.h>
76 76
77#include <sound/core.h> 77#include <sound/core.h>
78#include <sound/pcm.h> 78#include <sound/pcm.h>
diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c
index 5452d19607e1..d86ee1bfc03a 100644
--- a/sound/soc/sh/siu_dai.c
+++ b/sound/soc/sh/siu_dai.c
@@ -22,6 +22,7 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/firmware.h> 23#include <linux/firmware.h>
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/slab.h>
25 26
26#include <asm/clock.h> 27#include <asm/clock.h>
27#include <asm/siu.h> 28#include <asm/siu.h>
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c
index c5efc30f0136..8f85719212f9 100644
--- a/sound/soc/sh/siu_pcm.c
+++ b/sound/soc/sh/siu_pcm.c
@@ -24,7 +24,6 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/slab.h>
28 27
29#include <sound/control.h> 28#include <sound/control.h>
30#include <sound/core.h> 29#include <sound/core.h>
@@ -32,7 +31,7 @@
32#include <sound/pcm_params.h> 31#include <sound/pcm_params.h>
33#include <sound/soc-dai.h> 32#include <sound/soc-dai.h>
34 33
35#include <asm/dma-sh.h> 34#include <asm/dmaengine.h>
36#include <asm/siu.h> 35#include <asm/siu.h>
37 36
38#include "siu.h" 37#include "siu.h"
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a03bac943aaf..ad7f9528d751 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -28,6 +28,7 @@
28#include <linux/bitops.h> 28#include <linux/bitops.h>
29#include <linux/debugfs.h> 29#include <linux/debugfs.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/slab.h>
31#include <sound/ac97_codec.h> 32#include <sound/ac97_codec.h>
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/pcm.h> 34#include <sound/pcm.h>
@@ -427,24 +428,24 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
427 if (!runtime->hw.rates) { 428 if (!runtime->hw.rates) {
428 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", 429 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
429 codec_dai->name, cpu_dai->name); 430 codec_dai->name, cpu_dai->name);
430 goto machine_err; 431 goto config_err;
431 } 432 }
432 if (!runtime->hw.formats) { 433 if (!runtime->hw.formats) {
433 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", 434 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
434 codec_dai->name, cpu_dai->name); 435 codec_dai->name, cpu_dai->name);
435 goto machine_err; 436 goto config_err;
436 } 437 }
437 if (!runtime->hw.channels_min || !runtime->hw.channels_max) { 438 if (!runtime->hw.channels_min || !runtime->hw.channels_max) {
438 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", 439 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
439 codec_dai->name, cpu_dai->name); 440 codec_dai->name, cpu_dai->name);
440 goto machine_err; 441 goto config_err;
441 } 442 }
442 443
443 /* Symmetry only applies if we've already got an active stream. */ 444 /* Symmetry only applies if we've already got an active stream. */
444 if (cpu_dai->active || codec_dai->active) { 445 if (cpu_dai->active || codec_dai->active) {
445 ret = soc_pcm_apply_symmetry(substream); 446 ret = soc_pcm_apply_symmetry(substream);
446 if (ret != 0) 447 if (ret != 0)
447 goto machine_err; 448 goto config_err;
448 } 449 }
449 450
450 pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); 451 pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name);
@@ -464,10 +465,14 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
464 mutex_unlock(&pcm_mutex); 465 mutex_unlock(&pcm_mutex);
465 return 0; 466 return 0;
466 467
467machine_err: 468config_err:
468 if (machine->ops && machine->ops->shutdown) 469 if (machine->ops && machine->ops->shutdown)
469 machine->ops->shutdown(substream); 470 machine->ops->shutdown(substream);
470 471
472machine_err:
473 if (codec_dai->ops->shutdown)
474 codec_dai->ops->shutdown(substream, codec_dai);
475
471codec_dai_err: 476codec_dai_err:
472 if (platform->pcm_ops->close) 477 if (platform->pcm_ops->close)
473 platform->pcm_ops->close(substream); 478 platform->pcm_ops->close(substream);
@@ -1544,7 +1549,8 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
1544 mutex_unlock(&codec->mutex); 1549 mutex_unlock(&codec->mutex);
1545 return ret; 1550 return ret;
1546 } 1551 }
1547 if (card->dai_link[i].codec_dai->ac97_control) { 1552 /* Check for codec->ac97 to handle the ac97.c fun */
1553 if (card->dai_link[i].codec_dai->ac97_control && codec->ac97) {
1548 snd_ac97_dev_add_pdata(codec->ac97, 1554 snd_ac97_dev_add_pdata(codec->ac97,
1549 card->dai_link[i].cpu_dai->ac97_pdata); 1555 card->dai_link[i].cpu_dai->ac97_pdata);
1550 } 1556 }
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 6c3351095786..7c28f401f436 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -38,6 +38,7 @@
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/jiffies.h> 39#include <linux/jiffies.h>
40#include <linux/debugfs.h> 40#include <linux/debugfs.h>
41#include <linux/slab.h>
41#include <sound/core.h> 42#include <sound/core.h>
42#include <sound/pcm.h> 43#include <sound/pcm.h>
43#include <sound/pcm_params.h> 44#include <sound/pcm_params.h>
diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c
index 0f83bdb9b16f..612e18b4bf4e 100644
--- a/sound/soc/txx9/txx9aclc-ac97.c
+++ b/sound/soc/txx9/txx9aclc-ac97.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/gfp.h>
19#include <sound/core.h> 20#include <sound/core.h>
20#include <sound/pcm.h> 21#include <sound/pcm.h>
21#include <sound/soc.h> 22#include <sound/soc.h>
diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c
index efed64b8b026..49cc7ea9a518 100644
--- a/sound/soc/txx9/txx9aclc.c
+++ b/sound/soc/txx9/txx9aclc.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/scatterlist.h> 17#include <linux/scatterlist.h>
18#include <linux/slab.h>
18#include <sound/core.h> 19#include <sound/core.h>
19#include <sound/pcm.h> 20#include <sound/pcm.h>
20#include <sound/pcm_params.h> 21#include <sound/pcm_params.h>