aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:53:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:53:38 -0400
commit81d91acf8c093565f65383ae0349b9255fbb2d0d (patch)
tree4e72f779a88ab87b76afb3fb16adf053e7044071 /sound
parent132ea5e9aa9ce13f62ba45db8e43ec887d1106e9 (diff)
parent0dd7b0cbb2e426553f184f5aeba40a2203f33700 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (36 commits) ALSA: hda - Add VREF powerdown sequence for another board ALSA: oss - volume control for CSWITCH and CROUTE ALSA: hda - add missing comma in ad1884_slave_vols sound: usb-audio: allow period sizes less than 1 ms sound: usb-audio: save data packet interval in audioformat structure sound: usb-audio: remove check_hw_params_convention() sound: usb-audio: show sample format width in proc file ASoC: fsl_dma: Pass the proper device for dma mapping routines ASoC: Fix null dereference in ak4535_remove() ALSA: hda - enable SPDIF output for Intel DX58SO board ALSA: snd-atmel-abdac: increase periods_min to 6 instead of 4 ALSA: snd-atmel-abdac: replace bus_id with dev_name() ALSA: snd-atmel-ac97c: replace bus_id with dev_name() ALSA: snd-atmel-ac97c: cleanup registers when removing driver ALSA: snd-atmel-ac97c: do a proper reset of the external codec ALSA: snd-atmel-ac97c: enable interrupts to catch events for error reporting ALSA: snd-atmel-ac97c: set correct size for buffer hardware parameter ALSA: snd-atmel-ac97c: do not overwrite OCA and ICA when assigning channels ALSA: snd-atmel-ac97c: remove dead break statements after return in switch case ALSA: snd-atmel-ac97c: cleanup register definitions ...
Diffstat (limited to 'sound')
-rw-r--r--sound/arm/pxa2xx-ac97-lib.c15
-rw-r--r--sound/atmel/abdac.c4
-rw-r--r--sound/atmel/ac97c.c128
-rw-r--r--sound/atmel/ac97c.h14
-rw-r--r--sound/core/oss/mixer_oss.c8
-rw-r--r--sound/isa/opl3sa2.c1
-rw-r--r--sound/pci/hda/patch_analog.c2
-rw-r--r--sound/pci/hda/patch_realtek.c5
-rw-r--r--sound/pci/hda/patch_sigmatel.c20
-rw-r--r--sound/ppc/powermac.c2
-rw-r--r--sound/soc/codecs/ak4535.c3
-rw-r--r--sound/soc/codecs/twl4030.c59
-rw-r--r--sound/soc/codecs/twl4030.h1
-rw-r--r--sound/soc/codecs/wm9705.c37
-rw-r--r--sound/soc/fsl/fsl_dma.c29
-rw-r--r--sound/soc/fsl/fsl_ssi.c99
-rw-r--r--sound/soc/omap/omap-mcbsp.c11
-rw-r--r--sound/soc/pxa/Kconfig10
-rw-r--r--sound/soc/pxa/Makefile2
-rw-r--r--sound/soc/pxa/magician.c560
-rw-r--r--sound/soc/pxa/pxa-ssp.c12
-rw-r--r--sound/soc/soc-core.c20
-rw-r--r--sound/usb/usbaudio.c255
23 files changed, 1062 insertions, 235 deletions
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
index 7793d2a511ce..0afd1a8226fb 100644
--- a/sound/arm/pxa2xx-ac97-lib.c
+++ b/sound/arm/pxa2xx-ac97-lib.c
@@ -238,6 +238,8 @@ static inline void pxa_ac97_cold_pxa3xx(void)
238 238
239bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) 239bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
240{ 240{
241 unsigned long gsr;
242
241#ifdef CONFIG_PXA25x 243#ifdef CONFIG_PXA25x
242 if (cpu_is_pxa25x()) 244 if (cpu_is_pxa25x())
243 pxa_ac97_warm_pxa25x(); 245 pxa_ac97_warm_pxa25x();
@@ -254,10 +256,10 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
254 else 256 else
255#endif 257#endif
256 BUG(); 258 BUG();
257 259 gsr = GSR | gsr_bits;
258 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) { 260 if (!(gsr & (GSR_PCR | GSR_SCR))) {
259 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", 261 printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
260 __func__, gsr_bits); 262 __func__, gsr);
261 263
262 return false; 264 return false;
263 } 265 }
@@ -268,6 +270,8 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset);
268 270
269bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) 271bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
270{ 272{
273 unsigned long gsr;
274
271#ifdef CONFIG_PXA25x 275#ifdef CONFIG_PXA25x
272 if (cpu_is_pxa25x()) 276 if (cpu_is_pxa25x())
273 pxa_ac97_cold_pxa25x(); 277 pxa_ac97_cold_pxa25x();
@@ -285,9 +289,10 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
285#endif 289#endif
286 BUG(); 290 BUG();
287 291
288 if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR))) { 292 gsr = GSR | gsr_bits;
293 if (!(gsr & (GSR_PCR | GSR_SCR))) {
289 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", 294 printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
290 __func__, gsr_bits); 295 __func__, gsr);
291 296
292 return false; 297 return false;
293 } 298 }
diff --git a/sound/atmel/abdac.c b/sound/atmel/abdac.c
index 28b3c7f7cfe6..f2f41c854221 100644
--- a/sound/atmel/abdac.c
+++ b/sound/atmel/abdac.c
@@ -165,7 +165,7 @@ static struct snd_pcm_hardware atmel_abdac_hw = {
165 .buffer_bytes_max = 64 * 4096, 165 .buffer_bytes_max = 64 * 4096,
166 .period_bytes_min = 4096, 166 .period_bytes_min = 4096,
167 .period_bytes_max = 4096, 167 .period_bytes_max = 4096,
168 .periods_min = 4, 168 .periods_min = 6,
169 .periods_max = 64, 169 .periods_max = 64,
170}; 170};
171 171
@@ -502,7 +502,7 @@ static int __devinit atmel_abdac_probe(struct platform_device *pdev)
502 platform_set_drvdata(pdev, card); 502 platform_set_drvdata(pdev, card);
503 503
504 dev_info(&pdev->dev, "Atmel ABDAC at 0x%p using %s\n", 504 dev_info(&pdev->dev, "Atmel ABDAC at 0x%p using %s\n",
505 dac->regs, dac->dma.chan->dev->device.bus_id); 505 dac->regs, dev_name(&dac->dma.chan->dev->device));
506 506
507 return retval; 507 return retval;
508 508
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index dd72e00e5ae1..0c0f8771656a 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Driver for the Atmel AC97C controller 2 * Driver for Atmel AC97C
3 * 3 *
4 * Copyright (C) 2005-2009 Atmel Corporation 4 * Copyright (C) 2005-2009 Atmel Corporation
5 * 5 *
@@ -10,6 +10,7 @@
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/bitmap.h> 12#include <linux/bitmap.h>
13#include <linux/device.h>
13#include <linux/dmaengine.h> 14#include <linux/dmaengine.h>
14#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
15#include <linux/init.h> 16#include <linux/init.h>
@@ -65,6 +66,7 @@ struct atmel_ac97c {
65 /* Serialize access to opened variable */ 66 /* Serialize access to opened variable */
66 spinlock_t lock; 67 spinlock_t lock;
67 void __iomem *regs; 68 void __iomem *regs;
69 int irq;
68 int opened; 70 int opened;
69 int reset_pin; 71 int reset_pin;
70}; 72};
@@ -150,10 +152,10 @@ static struct snd_pcm_hardware atmel_ac97c_hw = {
150 .rate_max = 48000, 152 .rate_max = 48000,
151 .channels_min = 1, 153 .channels_min = 1,
152 .channels_max = 2, 154 .channels_max = 2,
153 .buffer_bytes_max = 64 * 4096, 155 .buffer_bytes_max = 2 * 2 * 64 * 2048,
154 .period_bytes_min = 4096, 156 .period_bytes_min = 4096,
155 .period_bytes_max = 4096, 157 .period_bytes_max = 4096,
156 .periods_min = 4, 158 .periods_min = 6,
157 .periods_max = 64, 159 .periods_max = 64,
158}; 160};
159 161
@@ -297,9 +299,11 @@ static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream)
297{ 299{
298 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 300 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
299 struct snd_pcm_runtime *runtime = substream->runtime; 301 struct snd_pcm_runtime *runtime = substream->runtime;
300 unsigned long word = 0; 302 unsigned long word = ac97c_readl(chip, OCA);
301 int retval; 303 int retval;
302 304
305 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
306
303 /* assign channels to AC97C channel A */ 307 /* assign channels to AC97C channel A */
304 switch (runtime->channels) { 308 switch (runtime->channels) {
305 case 1: 309 case 1:
@@ -312,7 +316,6 @@ static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream)
312 default: 316 default:
313 /* TODO: support more than two channels */ 317 /* TODO: support more than two channels */
314 return -EINVAL; 318 return -EINVAL;
315 break;
316 } 319 }
317 ac97c_writel(chip, OCA, word); 320 ac97c_writel(chip, OCA, word);
318 321
@@ -324,13 +327,25 @@ static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream)
324 word |= AC97C_CMR_CEM_LITTLE; 327 word |= AC97C_CMR_CEM_LITTLE;
325 break; 328 break;
326 case SNDRV_PCM_FORMAT_S16_BE: /* fall through */ 329 case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
327 default:
328 word &= ~(AC97C_CMR_CEM_LITTLE); 330 word &= ~(AC97C_CMR_CEM_LITTLE);
329 break; 331 break;
332 default:
333 word = ac97c_readl(chip, OCA);
334 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
335 ac97c_writel(chip, OCA, word);
336 return -EINVAL;
330 } 337 }
331 338
339 /* Enable underrun interrupt on channel A */
340 word |= AC97C_CSR_UNRUN;
341
332 ac97c_writel(chip, CAMR, word); 342 ac97c_writel(chip, CAMR, word);
333 343
344 /* Enable channel A event interrupt */
345 word = ac97c_readl(chip, IMR);
346 word |= AC97C_SR_CAEVT;
347 ac97c_writel(chip, IER, word);
348
334 /* set variable rate if needed */ 349 /* set variable rate if needed */
335 if (runtime->rate != 48000) { 350 if (runtime->rate != 48000) {
336 word = ac97c_readl(chip, MR); 351 word = ac97c_readl(chip, MR);
@@ -359,9 +374,11 @@ static int atmel_ac97c_capture_prepare(struct snd_pcm_substream *substream)
359{ 374{
360 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 375 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
361 struct snd_pcm_runtime *runtime = substream->runtime; 376 struct snd_pcm_runtime *runtime = substream->runtime;
362 unsigned long word = 0; 377 unsigned long word = ac97c_readl(chip, ICA);
363 int retval; 378 int retval;
364 379
380 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
381
365 /* assign channels to AC97C channel A */ 382 /* assign channels to AC97C channel A */
366 switch (runtime->channels) { 383 switch (runtime->channels) {
367 case 1: 384 case 1:
@@ -374,7 +391,6 @@ static int atmel_ac97c_capture_prepare(struct snd_pcm_substream *substream)
374 default: 391 default:
375 /* TODO: support more than two channels */ 392 /* TODO: support more than two channels */
376 return -EINVAL; 393 return -EINVAL;
377 break;
378 } 394 }
379 ac97c_writel(chip, ICA, word); 395 ac97c_writel(chip, ICA, word);
380 396
@@ -386,13 +402,25 @@ static int atmel_ac97c_capture_prepare(struct snd_pcm_substream *substream)
386 word |= AC97C_CMR_CEM_LITTLE; 402 word |= AC97C_CMR_CEM_LITTLE;
387 break; 403 break;
388 case SNDRV_PCM_FORMAT_S16_BE: /* fall through */ 404 case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
389 default:
390 word &= ~(AC97C_CMR_CEM_LITTLE); 405 word &= ~(AC97C_CMR_CEM_LITTLE);
391 break; 406 break;
407 default:
408 word = ac97c_readl(chip, ICA);
409 word &= ~(AC97C_CH_MASK(PCM_LEFT) | AC97C_CH_MASK(PCM_RIGHT));
410 ac97c_writel(chip, ICA, word);
411 return -EINVAL;
392 } 412 }
393 413
414 /* Enable overrun interrupt on channel A */
415 word |= AC97C_CSR_OVRUN;
416
394 ac97c_writel(chip, CAMR, word); 417 ac97c_writel(chip, CAMR, word);
395 418
419 /* Enable channel A event interrupt */
420 word = ac97c_readl(chip, IMR);
421 word |= AC97C_SR_CAEVT;
422 ac97c_writel(chip, IER, word);
423
396 /* set variable rate if needed */ 424 /* set variable rate if needed */
397 if (runtime->rate != 48000) { 425 if (runtime->rate != 48000) {
398 word = ac97c_readl(chip, MR); 426 word = ac97c_readl(chip, MR);
@@ -543,6 +571,43 @@ static struct snd_pcm_ops atmel_ac97_capture_ops = {
543 .pointer = atmel_ac97c_capture_pointer, 571 .pointer = atmel_ac97c_capture_pointer,
544}; 572};
545 573
574static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev)
575{
576 struct atmel_ac97c *chip = (struct atmel_ac97c *)dev;
577 irqreturn_t retval = IRQ_NONE;
578 u32 sr = ac97c_readl(chip, SR);
579 u32 casr = ac97c_readl(chip, CASR);
580 u32 cosr = ac97c_readl(chip, COSR);
581
582 if (sr & AC97C_SR_CAEVT) {
583 dev_info(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n",
584 casr & AC97C_CSR_OVRUN ? " OVRUN" : "",
585 casr & AC97C_CSR_RXRDY ? " RXRDY" : "",
586 casr & AC97C_CSR_UNRUN ? " UNRUN" : "",
587 casr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
588 casr & AC97C_CSR_TXRDY ? " TXRDY" : "",
589 !casr ? " NONE" : "");
590 retval = IRQ_HANDLED;
591 }
592
593 if (sr & AC97C_SR_COEVT) {
594 dev_info(&chip->pdev->dev, "codec channel event%s%s%s%s%s\n",
595 cosr & AC97C_CSR_OVRUN ? " OVRUN" : "",
596 cosr & AC97C_CSR_RXRDY ? " RXRDY" : "",
597 cosr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
598 cosr & AC97C_CSR_TXRDY ? " TXRDY" : "",
599 !cosr ? " NONE" : "");
600 retval = IRQ_HANDLED;
601 }
602
603 if (retval == IRQ_NONE) {
604 dev_err(&chip->pdev->dev, "spurious interrupt sr 0x%08x "
605 "casr 0x%08x cosr 0x%08x\n", sr, casr, cosr);
606 }
607
608 return retval;
609}
610
546static int __devinit atmel_ac97c_pcm_new(struct atmel_ac97c *chip) 611static int __devinit atmel_ac97c_pcm_new(struct atmel_ac97c *chip)
547{ 612{
548 struct snd_pcm *pcm; 613 struct snd_pcm *pcm;
@@ -665,17 +730,17 @@ static bool filter(struct dma_chan *chan, void *slave)
665 730
666static void atmel_ac97c_reset(struct atmel_ac97c *chip) 731static void atmel_ac97c_reset(struct atmel_ac97c *chip)
667{ 732{
668 ac97c_writel(chip, MR, AC97C_MR_WRST); 733 ac97c_writel(chip, MR, 0);
734 ac97c_writel(chip, MR, AC97C_MR_ENA);
735 ac97c_writel(chip, CAMR, 0);
736 ac97c_writel(chip, COMR, 0);
669 737
670 if (gpio_is_valid(chip->reset_pin)) { 738 if (gpio_is_valid(chip->reset_pin)) {
671 gpio_set_value(chip->reset_pin, 0); 739 gpio_set_value(chip->reset_pin, 0);
672 /* AC97 v2.2 specifications says minimum 1 us. */ 740 /* AC97 v2.2 specifications says minimum 1 us. */
673 udelay(10); 741 udelay(2);
674 gpio_set_value(chip->reset_pin, 1); 742 gpio_set_value(chip->reset_pin, 1);
675 } 743 }
676
677 udelay(1);
678 ac97c_writel(chip, MR, AC97C_MR_ENA);
679} 744}
680 745
681static int __devinit atmel_ac97c_probe(struct platform_device *pdev) 746static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
@@ -690,6 +755,7 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
690 .read = atmel_ac97c_read, 755 .read = atmel_ac97c_read,
691 }; 756 };
692 int retval; 757 int retval;
758 int irq;
693 759
694 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 760 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
695 if (!regs) { 761 if (!regs) {
@@ -703,6 +769,12 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
703 return -ENXIO; 769 return -ENXIO;
704 } 770 }
705 771
772 irq = platform_get_irq(pdev, 0);
773 if (irq < 0) {
774 dev_dbg(&pdev->dev, "could not get irq\n");
775 return -ENXIO;
776 }
777
706 pclk = clk_get(&pdev->dev, "pclk"); 778 pclk = clk_get(&pdev->dev, "pclk");
707 if (IS_ERR(pclk)) { 779 if (IS_ERR(pclk)) {
708 dev_dbg(&pdev->dev, "no peripheral clock\n"); 780 dev_dbg(&pdev->dev, "no peripheral clock\n");
@@ -719,6 +791,13 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
719 791
720 chip = get_chip(card); 792 chip = get_chip(card);
721 793
794 retval = request_irq(irq, atmel_ac97c_interrupt, 0, "AC97C", chip);
795 if (retval) {
796 dev_dbg(&pdev->dev, "unable to request irq %d\n", irq);
797 goto err_request_irq;
798 }
799 chip->irq = irq;
800
722 spin_lock_init(&chip->lock); 801 spin_lock_init(&chip->lock);
723 802
724 strcpy(card->driver, "Atmel AC97C"); 803 strcpy(card->driver, "Atmel AC97C");
@@ -747,14 +826,18 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
747 826
748 snd_card_set_dev(card, &pdev->dev); 827 snd_card_set_dev(card, &pdev->dev);
749 828
829 atmel_ac97c_reset(chip);
830
831 /* Enable overrun interrupt from codec channel */
832 ac97c_writel(chip, COMR, AC97C_CSR_OVRUN);
833 ac97c_writel(chip, IER, ac97c_readl(chip, IMR) | AC97C_SR_COEVT);
834
750 retval = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus); 835 retval = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus);
751 if (retval) { 836 if (retval) {
752 dev_dbg(&pdev->dev, "could not register on ac97 bus\n"); 837 dev_dbg(&pdev->dev, "could not register on ac97 bus\n");
753 goto err_ac97_bus; 838 goto err_ac97_bus;
754 } 839 }
755 840
756 atmel_ac97c_reset(chip);
757
758 retval = atmel_ac97c_mixer_new(chip); 841 retval = atmel_ac97c_mixer_new(chip);
759 if (retval) { 842 if (retval) {
760 dev_dbg(&pdev->dev, "could not register ac97 mixer\n"); 843 dev_dbg(&pdev->dev, "could not register ac97 mixer\n");
@@ -773,7 +856,7 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
773 chip->dma.rx_chan = dma_request_channel(mask, filter, dws); 856 chip->dma.rx_chan = dma_request_channel(mask, filter, dws);
774 857
775 dev_info(&chip->pdev->dev, "using %s for DMA RX\n", 858 dev_info(&chip->pdev->dev, "using %s for DMA RX\n",
776 chip->dma.rx_chan->dev->device.bus_id); 859 dev_name(&chip->dma.rx_chan->dev->device));
777 set_bit(DMA_RX_CHAN_PRESENT, &chip->flags); 860 set_bit(DMA_RX_CHAN_PRESENT, &chip->flags);
778 } 861 }
779 862
@@ -789,7 +872,7 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
789 chip->dma.tx_chan = dma_request_channel(mask, filter, dws); 872 chip->dma.tx_chan = dma_request_channel(mask, filter, dws);
790 873
791 dev_info(&chip->pdev->dev, "using %s for DMA TX\n", 874 dev_info(&chip->pdev->dev, "using %s for DMA TX\n",
792 chip->dma.tx_chan->dev->device.bus_id); 875 dev_name(&chip->dma.tx_chan->dev->device));
793 set_bit(DMA_TX_CHAN_PRESENT, &chip->flags); 876 set_bit(DMA_TX_CHAN_PRESENT, &chip->flags);
794 } 877 }
795 878
@@ -809,7 +892,7 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
809 retval = snd_card_register(card); 892 retval = snd_card_register(card);
810 if (retval) { 893 if (retval) {
811 dev_dbg(&pdev->dev, "could not register sound card\n"); 894 dev_dbg(&pdev->dev, "could not register sound card\n");
812 goto err_ac97_bus; 895 goto err_dma;
813 } 896 }
814 897
815 platform_set_drvdata(pdev, card); 898 platform_set_drvdata(pdev, card);
@@ -836,6 +919,8 @@ err_ac97_bus:
836 919
837 iounmap(chip->regs); 920 iounmap(chip->regs);
838err_ioremap: 921err_ioremap:
922 free_irq(irq, chip);
923err_request_irq:
839 snd_card_free(card); 924 snd_card_free(card);
840err_snd_card_new: 925err_snd_card_new:
841 clk_disable(pclk); 926 clk_disable(pclk);
@@ -884,9 +969,14 @@ static int __devexit atmel_ac97c_remove(struct platform_device *pdev)
884 if (gpio_is_valid(chip->reset_pin)) 969 if (gpio_is_valid(chip->reset_pin))
885 gpio_free(chip->reset_pin); 970 gpio_free(chip->reset_pin);
886 971
972 ac97c_writel(chip, CAMR, 0);
973 ac97c_writel(chip, COMR, 0);
974 ac97c_writel(chip, MR, 0);
975
887 clk_disable(chip->pclk); 976 clk_disable(chip->pclk);
888 clk_put(chip->pclk); 977 clk_put(chip->pclk);
889 iounmap(chip->regs); 978 iounmap(chip->regs);
979 free_irq(chip->irq, chip);
890 980
891 if (test_bit(DMA_RX_CHAN_PRESENT, &chip->flags)) 981 if (test_bit(DMA_RX_CHAN_PRESENT, &chip->flags))
892 dma_release_channel(chip->dma.rx_chan); 982 dma_release_channel(chip->dma.rx_chan);
diff --git a/sound/atmel/ac97c.h b/sound/atmel/ac97c.h
index c17bd5825980..ecbba5021c80 100644
--- a/sound/atmel/ac97c.h
+++ b/sound/atmel/ac97c.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Register definitions for the Atmel AC97C controller 2 * Register definitions for Atmel AC97C
3 * 3 *
4 * Copyright (C) 2005-2009 Atmel Corporation 4 * Copyright (C) 2005-2009 Atmel Corporation
5 * 5 *
@@ -17,10 +17,6 @@
17#define AC97C_CATHR 0x24 17#define AC97C_CATHR 0x24
18#define AC97C_CASR 0x28 18#define AC97C_CASR 0x28
19#define AC97C_CAMR 0x2c 19#define AC97C_CAMR 0x2c
20#define AC97C_CBRHR 0x30
21#define AC97C_CBTHR 0x34
22#define AC97C_CBSR 0x38
23#define AC97C_CBMR 0x3c
24#define AC97C_CORHR 0x40 20#define AC97C_CORHR 0x40
25#define AC97C_COTHR 0x44 21#define AC97C_COTHR 0x44
26#define AC97C_COSR 0x48 22#define AC97C_COSR 0x48
@@ -46,8 +42,10 @@
46#define AC97C_MR_VRA (1 << 2) 42#define AC97C_MR_VRA (1 << 2)
47 43
48#define AC97C_CSR_TXRDY (1 << 0) 44#define AC97C_CSR_TXRDY (1 << 0)
45#define AC97C_CSR_TXEMPTY (1 << 1)
49#define AC97C_CSR_UNRUN (1 << 2) 46#define AC97C_CSR_UNRUN (1 << 2)
50#define AC97C_CSR_RXRDY (1 << 4) 47#define AC97C_CSR_RXRDY (1 << 4)
48#define AC97C_CSR_OVRUN (1 << 5)
51#define AC97C_CSR_ENDTX (1 << 10) 49#define AC97C_CSR_ENDTX (1 << 10)
52#define AC97C_CSR_ENDRX (1 << 14) 50#define AC97C_CSR_ENDRX (1 << 14)
53 51
@@ -61,11 +59,15 @@
61#define AC97C_CMR_DMAEN (1 << 22) 59#define AC97C_CMR_DMAEN (1 << 22)
62 60
63#define AC97C_SR_CAEVT (1 << 3) 61#define AC97C_SR_CAEVT (1 << 3)
62#define AC97C_SR_COEVT (1 << 2)
63#define AC97C_SR_WKUP (1 << 1)
64#define AC97C_SR_SOF (1 << 0)
64 65
66#define AC97C_CH_MASK(slot) \
67 (0x7 << (3 * (AC97_SLOT_##slot - 3)))
65#define AC97C_CH_ASSIGN(slot, channel) \ 68#define AC97C_CH_ASSIGN(slot, channel) \
66 (AC97C_CHANNEL_##channel << (3 * (AC97_SLOT_##slot - 3))) 69 (AC97C_CHANNEL_##channel << (3 * (AC97_SLOT_##slot - 3)))
67#define AC97C_CHANNEL_NONE 0x0 70#define AC97C_CHANNEL_NONE 0x0
68#define AC97C_CHANNEL_A 0x1 71#define AC97C_CHANNEL_A 0x1
69#define AC97C_CHANNEL_B 0x2
70 72
71#endif /* __SOUND_ATMEL_AC97C_H */ 73#endif /* __SOUND_ATMEL_AC97C_H */
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index e570649184e2..5dcd8a526970 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -703,19 +703,27 @@ static int snd_mixer_oss_put_volume1(struct snd_mixer_oss_file *fmixer,
703 if (left || right) { 703 if (left || right) {
704 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) 704 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH)
705 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0); 705 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
706 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CSWITCH)
707 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], left, right, 0);
706 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) 708 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH)
707 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0); 709 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
708 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) 710 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE)
709 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1); 711 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
712 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CROUTE)
713 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], left, right, 1);
710 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) 714 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE)
711 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1); 715 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
712 } else { 716 } else {
713 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) { 717 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) {
714 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0); 718 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
719 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_CSWITCH) {
720 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], left, right, 0);
715 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) { 721 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) {
716 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0); 722 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
717 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) { 723 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) {
718 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1); 724 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
725 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_CROUTE) {
726 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], left, right, 1);
719 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) { 727 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) {
720 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1); 728 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
721 } 729 }
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index ef95279da7a3..0481a55334b9 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -481,6 +481,7 @@ OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1,
481OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1), 481OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
482OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1, 482OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1,
483 db_scale_5bit_12db_max), 483 db_scale_5bit_12db_max),
484OPL3SA2_SINGLE("ZV Port Switch", 0, 0x02, 0, 1, 0),
484}; 485};
485 486
486static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { 487static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = {
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 5bb48ee8b6c6..38ad3f7b040f 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -3256,7 +3256,7 @@ static const char *ad1884_slave_vols[] = {
3256 "Mic Playback Volume", 3256 "Mic Playback Volume",
3257 "CD Playback Volume", 3257 "CD Playback Volume",
3258 "Internal Mic Playback Volume", 3258 "Internal Mic Playback Volume",
3259 "Docking Mic Playback Volume" 3259 "Docking Mic Playback Volume",
3260 /* "Beep Playback Volume", */ 3260 /* "Beep Playback Volume", */
3261 "IEC958 Playback Volume", 3261 "IEC958 Playback Volume",
3262 NULL 3262 NULL
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 82097790f6f3..f35e58a2d921 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -8764,6 +8764,10 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8764 {} 8764 {}
8765}; 8765};
8766 8766
8767static hda_nid_t alc883_slave_dig_outs[] = {
8768 ALC1200_DIGOUT_NID, 0,
8769};
8770
8767static hda_nid_t alc1200_slave_dig_outs[] = { 8771static hda_nid_t alc1200_slave_dig_outs[] = {
8768 ALC883_DIGOUT_NID, 0, 8772 ALC883_DIGOUT_NID, 0,
8769}; 8773};
@@ -8809,6 +8813,7 @@ static struct alc_config_preset alc883_presets[] = {
8809 .dac_nids = alc883_dac_nids, 8813 .dac_nids = alc883_dac_nids,
8810 .dig_out_nid = ALC883_DIGOUT_NID, 8814 .dig_out_nid = ALC883_DIGOUT_NID,
8811 .dig_in_nid = ALC883_DIGIN_NID, 8815 .dig_in_nid = ALC883_DIGIN_NID,
8816 .slave_dig_outs = alc883_slave_dig_outs,
8812 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), 8817 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8813 .channel_mode = alc883_3ST_6ch_intel_modes, 8818 .channel_mode = alc883_3ST_6ch_intel_modes,
8814 .need_dac_fix = 1, 8819 .need_dac_fix = 1,
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index b5e108aa8f63..61996a2f45df 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -4413,6 +4413,24 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4413 if (spec->num_pwrs > 0) 4413 if (spec->num_pwrs > 0)
4414 stac92xx_pin_sense(codec, event->nid); 4414 stac92xx_pin_sense(codec, event->nid);
4415 stac92xx_report_jack(codec, event->nid); 4415 stac92xx_report_jack(codec, event->nid);
4416
4417 switch (codec->subsystem_id) {
4418 case 0x103c308f:
4419 if (event->nid == 0xb) {
4420 int pin = AC_PINCTL_IN_EN;
4421
4422 if (get_pin_presence(codec, 0xa)
4423 && get_pin_presence(codec, 0xb))
4424 pin |= AC_PINCTL_VREF_80;
4425 if (!get_pin_presence(codec, 0xb))
4426 pin |= AC_PINCTL_VREF_80;
4427
4428 /* toggle VREF state based on mic + hp pin
4429 * status
4430 */
4431 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4432 }
4433 }
4416 break; 4434 break;
4417 case STAC_VREF_EVENT: 4435 case STAC_VREF_EVENT:
4418 data = snd_hda_codec_read(codec, codec->afg, 0, 4436 data = snd_hda_codec_read(codec, codec->afg, 0,
@@ -4895,6 +4913,7 @@ again:
4895 switch (codec->vendor_id) { 4913 switch (codec->vendor_id) {
4896 case 0x111d7604: 4914 case 0x111d7604:
4897 case 0x111d7605: 4915 case 0x111d7605:
4916 case 0x111d76d5:
4898 if (spec->board_config == STAC_92HD83XXX_PWR_REF) 4917 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4899 break; 4918 break;
4900 spec->num_pwrs = 0; 4919 spec->num_pwrs = 0;
@@ -5707,6 +5726,7 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5707 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, 5726 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5708 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, 5727 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5709 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, 5728 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5729 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
5710 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, 5730 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5711 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, 5731 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5712 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, 5732 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index 5a929069dce9..a2b69b8cff43 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -51,7 +51,7 @@ static struct platform_device *device;
51/* 51/*
52 */ 52 */
53 53
54static int __init snd_pmac_probe(struct platform_device *devptr) 54static int __devinit snd_pmac_probe(struct platform_device *devptr)
55{ 55{
56 struct snd_card *card; 56 struct snd_card *card;
57 struct snd_pmac *chip; 57 struct snd_pmac *chip;
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c
index 1f63d387a2f4..dd3380202766 100644
--- a/sound/soc/codecs/ak4535.c
+++ b/sound/soc/codecs/ak4535.c
@@ -659,7 +659,8 @@ static int ak4535_remove(struct platform_device *pdev)
659 snd_soc_free_pcms(socdev); 659 snd_soc_free_pcms(socdev);
660 snd_soc_dapm_free(socdev); 660 snd_soc_dapm_free(socdev);
661#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 661#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
662 i2c_unregister_device(codec->control_data); 662 if (codec->control_data)
663 i2c_unregister_device(codec->control_data);
663 i2c_del_driver(&ak4535_i2c_driver); 664 i2c_del_driver(&ak4535_i2c_driver);
664#endif 665#endif
665 kfree(codec->private_data); 666 kfree(codec->private_data);
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 97738e2ece04..bfda7a88e825 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -122,6 +122,9 @@ struct twl4030_priv {
122 unsigned int bypass_state; 122 unsigned int bypass_state;
123 unsigned int codec_powered; 123 unsigned int codec_powered;
124 unsigned int codec_muted; 124 unsigned int codec_muted;
125
126 struct snd_pcm_substream *master_substream;
127 struct snd_pcm_substream *slave_substream;
125}; 128};
126 129
127/* 130/*
@@ -1217,6 +1220,50 @@ static int twl4030_set_bias_level(struct snd_soc_codec *codec,
1217 return 0; 1220 return 0;
1218} 1221}
1219 1222
1223static int twl4030_startup(struct snd_pcm_substream *substream)
1224{
1225 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1226 struct snd_soc_device *socdev = rtd->socdev;
1227 struct snd_soc_codec *codec = socdev->codec;
1228 struct twl4030_priv *twl4030 = codec->private_data;
1229
1230 /* If we already have a playback or capture going then constrain
1231 * this substream to match it.
1232 */
1233 if (twl4030->master_substream) {
1234 struct snd_pcm_runtime *master_runtime;
1235 master_runtime = twl4030->master_substream->runtime;
1236
1237 snd_pcm_hw_constraint_minmax(substream->runtime,
1238 SNDRV_PCM_HW_PARAM_RATE,
1239 master_runtime->rate,
1240 master_runtime->rate);
1241
1242 snd_pcm_hw_constraint_minmax(substream->runtime,
1243 SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
1244 master_runtime->sample_bits,
1245 master_runtime->sample_bits);
1246
1247 twl4030->slave_substream = substream;
1248 } else
1249 twl4030->master_substream = substream;
1250
1251 return 0;
1252}
1253
1254static void twl4030_shutdown(struct snd_pcm_substream *substream)
1255{
1256 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1257 struct snd_soc_device *socdev = rtd->socdev;
1258 struct snd_soc_codec *codec = socdev->codec;
1259 struct twl4030_priv *twl4030 = codec->private_data;
1260
1261 if (twl4030->master_substream == substream)
1262 twl4030->master_substream = twl4030->slave_substream;
1263
1264 twl4030->slave_substream = NULL;
1265}
1266
1220static int twl4030_hw_params(struct snd_pcm_substream *substream, 1267static int twl4030_hw_params(struct snd_pcm_substream *substream,
1221 struct snd_pcm_hw_params *params, 1268 struct snd_pcm_hw_params *params,
1222 struct snd_soc_dai *dai) 1269 struct snd_soc_dai *dai)
@@ -1224,8 +1271,13 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream,
1224 struct snd_soc_pcm_runtime *rtd = substream->private_data; 1271 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1225 struct snd_soc_device *socdev = rtd->socdev; 1272 struct snd_soc_device *socdev = rtd->socdev;
1226 struct snd_soc_codec *codec = socdev->card->codec; 1273 struct snd_soc_codec *codec = socdev->card->codec;
1274 struct twl4030_priv *twl4030 = codec->private_data;
1227 u8 mode, old_mode, format, old_format; 1275 u8 mode, old_mode, format, old_format;
1228 1276
1277 if (substream == twl4030->slave_substream)
1278 /* Ignoring hw_params for slave substream */
1279 return 0;
1280
1229 /* bit rate */ 1281 /* bit rate */
1230 old_mode = twl4030_read_reg_cache(codec, 1282 old_mode = twl4030_read_reg_cache(codec,
1231 TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; 1283 TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ;
@@ -1259,6 +1311,9 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream,
1259 case 48000: 1311 case 48000:
1260 mode |= TWL4030_APLL_RATE_48000; 1312 mode |= TWL4030_APLL_RATE_48000;
1261 break; 1313 break;
1314 case 96000:
1315 mode |= TWL4030_APLL_RATE_96000;
1316 break;
1262 default: 1317 default:
1263 printk(KERN_ERR "TWL4030 hw params: unknown rate %d\n", 1318 printk(KERN_ERR "TWL4030 hw params: unknown rate %d\n",
1264 params_rate(params)); 1319 params_rate(params));
@@ -1384,6 +1439,8 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai,
1384#define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE) 1439#define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE)
1385 1440
1386static struct snd_soc_dai_ops twl4030_dai_ops = { 1441static struct snd_soc_dai_ops twl4030_dai_ops = {
1442 .startup = twl4030_startup,
1443 .shutdown = twl4030_shutdown,
1387 .hw_params = twl4030_hw_params, 1444 .hw_params = twl4030_hw_params,
1388 .set_sysclk = twl4030_set_dai_sysclk, 1445 .set_sysclk = twl4030_set_dai_sysclk,
1389 .set_fmt = twl4030_set_dai_fmt, 1446 .set_fmt = twl4030_set_dai_fmt,
@@ -1395,7 +1452,7 @@ struct snd_soc_dai twl4030_dai = {
1395 .stream_name = "Playback", 1452 .stream_name = "Playback",
1396 .channels_min = 2, 1453 .channels_min = 2,
1397 .channels_max = 2, 1454 .channels_max = 2,
1398 .rates = TWL4030_RATES, 1455 .rates = TWL4030_RATES | SNDRV_PCM_RATE_96000,
1399 .formats = TWL4030_FORMATS,}, 1456 .formats = TWL4030_FORMATS,},
1400 .capture = { 1457 .capture = {
1401 .stream_name = "Capture", 1458 .stream_name = "Capture",
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h
index 33dbb144dad1..cb63765db1df 100644
--- a/sound/soc/codecs/twl4030.h
+++ b/sound/soc/codecs/twl4030.h
@@ -109,6 +109,7 @@
109#define TWL4030_APLL_RATE_32000 0x80 109#define TWL4030_APLL_RATE_32000 0x80
110#define TWL4030_APLL_RATE_44100 0x90 110#define TWL4030_APLL_RATE_44100 0x90
111#define TWL4030_APLL_RATE_48000 0xA0 111#define TWL4030_APLL_RATE_48000 0xA0
112#define TWL4030_APLL_RATE_96000 0xE0
112#define TWL4030_SEL_16K 0x04 113#define TWL4030_SEL_16K 0x04
113#define TWL4030_CODECPDZ 0x02 114#define TWL4030_CODECPDZ 0x02
114#define TWL4030_OPT_MODE 0x01 115#define TWL4030_OPT_MODE 0x01
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 3265817c5c26..6e23a81dba78 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -317,6 +317,41 @@ static int wm9705_reset(struct snd_soc_codec *codec)
317 return -EIO; 317 return -EIO;
318} 318}
319 319
320#ifdef CONFIG_PM
321static int wm9705_soc_suspend(struct platform_device *pdev)
322{
323 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
324 struct snd_soc_codec *codec = socdev->card->codec;
325
326 soc_ac97_ops.write(codec->ac97, AC97_POWERDOWN, 0xffff);
327
328 return 0;
329}
330
331static int wm9705_soc_resume(struct platform_device *pdev)
332{
333 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
334 struct snd_soc_codec *codec = socdev->card->codec;
335 int i, ret;
336 u16 *cache = codec->reg_cache;
337
338 ret = wm9705_reset(codec);
339 if (ret < 0) {
340 printk(KERN_ERR "could not reset AC97 codec\n");
341 return ret;
342 }
343
344 for (i = 2; i < ARRAY_SIZE(wm9705_reg) << 1; i += 2) {
345 soc_ac97_ops.write(codec->ac97, i, cache[i>>1]);
346 }
347
348 return 0;
349}
350#else
351#define wm9705_soc_suspend NULL
352#define wm9705_soc_resume NULL
353#endif
354
320static int wm9705_soc_probe(struct platform_device *pdev) 355static int wm9705_soc_probe(struct platform_device *pdev)
321{ 356{
322 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 357 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -407,6 +442,8 @@ static int wm9705_soc_remove(struct platform_device *pdev)
407struct snd_soc_codec_device soc_codec_dev_wm9705 = { 442struct snd_soc_codec_device soc_codec_dev_wm9705 = {
408 .probe = wm9705_soc_probe, 443 .probe = wm9705_soc_probe,
409 .remove = wm9705_soc_remove, 444 .remove = wm9705_soc_remove,
445 .suspend = wm9705_soc_suspend,
446 .resume = wm9705_soc_resume,
410}; 447};
411EXPORT_SYMBOL_GPL(soc_codec_dev_wm9705); 448EXPORT_SYMBOL_GPL(soc_codec_dev_wm9705);
412 449
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index b3eb8570cd7b..b1a3a278819f 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -300,7 +300,7 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
300 if (!card->dev->coherent_dma_mask) 300 if (!card->dev->coherent_dma_mask)
301 card->dev->coherent_dma_mask = fsl_dma_dmamask; 301 card->dev->coherent_dma_mask = fsl_dma_dmamask;
302 302
303 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, 303 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
304 fsl_dma_hardware.buffer_bytes_max, 304 fsl_dma_hardware.buffer_bytes_max,
305 &pcm->streams[0].substream->dma_buffer); 305 &pcm->streams[0].substream->dma_buffer);
306 if (ret) { 306 if (ret) {
@@ -310,7 +310,7 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
310 return -ENOMEM; 310 return -ENOMEM;
311 } 311 }
312 312
313 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, 313 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
314 fsl_dma_hardware.buffer_bytes_max, 314 fsl_dma_hardware.buffer_bytes_max,
315 &pcm->streams[1].substream->dma_buffer); 315 &pcm->streams[1].substream->dma_buffer);
316 if (ret) { 316 if (ret) {
@@ -418,7 +418,7 @@ static int fsl_dma_open(struct snd_pcm_substream *substream)
418 return -EBUSY; 418 return -EBUSY;
419 } 419 }
420 420
421 dma_private = dma_alloc_coherent(substream->pcm->dev, 421 dma_private = dma_alloc_coherent(substream->pcm->card->dev,
422 sizeof(struct fsl_dma_private), &ld_buf_phys, GFP_KERNEL); 422 sizeof(struct fsl_dma_private), &ld_buf_phys, GFP_KERNEL);
423 if (!dma_private) { 423 if (!dma_private) {
424 dev_err(substream->pcm->card->dev, 424 dev_err(substream->pcm->card->dev,
@@ -445,7 +445,7 @@ static int fsl_dma_open(struct snd_pcm_substream *substream)
445 dev_err(substream->pcm->card->dev, 445 dev_err(substream->pcm->card->dev,
446 "can't register ISR for IRQ %u (ret=%i)\n", 446 "can't register ISR for IRQ %u (ret=%i)\n",
447 dma_private->irq, ret); 447 dma_private->irq, ret);
448 dma_free_coherent(substream->pcm->dev, 448 dma_free_coherent(substream->pcm->card->dev,
449 sizeof(struct fsl_dma_private), 449 sizeof(struct fsl_dma_private),
450 dma_private, dma_private->ld_buf_phys); 450 dma_private, dma_private->ld_buf_phys);
451 return ret; 451 return ret;
@@ -697,6 +697,23 @@ static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream)
697 else 697 else
698 position = in_be32(&dma_channel->dar); 698 position = in_be32(&dma_channel->dar);
699 699
700 /*
701 * When capture is started, the SSI immediately starts to fill its FIFO.
702 * This means that the DMA controller is not started until the FIFO is
703 * full. However, ALSA calls this function before that happens, when
704 * MR.DAR is still zero. In this case, just return zero to indicate
705 * that nothing has been received yet.
706 */
707 if (!position)
708 return 0;
709
710 if ((position < dma_private->dma_buf_phys) ||
711 (position > dma_private->dma_buf_end)) {
712 dev_err(substream->pcm->card->dev,
713 "dma pointer is out of range, halting stream\n");
714 return SNDRV_PCM_POS_XRUN;
715 }
716
700 frames = bytes_to_frames(runtime, position - dma_private->dma_buf_phys); 717 frames = bytes_to_frames(runtime, position - dma_private->dma_buf_phys);
701 718
702 /* 719 /*
@@ -761,13 +778,13 @@ static int fsl_dma_close(struct snd_pcm_substream *substream)
761 free_irq(dma_private->irq, dma_private); 778 free_irq(dma_private->irq, dma_private);
762 779
763 if (dma_private->ld_buf_phys) { 780 if (dma_private->ld_buf_phys) {
764 dma_unmap_single(substream->pcm->dev, 781 dma_unmap_single(substream->pcm->card->dev,
765 dma_private->ld_buf_phys, 782 dma_private->ld_buf_phys,
766 sizeof(dma_private->link), DMA_TO_DEVICE); 783 sizeof(dma_private->link), DMA_TO_DEVICE);
767 } 784 }
768 785
769 /* Deallocate the fsl_dma_private structure */ 786 /* Deallocate the fsl_dma_private structure */
770 dma_free_coherent(substream->pcm->dev, 787 dma_free_coherent(substream->pcm->card->dev,
771 sizeof(struct fsl_dma_private), 788 sizeof(struct fsl_dma_private),
772 dma_private, dma_private->ld_buf_phys); 789 dma_private, dma_private->ld_buf_phys);
773 substream->runtime->private_data = NULL; 790 substream->runtime->private_data = NULL;
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 169bca295b78..3711d8454d96 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -60,6 +60,13 @@
60 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE) 60 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE)
61#endif 61#endif
62 62
63/* SIER bitflag of interrupts to enable */
64#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \
65 CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \
66 CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \
67 CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \
68 CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)
69
63/** 70/**
64 * fsl_ssi_private: per-SSI private data 71 * fsl_ssi_private: per-SSI private data
65 * 72 *
@@ -140,7 +147,7 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
140 were interrupted for. We mask it with the Interrupt Enable register 147 were interrupted for. We mask it with the Interrupt Enable register
141 so that we only check for events that we're interested in. 148 so that we only check for events that we're interested in.
142 */ 149 */
143 sisr = in_be32(&ssi->sisr) & in_be32(&ssi->sier); 150 sisr = in_be32(&ssi->sisr) & SIER_FLAGS;
144 151
145 if (sisr & CCSR_SSI_SISR_RFRC) { 152 if (sisr & CCSR_SSI_SISR_RFRC) {
146 ssi_private->stats.rfrc++; 153 ssi_private->stats.rfrc++;
@@ -324,12 +331,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
324 */ 331 */
325 332
326 /* 4. Enable the interrupts and DMA requests */ 333 /* 4. Enable the interrupts and DMA requests */
327 out_be32(&ssi->sier, 334 out_be32(&ssi->sier, SIER_FLAGS);
328 CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE |
329 CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN |
330 CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN |
331 CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE |
332 CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN);
333 335
334 /* 336 /*
335 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We 337 * Set the watermark for transmit FIFI 0 and receive FIFO 0. We
@@ -466,28 +468,12 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
466 case SNDRV_PCM_TRIGGER_START: 468 case SNDRV_PCM_TRIGGER_START:
467 clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); 469 clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN);
468 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 470 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
469 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 471 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
470 setbits32(&ssi->scr, 472 setbits32(&ssi->scr,
471 CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); 473 CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE);
472 } else { 474 else
473 long timeout = jiffies + 10;
474
475 setbits32(&ssi->scr, 475 setbits32(&ssi->scr,
476 CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); 476 CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE);
477
478 /* Wait until the SSI has filled its FIFO. Without this
479 * delay, ALSA complains about overruns. When the FIFO
480 * is full, the DMA controller initiates its first
481 * transfer. Until then, however, the DMA's DAR
482 * register is zero, which translates to an
483 * out-of-bounds pointer. This makes ALSA think an
484 * overrun has occurred.
485 */
486 while (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0) &&
487 (jiffies < timeout));
488 if (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0))
489 return -EIO;
490 }
491 break; 477 break;
492 478
493 case SNDRV_PCM_TRIGGER_STOP: 479 case SNDRV_PCM_TRIGGER_STOP:
@@ -606,39 +592,52 @@ static struct snd_soc_dai fsl_ssi_dai_template = {
606 .ops = &fsl_ssi_dai_ops, 592 .ops = &fsl_ssi_dai_ops,
607}; 593};
608 594
595/* Show the statistics of a flag only if its interrupt is enabled. The
596 * compiler will optimze this code to a no-op if the interrupt is not
597 * enabled.
598 */
599#define SIER_SHOW(flag, name) \
600 do { \
601 if (SIER_FLAGS & CCSR_SSI_SIER_##flag) \
602 length += sprintf(buf + length, #name "=%u\n", \
603 ssi_private->stats.name); \
604 } while (0)
605
606
609/** 607/**
610 * fsl_sysfs_ssi_show: display SSI statistics 608 * fsl_sysfs_ssi_show: display SSI statistics
611 * 609 *
612 * Display the statistics for the current SSI device. 610 * Display the statistics for the current SSI device. To avoid confusion,
611 * we only show those counts that are enabled.
613 */ 612 */
614static ssize_t fsl_sysfs_ssi_show(struct device *dev, 613static ssize_t fsl_sysfs_ssi_show(struct device *dev,
615 struct device_attribute *attr, char *buf) 614 struct device_attribute *attr, char *buf)
616{ 615{
617 struct fsl_ssi_private *ssi_private = 616 struct fsl_ssi_private *ssi_private =
618 container_of(attr, struct fsl_ssi_private, dev_attr); 617 container_of(attr, struct fsl_ssi_private, dev_attr);
619 ssize_t length; 618 ssize_t length = 0;
620 619
621 length = sprintf(buf, "rfrc=%u", ssi_private->stats.rfrc); 620 SIER_SHOW(RFRC_EN, rfrc);
622 length += sprintf(buf + length, "\ttfrc=%u", ssi_private->stats.tfrc); 621 SIER_SHOW(TFRC_EN, tfrc);
623 length += sprintf(buf + length, "\tcmdau=%u", ssi_private->stats.cmdau); 622 SIER_SHOW(CMDAU_EN, cmdau);
624 length += sprintf(buf + length, "\tcmddu=%u", ssi_private->stats.cmddu); 623 SIER_SHOW(CMDDU_EN, cmddu);
625 length += sprintf(buf + length, "\trxt=%u", ssi_private->stats.rxt); 624 SIER_SHOW(RXT_EN, rxt);
626 length += sprintf(buf + length, "\trdr1=%u", ssi_private->stats.rdr1); 625 SIER_SHOW(RDR1_EN, rdr1);
627 length += sprintf(buf + length, "\trdr0=%u", ssi_private->stats.rdr0); 626 SIER_SHOW(RDR0_EN, rdr0);
628 length += sprintf(buf + length, "\ttde1=%u", ssi_private->stats.tde1); 627 SIER_SHOW(TDE1_EN, tde1);
629 length += sprintf(buf + length, "\ttde0=%u", ssi_private->stats.tde0); 628 SIER_SHOW(TDE0_EN, tde0);
630 length += sprintf(buf + length, "\troe1=%u", ssi_private->stats.roe1); 629 SIER_SHOW(ROE1_EN, roe1);
631 length += sprintf(buf + length, "\troe0=%u", ssi_private->stats.roe0); 630 SIER_SHOW(ROE0_EN, roe0);
632 length += sprintf(buf + length, "\ttue1=%u", ssi_private->stats.tue1); 631 SIER_SHOW(TUE1_EN, tue1);
633 length += sprintf(buf + length, "\ttue0=%u", ssi_private->stats.tue0); 632 SIER_SHOW(TUE0_EN, tue0);
634 length += sprintf(buf + length, "\ttfs=%u", ssi_private->stats.tfs); 633 SIER_SHOW(TFS_EN, tfs);
635 length += sprintf(buf + length, "\trfs=%u", ssi_private->stats.rfs); 634 SIER_SHOW(RFS_EN, rfs);
636 length += sprintf(buf + length, "\ttls=%u", ssi_private->stats.tls); 635 SIER_SHOW(TLS_EN, tls);
637 length += sprintf(buf + length, "\trls=%u", ssi_private->stats.rls); 636 SIER_SHOW(RLS_EN, rls);
638 length += sprintf(buf + length, "\trff1=%u", ssi_private->stats.rff1); 637 SIER_SHOW(RFF1_EN, rff1);
639 length += sprintf(buf + length, "\trff0=%u", ssi_private->stats.rff0); 638 SIER_SHOW(RFF0_EN, rff0);
640 length += sprintf(buf + length, "\ttfe1=%u", ssi_private->stats.tfe1); 639 SIER_SHOW(TFE1_EN, tfe1);
641 length += sprintf(buf + length, "\ttfe0=%u\n", ssi_private->stats.tfe0); 640 SIER_SHOW(TFE0_EN, tfe0);
642 641
643 return length; 642 return length;
644} 643}
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index d6882be33452..9c09b94f0cf8 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -146,6 +146,17 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
146 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 146 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
147 int err = 0; 147 int err = 0;
148 148
149 if (cpu_is_omap343x() && mcbsp_data->bus_id == 1) {
150 /*
151 * McBSP2 in OMAP3 has 1024 * 32-bit internal audio buffer.
152 * Set constraint for minimum buffer size to the same than FIFO
153 * size in order to avoid underruns in playback startup because
154 * HW is keeping the DMA request active until FIFO is filled.
155 */
156 snd_pcm_hw_constraint_minmax(substream->runtime,
157 SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 4096, UINT_MAX);
158 }
159
149 if (!cpu_dai->active) 160 if (!cpu_dai->active)
150 err = omap_mcbsp_request(mcbsp_data->bus_id); 161 err = omap_mcbsp_request(mcbsp_data->bus_id);
151 162
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 5998ab366e83..ad8a10fe6298 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -116,6 +116,16 @@ config SND_SOC_ZYLONITE
116 Say Y if you want to add support for SoC audio on the 116 Say Y if you want to add support for SoC audio on the
117 Marvell Zylonite reference platform. 117 Marvell Zylonite reference platform.
118 118
119config SND_PXA2XX_SOC_MAGICIAN
120 tristate "SoC Audio support for HTC Magician"
121 depends on SND_PXA2XX_SOC && MACH_MAGICIAN
122 select SND_PXA2XX_SOC_I2S
123 select SND_PXA_SOC_SSP
124 select SND_SOC_UDA1380
125 help
126 Say Y if you want to add support for SoC audio on the
127 HTC Magician.
128
119config SND_PXA2XX_SOC_MIOA701 129config SND_PXA2XX_SOC_MIOA701
120 tristate "SoC Audio support for MIO A701" 130 tristate "SoC Audio support for MIO A701"
121 depends on SND_PXA2XX_SOC && MACH_MIOA701 131 depends on SND_PXA2XX_SOC && MACH_MIOA701
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index 8ed881c5e5cc..4b90c3ccae45 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -20,6 +20,7 @@ snd-soc-spitz-objs := spitz.o
20snd-soc-em-x270-objs := em-x270.o 20snd-soc-em-x270-objs := em-x270.o
21snd-soc-palm27x-objs := palm27x.o 21snd-soc-palm27x-objs := palm27x.o
22snd-soc-zylonite-objs := zylonite.o 22snd-soc-zylonite-objs := zylonite.o
23snd-soc-magician-objs := magician.o
23snd-soc-mioa701-objs := mioa701_wm9713.o 24snd-soc-mioa701-objs := mioa701_wm9713.o
24 25
25obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o 26obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
@@ -31,5 +32,6 @@ obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
31obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o 32obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
32obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o 33obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
33obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o 34obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
35obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
34obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o 36obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
35obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o 37obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c
new file mode 100644
index 000000000000..f7c4544f7859
--- /dev/null
+++ b/sound/soc/pxa/magician.c
@@ -0,0 +1,560 @@
1/*
2 * SoC audio for HTC Magician
3 *
4 * Copyright (c) 2006 Philipp Zabel <philipp.zabel@gmail.com>
5 *
6 * based on spitz.c,
7 * Authors: Liam Girdwood <lrg@slimlogic.co.uk>
8 * Richard Purdie <richard@openedhand.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/module.h>
18#include <linux/timer.h>
19#include <linux/interrupt.h>
20#include <linux/platform_device.h>
21#include <linux/delay.h>
22#include <linux/gpio.h>
23
24#include <sound/core.h>
25#include <sound/pcm.h>
26#include <sound/pcm_params.h>
27#include <sound/soc.h>
28#include <sound/soc-dapm.h>
29
30#include <mach/pxa-regs.h>
31#include <mach/hardware.h>
32#include <mach/magician.h>
33#include <asm/mach-types.h>
34#include "../codecs/uda1380.h"
35#include "pxa2xx-pcm.h"
36#include "pxa2xx-i2s.h"
37#include "pxa-ssp.h"
38
39#define MAGICIAN_MIC 0
40#define MAGICIAN_MIC_EXT 1
41
42static int magician_hp_switch;
43static int magician_spk_switch = 1;
44static int magician_in_sel = MAGICIAN_MIC;
45
46static void magician_ext_control(struct snd_soc_codec *codec)
47{
48 if (magician_spk_switch)
49 snd_soc_dapm_enable_pin(codec, "Speaker");
50 else
51 snd_soc_dapm_disable_pin(codec, "Speaker");
52 if (magician_hp_switch)
53 snd_soc_dapm_enable_pin(codec, "Headphone Jack");
54 else
55 snd_soc_dapm_disable_pin(codec, "Headphone Jack");
56
57 switch (magician_in_sel) {
58 case MAGICIAN_MIC:
59 snd_soc_dapm_disable_pin(codec, "Headset Mic");
60 snd_soc_dapm_enable_pin(codec, "Call Mic");
61 break;
62 case MAGICIAN_MIC_EXT:
63 snd_soc_dapm_disable_pin(codec, "Call Mic");
64 snd_soc_dapm_enable_pin(codec, "Headset Mic");
65 break;
66 }
67
68 snd_soc_dapm_sync(codec);
69}
70
71static int magician_startup(struct snd_pcm_substream *substream)
72{
73 struct snd_soc_pcm_runtime *rtd = substream->private_data;
74 struct snd_soc_codec *codec = rtd->socdev->card->codec;
75
76 /* check the jack status at stream startup */
77 magician_ext_control(codec);
78
79 return 0;
80}
81
82/*
83 * Magician uses SSP port for playback.
84 */
85static int magician_playback_hw_params(struct snd_pcm_substream *substream,
86 struct snd_pcm_hw_params *params)
87{
88 struct snd_soc_pcm_runtime *rtd = substream->private_data;
89 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
90 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
91 unsigned int acps, acds, width, rate;
92 unsigned int div4 = PXA_SSP_CLK_SCDB_4;
93 int ret = 0;
94
95 rate = params_rate(params);
96 width = snd_pcm_format_physical_width(params_format(params));
97
98 /*
99 * rate = SSPSCLK / (2 * width(16 or 32))
100 * SSPSCLK = (ACPS / ACDS) / SSPSCLKDIV(div4 or div1)
101 */
102 switch (params_rate(params)) {
103 case 8000:
104 /* off by a factor of 2: bug in the PXA27x audio clock? */
105 acps = 32842000;
106 switch (width) {
107 case 16:
108 /* 513156 Hz ~= _2_ * 8000 Hz * 32 (+0.23%) */
109 acds = PXA_SSP_CLK_AUDIO_DIV_16;
110 break;
111 case 32:
112 /* 1026312 Hz ~= _2_ * 8000 Hz * 64 (+0.23%) */
113 acds = PXA_SSP_CLK_AUDIO_DIV_8;
114 }
115 break;
116 case 11025:
117 acps = 5622000;
118 switch (width) {
119 case 16:
120 /* 351375 Hz ~= 11025 Hz * 32 (-0.41%) */
121 acds = PXA_SSP_CLK_AUDIO_DIV_4;
122 break;
123 case 32:
124 /* 702750 Hz ~= 11025 Hz * 64 (-0.41%) */
125 acds = PXA_SSP_CLK_AUDIO_DIV_2;
126 }
127 break;
128 case 22050:
129 acps = 5622000;
130 switch (width) {
131 case 16:
132 /* 702750 Hz ~= 22050 Hz * 32 (-0.41%) */
133 acds = PXA_SSP_CLK_AUDIO_DIV_2;
134 break;
135 case 32:
136 /* 1405500 Hz ~= 22050 Hz * 64 (-0.41%) */
137 acds = PXA_SSP_CLK_AUDIO_DIV_1;
138 }
139 break;
140 case 44100:
141 acps = 5622000;
142 switch (width) {
143 case 16:
144 /* 1405500 Hz ~= 44100 Hz * 32 (-0.41%) */
145 acds = PXA_SSP_CLK_AUDIO_DIV_2;
146 break;
147 case 32:
148 /* 2811000 Hz ~= 44100 Hz * 64 (-0.41%) */
149 acds = PXA_SSP_CLK_AUDIO_DIV_1;
150 }
151 break;
152 case 48000:
153 acps = 12235000;
154 switch (width) {
155 case 16:
156 /* 1529375 Hz ~= 48000 Hz * 32 (-0.44%) */
157 acds = PXA_SSP_CLK_AUDIO_DIV_2;
158 break;
159 case 32:
160 /* 3058750 Hz ~= 48000 Hz * 64 (-0.44%) */
161 acds = PXA_SSP_CLK_AUDIO_DIV_1;
162 }
163 break;
164 case 96000:
165 acps = 12235000;
166 switch (width) {
167 case 16:
168 /* 3058750 Hz ~= 96000 Hz * 32 (-0.44%) */
169 acds = PXA_SSP_CLK_AUDIO_DIV_1;
170 break;
171 case 32:
172 /* 6117500 Hz ~= 96000 Hz * 64 (-0.44%) */
173 acds = PXA_SSP_CLK_AUDIO_DIV_2;
174 div4 = PXA_SSP_CLK_SCDB_1;
175 break;
176 }
177 break;
178 }
179
180 /* set codec DAI configuration */
181 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_MSB |
182 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
183 if (ret < 0)
184 return ret;
185
186 /* set cpu DAI configuration */
187 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |
188 SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBS_CFS);
189 if (ret < 0)
190 return ret;
191
192 ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1);
193 if (ret < 0)
194 return ret;
195
196 /* set audio clock as clock source */
197 ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0,
198 SND_SOC_CLOCK_OUT);
199 if (ret < 0)
200 return ret;
201
202 /* set the SSP audio system clock ACDS divider */
203 ret = snd_soc_dai_set_clkdiv(cpu_dai,
204 PXA_SSP_AUDIO_DIV_ACDS, acds);
205 if (ret < 0)
206 return ret;
207
208 /* set the SSP audio system clock SCDB divider4 */
209 ret = snd_soc_dai_set_clkdiv(cpu_dai,
210 PXA_SSP_AUDIO_DIV_SCDB, div4);
211 if (ret < 0)
212 return ret;
213
214 /* set SSP audio pll clock */
215 ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, acps);
216 if (ret < 0)
217 return ret;
218
219 return 0;
220}
221
222/*
223 * Magician uses I2S for capture.
224 */
225static int magician_capture_hw_params(struct snd_pcm_substream *substream,
226 struct snd_pcm_hw_params *params)
227{
228 struct snd_soc_pcm_runtime *rtd = substream->private_data;
229 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
230 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
231 int ret = 0;
232
233 /* set codec DAI configuration */
234 ret = snd_soc_dai_set_fmt(codec_dai,
235 SND_SOC_DAIFMT_MSB | SND_SOC_DAIFMT_NB_NF |
236 SND_SOC_DAIFMT_CBS_CFS);
237 if (ret < 0)
238 return ret;
239
240 /* set cpu DAI configuration */
241 ret = snd_soc_dai_set_fmt(cpu_dai,
242 SND_SOC_DAIFMT_MSB | SND_SOC_DAIFMT_NB_NF |
243 SND_SOC_DAIFMT_CBS_CFS);
244 if (ret < 0)
245 return ret;
246
247 /* set the I2S system clock as output */
248 ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
249 SND_SOC_CLOCK_OUT);
250 if (ret < 0)
251 return ret;
252
253 return 0;
254}
255
256static struct snd_soc_ops magician_capture_ops = {
257 .startup = magician_startup,
258 .hw_params = magician_capture_hw_params,
259};
260
261static struct snd_soc_ops magician_playback_ops = {
262 .startup = magician_startup,
263 .hw_params = magician_playback_hw_params,
264};
265
266static int magician_get_hp(struct snd_kcontrol *kcontrol,
267 struct snd_ctl_elem_value *ucontrol)
268{
269 ucontrol->value.integer.value[0] = magician_hp_switch;
270 return 0;
271}
272
273static int magician_set_hp(struct snd_kcontrol *kcontrol,
274 struct snd_ctl_elem_value *ucontrol)
275{
276 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
277
278 if (magician_hp_switch == ucontrol->value.integer.value[0])
279 return 0;
280
281 magician_hp_switch = ucontrol->value.integer.value[0];
282 magician_ext_control(codec);
283 return 1;
284}
285
286static int magician_get_spk(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_value *ucontrol)
288{
289 ucontrol->value.integer.value[0] = magician_spk_switch;
290 return 0;
291}
292
293static int magician_set_spk(struct snd_kcontrol *kcontrol,
294 struct snd_ctl_elem_value *ucontrol)
295{
296 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
297
298 if (magician_spk_switch == ucontrol->value.integer.value[0])
299 return 0;
300
301 magician_spk_switch = ucontrol->value.integer.value[0];
302 magician_ext_control(codec);
303 return 1;
304}
305
306static int magician_get_input(struct snd_kcontrol *kcontrol,
307 struct snd_ctl_elem_value *ucontrol)
308{
309 ucontrol->value.integer.value[0] = magician_in_sel;
310 return 0;
311}
312
313static int magician_set_input(struct snd_kcontrol *kcontrol,
314 struct snd_ctl_elem_value *ucontrol)
315{
316 if (magician_in_sel == ucontrol->value.integer.value[0])
317 return 0;
318
319 magician_in_sel = ucontrol->value.integer.value[0];
320
321 switch (magician_in_sel) {
322 case MAGICIAN_MIC:
323 gpio_set_value(EGPIO_MAGICIAN_IN_SEL1, 1);
324 break;
325 case MAGICIAN_MIC_EXT:
326 gpio_set_value(EGPIO_MAGICIAN_IN_SEL1, 0);
327 }
328
329 return 1;
330}
331
332static int magician_spk_power(struct snd_soc_dapm_widget *w,
333 struct snd_kcontrol *k, int event)
334{
335 gpio_set_value(EGPIO_MAGICIAN_SPK_POWER, SND_SOC_DAPM_EVENT_ON(event));
336 return 0;
337}
338
339static int magician_hp_power(struct snd_soc_dapm_widget *w,
340 struct snd_kcontrol *k, int event)
341{
342 gpio_set_value(EGPIO_MAGICIAN_EP_POWER, SND_SOC_DAPM_EVENT_ON(event));
343 return 0;
344}
345
346static int magician_mic_bias(struct snd_soc_dapm_widget *w,
347 struct snd_kcontrol *k, int event)
348{
349 gpio_set_value(EGPIO_MAGICIAN_MIC_POWER, SND_SOC_DAPM_EVENT_ON(event));
350 return 0;
351}
352
353/* magician machine dapm widgets */
354static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
355 SND_SOC_DAPM_HP("Headphone Jack", magician_hp_power),
356 SND_SOC_DAPM_SPK("Speaker", magician_spk_power),
357 SND_SOC_DAPM_MIC("Call Mic", magician_mic_bias),
358 SND_SOC_DAPM_MIC("Headset Mic", magician_mic_bias),
359};
360
361/* magician machine audio_map */
362static const struct snd_soc_dapm_route audio_map[] = {
363
364 /* Headphone connected to VOUTL, VOUTR */
365 {"Headphone Jack", NULL, "VOUTL"},
366 {"Headphone Jack", NULL, "VOUTR"},
367
368 /* Speaker connected to VOUTL, VOUTR */
369 {"Speaker", NULL, "VOUTL"},
370 {"Speaker", NULL, "VOUTR"},
371
372 /* Mics are connected to VINM */
373 {"VINM", NULL, "Headset Mic"},
374 {"VINM", NULL, "Call Mic"},
375};
376
377static const char *input_select[] = {"Call Mic", "Headset Mic"};
378static const struct soc_enum magician_in_sel_enum =
379 SOC_ENUM_SINGLE_EXT(2, input_select);
380
381static const struct snd_kcontrol_new uda1380_magician_controls[] = {
382 SOC_SINGLE_BOOL_EXT("Headphone Switch",
383 (unsigned long)&magician_hp_switch,
384 magician_get_hp, magician_set_hp),
385 SOC_SINGLE_BOOL_EXT("Speaker Switch",
386 (unsigned long)&magician_spk_switch,
387 magician_get_spk, magician_set_spk),
388 SOC_ENUM_EXT("Input Select", magician_in_sel_enum,
389 magician_get_input, magician_set_input),
390};
391
392/*
393 * Logic for a uda1380 as connected on a HTC Magician
394 */
395static int magician_uda1380_init(struct snd_soc_codec *codec)
396{
397 int err;
398
399 /* NC codec pins */
400 snd_soc_dapm_nc_pin(codec, "VOUTLHP");
401 snd_soc_dapm_nc_pin(codec, "VOUTRHP");
402
403 /* FIXME: is anything connected here? */
404 snd_soc_dapm_nc_pin(codec, "VINL");
405 snd_soc_dapm_nc_pin(codec, "VINR");
406
407 /* Add magician specific controls */
408 err = snd_soc_add_controls(codec, uda1380_magician_controls,
409 ARRAY_SIZE(uda1380_magician_controls));
410 if (err < 0)
411 return err;
412
413 /* Add magician specific widgets */
414 snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
415 ARRAY_SIZE(uda1380_dapm_widgets));
416
417 /* Set up magician specific audio path interconnects */
418 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
419
420 snd_soc_dapm_sync(codec);
421 return 0;
422}
423
424/* magician digital audio interface glue - connects codec <--> CPU */
425static struct snd_soc_dai_link magician_dai[] = {
426{
427 .name = "uda1380",
428 .stream_name = "UDA1380 Playback",
429 .cpu_dai = &pxa_ssp_dai[PXA_DAI_SSP1],
430 .codec_dai = &uda1380_dai[UDA1380_DAI_PLAYBACK],
431 .init = magician_uda1380_init,
432 .ops = &magician_playback_ops,
433},
434{
435 .name = "uda1380",
436 .stream_name = "UDA1380 Capture",
437 .cpu_dai = &pxa_i2s_dai,
438 .codec_dai = &uda1380_dai[UDA1380_DAI_CAPTURE],
439 .ops = &magician_capture_ops,
440}
441};
442
443/* magician audio machine driver */
444static struct snd_soc_card snd_soc_card_magician = {
445 .name = "Magician",
446 .dai_link = magician_dai,
447 .num_links = ARRAY_SIZE(magician_dai),
448 .platform = &pxa2xx_soc_platform,
449};
450
451/* magician audio private data */
452static struct uda1380_setup_data magician_uda1380_setup = {
453 .i2c_address = 0x18,
454 .dac_clk = UDA1380_DAC_CLK_WSPLL,
455};
456
457/* magician audio subsystem */
458static struct snd_soc_device magician_snd_devdata = {
459 .card = &snd_soc_card_magician,
460 .codec_dev = &soc_codec_dev_uda1380,
461 .codec_data = &magician_uda1380_setup,
462};
463
464static struct platform_device *magician_snd_device;
465
466static int __init magician_init(void)
467{
468 int ret;
469
470 if (!machine_is_magician())
471 return -ENODEV;
472
473 ret = gpio_request(EGPIO_MAGICIAN_CODEC_POWER, "CODEC_POWER");
474 if (ret)
475 goto err_request_power;
476 ret = gpio_request(EGPIO_MAGICIAN_CODEC_RESET, "CODEC_RESET");
477 if (ret)
478 goto err_request_reset;
479 ret = gpio_request(EGPIO_MAGICIAN_SPK_POWER, "SPK_POWER");
480 if (ret)
481 goto err_request_spk;
482 ret = gpio_request(EGPIO_MAGICIAN_EP_POWER, "EP_POWER");
483 if (ret)
484 goto err_request_ep;
485 ret = gpio_request(EGPIO_MAGICIAN_MIC_POWER, "MIC_POWER");
486 if (ret)
487 goto err_request_mic;
488 ret = gpio_request(EGPIO_MAGICIAN_IN_SEL0, "IN_SEL0");
489 if (ret)
490 goto err_request_in_sel0;
491 ret = gpio_request(EGPIO_MAGICIAN_IN_SEL1, "IN_SEL1");
492 if (ret)
493 goto err_request_in_sel1;
494
495 gpio_set_value(EGPIO_MAGICIAN_CODEC_POWER, 1);
496 gpio_set_value(EGPIO_MAGICIAN_IN_SEL0, 0);
497
498 /* we may need to have the clock running here - pH5 */
499 gpio_set_value(EGPIO_MAGICIAN_CODEC_RESET, 1);
500 udelay(5);
501 gpio_set_value(EGPIO_MAGICIAN_CODEC_RESET, 0);
502
503 magician_snd_device = platform_device_alloc("soc-audio", -1);
504 if (!magician_snd_device) {
505 ret = -ENOMEM;
506 goto err_pdev;
507 }
508
509 platform_set_drvdata(magician_snd_device, &magician_snd_devdata);
510 magician_snd_devdata.dev = &magician_snd_device->dev;
511 ret = platform_device_add(magician_snd_device);
512 if (ret) {
513 platform_device_put(magician_snd_device);
514 goto err_pdev;
515 }
516
517 return 0;
518
519err_pdev:
520 gpio_free(EGPIO_MAGICIAN_IN_SEL1);
521err_request_in_sel1:
522 gpio_free(EGPIO_MAGICIAN_IN_SEL0);
523err_request_in_sel0:
524 gpio_free(EGPIO_MAGICIAN_MIC_POWER);
525err_request_mic:
526 gpio_free(EGPIO_MAGICIAN_EP_POWER);
527err_request_ep:
528 gpio_free(EGPIO_MAGICIAN_SPK_POWER);
529err_request_spk:
530 gpio_free(EGPIO_MAGICIAN_CODEC_RESET);
531err_request_reset:
532 gpio_free(EGPIO_MAGICIAN_CODEC_POWER);
533err_request_power:
534 return ret;
535}
536
537static void __exit magician_exit(void)
538{
539 platform_device_unregister(magician_snd_device);
540
541 gpio_set_value(EGPIO_MAGICIAN_SPK_POWER, 0);
542 gpio_set_value(EGPIO_MAGICIAN_EP_POWER, 0);
543 gpio_set_value(EGPIO_MAGICIAN_MIC_POWER, 0);
544 gpio_set_value(EGPIO_MAGICIAN_CODEC_POWER, 0);
545
546 gpio_free(EGPIO_MAGICIAN_IN_SEL1);
547 gpio_free(EGPIO_MAGICIAN_IN_SEL0);
548 gpio_free(EGPIO_MAGICIAN_MIC_POWER);
549 gpio_free(EGPIO_MAGICIAN_EP_POWER);
550 gpio_free(EGPIO_MAGICIAN_SPK_POWER);
551 gpio_free(EGPIO_MAGICIAN_CODEC_RESET);
552 gpio_free(EGPIO_MAGICIAN_CODEC_POWER);
553}
554
555module_init(magician_init);
556module_exit(magician_exit);
557
558MODULE_AUTHOR("Philipp Zabel");
559MODULE_DESCRIPTION("ALSA SoC Magician");
560MODULE_LICENSE("GPL");
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 7acd3febf8b0..308a657928d2 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -627,12 +627,18 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
627 u32 sscr0; 627 u32 sscr0;
628 u32 sspsp; 628 u32 sspsp;
629 int width = snd_pcm_format_physical_width(params_format(params)); 629 int width = snd_pcm_format_physical_width(params_format(params));
630 int ttsa = ssp_read_reg(ssp, SSTSA) & 0xf;
630 631
631 /* select correct DMA params */ 632 /* select correct DMA params */
632 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) 633 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
633 dma = 1; /* capture DMA offset is 1,3 */ 634 dma = 1; /* capture DMA offset is 1,3 */
634 if (chn == 2) 635 /* Network mode with one active slot (ttsa == 1) can be used
635 dma += 2; /* stereo DMA offset is 2, mono is 0 */ 636 * to force 16-bit frame width on the wire (for S16_LE), even
637 * with two channels. Use 16-bit DMA transfers for this case.
638 */
639 if (((chn == 2) && (ttsa != 1)) || (width == 32))
640 dma += 2; /* 32-bit DMA offset is 2, 16-bit is 0 */
641
636 cpu_dai->dma_data = ssp_dma_params[cpu_dai->id][dma]; 642 cpu_dai->dma_data = ssp_dma_params[cpu_dai->id][dma];
637 643
638 dev_dbg(&ssp->pdev->dev, "pxa_ssp_hw_params: dma %d\n", dma); 644 dev_dbg(&ssp->pdev->dev, "pxa_ssp_hw_params: dma %d\n", dma);
@@ -712,7 +718,7 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
712 /* When we use a network mode, we always require TDM slots 718 /* When we use a network mode, we always require TDM slots
713 * - complain loudly and fail if they've not been set up yet. 719 * - complain loudly and fail if they've not been set up yet.
714 */ 720 */
715 if ((sscr0 & SSCR0_MOD) && !(ssp_read_reg(ssp, SSTSA) & 0xf)) { 721 if ((sscr0 & SSCR0_MOD) && !ttsa) {
716 dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); 722 dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n");
717 return -EINVAL; 723 return -EINVAL;
718 } 724 }
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6e710f705a74..99712f652d0d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -98,7 +98,7 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
98 int err; 98 int err;
99 99
100 codec->ac97->dev.bus = &ac97_bus_type; 100 codec->ac97->dev.bus = &ac97_bus_type;
101 codec->ac97->dev.parent = NULL; 101 codec->ac97->dev.parent = codec->card->dev;
102 codec->ac97->dev.release = soc_ac97_device_release; 102 codec->ac97->dev.release = soc_ac97_device_release;
103 103
104 dev_set_name(&codec->ac97->dev, "%d-%d:%s", 104 dev_set_name(&codec->ac97->dev, "%d-%d:%s",
@@ -767,11 +767,21 @@ static int soc_resume(struct platform_device *pdev)
767{ 767{
768 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 768 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
769 struct snd_soc_card *card = socdev->card; 769 struct snd_soc_card *card = socdev->card;
770 struct snd_soc_dai *cpu_dai = card->dai_link[0].cpu_dai;
770 771
771 dev_dbg(socdev->dev, "scheduling resume work\n"); 772 /* AC97 devices might have other drivers hanging off them so
772 773 * need to resume immediately. Other drivers don't have that
773 if (!schedule_work(&card->deferred_resume_work)) 774 * problem and may take a substantial amount of time to resume
774 dev_err(socdev->dev, "resume work item may be lost\n"); 775 * due to I/O costs and anti-pop so handle them out of line.
776 */
777 if (cpu_dai->ac97_control) {
778 dev_dbg(socdev->dev, "Resuming AC97 immediately\n");
779 soc_resume_deferred(&card->deferred_resume_work);
780 } else {
781 dev_dbg(socdev->dev, "Scheduling resume work\n");
782 if (!schedule_work(&card->deferred_resume_work))
783 dev_err(socdev->dev, "resume work item may be lost\n");
784 }
775 785
776 return 0; 786 return 0;
777} 787}
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index c2db0f959681..823296d7d578 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -121,6 +121,7 @@ struct audioformat {
121 unsigned char attributes; /* corresponding attributes of cs endpoint */ 121 unsigned char attributes; /* corresponding attributes of cs endpoint */
122 unsigned char endpoint; /* endpoint */ 122 unsigned char endpoint; /* endpoint */
123 unsigned char ep_attr; /* endpoint attributes */ 123 unsigned char ep_attr; /* endpoint attributes */
124 unsigned char datainterval; /* log_2 of data packet interval */
124 unsigned int maxpacksize; /* max. packet size */ 125 unsigned int maxpacksize; /* max. packet size */
125 unsigned int rates; /* rate bitmasks */ 126 unsigned int rates; /* rate bitmasks */
126 unsigned int rate_min, rate_max; /* min/max rates */ 127 unsigned int rate_min, rate_max; /* min/max rates */
@@ -170,7 +171,6 @@ struct snd_usb_substream {
170 unsigned int curframesize; /* current packet size in frames (for capture) */ 171 unsigned int curframesize; /* current packet size in frames (for capture) */
171 unsigned int fill_max: 1; /* fill max packet size always */ 172 unsigned int fill_max: 1; /* fill max packet size always */
172 unsigned int fmt_type; /* USB audio format type (1-3) */ 173 unsigned int fmt_type; /* USB audio format type (1-3) */
173 unsigned int packs_per_ms; /* packets per millisecond (for playback) */
174 174
175 unsigned int running: 1; /* running status */ 175 unsigned int running: 1; /* running status */
176 176
@@ -607,9 +607,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,
607 break; 607 break;
608 } 608 }
609 } 609 }
610 /* finish at the frame boundary at/after the period boundary */ 610 if (period_elapsed) /* finish at the period boundary */
611 if (period_elapsed &&
612 (i & (subs->packs_per_ms - 1)) == subs->packs_per_ms - 1)
613 break; 611 break;
614 } 612 }
615 if (subs->hwptr_done + offs > runtime->buffer_size) { 613 if (subs->hwptr_done + offs > runtime->buffer_size) {
@@ -1067,7 +1065,6 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1067 packs_per_ms = 8 >> subs->datainterval; 1065 packs_per_ms = 8 >> subs->datainterval;
1068 else 1066 else
1069 packs_per_ms = 1; 1067 packs_per_ms = 1;
1070 subs->packs_per_ms = packs_per_ms;
1071 1068
1072 if (is_playback) { 1069 if (is_playback) {
1073 urb_packs = max(nrpacks, 1); 1070 urb_packs = max(nrpacks, 1);
@@ -1087,18 +1084,17 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1087 minsize -= minsize >> 3; 1084 minsize -= minsize >> 3;
1088 minsize = max(minsize, 1u); 1085 minsize = max(minsize, 1u);
1089 total_packs = (period_bytes + minsize - 1) / minsize; 1086 total_packs = (period_bytes + minsize - 1) / minsize;
1090 /* round up to multiple of packs_per_ms */
1091 total_packs = (total_packs + packs_per_ms - 1)
1092 & ~(packs_per_ms - 1);
1093 /* we need at least two URBs for queueing */ 1087 /* we need at least two URBs for queueing */
1094 if (total_packs < 2 * packs_per_ms) { 1088 if (total_packs < 2) {
1095 total_packs = 2 * packs_per_ms; 1089 total_packs = 2;
1096 } else { 1090 } else {
1097 /* and we don't want too long a queue either */ 1091 /* and we don't want too long a queue either */
1098 maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2); 1092 maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2);
1099 total_packs = min(total_packs, maxpacks); 1093 total_packs = min(total_packs, maxpacks);
1100 } 1094 }
1101 } else { 1095 } else {
1096 while (urb_packs > 1 && urb_packs * maxsize >= period_bytes)
1097 urb_packs >>= 1;
1102 total_packs = MAX_URBS * urb_packs; 1098 total_packs = MAX_URBS * urb_packs;
1103 } 1099 }
1104 subs->nurbs = (total_packs + urb_packs - 1) / urb_packs; 1100 subs->nurbs = (total_packs + urb_packs - 1) / urb_packs;
@@ -1350,12 +1346,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1350 subs->datapipe = usb_sndisocpipe(dev, ep); 1346 subs->datapipe = usb_sndisocpipe(dev, ep);
1351 else 1347 else
1352 subs->datapipe = usb_rcvisocpipe(dev, ep); 1348 subs->datapipe = usb_rcvisocpipe(dev, ep);
1353 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH && 1349 subs->datainterval = fmt->datainterval;
1354 get_endpoint(alts, 0)->bInterval >= 1 &&
1355 get_endpoint(alts, 0)->bInterval <= 4)
1356 subs->datainterval = get_endpoint(alts, 0)->bInterval - 1;
1357 else
1358 subs->datainterval = 0;
1359 subs->syncpipe = subs->syncinterval = 0; 1350 subs->syncpipe = subs->syncinterval = 0;
1360 subs->maxpacksize = fmt->maxpacksize; 1351 subs->maxpacksize = fmt->maxpacksize;
1361 subs->fill_max = 0; 1352 subs->fill_max = 0;
@@ -1568,11 +1559,15 @@ static struct snd_pcm_hardware snd_usb_hardware =
1568#define hwc_debug(fmt, args...) /**/ 1559#define hwc_debug(fmt, args...) /**/
1569#endif 1560#endif
1570 1561
1571static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audioformat *fp) 1562static int hw_check_valid_format(struct snd_usb_substream *subs,
1563 struct snd_pcm_hw_params *params,
1564 struct audioformat *fp)
1572{ 1565{
1573 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 1566 struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
1574 struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); 1567 struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
1575 struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1568 struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
1569 struct snd_interval *pt = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME);
1570 unsigned int ptime;
1576 1571
1577 /* check the format */ 1572 /* check the format */
1578 if (!snd_mask_test(fmts, fp->format)) { 1573 if (!snd_mask_test(fmts, fp->format)) {
@@ -1593,6 +1588,14 @@ static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audiof
1593 hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min); 1588 hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min);
1594 return 0; 1589 return 0;
1595 } 1590 }
1591 /* check whether the period time is >= the data packet interval */
1592 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) {
1593 ptime = 125 * (1 << fp->datainterval);
1594 if (ptime > pt->max || (ptime == pt->max && pt->openmax)) {
1595 hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max);
1596 return 0;
1597 }
1598 }
1596 return 1; 1599 return 1;
1597} 1600}
1598 1601
@@ -1611,7 +1614,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params,
1611 list_for_each(p, &subs->fmt_list) { 1614 list_for_each(p, &subs->fmt_list) {
1612 struct audioformat *fp; 1615 struct audioformat *fp;
1613 fp = list_entry(p, struct audioformat, list); 1616 fp = list_entry(p, struct audioformat, list);
1614 if (!hw_check_valid_format(params, fp)) 1617 if (!hw_check_valid_format(subs, params, fp))
1615 continue; 1618 continue;
1616 if (changed++) { 1619 if (changed++) {
1617 if (rmin > fp->rate_min) 1620 if (rmin > fp->rate_min)
@@ -1665,7 +1668,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params,
1665 list_for_each(p, &subs->fmt_list) { 1668 list_for_each(p, &subs->fmt_list) {
1666 struct audioformat *fp; 1669 struct audioformat *fp;
1667 fp = list_entry(p, struct audioformat, list); 1670 fp = list_entry(p, struct audioformat, list);
1668 if (!hw_check_valid_format(params, fp)) 1671 if (!hw_check_valid_format(subs, params, fp))
1669 continue; 1672 continue;
1670 if (changed++) { 1673 if (changed++) {
1671 if (rmin > fp->channels) 1674 if (rmin > fp->channels)
@@ -1718,7 +1721,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
1718 list_for_each(p, &subs->fmt_list) { 1721 list_for_each(p, &subs->fmt_list) {
1719 struct audioformat *fp; 1722 struct audioformat *fp;
1720 fp = list_entry(p, struct audioformat, list); 1723 fp = list_entry(p, struct audioformat, list);
1721 if (!hw_check_valid_format(params, fp)) 1724 if (!hw_check_valid_format(subs, params, fp))
1722 continue; 1725 continue;
1723 fbits |= (1ULL << fp->format); 1726 fbits |= (1ULL << fp->format);
1724 } 1727 }
@@ -1736,95 +1739,42 @@ static int hw_rule_format(struct snd_pcm_hw_params *params,
1736 return changed; 1739 return changed;
1737} 1740}
1738 1741
1739#define MAX_MASK 64 1742static int hw_rule_period_time(struct snd_pcm_hw_params *params,
1740 1743 struct snd_pcm_hw_rule *rule)
1741/*
1742 * check whether the registered audio formats need special hw-constraints
1743 */
1744static int check_hw_params_convention(struct snd_usb_substream *subs)
1745{ 1744{
1746 int i; 1745 struct snd_usb_substream *subs = rule->private;
1747 u32 *channels; 1746 struct audioformat *fp;
1748 u32 *rates; 1747 struct snd_interval *it;
1749 u32 cmaster, rmaster; 1748 unsigned char min_datainterval;
1750 u32 rate_min = 0, rate_max = 0; 1749 unsigned int pmin;
1751 struct list_head *p; 1750 int changed;
1752 int err = 1;
1753
1754 channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
1755 rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
1756 if (!channels || !rates) {
1757 err = -ENOMEM;
1758 goto __out;
1759 }
1760 1751
1761 list_for_each(p, &subs->fmt_list) { 1752 it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME);
1762 struct audioformat *f; 1753 hwc_debug("hw_rule_period_time: (%u,%u)\n", it->min, it->max);
1763 f = list_entry(p, struct audioformat, list); 1754 min_datainterval = 0xff;
1764 /* unconventional channels? */ 1755 list_for_each_entry(fp, &subs->fmt_list, list) {
1765 if (f->channels > 32) 1756 if (!hw_check_valid_format(subs, params, fp))
1766 goto __out;
1767 /* continuous rate min/max matches? */
1768 if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) {
1769 if (rate_min && f->rate_min != rate_min)
1770 goto __out;
1771 if (rate_max && f->rate_max != rate_max)
1772 goto __out;
1773 rate_min = f->rate_min;
1774 rate_max = f->rate_max;
1775 }
1776 /* combination of continuous rates and fixed rates? */
1777 if (rates[f->format] & SNDRV_PCM_RATE_CONTINUOUS) {
1778 if (f->rates != rates[f->format])
1779 goto __out;
1780 }
1781 if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) {
1782 if (rates[f->format] && rates[f->format] != f->rates)
1783 goto __out;
1784 }
1785 channels[f->format] |= 1 << (f->channels - 1);
1786 rates[f->format] |= f->rates;
1787 /* needs knot? */
1788 if (f->rates & SNDRV_PCM_RATE_KNOT)
1789 goto __out;
1790 }
1791 /* check whether channels and rates match for all formats */
1792 cmaster = rmaster = 0;
1793 for (i = 0; i < MAX_MASK; i++) {
1794 if (cmaster != channels[i] && cmaster && channels[i])
1795 goto __out;
1796 if (rmaster != rates[i] && rmaster && rates[i])
1797 goto __out;
1798 if (channels[i])
1799 cmaster = channels[i];
1800 if (rates[i])
1801 rmaster = rates[i];
1802 }
1803 /* check whether channels match for all distinct rates */
1804 memset(channels, 0, MAX_MASK * sizeof(u32));
1805 list_for_each(p, &subs->fmt_list) {
1806 struct audioformat *f;
1807 f = list_entry(p, struct audioformat, list);
1808 if (f->rates & SNDRV_PCM_RATE_CONTINUOUS)
1809 continue; 1757 continue;
1810 for (i = 0; i < 32; i++) { 1758 min_datainterval = min(min_datainterval, fp->datainterval);
1811 if (f->rates & (1 << i))
1812 channels[i] |= 1 << (f->channels - 1);
1813 }
1814 } 1759 }
1815 cmaster = 0; 1760 if (min_datainterval == 0xff) {
1816 for (i = 0; i < 32; i++) { 1761 hwc_debug(" --> get emtpy\n");
1817 if (cmaster != channels[i] && cmaster && channels[i]) 1762 it->empty = 1;
1818 goto __out; 1763 return -EINVAL;
1819 if (channels[i])
1820 cmaster = channels[i];
1821 } 1764 }
1822 err = 0; 1765 pmin = 125 * (1 << min_datainterval);
1823 1766 changed = 0;
1824 __out: 1767 if (it->min < pmin) {
1825 kfree(channels); 1768 it->min = pmin;
1826 kfree(rates); 1769 it->openmin = 0;
1827 return err; 1770 changed = 1;
1771 }
1772 if (snd_interval_checkempty(it)) {
1773 it->empty = 1;
1774 return -EINVAL;
1775 }
1776 hwc_debug(" --> (%u,%u) (changed = %d)\n", it->min, it->max, changed);
1777 return changed;
1828} 1778}
1829 1779
1830/* 1780/*
@@ -1872,6 +1822,8 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
1872static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) 1822static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs)
1873{ 1823{
1874 struct list_head *p; 1824 struct list_head *p;
1825 unsigned int pt, ptmin;
1826 int param_period_time_if_needed;
1875 int err; 1827 int err;
1876 1828
1877 runtime->hw.formats = subs->formats; 1829 runtime->hw.formats = subs->formats;
@@ -1881,6 +1833,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1881 runtime->hw.channels_min = 256; 1833 runtime->hw.channels_min = 256;
1882 runtime->hw.channels_max = 0; 1834 runtime->hw.channels_max = 0;
1883 runtime->hw.rates = 0; 1835 runtime->hw.rates = 0;
1836 ptmin = UINT_MAX;
1884 /* check min/max rates and channels */ 1837 /* check min/max rates and channels */
1885 list_for_each(p, &subs->fmt_list) { 1838 list_for_each(p, &subs->fmt_list) {
1886 struct audioformat *fp; 1839 struct audioformat *fp;
@@ -1899,42 +1852,54 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1899 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = 1852 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max =
1900 fp->frame_size; 1853 fp->frame_size;
1901 } 1854 }
1855 pt = 125 * (1 << fp->datainterval);
1856 ptmin = min(ptmin, pt);
1902 } 1857 }
1903 1858
1904 /* set the period time minimum 1ms */ 1859 param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME;
1905 /* FIXME: high-speed mode allows 125us minimum period, but many parts 1860 if (snd_usb_get_speed(subs->dev) != USB_SPEED_HIGH)
1906 * in the current code assume the 1ms period. 1861 /* full speed devices have fixed data packet interval */
1907 */ 1862 ptmin = 1000;
1863 if (ptmin == 1000)
1864 /* if period time doesn't go below 1 ms, no rules needed */
1865 param_period_time_if_needed = -1;
1908 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1866 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1909 1000, 1867 ptmin, UINT_MAX);
1910 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1868
1911 1869 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
1912 err = check_hw_params_convention(subs); 1870 hw_rule_rate, subs,
1913 if (err < 0) 1871 SNDRV_PCM_HW_PARAM_FORMAT,
1872 SNDRV_PCM_HW_PARAM_CHANNELS,
1873 param_period_time_if_needed,
1874 -1)) < 0)
1914 return err; 1875 return err;
1915 else if (err) { 1876 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
1916 hwc_debug("setting extra hw constraints...\n"); 1877 hw_rule_channels, subs,
1917 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 1878 SNDRV_PCM_HW_PARAM_FORMAT,
1918 hw_rule_rate, subs, 1879 SNDRV_PCM_HW_PARAM_RATE,
1919 SNDRV_PCM_HW_PARAM_FORMAT, 1880 param_period_time_if_needed,
1920 SNDRV_PCM_HW_PARAM_CHANNELS, 1881 -1)) < 0)
1921 -1)) < 0) 1882 return err;
1922 return err; 1883 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT,
1923 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 1884 hw_rule_format, subs,
1924 hw_rule_channels, subs, 1885 SNDRV_PCM_HW_PARAM_RATE,
1925 SNDRV_PCM_HW_PARAM_FORMAT, 1886 SNDRV_PCM_HW_PARAM_CHANNELS,
1926 SNDRV_PCM_HW_PARAM_RATE, 1887 param_period_time_if_needed,
1927 -1)) < 0) 1888 -1)) < 0)
1928 return err; 1889 return err;
1929 if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, 1890 if (param_period_time_if_needed >= 0) {
1930 hw_rule_format, subs, 1891 err = snd_pcm_hw_rule_add(runtime, 0,
1931 SNDRV_PCM_HW_PARAM_RATE, 1892 SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1932 SNDRV_PCM_HW_PARAM_CHANNELS, 1893 hw_rule_period_time, subs,
1933 -1)) < 0) 1894 SNDRV_PCM_HW_PARAM_FORMAT,
1934 return err; 1895 SNDRV_PCM_HW_PARAM_CHANNELS,
1935 if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) 1896 SNDRV_PCM_HW_PARAM_RATE,
1897 -1);
1898 if (err < 0)
1936 return err; 1899 return err;
1937 } 1900 }
1901 if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0)
1902 return err;
1938 return 0; 1903 return 0;
1939} 1904}
1940 1905
@@ -2147,7 +2112,8 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2147 fp = list_entry(p, struct audioformat, list); 2112 fp = list_entry(p, struct audioformat, list);
2148 snd_iprintf(buffer, " Interface %d\n", fp->iface); 2113 snd_iprintf(buffer, " Interface %d\n", fp->iface);
2149 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 2114 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
2150 snd_iprintf(buffer, " Format: %#x\n", fp->format); 2115 snd_iprintf(buffer, " Format: %#x (%d bits)\n",
2116 fp->format, snd_pcm_format_width(fp->format));
2151 snd_iprintf(buffer, " Channels: %d\n", fp->channels); 2117 snd_iprintf(buffer, " Channels: %d\n", fp->channels);
2152 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2118 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n",
2153 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2119 fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
@@ -2166,6 +2132,9 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2166 } 2132 }
2167 snd_iprintf(buffer, "\n"); 2133 snd_iprintf(buffer, "\n");
2168 } 2134 }
2135 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH)
2136 snd_iprintf(buffer, " Data packet interval: %d us\n",
2137 125 * (1 << fp->datainterval));
2169 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); 2138 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
2170 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes); 2139 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes);
2171 } 2140 }
@@ -2659,6 +2628,17 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp
2659 return 0; 2628 return 0;
2660} 2629}
2661 2630
2631static unsigned char parse_datainterval(struct snd_usb_audio *chip,
2632 struct usb_host_interface *alts)
2633{
2634 if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH &&
2635 get_endpoint(alts, 0)->bInterval >= 1 &&
2636 get_endpoint(alts, 0)->bInterval <= 4)
2637 return get_endpoint(alts, 0)->bInterval - 1;
2638 else
2639 return 0;
2640}
2641
2662static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, 2642static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
2663 int iface, int altno); 2643 int iface, int altno);
2664static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) 2644static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
@@ -2764,6 +2744,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2764 fp->altset_idx = i; 2744 fp->altset_idx = i;
2765 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 2745 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
2766 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 2746 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
2747 fp->datainterval = parse_datainterval(chip, alts);
2767 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2748 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2768 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) 2749 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH)
2769 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) 2750 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1)
@@ -2955,6 +2936,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
2955 return -EINVAL; 2936 return -EINVAL;
2956 } 2937 }
2957 alts = &iface->altsetting[fp->altset_idx]; 2938 alts = &iface->altsetting[fp->altset_idx];
2939 fp->datainterval = parse_datainterval(chip, alts);
2958 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2940 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2959 usb_set_interface(chip->dev, fp->iface, 0); 2941 usb_set_interface(chip->dev, fp->iface, 0);
2960 init_usb_pitch(chip->dev, fp->iface, alts, fp); 2942 init_usb_pitch(chip->dev, fp->iface, alts, fp);
@@ -3049,6 +3031,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
3049 fp->iface = altsd->bInterfaceNumber; 3031 fp->iface = altsd->bInterfaceNumber;
3050 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3032 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3051 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3033 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3034 fp->datainterval = 0;
3052 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3035 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3053 3036
3054 switch (fp->maxpacksize) { 3037 switch (fp->maxpacksize) {
@@ -3116,6 +3099,7 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip,
3116 fp->iface = altsd->bInterfaceNumber; 3099 fp->iface = altsd->bInterfaceNumber;
3117 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3100 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3118 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3101 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3102 fp->datainterval = parse_datainterval(chip, alts);
3119 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3103 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3120 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); 3104 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]);
3121 3105
@@ -3168,6 +3152,7 @@ static int create_ua101_quirk(struct snd_usb_audio *chip,
3168 fp->iface = altsd->bInterfaceNumber; 3152 fp->iface = altsd->bInterfaceNumber;
3169 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3153 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3170 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3154 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3155 fp->datainterval = parse_datainterval(chip, alts);
3171 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3156 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3172 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); 3157 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]);
3173 3158