diff options
Diffstat (limited to 'sound')
64 files changed, 3325 insertions, 1258 deletions
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 1497dce1b04a..c5699863643b 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c | |||
@@ -172,14 +172,15 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg) | |||
172 | return v; | 172 | return v; |
173 | } | 173 | } |
174 | 174 | ||
175 | static inline void aaci_chan_wait_ready(struct aaci_runtime *aacirun) | 175 | static inline void |
176 | aaci_chan_wait_ready(struct aaci_runtime *aacirun, unsigned long mask) | ||
176 | { | 177 | { |
177 | u32 val; | 178 | u32 val; |
178 | int timeout = 5000; | 179 | int timeout = 5000; |
179 | 180 | ||
180 | do { | 181 | do { |
181 | val = readl(aacirun->base + AACI_SR); | 182 | val = readl(aacirun->base + AACI_SR); |
182 | } while (val & (SR_TXB|SR_RXB) && timeout--); | 183 | } while (val & mask && timeout--); |
183 | } | 184 | } |
184 | 185 | ||
185 | 186 | ||
@@ -208,8 +209,10 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
208 | writel(0, aacirun->base + AACI_IE); | 209 | writel(0, aacirun->base + AACI_IE); |
209 | return; | 210 | return; |
210 | } | 211 | } |
211 | ptr = aacirun->ptr; | ||
212 | 212 | ||
213 | spin_lock(&aacirun->lock); | ||
214 | |||
215 | ptr = aacirun->ptr; | ||
213 | do { | 216 | do { |
214 | unsigned int len = aacirun->fifosz; | 217 | unsigned int len = aacirun->fifosz; |
215 | u32 val; | 218 | u32 val; |
@@ -217,9 +220,9 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
217 | if (aacirun->bytes <= 0) { | 220 | if (aacirun->bytes <= 0) { |
218 | aacirun->bytes += aacirun->period; | 221 | aacirun->bytes += aacirun->period; |
219 | aacirun->ptr = ptr; | 222 | aacirun->ptr = ptr; |
220 | spin_unlock(&aaci->lock); | 223 | spin_unlock(&aacirun->lock); |
221 | snd_pcm_period_elapsed(aacirun->substream); | 224 | snd_pcm_period_elapsed(aacirun->substream); |
222 | spin_lock(&aaci->lock); | 225 | spin_lock(&aacirun->lock); |
223 | } | 226 | } |
224 | if (!(aacirun->cr & CR_EN)) | 227 | if (!(aacirun->cr & CR_EN)) |
225 | break; | 228 | break; |
@@ -245,7 +248,10 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
245 | ptr = aacirun->start; | 248 | ptr = aacirun->start; |
246 | } | 249 | } |
247 | } while(1); | 250 | } while(1); |
251 | |||
248 | aacirun->ptr = ptr; | 252 | aacirun->ptr = ptr; |
253 | |||
254 | spin_unlock(&aacirun->lock); | ||
249 | } | 255 | } |
250 | 256 | ||
251 | if (mask & ISR_URINTR) { | 257 | if (mask & ISR_URINTR) { |
@@ -263,6 +269,8 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
263 | return; | 269 | return; |
264 | } | 270 | } |
265 | 271 | ||
272 | spin_lock(&aacirun->lock); | ||
273 | |||
266 | ptr = aacirun->ptr; | 274 | ptr = aacirun->ptr; |
267 | do { | 275 | do { |
268 | unsigned int len = aacirun->fifosz; | 276 | unsigned int len = aacirun->fifosz; |
@@ -271,9 +279,9 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
271 | if (aacirun->bytes <= 0) { | 279 | if (aacirun->bytes <= 0) { |
272 | aacirun->bytes += aacirun->period; | 280 | aacirun->bytes += aacirun->period; |
273 | aacirun->ptr = ptr; | 281 | aacirun->ptr = ptr; |
274 | spin_unlock(&aaci->lock); | 282 | spin_unlock(&aacirun->lock); |
275 | snd_pcm_period_elapsed(aacirun->substream); | 283 | snd_pcm_period_elapsed(aacirun->substream); |
276 | spin_lock(&aaci->lock); | 284 | spin_lock(&aacirun->lock); |
277 | } | 285 | } |
278 | if (!(aacirun->cr & CR_EN)) | 286 | if (!(aacirun->cr & CR_EN)) |
279 | break; | 287 | break; |
@@ -301,6 +309,8 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
301 | } while (1); | 309 | } while (1); |
302 | 310 | ||
303 | aacirun->ptr = ptr; | 311 | aacirun->ptr = ptr; |
312 | |||
313 | spin_unlock(&aacirun->lock); | ||
304 | } | 314 | } |
305 | } | 315 | } |
306 | 316 | ||
@@ -310,7 +320,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
310 | u32 mask; | 320 | u32 mask; |
311 | int i; | 321 | int i; |
312 | 322 | ||
313 | spin_lock(&aaci->lock); | ||
314 | mask = readl(aaci->base + AACI_ALLINTS); | 323 | mask = readl(aaci->base + AACI_ALLINTS); |
315 | if (mask) { | 324 | if (mask) { |
316 | u32 m = mask; | 325 | u32 m = mask; |
@@ -320,7 +329,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
320 | } | 329 | } |
321 | } | 330 | } |
322 | } | 331 | } |
323 | spin_unlock(&aaci->lock); | ||
324 | 332 | ||
325 | return mask ? IRQ_HANDLED : IRQ_NONE; | 333 | return mask ? IRQ_HANDLED : IRQ_NONE; |
326 | } | 334 | } |
@@ -330,63 +338,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
330 | /* | 338 | /* |
331 | * ALSA support. | 339 | * ALSA support. |
332 | */ | 340 | */ |
333 | |||
334 | struct aaci_stream { | ||
335 | unsigned char codec_idx; | ||
336 | unsigned char rate_idx; | ||
337 | }; | ||
338 | |||
339 | static struct aaci_stream aaci_streams[] = { | ||
340 | [ACSTREAM_FRONT] = { | ||
341 | .codec_idx = 0, | ||
342 | .rate_idx = AC97_RATES_FRONT_DAC, | ||
343 | }, | ||
344 | [ACSTREAM_SURROUND] = { | ||
345 | .codec_idx = 0, | ||
346 | .rate_idx = AC97_RATES_SURR_DAC, | ||
347 | }, | ||
348 | [ACSTREAM_LFE] = { | ||
349 | .codec_idx = 0, | ||
350 | .rate_idx = AC97_RATES_LFE_DAC, | ||
351 | }, | ||
352 | }; | ||
353 | |||
354 | static inline unsigned int aaci_rate_mask(struct aaci *aaci, int streamid) | ||
355 | { | ||
356 | struct aaci_stream *s = aaci_streams + streamid; | ||
357 | return aaci->ac97_bus->codec[s->codec_idx]->rates[s->rate_idx]; | ||
358 | } | ||
359 | |||
360 | static unsigned int rate_list[] = { | ||
361 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, | ||
362 | 48000, 64000, 88200, 96000, 176400, 192000 | ||
363 | }; | ||
364 | |||
365 | /* | ||
366 | * Double-rate rule: we can support double rate iff channels == 2 | ||
367 | * (unimplemented) | ||
368 | */ | ||
369 | static int | ||
370 | aaci_rule_rate_by_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule) | ||
371 | { | ||
372 | struct aaci *aaci = rule->private; | ||
373 | unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512; | ||
374 | struct snd_interval *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
375 | |||
376 | switch (c->max) { | ||
377 | case 6: | ||
378 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE); | ||
379 | case 4: | ||
380 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND); | ||
381 | case 2: | ||
382 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT); | ||
383 | } | ||
384 | |||
385 | return snd_interval_list(hw_param_interval(p, rule->var), | ||
386 | ARRAY_SIZE(rate_list), rate_list, | ||
387 | rate_mask); | ||
388 | } | ||
389 | |||
390 | static struct snd_pcm_hardware aaci_hw_info = { | 341 | static struct snd_pcm_hardware aaci_hw_info = { |
391 | .info = SNDRV_PCM_INFO_MMAP | | 342 | .info = SNDRV_PCM_INFO_MMAP | |
392 | SNDRV_PCM_INFO_MMAP_VALID | | 343 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -400,10 +351,7 @@ static struct snd_pcm_hardware aaci_hw_info = { | |||
400 | */ | 351 | */ |
401 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 352 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
402 | 353 | ||
403 | /* should this be continuous or knot? */ | 354 | /* rates are setup from the AC'97 codec */ |
404 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
405 | .rate_max = 48000, | ||
406 | .rate_min = 4000, | ||
407 | .channels_min = 2, | 355 | .channels_min = 2, |
408 | .channels_max = 6, | 356 | .channels_max = 6, |
409 | .buffer_bytes_max = 64 * 1024, | 357 | .buffer_bytes_max = 64 * 1024, |
@@ -423,6 +371,12 @@ static int __aaci_pcm_open(struct aaci *aaci, | |||
423 | aacirun->substream = substream; | 371 | aacirun->substream = substream; |
424 | runtime->private_data = aacirun; | 372 | runtime->private_data = aacirun; |
425 | runtime->hw = aaci_hw_info; | 373 | runtime->hw = aaci_hw_info; |
374 | runtime->hw.rates = aacirun->pcm->rates; | ||
375 | snd_pcm_limit_hw_rates(runtime); | ||
376 | |||
377 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | ||
378 | aacirun->pcm->r[1].slots) | ||
379 | snd_ac97_pcm_double_rate_rules(runtime); | ||
426 | 380 | ||
427 | /* | 381 | /* |
428 | * FIXME: ALSA specifies fifo_size in bytes. If we're in normal | 382 | * FIXME: ALSA specifies fifo_size in bytes. If we're in normal |
@@ -433,17 +387,6 @@ static int __aaci_pcm_open(struct aaci *aaci, | |||
433 | */ | 387 | */ |
434 | runtime->hw.fifo_size = aaci->fifosize * 2; | 388 | runtime->hw.fifo_size = aaci->fifosize * 2; |
435 | 389 | ||
436 | /* | ||
437 | * Add rule describing hardware rate dependency | ||
438 | * on the number of channels. | ||
439 | */ | ||
440 | ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
441 | aaci_rule_rate_by_channels, aaci, | ||
442 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
443 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
444 | if (ret) | ||
445 | goto out; | ||
446 | |||
447 | ret = request_irq(aaci->dev->irq[0], aaci_irq, IRQF_SHARED|IRQF_DISABLED, | 390 | ret = request_irq(aaci->dev->irq[0], aaci_irq, IRQF_SHARED|IRQF_DISABLED, |
448 | DRIVER_NAME, aaci); | 391 | DRIVER_NAME, aaci); |
449 | if (ret) | 392 | if (ret) |
@@ -507,18 +450,22 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, | |||
507 | 450 | ||
508 | err = snd_pcm_lib_malloc_pages(substream, | 451 | err = snd_pcm_lib_malloc_pages(substream, |
509 | params_buffer_bytes(params)); | 452 | params_buffer_bytes(params)); |
510 | if (err < 0) | 453 | if (err >= 0) { |
511 | goto out; | 454 | unsigned int rate = params_rate(params); |
455 | int dbl = rate > 48000; | ||
512 | 456 | ||
513 | err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), | 457 | err = snd_ac97_pcm_open(aacirun->pcm, rate, |
514 | params_channels(params), | 458 | params_channels(params), |
515 | aacirun->pcm->r[0].slots); | 459 | aacirun->pcm->r[dbl].slots); |
516 | if (err) | ||
517 | goto out; | ||
518 | 460 | ||
519 | aacirun->pcm_open = 1; | 461 | aacirun->pcm_open = err == 0; |
462 | aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; | ||
463 | aacirun->fifosz = aaci->fifosize * 4; | ||
464 | |||
465 | if (aacirun->cr & CR_COMPACT) | ||
466 | aacirun->fifosz >>= 1; | ||
467 | } | ||
520 | 468 | ||
521 | out: | ||
522 | return err; | 469 | return err; |
523 | } | 470 | } |
524 | 471 | ||
@@ -527,7 +474,7 @@ static int aaci_pcm_prepare(struct snd_pcm_substream *substream) | |||
527 | struct snd_pcm_runtime *runtime = substream->runtime; | 474 | struct snd_pcm_runtime *runtime = substream->runtime; |
528 | struct aaci_runtime *aacirun = runtime->private_data; | 475 | struct aaci_runtime *aacirun = runtime->private_data; |
529 | 476 | ||
530 | aacirun->start = (void *)runtime->dma_area; | 477 | aacirun->start = runtime->dma_area; |
531 | aacirun->end = aacirun->start + snd_pcm_lib_buffer_bytes(substream); | 478 | aacirun->end = aacirun->start + snd_pcm_lib_buffer_bytes(substream); |
532 | aacirun->ptr = aacirun->start; | 479 | aacirun->ptr = aacirun->start; |
533 | aacirun->period = | 480 | aacirun->period = |
@@ -627,14 +574,9 @@ static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream, | |||
627 | * Enable FIFO, compact mode, 16 bits per sample. | 574 | * Enable FIFO, compact mode, 16 bits per sample. |
628 | * FIXME: double rate slots? | 575 | * FIXME: double rate slots? |
629 | */ | 576 | */ |
630 | if (ret >= 0) { | 577 | if (ret >= 0) |
631 | aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; | ||
632 | aacirun->cr |= channels_to_txmask[channels]; | 578 | aacirun->cr |= channels_to_txmask[channels]; |
633 | 579 | ||
634 | aacirun->fifosz = aaci->fifosize * 4; | ||
635 | if (aacirun->cr & CR_COMPACT) | ||
636 | aacirun->fifosz >>= 1; | ||
637 | } | ||
638 | return ret; | 580 | return ret; |
639 | } | 581 | } |
640 | 582 | ||
@@ -646,7 +588,7 @@ static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun) | |||
646 | ie &= ~(IE_URIE|IE_TXIE); | 588 | ie &= ~(IE_URIE|IE_TXIE); |
647 | writel(ie, aacirun->base + AACI_IE); | 589 | writel(ie, aacirun->base + AACI_IE); |
648 | aacirun->cr &= ~CR_EN; | 590 | aacirun->cr &= ~CR_EN; |
649 | aaci_chan_wait_ready(aacirun); | 591 | aaci_chan_wait_ready(aacirun, SR_TXB); |
650 | writel(aacirun->cr, aacirun->base + AACI_TXCR); | 592 | writel(aacirun->cr, aacirun->base + AACI_TXCR); |
651 | } | 593 | } |
652 | 594 | ||
@@ -654,7 +596,7 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) | |||
654 | { | 596 | { |
655 | u32 ie; | 597 | u32 ie; |
656 | 598 | ||
657 | aaci_chan_wait_ready(aacirun); | 599 | aaci_chan_wait_ready(aacirun, SR_TXB); |
658 | aacirun->cr |= CR_EN; | 600 | aacirun->cr |= CR_EN; |
659 | 601 | ||
660 | ie = readl(aacirun->base + AACI_IE); | 602 | ie = readl(aacirun->base + AACI_IE); |
@@ -665,12 +607,12 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) | |||
665 | 607 | ||
666 | static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) | 608 | static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) |
667 | { | 609 | { |
668 | struct aaci *aaci = substream->private_data; | ||
669 | struct aaci_runtime *aacirun = substream->runtime->private_data; | 610 | struct aaci_runtime *aacirun = substream->runtime->private_data; |
670 | unsigned long flags; | 611 | unsigned long flags; |
671 | int ret = 0; | 612 | int ret = 0; |
672 | 613 | ||
673 | spin_lock_irqsave(&aaci->lock, flags); | 614 | spin_lock_irqsave(&aacirun->lock, flags); |
615 | |||
674 | switch (cmd) { | 616 | switch (cmd) { |
675 | case SNDRV_PCM_TRIGGER_START: | 617 | case SNDRV_PCM_TRIGGER_START: |
676 | aaci_pcm_playback_start(aacirun); | 618 | aaci_pcm_playback_start(aacirun); |
@@ -697,7 +639,8 @@ static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cm | |||
697 | default: | 639 | default: |
698 | ret = -EINVAL; | 640 | ret = -EINVAL; |
699 | } | 641 | } |
700 | spin_unlock_irqrestore(&aaci->lock, flags); | 642 | |
643 | spin_unlock_irqrestore(&aacirun->lock, flags); | ||
701 | 644 | ||
702 | return ret; | 645 | return ret; |
703 | } | 646 | } |
@@ -721,18 +664,10 @@ static int aaci_pcm_capture_hw_params(struct snd_pcm_substream *substream, | |||
721 | int ret; | 664 | int ret; |
722 | 665 | ||
723 | ret = aaci_pcm_hw_params(substream, aacirun, params); | 666 | ret = aaci_pcm_hw_params(substream, aacirun, params); |
724 | 667 | if (ret >= 0) | |
725 | if (ret >= 0) { | ||
726 | aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; | ||
727 | |||
728 | /* Line in record: slot 3 and 4 */ | 668 | /* Line in record: slot 3 and 4 */ |
729 | aacirun->cr |= CR_SL3 | CR_SL4; | 669 | aacirun->cr |= CR_SL3 | CR_SL4; |
730 | 670 | ||
731 | aacirun->fifosz = aaci->fifosize * 4; | ||
732 | |||
733 | if (aacirun->cr & CR_COMPACT) | ||
734 | aacirun->fifosz >>= 1; | ||
735 | } | ||
736 | return ret; | 671 | return ret; |
737 | } | 672 | } |
738 | 673 | ||
@@ -740,7 +675,7 @@ static void aaci_pcm_capture_stop(struct aaci_runtime *aacirun) | |||
740 | { | 675 | { |
741 | u32 ie; | 676 | u32 ie; |
742 | 677 | ||
743 | aaci_chan_wait_ready(aacirun); | 678 | aaci_chan_wait_ready(aacirun, SR_RXB); |
744 | 679 | ||
745 | ie = readl(aacirun->base + AACI_IE); | 680 | ie = readl(aacirun->base + AACI_IE); |
746 | ie &= ~(IE_ORIE | IE_RXIE); | 681 | ie &= ~(IE_ORIE | IE_RXIE); |
@@ -755,7 +690,7 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun) | |||
755 | { | 690 | { |
756 | u32 ie; | 691 | u32 ie; |
757 | 692 | ||
758 | aaci_chan_wait_ready(aacirun); | 693 | aaci_chan_wait_ready(aacirun, SR_RXB); |
759 | 694 | ||
760 | #ifdef DEBUG | 695 | #ifdef DEBUG |
761 | /* RX Timeout value: bits 28:17 in RXCR */ | 696 | /* RX Timeout value: bits 28:17 in RXCR */ |
@@ -772,12 +707,11 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun) | |||
772 | 707 | ||
773 | static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd) | 708 | static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd) |
774 | { | 709 | { |
775 | struct aaci *aaci = substream->private_data; | ||
776 | struct aaci_runtime *aacirun = substream->runtime->private_data; | 710 | struct aaci_runtime *aacirun = substream->runtime->private_data; |
777 | unsigned long flags; | 711 | unsigned long flags; |
778 | int ret = 0; | 712 | int ret = 0; |
779 | 713 | ||
780 | spin_lock_irqsave(&aaci->lock, flags); | 714 | spin_lock_irqsave(&aacirun->lock, flags); |
781 | 715 | ||
782 | switch (cmd) { | 716 | switch (cmd) { |
783 | case SNDRV_PCM_TRIGGER_START: | 717 | case SNDRV_PCM_TRIGGER_START: |
@@ -806,7 +740,7 @@ static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd | |||
806 | ret = -EINVAL; | 740 | ret = -EINVAL; |
807 | } | 741 | } |
808 | 742 | ||
809 | spin_unlock_irqrestore(&aaci->lock, flags); | 743 | spin_unlock_irqrestore(&aacirun->lock, flags); |
810 | 744 | ||
811 | return ret; | 745 | return ret; |
812 | } | 746 | } |
@@ -889,6 +823,12 @@ static struct ac97_pcm ac97_defs[] __devinitdata = { | |||
889 | (1 << AC97_SLOT_PCM_SRIGHT) | | 823 | (1 << AC97_SLOT_PCM_SRIGHT) | |
890 | (1 << AC97_SLOT_LFE), | 824 | (1 << AC97_SLOT_LFE), |
891 | }, | 825 | }, |
826 | [1] = { | ||
827 | .slots = (1 << AC97_SLOT_PCM_LEFT) | | ||
828 | (1 << AC97_SLOT_PCM_RIGHT) | | ||
829 | (1 << AC97_SLOT_PCM_LEFT_0) | | ||
830 | (1 << AC97_SLOT_PCM_RIGHT_0), | ||
831 | }, | ||
892 | }, | 832 | }, |
893 | }, | 833 | }, |
894 | [1] = { /* PCM in */ | 834 | [1] = { /* PCM in */ |
@@ -1001,7 +941,6 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev) | |||
1001 | 941 | ||
1002 | aaci = card->private_data; | 942 | aaci = card->private_data; |
1003 | mutex_init(&aaci->ac97_sem); | 943 | mutex_init(&aaci->ac97_sem); |
1004 | spin_lock_init(&aaci->lock); | ||
1005 | aaci->card = card; | 944 | aaci->card = card; |
1006 | aaci->dev = dev; | 945 | aaci->dev = dev; |
1007 | 946 | ||
@@ -1028,7 +967,7 @@ static int __devinit aaci_init_pcm(struct aaci *aaci) | |||
1028 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); | 967 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); |
1029 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops); | 968 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops); |
1030 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 969 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
1031 | NULL, 0, 64 * 104); | 970 | NULL, 0, 64 * 1024); |
1032 | } | 971 | } |
1033 | 972 | ||
1034 | return ret; | 973 | return ret; |
@@ -1088,12 +1027,14 @@ static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id) | |||
1088 | /* | 1027 | /* |
1089 | * Playback uses AACI channel 0 | 1028 | * Playback uses AACI channel 0 |
1090 | */ | 1029 | */ |
1030 | spin_lock_init(&aaci->playback.lock); | ||
1091 | aaci->playback.base = aaci->base + AACI_CSCH1; | 1031 | aaci->playback.base = aaci->base + AACI_CSCH1; |
1092 | aaci->playback.fifo = aaci->base + AACI_DR1; | 1032 | aaci->playback.fifo = aaci->base + AACI_DR1; |
1093 | 1033 | ||
1094 | /* | 1034 | /* |
1095 | * Capture uses AACI channel 0 | 1035 | * Capture uses AACI channel 0 |
1096 | */ | 1036 | */ |
1037 | spin_lock_init(&aaci->capture.lock); | ||
1097 | aaci->capture.base = aaci->base + AACI_CSCH1; | 1038 | aaci->capture.base = aaci->base + AACI_CSCH1; |
1098 | aaci->capture.fifo = aaci->base + AACI_DR1; | 1039 | aaci->capture.fifo = aaci->base + AACI_DR1; |
1099 | 1040 | ||
diff --git a/sound/arm/aaci.h b/sound/arm/aaci.h index 924f69c1c44c..6a4a2eebdda1 100644 --- a/sound/arm/aaci.h +++ b/sound/arm/aaci.h | |||
@@ -202,6 +202,7 @@ | |||
202 | struct aaci_runtime { | 202 | struct aaci_runtime { |
203 | void __iomem *base; | 203 | void __iomem *base; |
204 | void __iomem *fifo; | 204 | void __iomem *fifo; |
205 | spinlock_t lock; | ||
205 | 206 | ||
206 | struct ac97_pcm *pcm; | 207 | struct ac97_pcm *pcm; |
207 | int pcm_open; | 208 | int pcm_open; |
@@ -232,7 +233,6 @@ struct aaci { | |||
232 | struct snd_ac97 *ac97; | 233 | struct snd_ac97 *ac97; |
233 | 234 | ||
234 | u32 maincr; | 235 | u32 maincr; |
235 | spinlock_t lock; | ||
236 | 236 | ||
237 | struct aaci_runtime playback; | 237 | struct aaci_runtime playback; |
238 | struct aaci_runtime capture; | 238 | struct aaci_runtime capture; |
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index b4b48afb6de6..5d9411839cd7 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c | |||
@@ -159,7 +159,7 @@ static int pxa2xx_ac97_resume(struct device *dev) | |||
159 | return ret; | 159 | return ret; |
160 | } | 160 | } |
161 | 161 | ||
162 | static struct dev_pm_ops pxa2xx_ac97_pm_ops = { | 162 | static const struct dev_pm_ops pxa2xx_ac97_pm_ops = { |
163 | .suspend = pxa2xx_ac97_suspend, | 163 | .suspend = pxa2xx_ac97_suspend, |
164 | .resume = pxa2xx_ac97_resume, | 164 | .resume = pxa2xx_ac97_resume, |
165 | }; | 165 | }; |
diff --git a/sound/core/Kconfig b/sound/core/Kconfig index c15682a2f9db..475455c76610 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig | |||
@@ -5,6 +5,7 @@ config SND_TIMER | |||
5 | config SND_PCM | 5 | config SND_PCM |
6 | tristate | 6 | tristate |
7 | select SND_TIMER | 7 | select SND_TIMER |
8 | select GCD | ||
8 | 9 | ||
9 | config SND_HWDEP | 10 | config SND_HWDEP |
10 | tristate | 11 | tristate |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index c7b35b20e659..0403a7d55f0c 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -761,10 +761,13 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
761 | unsigned int rats_count, struct snd_ratnum *rats, | 761 | unsigned int rats_count, struct snd_ratnum *rats, |
762 | unsigned int *nump, unsigned int *denp) | 762 | unsigned int *nump, unsigned int *denp) |
763 | { | 763 | { |
764 | unsigned int best_num, best_diff, best_den; | 764 | unsigned int best_num, best_den; |
765 | int best_diff; | ||
765 | unsigned int k; | 766 | unsigned int k; |
766 | struct snd_interval t; | 767 | struct snd_interval t; |
767 | int err; | 768 | int err; |
769 | unsigned int result_num, result_den; | ||
770 | int result_diff; | ||
768 | 771 | ||
769 | best_num = best_den = best_diff = 0; | 772 | best_num = best_den = best_diff = 0; |
770 | for (k = 0; k < rats_count; ++k) { | 773 | for (k = 0; k < rats_count; ++k) { |
@@ -774,7 +777,7 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
774 | int diff; | 777 | int diff; |
775 | if (q == 0) | 778 | if (q == 0) |
776 | q = 1; | 779 | q = 1; |
777 | den = div_down(num, q); | 780 | den = div_up(num, q); |
778 | if (den < rats[k].den_min) | 781 | if (den < rats[k].den_min) |
779 | continue; | 782 | continue; |
780 | if (den > rats[k].den_max) | 783 | if (den > rats[k].den_max) |
@@ -786,6 +789,8 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
786 | den -= r; | 789 | den -= r; |
787 | } | 790 | } |
788 | diff = num - q * den; | 791 | diff = num - q * den; |
792 | if (diff < 0) | ||
793 | diff = -diff; | ||
789 | if (best_num == 0 || | 794 | if (best_num == 0 || |
790 | diff * best_den < best_diff * den) { | 795 | diff * best_den < best_diff * den) { |
791 | best_diff = diff; | 796 | best_diff = diff; |
@@ -800,6 +805,9 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
800 | t.min = div_down(best_num, best_den); | 805 | t.min = div_down(best_num, best_den); |
801 | t.openmin = !!(best_num % best_den); | 806 | t.openmin = !!(best_num % best_den); |
802 | 807 | ||
808 | result_num = best_num; | ||
809 | result_diff = best_diff; | ||
810 | result_den = best_den; | ||
803 | best_num = best_den = best_diff = 0; | 811 | best_num = best_den = best_diff = 0; |
804 | for (k = 0; k < rats_count; ++k) { | 812 | for (k = 0; k < rats_count; ++k) { |
805 | unsigned int num = rats[k].num; | 813 | unsigned int num = rats[k].num; |
@@ -810,7 +818,7 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
810 | i->empty = 1; | 818 | i->empty = 1; |
811 | return -EINVAL; | 819 | return -EINVAL; |
812 | } | 820 | } |
813 | den = div_up(num, q); | 821 | den = div_down(num, q); |
814 | if (den > rats[k].den_max) | 822 | if (den > rats[k].den_max) |
815 | continue; | 823 | continue; |
816 | if (den < rats[k].den_min) | 824 | if (den < rats[k].den_min) |
@@ -822,6 +830,8 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
822 | den += rats[k].den_step - r; | 830 | den += rats[k].den_step - r; |
823 | } | 831 | } |
824 | diff = q * den - num; | 832 | diff = q * den - num; |
833 | if (diff < 0) | ||
834 | diff = -diff; | ||
825 | if (best_num == 0 || | 835 | if (best_num == 0 || |
826 | diff * best_den < best_diff * den) { | 836 | diff * best_den < best_diff * den) { |
827 | best_diff = diff; | 837 | best_diff = diff; |
@@ -841,10 +851,14 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
841 | return err; | 851 | return err; |
842 | 852 | ||
843 | if (snd_interval_single(i)) { | 853 | if (snd_interval_single(i)) { |
854 | if (best_diff * result_den < result_diff * best_den) { | ||
855 | result_num = best_num; | ||
856 | result_den = best_den; | ||
857 | } | ||
844 | if (nump) | 858 | if (nump) |
845 | *nump = best_num; | 859 | *nump = result_num; |
846 | if (denp) | 860 | if (denp) |
847 | *denp = best_den; | 861 | *denp = result_den; |
848 | } | 862 | } |
849 | return err; | 863 | return err; |
850 | } | 864 | } |
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index caa7796bc2f5..d6d49d6651f9 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/time.h> | 23 | #include <linux/time.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/moduleparam.h> | 25 | #include <linux/moduleparam.h> |
26 | #include <linux/vmalloc.h> | ||
26 | #include <sound/core.h> | 27 | #include <sound/core.h> |
27 | #include <sound/pcm.h> | 28 | #include <sound/pcm.h> |
28 | #include <sound/info.h> | 29 | #include <sound/info.h> |
@@ -434,3 +435,57 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) | |||
434 | } | 435 | } |
435 | 436 | ||
436 | EXPORT_SYMBOL(snd_pcm_lib_free_pages); | 437 | EXPORT_SYMBOL(snd_pcm_lib_free_pages); |
438 | |||
439 | int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, | ||
440 | size_t size, gfp_t gfp_flags) | ||
441 | { | ||
442 | struct snd_pcm_runtime *runtime; | ||
443 | |||
444 | if (PCM_RUNTIME_CHECK(substream)) | ||
445 | return -EINVAL; | ||
446 | runtime = substream->runtime; | ||
447 | if (runtime->dma_area) { | ||
448 | if (runtime->dma_bytes >= size) | ||
449 | return 0; /* already large enough */ | ||
450 | vfree(runtime->dma_area); | ||
451 | } | ||
452 | runtime->dma_area = __vmalloc(size, gfp_flags, PAGE_KERNEL); | ||
453 | if (!runtime->dma_area) | ||
454 | return -ENOMEM; | ||
455 | runtime->dma_bytes = size; | ||
456 | return 1; | ||
457 | } | ||
458 | EXPORT_SYMBOL(_snd_pcm_lib_alloc_vmalloc_buffer); | ||
459 | |||
460 | /** | ||
461 | * snd_pcm_lib_free_vmalloc_buffer - free vmalloc buffer | ||
462 | * @substream: the substream with a buffer allocated by | ||
463 | * snd_pcm_lib_alloc_vmalloc_buffer() | ||
464 | */ | ||
465 | int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) | ||
466 | { | ||
467 | struct snd_pcm_runtime *runtime; | ||
468 | |||
469 | if (PCM_RUNTIME_CHECK(substream)) | ||
470 | return -EINVAL; | ||
471 | runtime = substream->runtime; | ||
472 | vfree(runtime->dma_area); | ||
473 | runtime->dma_area = NULL; | ||
474 | return 0; | ||
475 | } | ||
476 | EXPORT_SYMBOL(snd_pcm_lib_free_vmalloc_buffer); | ||
477 | |||
478 | /** | ||
479 | * snd_pcm_lib_get_vmalloc_page - map vmalloc buffer offset to page struct | ||
480 | * @substream: the substream with a buffer allocated by | ||
481 | * snd_pcm_lib_alloc_vmalloc_buffer() | ||
482 | * @offset: offset in the buffer | ||
483 | * | ||
484 | * This function is to be used as the page callback in the PCM ops. | ||
485 | */ | ||
486 | struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, | ||
487 | unsigned long offset) | ||
488 | { | ||
489 | return vmalloc_to_page(substream->runtime->dma_area + offset); | ||
490 | } | ||
491 | EXPORT_SYMBOL(snd_pcm_lib_get_vmalloc_page); | ||
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 27284f628361..a870fe696578 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -1918,13 +1918,13 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) | |||
1918 | 1918 | ||
1919 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, | 1919 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, |
1920 | hw->rate_min, hw->rate_max); | 1920 | hw->rate_min, hw->rate_max); |
1921 | if (err < 0) | 1921 | if (err < 0) |
1922 | return err; | 1922 | return err; |
1923 | 1923 | ||
1924 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, | 1924 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, |
1925 | hw->period_bytes_min, hw->period_bytes_max); | 1925 | hw->period_bytes_min, hw->period_bytes_max); |
1926 | if (err < 0) | 1926 | if (err < 0) |
1927 | return err; | 1927 | return err; |
1928 | 1928 | ||
1929 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, | 1929 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, |
1930 | hw->periods_min, hw->periods_max); | 1930 | hw->periods_min, hw->periods_max); |
diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c index ca8068b63d6c..b01d9481d632 100644 --- a/sound/core/pcm_timer.c +++ b/sound/core/pcm_timer.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/time.h> | 22 | #include <linux/time.h> |
23 | #include <linux/gcd.h> | ||
23 | #include <sound/core.h> | 24 | #include <sound/core.h> |
24 | #include <sound/pcm.h> | 25 | #include <sound/pcm.h> |
25 | #include <sound/timer.h> | 26 | #include <sound/timer.h> |
@@ -28,22 +29,6 @@ | |||
28 | * Timer functions | 29 | * Timer functions |
29 | */ | 30 | */ |
30 | 31 | ||
31 | /* Greatest common divisor */ | ||
32 | static unsigned long gcd(unsigned long a, unsigned long b) | ||
33 | { | ||
34 | unsigned long r; | ||
35 | if (a < b) { | ||
36 | r = a; | ||
37 | a = b; | ||
38 | b = r; | ||
39 | } | ||
40 | while ((r = a % b) != 0) { | ||
41 | a = b; | ||
42 | b = r; | ||
43 | } | ||
44 | return b; | ||
45 | } | ||
46 | |||
47 | void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) | 32 | void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) |
48 | { | 33 | { |
49 | unsigned long rate, mult, fsize, l, post; | 34 | unsigned long rate, mult, fsize, l, post; |
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 6644d0034fba..c8385d26a16f 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c | |||
@@ -46,7 +46,6 @@ | |||
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <linux/slab.h> | 48 | #include <linux/slab.h> |
49 | #include <linux/vmalloc.h> | ||
50 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
51 | #include <sound/core.h> | 50 | #include <sound/core.h> |
52 | #include <sound/asoundef.h> | 51 | #include <sound/asoundef.h> |
@@ -56,55 +55,6 @@ | |||
56 | 55 | ||
57 | 56 | ||
58 | /* | 57 | /* |
59 | * we use a vmalloc'ed (sg-)buffer | ||
60 | */ | ||
61 | |||
62 | /* get the physical page pointer on the given offset */ | ||
63 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
64 | unsigned long offset) | ||
65 | { | ||
66 | void *pageptr = subs->runtime->dma_area + offset; | ||
67 | return vmalloc_to_page(pageptr); | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | * allocate a buffer via vmalloc_32(). | ||
72 | * called from hw_params | ||
73 | * NOTE: this may be called not only once per pcm open! | ||
74 | */ | ||
75 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
76 | { | ||
77 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
78 | if (runtime->dma_area) { | ||
79 | /* already allocated */ | ||
80 | if (runtime->dma_bytes >= size) | ||
81 | return 0; /* already enough large */ | ||
82 | vfree(runtime->dma_area); | ||
83 | } | ||
84 | runtime->dma_area = vmalloc_32(size); | ||
85 | if (! runtime->dma_area) | ||
86 | return -ENOMEM; | ||
87 | memset(runtime->dma_area, 0, size); | ||
88 | runtime->dma_bytes = size; | ||
89 | return 1; /* changed */ | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * free the buffer. | ||
94 | * called from hw_free callback | ||
95 | * NOTE: this may be called not only once per pcm open! | ||
96 | */ | ||
97 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
98 | { | ||
99 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
100 | |||
101 | vfree(runtime->dma_area); | ||
102 | runtime->dma_area = NULL; | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | |||
107 | /* | ||
108 | * read three pending pcm bytes via inb() | 58 | * read three pending pcm bytes via inb() |
109 | */ | 59 | */ |
110 | static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime, | 60 | static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime, |
@@ -865,7 +815,8 @@ static snd_pcm_uframes_t vx_pcm_playback_pointer(struct snd_pcm_substream *subs) | |||
865 | static int vx_pcm_hw_params(struct snd_pcm_substream *subs, | 815 | static int vx_pcm_hw_params(struct snd_pcm_substream *subs, |
866 | struct snd_pcm_hw_params *hw_params) | 816 | struct snd_pcm_hw_params *hw_params) |
867 | { | 817 | { |
868 | return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); | 818 | return snd_pcm_lib_alloc_vmalloc_32_buffer |
819 | (subs, params_buffer_bytes(hw_params)); | ||
869 | } | 820 | } |
870 | 821 | ||
871 | /* | 822 | /* |
@@ -873,7 +824,7 @@ static int vx_pcm_hw_params(struct snd_pcm_substream *subs, | |||
873 | */ | 824 | */ |
874 | static int vx_pcm_hw_free(struct snd_pcm_substream *subs) | 825 | static int vx_pcm_hw_free(struct snd_pcm_substream *subs) |
875 | { | 826 | { |
876 | return snd_pcm_free_vmalloc_buffer(subs); | 827 | return snd_pcm_lib_free_vmalloc_buffer(subs); |
877 | } | 828 | } |
878 | 829 | ||
879 | /* | 830 | /* |
@@ -953,7 +904,7 @@ static struct snd_pcm_ops vx_pcm_playback_ops = { | |||
953 | .prepare = vx_pcm_prepare, | 904 | .prepare = vx_pcm_prepare, |
954 | .trigger = vx_pcm_trigger, | 905 | .trigger = vx_pcm_trigger, |
955 | .pointer = vx_pcm_playback_pointer, | 906 | .pointer = vx_pcm_playback_pointer, |
956 | .page = snd_pcm_get_vmalloc_page, | 907 | .page = snd_pcm_lib_get_vmalloc_page, |
957 | }; | 908 | }; |
958 | 909 | ||
959 | 910 | ||
@@ -1173,7 +1124,7 @@ static struct snd_pcm_ops vx_pcm_capture_ops = { | |||
1173 | .prepare = vx_pcm_prepare, | 1124 | .prepare = vx_pcm_prepare, |
1174 | .trigger = vx_pcm_trigger, | 1125 | .trigger = vx_pcm_trigger, |
1175 | .pointer = vx_pcm_capture_pointer, | 1126 | .pointer = vx_pcm_capture_pointer, |
1176 | .page = snd_pcm_get_vmalloc_page, | 1127 | .page = snd_pcm_lib_get_vmalloc_page, |
1177 | }; | 1128 | }; |
1178 | 1129 | ||
1179 | 1130 | ||
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 02fe81ca88fd..755a0a5f0e3f 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
@@ -63,15 +63,16 @@ config SND_AD1848 | |||
63 | will be called snd-ad1848. | 63 | will be called snd-ad1848. |
64 | 64 | ||
65 | config SND_ALS100 | 65 | config SND_ALS100 |
66 | tristate "Avance Logic ALS100/ALS120" | 66 | tristate "Diamond Tech. DT-019x and Avance Logic ALSxxx" |
67 | depends on PNP | 67 | depends on PNP |
68 | select ISAPNP | 68 | select ISAPNP |
69 | select SND_OPL3_LIB | 69 | select SND_OPL3_LIB |
70 | select SND_MPU401_UART | 70 | select SND_MPU401_UART |
71 | select SND_SB16_DSP | 71 | select SND_SB16_DSP |
72 | help | 72 | help |
73 | Say Y here to include support for soundcards based on Avance | 73 | Say Y here to include support for soundcards based on the |
74 | Logic ALS100, ALS110, ALS120 and ALS200 chips. | 74 | Diamond Technologies DT-019X or Avance Logic chips: ALS007, |
75 | ALS100, ALS110, ALS120 and ALS200 chips. | ||
75 | 76 | ||
76 | To compile this driver as a module, choose M here: the module | 77 | To compile this driver as a module, choose M here: the module |
77 | will be called snd-als100. | 78 | will be called snd-als100. |
@@ -127,20 +128,6 @@ config SND_CS4236 | |||
127 | To compile this driver as a module, choose M here: the module | 128 | To compile this driver as a module, choose M here: the module |
128 | will be called snd-cs4236. | 129 | will be called snd-cs4236. |
129 | 130 | ||
130 | config SND_DT019X | ||
131 | tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" | ||
132 | depends on PNP | ||
133 | select ISAPNP | ||
134 | select SND_OPL3_LIB | ||
135 | select SND_MPU401_UART | ||
136 | select SND_SB16_DSP | ||
137 | help | ||
138 | Say Y here to include support for soundcards based on the | ||
139 | Diamond Technologies DT-019X or Avance Logic ALS-007 chips. | ||
140 | |||
141 | To compile this driver as a module, choose M here: the module | ||
142 | will be called snd-dt019x. | ||
143 | |||
144 | config SND_ES968 | 131 | config SND_ES968 |
145 | tristate "Generic ESS ES968 driver" | 132 | tristate "Generic ESS ES968 driver" |
146 | depends on PNP | 133 | depends on PNP |
@@ -252,6 +239,22 @@ config SND_INTERWAVE_STB | |||
252 | To compile this driver as a module, choose M here: the module | 239 | To compile this driver as a module, choose M here: the module |
253 | will be called snd-interwave-stb. | 240 | will be called snd-interwave-stb. |
254 | 241 | ||
242 | config SND_JAZZ16 | ||
243 | tristate "Media Vision Jazz16 card and compatibles" | ||
244 | select SND_OPL3_LIB | ||
245 | select SND_MPU401_UART | ||
246 | select SND_SB8_DSP | ||
247 | help | ||
248 | Say Y here to include support for soundcards based on the | ||
249 | Media Vision Jazz16 chipset: digital chip MVD1216 (Jazz16), | ||
250 | codec MVA416 (CS4216) and mixer MVA514 (ICS2514). | ||
251 | Media Vision's Jazz16 cards were sold under names Pro Sonic 16, | ||
252 | Premium 3-D and Pro 3-D. There were also OEMs cards with the | ||
253 | Jazz16 chipset. | ||
254 | |||
255 | To compile this driver as a module, choose M here: the module | ||
256 | will be called snd-jazz16. | ||
257 | |||
255 | config SND_OPL3SA2 | 258 | config SND_OPL3SA2 |
256 | tristate "Yamaha OPL3-SA2/SA3" | 259 | tristate "Yamaha OPL3-SA2/SA3" |
257 | select SND_OPL3_LIB | 260 | select SND_OPL3_LIB |
diff --git a/sound/isa/Makefile b/sound/isa/Makefile index b906b9a1a81e..c73d30c4f462 100644 --- a/sound/isa/Makefile +++ b/sound/isa/Makefile | |||
@@ -7,7 +7,6 @@ snd-adlib-objs := adlib.o | |||
7 | snd-als100-objs := als100.o | 7 | snd-als100-objs := als100.o |
8 | snd-azt2320-objs := azt2320.o | 8 | snd-azt2320-objs := azt2320.o |
9 | snd-cmi8330-objs := cmi8330.o | 9 | snd-cmi8330-objs := cmi8330.o |
10 | snd-dt019x-objs := dt019x.o | ||
11 | snd-es18xx-objs := es18xx.o | 10 | snd-es18xx-objs := es18xx.o |
12 | snd-opl3sa2-objs := opl3sa2.o | 11 | snd-opl3sa2-objs := opl3sa2.o |
13 | snd-sc6000-objs := sc6000.o | 12 | snd-sc6000-objs := sc6000.o |
@@ -19,7 +18,6 @@ obj-$(CONFIG_SND_ADLIB) += snd-adlib.o | |||
19 | obj-$(CONFIG_SND_ALS100) += snd-als100.o | 18 | obj-$(CONFIG_SND_ALS100) += snd-als100.o |
20 | obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o | 19 | obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o |
21 | obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o | 20 | obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o |
22 | obj-$(CONFIG_SND_DT019X) += snd-dt019x.o | ||
23 | obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o | 21 | obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o |
24 | obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o | 22 | obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o |
25 | obj-$(CONFIG_SND_SC6000) += snd-sc6000.o | 23 | obj-$(CONFIG_SND_SC6000) += snd-sc6000.o |
diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 5fd52e4d7079..20becc89f6f6 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c | |||
@@ -2,9 +2,13 @@ | |||
2 | /* | 2 | /* |
3 | card-als100.c - driver for Avance Logic ALS100 based soundcards. | 3 | card-als100.c - driver for Avance Logic ALS100 based soundcards. |
4 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> | 4 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> |
5 | Copyright (C) 1999-2002 by Massimo Piccioni <dafastidio@libero.it> | ||
5 | 6 | ||
6 | Thanks to Pierfrancesco 'qM2' Passerini. | 7 | Thanks to Pierfrancesco 'qM2' Passerini. |
7 | 8 | ||
9 | Generalised for soundcards based on DT-0196 and ALS-007 chips | ||
10 | by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. | ||
11 | |||
8 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 14 | the Free Software Foundation; either version 2 of the License, or |
@@ -33,10 +37,10 @@ | |||
33 | 37 | ||
34 | #define PFX "als100: " | 38 | #define PFX "als100: " |
35 | 39 | ||
36 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | 40 | MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0"); |
37 | MODULE_DESCRIPTION("Avance Logic ALS1X0"); | 41 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," |
38 | MODULE_LICENSE("GPL"); | 42 | "{Avance Logic ALS-007}}" |
39 | MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," | 43 | "{{Avance Logic,ALS100 - PRO16PNP}," |
40 | "{Avance Logic,ALS110}," | 44 | "{Avance Logic,ALS110}," |
41 | "{Avance Logic,ALS120}," | 45 | "{Avance Logic,ALS120}," |
42 | "{Avance Logic,ALS200}," | 46 | "{Avance Logic,ALS200}," |
@@ -45,9 +49,12 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," | |||
45 | "{Avance Logic,ALS120}," | 49 | "{Avance Logic,ALS120}," |
46 | "{RTL,RTL3000}}"); | 50 | "{RTL,RTL3000}}"); |
47 | 51 | ||
52 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | ||
53 | MODULE_LICENSE("GPL"); | ||
54 | |||
48 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 55 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
49 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 56 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
50 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ | 57 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
51 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 58 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
52 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 59 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
53 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 60 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
@@ -57,14 +64,15 @@ static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | |||
57 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | 64 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ |
58 | 65 | ||
59 | module_param_array(index, int, NULL, 0444); | 66 | module_param_array(index, int, NULL, 0444); |
60 | MODULE_PARM_DESC(index, "Index value for als100 based soundcard."); | 67 | MODULE_PARM_DESC(index, "Index value for Avance Logic based soundcard."); |
61 | module_param_array(id, charp, NULL, 0444); | 68 | module_param_array(id, charp, NULL, 0444); |
62 | MODULE_PARM_DESC(id, "ID string for als100 based soundcard."); | 69 | MODULE_PARM_DESC(id, "ID string for Avance Logic based soundcard."); |
63 | module_param_array(enable, bool, NULL, 0444); | 70 | module_param_array(enable, bool, NULL, 0444); |
64 | MODULE_PARM_DESC(enable, "Enable als100 based soundcard."); | 71 | MODULE_PARM_DESC(enable, "Enable Avance Logic based soundcard."); |
72 | |||
73 | MODULE_ALIAS("snd-dt019x"); | ||
65 | 74 | ||
66 | struct snd_card_als100 { | 75 | struct snd_card_als100 { |
67 | int dev_no; | ||
68 | struct pnp_dev *dev; | 76 | struct pnp_dev *dev; |
69 | struct pnp_dev *devmpu; | 77 | struct pnp_dev *devmpu; |
70 | struct pnp_dev *devopl; | 78 | struct pnp_dev *devopl; |
@@ -72,25 +80,43 @@ struct snd_card_als100 { | |||
72 | }; | 80 | }; |
73 | 81 | ||
74 | static struct pnp_card_device_id snd_als100_pnpids[] = { | 82 | static struct pnp_card_device_id snd_als100_pnpids[] = { |
83 | /* DT197A30 */ | ||
84 | { .id = "RWB1688", | ||
85 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, | ||
86 | .driver_data = SB_HW_DT019X }, | ||
87 | /* DT0196 / ALS-007 */ | ||
88 | { .id = "ALS0007", | ||
89 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, | ||
90 | .driver_data = SB_HW_DT019X }, | ||
75 | /* ALS100 - PRO16PNP */ | 91 | /* ALS100 - PRO16PNP */ |
76 | { .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, | 92 | { .id = "ALS0001", |
93 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, | ||
94 | .driver_data = SB_HW_ALS100 }, | ||
77 | /* ALS110 - MF1000 - Digimate 3D Sound */ | 95 | /* ALS110 - MF1000 - Digimate 3D Sound */ |
78 | { .id = "ALS0110", .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } } }, | 96 | { .id = "ALS0110", |
97 | .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } }, | ||
98 | .driver_data = SB_HW_ALS100 }, | ||
79 | /* ALS120 */ | 99 | /* ALS120 */ |
80 | { .id = "ALS0120", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, | 100 | { .id = "ALS0120", |
101 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, | ||
102 | .driver_data = SB_HW_ALS100 }, | ||
81 | /* ALS200 */ | 103 | /* ALS200 */ |
82 | { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } } }, | 104 | { .id = "ALS0200", |
105 | .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } }, | ||
106 | .driver_data = SB_HW_ALS100 }, | ||
83 | /* ALS200 OEM */ | 107 | /* ALS200 OEM */ |
84 | { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } } }, | 108 | { .id = "ALS0200", |
109 | .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } }, | ||
110 | .driver_data = SB_HW_ALS100 }, | ||
85 | /* RTL3000 */ | 111 | /* RTL3000 */ |
86 | { .id = "RTL3000", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, | 112 | { .id = "RTL3000", |
87 | { .id = "", } /* end */ | 113 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, |
114 | .driver_data = SB_HW_ALS100 }, | ||
115 | { .id = "" } /* end */ | ||
88 | }; | 116 | }; |
89 | 117 | ||
90 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); | 118 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); |
91 | 119 | ||
92 | #define DRIVER_NAME "snd-card-als100" | ||
93 | |||
94 | static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, | 120 | static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, |
95 | struct pnp_card_link *card, | 121 | struct pnp_card_link *card, |
96 | const struct pnp_card_device_id *id) | 122 | const struct pnp_card_device_id *id) |
@@ -113,8 +139,12 @@ static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, | |||
113 | return err; | 139 | return err; |
114 | } | 140 | } |
115 | port[dev] = pnp_port_start(pdev, 0); | 141 | port[dev] = pnp_port_start(pdev, 0); |
116 | dma8[dev] = pnp_dma(pdev, 1); | 142 | if (id->driver_data == SB_HW_DT019X) |
117 | dma16[dev] = pnp_dma(pdev, 0); | 143 | dma8[dev] = pnp_dma(pdev, 0); |
144 | else { | ||
145 | dma8[dev] = pnp_dma(pdev, 1); | ||
146 | dma16[dev] = pnp_dma(pdev, 0); | ||
147 | } | ||
118 | irq[dev] = pnp_irq(pdev, 0); | 148 | irq[dev] = pnp_irq(pdev, 0); |
119 | 149 | ||
120 | pdev = acard->devmpu; | 150 | pdev = acard->devmpu; |
@@ -175,22 +205,33 @@ static int __devinit snd_card_als100_probe(int dev, | |||
175 | } | 205 | } |
176 | snd_card_set_dev(card, &pcard->card->dev); | 206 | snd_card_set_dev(card, &pcard->card->dev); |
177 | 207 | ||
178 | if ((error = snd_sbdsp_create(card, port[dev], | 208 | if (pid->driver_data == SB_HW_DT019X) |
179 | irq[dev], | 209 | dma16[dev] = -1; |
180 | snd_sb16dsp_interrupt, | 210 | |
181 | dma8[dev], | 211 | error = snd_sbdsp_create(card, port[dev], irq[dev], |
182 | dma16[dev], | 212 | snd_sb16dsp_interrupt, |
183 | SB_HW_ALS100, &chip)) < 0) { | 213 | dma8[dev], dma16[dev], |
214 | pid->driver_data, | ||
215 | &chip); | ||
216 | if (error < 0) { | ||
184 | snd_card_free(card); | 217 | snd_card_free(card); |
185 | return error; | 218 | return error; |
186 | } | 219 | } |
187 | acard->chip = chip; | 220 | acard->chip = chip; |
188 | 221 | ||
189 | strcpy(card->driver, "ALS100"); | 222 | if (pid->driver_data == SB_HW_DT019X) { |
190 | strcpy(card->shortname, "Avance Logic ALS100"); | 223 | strcpy(card->driver, "DT-019X"); |
191 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 224 | strcpy(card->shortname, "Diamond Tech. DT-019X"); |
192 | card->shortname, chip->name, chip->port, | 225 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
193 | irq[dev], dma8[dev], dma16[dev]); | 226 | card->shortname, chip->name, chip->port, |
227 | irq[dev], dma8[dev]); | ||
228 | } else { | ||
229 | strcpy(card->driver, "ALS100"); | ||
230 | strcpy(card->shortname, "Avance Logic ALS100"); | ||
231 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | ||
232 | card->shortname, chip->name, chip->port, | ||
233 | irq[dev], dma8[dev], dma16[dev]); | ||
234 | } | ||
194 | 235 | ||
195 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | 236 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { |
196 | snd_card_free(card); | 237 | snd_card_free(card); |
@@ -203,9 +244,19 @@ static int __devinit snd_card_als100_probe(int dev, | |||
203 | } | 244 | } |
204 | 245 | ||
205 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | 246 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
206 | if (snd_mpu401_uart_new(card, 0, MPU401_HW_ALS100, | 247 | int mpu_type = MPU401_HW_ALS100; |
248 | |||
249 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
250 | mpu_irq[dev] = -1; | ||
251 | |||
252 | if (pid->driver_data == SB_HW_DT019X) | ||
253 | mpu_type = MPU401_HW_MPU401; | ||
254 | |||
255 | if (snd_mpu401_uart_new(card, 0, | ||
256 | mpu_type, | ||
207 | mpu_port[dev], 0, | 257 | mpu_port[dev], 0, |
208 | mpu_irq[dev], IRQF_DISABLED, | 258 | mpu_irq[dev], |
259 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
209 | NULL) < 0) | 260 | NULL) < 0) |
210 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); | 261 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); |
211 | } | 262 | } |
@@ -291,7 +342,7 @@ static int snd_als100_pnp_resume(struct pnp_card_link *pcard) | |||
291 | 342 | ||
292 | static struct pnp_card_driver als100_pnpc_driver = { | 343 | static struct pnp_card_driver als100_pnpc_driver = { |
293 | .flags = PNP_DRIVER_RES_DISABLE, | 344 | .flags = PNP_DRIVER_RES_DISABLE, |
294 | .name = "als100", | 345 | .name = "als100", |
295 | .id_table = snd_als100_pnpids, | 346 | .id_table = snd_als100_pnpids, |
296 | .probe = snd_als100_pnp_detect, | 347 | .probe = snd_als100_pnp_detect, |
297 | .remove = __devexit_p(snd_als100_pnp_remove), | 348 | .remove = __devexit_p(snd_als100_pnp_remove), |
@@ -312,7 +363,7 @@ static int __init alsa_card_als100_init(void) | |||
312 | if (!als100_devices) { | 363 | if (!als100_devices) { |
313 | pnp_unregister_card_driver(&als100_pnpc_driver); | 364 | pnp_unregister_card_driver(&als100_pnpc_driver); |
314 | #ifdef MODULE | 365 | #ifdef MODULE |
315 | snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); | 366 | snd_printk(KERN_ERR "no Avance Logic based soundcards found\n"); |
316 | #endif | 367 | #endif |
317 | return -ENODEV; | 368 | return -ENODEV; |
318 | } | 369 | } |
diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c deleted file mode 100644 index 80f5b1af9be8..000000000000 --- a/sound/isa/dt019x.c +++ /dev/null | |||
@@ -1,321 +0,0 @@ | |||
1 | |||
2 | /* | ||
3 | dt019x.c - driver for Diamond Technologies DT-0197H based soundcards. | ||
4 | Copyright (C) 1999, 2002 by Massimo Piccioni <dafastidio@libero.it> | ||
5 | |||
6 | Generalised for soundcards based on DT-0196 and ALS-007 chips | ||
7 | by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | #include <linux/init.h> | ||
25 | #include <linux/wait.h> | ||
26 | #include <linux/pnp.h> | ||
27 | #include <linux/moduleparam.h> | ||
28 | #include <sound/core.h> | ||
29 | #include <sound/initval.h> | ||
30 | #include <sound/mpu401.h> | ||
31 | #include <sound/opl3.h> | ||
32 | #include <sound/sb.h> | ||
33 | |||
34 | #define PFX "dt019x: " | ||
35 | |||
36 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | ||
37 | MODULE_DESCRIPTION("Diamond Technologies DT-019X / Avance Logic ALS-007"); | ||
38 | MODULE_LICENSE("GPL"); | ||
39 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," | ||
40 | "{Avance Logic ALS-007}}"); | ||
41 | |||
42 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
43 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
44 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | ||
45 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
46 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
47 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
48 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ | ||
49 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ | ||
50 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | ||
51 | |||
52 | module_param_array(index, int, NULL, 0444); | ||
53 | MODULE_PARM_DESC(index, "Index value for DT-019X based soundcard."); | ||
54 | module_param_array(id, charp, NULL, 0444); | ||
55 | MODULE_PARM_DESC(id, "ID string for DT-019X based soundcard."); | ||
56 | module_param_array(enable, bool, NULL, 0444); | ||
57 | MODULE_PARM_DESC(enable, "Enable DT-019X based soundcard."); | ||
58 | |||
59 | struct snd_card_dt019x { | ||
60 | struct pnp_dev *dev; | ||
61 | struct pnp_dev *devmpu; | ||
62 | struct pnp_dev *devopl; | ||
63 | struct snd_sb *chip; | ||
64 | }; | ||
65 | |||
66 | static struct pnp_card_device_id snd_dt019x_pnpids[] = { | ||
67 | /* DT197A30 */ | ||
68 | { .id = "RWB1688", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, | ||
69 | /* DT0196 / ALS-007 */ | ||
70 | { .id = "ALS0007", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, | ||
71 | { .id = "", } | ||
72 | }; | ||
73 | |||
74 | MODULE_DEVICE_TABLE(pnp_card, snd_dt019x_pnpids); | ||
75 | |||
76 | |||
77 | #define DRIVER_NAME "snd-card-dt019x" | ||
78 | |||
79 | |||
80 | static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, | ||
81 | struct pnp_card_link *card, | ||
82 | const struct pnp_card_device_id *pid) | ||
83 | { | ||
84 | struct pnp_dev *pdev; | ||
85 | int err; | ||
86 | |||
87 | acard->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); | ||
88 | if (acard->dev == NULL) | ||
89 | return -ENODEV; | ||
90 | |||
91 | acard->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
92 | acard->devopl = pnp_request_card_device(card, pid->devs[2].id, NULL); | ||
93 | |||
94 | pdev = acard->dev; | ||
95 | |||
96 | err = pnp_activate_dev(pdev); | ||
97 | if (err < 0) { | ||
98 | snd_printk(KERN_ERR PFX "DT-019X AUDIO pnp configure failure\n"); | ||
99 | return err; | ||
100 | } | ||
101 | |||
102 | port[dev] = pnp_port_start(pdev, 0); | ||
103 | dma8[dev] = pnp_dma(pdev, 0); | ||
104 | irq[dev] = pnp_irq(pdev, 0); | ||
105 | snd_printdd("dt019x: found audio interface: port=0x%lx, irq=0x%x, dma=0x%x\n", | ||
106 | port[dev],irq[dev],dma8[dev]); | ||
107 | |||
108 | pdev = acard->devmpu; | ||
109 | if (pdev != NULL) { | ||
110 | err = pnp_activate_dev(pdev); | ||
111 | if (err < 0) { | ||
112 | pnp_release_card_device(pdev); | ||
113 | snd_printk(KERN_ERR PFX "DT-019X MPU401 pnp configure failure, skipping\n"); | ||
114 | goto __mpu_error; | ||
115 | } | ||
116 | mpu_port[dev] = pnp_port_start(pdev, 0); | ||
117 | mpu_irq[dev] = pnp_irq(pdev, 0); | ||
118 | snd_printdd("dt019x: found MPU-401: port=0x%lx, irq=0x%x\n", | ||
119 | mpu_port[dev],mpu_irq[dev]); | ||
120 | } else { | ||
121 | __mpu_error: | ||
122 | acard->devmpu = NULL; | ||
123 | mpu_port[dev] = -1; | ||
124 | } | ||
125 | |||
126 | pdev = acard->devopl; | ||
127 | if (pdev != NULL) { | ||
128 | err = pnp_activate_dev(pdev); | ||
129 | if (err < 0) { | ||
130 | pnp_release_card_device(pdev); | ||
131 | snd_printk(KERN_ERR PFX "DT-019X OPL3 pnp configure failure, skipping\n"); | ||
132 | goto __fm_error; | ||
133 | } | ||
134 | fm_port[dev] = pnp_port_start(pdev, 0); | ||
135 | snd_printdd("dt019x: found OPL3 synth: port=0x%lx\n",fm_port[dev]); | ||
136 | } else { | ||
137 | __fm_error: | ||
138 | acard->devopl = NULL; | ||
139 | fm_port[dev] = -1; | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) | ||
146 | { | ||
147 | int error; | ||
148 | struct snd_sb *chip; | ||
149 | struct snd_card *card; | ||
150 | struct snd_card_dt019x *acard; | ||
151 | struct snd_opl3 *opl3; | ||
152 | |||
153 | error = snd_card_create(index[dev], id[dev], THIS_MODULE, | ||
154 | sizeof(struct snd_card_dt019x), &card); | ||
155 | if (error < 0) | ||
156 | return error; | ||
157 | acard = card->private_data; | ||
158 | |||
159 | snd_card_set_dev(card, &pcard->card->dev); | ||
160 | if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { | ||
161 | snd_card_free(card); | ||
162 | return error; | ||
163 | } | ||
164 | |||
165 | if ((error = snd_sbdsp_create(card, port[dev], | ||
166 | irq[dev], | ||
167 | snd_sb16dsp_interrupt, | ||
168 | dma8[dev], | ||
169 | -1, | ||
170 | SB_HW_DT019X, | ||
171 | &chip)) < 0) { | ||
172 | snd_card_free(card); | ||
173 | return error; | ||
174 | } | ||
175 | acard->chip = chip; | ||
176 | |||
177 | strcpy(card->driver, "DT-019X"); | ||
178 | strcpy(card->shortname, "Diamond Tech. DT-019X"); | ||
179 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | ||
180 | card->shortname, chip->name, chip->port, | ||
181 | irq[dev], dma8[dev]); | ||
182 | |||
183 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | ||
184 | snd_card_free(card); | ||
185 | return error; | ||
186 | } | ||
187 | if ((error = snd_sbmixer_new(chip)) < 0) { | ||
188 | snd_card_free(card); | ||
189 | return error; | ||
190 | } | ||
191 | |||
192 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | ||
193 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
194 | mpu_irq[dev] = -1; | ||
195 | if (snd_mpu401_uart_new(card, 0, | ||
196 | /* MPU401_HW_SB,*/ | ||
197 | MPU401_HW_MPU401, | ||
198 | mpu_port[dev], 0, | ||
199 | mpu_irq[dev], | ||
200 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
201 | NULL) < 0) | ||
202 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]); | ||
203 | } | ||
204 | |||
205 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | ||
206 | if (snd_opl3_create(card, | ||
207 | fm_port[dev], | ||
208 | fm_port[dev] + 2, | ||
209 | OPL3_HW_AUTO, 0, &opl3) < 0) { | ||
210 | snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n", | ||
211 | fm_port[dev], fm_port[dev] + 2); | ||
212 | } else { | ||
213 | if ((error = snd_opl3_timer_new(opl3, 0, 1)) < 0) { | ||
214 | snd_card_free(card); | ||
215 | return error; | ||
216 | } | ||
217 | if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { | ||
218 | snd_card_free(card); | ||
219 | return error; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | if ((error = snd_card_register(card)) < 0) { | ||
225 | snd_card_free(card); | ||
226 | return error; | ||
227 | } | ||
228 | pnp_set_card_drvdata(pcard, card); | ||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | static unsigned int __devinitdata dt019x_devices; | ||
233 | |||
234 | static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, | ||
235 | const struct pnp_card_device_id *pid) | ||
236 | { | ||
237 | static int dev; | ||
238 | int res; | ||
239 | |||
240 | for ( ; dev < SNDRV_CARDS; dev++) { | ||
241 | if (!enable[dev]) | ||
242 | continue; | ||
243 | res = snd_card_dt019x_probe(dev, card, pid); | ||
244 | if (res < 0) | ||
245 | return res; | ||
246 | dev++; | ||
247 | dt019x_devices++; | ||
248 | return 0; | ||
249 | } | ||
250 | return -ENODEV; | ||
251 | } | ||
252 | |||
253 | static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) | ||
254 | { | ||
255 | snd_card_free(pnp_get_card_drvdata(pcard)); | ||
256 | pnp_set_card_drvdata(pcard, NULL); | ||
257 | } | ||
258 | |||
259 | #ifdef CONFIG_PM | ||
260 | static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) | ||
261 | { | ||
262 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
263 | struct snd_card_dt019x *acard = card->private_data; | ||
264 | struct snd_sb *chip = acard->chip; | ||
265 | |||
266 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
267 | snd_pcm_suspend_all(chip->pcm); | ||
268 | snd_sbmixer_suspend(chip); | ||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard) | ||
273 | { | ||
274 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
275 | struct snd_card_dt019x *acard = card->private_data; | ||
276 | struct snd_sb *chip = acard->chip; | ||
277 | |||
278 | snd_sbdsp_reset(chip); | ||
279 | snd_sbmixer_resume(chip); | ||
280 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
281 | return 0; | ||
282 | } | ||
283 | #endif | ||
284 | |||
285 | static struct pnp_card_driver dt019x_pnpc_driver = { | ||
286 | .flags = PNP_DRIVER_RES_DISABLE, | ||
287 | .name = "dt019x", | ||
288 | .id_table = snd_dt019x_pnpids, | ||
289 | .probe = snd_dt019x_pnp_probe, | ||
290 | .remove = __devexit_p(snd_dt019x_pnp_remove), | ||
291 | #ifdef CONFIG_PM | ||
292 | .suspend = snd_dt019x_pnp_suspend, | ||
293 | .resume = snd_dt019x_pnp_resume, | ||
294 | #endif | ||
295 | }; | ||
296 | |||
297 | static int __init alsa_card_dt019x_init(void) | ||
298 | { | ||
299 | int err; | ||
300 | |||
301 | err = pnp_register_card_driver(&dt019x_pnpc_driver); | ||
302 | if (err) | ||
303 | return err; | ||
304 | |||
305 | if (!dt019x_devices) { | ||
306 | pnp_unregister_card_driver(&dt019x_pnpc_driver); | ||
307 | #ifdef MODULE | ||
308 | snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); | ||
309 | #endif | ||
310 | return -ENODEV; | ||
311 | } | ||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | static void __exit alsa_card_dt019x_exit(void) | ||
316 | { | ||
317 | pnp_unregister_card_driver(&dt019x_pnpc_driver); | ||
318 | } | ||
319 | |||
320 | module_init(alsa_card_dt019x_init) | ||
321 | module_exit(alsa_card_dt019x_exit) | ||
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index 661205c4dcea..af888a022fc0 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c | |||
@@ -127,7 +127,8 @@ static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc, | |||
127 | !share_id[2] && !share_id[3]) | 127 | !share_id[2] && !share_id[3]) |
128 | return NULL; | 128 | return NULL; |
129 | for (block = alloc->first; block; block = block->next) | 129 | for (block = alloc->first; block; block = block->next) |
130 | if (!memcmp(share_id, block->share_id, sizeof(share_id))) | 130 | if (!memcmp(share_id, block->share_id, |
131 | sizeof(block->share_id))) | ||
131 | return block; | 132 | return block; |
132 | return NULL; | 133 | return NULL; |
133 | } | 134 | } |
diff --git a/sound/isa/msnd/msnd_midi.c b/sound/isa/msnd/msnd_midi.c index cb9aa4c4edd0..4be562b2cf21 100644 --- a/sound/isa/msnd/msnd_midi.c +++ b/sound/isa/msnd/msnd_midi.c | |||
@@ -162,7 +162,7 @@ int snd_msndmidi_new(struct snd_card *card, int device) | |||
162 | err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); | 162 | err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); |
163 | if (err < 0) | 163 | if (err < 0) |
164 | return err; | 164 | return err; |
165 | mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL); | 165 | mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); |
166 | if (mpu == NULL) { | 166 | if (mpu == NULL) { |
167 | snd_device_free(card, rmidi); | 167 | snd_device_free(card, rmidi); |
168 | return -ENOMEM; | 168 | return -ENOMEM; |
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index c8a8da0d4036..a4af53b5c1cf 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <asm/dma.h> | 34 | #include <asm/dma.h> |
35 | #include <sound/core.h> | 35 | #include <sound/core.h> |
36 | #include <sound/tlv.h> | ||
36 | #include <sound/wss.h> | 37 | #include <sound/wss.h> |
37 | #include <sound/mpu401.h> | 38 | #include <sound/mpu401.h> |
38 | #include <sound/opl3.h> | 39 | #include <sound/opl3.h> |
@@ -546,6 +547,93 @@ __skip_mpu: | |||
546 | 547 | ||
547 | #ifdef OPTi93X | 548 | #ifdef OPTi93X |
548 | 549 | ||
550 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0); | ||
551 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0); | ||
552 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0); | ||
553 | |||
554 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
555 | WSS_DOUBLE("Master Playback Switch", 0, | ||
556 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
557 | WSS_DOUBLE_TLV("Master Playback Volume", 0, | ||
558 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, | ||
559 | db_scale_5bit_3db_step), | ||
560 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, | ||
561 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1, | ||
562 | db_scale_5bit), | ||
563 | WSS_DOUBLE_TLV("FM Playback Volume", 0, | ||
564 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1, | ||
565 | db_scale_4bit_12db_max), | ||
566 | WSS_DOUBLE("Line Playback Switch", 0, | ||
567 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
568 | WSS_DOUBLE_TLV("Line Playback Volume", 0, | ||
569 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1, | ||
570 | db_scale_4bit_12db_max), | ||
571 | WSS_DOUBLE("Mic Playback Switch", 0, | ||
572 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | ||
573 | WSS_DOUBLE_TLV("Mic Playback Volume", 0, | ||
574 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1, | ||
575 | db_scale_4bit_12db_max), | ||
576 | WSS_DOUBLE_TLV("CD Playback Volume", 0, | ||
577 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1, | ||
578 | db_scale_4bit_12db_max), | ||
579 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
580 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
581 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, | ||
582 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1, | ||
583 | db_scale_4bit_12db_max), | ||
584 | }; | ||
585 | |||
586 | static int __devinit snd_opti93x_mixer(struct snd_wss *chip) | ||
587 | { | ||
588 | struct snd_card *card; | ||
589 | unsigned int idx; | ||
590 | struct snd_ctl_elem_id id1, id2; | ||
591 | int err; | ||
592 | |||
593 | if (snd_BUG_ON(!chip || !chip->pcm)) | ||
594 | return -EINVAL; | ||
595 | |||
596 | card = chip->card; | ||
597 | |||
598 | strcpy(card->mixername, chip->pcm->name); | ||
599 | |||
600 | memset(&id1, 0, sizeof(id1)); | ||
601 | memset(&id2, 0, sizeof(id2)); | ||
602 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
603 | /* reassign AUX0 switch to CD */ | ||
604 | strcpy(id1.name, "Aux Playback Switch"); | ||
605 | strcpy(id2.name, "CD Playback Switch"); | ||
606 | err = snd_ctl_rename_id(card, &id1, &id2); | ||
607 | if (err < 0) { | ||
608 | snd_printk(KERN_ERR "Cannot rename opti93x control\n"); | ||
609 | return err; | ||
610 | } | ||
611 | /* reassign AUX1 switch to FM */ | ||
612 | strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; | ||
613 | strcpy(id2.name, "FM Playback Switch"); | ||
614 | err = snd_ctl_rename_id(card, &id1, &id2); | ||
615 | if (err < 0) { | ||
616 | snd_printk(KERN_ERR "Cannot rename opti93x control\n"); | ||
617 | return err; | ||
618 | } | ||
619 | /* remove AUX1 volume */ | ||
620 | strcpy(id1.name, "Aux Playback Volume"); id1.index = 1; | ||
621 | snd_ctl_remove_id(card, &id1); | ||
622 | |||
623 | /* Replace WSS volume controls with OPTi93x volume controls */ | ||
624 | id1.index = 0; | ||
625 | for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { | ||
626 | strcpy(id1.name, snd_opti93x_controls[idx].name); | ||
627 | snd_ctl_remove_id(card, &id1); | ||
628 | |||
629 | err = snd_ctl_add(card, | ||
630 | snd_ctl_new1(&snd_opti93x_controls[idx], chip)); | ||
631 | if (err < 0) | ||
632 | return err; | ||
633 | } | ||
634 | return 0; | ||
635 | } | ||
636 | |||
549 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | 637 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
550 | { | 638 | { |
551 | struct snd_opti9xx *chip = dev_id; | 639 | struct snd_opti9xx *chip = dev_id; |
@@ -754,6 +842,11 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
754 | error = snd_wss_mixer(codec); | 842 | error = snd_wss_mixer(codec); |
755 | if (error < 0) | 843 | if (error < 0) |
756 | return error; | 844 | return error; |
845 | #ifdef OPTi93X | ||
846 | error = snd_opti93x_mixer(codec); | ||
847 | if (error < 0) | ||
848 | return error; | ||
849 | #endif | ||
757 | #ifdef CS4231 | 850 | #ifdef CS4231 |
758 | error = snd_wss_timer(codec, 0, &timer); | 851 | error = snd_wss_timer(codec, 0, &timer); |
759 | if (error < 0) | 852 | if (error < 0) |
diff --git a/sound/isa/sb/Makefile b/sound/isa/sb/Makefile index faeffceb01b7..af3669681788 100644 --- a/sound/isa/sb/Makefile +++ b/sound/isa/sb/Makefile | |||
@@ -12,6 +12,7 @@ snd-sb16-objs := sb16.o | |||
12 | snd-sbawe-objs := sbawe.o emu8000.o | 12 | snd-sbawe-objs := sbawe.o emu8000.o |
13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o | 13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o |
14 | snd-es968-objs := es968.o | 14 | snd-es968-objs := es968.o |
15 | snd-jazz16-objs := jazz16.o | ||
15 | 16 | ||
16 | # Toplevel Module Dependency | 17 | # Toplevel Module Dependency |
17 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o | 18 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o |
@@ -21,6 +22,7 @@ obj-$(CONFIG_SND_SB8) += snd-sb8.o | |||
21 | obj-$(CONFIG_SND_SB16) += snd-sb16.o | 22 | obj-$(CONFIG_SND_SB16) += snd-sb16.o |
22 | obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o | 23 | obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o |
23 | obj-$(CONFIG_SND_ES968) += snd-es968.o | 24 | obj-$(CONFIG_SND_ES968) += snd-es968.o |
25 | obj-$(CONFIG_SND_JAZZ16) += snd-jazz16.o | ||
24 | ifeq ($(CONFIG_SND_SB16_CSP),y) | 26 | ifeq ($(CONFIG_SND_SB16_CSP),y) |
25 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o | 27 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o |
26 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o | 28 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o |
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 96678d5d3834..751762f1c59a 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c | |||
@@ -393,8 +393,6 @@ size_dram(struct snd_emu8000 *emu) | |||
393 | 393 | ||
394 | while (size < EMU8000_MAX_DRAM) { | 394 | while (size < EMU8000_MAX_DRAM) { |
395 | 395 | ||
396 | size += 512 * 1024; /* increment 512kbytes */ | ||
397 | |||
398 | /* Write a unique data on the test address. | 396 | /* Write a unique data on the test address. |
399 | * if the address is out of range, the data is written on | 397 | * if the address is out of range, the data is written on |
400 | * 0x200000(=EMU8000_DRAM_OFFSET). Then the id word is | 398 | * 0x200000(=EMU8000_DRAM_OFFSET). Then the id word is |
@@ -414,7 +412,9 @@ size_dram(struct snd_emu8000 *emu) | |||
414 | /*snd_emu8000_read_wait(emu);*/ | 412 | /*snd_emu8000_read_wait(emu);*/ |
415 | EMU8000_SMLD_READ(emu); /* discard stale data */ | 413 | EMU8000_SMLD_READ(emu); /* discard stale data */ |
416 | if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2) | 414 | if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2) |
417 | break; /* we must have wrapped around */ | 415 | break; /* no memory at this address */ |
416 | |||
417 | size += 512 * 1024; /* increment 512kbytes */ | ||
418 | 418 | ||
419 | snd_emu8000_read_wait(emu); | 419 | snd_emu8000_read_wait(emu); |
420 | 420 | ||
diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c new file mode 100644 index 000000000000..8d21a3feda3a --- /dev/null +++ b/sound/isa/sb/jazz16.c | |||
@@ -0,0 +1,404 @@ | |||
1 | |||
2 | /* | ||
3 | * jazz16.c - driver for Media Vision Jazz16 based soundcards. | ||
4 | * Copyright (C) 2009 Krzysztof Helt <krzysztof.h1@wp.pl> | ||
5 | * Based on patches posted by Rask Ingemann Lambertsen and Rene Herman. | ||
6 | * Based on OSS Sound Blaster driver. | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <asm/dma.h> | ||
18 | #include <linux/isa.h> | ||
19 | #include <sound/core.h> | ||
20 | #include <sound/mpu401.h> | ||
21 | #include <sound/opl3.h> | ||
22 | #include <sound/sb.h> | ||
23 | #define SNDRV_LEGACY_FIND_FREE_IRQ | ||
24 | #define SNDRV_LEGACY_FIND_FREE_DMA | ||
25 | #include <sound/initval.h> | ||
26 | |||
27 | #define PFX "jazz16: " | ||
28 | |||
29 | MODULE_DESCRIPTION("Media Vision Jazz16"); | ||
30 | MODULE_SUPPORTED_DEVICE("{{Media Vision ??? }," | ||
31 | "{RTL,RTL3000}}"); | ||
32 | |||
33 | MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>"); | ||
34 | MODULE_LICENSE("GPL"); | ||
35 | |||
36 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
37 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
38 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | ||
39 | static unsigned long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
40 | static unsigned long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
41 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
42 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
43 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
44 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
45 | |||
46 | module_param_array(index, int, NULL, 0444); | ||
47 | MODULE_PARM_DESC(index, "Index value for Media Vision Jazz16 based soundcard."); | ||
48 | module_param_array(id, charp, NULL, 0444); | ||
49 | MODULE_PARM_DESC(id, "ID string for Media Vision Jazz16 based soundcard."); | ||
50 | module_param_array(enable, bool, NULL, 0444); | ||
51 | MODULE_PARM_DESC(enable, "Enable Media Vision Jazz16 based soundcard."); | ||
52 | module_param_array(port, long, NULL, 0444); | ||
53 | MODULE_PARM_DESC(port, "Port # for jazz16 driver."); | ||
54 | module_param_array(mpu_port, long, NULL, 0444); | ||
55 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for jazz16 driver."); | ||
56 | module_param_array(irq, int, NULL, 0444); | ||
57 | MODULE_PARM_DESC(irq, "IRQ # for jazz16 driver."); | ||
58 | module_param_array(mpu_irq, int, NULL, 0444); | ||
59 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for jazz16 driver."); | ||
60 | module_param_array(dma8, int, NULL, 0444); | ||
61 | MODULE_PARM_DESC(dma8, "DMA8 # for jazz16 driver."); | ||
62 | module_param_array(dma16, int, NULL, 0444); | ||
63 | MODULE_PARM_DESC(dma16, "DMA16 # for jazz16 driver."); | ||
64 | |||
65 | #define SB_JAZZ16_WAKEUP 0xaf | ||
66 | #define SB_JAZZ16_SET_PORTS 0x50 | ||
67 | #define SB_DSP_GET_JAZZ_BRD_REV 0xfa | ||
68 | #define SB_JAZZ16_SET_DMAINTR 0xfb | ||
69 | #define SB_DSP_GET_JAZZ_MODEL 0xfe | ||
70 | |||
71 | struct snd_card_jazz16 { | ||
72 | struct snd_sb *chip; | ||
73 | }; | ||
74 | |||
75 | static irqreturn_t jazz16_interrupt(int irq, void *chip) | ||
76 | { | ||
77 | return snd_sb8dsp_interrupt(chip); | ||
78 | } | ||
79 | |||
80 | static int __devinit jazz16_configure_ports(unsigned long port, | ||
81 | unsigned long mpu_port, int idx) | ||
82 | { | ||
83 | unsigned char val; | ||
84 | |||
85 | if (!request_region(0x201, 1, "jazz16 config")) { | ||
86 | snd_printk(KERN_ERR "config port region is already in use.\n"); | ||
87 | return -EBUSY; | ||
88 | } | ||
89 | outb(SB_JAZZ16_WAKEUP - idx, 0x201); | ||
90 | udelay(100); | ||
91 | outb(SB_JAZZ16_SET_PORTS + idx, 0x201); | ||
92 | udelay(100); | ||
93 | val = port & 0x70; | ||
94 | val |= (mpu_port & 0x30) >> 4; | ||
95 | outb(val, 0x201); | ||
96 | |||
97 | release_region(0x201, 1); | ||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static int __devinit jazz16_detect_board(unsigned long port, | ||
102 | unsigned long mpu_port) | ||
103 | { | ||
104 | int err; | ||
105 | int val; | ||
106 | struct snd_sb chip; | ||
107 | |||
108 | if (!request_region(port, 0x10, "jazz16")) { | ||
109 | snd_printk(KERN_ERR "I/O port region is already in use.\n"); | ||
110 | return -EBUSY; | ||
111 | } | ||
112 | /* just to call snd_sbdsp_command/reset/get_byte() */ | ||
113 | chip.port = port; | ||
114 | |||
115 | err = snd_sbdsp_reset(&chip); | ||
116 | if (err < 0) | ||
117 | for (val = 0; val < 4; val++) { | ||
118 | err = jazz16_configure_ports(port, mpu_port, val); | ||
119 | if (err < 0) | ||
120 | break; | ||
121 | |||
122 | err = snd_sbdsp_reset(&chip); | ||
123 | if (!err) | ||
124 | break; | ||
125 | } | ||
126 | if (err < 0) { | ||
127 | err = -ENODEV; | ||
128 | goto err_unmap; | ||
129 | } | ||
130 | if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_BRD_REV)) { | ||
131 | err = -EBUSY; | ||
132 | goto err_unmap; | ||
133 | } | ||
134 | val = snd_sbdsp_get_byte(&chip); | ||
135 | if (val >= 0x30) | ||
136 | snd_sbdsp_get_byte(&chip); | ||
137 | |||
138 | if ((val & 0xf0) != 0x10) { | ||
139 | err = -ENODEV; | ||
140 | goto err_unmap; | ||
141 | } | ||
142 | if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_MODEL)) { | ||
143 | err = -EBUSY; | ||
144 | goto err_unmap; | ||
145 | } | ||
146 | snd_sbdsp_get_byte(&chip); | ||
147 | err = snd_sbdsp_get_byte(&chip); | ||
148 | snd_printd("Media Vision Jazz16 board detected: rev 0x%x, model 0x%x\n", | ||
149 | val, err); | ||
150 | |||
151 | err = 0; | ||
152 | |||
153 | err_unmap: | ||
154 | release_region(port, 0x10); | ||
155 | return err; | ||
156 | } | ||
157 | |||
158 | static int __devinit jazz16_configure_board(struct snd_sb *chip, int mpu_irq) | ||
159 | { | ||
160 | static unsigned char jazz_irq_bits[] = { 0, 0, 2, 3, 0, 1, 0, 4, | ||
161 | 0, 2, 5, 0, 0, 0, 0, 6 }; | ||
162 | static unsigned char jazz_dma_bits[] = { 0, 1, 0, 2, 0, 3, 0, 4 }; | ||
163 | |||
164 | if (jazz_dma_bits[chip->dma8] == 0 || | ||
165 | jazz_dma_bits[chip->dma16] == 0 || | ||
166 | jazz_irq_bits[chip->irq] == 0) | ||
167 | return -EINVAL; | ||
168 | |||
169 | if (!snd_sbdsp_command(chip, SB_JAZZ16_SET_DMAINTR)) | ||
170 | return -EBUSY; | ||
171 | |||
172 | if (!snd_sbdsp_command(chip, | ||
173 | jazz_dma_bits[chip->dma8] | | ||
174 | (jazz_dma_bits[chip->dma16] << 4))) | ||
175 | return -EBUSY; | ||
176 | |||
177 | if (!snd_sbdsp_command(chip, | ||
178 | jazz_irq_bits[chip->irq] | | ||
179 | (jazz_irq_bits[mpu_irq] << 4))) | ||
180 | return -EBUSY; | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int __devinit snd_jazz16_match(struct device *devptr, unsigned int dev) | ||
186 | { | ||
187 | if (!enable[dev]) | ||
188 | return 0; | ||
189 | if (port[dev] == SNDRV_AUTO_PORT) { | ||
190 | snd_printk(KERN_ERR "please specify port\n"); | ||
191 | return 0; | ||
192 | } else if (port[dev] == 0x200 || (port[dev] & ~0x270)) { | ||
193 | snd_printk(KERN_ERR "incorrect port specified\n"); | ||
194 | return 0; | ||
195 | } | ||
196 | if (dma8[dev] != SNDRV_AUTO_DMA && | ||
197 | dma8[dev] != 1 && dma8[dev] != 3) { | ||
198 | snd_printk(KERN_ERR "dma8 must be 1 or 3\n"); | ||
199 | return 0; | ||
200 | } | ||
201 | if (dma16[dev] != SNDRV_AUTO_DMA && | ||
202 | dma16[dev] != 5 && dma16[dev] != 7) { | ||
203 | snd_printk(KERN_ERR "dma16 must be 5 or 7\n"); | ||
204 | return 0; | ||
205 | } | ||
206 | if (mpu_port[dev] != SNDRV_AUTO_PORT && | ||
207 | (mpu_port[dev] & ~0x030) != 0x300) { | ||
208 | snd_printk(KERN_ERR "incorrect mpu_port specified\n"); | ||
209 | return 0; | ||
210 | } | ||
211 | if (mpu_irq[dev] != SNDRV_AUTO_DMA && | ||
212 | mpu_irq[dev] != 2 && mpu_irq[dev] != 3 && | ||
213 | mpu_irq[dev] != 5 && mpu_irq[dev] != 7) { | ||
214 | snd_printk(KERN_ERR "mpu_irq must be 2, 3, 5 or 7\n"); | ||
215 | return 0; | ||
216 | } | ||
217 | return 1; | ||
218 | } | ||
219 | |||
220 | static int __devinit snd_jazz16_probe(struct device *devptr, unsigned int dev) | ||
221 | { | ||
222 | struct snd_card *card; | ||
223 | struct snd_card_jazz16 *jazz16; | ||
224 | struct snd_sb *chip; | ||
225 | struct snd_opl3 *opl3; | ||
226 | static int possible_irqs[] = {2, 3, 5, 7, 9, 10, 15, -1}; | ||
227 | static int possible_dmas8[] = {1, 3, -1}; | ||
228 | static int possible_dmas16[] = {5, 7, -1}; | ||
229 | int err, xirq, xdma8, xdma16, xmpu_port, xmpu_irq; | ||
230 | |||
231 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, | ||
232 | sizeof(struct snd_card_jazz16), &card); | ||
233 | if (err < 0) | ||
234 | return err; | ||
235 | |||
236 | jazz16 = card->private_data; | ||
237 | |||
238 | xirq = irq[dev]; | ||
239 | if (xirq == SNDRV_AUTO_IRQ) { | ||
240 | xirq = snd_legacy_find_free_irq(possible_irqs); | ||
241 | if (xirq < 0) { | ||
242 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
243 | err = -EBUSY; | ||
244 | goto err_free; | ||
245 | } | ||
246 | } | ||
247 | xdma8 = dma8[dev]; | ||
248 | if (xdma8 == SNDRV_AUTO_DMA) { | ||
249 | xdma8 = snd_legacy_find_free_dma(possible_dmas8); | ||
250 | if (xdma8 < 0) { | ||
251 | snd_printk(KERN_ERR "unable to find a free DMA8\n"); | ||
252 | err = -EBUSY; | ||
253 | goto err_free; | ||
254 | } | ||
255 | } | ||
256 | xdma16 = dma16[dev]; | ||
257 | if (xdma16 == SNDRV_AUTO_DMA) { | ||
258 | xdma16 = snd_legacy_find_free_dma(possible_dmas16); | ||
259 | if (xdma16 < 0) { | ||
260 | snd_printk(KERN_ERR "unable to find a free DMA16\n"); | ||
261 | err = -EBUSY; | ||
262 | goto err_free; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | xmpu_port = mpu_port[dev]; | ||
267 | if (xmpu_port == SNDRV_AUTO_PORT) | ||
268 | xmpu_port = 0; | ||
269 | err = jazz16_detect_board(port[dev], xmpu_port); | ||
270 | if (err < 0) { | ||
271 | printk(KERN_ERR "Media Vision Jazz16 board not detected\n"); | ||
272 | goto err_free; | ||
273 | } | ||
274 | err = snd_sbdsp_create(card, port[dev], irq[dev], | ||
275 | jazz16_interrupt, | ||
276 | dma8[dev], dma16[dev], | ||
277 | SB_HW_JAZZ16, | ||
278 | &chip); | ||
279 | if (err < 0) | ||
280 | goto err_free; | ||
281 | |||
282 | xmpu_irq = mpu_irq[dev]; | ||
283 | if (xmpu_irq == SNDRV_AUTO_IRQ || mpu_port[dev] == SNDRV_AUTO_PORT) | ||
284 | xmpu_irq = 0; | ||
285 | err = jazz16_configure_board(chip, xmpu_irq); | ||
286 | if (err < 0) { | ||
287 | printk(KERN_ERR "Media Vision Jazz16 configuration failed\n"); | ||
288 | goto err_free; | ||
289 | } | ||
290 | |||
291 | jazz16->chip = chip; | ||
292 | |||
293 | strcpy(card->driver, "jazz16"); | ||
294 | strcpy(card->shortname, "Media Vision Jazz16"); | ||
295 | sprintf(card->longname, | ||
296 | "Media Vision Jazz16 at 0x%lx, irq %d, dma8 %d, dma16 %d", | ||
297 | port[dev], xirq, xdma8, xdma16); | ||
298 | |||
299 | err = snd_sb8dsp_pcm(chip, 0, NULL); | ||
300 | if (err < 0) | ||
301 | goto err_free; | ||
302 | err = snd_sbmixer_new(chip); | ||
303 | if (err < 0) | ||
304 | goto err_free; | ||
305 | |||
306 | err = snd_opl3_create(card, chip->port, chip->port + 2, | ||
307 | OPL3_HW_AUTO, 1, &opl3); | ||
308 | if (err < 0) | ||
309 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", | ||
310 | chip->port, chip->port + 2); | ||
311 | else { | ||
312 | err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); | ||
313 | if (err < 0) | ||
314 | goto err_free; | ||
315 | } | ||
316 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | ||
317 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
318 | mpu_irq[dev] = -1; | ||
319 | |||
320 | if (snd_mpu401_uart_new(card, 0, | ||
321 | MPU401_HW_MPU401, | ||
322 | mpu_port[dev], 0, | ||
323 | mpu_irq[dev], | ||
324 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
325 | NULL) < 0) | ||
326 | snd_printk(KERN_ERR "no MPU-401 device at 0x%lx\n", | ||
327 | mpu_port[dev]); | ||
328 | } | ||
329 | |||
330 | snd_card_set_dev(card, devptr); | ||
331 | |||
332 | err = snd_card_register(card); | ||
333 | if (err < 0) | ||
334 | goto err_free; | ||
335 | |||
336 | dev_set_drvdata(devptr, card); | ||
337 | return 0; | ||
338 | |||
339 | err_free: | ||
340 | snd_card_free(card); | ||
341 | return err; | ||
342 | } | ||
343 | |||
344 | static int __devexit snd_jazz16_remove(struct device *devptr, unsigned int dev) | ||
345 | { | ||
346 | struct snd_card *card = dev_get_drvdata(devptr); | ||
347 | |||
348 | dev_set_drvdata(devptr, NULL); | ||
349 | snd_card_free(card); | ||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | #ifdef CONFIG_PM | ||
354 | static int snd_jazz16_suspend(struct device *pdev, unsigned int n, | ||
355 | pm_message_t state) | ||
356 | { | ||
357 | struct snd_card *card = dev_get_drvdata(pdev); | ||
358 | struct snd_card_jazz16 *acard = card->private_data; | ||
359 | struct snd_sb *chip = acard->chip; | ||
360 | |||
361 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
362 | snd_pcm_suspend_all(chip->pcm); | ||
363 | snd_sbmixer_suspend(chip); | ||
364 | return 0; | ||
365 | } | ||
366 | |||
367 | static int snd_jazz16_resume(struct device *pdev, unsigned int n) | ||
368 | { | ||
369 | struct snd_card *card = dev_get_drvdata(pdev); | ||
370 | struct snd_card_jazz16 *acard = card->private_data; | ||
371 | struct snd_sb *chip = acard->chip; | ||
372 | |||
373 | snd_sbdsp_reset(chip); | ||
374 | snd_sbmixer_resume(chip); | ||
375 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
376 | return 0; | ||
377 | } | ||
378 | #endif | ||
379 | |||
380 | static struct isa_driver snd_jazz16_driver = { | ||
381 | .match = snd_jazz16_match, | ||
382 | .probe = snd_jazz16_probe, | ||
383 | .remove = __devexit_p(snd_jazz16_remove), | ||
384 | #ifdef CONFIG_PM | ||
385 | .suspend = snd_jazz16_suspend, | ||
386 | .resume = snd_jazz16_resume, | ||
387 | #endif | ||
388 | .driver = { | ||
389 | .name = "jazz16" | ||
390 | }, | ||
391 | }; | ||
392 | |||
393 | static int __init alsa_card_jazz16_init(void) | ||
394 | { | ||
395 | return isa_register_driver(&snd_jazz16_driver, SNDRV_CARDS); | ||
396 | } | ||
397 | |||
398 | static void __exit alsa_card_jazz16_exit(void) | ||
399 | { | ||
400 | isa_unregister_driver(&snd_jazz16_driver); | ||
401 | } | ||
402 | |||
403 | module_init(alsa_card_jazz16_init) | ||
404 | module_exit(alsa_card_jazz16_exit) | ||
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 658d55769c9c..7d84c9f34dc9 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c | |||
@@ -106,9 +106,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
107 | struct snd_pcm_runtime *runtime = substream->runtime; | 107 | struct snd_pcm_runtime *runtime = substream->runtime; |
108 | unsigned int mixreg, rate, size, count; | 108 | unsigned int mixreg, rate, size, count; |
109 | unsigned char format; | ||
110 | unsigned char stereo = runtime->channels > 1; | ||
111 | int dma; | ||
109 | 112 | ||
110 | rate = runtime->rate; | 113 | rate = runtime->rate; |
111 | switch (chip->hardware) { | 114 | switch (chip->hardware) { |
115 | case SB_HW_JAZZ16: | ||
116 | if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { | ||
117 | if (chip->mode & SB_MODE_CAPTURE_16) | ||
118 | return -EBUSY; | ||
119 | else | ||
120 | chip->mode |= SB_MODE_PLAYBACK_16; | ||
121 | } | ||
122 | chip->playback_format = SB_DSP_LO_OUTPUT_AUTO; | ||
123 | break; | ||
112 | case SB_HW_PRO: | 124 | case SB_HW_PRO: |
113 | if (runtime->channels > 1) { | 125 | if (runtime->channels > 1) { |
114 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 126 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
@@ -133,11 +145,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
133 | default: | 145 | default: |
134 | return -EINVAL; | 146 | return -EINVAL; |
135 | } | 147 | } |
148 | if (chip->mode & SB_MODE_PLAYBACK_16) { | ||
149 | format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; | ||
150 | dma = chip->dma16; | ||
151 | } else { | ||
152 | format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; | ||
153 | chip->mode |= SB_MODE_PLAYBACK_8; | ||
154 | dma = chip->dma8; | ||
155 | } | ||
136 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); | 156 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); |
137 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); | 157 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); |
138 | spin_lock_irqsave(&chip->reg_lock, flags); | 158 | spin_lock_irqsave(&chip->reg_lock, flags); |
139 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); | 159 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); |
140 | if (runtime->channels > 1) { | 160 | if (chip->hardware == SB_HW_JAZZ16) |
161 | snd_sbdsp_command(chip, format); | ||
162 | else if (stereo) { | ||
141 | /* set playback stereo mode */ | 163 | /* set playback stereo mode */ |
142 | spin_lock(&chip->mixer_lock); | 164 | spin_lock(&chip->mixer_lock); |
143 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); | 165 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); |
@@ -147,15 +169,14 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
147 | /* Soundblaster hardware programming reference guide, 3-23 */ | 169 | /* Soundblaster hardware programming reference guide, 3-23 */ |
148 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); | 170 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); |
149 | runtime->dma_area[0] = 0x80; | 171 | runtime->dma_area[0] = 0x80; |
150 | snd_dma_program(chip->dma8, runtime->dma_addr, 1, DMA_MODE_WRITE); | 172 | snd_dma_program(dma, runtime->dma_addr, 1, DMA_MODE_WRITE); |
151 | /* force interrupt */ | 173 | /* force interrupt */ |
152 | chip->mode = SB_MODE_HALT; | ||
153 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); | 174 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); |
154 | snd_sbdsp_command(chip, 0); | 175 | snd_sbdsp_command(chip, 0); |
155 | snd_sbdsp_command(chip, 0); | 176 | snd_sbdsp_command(chip, 0); |
156 | } | 177 | } |
157 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 178 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
158 | if (runtime->channels > 1) { | 179 | if (stereo) { |
159 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 180 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
160 | spin_lock(&chip->mixer_lock); | 181 | spin_lock(&chip->mixer_lock); |
161 | /* save output filter status and turn it off */ | 182 | /* save output filter status and turn it off */ |
@@ -168,13 +189,15 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
168 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 189 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
169 | } | 190 | } |
170 | if (chip->playback_format != SB_DSP_OUTPUT) { | 191 | if (chip->playback_format != SB_DSP_OUTPUT) { |
192 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
193 | count /= 2; | ||
171 | count--; | 194 | count--; |
172 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 195 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
173 | snd_sbdsp_command(chip, count & 0xff); | 196 | snd_sbdsp_command(chip, count & 0xff); |
174 | snd_sbdsp_command(chip, count >> 8); | 197 | snd_sbdsp_command(chip, count >> 8); |
175 | } | 198 | } |
176 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 199 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
177 | snd_dma_program(chip->dma8, runtime->dma_addr, | 200 | snd_dma_program(dma, runtime->dma_addr, |
178 | size, DMA_MODE_WRITE | DMA_AUTOINIT); | 201 | size, DMA_MODE_WRITE | DMA_AUTOINIT); |
179 | return 0; | 202 | return 0; |
180 | } | 203 | } |
@@ -212,7 +235,6 @@ static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, | |||
212 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 235 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
213 | } | 236 | } |
214 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 237 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
215 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_PLAYBACK_8 : SB_MODE_HALT; | ||
216 | return 0; | 238 | return 0; |
217 | } | 239 | } |
218 | 240 | ||
@@ -234,9 +256,21 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
234 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 256 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
235 | struct snd_pcm_runtime *runtime = substream->runtime; | 257 | struct snd_pcm_runtime *runtime = substream->runtime; |
236 | unsigned int mixreg, rate, size, count; | 258 | unsigned int mixreg, rate, size, count; |
259 | unsigned char format; | ||
260 | unsigned char stereo = runtime->channels > 1; | ||
261 | int dma; | ||
237 | 262 | ||
238 | rate = runtime->rate; | 263 | rate = runtime->rate; |
239 | switch (chip->hardware) { | 264 | switch (chip->hardware) { |
265 | case SB_HW_JAZZ16: | ||
266 | if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { | ||
267 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
268 | return -EBUSY; | ||
269 | else | ||
270 | chip->mode |= SB_MODE_CAPTURE_16; | ||
271 | } | ||
272 | chip->capture_format = SB_DSP_LO_INPUT_AUTO; | ||
273 | break; | ||
240 | case SB_HW_PRO: | 274 | case SB_HW_PRO: |
241 | if (runtime->channels > 1) { | 275 | if (runtime->channels > 1) { |
242 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 276 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
@@ -262,14 +296,24 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
262 | default: | 296 | default: |
263 | return -EINVAL; | 297 | return -EINVAL; |
264 | } | 298 | } |
299 | if (chip->mode & SB_MODE_CAPTURE_16) { | ||
300 | format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; | ||
301 | dma = chip->dma16; | ||
302 | } else { | ||
303 | format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; | ||
304 | chip->mode |= SB_MODE_CAPTURE_8; | ||
305 | dma = chip->dma8; | ||
306 | } | ||
265 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); | 307 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); |
266 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); | 308 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); |
267 | spin_lock_irqsave(&chip->reg_lock, flags); | 309 | spin_lock_irqsave(&chip->reg_lock, flags); |
268 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 310 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
269 | if (runtime->channels > 1) | 311 | if (chip->hardware == SB_HW_JAZZ16) |
312 | snd_sbdsp_command(chip, format); | ||
313 | else if (stereo) | ||
270 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); | 314 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); |
271 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 315 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
272 | if (runtime->channels > 1) { | 316 | if (stereo) { |
273 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 317 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
274 | spin_lock(&chip->mixer_lock); | 318 | spin_lock(&chip->mixer_lock); |
275 | /* save input filter status and turn it off */ | 319 | /* save input filter status and turn it off */ |
@@ -282,13 +326,15 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
282 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 326 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
283 | } | 327 | } |
284 | if (chip->capture_format != SB_DSP_INPUT) { | 328 | if (chip->capture_format != SB_DSP_INPUT) { |
329 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
330 | count /= 2; | ||
285 | count--; | 331 | count--; |
286 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 332 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
287 | snd_sbdsp_command(chip, count & 0xff); | 333 | snd_sbdsp_command(chip, count & 0xff); |
288 | snd_sbdsp_command(chip, count >> 8); | 334 | snd_sbdsp_command(chip, count >> 8); |
289 | } | 335 | } |
290 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 336 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
291 | snd_dma_program(chip->dma8, runtime->dma_addr, | 337 | snd_dma_program(dma, runtime->dma_addr, |
292 | size, DMA_MODE_READ | DMA_AUTOINIT); | 338 | size, DMA_MODE_READ | DMA_AUTOINIT); |
293 | return 0; | 339 | return 0; |
294 | } | 340 | } |
@@ -328,7 +374,6 @@ static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream, | |||
328 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 374 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
329 | } | 375 | } |
330 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 376 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
331 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_CAPTURE_8 : SB_MODE_HALT; | ||
332 | return 0; | 377 | return 0; |
333 | } | 378 | } |
334 | 379 | ||
@@ -339,13 +384,21 @@ irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip) | |||
339 | 384 | ||
340 | snd_sb_ack_8bit(chip); | 385 | snd_sb_ack_8bit(chip); |
341 | switch (chip->mode) { | 386 | switch (chip->mode) { |
342 | case SB_MODE_PLAYBACK_8: /* ok.. playback is active */ | 387 | case SB_MODE_PLAYBACK_16: /* ok.. playback is active */ |
388 | if (chip->hardware != SB_HW_JAZZ16) | ||
389 | break; | ||
390 | /* fallthru */ | ||
391 | case SB_MODE_PLAYBACK_8: | ||
343 | substream = chip->playback_substream; | 392 | substream = chip->playback_substream; |
344 | runtime = substream->runtime; | 393 | runtime = substream->runtime; |
345 | if (chip->playback_format == SB_DSP_OUTPUT) | 394 | if (chip->playback_format == SB_DSP_OUTPUT) |
346 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); | 395 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); |
347 | snd_pcm_period_elapsed(substream); | 396 | snd_pcm_period_elapsed(substream); |
348 | break; | 397 | break; |
398 | case SB_MODE_CAPTURE_16: | ||
399 | if (chip->hardware != SB_HW_JAZZ16) | ||
400 | break; | ||
401 | /* fallthru */ | ||
349 | case SB_MODE_CAPTURE_8: | 402 | case SB_MODE_CAPTURE_8: |
350 | substream = chip->capture_substream; | 403 | substream = chip->capture_substream; |
351 | runtime = substream->runtime; | 404 | runtime = substream->runtime; |
@@ -361,10 +414,15 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *subs | |||
361 | { | 414 | { |
362 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 415 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
363 | size_t ptr; | 416 | size_t ptr; |
417 | int dma; | ||
364 | 418 | ||
365 | if (chip->mode != SB_MODE_PLAYBACK_8) | 419 | if (chip->mode & SB_MODE_PLAYBACK_8) |
420 | dma = chip->dma8; | ||
421 | else if (chip->mode & SB_MODE_PLAYBACK_16) | ||
422 | dma = chip->dma16; | ||
423 | else | ||
366 | return 0; | 424 | return 0; |
367 | ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size); | 425 | ptr = snd_dma_pointer(dma, chip->p_dma_size); |
368 | return bytes_to_frames(substream->runtime, ptr); | 426 | return bytes_to_frames(substream->runtime, ptr); |
369 | } | 427 | } |
370 | 428 | ||
@@ -372,10 +430,15 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *subst | |||
372 | { | 430 | { |
373 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 431 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
374 | size_t ptr; | 432 | size_t ptr; |
433 | int dma; | ||
375 | 434 | ||
376 | if (chip->mode != SB_MODE_CAPTURE_8) | 435 | if (chip->mode & SB_MODE_CAPTURE_8) |
436 | dma = chip->dma8; | ||
437 | else if (chip->mode & SB_MODE_CAPTURE_16) | ||
438 | dma = chip->dma16; | ||
439 | else | ||
377 | return 0; | 440 | return 0; |
378 | ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size); | 441 | ptr = snd_dma_pointer(dma, chip->c_dma_size); |
379 | return bytes_to_frames(substream->runtime, ptr); | 442 | return bytes_to_frames(substream->runtime, ptr); |
380 | } | 443 | } |
381 | 444 | ||
@@ -446,6 +509,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
446 | runtime->hw = snd_sb8_capture; | 509 | runtime->hw = snd_sb8_capture; |
447 | } | 510 | } |
448 | switch (chip->hardware) { | 511 | switch (chip->hardware) { |
512 | case SB_HW_JAZZ16: | ||
513 | if (chip->dma16 == 5 || chip->dma16 == 7) | ||
514 | runtime->hw.formats |= SNDRV_PCM_FMTBIT_S16_LE; | ||
515 | runtime->hw.rates |= SNDRV_PCM_RATE_8000_48000; | ||
516 | runtime->hw.rate_min = 4000; | ||
517 | runtime->hw.rate_max = 50000; | ||
518 | runtime->hw.channels_max = 2; | ||
519 | break; | ||
449 | case SB_HW_PRO: | 520 | case SB_HW_PRO: |
450 | runtime->hw.rate_max = 44100; | 521 | runtime->hw.rate_max = 44100; |
451 | runtime->hw.channels_max = 2; | 522 | runtime->hw.channels_max = 2; |
@@ -468,6 +539,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
468 | } | 539 | } |
469 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 540 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
470 | &hw_constraints_clock); | 541 | &hw_constraints_clock); |
542 | if (chip->dma8 > 3 || chip->dma16 >= 0) { | ||
543 | snd_pcm_hw_constraint_step(runtime, 0, | ||
544 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 2); | ||
545 | snd_pcm_hw_constraint_step(runtime, 0, | ||
546 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 2); | ||
547 | runtime->hw.buffer_bytes_max = 128 * 1024 * 1024; | ||
548 | runtime->hw.period_bytes_max = 128 * 1024 * 1024; | ||
549 | } | ||
471 | return 0; | 550 | return 0; |
472 | } | 551 | } |
473 | 552 | ||
@@ -480,6 +559,10 @@ static int snd_sb8_close(struct snd_pcm_substream *substream) | |||
480 | chip->capture_substream = NULL; | 559 | chip->capture_substream = NULL; |
481 | spin_lock_irqsave(&chip->open_lock, flags); | 560 | spin_lock_irqsave(&chip->open_lock, flags); |
482 | chip->open &= ~SB_OPEN_PCM; | 561 | chip->open &= ~SB_OPEN_PCM; |
562 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
563 | chip->mode &= ~SB_MODE_PLAYBACK; | ||
564 | else | ||
565 | chip->mode &= ~SB_MODE_CAPTURE; | ||
483 | spin_unlock_irqrestore(&chip->open_lock, flags); | 566 | spin_unlock_irqrestore(&chip->open_lock, flags); |
484 | return 0; | 567 | return 0; |
485 | } | 568 | } |
@@ -515,6 +598,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
515 | struct snd_card *card = chip->card; | 598 | struct snd_card *card = chip->card; |
516 | struct snd_pcm *pcm; | 599 | struct snd_pcm *pcm; |
517 | int err; | 600 | int err; |
601 | size_t max_prealloc = 64 * 1024; | ||
518 | 602 | ||
519 | if (rpcm) | 603 | if (rpcm) |
520 | *rpcm = NULL; | 604 | *rpcm = NULL; |
@@ -527,9 +611,11 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
527 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); | 611 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); |
528 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); | 612 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); |
529 | 613 | ||
614 | if (chip->dma8 > 3 || chip->dma16 >= 0) | ||
615 | max_prealloc = 128 * 1024; | ||
530 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 616 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
531 | snd_dma_isa_data(), | 617 | snd_dma_isa_data(), |
532 | 64*1024, 64*1024); | 618 | 64*1024, max_prealloc); |
533 | 619 | ||
534 | if (rpcm) | 620 | if (rpcm) |
535 | *rpcm = pcm; | 621 | *rpcm = pcm; |
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 27a651502251..eae6c1c0eff9 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c | |||
@@ -170,6 +170,9 @@ static int snd_sbdsp_probe(struct snd_sb * chip) | |||
170 | case SB_HW_CS5530: | 170 | case SB_HW_CS5530: |
171 | str = "16 (CS5530)"; | 171 | str = "16 (CS5530)"; |
172 | break; | 172 | break; |
173 | case SB_HW_JAZZ16: | ||
174 | str = "Pro (Jazz16)"; | ||
175 | break; | ||
173 | default: | 176 | default: |
174 | return -ENODEV; | 177 | return -ENODEV; |
175 | } | 178 | } |
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 318ff0c823e7..6496822c1808 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c | |||
@@ -528,20 +528,11 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty | |||
528 | * SB 2.0 specific mixer elements | 528 | * SB 2.0 specific mixer elements |
529 | */ | 529 | */ |
530 | 530 | ||
531 | static struct sbmix_elem snd_sb20_ctl_master_play_vol = | 531 | static struct sbmix_elem snd_sb20_controls[] = { |
532 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7); | 532 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7), |
533 | static struct sbmix_elem snd_sb20_ctl_pcm_play_vol = | 533 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3), |
534 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3); | 534 | SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7), |
535 | static struct sbmix_elem snd_sb20_ctl_synth_play_vol = | 535 | SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7) |
536 | SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7); | ||
537 | static struct sbmix_elem snd_sb20_ctl_cd_play_vol = | ||
538 | SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7); | ||
539 | |||
540 | static struct sbmix_elem *snd_sb20_controls[] = { | ||
541 | &snd_sb20_ctl_master_play_vol, | ||
542 | &snd_sb20_ctl_pcm_play_vol, | ||
543 | &snd_sb20_ctl_synth_play_vol, | ||
544 | &snd_sb20_ctl_cd_play_vol | ||
545 | }; | 536 | }; |
546 | 537 | ||
547 | static unsigned char snd_sb20_init_values[][2] = { | 538 | static unsigned char snd_sb20_init_values[][2] = { |
@@ -552,41 +543,24 @@ static unsigned char snd_sb20_init_values[][2] = { | |||
552 | /* | 543 | /* |
553 | * SB Pro specific mixer elements | 544 | * SB Pro specific mixer elements |
554 | */ | 545 | */ |
555 | static struct sbmix_elem snd_sbpro_ctl_master_play_vol = | 546 | static struct sbmix_elem snd_sbpro_controls[] = { |
556 | SB_DOUBLE("Master Playback Volume", SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7); | 547 | SB_DOUBLE("Master Playback Volume", |
557 | static struct sbmix_elem snd_sbpro_ctl_pcm_play_vol = | 548 | SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7), |
558 | SB_DOUBLE("PCM Playback Volume", SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7); | 549 | SB_DOUBLE("PCM Playback Volume", |
559 | static struct sbmix_elem snd_sbpro_ctl_pcm_play_filter = | 550 | SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7), |
560 | SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1); | 551 | SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1), |
561 | static struct sbmix_elem snd_sbpro_ctl_synth_play_vol = | 552 | SB_DOUBLE("Synth Playback Volume", |
562 | SB_DOUBLE("Synth Playback Volume", SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7); | 553 | SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7), |
563 | static struct sbmix_elem snd_sbpro_ctl_cd_play_vol = | 554 | SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7), |
564 | SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7); | 555 | SB_DOUBLE("Line Playback Volume", |
565 | static struct sbmix_elem snd_sbpro_ctl_line_play_vol = | 556 | SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7), |
566 | SB_DOUBLE("Line Playback Volume", SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7); | 557 | SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3), |
567 | static struct sbmix_elem snd_sbpro_ctl_mic_play_vol = | ||
568 | SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3); | ||
569 | static struct sbmix_elem snd_sbpro_ctl_capture_source = | ||
570 | { | 558 | { |
571 | .name = "Capture Source", | 559 | .name = "Capture Source", |
572 | .type = SB_MIX_CAPTURE_PRO | 560 | .type = SB_MIX_CAPTURE_PRO |
573 | }; | 561 | }, |
574 | static struct sbmix_elem snd_sbpro_ctl_capture_filter = | 562 | SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1), |
575 | SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1); | 563 | SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1) |
576 | static struct sbmix_elem snd_sbpro_ctl_capture_low_filter = | ||
577 | SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1); | ||
578 | |||
579 | static struct sbmix_elem *snd_sbpro_controls[] = { | ||
580 | &snd_sbpro_ctl_master_play_vol, | ||
581 | &snd_sbpro_ctl_pcm_play_vol, | ||
582 | &snd_sbpro_ctl_pcm_play_filter, | ||
583 | &snd_sbpro_ctl_synth_play_vol, | ||
584 | &snd_sbpro_ctl_cd_play_vol, | ||
585 | &snd_sbpro_ctl_line_play_vol, | ||
586 | &snd_sbpro_ctl_mic_play_vol, | ||
587 | &snd_sbpro_ctl_capture_source, | ||
588 | &snd_sbpro_ctl_capture_filter, | ||
589 | &snd_sbpro_ctl_capture_low_filter | ||
590 | }; | 564 | }; |
591 | 565 | ||
592 | static unsigned char snd_sbpro_init_values[][2] = { | 566 | static unsigned char snd_sbpro_init_values[][2] = { |
@@ -598,68 +572,42 @@ static unsigned char snd_sbpro_init_values[][2] = { | |||
598 | /* | 572 | /* |
599 | * SB16 specific mixer elements | 573 | * SB16 specific mixer elements |
600 | */ | 574 | */ |
601 | static struct sbmix_elem snd_sb16_ctl_master_play_vol = | 575 | static struct sbmix_elem snd_sb16_controls[] = { |
602 | SB_DOUBLE("Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31); | 576 | SB_DOUBLE("Master Playback Volume", |
603 | static struct sbmix_elem snd_sb16_ctl_3d_enhance_switch = | 577 | SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), |
604 | SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1); | 578 | SB_DOUBLE("PCM Playback Volume", |
605 | static struct sbmix_elem snd_sb16_ctl_tone_bass = | 579 | SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31), |
606 | SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15); | 580 | SB16_INPUT_SW("Synth Capture Route", |
607 | static struct sbmix_elem snd_sb16_ctl_tone_treble = | 581 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5), |
608 | SB_DOUBLE("Tone Control - Treble", SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15); | 582 | SB_DOUBLE("Synth Playback Volume", |
609 | static struct sbmix_elem snd_sb16_ctl_pcm_play_vol = | 583 | SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31), |
610 | SB_DOUBLE("PCM Playback Volume", SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31); | 584 | SB16_INPUT_SW("CD Capture Route", |
611 | static struct sbmix_elem snd_sb16_ctl_synth_capture_route = | 585 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1), |
612 | SB16_INPUT_SW("Synth Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5); | 586 | SB_DOUBLE("CD Playback Switch", |
613 | static struct sbmix_elem snd_sb16_ctl_synth_play_vol = | 587 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), |
614 | SB_DOUBLE("Synth Playback Volume", SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31); | 588 | SB_DOUBLE("CD Playback Volume", |
615 | static struct sbmix_elem snd_sb16_ctl_cd_capture_route = | 589 | SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31), |
616 | SB16_INPUT_SW("CD Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1); | 590 | SB16_INPUT_SW("Mic Capture Route", |
617 | static struct sbmix_elem snd_sb16_ctl_cd_play_switch = | 591 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0), |
618 | SB_DOUBLE("CD Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1); | 592 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
619 | static struct sbmix_elem snd_sb16_ctl_cd_play_vol = | 593 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), |
620 | SB_DOUBLE("CD Playback Volume", SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31); | 594 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3), |
621 | static struct sbmix_elem snd_sb16_ctl_line_capture_route = | 595 | SB_DOUBLE("Capture Volume", |
622 | SB16_INPUT_SW("Line Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3); | 596 | SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), |
623 | static struct sbmix_elem snd_sb16_ctl_line_play_switch = | 597 | SB_DOUBLE("Playback Volume", |
624 | SB_DOUBLE("Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1); | 598 | SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), |
625 | static struct sbmix_elem snd_sb16_ctl_line_play_vol = | 599 | SB16_INPUT_SW("Line Capture Route", |
626 | SB_DOUBLE("Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31); | 600 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3), |
627 | static struct sbmix_elem snd_sb16_ctl_mic_capture_route = | 601 | SB_DOUBLE("Line Playback Switch", |
628 | SB16_INPUT_SW("Mic Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0); | 602 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), |
629 | static struct sbmix_elem snd_sb16_ctl_mic_play_switch = | 603 | SB_DOUBLE("Line Playback Volume", |
630 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1); | 604 | SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), |
631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = | 605 | SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), |
632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); | 606 | SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1), |
633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = | 607 | SB_DOUBLE("Tone Control - Bass", |
634 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3); | 608 | SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15), |
635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = | 609 | SB_DOUBLE("Tone Control - Treble", |
636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); | 610 | SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15) |
637 | static struct sbmix_elem snd_sb16_ctl_play_vol = | ||
638 | SB_DOUBLE("Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3); | ||
639 | static struct sbmix_elem snd_sb16_ctl_auto_mic_gain = | ||
640 | SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1); | ||
641 | |||
642 | static struct sbmix_elem *snd_sb16_controls[] = { | ||
643 | &snd_sb16_ctl_master_play_vol, | ||
644 | &snd_sb16_ctl_3d_enhance_switch, | ||
645 | &snd_sb16_ctl_tone_bass, | ||
646 | &snd_sb16_ctl_tone_treble, | ||
647 | &snd_sb16_ctl_pcm_play_vol, | ||
648 | &snd_sb16_ctl_synth_capture_route, | ||
649 | &snd_sb16_ctl_synth_play_vol, | ||
650 | &snd_sb16_ctl_cd_capture_route, | ||
651 | &snd_sb16_ctl_cd_play_switch, | ||
652 | &snd_sb16_ctl_cd_play_vol, | ||
653 | &snd_sb16_ctl_line_capture_route, | ||
654 | &snd_sb16_ctl_line_play_switch, | ||
655 | &snd_sb16_ctl_line_play_vol, | ||
656 | &snd_sb16_ctl_mic_capture_route, | ||
657 | &snd_sb16_ctl_mic_play_switch, | ||
658 | &snd_sb16_ctl_mic_play_vol, | ||
659 | &snd_sb16_ctl_pc_speaker_vol, | ||
660 | &snd_sb16_ctl_capture_vol, | ||
661 | &snd_sb16_ctl_play_vol, | ||
662 | &snd_sb16_ctl_auto_mic_gain | ||
663 | }; | 611 | }; |
664 | 612 | ||
665 | static unsigned char snd_sb16_init_values[][2] = { | 613 | static unsigned char snd_sb16_init_values[][2] = { |
@@ -678,46 +626,34 @@ static unsigned char snd_sb16_init_values[][2] = { | |||
678 | /* | 626 | /* |
679 | * DT019x specific mixer elements | 627 | * DT019x specific mixer elements |
680 | */ | 628 | */ |
681 | static struct sbmix_elem snd_dt019x_ctl_master_play_vol = | 629 | static struct sbmix_elem snd_dt019x_controls[] = { |
682 | SB_DOUBLE("Master Playback Volume", SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4,0, 15); | 630 | /* ALS4000 below has some parts which we might be lacking, |
683 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_vol = | 631 | * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ |
684 | SB_DOUBLE("PCM Playback Volume", SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4,0, 15); | 632 | SB_DOUBLE("Master Playback Volume", |
685 | static struct sbmix_elem snd_dt019x_ctl_synth_play_vol = | 633 | SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4, 0, 15), |
686 | SB_DOUBLE("Synth Playback Volume", SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4,0, 15); | 634 | SB_DOUBLE("PCM Playback Switch", |
687 | static struct sbmix_elem snd_dt019x_ctl_cd_play_vol = | 635 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), |
688 | SB_DOUBLE("CD Playback Volume", SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4,0, 15); | 636 | SB_DOUBLE("PCM Playback Volume", |
689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = | 637 | SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4, 0, 15), |
690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); | 638 | SB_DOUBLE("Synth Playback Switch", |
691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = | 639 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), |
692 | SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7); | 640 | SB_DOUBLE("Synth Playback Volume", |
693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = | 641 | SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4, 0, 15), |
694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); | 642 | SB_DOUBLE("CD Playback Switch", |
695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = | 643 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), |
696 | SB_DOUBLE("PCM Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2,1, 1); | 644 | SB_DOUBLE("CD Playback Volume", |
697 | static struct sbmix_elem snd_dt019x_ctl_synth_play_switch = | 645 | SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4, 0, 15), |
698 | SB_DOUBLE("Synth Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4,3, 1); | 646 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
699 | static struct sbmix_elem snd_dt019x_ctl_capture_source = | 647 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7), |
648 | SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7), | ||
649 | SB_DOUBLE("Line Playback Switch", | ||
650 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), | ||
651 | SB_DOUBLE("Line Playback Volume", | ||
652 | SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4, 0, 15), | ||
700 | { | 653 | { |
701 | .name = "Capture Source", | 654 | .name = "Capture Source", |
702 | .type = SB_MIX_CAPTURE_DT019X | 655 | .type = SB_MIX_CAPTURE_DT019X |
703 | }; | 656 | } |
704 | |||
705 | static struct sbmix_elem *snd_dt019x_controls[] = { | ||
706 | /* ALS4000 below has some parts which we might be lacking, | ||
707 | * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ | ||
708 | &snd_dt019x_ctl_master_play_vol, | ||
709 | &snd_dt019x_ctl_pcm_play_vol, | ||
710 | &snd_dt019x_ctl_synth_play_vol, | ||
711 | &snd_dt019x_ctl_cd_play_vol, | ||
712 | &snd_dt019x_ctl_mic_play_vol, | ||
713 | &snd_dt019x_ctl_pc_speaker_vol, | ||
714 | &snd_dt019x_ctl_line_play_vol, | ||
715 | &snd_sb16_ctl_mic_play_switch, | ||
716 | &snd_sb16_ctl_cd_play_switch, | ||
717 | &snd_sb16_ctl_line_play_switch, | ||
718 | &snd_dt019x_ctl_pcm_play_switch, | ||
719 | &snd_dt019x_ctl_synth_play_switch, | ||
720 | &snd_dt019x_ctl_capture_source | ||
721 | }; | 657 | }; |
722 | 658 | ||
723 | static unsigned char snd_dt019x_init_values[][2] = { | 659 | static unsigned char snd_dt019x_init_values[][2] = { |
@@ -735,82 +671,37 @@ static unsigned char snd_dt019x_init_values[][2] = { | |||
735 | /* | 671 | /* |
736 | * ALS4000 specific mixer elements | 672 | * ALS4000 specific mixer elements |
737 | */ | 673 | */ |
738 | static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = | 674 | static struct sbmix_elem snd_als4000_controls[] = { |
739 | SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); | 675 | SB_DOUBLE("PCM Playback Switch", |
740 | static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = { | 676 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), |
677 | SB_DOUBLE("Synth Playback Switch", | ||
678 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), | ||
679 | SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03), | ||
680 | SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1), | ||
681 | { | ||
741 | .name = "Master Mono Capture Route", | 682 | .name = "Master Mono Capture Route", |
742 | .type = SB_MIX_MONO_CAPTURE_ALS4K | 683 | .type = SB_MIX_MONO_CAPTURE_ALS4K |
743 | }; | 684 | }, |
744 | static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = | 685 | SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1), |
745 | SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); | 686 | SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01), |
746 | static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = | 687 | SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01), |
747 | SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); | ||
748 | static struct sbmix_elem snd_als4000_ctl_mixer_analog_loopback = | ||
749 | SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); | ||
750 | static struct sbmix_elem snd_als4000_ctl_mixer_digital_loopback = | ||
751 | SB_SINGLE("Digital Loopback Switch", | 688 | SB_SINGLE("Digital Loopback Switch", |
752 | SB_ALS4000_CR3_CONFIGURATION, 7, 0x01); | 689 | SB_ALS4000_CR3_CONFIGURATION, 7, 0x01), |
753 | /* FIXME: functionality of 3D controls might be swapped, I didn't find | 690 | /* FIXME: functionality of 3D controls might be swapped, I didn't find |
754 | * a description of how to identify what is supposed to be what */ | 691 | * a description of how to identify what is supposed to be what */ |
755 | static struct sbmix_elem snd_als4000_3d_control_switch = | 692 | SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07), |
756 | SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); | ||
757 | static struct sbmix_elem snd_als4000_3d_control_ratio = | ||
758 | SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07); | ||
759 | static struct sbmix_elem snd_als4000_3d_control_freq = | ||
760 | /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ | 693 | /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ |
761 | SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03); | 694 | SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03), |
762 | static struct sbmix_elem snd_als4000_3d_control_delay = | ||
763 | /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, | 695 | /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, |
764 | * but what ALSA 3D attribute is that actually? "Center", "Depth", | 696 | * but what ALSA 3D attribute is that actually? "Center", "Depth", |
765 | * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ | 697 | * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ |
766 | SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); | 698 | SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f), |
767 | static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = | 699 | SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01), |
768 | SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); | ||
769 | static struct sbmix_elem snd_als4000_ctl_3db_freq_control_switch = | ||
770 | SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", | 700 | SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", |
771 | SB_ALS4000_FMDAC, 5, 0x01); | 701 | SB_ALS4000_FMDAC, 5, 0x01), |
772 | #ifdef NOT_AVAILABLE | 702 | #ifdef NOT_AVAILABLE |
773 | static struct sbmix_elem snd_als4000_ctl_fmdac = | 703 | SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01), |
774 | SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); | 704 | SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f), |
775 | static struct sbmix_elem snd_als4000_ctl_qsound = | ||
776 | SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f); | ||
777 | #endif | ||
778 | |||
779 | static struct sbmix_elem *snd_als4000_controls[] = { | ||
780 | /* ALS4000a.PDF regs page */ | ||
781 | &snd_sb16_ctl_master_play_vol, /* MX30/31 12 */ | ||
782 | &snd_dt019x_ctl_pcm_play_switch, /* MX4C 16 */ | ||
783 | &snd_sb16_ctl_pcm_play_vol, /* MX32/33 12 */ | ||
784 | &snd_sb16_ctl_synth_capture_route, /* MX3D/3E 14 */ | ||
785 | &snd_dt019x_ctl_synth_play_switch, /* MX4C 16 */ | ||
786 | &snd_sb16_ctl_synth_play_vol, /* MX34/35 12/13 */ | ||
787 | &snd_sb16_ctl_cd_capture_route, /* MX3D/3E 14 */ | ||
788 | &snd_sb16_ctl_cd_play_switch, /* MX3C 14 */ | ||
789 | &snd_sb16_ctl_cd_play_vol, /* MX36/37 13 */ | ||
790 | &snd_sb16_ctl_line_capture_route, /* MX3D/3E 14 */ | ||
791 | &snd_sb16_ctl_line_play_switch, /* MX3C 14 */ | ||
792 | &snd_sb16_ctl_line_play_vol, /* MX38/39 13 */ | ||
793 | &snd_sb16_ctl_mic_capture_route, /* MX3D/3E 14 */ | ||
794 | &snd_als4000_ctl_mic_20db_boost, /* MX4D 16 */ | ||
795 | &snd_sb16_ctl_mic_play_switch, /* MX3C 14 */ | ||
796 | &snd_sb16_ctl_mic_play_vol, /* MX3A 13 */ | ||
797 | &snd_sb16_ctl_pc_speaker_vol, /* MX3B 14 */ | ||
798 | &snd_sb16_ctl_capture_vol, /* MX3F/40 15 */ | ||
799 | &snd_sb16_ctl_play_vol, /* MX41/42 15 */ | ||
800 | &snd_als4000_ctl_master_mono_playback_switch, /* MX4C 16 */ | ||
801 | &snd_als4k_ctl_master_mono_capture_route, /* MX4B 16 */ | ||
802 | &snd_als4000_ctl_mono_playback_switch, /* MX4C 16 */ | ||
803 | &snd_als4000_ctl_mixer_analog_loopback, /* MX4D 16 */ | ||
804 | &snd_als4000_ctl_mixer_digital_loopback, /* CR3 21 */ | ||
805 | &snd_als4000_3d_control_switch, /* MX50 17 */ | ||
806 | &snd_als4000_3d_control_ratio, /* MX50 17 */ | ||
807 | &snd_als4000_3d_control_freq, /* MX50 17 */ | ||
808 | &snd_als4000_3d_control_delay, /* MX51 18 */ | ||
809 | &snd_als4000_3d_control_poweroff_switch, /* MX51 18 */ | ||
810 | &snd_als4000_ctl_3db_freq_control_switch, /* MX4F 17 */ | ||
811 | #ifdef NOT_AVAILABLE | ||
812 | &snd_als4000_ctl_fmdac, | ||
813 | &snd_als4000_ctl_qsound, | ||
814 | #endif | 705 | #endif |
815 | }; | 706 | }; |
816 | 707 | ||
@@ -829,11 +720,10 @@ static unsigned char snd_als4000_init_values[][2] = { | |||
829 | { SB_ALS4000_MIC_IN_GAIN, 0 }, | 720 | { SB_ALS4000_MIC_IN_GAIN, 0 }, |
830 | }; | 721 | }; |
831 | 722 | ||
832 | |||
833 | /* | 723 | /* |
834 | */ | 724 | */ |
835 | static int snd_sbmixer_init(struct snd_sb *chip, | 725 | static int snd_sbmixer_init(struct snd_sb *chip, |
836 | struct sbmix_elem **controls, | 726 | struct sbmix_elem *controls, |
837 | int controls_count, | 727 | int controls_count, |
838 | unsigned char map[][2], | 728 | unsigned char map[][2], |
839 | int map_count, | 729 | int map_count, |
@@ -856,7 +746,8 @@ static int snd_sbmixer_init(struct snd_sb *chip, | |||
856 | } | 746 | } |
857 | 747 | ||
858 | for (idx = 0; idx < controls_count; idx++) { | 748 | for (idx = 0; idx < controls_count; idx++) { |
859 | if ((err = snd_sbmixer_add_ctl_elem(chip, controls[idx])) < 0) | 749 | err = snd_sbmixer_add_ctl_elem(chip, &controls[idx]); |
750 | if (err < 0) | ||
860 | return err; | 751 | return err; |
861 | } | 752 | } |
862 | snd_component_add(card, name); | 753 | snd_component_add(card, name); |
@@ -888,6 +779,7 @@ int snd_sbmixer_new(struct snd_sb *chip) | |||
888 | return err; | 779 | return err; |
889 | break; | 780 | break; |
890 | case SB_HW_PRO: | 781 | case SB_HW_PRO: |
782 | case SB_HW_JAZZ16: | ||
891 | if ((err = snd_sbmixer_init(chip, | 783 | if ((err = snd_sbmixer_init(chip, |
892 | snd_sbpro_controls, | 784 | snd_sbpro_controls, |
893 | ARRAY_SIZE(snd_sbpro_controls), | 785 | ARRAY_SIZE(snd_sbpro_controls), |
@@ -908,6 +800,15 @@ int snd_sbmixer_new(struct snd_sb *chip) | |||
908 | return err; | 800 | return err; |
909 | break; | 801 | break; |
910 | case SB_HW_ALS4000: | 802 | case SB_HW_ALS4000: |
803 | /* use only the first 16 controls from SB16 */ | ||
804 | err = snd_sbmixer_init(chip, | ||
805 | snd_sb16_controls, | ||
806 | 16, | ||
807 | snd_sb16_init_values, | ||
808 | ARRAY_SIZE(snd_sb16_init_values), | ||
809 | "ALS4000"); | ||
810 | if (err < 0) | ||
811 | return err; | ||
911 | if ((err = snd_sbmixer_init(chip, | 812 | if ((err = snd_sbmixer_init(chip, |
912 | snd_als4000_controls, | 813 | snd_als4000_controls, |
913 | ARRAY_SIZE(snd_als4000_controls), | 814 | ARRAY_SIZE(snd_als4000_controls), |
@@ -1029,6 +930,7 @@ void snd_sbmixer_suspend(struct snd_sb *chip) | |||
1029 | save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); | 930 | save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); |
1030 | break; | 931 | break; |
1031 | case SB_HW_PRO: | 932 | case SB_HW_PRO: |
933 | case SB_HW_JAZZ16: | ||
1032 | save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); | 934 | save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); |
1033 | break; | 935 | break; |
1034 | case SB_HW_16: | 936 | case SB_HW_16: |
@@ -1055,6 +957,7 @@ void snd_sbmixer_resume(struct snd_sb *chip) | |||
1055 | restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); | 957 | restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); |
1056 | break; | 958 | break; |
1057 | case SB_HW_PRO: | 959 | case SB_HW_PRO: |
960 | case SB_HW_JAZZ16: | ||
1058 | restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); | 961 | restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); |
1059 | break; | 962 | break; |
1060 | case SB_HW_16: | 963 | case SB_HW_16: |
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 5b9d6c18bc45..9191b32d9130 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c | |||
@@ -2014,6 +2014,7 @@ static int snd_wss_info_mux(struct snd_kcontrol *kcontrol, | |||
2014 | case WSS_HW_INTERWAVE: | 2014 | case WSS_HW_INTERWAVE: |
2015 | ptexts = gusmax_texts; | 2015 | ptexts = gusmax_texts; |
2016 | break; | 2016 | break; |
2017 | case WSS_HW_OPTI93X: | ||
2017 | case WSS_HW_OPL3SA2: | 2018 | case WSS_HW_OPL3SA2: |
2018 | ptexts = opl3sa_texts; | 2019 | ptexts = opl3sa_texts; |
2019 | break; | 2020 | break; |
@@ -2246,54 +2247,12 @@ WSS_SINGLE("Beep Bypass Playback Switch", 0, | |||
2246 | CS4231_MONO_CTRL, 5, 1, 0), | 2247 | CS4231_MONO_CTRL, 5, 1, 0), |
2247 | }; | 2248 | }; |
2248 | 2249 | ||
2249 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
2250 | WSS_DOUBLE("Master Playback Switch", 0, | ||
2251 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
2252 | WSS_DOUBLE_TLV("Master Playback Volume", 0, | ||
2253 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, | ||
2254 | db_scale_6bit), | ||
2255 | WSS_DOUBLE("PCM Playback Switch", 0, | ||
2256 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | ||
2257 | WSS_DOUBLE("PCM Playback Volume", 0, | ||
2258 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1), | ||
2259 | WSS_DOUBLE("FM Playback Switch", 0, | ||
2260 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | ||
2261 | WSS_DOUBLE("FM Playback Volume", 0, | ||
2262 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1), | ||
2263 | WSS_DOUBLE("Line Playback Switch", 0, | ||
2264 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
2265 | WSS_DOUBLE("Line Playback Volume", 0, | ||
2266 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1), | ||
2267 | WSS_DOUBLE("Mic Playback Switch", 0, | ||
2268 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | ||
2269 | WSS_DOUBLE("Mic Playback Volume", 0, | ||
2270 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1), | ||
2271 | WSS_DOUBLE("Mic Boost", 0, | ||
2272 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), | ||
2273 | WSS_DOUBLE("CD Playback Switch", 0, | ||
2274 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | ||
2275 | WSS_DOUBLE("CD Playback Volume", 0, | ||
2276 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1), | ||
2277 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
2278 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
2279 | WSS_DOUBLE("Aux Playback Volume", 0, | ||
2280 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1), | ||
2281 | WSS_DOUBLE("Capture Volume", 0, | ||
2282 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | ||
2283 | { | ||
2284 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2285 | .name = "Capture Source", | ||
2286 | .info = snd_wss_info_mux, | ||
2287 | .get = snd_wss_get_mux, | ||
2288 | .put = snd_wss_put_mux, | ||
2289 | } | ||
2290 | }; | ||
2291 | |||
2292 | int snd_wss_mixer(struct snd_wss *chip) | 2250 | int snd_wss_mixer(struct snd_wss *chip) |
2293 | { | 2251 | { |
2294 | struct snd_card *card; | 2252 | struct snd_card *card; |
2295 | unsigned int idx; | 2253 | unsigned int idx; |
2296 | int err; | 2254 | int err; |
2255 | int count = ARRAY_SIZE(snd_wss_controls); | ||
2297 | 2256 | ||
2298 | if (snd_BUG_ON(!chip || !chip->pcm)) | 2257 | if (snd_BUG_ON(!chip || !chip->pcm)) |
2299 | return -EINVAL; | 2258 | return -EINVAL; |
@@ -2302,28 +2261,19 @@ int snd_wss_mixer(struct snd_wss *chip) | |||
2302 | 2261 | ||
2303 | strcpy(card->mixername, chip->pcm->name); | 2262 | strcpy(card->mixername, chip->pcm->name); |
2304 | 2263 | ||
2305 | if (chip->hardware == WSS_HW_OPTI93X) | 2264 | /* Use only the first 11 entries on AD1848 */ |
2306 | for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { | 2265 | if (chip->hardware & WSS_HW_AD1848_MASK) |
2307 | err = snd_ctl_add(card, | 2266 | count = 11; |
2308 | snd_ctl_new1(&snd_opti93x_controls[idx], | 2267 | /* There is no loopback on OPTI93X */ |
2309 | chip)); | 2268 | else if (chip->hardware == WSS_HW_OPTI93X) |
2310 | if (err < 0) | 2269 | count = 9; |
2311 | return err; | 2270 | |
2312 | } | 2271 | for (idx = 0; idx < count; idx++) { |
2313 | else { | 2272 | err = snd_ctl_add(card, |
2314 | int count = ARRAY_SIZE(snd_wss_controls); | 2273 | snd_ctl_new1(&snd_wss_controls[idx], |
2315 | 2274 | chip)); | |
2316 | /* Use only the first 11 entries on AD1848 */ | 2275 | if (err < 0) |
2317 | if (chip->hardware & WSS_HW_AD1848_MASK) | 2276 | return err; |
2318 | count = 11; | ||
2319 | |||
2320 | for (idx = 0; idx < count; idx++) { | ||
2321 | err = snd_ctl_add(card, | ||
2322 | snd_ctl_new1(&snd_wss_controls[idx], | ||
2323 | chip)); | ||
2324 | if (err < 0) | ||
2325 | return err; | ||
2326 | } | ||
2327 | } | 2277 | } |
2328 | return 0; | 2278 | return 0; |
2329 | } | 2279 | } |
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 8691f4cf6191..9b486beeb932 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <linux/gfp.h> | 28 | #include <linux/gfp.h> |
29 | #include <linux/vmalloc.h> | ||
30 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
31 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
32 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
@@ -603,25 +602,14 @@ static int snd_sgio2audio_pcm_close(struct snd_pcm_substream *substream) | |||
603 | static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, | 602 | static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, |
604 | struct snd_pcm_hw_params *hw_params) | 603 | struct snd_pcm_hw_params *hw_params) |
605 | { | 604 | { |
606 | struct snd_pcm_runtime *runtime = substream->runtime; | 605 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, |
607 | int size = params_buffer_bytes(hw_params); | 606 | params_buffer_bytes(hw_params)); |
608 | |||
609 | /* alloc virtual 'dma' area */ | ||
610 | if (runtime->dma_area) | ||
611 | vfree(runtime->dma_area); | ||
612 | runtime->dma_area = vmalloc(size); | ||
613 | if (runtime->dma_area == NULL) | ||
614 | return -ENOMEM; | ||
615 | runtime->dma_bytes = size; | ||
616 | return 0; | ||
617 | } | 607 | } |
618 | 608 | ||
619 | /* hw_free callback */ | 609 | /* hw_free callback */ |
620 | static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) | 610 | static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) |
621 | { | 611 | { |
622 | vfree(substream->runtime->dma_area); | 612 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
623 | substream->runtime->dma_area = NULL; | ||
624 | return 0; | ||
625 | } | 613 | } |
626 | 614 | ||
627 | /* prepare callback */ | 615 | /* prepare callback */ |
@@ -692,13 +680,6 @@ snd_sgio2audio_pcm_pointer(struct snd_pcm_substream *substream) | |||
692 | chip->channel[chan->idx].pos); | 680 | chip->channel[chan->idx].pos); |
693 | } | 681 | } |
694 | 682 | ||
695 | /* get the physical page pointer on the given offset */ | ||
696 | static struct page *snd_sgio2audio_page(struct snd_pcm_substream *substream, | ||
697 | unsigned long offset) | ||
698 | { | ||
699 | return vmalloc_to_page(substream->runtime->dma_area + offset); | ||
700 | } | ||
701 | |||
702 | /* operators */ | 683 | /* operators */ |
703 | static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { | 684 | static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { |
704 | .open = snd_sgio2audio_playback1_open, | 685 | .open = snd_sgio2audio_playback1_open, |
@@ -709,7 +690,7 @@ static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { | |||
709 | .prepare = snd_sgio2audio_pcm_prepare, | 690 | .prepare = snd_sgio2audio_pcm_prepare, |
710 | .trigger = snd_sgio2audio_pcm_trigger, | 691 | .trigger = snd_sgio2audio_pcm_trigger, |
711 | .pointer = snd_sgio2audio_pcm_pointer, | 692 | .pointer = snd_sgio2audio_pcm_pointer, |
712 | .page = snd_sgio2audio_page, | 693 | .page = snd_pcm_lib_get_vmalloc_page, |
713 | }; | 694 | }; |
714 | 695 | ||
715 | static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { | 696 | static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { |
@@ -721,7 +702,7 @@ static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { | |||
721 | .prepare = snd_sgio2audio_pcm_prepare, | 702 | .prepare = snd_sgio2audio_pcm_prepare, |
722 | .trigger = snd_sgio2audio_pcm_trigger, | 703 | .trigger = snd_sgio2audio_pcm_trigger, |
723 | .pointer = snd_sgio2audio_pcm_pointer, | 704 | .pointer = snd_sgio2audio_pcm_pointer, |
724 | .page = snd_sgio2audio_page, | 705 | .page = snd_pcm_lib_get_vmalloc_page, |
725 | }; | 706 | }; |
726 | 707 | ||
727 | static struct snd_pcm_ops snd_sgio2audio_capture_ops = { | 708 | static struct snd_pcm_ops snd_sgio2audio_capture_ops = { |
@@ -733,7 +714,7 @@ static struct snd_pcm_ops snd_sgio2audio_capture_ops = { | |||
733 | .prepare = snd_sgio2audio_pcm_prepare, | 714 | .prepare = snd_sgio2audio_pcm_prepare, |
734 | .trigger = snd_sgio2audio_pcm_trigger, | 715 | .trigger = snd_sgio2audio_pcm_trigger, |
735 | .pointer = snd_sgio2audio_pcm_pointer, | 716 | .pointer = snd_sgio2audio_pcm_pointer, |
736 | .page = snd_sgio2audio_page, | 717 | .page = snd_pcm_lib_get_vmalloc_page, |
737 | }; | 718 | }; |
738 | 719 | ||
739 | /* | 720 | /* |
diff --git a/sound/oss/pss.c b/sound/oss/pss.c index 83f5ee236b12..e19dd5dcc2de 100644 --- a/sound/oss/pss.c +++ b/sound/oss/pss.c | |||
@@ -269,7 +269,7 @@ static int pss_reset_dsp(pss_confdata * devc) | |||
269 | unsigned long i, limit = jiffies + HZ/10; | 269 | unsigned long i, limit = jiffies + HZ/10; |
270 | 270 | ||
271 | outw(0x2000, REG(PSS_CONTROL)); | 271 | outw(0x2000, REG(PSS_CONTROL)); |
272 | for (i = 0; i < 32768 && (limit-jiffies >= 0); i++) | 272 | for (i = 0; i < 32768 && time_after_eq(limit, jiffies); i++) |
273 | inw(REG(PSS_CONTROL)); | 273 | inw(REG(PSS_CONTROL)); |
274 | outw(0x0000, REG(PSS_CONTROL)); | 274 | outw(0x0000, REG(PSS_CONTROL)); |
275 | return 1; | 275 | return 1; |
@@ -369,11 +369,11 @@ static int pss_download_boot(pss_confdata * devc, unsigned char *block, int size | |||
369 | outw(0, REG(PSS_DATA)); | 369 | outw(0, REG(PSS_DATA)); |
370 | 370 | ||
371 | limit = jiffies + HZ/10; | 371 | limit = jiffies + HZ/10; |
372 | for (i = 0; i < 32768 && (limit - jiffies >= 0); i++) | 372 | for (i = 0; i < 32768 && time_after_eq(limit, jiffies); i++) |
373 | val = inw(REG(PSS_STATUS)); | 373 | val = inw(REG(PSS_STATUS)); |
374 | 374 | ||
375 | limit = jiffies + HZ/10; | 375 | limit = jiffies + HZ/10; |
376 | for (i = 0; i < 32768 && (limit-jiffies >= 0); i++) | 376 | for (i = 0; i < 32768 && time_after_eq(limit, jiffies); i++) |
377 | { | 377 | { |
378 | val = inw(REG(PSS_STATUS)); | 378 | val = inw(REG(PSS_STATUS)); |
379 | if (val & 0x4000) | 379 | if (val & 0x4000) |
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 20cb60afb200..c11920623009 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c | |||
@@ -2122,7 +2122,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, | |||
2122 | } | 2122 | } |
2123 | /* nothing should be in powerdown mode */ | 2123 | /* nothing should be in powerdown mode */ |
2124 | snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0); | 2124 | snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0); |
2125 | end_time = jiffies + msecs_to_jiffies(120); | 2125 | end_time = jiffies + msecs_to_jiffies(5000); |
2126 | do { | 2126 | do { |
2127 | if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f) | 2127 | if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f) |
2128 | goto __ready_ok; | 2128 | goto __ready_ok; |
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 1be96ead4244..e6b4a879ae2e 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c | |||
@@ -3597,7 +3597,7 @@ static struct cs_card_type __devinitdata cards[] = { | |||
3597 | #ifdef CONFIG_PM | 3597 | #ifdef CONFIG_PM |
3598 | static unsigned int saved_regs[] = { | 3598 | static unsigned int saved_regs[] = { |
3599 | BA0_ACOSV, | 3599 | BA0_ACOSV, |
3600 | BA0_ASER_FADDR, | 3600 | /*BA0_ASER_FADDR,*/ |
3601 | BA0_ASER_MASTER, | 3601 | BA0_ASER_MASTER, |
3602 | BA1_PVOL, | 3602 | BA1_PVOL, |
3603 | BA1_CVOL, | 3603 | BA1_CVOL, |
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index f4f0c8f5dad7..3e5ca8fb519f 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c | |||
@@ -298,6 +298,9 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) | |||
298 | if (ins->scbs[i].deleted) continue; | 298 | if (ins->scbs[i].deleted) continue; |
299 | 299 | ||
300 | cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); | 300 | cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); |
301 | #ifdef CONFIG_PM | ||
302 | kfree(ins->scbs[i].data); | ||
303 | #endif | ||
301 | } | 304 | } |
302 | 305 | ||
303 | kfree(ins->code.data); | 306 | kfree(ins->code.data); |
@@ -974,13 +977,11 @@ static struct dsp_scb_descriptor * _map_scb (struct snd_cs46xx *chip, char * nam | |||
974 | 977 | ||
975 | index = find_free_scb_index (ins); | 978 | index = find_free_scb_index (ins); |
976 | 979 | ||
980 | memset(&ins->scbs[index], 0, sizeof(ins->scbs[index])); | ||
977 | strcpy(ins->scbs[index].scb_name, name); | 981 | strcpy(ins->scbs[index].scb_name, name); |
978 | ins->scbs[index].address = dest; | 982 | ins->scbs[index].address = dest; |
979 | ins->scbs[index].index = index; | 983 | ins->scbs[index].index = index; |
980 | ins->scbs[index].proc_info = NULL; | ||
981 | ins->scbs[index].ref_count = 1; | 984 | ins->scbs[index].ref_count = 1; |
982 | ins->scbs[index].deleted = 0; | ||
983 | spin_lock_init(&ins->scbs[index].lock); | ||
984 | 985 | ||
985 | desc = (ins->scbs + index); | 986 | desc = (ins->scbs + index); |
986 | ins->scbs[index].scb_symbol = add_symbol (chip, name, dest, SYMBOL_PARAMETER); | 987 | ins->scbs[index].scb_symbol = add_symbol (chip, name, dest, SYMBOL_PARAMETER); |
@@ -1022,17 +1023,29 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size) | |||
1022 | return desc; | 1023 | return desc; |
1023 | } | 1024 | } |
1024 | 1025 | ||
1026 | #define SCB_BYTES (0x10 * 4) | ||
1027 | |||
1025 | struct dsp_scb_descriptor * | 1028 | struct dsp_scb_descriptor * |
1026 | cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest) | 1029 | cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest) |
1027 | { | 1030 | { |
1028 | struct dsp_scb_descriptor * desc; | 1031 | struct dsp_scb_descriptor * desc; |
1029 | 1032 | ||
1033 | #ifdef CONFIG_PM | ||
1034 | /* copy the data for resume */ | ||
1035 | scb_data = kmemdup(scb_data, SCB_BYTES, GFP_KERNEL); | ||
1036 | if (!scb_data) | ||
1037 | return NULL; | ||
1038 | #endif | ||
1039 | |||
1030 | desc = _map_scb (chip,name,dest); | 1040 | desc = _map_scb (chip,name,dest); |
1031 | if (desc) { | 1041 | if (desc) { |
1032 | desc->data = scb_data; | 1042 | desc->data = scb_data; |
1033 | _dsp_create_scb(chip,scb_data,dest); | 1043 | _dsp_create_scb(chip,scb_data,dest); |
1034 | } else { | 1044 | } else { |
1035 | snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); | 1045 | snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); |
1046 | #ifdef CONFIG_PM | ||
1047 | kfree(scb_data); | ||
1048 | #endif | ||
1036 | } | 1049 | } |
1037 | 1050 | ||
1038 | return desc; | 1051 | return desc; |
@@ -1988,7 +2001,28 @@ int cs46xx_dsp_resume(struct snd_cs46xx * chip) | |||
1988 | continue; | 2001 | continue; |
1989 | _dsp_create_scb(chip, s->data, s->address); | 2002 | _dsp_create_scb(chip, s->data, s->address); |
1990 | } | 2003 | } |
1991 | 2004 | for (i = 0; i < ins->nscb; i++) { | |
2005 | struct dsp_scb_descriptor *s = &ins->scbs[i]; | ||
2006 | if (s->deleted) | ||
2007 | continue; | ||
2008 | if (s->updated) | ||
2009 | cs46xx_dsp_spos_update_scb(chip, s); | ||
2010 | if (s->volume_set) | ||
2011 | cs46xx_dsp_scb_set_volume(chip, s, | ||
2012 | s->volume[0], s->volume[1]); | ||
2013 | } | ||
2014 | if (ins->spdif_status_out & DSP_SPDIF_STATUS_HW_ENABLED) { | ||
2015 | cs46xx_dsp_enable_spdif_hw(chip); | ||
2016 | snd_cs46xx_poke(chip, (ins->ref_snoop_scb->address + 2) << 2, | ||
2017 | (OUTPUT_SNOOP_BUFFER + 0x10) << 0x10); | ||
2018 | if (ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) | ||
2019 | cs46xx_poke_via_dsp(chip, SP_SPDOUT_CSUV, | ||
2020 | ins->spdif_csuv_stream); | ||
2021 | } | ||
2022 | if (chip->dsp_spos_instance->spdif_status_in) { | ||
2023 | cs46xx_poke_via_dsp(chip, SP_ASER_COUNTDOWN, 0x80000005); | ||
2024 | cs46xx_poke_via_dsp(chip, SP_SPDIN_CONTROL, 0x800003ff); | ||
2025 | } | ||
1992 | return 0; | 2026 | return 0; |
1993 | } | 2027 | } |
1994 | #endif | 2028 | #endif |
diff --git a/sound/pci/cs46xx/dsp_spos.h b/sound/pci/cs46xx/dsp_spos.h index f9e169d33c03..ca47a8114c7f 100644 --- a/sound/pci/cs46xx/dsp_spos.h +++ b/sound/pci/cs46xx/dsp_spos.h | |||
@@ -212,6 +212,7 @@ static inline void cs46xx_dsp_spos_update_scb (struct snd_cs46xx * chip, | |||
212 | (scb->address + SCBsubListPtr) << 2, | 212 | (scb->address + SCBsubListPtr) << 2, |
213 | (scb->sub_list_ptr->address << 0x10) | | 213 | (scb->sub_list_ptr->address << 0x10) | |
214 | (scb->next_scb_ptr->address)); | 214 | (scb->next_scb_ptr->address)); |
215 | scb->updated = 1; | ||
215 | } | 216 | } |
216 | 217 | ||
217 | static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, | 218 | static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, |
@@ -222,6 +223,9 @@ static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, | |||
222 | 223 | ||
223 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); | 224 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); |
224 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl + 1) << 2, val); | 225 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl + 1) << 2, val); |
226 | scb->volume_set = 1; | ||
227 | scb->volume[0] = left; | ||
228 | scb->volume[1] = right; | ||
225 | } | 229 | } |
226 | #endif /* __DSP_SPOS_H__ */ | 230 | #endif /* __DSP_SPOS_H__ */ |
227 | #endif /* CONFIG_SND_CS46XX_NEW_DSP */ | 231 | #endif /* CONFIG_SND_CS46XX_NEW_DSP */ |
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index dd7c41b037b4..00b148a10239 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c | |||
@@ -115,7 +115,6 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, | |||
115 | static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) | 115 | static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) |
116 | { | 116 | { |
117 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 117 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
118 | unsigned long flags; | ||
119 | 118 | ||
120 | if ( scb->parent_scb_ptr ) { | 119 | if ( scb->parent_scb_ptr ) { |
121 | /* unlink parent SCB */ | 120 | /* unlink parent SCB */ |
@@ -153,8 +152,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor | |||
153 | scb->next_scb_ptr = ins->the_null_scb; | 152 | scb->next_scb_ptr = ins->the_null_scb; |
154 | } | 153 | } |
155 | 154 | ||
156 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
157 | |||
158 | /* update parent first entry in DSP RAM */ | 155 | /* update parent first entry in DSP RAM */ |
159 | cs46xx_dsp_spos_update_scb(chip,scb->parent_scb_ptr); | 156 | cs46xx_dsp_spos_update_scb(chip,scb->parent_scb_ptr); |
160 | 157 | ||
@@ -162,7 +159,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor | |||
162 | cs46xx_dsp_spos_update_scb(chip,scb); | 159 | cs46xx_dsp_spos_update_scb(chip,scb); |
163 | 160 | ||
164 | scb->parent_scb_ptr = NULL; | 161 | scb->parent_scb_ptr = NULL; |
165 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
166 | } | 162 | } |
167 | } | 163 | } |
168 | 164 | ||
@@ -197,9 +193,9 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * | |||
197 | goto _end; | 193 | goto _end; |
198 | #endif | 194 | #endif |
199 | 195 | ||
200 | spin_lock_irqsave(&scb->lock, flags); | 196 | spin_lock_irqsave(&chip->reg_lock, flags); |
201 | _dsp_unlink_scb (chip,scb); | 197 | _dsp_unlink_scb (chip,scb); |
202 | spin_unlock_irqrestore(&scb->lock, flags); | 198 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
203 | 199 | ||
204 | cs46xx_dsp_proc_free_scb_desc(scb); | 200 | cs46xx_dsp_proc_free_scb_desc(scb); |
205 | if (snd_BUG_ON(!scb->scb_symbol)) | 201 | if (snd_BUG_ON(!scb->scb_symbol)) |
@@ -207,6 +203,10 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * | |||
207 | remove_symbol (chip,scb->scb_symbol); | 203 | remove_symbol (chip,scb->scb_symbol); |
208 | 204 | ||
209 | ins->scbs[scb->index].deleted = 1; | 205 | ins->scbs[scb->index].deleted = 1; |
206 | #ifdef CONFIG_PM | ||
207 | kfree(ins->scbs[scb->index].data); | ||
208 | ins->scbs[scb->index].data = NULL; | ||
209 | #endif | ||
210 | 210 | ||
211 | if (scb->index < ins->scb_highest_frag_index) | 211 | if (scb->index < ins->scb_highest_frag_index) |
212 | ins->scb_highest_frag_index = scb->index; | 212 | ins->scb_highest_frag_index = scb->index; |
@@ -1508,20 +1508,17 @@ int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, | |||
1508 | chip->dsp_spos_instance->npcm_channels <= 0)) | 1508 | chip->dsp_spos_instance->npcm_channels <= 0)) |
1509 | return -EIO; | 1509 | return -EIO; |
1510 | 1510 | ||
1511 | spin_lock(&pcm_channel->src_scb->lock); | 1511 | spin_lock_irqsave(&chip->reg_lock, flags); |
1512 | |||
1513 | if (pcm_channel->unlinked) { | 1512 | if (pcm_channel->unlinked) { |
1514 | spin_unlock(&pcm_channel->src_scb->lock); | 1513 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1515 | return -EIO; | 1514 | return -EIO; |
1516 | } | 1515 | } |
1517 | 1516 | ||
1518 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
1519 | pcm_channel->unlinked = 1; | 1517 | pcm_channel->unlinked = 1; |
1520 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
1521 | 1518 | ||
1522 | _dsp_unlink_scb (chip,pcm_channel->pcm_reader_scb); | 1519 | _dsp_unlink_scb (chip,pcm_channel->pcm_reader_scb); |
1520 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
1523 | 1521 | ||
1524 | spin_unlock(&pcm_channel->src_scb->lock); | ||
1525 | return 0; | 1522 | return 0; |
1526 | } | 1523 | } |
1527 | 1524 | ||
@@ -1533,10 +1530,10 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1533 | struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; | 1530 | struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; |
1534 | unsigned long flags; | 1531 | unsigned long flags; |
1535 | 1532 | ||
1536 | spin_lock(&pcm_channel->src_scb->lock); | 1533 | spin_lock_irqsave(&chip->reg_lock, flags); |
1537 | 1534 | ||
1538 | if (pcm_channel->unlinked == 0) { | 1535 | if (pcm_channel->unlinked == 0) { |
1539 | spin_unlock(&pcm_channel->src_scb->lock); | 1536 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1540 | return -EIO; | 1537 | return -EIO; |
1541 | } | 1538 | } |
1542 | 1539 | ||
@@ -1552,8 +1549,6 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1552 | snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); | 1549 | snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); |
1553 | pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; | 1550 | pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; |
1554 | 1551 | ||
1555 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
1556 | |||
1557 | /* update SCB entry in DSP RAM */ | 1552 | /* update SCB entry in DSP RAM */ |
1558 | cs46xx_dsp_spos_update_scb(chip,pcm_channel->pcm_reader_scb); | 1553 | cs46xx_dsp_spos_update_scb(chip,pcm_channel->pcm_reader_scb); |
1559 | 1554 | ||
@@ -1562,8 +1557,6 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1562 | 1557 | ||
1563 | pcm_channel->unlinked = 0; | 1558 | pcm_channel->unlinked = 0; |
1564 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1559 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1565 | |||
1566 | spin_unlock(&pcm_channel->src_scb->lock); | ||
1567 | return 0; | 1560 | return 0; |
1568 | } | 1561 | } |
1569 | 1562 | ||
@@ -1596,13 +1589,17 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s | |||
1596 | 1589 | ||
1597 | int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) | 1590 | int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) |
1598 | { | 1591 | { |
1592 | unsigned long flags; | ||
1593 | |||
1599 | if (snd_BUG_ON(!src->parent_scb_ptr)) | 1594 | if (snd_BUG_ON(!src->parent_scb_ptr)) |
1600 | return -EINVAL; | 1595 | return -EINVAL; |
1601 | 1596 | ||
1602 | /* mute SCB */ | 1597 | /* mute SCB */ |
1603 | cs46xx_dsp_scb_set_volume (chip,src,0,0); | 1598 | cs46xx_dsp_scb_set_volume (chip,src,0,0); |
1604 | 1599 | ||
1600 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
1605 | _dsp_unlink_scb (chip,src); | 1601 | _dsp_unlink_scb (chip,src); |
1602 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
1606 | 1603 | ||
1607 | return 0; | 1604 | return 0; |
1608 | } | 1605 | } |
diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile index fda7a94c992f..ccc642269b9e 100644 --- a/sound/pci/cs5535audio/Makefile +++ b/sound/pci/cs5535audio/Makefile | |||
@@ -4,9 +4,7 @@ | |||
4 | 4 | ||
5 | snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o | 5 | snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o |
6 | snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o | 6 | snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o |
7 | ifdef CONFIG_MGEODE_LX | ||
8 | snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o | 7 | snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o |
9 | endif | ||
10 | 8 | ||
11 | # Toplevel Module Dependency | 9 | # Toplevel Module Dependency |
12 | obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o | 10 | obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o |
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 05f56e04849b..91e7faf69bbb 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c | |||
@@ -389,6 +389,7 @@ probefail_out: | |||
389 | 389 | ||
390 | static void __devexit snd_cs5535audio_remove(struct pci_dev *pci) | 390 | static void __devexit snd_cs5535audio_remove(struct pci_dev *pci) |
391 | { | 391 | { |
392 | olpc_quirks_cleanup(); | ||
392 | snd_card_free(pci_get_drvdata(pci)); | 393 | snd_card_free(pci_get_drvdata(pci)); |
393 | pci_set_drvdata(pci, NULL); | 394 | pci_set_drvdata(pci, NULL); |
394 | } | 395 | } |
diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 7a298ac662e3..51966d782a3c 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h | |||
@@ -99,10 +99,11 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); | |||
99 | int snd_cs5535audio_resume(struct pci_dev *pci); | 99 | int snd_cs5535audio_resume(struct pci_dev *pci); |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #if defined(CONFIG_OLPC) && defined(CONFIG_MGEODE_LX) | 102 | #ifdef CONFIG_OLPC |
103 | void __devinit olpc_prequirks(struct snd_card *card, | 103 | void __devinit olpc_prequirks(struct snd_card *card, |
104 | struct snd_ac97_template *ac97); | 104 | struct snd_ac97_template *ac97); |
105 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); | 105 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); |
106 | void __devexit olpc_quirks_cleanup(void); | ||
106 | void olpc_analog_input(struct snd_ac97 *ac97, int on); | 107 | void olpc_analog_input(struct snd_ac97 *ac97, int on); |
107 | void olpc_mic_bias(struct snd_ac97 *ac97, int on); | 108 | void olpc_mic_bias(struct snd_ac97 *ac97, int on); |
108 | 109 | ||
@@ -128,6 +129,7 @@ static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | |||
128 | { | 129 | { |
129 | return 0; | 130 | return 0; |
130 | } | 131 | } |
132 | static inline void olpc_quirks_cleanup(void) { } | ||
131 | static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } | 133 | static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } |
132 | static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { } | 134 | static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { } |
133 | static inline void olpc_capture_open(struct snd_ac97 *ac97) { } | 135 | static inline void olpc_capture_open(struct snd_ac97 *ac97) { } |
diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index 5c6814335cd7..50da49be9ae5 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c | |||
@@ -13,10 +13,13 @@ | |||
13 | #include <sound/info.h> | 13 | #include <sound/info.h> |
14 | #include <sound/control.h> | 14 | #include <sound/control.h> |
15 | #include <sound/ac97_codec.h> | 15 | #include <sound/ac97_codec.h> |
16 | #include <linux/gpio.h> | ||
16 | 17 | ||
17 | #include <asm/olpc.h> | 18 | #include <asm/olpc.h> |
18 | #include "cs5535audio.h" | 19 | #include "cs5535audio.h" |
19 | 20 | ||
21 | #define DRV_NAME "cs5535audio-olpc" | ||
22 | |||
20 | /* | 23 | /* |
21 | * OLPC has an additional feature on top of the regular AD1888 codec features. | 24 | * OLPC has an additional feature on top of the regular AD1888 codec features. |
22 | * It has an Analog Input mode that is switched into (after disabling the | 25 | * It has an Analog Input mode that is switched into (after disabling the |
@@ -38,10 +41,7 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on) | |||
38 | } | 41 | } |
39 | 42 | ||
40 | /* set Analog Input through GPIO */ | 43 | /* set Analog Input through GPIO */ |
41 | if (on) | 44 | gpio_set_value(OLPC_GPIO_MIC_AC, on); |
42 | geode_gpio_set(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); | ||
43 | else | ||
44 | geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); | ||
45 | } | 45 | } |
46 | 46 | ||
47 | /* | 47 | /* |
@@ -73,8 +73,7 @@ static int olpc_dc_info(struct snd_kcontrol *kctl, | |||
73 | 73 | ||
74 | static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | 74 | static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) |
75 | { | 75 | { |
76 | v->value.integer.value[0] = geode_gpio_isset(OLPC_GPIO_MIC_AC, | 76 | v->value.integer.value[0] = gpio_get_value(OLPC_GPIO_MIC_AC); |
77 | GPIO_OUTPUT_VAL); | ||
78 | return 0; | 77 | return 0; |
79 | } | 78 | } |
80 | 79 | ||
@@ -153,6 +152,12 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | |||
153 | if (!machine_is_olpc()) | 152 | if (!machine_is_olpc()) |
154 | return 0; | 153 | return 0; |
155 | 154 | ||
155 | if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) { | ||
156 | printk(KERN_ERR DRV_NAME ": unable to allocate MIC GPIO\n"); | ||
157 | return -EIO; | ||
158 | } | ||
159 | gpio_direction_output(OLPC_GPIO_MIC_AC, 0); | ||
160 | |||
156 | /* drop the original AD1888 HPF control */ | 161 | /* drop the original AD1888 HPF control */ |
157 | memset(&elem, 0, sizeof(elem)); | 162 | memset(&elem, 0, sizeof(elem)); |
158 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 163 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
@@ -169,11 +174,18 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | |||
169 | for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) { | 174 | for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) { |
170 | err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i], | 175 | err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i], |
171 | ac97->private_data)); | 176 | ac97->private_data)); |
172 | if (err < 0) | 177 | if (err < 0) { |
178 | gpio_free(OLPC_GPIO_MIC_AC); | ||
173 | return err; | 179 | return err; |
180 | } | ||
174 | } | 181 | } |
175 | 182 | ||
176 | /* turn off the mic by default */ | 183 | /* turn off the mic by default */ |
177 | olpc_mic_bias(ac97, 0); | 184 | olpc_mic_bias(ac97, 0); |
178 | return 0; | 185 | return 0; |
179 | } | 186 | } |
187 | |||
188 | void __devexit olpc_quirks_cleanup(void) | ||
189 | { | ||
190 | gpio_free(OLPC_GPIO_MIC_AC); | ||
191 | } | ||
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index c848ec0f085e..d2f10b1c3a8a 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1088,11 +1088,6 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1088 | if (err < 0) | 1088 | if (err < 0) |
1089 | return err; | 1089 | return err; |
1090 | } | 1090 | } |
1091 | /* audio codec should override the mixer name */ | ||
1092 | if (codec->afg || !*codec->bus->card->mixername) | ||
1093 | snprintf(codec->bus->card->mixername, | ||
1094 | sizeof(codec->bus->card->mixername), | ||
1095 | "%s %s", codec->vendor_name, codec->chip_name); | ||
1096 | 1091 | ||
1097 | if (is_generic_config(codec)) { | 1092 | if (is_generic_config(codec)) { |
1098 | err = snd_hda_parse_generic_codec(codec); | 1093 | err = snd_hda_parse_generic_codec(codec); |
@@ -1111,6 +1106,11 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1111 | patched: | 1106 | patched: |
1112 | if (!err && codec->patch_ops.unsol_event) | 1107 | if (!err && codec->patch_ops.unsol_event) |
1113 | err = init_unsol_queue(codec->bus); | 1108 | err = init_unsol_queue(codec->bus); |
1109 | /* audio codec should override the mixer name */ | ||
1110 | if (!err && (codec->afg || !*codec->bus->card->mixername)) | ||
1111 | snprintf(codec->bus->card->mixername, | ||
1112 | sizeof(codec->bus->card->mixername), | ||
1113 | "%s %s", codec->vendor_name, codec->chip_name); | ||
1114 | return err; | 1114 | return err; |
1115 | } | 1115 | } |
1116 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); | 1116 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); |
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index d24328661c6a..40ccb419b6e9 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/compat.h> | 24 | #include <linux/compat.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/ctype.h> | 26 | #include <linux/ctype.h> |
27 | #include <linux/string.h> | ||
27 | #include <linux/firmware.h> | 28 | #include <linux/firmware.h> |
28 | #include <sound/core.h> | 29 | #include <sound/core.h> |
29 | #include "hda_codec.h" | 30 | #include "hda_codec.h" |
@@ -428,8 +429,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf) | |||
428 | char *key, *val; | 429 | char *key, *val; |
429 | struct hda_hint *hint; | 430 | struct hda_hint *hint; |
430 | 431 | ||
431 | while (isspace(*buf)) | 432 | buf = skip_spaces(buf); |
432 | buf++; | ||
433 | if (!*buf || *buf == '#' || *buf == '\n') | 433 | if (!*buf || *buf == '#' || *buf == '\n') |
434 | return 0; | 434 | return 0; |
435 | if (*buf == '=') | 435 | if (*buf == '=') |
@@ -444,8 +444,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf) | |||
444 | return -EINVAL; | 444 | return -EINVAL; |
445 | } | 445 | } |
446 | *val++ = 0; | 446 | *val++ = 0; |
447 | while (isspace(*val)) | 447 | val = skip_spaces(val); |
448 | val++; | ||
449 | remove_trail_spaces(key); | 448 | remove_trail_spaces(key); |
450 | remove_trail_spaces(val); | 449 | remove_trail_spaces(val); |
451 | hint = get_hint(codec, key); | 450 | hint = get_hint(codec, key); |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index e54420e691ae..ff8ad46cc50e 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -2322,6 +2322,7 @@ static void __devinit check_probe_mask(struct azx *chip, int dev) | |||
2322 | * white/black-list for enable_msi | 2322 | * white/black-list for enable_msi |
2323 | */ | 2323 | */ |
2324 | static struct snd_pci_quirk msi_black_list[] __devinitdata = { | 2324 | static struct snd_pci_quirk msi_black_list[] __devinitdata = { |
2325 | SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ | ||
2325 | {} | 2326 | {} |
2326 | }; | 2327 | }; |
2327 | 2328 | ||
@@ -2713,6 +2714,9 @@ static struct pci_device_id azx_ids[] = { | |||
2713 | { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, | 2714 | { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, |
2714 | { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, | 2715 | { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, |
2715 | { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, | 2716 | { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, |
2717 | { PCI_DEVICE(0x10de, 0x0be2), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2718 | { PCI_DEVICE(0x10de, 0x0be3), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2719 | { PCI_DEVICE(0x10de, 0x0be4), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2716 | { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA }, | 2720 | { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA }, |
2717 | { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA }, | 2721 | { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA }, |
2718 | { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA }, | 2722 | { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA }, |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index e75b5e5a1d55..92b72d4f3984 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -1813,6 +1813,14 @@ static int patch_ad1981(struct hda_codec *codec) | |||
1813 | 1813 | ||
1814 | codec->patch_ops.init = ad1981_hp_init; | 1814 | codec->patch_ops.init = ad1981_hp_init; |
1815 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; | 1815 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
1816 | /* set the upper-limit for mixer amp to 0dB for avoiding the | ||
1817 | * possible damage by overloading | ||
1818 | */ | ||
1819 | snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT, | ||
1820 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | ||
1821 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
1822 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
1823 | (1 << AC_AMPCAP_MUTE_SHIFT)); | ||
1816 | break; | 1824 | break; |
1817 | case AD1981_THINKPAD: | 1825 | case AD1981_THINKPAD: |
1818 | spec->mixers[0] = ad1981_thinkpad_mixers; | 1826 | spec->mixers[0] = ad1981_thinkpad_mixers; |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index eeb91f6a06c2..093cfbb55e9e 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -66,6 +66,7 @@ struct cs_spec { | |||
66 | /* available models */ | 66 | /* available models */ |
67 | enum { | 67 | enum { |
68 | CS420X_MBP55, | 68 | CS420X_MBP55, |
69 | CS420X_IMAC27, | ||
69 | CS420X_AUTO, | 70 | CS420X_AUTO, |
70 | CS420X_MODELS | 71 | CS420X_MODELS |
71 | }; | 72 | }; |
@@ -833,7 +834,8 @@ static void cs_automute(struct hda_codec *codec) | |||
833 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 834 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
834 | hp_present ? 0 : PIN_OUT); | 835 | hp_present ? 0 : PIN_OUT); |
835 | } | 836 | } |
836 | if (spec->board_config == CS420X_MBP55) { | 837 | if (spec->board_config == CS420X_MBP55 || |
838 | spec->board_config == CS420X_IMAC27) { | ||
837 | unsigned int gpio = hp_present ? 0x02 : 0x08; | 839 | unsigned int gpio = hp_present ? 0x02 : 0x08; |
838 | snd_hda_codec_write(codec, 0x01, 0, | 840 | snd_hda_codec_write(codec, 0x01, 0, |
839 | AC_VERB_SET_GPIO_DATA, gpio); | 841 | AC_VERB_SET_GPIO_DATA, gpio); |
@@ -1075,12 +1077,14 @@ static int cs_parse_auto_config(struct hda_codec *codec) | |||
1075 | 1077 | ||
1076 | static const char *cs420x_models[CS420X_MODELS] = { | 1078 | static const char *cs420x_models[CS420X_MODELS] = { |
1077 | [CS420X_MBP55] = "mbp55", | 1079 | [CS420X_MBP55] = "mbp55", |
1080 | [CS420X_IMAC27] = "imac27", | ||
1078 | [CS420X_AUTO] = "auto", | 1081 | [CS420X_AUTO] = "auto", |
1079 | }; | 1082 | }; |
1080 | 1083 | ||
1081 | 1084 | ||
1082 | static struct snd_pci_quirk cs420x_cfg_tbl[] = { | 1085 | static struct snd_pci_quirk cs420x_cfg_tbl[] = { |
1083 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), | 1086 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), |
1087 | SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), | ||
1084 | {} /* terminator */ | 1088 | {} /* terminator */ |
1085 | }; | 1089 | }; |
1086 | 1090 | ||
@@ -1103,8 +1107,23 @@ static struct cs_pincfg mbp55_pincfgs[] = { | |||
1103 | {} /* terminator */ | 1107 | {} /* terminator */ |
1104 | }; | 1108 | }; |
1105 | 1109 | ||
1110 | static struct cs_pincfg imac27_pincfgs[] = { | ||
1111 | { 0x09, 0x012b4050 }, | ||
1112 | { 0x0a, 0x90100140 }, | ||
1113 | { 0x0b, 0x90100142 }, | ||
1114 | { 0x0c, 0x018b3020 }, | ||
1115 | { 0x0d, 0x90a00110 }, | ||
1116 | { 0x0e, 0x400000f0 }, | ||
1117 | { 0x0f, 0x01cbe030 }, | ||
1118 | { 0x10, 0x014be060 }, | ||
1119 | { 0x12, 0x01ab9070 }, | ||
1120 | { 0x15, 0x400000f0 }, | ||
1121 | {} /* terminator */ | ||
1122 | }; | ||
1123 | |||
1106 | static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { | 1124 | static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { |
1107 | [CS420X_MBP55] = mbp55_pincfgs, | 1125 | [CS420X_MBP55] = mbp55_pincfgs, |
1126 | [CS420X_IMAC27] = imac27_pincfgs, | ||
1108 | }; | 1127 | }; |
1109 | 1128 | ||
1110 | static void fix_pincfg(struct hda_codec *codec, int model) | 1129 | static void fix_pincfg(struct hda_codec *codec, int model) |
@@ -1134,6 +1153,7 @@ static int patch_cs420x(struct hda_codec *codec) | |||
1134 | fix_pincfg(codec, spec->board_config); | 1153 | fix_pincfg(codec, spec->board_config); |
1135 | 1154 | ||
1136 | switch (spec->board_config) { | 1155 | switch (spec->board_config) { |
1156 | case CS420X_IMAC27: | ||
1137 | case CS420X_MBP55: | 1157 | case CS420X_MBP55: |
1138 | /* GPIO1 = headphones */ | 1158 | /* GPIO1 = headphones */ |
1139 | /* GPIO3 = speakers */ | 1159 | /* GPIO3 = speakers */ |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 1ab2958a290b..947785f43b28 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include "hda_codec.h" | 30 | #include "hda_codec.h" |
31 | #include "hda_local.h" | 31 | #include "hda_local.h" |
32 | #include "hda_beep.h" | ||
32 | 33 | ||
33 | #define CXT_PIN_DIR_IN 0x00 | 34 | #define CXT_PIN_DIR_IN 0x00 |
34 | #define CXT_PIN_DIR_OUT 0x01 | 35 | #define CXT_PIN_DIR_OUT 0x01 |
@@ -111,6 +112,7 @@ struct conexant_spec { | |||
111 | unsigned int dell_automute; | 112 | unsigned int dell_automute; |
112 | unsigned int port_d_mode; | 113 | unsigned int port_d_mode; |
113 | unsigned char ext_mic_bias; | 114 | unsigned char ext_mic_bias; |
115 | unsigned int dell_vostro; | ||
114 | }; | 116 | }; |
115 | 117 | ||
116 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | 118 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
@@ -476,6 +478,7 @@ static void conexant_free(struct hda_codec *codec) | |||
476 | snd_array_free(&spec->jacks); | 478 | snd_array_free(&spec->jacks); |
477 | } | 479 | } |
478 | #endif | 480 | #endif |
481 | snd_hda_detach_beep_device(codec); | ||
479 | kfree(codec->spec); | 482 | kfree(codec->spec); |
480 | } | 483 | } |
481 | 484 | ||
@@ -2109,9 +2112,12 @@ static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | |||
2109 | { | 2112 | { |
2110 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2113 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2111 | int val; | 2114 | int val; |
2115 | hda_nid_t nid = kcontrol->private_value & 0xff; | ||
2116 | int inout = (kcontrol->private_value & 0x100) ? | ||
2117 | AC_AMP_GET_INPUT : AC_AMP_GET_OUTPUT; | ||
2112 | 2118 | ||
2113 | val = snd_hda_codec_read(codec, 0x17, 0, | 2119 | val = snd_hda_codec_read(codec, nid, 0, |
2114 | AC_VERB_GET_AMP_GAIN_MUTE, AC_AMP_GET_OUTPUT); | 2120 | AC_VERB_GET_AMP_GAIN_MUTE, inout); |
2115 | 2121 | ||
2116 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; | 2122 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; |
2117 | return 0; | 2123 | return 0; |
@@ -2123,6 +2129,9 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
2123 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2129 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2124 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | 2130 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
2125 | unsigned int idx; | 2131 | unsigned int idx; |
2132 | hda_nid_t nid = kcontrol->private_value & 0xff; | ||
2133 | int inout = (kcontrol->private_value & 0x100) ? | ||
2134 | AC_AMP_SET_INPUT : AC_AMP_SET_OUTPUT; | ||
2126 | 2135 | ||
2127 | if (!imux->num_items) | 2136 | if (!imux->num_items) |
2128 | return 0; | 2137 | return 0; |
@@ -2130,9 +2139,9 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
2130 | if (idx >= imux->num_items) | 2139 | if (idx >= imux->num_items) |
2131 | idx = imux->num_items - 1; | 2140 | idx = imux->num_items - 1; |
2132 | 2141 | ||
2133 | snd_hda_codec_write_cache(codec, 0x17, 0, | 2142 | snd_hda_codec_write_cache(codec, nid, 0, |
2134 | AC_VERB_SET_AMP_GAIN_MUTE, | 2143 | AC_VERB_SET_AMP_GAIN_MUTE, |
2135 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | 2144 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | inout | |
2136 | imux->items[idx].index); | 2145 | imux->items[idx].index); |
2137 | 2146 | ||
2138 | return 1; | 2147 | return 1; |
@@ -2202,10 +2211,11 @@ static struct snd_kcontrol_new cxt5066_mixers[] = { | |||
2202 | 2211 | ||
2203 | { | 2212 | { |
2204 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2213 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2205 | .name = "Analog Mic Boost Capture Enum", | 2214 | .name = "Ext Mic Boost Capture Enum", |
2206 | .info = cxt5066_mic_boost_mux_enum_info, | 2215 | .info = cxt5066_mic_boost_mux_enum_info, |
2207 | .get = cxt5066_mic_boost_mux_enum_get, | 2216 | .get = cxt5066_mic_boost_mux_enum_get, |
2208 | .put = cxt5066_mic_boost_mux_enum_put, | 2217 | .put = cxt5066_mic_boost_mux_enum_put, |
2218 | .private_value = 0x17, | ||
2209 | }, | 2219 | }, |
2210 | 2220 | ||
2211 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | 2221 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), |
@@ -2213,6 +2223,19 @@ static struct snd_kcontrol_new cxt5066_mixers[] = { | |||
2213 | {} | 2223 | {} |
2214 | }; | 2224 | }; |
2215 | 2225 | ||
2226 | static struct snd_kcontrol_new cxt5066_vostro_mixers[] = { | ||
2227 | { | ||
2228 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2229 | .name = "Int Mic Boost Capture Enum", | ||
2230 | .info = cxt5066_mic_boost_mux_enum_info, | ||
2231 | .get = cxt5066_mic_boost_mux_enum_get, | ||
2232 | .put = cxt5066_mic_boost_mux_enum_put, | ||
2233 | .private_value = 0x23 | 0x100, | ||
2234 | }, | ||
2235 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), | ||
2236 | {} | ||
2237 | }; | ||
2238 | |||
2216 | static struct hda_verb cxt5066_init_verbs[] = { | 2239 | static struct hda_verb cxt5066_init_verbs[] = { |
2217 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ | 2240 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
2218 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | 2241 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
@@ -2398,11 +2421,16 @@ static struct hda_verb cxt5066_init_verbs_portd_lo[] = { | |||
2398 | /* initialize jack-sensing, too */ | 2421 | /* initialize jack-sensing, too */ |
2399 | static int cxt5066_init(struct hda_codec *codec) | 2422 | static int cxt5066_init(struct hda_codec *codec) |
2400 | { | 2423 | { |
2424 | struct conexant_spec *spec = codec->spec; | ||
2425 | |||
2401 | snd_printdd("CXT5066: init\n"); | 2426 | snd_printdd("CXT5066: init\n"); |
2402 | conexant_init(codec); | 2427 | conexant_init(codec); |
2403 | if (codec->patch_ops.unsol_event) { | 2428 | if (codec->patch_ops.unsol_event) { |
2404 | cxt5066_hp_automute(codec); | 2429 | cxt5066_hp_automute(codec); |
2405 | cxt5066_automic(codec); | 2430 | if (spec->dell_vostro) |
2431 | cxt5066_vostro_automic(codec); | ||
2432 | else | ||
2433 | cxt5066_automic(codec); | ||
2406 | } | 2434 | } |
2407 | return 0; | 2435 | return 0; |
2408 | } | 2436 | } |
@@ -2501,7 +2529,10 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2501 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; | 2529 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
2502 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | 2530 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
2503 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | 2531 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
2532 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; | ||
2504 | spec->port_d_mode = 0; | 2533 | spec->port_d_mode = 0; |
2534 | spec->dell_vostro = 1; | ||
2535 | snd_hda_attach_beep_device(codec, 0x13); | ||
2505 | 2536 | ||
2506 | /* no S/PDIF out */ | 2537 | /* no S/PDIF out */ |
2507 | spec->multiout.dig_out_nid = 0; | 2538 | spec->multiout.dig_out_nid = 0; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cb7679551bdc..aeb23ef6afe5 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -131,8 +131,8 @@ enum { | |||
131 | enum { | 131 | enum { |
132 | ALC269_BASIC, | 132 | ALC269_BASIC, |
133 | ALC269_QUANTA_FL1, | 133 | ALC269_QUANTA_FL1, |
134 | ALC269_ASUS_EEEPC_P703, | 134 | ALC269_ASUS_AMIC, |
135 | ALC269_ASUS_EEEPC_P901, | 135 | ALC269_ASUS_DMIC, |
136 | ALC269_FUJITSU, | 136 | ALC269_FUJITSU, |
137 | ALC269_LIFEBOOK, | 137 | ALC269_LIFEBOOK, |
138 | ALC269_AUTO, | 138 | ALC269_AUTO, |
@@ -188,6 +188,8 @@ enum { | |||
188 | ALC663_ASUS_MODE4, | 188 | ALC663_ASUS_MODE4, |
189 | ALC663_ASUS_MODE5, | 189 | ALC663_ASUS_MODE5, |
190 | ALC663_ASUS_MODE6, | 190 | ALC663_ASUS_MODE6, |
191 | ALC663_ASUS_MODE7, | ||
192 | ALC663_ASUS_MODE8, | ||
191 | ALC272_DELL, | 193 | ALC272_DELL, |
192 | ALC272_DELL_ZM1, | 194 | ALC272_DELL_ZM1, |
193 | ALC272_SAMSUNG_NC10, | 195 | ALC272_SAMSUNG_NC10, |
@@ -335,6 +337,9 @@ struct alc_spec { | |||
335 | /* hooks */ | 337 | /* hooks */ |
336 | void (*init_hook)(struct hda_codec *codec); | 338 | void (*init_hook)(struct hda_codec *codec); |
337 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | 339 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
340 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
341 | void (*power_hook)(struct hda_codec *codec, int power); | ||
342 | #endif | ||
338 | 343 | ||
339 | /* for pin sensing */ | 344 | /* for pin sensing */ |
340 | unsigned int sense_updated: 1; | 345 | unsigned int sense_updated: 1; |
@@ -386,6 +391,7 @@ struct alc_config_preset { | |||
386 | void (*init_hook)(struct hda_codec *); | 391 | void (*init_hook)(struct hda_codec *); |
387 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 392 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
388 | struct hda_amp_list *loopbacks; | 393 | struct hda_amp_list *loopbacks; |
394 | void (*power_hook)(struct hda_codec *codec, int power); | ||
389 | #endif | 395 | #endif |
390 | }; | 396 | }; |
391 | 397 | ||
@@ -902,6 +908,7 @@ static void setup_preset(struct hda_codec *codec, | |||
902 | spec->unsol_event = preset->unsol_event; | 908 | spec->unsol_event = preset->unsol_event; |
903 | spec->init_hook = preset->init_hook; | 909 | spec->init_hook = preset->init_hook; |
904 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 910 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
911 | spec->power_hook = preset->power_hook; | ||
905 | spec->loopback.amplist = preset->loopbacks; | 912 | spec->loopback.amplist = preset->loopbacks; |
906 | #endif | 913 | #endif |
907 | 914 | ||
@@ -1667,9 +1674,6 @@ static struct hda_verb alc889_acer_aspire_8930g_verbs[] = { | |||
1667 | /* some bit here disables the other DACs. Init=0x4900 */ | 1674 | /* some bit here disables the other DACs. Init=0x4900 */ |
1668 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, | 1675 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, |
1669 | {0x20, AC_VERB_SET_PROC_COEF, 0x0000}, | 1676 | {0x20, AC_VERB_SET_PROC_COEF, 0x0000}, |
1670 | /* Enable amplifiers */ | ||
1671 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
1672 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
1673 | /* DMIC fix | 1677 | /* DMIC fix |
1674 | * This laptop has a stereo digital microphone. The mics are only 1cm apart | 1678 | * This laptop has a stereo digital microphone. The mics are only 1cm apart |
1675 | * which makes the stereo useless. However, either the mic or the ALC889 | 1679 | * which makes the stereo useless. However, either the mic or the ALC889 |
@@ -1782,6 +1786,25 @@ static struct snd_kcontrol_new alc888_base_mixer[] = { | |||
1782 | { } /* end */ | 1786 | { } /* end */ |
1783 | }; | 1787 | }; |
1784 | 1788 | ||
1789 | static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = { | ||
1790 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
1791 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
1792 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
1793 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
1794 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | ||
1795 | HDA_OUTPUT), | ||
1796 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
1797 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
1798 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
1799 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
1800 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
1801 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
1802 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
1803 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
1804 | { } /* end */ | ||
1805 | }; | ||
1806 | |||
1807 | |||
1785 | static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) | 1808 | static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) |
1786 | { | 1809 | { |
1787 | struct alc_spec *spec = codec->spec; | 1810 | struct alc_spec *spec = codec->spec; |
@@ -1812,6 +1835,16 @@ static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) | |||
1812 | spec->autocfg.speaker_pins[2] = 0x1b; | 1835 | spec->autocfg.speaker_pins[2] = 0x1b; |
1813 | } | 1836 | } |
1814 | 1837 | ||
1838 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
1839 | static void alc889_power_eapd(struct hda_codec *codec, int power) | ||
1840 | { | ||
1841 | snd_hda_codec_write(codec, 0x14, 0, | ||
1842 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1843 | snd_hda_codec_write(codec, 0x15, 0, | ||
1844 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1845 | } | ||
1846 | #endif | ||
1847 | |||
1815 | /* | 1848 | /* |
1816 | * ALC880 3-stack model | 1849 | * ALC880 3-stack model |
1817 | * | 1850 | * |
@@ -3683,12 +3716,29 @@ static void alc_free(struct hda_codec *codec) | |||
3683 | snd_hda_detach_beep_device(codec); | 3716 | snd_hda_detach_beep_device(codec); |
3684 | } | 3717 | } |
3685 | 3718 | ||
3719 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3720 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) | ||
3721 | { | ||
3722 | struct alc_spec *spec = codec->spec; | ||
3723 | if (spec && spec->power_hook) | ||
3724 | spec->power_hook(codec, 0); | ||
3725 | return 0; | ||
3726 | } | ||
3727 | #endif | ||
3728 | |||
3686 | #ifdef SND_HDA_NEEDS_RESUME | 3729 | #ifdef SND_HDA_NEEDS_RESUME |
3687 | static int alc_resume(struct hda_codec *codec) | 3730 | static int alc_resume(struct hda_codec *codec) |
3688 | { | 3731 | { |
3732 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3733 | struct alc_spec *spec = codec->spec; | ||
3734 | #endif | ||
3689 | codec->patch_ops.init(codec); | 3735 | codec->patch_ops.init(codec); |
3690 | snd_hda_codec_resume_amp(codec); | 3736 | snd_hda_codec_resume_amp(codec); |
3691 | snd_hda_codec_resume_cache(codec); | 3737 | snd_hda_codec_resume_cache(codec); |
3738 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3739 | if (spec && spec->power_hook) | ||
3740 | spec->power_hook(codec, 1); | ||
3741 | #endif | ||
3692 | return 0; | 3742 | return 0; |
3693 | } | 3743 | } |
3694 | #endif | 3744 | #endif |
@@ -3705,6 +3755,7 @@ static struct hda_codec_ops alc_patch_ops = { | |||
3705 | .resume = alc_resume, | 3755 | .resume = alc_resume, |
3706 | #endif | 3756 | #endif |
3707 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3757 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3758 | .suspend = alc_suspend, | ||
3708 | .check_power_status = alc_check_power_status, | 3759 | .check_power_status = alc_check_power_status, |
3709 | #endif | 3760 | #endif |
3710 | }; | 3761 | }; |
@@ -6334,6 +6385,7 @@ static const char *alc260_models[ALC260_MODEL_LAST] = { | |||
6334 | 6385 | ||
6335 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | 6386 | static struct snd_pci_quirk alc260_cfg_tbl[] = { |
6336 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), | 6387 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
6388 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL), | ||
6337 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), | 6389 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
6338 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100), | 6390 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100), |
6339 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), | 6391 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
@@ -9004,7 +9056,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = { | |||
9004 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), | 9056 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
9005 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), | 9057 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
9006 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ | 9058 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
9007 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), | 9059 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO), |
9008 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | 9060 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), |
9009 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), | 9061 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
9010 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), | 9062 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
@@ -9367,6 +9419,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9367 | .dac_nids = alc883_dac_nids, | 9419 | .dac_nids = alc883_dac_nids, |
9368 | .adc_nids = alc883_adc_nids_alt, | 9420 | .adc_nids = alc883_adc_nids_alt, |
9369 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | 9421 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), |
9422 | .capsrc_nids = alc883_capsrc_nids, | ||
9370 | .dig_out_nid = ALC883_DIGOUT_NID, | 9423 | .dig_out_nid = ALC883_DIGOUT_NID, |
9371 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9424 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9372 | .channel_mode = alc883_3ST_2ch_modes, | 9425 | .channel_mode = alc883_3ST_2ch_modes, |
@@ -9463,10 +9516,11 @@ static struct alc_config_preset alc882_presets[] = { | |||
9463 | .init_hook = alc_automute_amp, | 9516 | .init_hook = alc_automute_amp, |
9464 | }, | 9517 | }, |
9465 | [ALC888_ACER_ASPIRE_8930G] = { | 9518 | [ALC888_ACER_ASPIRE_8930G] = { |
9466 | .mixers = { alc888_base_mixer, | 9519 | .mixers = { alc889_acer_aspire_8930g_mixer, |
9467 | alc883_chmode_mixer }, | 9520 | alc883_chmode_mixer }, |
9468 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | 9521 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, |
9469 | alc889_acer_aspire_8930g_verbs }, | 9522 | alc889_acer_aspire_8930g_verbs, |
9523 | alc889_eapd_verbs}, | ||
9470 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | 9524 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
9471 | .dac_nids = alc883_dac_nids, | 9525 | .dac_nids = alc883_dac_nids, |
9472 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | 9526 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), |
@@ -9483,6 +9537,9 @@ static struct alc_config_preset alc882_presets[] = { | |||
9483 | .unsol_event = alc_automute_amp_unsol_event, | 9537 | .unsol_event = alc_automute_amp_unsol_event, |
9484 | .setup = alc889_acer_aspire_8930g_setup, | 9538 | .setup = alc889_acer_aspire_8930g_setup, |
9485 | .init_hook = alc_automute_amp, | 9539 | .init_hook = alc_automute_amp, |
9540 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
9541 | .power_hook = alc889_power_eapd, | ||
9542 | #endif | ||
9486 | }, | 9543 | }, |
9487 | [ALC888_ACER_ASPIRE_7730G] = { | 9544 | [ALC888_ACER_ASPIRE_7730G] = { |
9488 | .mixers = { alc883_3ST_6ch_mixer, | 9545 | .mixers = { alc883_3ST_6ch_mixer, |
@@ -9513,6 +9570,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9513 | .dac_nids = alc883_dac_nids, | 9570 | .dac_nids = alc883_dac_nids, |
9514 | .adc_nids = alc883_adc_nids_alt, | 9571 | .adc_nids = alc883_adc_nids_alt, |
9515 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | 9572 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), |
9573 | .capsrc_nids = alc883_capsrc_nids, | ||
9516 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | 9574 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
9517 | .channel_mode = alc883_sixstack_modes, | 9575 | .channel_mode = alc883_sixstack_modes, |
9518 | .input_mux = &alc883_capture_source, | 9576 | .input_mux = &alc883_capture_source, |
@@ -9574,6 +9632,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9574 | .dac_nids = alc883_dac_nids, | 9632 | .dac_nids = alc883_dac_nids, |
9575 | .adc_nids = alc883_adc_nids_alt, | 9633 | .adc_nids = alc883_adc_nids_alt, |
9576 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | 9634 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), |
9635 | .capsrc_nids = alc883_capsrc_nids, | ||
9577 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9636 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9578 | .channel_mode = alc883_3ST_2ch_modes, | 9637 | .channel_mode = alc883_3ST_2ch_modes, |
9579 | .input_mux = &alc883_lenovo_101e_capture_source, | 9638 | .input_mux = &alc883_lenovo_101e_capture_source, |
@@ -9753,6 +9812,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9753 | alc880_gpio1_init_verbs }, | 9812 | alc880_gpio1_init_verbs }, |
9754 | .adc_nids = alc883_adc_nids, | 9813 | .adc_nids = alc883_adc_nids, |
9755 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | 9814 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
9815 | .capsrc_nids = alc883_capsrc_nids, | ||
9756 | .dac_nids = alc883_dac_nids, | 9816 | .dac_nids = alc883_dac_nids, |
9757 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | 9817 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
9758 | .channel_mode = alc889A_mb31_6ch_modes, | 9818 | .channel_mode = alc889A_mb31_6ch_modes, |
@@ -10775,6 +10835,13 @@ static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { | |||
10775 | {} | 10835 | {} |
10776 | }; | 10836 | }; |
10777 | 10837 | ||
10838 | static struct hda_verb alc262_lenovo_3000_init_verbs[] = { | ||
10839 | /* Front Mic pin: input vref at 50% */ | ||
10840 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | ||
10841 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
10842 | {} | ||
10843 | }; | ||
10844 | |||
10778 | static struct hda_input_mux alc262_fujitsu_capture_source = { | 10845 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
10779 | .num_items = 3, | 10846 | .num_items = 3, |
10780 | .items = { | 10847 | .items = { |
@@ -11829,7 +11896,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11829 | [ALC262_LENOVO_3000] = { | 11896 | [ALC262_LENOVO_3000] = { |
11830 | .mixers = { alc262_lenovo_3000_mixer }, | 11897 | .mixers = { alc262_lenovo_3000_mixer }, |
11831 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | 11898 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
11832 | alc262_lenovo_3000_unsol_verbs }, | 11899 | alc262_lenovo_3000_unsol_verbs, |
11900 | alc262_lenovo_3000_init_verbs }, | ||
11833 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11901 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
11834 | .dac_nids = alc262_dac_nids, | 11902 | .dac_nids = alc262_dac_nids, |
11835 | .hp_nid = 0x03, | 11903 | .hp_nid = 0x03, |
@@ -12969,7 +13037,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
12969 | int board_config; | 13037 | int board_config; |
12970 | int i, has_beep, err; | 13038 | int i, has_beep, err; |
12971 | 13039 | ||
12972 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 13040 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
12973 | if (spec == NULL) | 13041 | if (spec == NULL) |
12974 | return -ENOMEM; | 13042 | return -ENOMEM; |
12975 | 13043 | ||
@@ -13346,10 +13414,12 @@ static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |||
13346 | /* toggle speaker-output according to the hp-jack state */ | 13414 | /* toggle speaker-output according to the hp-jack state */ |
13347 | static void alc269_speaker_automute(struct hda_codec *codec) | 13415 | static void alc269_speaker_automute(struct hda_codec *codec) |
13348 | { | 13416 | { |
13417 | struct alc_spec *spec = codec->spec; | ||
13418 | unsigned int nid = spec->autocfg.hp_pins[0]; | ||
13349 | unsigned int present; | 13419 | unsigned int present; |
13350 | unsigned char bits; | 13420 | unsigned char bits; |
13351 | 13421 | ||
13352 | present = snd_hda_jack_detect(codec, 0x15); | 13422 | present = snd_hda_jack_detect(codec, nid); |
13353 | bits = present ? AMP_IN_MUTE(0) : 0; | 13423 | bits = present ? AMP_IN_MUTE(0) : 0; |
13354 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 13424 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
13355 | AMP_IN_MUTE(0), bits); | 13425 | AMP_IN_MUTE(0), bits); |
@@ -13574,8 +13644,8 @@ static void alc269_auto_init(struct hda_codec *codec) | |||
13574 | static const char *alc269_models[ALC269_MODEL_LAST] = { | 13644 | static const char *alc269_models[ALC269_MODEL_LAST] = { |
13575 | [ALC269_BASIC] = "basic", | 13645 | [ALC269_BASIC] = "basic", |
13576 | [ALC269_QUANTA_FL1] = "quanta", | 13646 | [ALC269_QUANTA_FL1] = "quanta", |
13577 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | 13647 | [ALC269_ASUS_AMIC] = "asus-amic", |
13578 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901", | 13648 | [ALC269_ASUS_DMIC] = "asus-dmic", |
13579 | [ALC269_FUJITSU] = "fujitsu", | 13649 | [ALC269_FUJITSU] = "fujitsu", |
13580 | [ALC269_LIFEBOOK] = "lifebook", | 13650 | [ALC269_LIFEBOOK] = "lifebook", |
13581 | [ALC269_AUTO] = "auto", | 13651 | [ALC269_AUTO] = "auto", |
@@ -13584,18 +13654,41 @@ static const char *alc269_models[ALC269_MODEL_LAST] = { | |||
13584 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | 13654 | static struct snd_pci_quirk alc269_cfg_tbl[] = { |
13585 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), | 13655 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
13586 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", | 13656 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
13587 | ALC269_ASUS_EEEPC_P703), | 13657 | ALC269_ASUS_AMIC), |
13588 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703), | 13658 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC), |
13589 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703), | 13659 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC), |
13590 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703), | 13660 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC), |
13591 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703), | 13661 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC), |
13592 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703), | 13662 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC), |
13593 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703), | 13663 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC), |
13664 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC), | ||
13665 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC), | ||
13666 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC), | ||
13667 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC), | ||
13668 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC), | ||
13669 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC), | ||
13670 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC), | ||
13671 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC), | ||
13672 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC), | ||
13673 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC), | ||
13674 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC), | ||
13675 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC), | ||
13676 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC), | ||
13677 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC), | ||
13678 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC), | ||
13679 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC), | ||
13680 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC), | ||
13681 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC), | ||
13682 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC), | ||
13683 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC), | ||
13684 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC), | ||
13685 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC), | ||
13594 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | 13686 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", |
13595 | ALC269_ASUS_EEEPC_P901), | 13687 | ALC269_ASUS_DMIC), |
13596 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", | 13688 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
13597 | ALC269_ASUS_EEEPC_P901), | 13689 | ALC269_ASUS_DMIC), |
13598 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901), | 13690 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC), |
13691 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC), | ||
13599 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), | 13692 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), |
13600 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), | 13693 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), |
13601 | {} | 13694 | {} |
@@ -13625,7 +13718,7 @@ static struct alc_config_preset alc269_presets[] = { | |||
13625 | .setup = alc269_quanta_fl1_setup, | 13718 | .setup = alc269_quanta_fl1_setup, |
13626 | .init_hook = alc269_quanta_fl1_init_hook, | 13719 | .init_hook = alc269_quanta_fl1_init_hook, |
13627 | }, | 13720 | }, |
13628 | [ALC269_ASUS_EEEPC_P703] = { | 13721 | [ALC269_ASUS_AMIC] = { |
13629 | .mixers = { alc269_eeepc_mixer }, | 13722 | .mixers = { alc269_eeepc_mixer }, |
13630 | .cap_mixer = alc269_epc_capture_mixer, | 13723 | .cap_mixer = alc269_epc_capture_mixer, |
13631 | .init_verbs = { alc269_init_verbs, | 13724 | .init_verbs = { alc269_init_verbs, |
@@ -13639,7 +13732,7 @@ static struct alc_config_preset alc269_presets[] = { | |||
13639 | .setup = alc269_eeepc_amic_setup, | 13732 | .setup = alc269_eeepc_amic_setup, |
13640 | .init_hook = alc269_eeepc_inithook, | 13733 | .init_hook = alc269_eeepc_inithook, |
13641 | }, | 13734 | }, |
13642 | [ALC269_ASUS_EEEPC_P901] = { | 13735 | [ALC269_ASUS_DMIC] = { |
13643 | .mixers = { alc269_eeepc_mixer }, | 13736 | .mixers = { alc269_eeepc_mixer }, |
13644 | .cap_mixer = alc269_epc_capture_mixer, | 13737 | .cap_mixer = alc269_epc_capture_mixer, |
13645 | .init_verbs = { alc269_init_verbs, | 13738 | .init_verbs = { alc269_init_verbs, |
@@ -16274,6 +16367,52 @@ static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |||
16274 | { } /* end */ | 16367 | { } /* end */ |
16275 | }; | 16368 | }; |
16276 | 16369 | ||
16370 | static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = { | ||
16371 | .ops = &snd_hda_bind_sw, | ||
16372 | .values = { | ||
16373 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | ||
16374 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | ||
16375 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
16376 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | ||
16377 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
16378 | 0 | ||
16379 | }, | ||
16380 | }; | ||
16381 | |||
16382 | static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = { | ||
16383 | .ops = &snd_hda_bind_sw, | ||
16384 | .values = { | ||
16385 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | ||
16386 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
16387 | 0 | ||
16388 | }, | ||
16389 | }; | ||
16390 | |||
16391 | static struct snd_kcontrol_new alc663_mode7_mixer[] = { | ||
16392 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch), | ||
16393 | HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol), | ||
16394 | HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch), | ||
16395 | HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
16396 | HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
16397 | HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
16398 | HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
16399 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
16400 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
16401 | { } /* end */ | ||
16402 | }; | ||
16403 | |||
16404 | static struct snd_kcontrol_new alc663_mode8_mixer[] = { | ||
16405 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch), | ||
16406 | HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol), | ||
16407 | HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch), | ||
16408 | HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
16409 | HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
16410 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
16411 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
16412 | { } /* end */ | ||
16413 | }; | ||
16414 | |||
16415 | |||
16277 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { | 16416 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
16278 | { | 16417 | { |
16279 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 16418 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -16561,6 +16700,45 @@ static struct hda_verb alc272_dell_init_verbs[] = { | |||
16561 | {} | 16700 | {} |
16562 | }; | 16701 | }; |
16563 | 16702 | ||
16703 | static struct hda_verb alc663_mode7_init_verbs[] = { | ||
16704 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16705 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16706 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16707 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16708 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16709 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16710 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
16711 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16712 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16713 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | ||
16714 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
16715 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | ||
16716 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | ||
16717 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16718 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16719 | {} | ||
16720 | }; | ||
16721 | |||
16722 | static struct hda_verb alc663_mode8_init_verbs[] = { | ||
16723 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16724 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16725 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16726 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
16727 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16728 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16729 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16730 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16731 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16732 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16733 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | ||
16734 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
16735 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | ||
16736 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16737 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | ||
16738 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16739 | {} | ||
16740 | }; | ||
16741 | |||
16564 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { | 16742 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
16565 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | 16743 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), |
16566 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | 16744 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), |
@@ -16740,6 +16918,54 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |||
16740 | } | 16918 | } |
16741 | } | 16919 | } |
16742 | 16920 | ||
16921 | static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec) | ||
16922 | { | ||
16923 | unsigned int present1, present2; | ||
16924 | |||
16925 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | ||
16926 | AC_VERB_GET_PIN_SENSE, 0) | ||
16927 | & AC_PINSENSE_PRESENCE; | ||
16928 | present2 = snd_hda_codec_read(codec, 0x21, 0, | ||
16929 | AC_VERB_GET_PIN_SENSE, 0) | ||
16930 | & AC_PINSENSE_PRESENCE; | ||
16931 | |||
16932 | if (present1 || present2) { | ||
16933 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16934 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16935 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16936 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16937 | } else { | ||
16938 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16939 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16940 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16941 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16942 | } | ||
16943 | } | ||
16944 | |||
16945 | static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec) | ||
16946 | { | ||
16947 | unsigned int present1, present2; | ||
16948 | |||
16949 | present1 = snd_hda_codec_read(codec, 0x21, 0, | ||
16950 | AC_VERB_GET_PIN_SENSE, 0) | ||
16951 | & AC_PINSENSE_PRESENCE; | ||
16952 | present2 = snd_hda_codec_read(codec, 0x15, 0, | ||
16953 | AC_VERB_GET_PIN_SENSE, 0) | ||
16954 | & AC_PINSENSE_PRESENCE; | ||
16955 | |||
16956 | if (present1 || present2) { | ||
16957 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16958 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16959 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16960 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16961 | } else { | ||
16962 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16963 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16964 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16965 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16966 | } | ||
16967 | } | ||
16968 | |||
16743 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | 16969 | static void alc663_m51va_unsol_event(struct hda_codec *codec, |
16744 | unsigned int res) | 16970 | unsigned int res) |
16745 | { | 16971 | { |
@@ -16759,7 +16985,7 @@ static void alc663_m51va_setup(struct hda_codec *codec) | |||
16759 | spec->ext_mic.pin = 0x18; | 16985 | spec->ext_mic.pin = 0x18; |
16760 | spec->ext_mic.mux_idx = 0; | 16986 | spec->ext_mic.mux_idx = 0; |
16761 | spec->int_mic.pin = 0x12; | 16987 | spec->int_mic.pin = 0x12; |
16762 | spec->int_mic.mux_idx = 1; | 16988 | spec->int_mic.mux_idx = 9; |
16763 | spec->auto_mic = 1; | 16989 | spec->auto_mic = 1; |
16764 | } | 16990 | } |
16765 | 16991 | ||
@@ -16771,7 +16997,17 @@ static void alc663_m51va_inithook(struct hda_codec *codec) | |||
16771 | 16997 | ||
16772 | /* ***************** Mode1 ******************************/ | 16998 | /* ***************** Mode1 ******************************/ |
16773 | #define alc663_mode1_unsol_event alc663_m51va_unsol_event | 16999 | #define alc663_mode1_unsol_event alc663_m51va_unsol_event |
16774 | #define alc663_mode1_setup alc663_m51va_setup | 17000 | |
17001 | static void alc663_mode1_setup(struct hda_codec *codec) | ||
17002 | { | ||
17003 | struct alc_spec *spec = codec->spec; | ||
17004 | spec->ext_mic.pin = 0x18; | ||
17005 | spec->ext_mic.mux_idx = 0; | ||
17006 | spec->int_mic.pin = 0x19; | ||
17007 | spec->int_mic.mux_idx = 1; | ||
17008 | spec->auto_mic = 1; | ||
17009 | } | ||
17010 | |||
16775 | #define alc663_mode1_inithook alc663_m51va_inithook | 17011 | #define alc663_mode1_inithook alc663_m51va_inithook |
16776 | 17012 | ||
16777 | /* ***************** Mode2 ******************************/ | 17013 | /* ***************** Mode2 ******************************/ |
@@ -16788,7 +17024,7 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec, | |||
16788 | } | 17024 | } |
16789 | } | 17025 | } |
16790 | 17026 | ||
16791 | #define alc662_mode2_setup alc663_m51va_setup | 17027 | #define alc662_mode2_setup alc663_mode1_setup |
16792 | 17028 | ||
16793 | static void alc662_mode2_inithook(struct hda_codec *codec) | 17029 | static void alc662_mode2_inithook(struct hda_codec *codec) |
16794 | { | 17030 | { |
@@ -16809,7 +17045,7 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec, | |||
16809 | } | 17045 | } |
16810 | } | 17046 | } |
16811 | 17047 | ||
16812 | #define alc663_mode3_setup alc663_m51va_setup | 17048 | #define alc663_mode3_setup alc663_mode1_setup |
16813 | 17049 | ||
16814 | static void alc663_mode3_inithook(struct hda_codec *codec) | 17050 | static void alc663_mode3_inithook(struct hda_codec *codec) |
16815 | { | 17051 | { |
@@ -16830,7 +17066,7 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec, | |||
16830 | } | 17066 | } |
16831 | } | 17067 | } |
16832 | 17068 | ||
16833 | #define alc663_mode4_setup alc663_m51va_setup | 17069 | #define alc663_mode4_setup alc663_mode1_setup |
16834 | 17070 | ||
16835 | static void alc663_mode4_inithook(struct hda_codec *codec) | 17071 | static void alc663_mode4_inithook(struct hda_codec *codec) |
16836 | { | 17072 | { |
@@ -16851,7 +17087,7 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec, | |||
16851 | } | 17087 | } |
16852 | } | 17088 | } |
16853 | 17089 | ||
16854 | #define alc663_mode5_setup alc663_m51va_setup | 17090 | #define alc663_mode5_setup alc663_mode1_setup |
16855 | 17091 | ||
16856 | static void alc663_mode5_inithook(struct hda_codec *codec) | 17092 | static void alc663_mode5_inithook(struct hda_codec *codec) |
16857 | { | 17093 | { |
@@ -16872,7 +17108,7 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec, | |||
16872 | } | 17108 | } |
16873 | } | 17109 | } |
16874 | 17110 | ||
16875 | #define alc663_mode6_setup alc663_m51va_setup | 17111 | #define alc663_mode6_setup alc663_mode1_setup |
16876 | 17112 | ||
16877 | static void alc663_mode6_inithook(struct hda_codec *codec) | 17113 | static void alc663_mode6_inithook(struct hda_codec *codec) |
16878 | { | 17114 | { |
@@ -16880,6 +17116,50 @@ static void alc663_mode6_inithook(struct hda_codec *codec) | |||
16880 | alc_mic_automute(codec); | 17116 | alc_mic_automute(codec); |
16881 | } | 17117 | } |
16882 | 17118 | ||
17119 | /* ***************** Mode7 ******************************/ | ||
17120 | static void alc663_mode7_unsol_event(struct hda_codec *codec, | ||
17121 | unsigned int res) | ||
17122 | { | ||
17123 | switch (res >> 26) { | ||
17124 | case ALC880_HP_EVENT: | ||
17125 | alc663_two_hp_m7_speaker_automute(codec); | ||
17126 | break; | ||
17127 | case ALC880_MIC_EVENT: | ||
17128 | alc_mic_automute(codec); | ||
17129 | break; | ||
17130 | } | ||
17131 | } | ||
17132 | |||
17133 | #define alc663_mode7_setup alc663_mode1_setup | ||
17134 | |||
17135 | static void alc663_mode7_inithook(struct hda_codec *codec) | ||
17136 | { | ||
17137 | alc663_two_hp_m7_speaker_automute(codec); | ||
17138 | alc_mic_automute(codec); | ||
17139 | } | ||
17140 | |||
17141 | /* ***************** Mode8 ******************************/ | ||
17142 | static void alc663_mode8_unsol_event(struct hda_codec *codec, | ||
17143 | unsigned int res) | ||
17144 | { | ||
17145 | switch (res >> 26) { | ||
17146 | case ALC880_HP_EVENT: | ||
17147 | alc663_two_hp_m8_speaker_automute(codec); | ||
17148 | break; | ||
17149 | case ALC880_MIC_EVENT: | ||
17150 | alc_mic_automute(codec); | ||
17151 | break; | ||
17152 | } | ||
17153 | } | ||
17154 | |||
17155 | #define alc663_mode8_setup alc663_m51va_setup | ||
17156 | |||
17157 | static void alc663_mode8_inithook(struct hda_codec *codec) | ||
17158 | { | ||
17159 | alc663_two_hp_m8_speaker_automute(codec); | ||
17160 | alc_mic_automute(codec); | ||
17161 | } | ||
17162 | |||
16883 | static void alc663_g71v_hp_automute(struct hda_codec *codec) | 17163 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
16884 | { | 17164 | { |
16885 | unsigned int present; | 17165 | unsigned int present; |
@@ -17014,6 +17294,8 @@ static const char *alc662_models[ALC662_MODEL_LAST] = { | |||
17014 | [ALC663_ASUS_MODE4] = "asus-mode4", | 17294 | [ALC663_ASUS_MODE4] = "asus-mode4", |
17015 | [ALC663_ASUS_MODE5] = "asus-mode5", | 17295 | [ALC663_ASUS_MODE5] = "asus-mode5", |
17016 | [ALC663_ASUS_MODE6] = "asus-mode6", | 17296 | [ALC663_ASUS_MODE6] = "asus-mode6", |
17297 | [ALC663_ASUS_MODE7] = "asus-mode7", | ||
17298 | [ALC663_ASUS_MODE8] = "asus-mode8", | ||
17017 | [ALC272_DELL] = "dell", | 17299 | [ALC272_DELL] = "dell", |
17018 | [ALC272_DELL_ZM1] = "dell-zm1", | 17300 | [ALC272_DELL_ZM1] = "dell-zm1", |
17019 | [ALC272_SAMSUNG_NC10] = "samsung-nc10", | 17301 | [ALC272_SAMSUNG_NC10] = "samsung-nc10", |
@@ -17030,12 +17312,22 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
17030 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | 17312 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), |
17031 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | 17313 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), |
17032 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), | 17314 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), |
17315 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1), | ||
17316 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1), | ||
17033 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), | 17317 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), |
17318 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7), | ||
17319 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7), | ||
17320 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8), | ||
17321 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3), | ||
17322 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1), | ||
17034 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), | 17323 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), |
17324 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2), | ||
17325 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1), | ||
17035 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | 17326 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), |
17036 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | 17327 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), |
17037 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | 17328 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), |
17038 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | 17329 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), |
17330 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1), | ||
17039 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3), | 17331 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3), |
17040 | SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA), | 17332 | SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA), |
17041 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2), | 17333 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2), |
@@ -17319,6 +17611,36 @@ static struct alc_config_preset alc662_presets[] = { | |||
17319 | .setup = alc663_mode6_setup, | 17611 | .setup = alc663_mode6_setup, |
17320 | .init_hook = alc663_mode6_inithook, | 17612 | .init_hook = alc663_mode6_inithook, |
17321 | }, | 17613 | }, |
17614 | [ALC663_ASUS_MODE7] = { | ||
17615 | .mixers = { alc663_mode7_mixer }, | ||
17616 | .cap_mixer = alc662_auto_capture_mixer, | ||
17617 | .init_verbs = { alc662_init_verbs, | ||
17618 | alc663_mode7_init_verbs }, | ||
17619 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | ||
17620 | .hp_nid = 0x03, | ||
17621 | .dac_nids = alc662_dac_nids, | ||
17622 | .dig_out_nid = ALC662_DIGOUT_NID, | ||
17623 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | ||
17624 | .channel_mode = alc662_3ST_2ch_modes, | ||
17625 | .unsol_event = alc663_mode7_unsol_event, | ||
17626 | .setup = alc663_mode7_setup, | ||
17627 | .init_hook = alc663_mode7_inithook, | ||
17628 | }, | ||
17629 | [ALC663_ASUS_MODE8] = { | ||
17630 | .mixers = { alc663_mode8_mixer }, | ||
17631 | .cap_mixer = alc662_auto_capture_mixer, | ||
17632 | .init_verbs = { alc662_init_verbs, | ||
17633 | alc663_mode8_init_verbs }, | ||
17634 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | ||
17635 | .hp_nid = 0x03, | ||
17636 | .dac_nids = alc662_dac_nids, | ||
17637 | .dig_out_nid = ALC662_DIGOUT_NID, | ||
17638 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | ||
17639 | .channel_mode = alc662_3ST_2ch_modes, | ||
17640 | .unsol_event = alc663_mode8_unsol_event, | ||
17641 | .setup = alc663_mode8_setup, | ||
17642 | .init_hook = alc663_mode8_inithook, | ||
17643 | }, | ||
17322 | [ALC272_DELL] = { | 17644 | [ALC272_DELL] = { |
17323 | .mixers = { alc663_m51va_mixer }, | 17645 | .mixers = { alc663_m51va_mixer }, |
17324 | .cap_mixer = alc272_auto_capture_mixer, | 17646 | .cap_mixer = alc272_auto_capture_mixer, |
@@ -17802,7 +18124,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
17802 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, | 18124 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
17803 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, | 18125 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
17804 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, | 18126 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
18127 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, | ||
17805 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, | 18128 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
18129 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, | ||
17806 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", | 18130 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
17807 | .patch = patch_alc861 }, | 18131 | .patch = patch_alc861 }, |
17808 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, | 18132 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 0bafea9d5106..74d5d333ed6c 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -2104,6 +2104,7 @@ static unsigned int ref9205_pin_configs[12] = { | |||
2104 | 10280204 | 2104 | 10280204 |
2105 | 1028021F | 2105 | 1028021F |
2106 | 10280228 (Dell Vostro 1500) | 2106 | 10280228 (Dell Vostro 1500) |
2107 | 10280229 (Dell Vostro 1700) | ||
2107 | */ | 2108 | */ |
2108 | static unsigned int dell_9205_m42_pin_configs[12] = { | 2109 | static unsigned int dell_9205_m42_pin_configs[12] = { |
2109 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, | 2110 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
@@ -2189,6 +2190,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = { | |||
2189 | "Dell Inspiron", STAC_9205_DELL_M44), | 2190 | "Dell Inspiron", STAC_9205_DELL_M44), |
2190 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, | 2191 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
2191 | "Dell Vostro 1500", STAC_9205_DELL_M42), | 2192 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
2193 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229, | ||
2194 | "Dell Vostro 1700", STAC_9205_DELL_M42), | ||
2192 | /* Gateway */ | 2195 | /* Gateway */ |
2193 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), | 2196 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
2194 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), | 2197 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
@@ -3778,15 +3781,16 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3778 | err = snd_hda_attach_beep_device(codec, nid); | 3781 | err = snd_hda_attach_beep_device(codec, nid); |
3779 | if (err < 0) | 3782 | if (err < 0) |
3780 | return err; | 3783 | return err; |
3781 | /* IDT/STAC codecs have linear beep tone parameter */ | 3784 | if (codec->beep) { |
3782 | codec->beep->linear_tone = 1; | 3785 | /* IDT/STAC codecs have linear beep tone parameter */ |
3783 | /* if no beep switch is available, make its own one */ | 3786 | codec->beep->linear_tone = 1; |
3784 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 3787 | /* if no beep switch is available, make its own one */ |
3785 | if (codec->beep && | 3788 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
3786 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { | 3789 | if (!(caps & AC_AMPCAP_MUTE)) { |
3787 | err = stac92xx_beep_switch_ctl(codec); | 3790 | err = stac92xx_beep_switch_ctl(codec); |
3788 | if (err < 0) | 3791 | if (err < 0) |
3789 | return err; | 3792 | return err; |
3793 | } | ||
3790 | } | 3794 | } |
3791 | } | 3795 | } |
3792 | #endif | 3796 | #endif |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 7717e01fc071..edaa729126bb 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c | |||
@@ -143,7 +143,8 @@ static int snd_pdacf_probe(struct pcmcia_device *link) | |||
143 | link->io.NumPorts1 = 16; | 143 | link->io.NumPorts1 = 16; |
144 | 144 | ||
145 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE; | 145 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE; |
146 | // link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; | 146 | /* FIXME: This driver should be updated to allow for dynamic IRQ sharing */ |
147 | /* link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FORCED_PULSE; */ | ||
147 | 148 | ||
148 | link->irq.Handler = pdacf_interrupt; | 149 | link->irq.Handler = pdacf_interrupt; |
149 | link->conf.Attributes = CONF_ENABLE_IRQ; | 150 | link->conf.Attributes = CONF_ENABLE_IRQ; |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index d057e6489643..0afa683c900e 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | |||
@@ -21,7 +21,6 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/vmalloc.h> | ||
25 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
26 | #include <sound/core.h> | 25 | #include <sound/core.h> |
27 | #include <sound/asoundef.h> | 26 | #include <sound/asoundef.h> |
@@ -29,49 +28,6 @@ | |||
29 | 28 | ||
30 | 29 | ||
31 | /* | 30 | /* |
32 | * we use a vmalloc'ed (sg-)buffer | ||
33 | */ | ||
34 | |||
35 | /* get the physical page pointer on the given offset */ | ||
36 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, unsigned long offset) | ||
37 | { | ||
38 | void *pageptr = subs->runtime->dma_area + offset; | ||
39 | return vmalloc_to_page(pageptr); | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * hw_params callback | ||
44 | * NOTE: this may be called not only once per pcm open! | ||
45 | */ | ||
46 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
47 | { | ||
48 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
49 | if (runtime->dma_area) { | ||
50 | if (runtime->dma_bytes >= size) | ||
51 | return 0; /* already enough large */ | ||
52 | vfree(runtime->dma_area); | ||
53 | } | ||
54 | runtime->dma_area = vmalloc_32(size); | ||
55 | if (! runtime->dma_area) | ||
56 | return -ENOMEM; | ||
57 | runtime->dma_bytes = size; | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | /* | ||
62 | * hw_free callback | ||
63 | * NOTE: this may be called not only once per pcm open! | ||
64 | */ | ||
65 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
66 | { | ||
67 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
68 | |||
69 | vfree(runtime->dma_area); | ||
70 | runtime->dma_area = NULL; | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * clear the SRAM contents | 31 | * clear the SRAM contents |
76 | */ | 32 | */ |
77 | static int pdacf_pcm_clear_sram(struct snd_pdacf *chip) | 33 | static int pdacf_pcm_clear_sram(struct snd_pdacf *chip) |
@@ -147,7 +103,8 @@ static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd) | |||
147 | static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, | 103 | static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, |
148 | struct snd_pcm_hw_params *hw_params) | 104 | struct snd_pcm_hw_params *hw_params) |
149 | { | 105 | { |
150 | return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); | 106 | return snd_pcm_lib_alloc_vmalloc_32_buffer |
107 | (subs, params_buffer_bytes(hw_params)); | ||
151 | } | 108 | } |
152 | 109 | ||
153 | /* | 110 | /* |
@@ -155,7 +112,7 @@ static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, | |||
155 | */ | 112 | */ |
156 | static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) | 113 | static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) |
157 | { | 114 | { |
158 | return snd_pcm_free_vmalloc_buffer(subs); | 115 | return snd_pcm_lib_free_vmalloc_buffer(subs); |
159 | } | 116 | } |
160 | 117 | ||
161 | /* | 118 | /* |
@@ -319,7 +276,7 @@ static struct snd_pcm_ops pdacf_pcm_capture_ops = { | |||
319 | .prepare = pdacf_pcm_prepare, | 276 | .prepare = pdacf_pcm_prepare, |
320 | .trigger = pdacf_pcm_trigger, | 277 | .trigger = pdacf_pcm_trigger, |
321 | .pointer = pdacf_pcm_capture_pointer, | 278 | .pointer = pdacf_pcm_capture_pointer, |
322 | .page = snd_pcm_get_vmalloc_page, | 279 | .page = snd_pcm_lib_get_vmalloc_page, |
323 | }; | 280 | }; |
324 | 281 | ||
325 | 282 | ||
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index b69861d52161..3ef16bbc8c83 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
@@ -470,7 +470,7 @@ EXPORT_SYMBOL_GPL(soc_codec_dev_ak4642); | |||
470 | 470 | ||
471 | static int __init ak4642_modinit(void) | 471 | static int __init ak4642_modinit(void) |
472 | { | 472 | { |
473 | int ret; | 473 | int ret = 0; |
474 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 474 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
475 | ret = i2c_add_driver(&ak4642_i2c_driver); | 475 | ret = i2c_add_driver(&ak4642_i2c_driver); |
476 | #endif | 476 | #endif |
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c index bbc72c2ddfca..81b8c9dfe7fc 100644 --- a/sound/soc/codecs/stac9766.c +++ b/sound/soc/codecs/stac9766.c | |||
@@ -191,6 +191,7 @@ static int ac97_analog_prepare(struct snd_pcm_substream *substream, | |||
191 | vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS); | 191 | vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS); |
192 | 192 | ||
193 | vra |= 0x1; /* enable variable rate audio */ | 193 | vra |= 0x1; /* enable variable rate audio */ |
194 | vra &= ~0x4; /* disable SPDIF output */ | ||
194 | 195 | ||
195 | stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra); | 196 | stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra); |
196 | 197 | ||
@@ -221,22 +222,6 @@ static int ac97_digital_prepare(struct snd_pcm_substream *substream, | |||
221 | return stac9766_ac97_write(codec, reg, runtime->rate); | 222 | return stac9766_ac97_write(codec, reg, runtime->rate); |
222 | } | 223 | } |
223 | 224 | ||
224 | static int ac97_digital_trigger(struct snd_pcm_substream *substream, | ||
225 | int cmd, struct snd_soc_dai *dai) | ||
226 | { | ||
227 | struct snd_soc_codec *codec = dai->codec; | ||
228 | unsigned short vra; | ||
229 | |||
230 | switch (cmd) { | ||
231 | case SNDRV_PCM_TRIGGER_STOP: | ||
232 | vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS); | ||
233 | vra &= !0x04; | ||
234 | stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra); | ||
235 | break; | ||
236 | } | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int stac9766_set_bias_level(struct snd_soc_codec *codec, | 225 | static int stac9766_set_bias_level(struct snd_soc_codec *codec, |
241 | enum snd_soc_bias_level level) | 226 | enum snd_soc_bias_level level) |
242 | { | 227 | { |
@@ -315,7 +300,6 @@ static struct snd_soc_dai_ops stac9766_dai_ops_analog = { | |||
315 | 300 | ||
316 | static struct snd_soc_dai_ops stac9766_dai_ops_digital = { | 301 | static struct snd_soc_dai_ops stac9766_dai_ops_digital = { |
317 | .prepare = ac97_digital_prepare, | 302 | .prepare = ac97_digital_prepare, |
318 | .trigger = ac97_digital_trigger, | ||
319 | }; | 303 | }; |
320 | 304 | ||
321 | struct snd_soc_dai stac9766_dai[] = { | 305 | struct snd_soc_dai stac9766_dai[] = { |
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 5f1681f6ca76..2a27f7b56726 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/pm.h> | 26 | #include <linux/pm.h> |
27 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/i2c/twl4030.h> | 29 | #include <linux/i2c/twl.h> |
30 | #include <sound/core.h> | 30 | #include <sound/core.h> |
31 | #include <sound/pcm.h> | 31 | #include <sound/pcm.h> |
32 | #include <sound/pcm_params.h> | 32 | #include <sound/pcm_params.h> |
@@ -175,7 +175,7 @@ static int twl4030_write(struct snd_soc_codec *codec, | |||
175 | { | 175 | { |
176 | twl4030_write_reg_cache(codec, reg, value); | 176 | twl4030_write_reg_cache(codec, reg, value); |
177 | if (likely(reg < TWL4030_REG_SW_SHADOW)) | 177 | if (likely(reg < TWL4030_REG_SW_SHADOW)) |
178 | return twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, | 178 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, |
179 | reg); | 179 | reg); |
180 | else | 180 | else |
181 | return 0; | 181 | return 0; |
@@ -261,7 +261,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec) | |||
261 | do { | 261 | do { |
262 | /* this takes a little while, so don't slam i2c */ | 262 | /* this takes a little while, so don't slam i2c */ |
263 | udelay(2000); | 263 | udelay(2000); |
264 | twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | 264 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, |
265 | TWL4030_REG_ANAMICL); | 265 | TWL4030_REG_ANAMICL); |
266 | } while ((i++ < 100) && | 266 | } while ((i++ < 100) && |
267 | ((byte & TWL4030_CNCL_OFFSET_START) == | 267 | ((byte & TWL4030_CNCL_OFFSET_START) == |
@@ -542,7 +542,7 @@ static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ | |||
542 | break; \ | 542 | break; \ |
543 | case SND_SOC_DAPM_POST_PMD: \ | 543 | case SND_SOC_DAPM_POST_PMD: \ |
544 | reg_val = twl4030_read_reg_cache(w->codec, reg); \ | 544 | reg_val = twl4030_read_reg_cache(w->codec, reg); \ |
545 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, \ | 545 | twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, \ |
546 | reg_val & (~mask), \ | 546 | reg_val & (~mask), \ |
547 | reg); \ | 547 | reg); \ |
548 | break; \ | 548 | break; \ |
@@ -679,7 +679,7 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) | |||
679 | mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / | 679 | mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / |
680 | twl4030->sysclk) + 1); | 680 | twl4030->sysclk) + 1); |
681 | /* Bypass the reg_cache to mute the headset */ | 681 | /* Bypass the reg_cache to mute the headset */ |
682 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | 682 | twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, |
683 | hs_gain & (~0x0f), | 683 | hs_gain & (~0x0f), |
684 | TWL4030_REG_HS_GAIN_SET); | 684 | TWL4030_REG_HS_GAIN_SET); |
685 | 685 | ||
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index f82125d9e85a..ebbf11b653a4 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
@@ -1340,9 +1340,10 @@ static int wm8350_resume(struct platform_device *pdev) | |||
1340 | return 0; | 1340 | return 0; |
1341 | } | 1341 | } |
1342 | 1342 | ||
1343 | static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) | 1343 | static irqreturn_t wm8350_hp_jack_handler(int irq, void *data) |
1344 | { | 1344 | { |
1345 | struct wm8350_data *priv = data; | 1345 | struct wm8350_data *priv = data; |
1346 | struct wm8350 *wm8350 = priv->codec.control_data; | ||
1346 | u16 reg; | 1347 | u16 reg; |
1347 | int report; | 1348 | int report; |
1348 | int mask; | 1349 | int mask; |
@@ -1365,7 +1366,7 @@ static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) | |||
1365 | 1366 | ||
1366 | if (!jack->jack) { | 1367 | if (!jack->jack) { |
1367 | dev_warn(wm8350->dev, "Jack interrupt called with no jack\n"); | 1368 | dev_warn(wm8350->dev, "Jack interrupt called with no jack\n"); |
1368 | return; | 1369 | return IRQ_NONE; |
1369 | } | 1370 | } |
1370 | 1371 | ||
1371 | /* Debounce */ | 1372 | /* Debounce */ |
@@ -1378,6 +1379,8 @@ static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) | |||
1378 | report = 0; | 1379 | report = 0; |
1379 | 1380 | ||
1380 | snd_soc_jack_report(jack->jack, report, jack->report); | 1381 | snd_soc_jack_report(jack->jack, report, jack->report); |
1382 | |||
1383 | return IRQ_HANDLED; | ||
1381 | } | 1384 | } |
1382 | 1385 | ||
1383 | /** | 1386 | /** |
@@ -1421,9 +1424,7 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, | |||
1421 | wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); | 1424 | wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); |
1422 | 1425 | ||
1423 | /* Sync status */ | 1426 | /* Sync status */ |
1424 | wm8350_hp_jack_handler(wm8350, irq, priv); | 1427 | wm8350_hp_jack_handler(irq, priv); |
1425 | |||
1426 | wm8350_unmask_irq(wm8350, irq); | ||
1427 | 1428 | ||
1428 | return 0; | 1429 | return 0; |
1429 | } | 1430 | } |
@@ -1482,12 +1483,16 @@ static int wm8350_probe(struct platform_device *pdev) | |||
1482 | wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, | 1483 | wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, |
1483 | WM8350_OUT2_VU | WM8350_OUT2R_MUTE); | 1484 | WM8350_OUT2_VU | WM8350_OUT2R_MUTE); |
1484 | 1485 | ||
1485 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | 1486 | /* Make sure jack detect is disabled to start off with */ |
1486 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | 1487 | wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, |
1488 | WM8350_JDL_ENA | WM8350_JDR_ENA); | ||
1489 | |||
1487 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, | 1490 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, |
1488 | wm8350_hp_jack_handler, priv); | 1491 | wm8350_hp_jack_handler, 0, "Left jack detect", |
1492 | priv); | ||
1489 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, | 1493 | wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, |
1490 | wm8350_hp_jack_handler, priv); | 1494 | wm8350_hp_jack_handler, 0, "Right jack detect", |
1495 | priv); | ||
1491 | 1496 | ||
1492 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | 1497 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); |
1493 | if (ret < 0) { | 1498 | if (ret < 0) { |
@@ -1516,8 +1521,6 @@ static int wm8350_remove(struct platform_device *pdev) | |||
1516 | WM8350_JDL_ENA | WM8350_JDR_ENA); | 1521 | WM8350_JDL_ENA | WM8350_JDR_ENA); |
1517 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); | 1522 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); |
1518 | 1523 | ||
1519 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | ||
1520 | wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | ||
1521 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | 1524 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); |
1522 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | 1525 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); |
1523 | 1526 | ||
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index c9438dd62df3..dbc368c08263 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
@@ -199,7 +199,7 @@ static void wm8900_reset(struct snd_soc_codec *codec) | |||
199 | snd_soc_write(codec, WM8900_REG_RESET, 0); | 199 | snd_soc_write(codec, WM8900_REG_RESET, 0); |
200 | 200 | ||
201 | memcpy(codec->reg_cache, wm8900_reg_defaults, | 201 | memcpy(codec->reg_cache, wm8900_reg_defaults, |
202 | sizeof(codec->reg_cache)); | 202 | sizeof(wm8900_reg_defaults)); |
203 | } | 203 | } |
204 | 204 | ||
205 | static int wm8900_hp_event(struct snd_soc_dapm_widget *w, | 205 | static int wm8900_hp_event(struct snd_soc_dapm_widget *w, |
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index 81c57b5c591c..a808675388fc 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c | |||
@@ -47,7 +47,7 @@ static const u16 wm8974_reg[WM8974_CACHEREGNUM] = { | |||
47 | }; | 47 | }; |
48 | 48 | ||
49 | #define WM8974_POWER1_BIASEN 0x08 | 49 | #define WM8974_POWER1_BIASEN 0x08 |
50 | #define WM8974_POWER1_BUFIOEN 0x10 | 50 | #define WM8974_POWER1_BUFIOEN 0x04 |
51 | 51 | ||
52 | struct wm8974_priv { | 52 | struct wm8974_priv { |
53 | struct snd_soc_codec codec; | 53 | struct snd_soc_codec codec; |
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 0ac1215dcd9b..e237bf615129 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c | |||
@@ -463,7 +463,8 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, | |||
463 | { | 463 | { |
464 | u16 *cache = codec->reg_cache; | 464 | u16 *cache = codec->reg_cache; |
465 | 465 | ||
466 | soc_ac97_ops.write(codec->ac97, reg, val); | 466 | if (reg < 0x7c) |
467 | soc_ac97_ops.write(codec->ac97, reg, val); | ||
467 | reg = reg >> 1; | 468 | reg = reg >> 1; |
468 | if (reg < (ARRAY_SIZE(wm9712_reg))) | 469 | if (reg < (ARRAY_SIZE(wm9712_reg))) |
469 | cache[reg] = val; | 470 | cache[reg] = val; |
diff --git a/sound/soc/imx/mx27vis_wm8974.c b/sound/soc/imx/mx27vis_wm8974.c index 0267d2d91685..07d2a248438c 100644 --- a/sound/soc/imx/mx27vis_wm8974.c +++ b/sound/soc/imx/mx27vis_wm8974.c | |||
@@ -180,7 +180,8 @@ static int mx27vis_hifi_hw_free(struct snd_pcm_substream *substream) | |||
180 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | 180 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; |
181 | 181 | ||
182 | /* disable the PLL */ | 182 | /* disable the PLL */ |
183 | return codec_dai->ops->set_pll(codec_dai, IGNORED_ARG, 0, 0); | 183 | return codec_dai->ops->set_pll(codec_dai, IGNORED_ARG, IGNORED_ARG, |
184 | 0, 0); | ||
184 | } | 185 | } |
185 | 186 | ||
186 | /* | 187 | /* |
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index c071f9603a38..3c85c0f92823 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/i2c/twl4030.h> | 27 | #include <linux/i2c/twl.h> |
28 | #include <sound/core.h> | 28 | #include <sound/core.h> |
29 | #include <sound/pcm.h> | 29 | #include <sound/pcm.h> |
30 | #include <sound/soc.h> | 30 | #include <sound/soc.h> |
@@ -321,11 +321,11 @@ static int __init sdp3430_soc_init(void) | |||
321 | *(unsigned int *)sdp3430_dai[1].cpu_dai->private_data = 2; /* McBSP3 */ | 321 | *(unsigned int *)sdp3430_dai[1].cpu_dai->private_data = 2; /* McBSP3 */ |
322 | 322 | ||
323 | /* Set TWL4030 GPIO6 as EXTMUTE signal */ | 323 | /* Set TWL4030 GPIO6 as EXTMUTE signal */ |
324 | twl4030_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux, | 324 | twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux, |
325 | TWL4030_INTBR_PMBR1); | 325 | TWL4030_INTBR_PMBR1); |
326 | pin_mux &= ~TWL4030_GPIO6_PWM0_MUTE(0x03); | 326 | pin_mux &= ~TWL4030_GPIO6_PWM0_MUTE(0x03); |
327 | pin_mux |= TWL4030_GPIO6_PWM0_MUTE(0x02); | 327 | pin_mux |= TWL4030_GPIO6_PWM0_MUTE(0x02); |
328 | twl4030_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux, | 328 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux, |
329 | TWL4030_INTBR_PMBR1); | 329 | TWL4030_INTBR_PMBR1); |
330 | 330 | ||
331 | ret = platform_device_add(sdp3430_snd_device); | 331 | ret = platform_device_add(sdp3430_snd_device); |
diff --git a/sound/soc/s3c24xx/s3c24xx_simtec.c b/sound/soc/s3c24xx/s3c24xx_simtec.c index d441c3b64631..4984754f3298 100644 --- a/sound/soc/s3c24xx/s3c24xx_simtec.c +++ b/sound/soc/s3c24xx/s3c24xx_simtec.c | |||
@@ -312,7 +312,7 @@ int simtec_audio_resume(struct device *dev) | |||
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | 314 | ||
315 | struct dev_pm_ops simtec_audio_pmops = { | 315 | const struct dev_pm_ops simtec_audio_pmops = { |
316 | .resume = simtec_audio_resume, | 316 | .resume = simtec_audio_resume, |
317 | }; | 317 | }; |
318 | EXPORT_SYMBOL_GPL(simtec_audio_pmops); | 318 | EXPORT_SYMBOL_GPL(simtec_audio_pmops); |
diff --git a/sound/soc/s3c24xx/s3c24xx_simtec.h b/sound/soc/s3c24xx/s3c24xx_simtec.h index 2714203af161..e18faee30cce 100644 --- a/sound/soc/s3c24xx/s3c24xx_simtec.h +++ b/sound/soc/s3c24xx/s3c24xx_simtec.h | |||
@@ -15,7 +15,7 @@ extern int simtec_audio_core_probe(struct platform_device *pdev, | |||
15 | extern int simtec_audio_remove(struct platform_device *pdev); | 15 | extern int simtec_audio_remove(struct platform_device *pdev); |
16 | 16 | ||
17 | #ifdef CONFIG_PM | 17 | #ifdef CONFIG_PM |
18 | extern struct dev_pm_ops simtec_audio_pmops; | 18 | extern const struct dev_pm_ops simtec_audio_pmops; |
19 | #define simtec_audio_pm &simtec_audio_pmops | 19 | #define simtec_audio_pm &simtec_audio_pmops |
20 | #else | 20 | #else |
21 | #define simtec_audio_pm NULL | 21 | #define simtec_audio_pm NULL |
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 9c49c11c43ce..42813b808389 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
@@ -876,7 +876,7 @@ static int fsi_probe(struct platform_device *pdev) | |||
876 | 876 | ||
877 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 877 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
878 | irq = platform_get_irq(pdev, 0); | 878 | irq = platform_get_irq(pdev, 0); |
879 | if (!res || !irq) { | 879 | if (!res || (int)irq <= 0) { |
880 | dev_err(&pdev->dev, "Not enough FSI platform resources.\n"); | 880 | dev_err(&pdev->dev, "Not enough FSI platform resources.\n"); |
881 | ret = -ENODEV; | 881 | ret = -ENODEV; |
882 | goto exit; | 882 | goto exit; |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ef8f28284cb9..0a6440c6f54a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1236,7 +1236,7 @@ static int soc_poweroff(struct device *dev) | |||
1236 | return 0; | 1236 | return 0; |
1237 | } | 1237 | } |
1238 | 1238 | ||
1239 | static struct dev_pm_ops soc_pm_ops = { | 1239 | static const struct dev_pm_ops soc_pm_ops = { |
1240 | .suspend = soc_suspend, | 1240 | .suspend = soc_suspend, |
1241 | .resume = soc_resume, | 1241 | .resume = soc_resume, |
1242 | .poweroff = soc_poweroff, | 1242 | .poweroff = soc_poweroff, |
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index 73525c048e7f..8c2925814ce4 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig | |||
@@ -21,6 +21,18 @@ config SND_USB_AUDIO | |||
21 | To compile this driver as a module, choose M here: the module | 21 | To compile this driver as a module, choose M here: the module |
22 | will be called snd-usb-audio. | 22 | will be called snd-usb-audio. |
23 | 23 | ||
24 | config SND_USB_UA101 | ||
25 | tristate "Edirol UA-101 driver (EXPERIMENTAL)" | ||
26 | depends on EXPERIMENTAL | ||
27 | select SND_PCM | ||
28 | select SND_RAWMIDI | ||
29 | help | ||
30 | Say Y here to include support for the Edirol UA-101 audio/MIDI | ||
31 | interface. | ||
32 | |||
33 | To compile this driver as a module, choose M here: the module | ||
34 | will be called snd-ua101. | ||
35 | |||
24 | config SND_USB_USX2Y | 36 | config SND_USB_USX2Y |
25 | tristate "Tascam US-122, US-224 and US-428 USB driver" | 37 | tristate "Tascam US-122, US-224 and US-428 USB driver" |
26 | depends on X86 || PPC || ALPHA | 38 | depends on X86 || PPC || ALPHA |
diff --git a/sound/usb/Makefile b/sound/usb/Makefile index abb288bfe35d..5bf64aef9558 100644 --- a/sound/usb/Makefile +++ b/sound/usb/Makefile | |||
@@ -4,9 +4,11 @@ | |||
4 | 4 | ||
5 | snd-usb-audio-objs := usbaudio.o usbmixer.o | 5 | snd-usb-audio-objs := usbaudio.o usbmixer.o |
6 | snd-usb-lib-objs := usbmidi.o | 6 | snd-usb-lib-objs := usbmidi.o |
7 | snd-ua101-objs := ua101.o | ||
7 | 8 | ||
8 | # Toplevel Module Dependency | 9 | # Toplevel Module Dependency |
9 | obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o | 10 | obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o |
11 | obj-$(CONFIG_SND_USB_UA101) += snd-ua101.o snd-usb-lib.o | ||
10 | obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o | 12 | obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o |
11 | obj-$(CONFIG_SND_USB_US122L) += snd-usb-lib.o | 13 | obj-$(CONFIG_SND_USB_US122L) += snd-usb-lib.o |
12 | 14 | ||
diff --git a/sound/usb/ua101.c b/sound/usb/ua101.c new file mode 100644 index 000000000000..16dc7bd5e120 --- /dev/null +++ b/sound/usb/ua101.c | |||
@@ -0,0 +1,1419 @@ | |||
1 | /* | ||
2 | * Edirol UA-101 driver | ||
3 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
4 | * | ||
5 | * This driver is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License, version 2. | ||
7 | * | ||
8 | * This driver is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this driver. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/init.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/usb.h> | ||
21 | #include <linux/usb/audio.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/initval.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/pcm_params.h> | ||
26 | #include "usbaudio.h" | ||
27 | |||
28 | MODULE_DESCRIPTION("Edirol UA-101 driver"); | ||
29 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | ||
30 | MODULE_LICENSE("GPL v2"); | ||
31 | MODULE_SUPPORTED_DEVICE("{{Edirol,UA-101}}"); | ||
32 | |||
33 | /* I use my UA-1A for testing because I don't have a UA-101 ... */ | ||
34 | #define UA1A_HACK | ||
35 | |||
36 | /* | ||
37 | * Should not be lower than the minimum scheduling delay of the host | ||
38 | * controller. Some Intel controllers need more than one frame; as long as | ||
39 | * that driver doesn't tell us about this, use 1.5 frames just to be sure. | ||
40 | */ | ||
41 | #define MIN_QUEUE_LENGTH 12 | ||
42 | /* Somewhat random. */ | ||
43 | #define MAX_QUEUE_LENGTH 30 | ||
44 | /* | ||
45 | * This magic value optimizes memory usage efficiency for the UA-101's packet | ||
46 | * sizes at all sample rates, taking into account the stupid cache pool sizes | ||
47 | * that usb_buffer_alloc() uses. | ||
48 | */ | ||
49 | #define DEFAULT_QUEUE_LENGTH 21 | ||
50 | |||
51 | #define MAX_PACKET_SIZE 672 /* hardware specific */ | ||
52 | #define MAX_MEMORY_BUFFERS DIV_ROUND_UP(MAX_QUEUE_LENGTH, \ | ||
53 | PAGE_SIZE / MAX_PACKET_SIZE) | ||
54 | |||
55 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | ||
56 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | ||
57 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | ||
58 | static unsigned int queue_length = 21; | ||
59 | |||
60 | module_param_array(index, int, NULL, 0444); | ||
61 | MODULE_PARM_DESC(index, "card index"); | ||
62 | module_param_array(id, charp, NULL, 0444); | ||
63 | MODULE_PARM_DESC(id, "ID string"); | ||
64 | module_param_array(enable, bool, NULL, 0444); | ||
65 | MODULE_PARM_DESC(enable, "enable card"); | ||
66 | module_param(queue_length, uint, 0644); | ||
67 | MODULE_PARM_DESC(queue_length, "USB queue length in microframes, " | ||
68 | __stringify(MIN_QUEUE_LENGTH)"-"__stringify(MAX_QUEUE_LENGTH)); | ||
69 | |||
70 | enum { | ||
71 | INTF_PLAYBACK, | ||
72 | INTF_CAPTURE, | ||
73 | INTF_MIDI, | ||
74 | |||
75 | INTF_COUNT | ||
76 | }; | ||
77 | |||
78 | /* bits in struct ua101::states */ | ||
79 | enum { | ||
80 | USB_CAPTURE_RUNNING, | ||
81 | USB_PLAYBACK_RUNNING, | ||
82 | ALSA_CAPTURE_OPEN, | ||
83 | ALSA_PLAYBACK_OPEN, | ||
84 | ALSA_CAPTURE_RUNNING, | ||
85 | ALSA_PLAYBACK_RUNNING, | ||
86 | CAPTURE_URB_COMPLETED, | ||
87 | PLAYBACK_URB_COMPLETED, | ||
88 | DISCONNECTED, | ||
89 | }; | ||
90 | |||
91 | struct ua101 { | ||
92 | struct usb_device *dev; | ||
93 | struct snd_card *card; | ||
94 | struct usb_interface *intf[INTF_COUNT]; | ||
95 | int card_index; | ||
96 | struct snd_pcm *pcm; | ||
97 | struct list_head midi_list; | ||
98 | u64 format_bit; | ||
99 | unsigned int rate; | ||
100 | unsigned int packets_per_second; | ||
101 | spinlock_t lock; | ||
102 | struct mutex mutex; | ||
103 | unsigned long states; | ||
104 | |||
105 | /* FIFO to synchronize playback rate to capture rate */ | ||
106 | unsigned int rate_feedback_start; | ||
107 | unsigned int rate_feedback_count; | ||
108 | u8 rate_feedback[MAX_QUEUE_LENGTH]; | ||
109 | |||
110 | struct list_head ready_playback_urbs; | ||
111 | struct tasklet_struct playback_tasklet; | ||
112 | wait_queue_head_t alsa_capture_wait; | ||
113 | wait_queue_head_t rate_feedback_wait; | ||
114 | wait_queue_head_t alsa_playback_wait; | ||
115 | struct ua101_stream { | ||
116 | struct snd_pcm_substream *substream; | ||
117 | unsigned int usb_pipe; | ||
118 | unsigned int channels; | ||
119 | unsigned int frame_bytes; | ||
120 | unsigned int max_packet_bytes; | ||
121 | unsigned int period_pos; | ||
122 | unsigned int buffer_pos; | ||
123 | unsigned int queue_length; | ||
124 | struct ua101_urb { | ||
125 | struct urb urb; | ||
126 | struct usb_iso_packet_descriptor iso_frame_desc[1]; | ||
127 | struct list_head ready_list; | ||
128 | } *urbs[MAX_QUEUE_LENGTH]; | ||
129 | struct { | ||
130 | unsigned int size; | ||
131 | void *addr; | ||
132 | dma_addr_t dma; | ||
133 | } buffers[MAX_MEMORY_BUFFERS]; | ||
134 | } capture, playback; | ||
135 | |||
136 | unsigned int fps[10]; | ||
137 | unsigned int frame_counter; | ||
138 | }; | ||
139 | |||
140 | static DEFINE_MUTEX(devices_mutex); | ||
141 | static unsigned int devices_used; | ||
142 | static struct usb_driver ua101_driver; | ||
143 | |||
144 | static void abort_alsa_playback(struct ua101 *ua); | ||
145 | static void abort_alsa_capture(struct ua101 *ua); | ||
146 | |||
147 | static const char *usb_error_string(int err) | ||
148 | { | ||
149 | switch (err) { | ||
150 | case -ENODEV: | ||
151 | return "no device"; | ||
152 | case -ENOENT: | ||
153 | return "endpoint not enabled"; | ||
154 | case -EPIPE: | ||
155 | return "endpoint stalled"; | ||
156 | case -ENOSPC: | ||
157 | return "not enough bandwidth"; | ||
158 | case -ESHUTDOWN: | ||
159 | return "device disabled"; | ||
160 | case -EHOSTUNREACH: | ||
161 | return "device suspended"; | ||
162 | case -EINVAL: | ||
163 | case -EAGAIN: | ||
164 | case -EFBIG: | ||
165 | case -EMSGSIZE: | ||
166 | return "internal error"; | ||
167 | default: | ||
168 | return "unknown error"; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | static void abort_usb_capture(struct ua101 *ua) | ||
173 | { | ||
174 | if (test_and_clear_bit(USB_CAPTURE_RUNNING, &ua->states)) { | ||
175 | wake_up(&ua->alsa_capture_wait); | ||
176 | wake_up(&ua->rate_feedback_wait); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | static void abort_usb_playback(struct ua101 *ua) | ||
181 | { | ||
182 | if (test_and_clear_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
183 | wake_up(&ua->alsa_playback_wait); | ||
184 | } | ||
185 | |||
186 | static void playback_urb_complete(struct urb *usb_urb) | ||
187 | { | ||
188 | struct ua101_urb *urb = (struct ua101_urb *)usb_urb; | ||
189 | struct ua101 *ua = urb->urb.context; | ||
190 | unsigned long flags; | ||
191 | |||
192 | if (unlikely(urb->urb.status == -ENOENT || /* unlinked */ | ||
193 | urb->urb.status == -ENODEV || /* device removed */ | ||
194 | urb->urb.status == -ECONNRESET || /* unlinked */ | ||
195 | urb->urb.status == -ESHUTDOWN)) { /* device disabled */ | ||
196 | abort_usb_playback(ua); | ||
197 | abort_alsa_playback(ua); | ||
198 | return; | ||
199 | } | ||
200 | |||
201 | if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) { | ||
202 | /* append URB to FIFO */ | ||
203 | spin_lock_irqsave(&ua->lock, flags); | ||
204 | list_add_tail(&urb->ready_list, &ua->ready_playback_urbs); | ||
205 | if (ua->rate_feedback_count > 0) | ||
206 | tasklet_schedule(&ua->playback_tasklet); | ||
207 | ua->playback.substream->runtime->delay -= | ||
208 | urb->urb.iso_frame_desc[0].length / | ||
209 | ua->playback.frame_bytes; | ||
210 | spin_unlock_irqrestore(&ua->lock, flags); | ||
211 | } | ||
212 | } | ||
213 | |||
214 | static void first_playback_urb_complete(struct urb *urb) | ||
215 | { | ||
216 | struct ua101 *ua = urb->context; | ||
217 | |||
218 | urb->complete = playback_urb_complete; | ||
219 | playback_urb_complete(urb); | ||
220 | |||
221 | set_bit(PLAYBACK_URB_COMPLETED, &ua->states); | ||
222 | wake_up(&ua->alsa_playback_wait); | ||
223 | } | ||
224 | |||
225 | /* copy data from the ALSA ring buffer into the URB buffer */ | ||
226 | static bool copy_playback_data(struct ua101_stream *stream, struct urb *urb, | ||
227 | unsigned int frames) | ||
228 | { | ||
229 | struct snd_pcm_runtime *runtime; | ||
230 | unsigned int frame_bytes, frames1; | ||
231 | const u8 *source; | ||
232 | |||
233 | runtime = stream->substream->runtime; | ||
234 | frame_bytes = stream->frame_bytes; | ||
235 | source = runtime->dma_area + stream->buffer_pos * frame_bytes; | ||
236 | if (stream->buffer_pos + frames <= runtime->buffer_size) { | ||
237 | memcpy(urb->transfer_buffer, source, frames * frame_bytes); | ||
238 | } else { | ||
239 | /* wrap around at end of ring buffer */ | ||
240 | frames1 = runtime->buffer_size - stream->buffer_pos; | ||
241 | memcpy(urb->transfer_buffer, source, frames1 * frame_bytes); | ||
242 | memcpy(urb->transfer_buffer + frames1 * frame_bytes, | ||
243 | runtime->dma_area, (frames - frames1) * frame_bytes); | ||
244 | } | ||
245 | |||
246 | stream->buffer_pos += frames; | ||
247 | if (stream->buffer_pos >= runtime->buffer_size) | ||
248 | stream->buffer_pos -= runtime->buffer_size; | ||
249 | stream->period_pos += frames; | ||
250 | if (stream->period_pos >= runtime->period_size) { | ||
251 | stream->period_pos -= runtime->period_size; | ||
252 | return true; | ||
253 | } | ||
254 | return false; | ||
255 | } | ||
256 | |||
257 | static inline void add_with_wraparound(struct ua101 *ua, | ||
258 | unsigned int *value, unsigned int add) | ||
259 | { | ||
260 | *value += add; | ||
261 | if (*value >= ua->playback.queue_length) | ||
262 | *value -= ua->playback.queue_length; | ||
263 | } | ||
264 | |||
265 | static void playback_tasklet(unsigned long data) | ||
266 | { | ||
267 | struct ua101 *ua = (void *)data; | ||
268 | unsigned long flags; | ||
269 | unsigned int frames; | ||
270 | struct ua101_urb *urb; | ||
271 | bool do_period_elapsed = false; | ||
272 | int err; | ||
273 | |||
274 | if (unlikely(!test_bit(USB_PLAYBACK_RUNNING, &ua->states))) | ||
275 | return; | ||
276 | |||
277 | /* | ||
278 | * Synchronizing the playback rate to the capture rate is done by using | ||
279 | * the same sequence of packet sizes for both streams. | ||
280 | * Submitting a playback URB therefore requires both a ready URB and | ||
281 | * the size of the corresponding capture packet, i.e., both playback | ||
282 | * and capture URBs must have been completed. Since the USB core does | ||
283 | * not guarantee that playback and capture complete callbacks are | ||
284 | * called alternately, we use two FIFOs for packet sizes and read URBs; | ||
285 | * submitting playback URBs is possible as long as both FIFOs are | ||
286 | * nonempty. | ||
287 | */ | ||
288 | spin_lock_irqsave(&ua->lock, flags); | ||
289 | while (ua->rate_feedback_count > 0 && | ||
290 | !list_empty(&ua->ready_playback_urbs)) { | ||
291 | /* take packet size out of FIFO */ | ||
292 | frames = ua->rate_feedback[ua->rate_feedback_start]; | ||
293 | add_with_wraparound(ua, &ua->rate_feedback_start, 1); | ||
294 | ua->rate_feedback_count--; | ||
295 | |||
296 | /* take URB out of FIFO */ | ||
297 | urb = list_first_entry(&ua->ready_playback_urbs, | ||
298 | struct ua101_urb, ready_list); | ||
299 | list_del(&urb->ready_list); | ||
300 | |||
301 | /* fill packet with data or silence */ | ||
302 | urb->urb.iso_frame_desc[0].length = | ||
303 | frames * ua->playback.frame_bytes; | ||
304 | if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) | ||
305 | do_period_elapsed |= copy_playback_data(&ua->playback, | ||
306 | &urb->urb, | ||
307 | frames); | ||
308 | else | ||
309 | memset(urb->urb.transfer_buffer, 0, | ||
310 | urb->urb.iso_frame_desc[0].length); | ||
311 | |||
312 | /* and off you go ... */ | ||
313 | err = usb_submit_urb(&urb->urb, GFP_ATOMIC); | ||
314 | if (unlikely(err < 0)) { | ||
315 | spin_unlock_irqrestore(&ua->lock, flags); | ||
316 | abort_usb_playback(ua); | ||
317 | abort_alsa_playback(ua); | ||
318 | dev_err(&ua->dev->dev, "USB request error %d: %s\n", | ||
319 | err, usb_error_string(err)); | ||
320 | return; | ||
321 | } | ||
322 | ua->playback.substream->runtime->delay += frames; | ||
323 | } | ||
324 | spin_unlock_irqrestore(&ua->lock, flags); | ||
325 | if (do_period_elapsed) | ||
326 | snd_pcm_period_elapsed(ua->playback.substream); | ||
327 | } | ||
328 | |||
329 | /* copy data from the URB buffer into the ALSA ring buffer */ | ||
330 | static bool copy_capture_data(struct ua101_stream *stream, struct urb *urb, | ||
331 | unsigned int frames) | ||
332 | { | ||
333 | struct snd_pcm_runtime *runtime; | ||
334 | unsigned int frame_bytes, frames1; | ||
335 | u8 *dest; | ||
336 | |||
337 | runtime = stream->substream->runtime; | ||
338 | frame_bytes = stream->frame_bytes; | ||
339 | dest = runtime->dma_area + stream->buffer_pos * frame_bytes; | ||
340 | if (stream->buffer_pos + frames <= runtime->buffer_size) { | ||
341 | memcpy(dest, urb->transfer_buffer, frames * frame_bytes); | ||
342 | } else { | ||
343 | /* wrap around at end of ring buffer */ | ||
344 | frames1 = runtime->buffer_size - stream->buffer_pos; | ||
345 | memcpy(dest, urb->transfer_buffer, frames1 * frame_bytes); | ||
346 | memcpy(runtime->dma_area, | ||
347 | urb->transfer_buffer + frames1 * frame_bytes, | ||
348 | (frames - frames1) * frame_bytes); | ||
349 | } | ||
350 | |||
351 | stream->buffer_pos += frames; | ||
352 | if (stream->buffer_pos >= runtime->buffer_size) | ||
353 | stream->buffer_pos -= runtime->buffer_size; | ||
354 | stream->period_pos += frames; | ||
355 | if (stream->period_pos >= runtime->period_size) { | ||
356 | stream->period_pos -= runtime->period_size; | ||
357 | return true; | ||
358 | } | ||
359 | return false; | ||
360 | } | ||
361 | |||
362 | static void capture_urb_complete(struct urb *urb) | ||
363 | { | ||
364 | struct ua101 *ua = urb->context; | ||
365 | struct ua101_stream *stream = &ua->capture; | ||
366 | unsigned long flags; | ||
367 | unsigned int frames, write_ptr; | ||
368 | bool do_period_elapsed; | ||
369 | int err; | ||
370 | |||
371 | if (unlikely(urb->status == -ENOENT || /* unlinked */ | ||
372 | urb->status == -ENODEV || /* device removed */ | ||
373 | urb->status == -ECONNRESET || /* unlinked */ | ||
374 | urb->status == -ESHUTDOWN)) /* device disabled */ | ||
375 | goto stream_stopped; | ||
376 | |||
377 | if (urb->status >= 0 && urb->iso_frame_desc[0].status >= 0) | ||
378 | frames = urb->iso_frame_desc[0].actual_length / | ||
379 | stream->frame_bytes; | ||
380 | else | ||
381 | frames = 0; | ||
382 | |||
383 | spin_lock_irqsave(&ua->lock, flags); | ||
384 | |||
385 | if (frames > 0 && test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) | ||
386 | do_period_elapsed = copy_capture_data(stream, urb, frames); | ||
387 | else | ||
388 | do_period_elapsed = false; | ||
389 | |||
390 | if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) { | ||
391 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
392 | if (unlikely(err < 0)) { | ||
393 | spin_unlock_irqrestore(&ua->lock, flags); | ||
394 | dev_err(&ua->dev->dev, "USB request error %d: %s\n", | ||
395 | err, usb_error_string(err)); | ||
396 | goto stream_stopped; | ||
397 | } | ||
398 | |||
399 | /* append packet size to FIFO */ | ||
400 | write_ptr = ua->rate_feedback_start; | ||
401 | add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count); | ||
402 | ua->rate_feedback[write_ptr] = frames; | ||
403 | if (ua->rate_feedback_count < ua->playback.queue_length) { | ||
404 | ua->rate_feedback_count++; | ||
405 | if (ua->rate_feedback_count == | ||
406 | ua->playback.queue_length) | ||
407 | wake_up(&ua->rate_feedback_wait); | ||
408 | } else { | ||
409 | /* | ||
410 | * Ring buffer overflow; this happens when the playback | ||
411 | * stream is not running. Throw away the oldest entry, | ||
412 | * so that the playback stream, when it starts, sees | ||
413 | * the most recent packet sizes. | ||
414 | */ | ||
415 | add_with_wraparound(ua, &ua->rate_feedback_start, 1); | ||
416 | } | ||
417 | if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) && | ||
418 | !list_empty(&ua->ready_playback_urbs)) | ||
419 | tasklet_schedule(&ua->playback_tasklet); | ||
420 | } | ||
421 | |||
422 | spin_unlock_irqrestore(&ua->lock, flags); | ||
423 | |||
424 | if (do_period_elapsed) | ||
425 | snd_pcm_period_elapsed(stream->substream); | ||
426 | |||
427 | /* for debugging: measure the sample rate relative to the USB clock */ | ||
428 | ua->fps[ua->frame_counter++ / ua->packets_per_second] += frames; | ||
429 | if (ua->frame_counter >= ARRAY_SIZE(ua->fps) * ua->packets_per_second) { | ||
430 | printk(KERN_DEBUG "capture rate:"); | ||
431 | for (frames = 0; frames < ARRAY_SIZE(ua->fps); ++frames) | ||
432 | printk(KERN_CONT " %u", ua->fps[frames]); | ||
433 | printk(KERN_CONT "\n"); | ||
434 | memset(ua->fps, 0, sizeof(ua->fps)); | ||
435 | ua->frame_counter = 0; | ||
436 | } | ||
437 | return; | ||
438 | |||
439 | stream_stopped: | ||
440 | abort_usb_playback(ua); | ||
441 | abort_usb_capture(ua); | ||
442 | abort_alsa_playback(ua); | ||
443 | abort_alsa_capture(ua); | ||
444 | } | ||
445 | |||
446 | static void first_capture_urb_complete(struct urb *urb) | ||
447 | { | ||
448 | struct ua101 *ua = urb->context; | ||
449 | |||
450 | urb->complete = capture_urb_complete; | ||
451 | capture_urb_complete(urb); | ||
452 | |||
453 | set_bit(CAPTURE_URB_COMPLETED, &ua->states); | ||
454 | wake_up(&ua->alsa_capture_wait); | ||
455 | } | ||
456 | |||
457 | static int submit_stream_urbs(struct ua101 *ua, struct ua101_stream *stream) | ||
458 | { | ||
459 | unsigned int i; | ||
460 | |||
461 | for (i = 0; i < stream->queue_length; ++i) { | ||
462 | int err = usb_submit_urb(&stream->urbs[i]->urb, GFP_KERNEL); | ||
463 | if (err < 0) { | ||
464 | dev_err(&ua->dev->dev, "USB request error %d: %s\n", | ||
465 | err, usb_error_string(err)); | ||
466 | return err; | ||
467 | } | ||
468 | } | ||
469 | return 0; | ||
470 | } | ||
471 | |||
472 | static void kill_stream_urbs(struct ua101_stream *stream) | ||
473 | { | ||
474 | unsigned int i; | ||
475 | |||
476 | for (i = 0; i < stream->queue_length; ++i) | ||
477 | usb_kill_urb(&stream->urbs[i]->urb); | ||
478 | } | ||
479 | |||
480 | static int enable_iso_interface(struct ua101 *ua, unsigned int intf_index) | ||
481 | { | ||
482 | struct usb_host_interface *alts; | ||
483 | |||
484 | alts = ua->intf[intf_index]->cur_altsetting; | ||
485 | if (alts->desc.bAlternateSetting != 1) { | ||
486 | int err = usb_set_interface(ua->dev, | ||
487 | alts->desc.bInterfaceNumber, 1); | ||
488 | if (err < 0) { | ||
489 | dev_err(&ua->dev->dev, | ||
490 | "cannot initialize interface; error %d: %s\n", | ||
491 | err, usb_error_string(err)); | ||
492 | return err; | ||
493 | } | ||
494 | } | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | static void disable_iso_interface(struct ua101 *ua, unsigned int intf_index) | ||
499 | { | ||
500 | struct usb_host_interface *alts; | ||
501 | |||
502 | alts = ua->intf[intf_index]->cur_altsetting; | ||
503 | if (alts->desc.bAlternateSetting != 0) { | ||
504 | int err = usb_set_interface(ua->dev, | ||
505 | alts->desc.bInterfaceNumber, 0); | ||
506 | if (err < 0 && !test_bit(DISCONNECTED, &ua->states)) | ||
507 | dev_warn(&ua->dev->dev, | ||
508 | "interface reset failed; error %d: %s\n", | ||
509 | err, usb_error_string(err)); | ||
510 | } | ||
511 | } | ||
512 | |||
513 | static void stop_usb_capture(struct ua101 *ua) | ||
514 | { | ||
515 | clear_bit(USB_CAPTURE_RUNNING, &ua->states); | ||
516 | |||
517 | kill_stream_urbs(&ua->capture); | ||
518 | |||
519 | disable_iso_interface(ua, INTF_CAPTURE); | ||
520 | } | ||
521 | |||
522 | static int start_usb_capture(struct ua101 *ua) | ||
523 | { | ||
524 | int err; | ||
525 | |||
526 | if (test_bit(DISCONNECTED, &ua->states)) | ||
527 | return -ENODEV; | ||
528 | |||
529 | if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) | ||
530 | return 0; | ||
531 | |||
532 | kill_stream_urbs(&ua->capture); | ||
533 | |||
534 | err = enable_iso_interface(ua, INTF_CAPTURE); | ||
535 | if (err < 0) | ||
536 | return err; | ||
537 | |||
538 | clear_bit(CAPTURE_URB_COMPLETED, &ua->states); | ||
539 | ua->capture.urbs[0]->urb.complete = first_capture_urb_complete; | ||
540 | ua->rate_feedback_start = 0; | ||
541 | ua->rate_feedback_count = 0; | ||
542 | |||
543 | set_bit(USB_CAPTURE_RUNNING, &ua->states); | ||
544 | err = submit_stream_urbs(ua, &ua->capture); | ||
545 | if (err < 0) | ||
546 | stop_usb_capture(ua); | ||
547 | return err; | ||
548 | } | ||
549 | |||
550 | static void stop_usb_playback(struct ua101 *ua) | ||
551 | { | ||
552 | clear_bit(USB_PLAYBACK_RUNNING, &ua->states); | ||
553 | |||
554 | kill_stream_urbs(&ua->playback); | ||
555 | |||
556 | tasklet_kill(&ua->playback_tasklet); | ||
557 | |||
558 | disable_iso_interface(ua, INTF_PLAYBACK); | ||
559 | } | ||
560 | |||
561 | static int start_usb_playback(struct ua101 *ua) | ||
562 | { | ||
563 | unsigned int i, frames; | ||
564 | struct urb *urb; | ||
565 | int err = 0; | ||
566 | |||
567 | if (test_bit(DISCONNECTED, &ua->states)) | ||
568 | return -ENODEV; | ||
569 | |||
570 | if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
571 | return 0; | ||
572 | |||
573 | kill_stream_urbs(&ua->playback); | ||
574 | tasklet_kill(&ua->playback_tasklet); | ||
575 | |||
576 | err = enable_iso_interface(ua, INTF_PLAYBACK); | ||
577 | if (err < 0) | ||
578 | return err; | ||
579 | |||
580 | clear_bit(PLAYBACK_URB_COMPLETED, &ua->states); | ||
581 | ua->playback.urbs[0]->urb.complete = | ||
582 | first_playback_urb_complete; | ||
583 | spin_lock_irq(&ua->lock); | ||
584 | INIT_LIST_HEAD(&ua->ready_playback_urbs); | ||
585 | spin_unlock_irq(&ua->lock); | ||
586 | |||
587 | /* | ||
588 | * We submit the initial URBs all at once, so we have to wait for the | ||
589 | * packet size FIFO to be full. | ||
590 | */ | ||
591 | wait_event(ua->rate_feedback_wait, | ||
592 | ua->rate_feedback_count >= ua->playback.queue_length || | ||
593 | !test_bit(USB_CAPTURE_RUNNING, &ua->states) || | ||
594 | test_bit(DISCONNECTED, &ua->states)); | ||
595 | if (test_bit(DISCONNECTED, &ua->states)) { | ||
596 | stop_usb_playback(ua); | ||
597 | return -ENODEV; | ||
598 | } | ||
599 | if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) { | ||
600 | stop_usb_playback(ua); | ||
601 | return -EIO; | ||
602 | } | ||
603 | |||
604 | for (i = 0; i < ua->playback.queue_length; ++i) { | ||
605 | /* all initial URBs contain silence */ | ||
606 | spin_lock_irq(&ua->lock); | ||
607 | frames = ua->rate_feedback[ua->rate_feedback_start]; | ||
608 | add_with_wraparound(ua, &ua->rate_feedback_start, 1); | ||
609 | ua->rate_feedback_count--; | ||
610 | spin_unlock_irq(&ua->lock); | ||
611 | urb = &ua->playback.urbs[i]->urb; | ||
612 | urb->iso_frame_desc[0].length = | ||
613 | frames * ua->playback.frame_bytes; | ||
614 | memset(urb->transfer_buffer, 0, | ||
615 | urb->iso_frame_desc[0].length); | ||
616 | } | ||
617 | |||
618 | set_bit(USB_PLAYBACK_RUNNING, &ua->states); | ||
619 | err = submit_stream_urbs(ua, &ua->playback); | ||
620 | if (err < 0) | ||
621 | stop_usb_playback(ua); | ||
622 | return err; | ||
623 | } | ||
624 | |||
625 | static void abort_alsa_capture(struct ua101 *ua) | ||
626 | { | ||
627 | if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) | ||
628 | snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN); | ||
629 | } | ||
630 | |||
631 | static void abort_alsa_playback(struct ua101 *ua) | ||
632 | { | ||
633 | if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) | ||
634 | snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN); | ||
635 | } | ||
636 | |||
637 | static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, | ||
638 | unsigned int channels) | ||
639 | { | ||
640 | int err; | ||
641 | |||
642 | substream->runtime->hw.info = | ||
643 | SNDRV_PCM_INFO_MMAP | | ||
644 | SNDRV_PCM_INFO_MMAP_VALID | | ||
645 | SNDRV_PCM_INFO_BATCH | | ||
646 | SNDRV_PCM_INFO_INTERLEAVED | | ||
647 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
648 | SNDRV_PCM_INFO_FIFO_IN_FRAMES; | ||
649 | substream->runtime->hw.formats = ua->format_bit; | ||
650 | substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate); | ||
651 | substream->runtime->hw.rate_min = ua->rate; | ||
652 | substream->runtime->hw.rate_max = ua->rate; | ||
653 | substream->runtime->hw.channels_min = channels; | ||
654 | substream->runtime->hw.channels_max = channels; | ||
655 | substream->runtime->hw.buffer_bytes_max = 45000 * 1024; | ||
656 | substream->runtime->hw.period_bytes_min = 1; | ||
657 | substream->runtime->hw.period_bytes_max = UINT_MAX; | ||
658 | substream->runtime->hw.periods_min = 2; | ||
659 | substream->runtime->hw.periods_max = UINT_MAX; | ||
660 | err = snd_pcm_hw_constraint_minmax(substream->runtime, | ||
661 | SNDRV_PCM_HW_PARAM_PERIOD_TIME, | ||
662 | 1500000 / ua->packets_per_second, | ||
663 | 8192000); | ||
664 | if (err < 0) | ||
665 | return err; | ||
666 | err = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 32, 24); | ||
667 | return err; | ||
668 | } | ||
669 | |||
670 | static int capture_pcm_open(struct snd_pcm_substream *substream) | ||
671 | { | ||
672 | struct ua101 *ua = substream->private_data; | ||
673 | int err; | ||
674 | |||
675 | ua->capture.substream = substream; | ||
676 | err = set_stream_hw(ua, substream, ua->capture.channels); | ||
677 | if (err < 0) | ||
678 | return err; | ||
679 | substream->runtime->hw.fifo_size = | ||
680 | DIV_ROUND_CLOSEST(ua->rate, ua->packets_per_second); | ||
681 | substream->runtime->delay = substream->runtime->hw.fifo_size; | ||
682 | |||
683 | mutex_lock(&ua->mutex); | ||
684 | err = start_usb_capture(ua); | ||
685 | if (err >= 0) | ||
686 | set_bit(ALSA_CAPTURE_OPEN, &ua->states); | ||
687 | mutex_unlock(&ua->mutex); | ||
688 | return err; | ||
689 | } | ||
690 | |||
691 | static int playback_pcm_open(struct snd_pcm_substream *substream) | ||
692 | { | ||
693 | struct ua101 *ua = substream->private_data; | ||
694 | int err; | ||
695 | |||
696 | ua->playback.substream = substream; | ||
697 | err = set_stream_hw(ua, substream, ua->playback.channels); | ||
698 | if (err < 0) | ||
699 | return err; | ||
700 | substream->runtime->hw.fifo_size = | ||
701 | DIV_ROUND_CLOSEST(ua->rate * ua->playback.queue_length, | ||
702 | ua->packets_per_second); | ||
703 | |||
704 | mutex_lock(&ua->mutex); | ||
705 | err = start_usb_capture(ua); | ||
706 | if (err < 0) | ||
707 | goto error; | ||
708 | err = start_usb_playback(ua); | ||
709 | if (err < 0) { | ||
710 | if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) | ||
711 | stop_usb_capture(ua); | ||
712 | goto error; | ||
713 | } | ||
714 | set_bit(ALSA_PLAYBACK_OPEN, &ua->states); | ||
715 | error: | ||
716 | mutex_unlock(&ua->mutex); | ||
717 | return err; | ||
718 | } | ||
719 | |||
720 | static int capture_pcm_close(struct snd_pcm_substream *substream) | ||
721 | { | ||
722 | struct ua101 *ua = substream->private_data; | ||
723 | |||
724 | mutex_lock(&ua->mutex); | ||
725 | clear_bit(ALSA_CAPTURE_OPEN, &ua->states); | ||
726 | if (!test_bit(ALSA_PLAYBACK_OPEN, &ua->states)) | ||
727 | stop_usb_capture(ua); | ||
728 | mutex_unlock(&ua->mutex); | ||
729 | return 0; | ||
730 | } | ||
731 | |||
732 | static int playback_pcm_close(struct snd_pcm_substream *substream) | ||
733 | { | ||
734 | struct ua101 *ua = substream->private_data; | ||
735 | |||
736 | mutex_lock(&ua->mutex); | ||
737 | stop_usb_playback(ua); | ||
738 | clear_bit(ALSA_PLAYBACK_OPEN, &ua->states); | ||
739 | if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) | ||
740 | stop_usb_capture(ua); | ||
741 | mutex_unlock(&ua->mutex); | ||
742 | return 0; | ||
743 | } | ||
744 | |||
745 | static int capture_pcm_hw_params(struct snd_pcm_substream *substream, | ||
746 | struct snd_pcm_hw_params *hw_params) | ||
747 | { | ||
748 | struct ua101 *ua = substream->private_data; | ||
749 | int err; | ||
750 | |||
751 | mutex_lock(&ua->mutex); | ||
752 | err = start_usb_capture(ua); | ||
753 | mutex_unlock(&ua->mutex); | ||
754 | if (err < 0) | ||
755 | return err; | ||
756 | |||
757 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, | ||
758 | params_buffer_bytes(hw_params)); | ||
759 | } | ||
760 | |||
761 | static int playback_pcm_hw_params(struct snd_pcm_substream *substream, | ||
762 | struct snd_pcm_hw_params *hw_params) | ||
763 | { | ||
764 | struct ua101 *ua = substream->private_data; | ||
765 | int err; | ||
766 | |||
767 | mutex_lock(&ua->mutex); | ||
768 | err = start_usb_capture(ua); | ||
769 | if (err >= 0) | ||
770 | err = start_usb_playback(ua); | ||
771 | mutex_unlock(&ua->mutex); | ||
772 | if (err < 0) | ||
773 | return err; | ||
774 | |||
775 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, | ||
776 | params_buffer_bytes(hw_params)); | ||
777 | } | ||
778 | |||
779 | static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) | ||
780 | { | ||
781 | return snd_pcm_lib_free_vmalloc_buffer(substream); | ||
782 | } | ||
783 | |||
784 | static int capture_pcm_prepare(struct snd_pcm_substream *substream) | ||
785 | { | ||
786 | struct ua101 *ua = substream->private_data; | ||
787 | int err; | ||
788 | |||
789 | mutex_lock(&ua->mutex); | ||
790 | err = start_usb_capture(ua); | ||
791 | mutex_unlock(&ua->mutex); | ||
792 | if (err < 0) | ||
793 | return err; | ||
794 | |||
795 | /* | ||
796 | * The EHCI driver schedules the first packet of an iso stream at 10 ms | ||
797 | * in the future, i.e., no data is actually captured for that long. | ||
798 | * Take the wait here so that the stream is known to be actually | ||
799 | * running when the start trigger has been called. | ||
800 | */ | ||
801 | wait_event(ua->alsa_capture_wait, | ||
802 | test_bit(CAPTURE_URB_COMPLETED, &ua->states) || | ||
803 | !test_bit(USB_CAPTURE_RUNNING, &ua->states)); | ||
804 | if (test_bit(DISCONNECTED, &ua->states)) | ||
805 | return -ENODEV; | ||
806 | if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) | ||
807 | return -EIO; | ||
808 | |||
809 | ua->capture.period_pos = 0; | ||
810 | ua->capture.buffer_pos = 0; | ||
811 | return 0; | ||
812 | } | ||
813 | |||
814 | static int playback_pcm_prepare(struct snd_pcm_substream *substream) | ||
815 | { | ||
816 | struct ua101 *ua = substream->private_data; | ||
817 | int err; | ||
818 | |||
819 | mutex_lock(&ua->mutex); | ||
820 | err = start_usb_capture(ua); | ||
821 | if (err >= 0) | ||
822 | err = start_usb_playback(ua); | ||
823 | mutex_unlock(&ua->mutex); | ||
824 | if (err < 0) | ||
825 | return err; | ||
826 | |||
827 | /* see the comment in capture_pcm_prepare() */ | ||
828 | wait_event(ua->alsa_playback_wait, | ||
829 | test_bit(PLAYBACK_URB_COMPLETED, &ua->states) || | ||
830 | !test_bit(USB_PLAYBACK_RUNNING, &ua->states)); | ||
831 | if (test_bit(DISCONNECTED, &ua->states)) | ||
832 | return -ENODEV; | ||
833 | if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
834 | return -EIO; | ||
835 | |||
836 | substream->runtime->delay = 0; | ||
837 | ua->playback.period_pos = 0; | ||
838 | ua->playback.buffer_pos = 0; | ||
839 | return 0; | ||
840 | } | ||
841 | |||
842 | static int capture_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
843 | { | ||
844 | struct ua101 *ua = substream->private_data; | ||
845 | |||
846 | switch (cmd) { | ||
847 | case SNDRV_PCM_TRIGGER_START: | ||
848 | if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) | ||
849 | return -EIO; | ||
850 | set_bit(ALSA_CAPTURE_RUNNING, &ua->states); | ||
851 | return 0; | ||
852 | case SNDRV_PCM_TRIGGER_STOP: | ||
853 | clear_bit(ALSA_CAPTURE_RUNNING, &ua->states); | ||
854 | return 0; | ||
855 | default: | ||
856 | return -EINVAL; | ||
857 | } | ||
858 | } | ||
859 | |||
860 | static int playback_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
861 | { | ||
862 | struct ua101 *ua = substream->private_data; | ||
863 | |||
864 | switch (cmd) { | ||
865 | case SNDRV_PCM_TRIGGER_START: | ||
866 | if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
867 | return -EIO; | ||
868 | set_bit(ALSA_PLAYBACK_RUNNING, &ua->states); | ||
869 | return 0; | ||
870 | case SNDRV_PCM_TRIGGER_STOP: | ||
871 | clear_bit(ALSA_PLAYBACK_RUNNING, &ua->states); | ||
872 | return 0; | ||
873 | default: | ||
874 | return -EINVAL; | ||
875 | } | ||
876 | } | ||
877 | |||
878 | static inline snd_pcm_uframes_t ua101_pcm_pointer(struct ua101 *ua, | ||
879 | struct ua101_stream *stream) | ||
880 | { | ||
881 | unsigned long flags; | ||
882 | unsigned int pos; | ||
883 | |||
884 | spin_lock_irqsave(&ua->lock, flags); | ||
885 | pos = stream->buffer_pos; | ||
886 | spin_unlock_irqrestore(&ua->lock, flags); | ||
887 | return pos; | ||
888 | } | ||
889 | |||
890 | static snd_pcm_uframes_t capture_pcm_pointer(struct snd_pcm_substream *subs) | ||
891 | { | ||
892 | struct ua101 *ua = subs->private_data; | ||
893 | |||
894 | return ua101_pcm_pointer(ua, &ua->capture); | ||
895 | } | ||
896 | |||
897 | static snd_pcm_uframes_t playback_pcm_pointer(struct snd_pcm_substream *subs) | ||
898 | { | ||
899 | struct ua101 *ua = subs->private_data; | ||
900 | |||
901 | return ua101_pcm_pointer(ua, &ua->playback); | ||
902 | } | ||
903 | |||
904 | static struct snd_pcm_ops capture_pcm_ops = { | ||
905 | .open = capture_pcm_open, | ||
906 | .close = capture_pcm_close, | ||
907 | .ioctl = snd_pcm_lib_ioctl, | ||
908 | .hw_params = capture_pcm_hw_params, | ||
909 | .hw_free = ua101_pcm_hw_free, | ||
910 | .prepare = capture_pcm_prepare, | ||
911 | .trigger = capture_pcm_trigger, | ||
912 | .pointer = capture_pcm_pointer, | ||
913 | .page = snd_pcm_lib_get_vmalloc_page, | ||
914 | }; | ||
915 | |||
916 | static struct snd_pcm_ops playback_pcm_ops = { | ||
917 | .open = playback_pcm_open, | ||
918 | .close = playback_pcm_close, | ||
919 | .ioctl = snd_pcm_lib_ioctl, | ||
920 | .hw_params = playback_pcm_hw_params, | ||
921 | .hw_free = ua101_pcm_hw_free, | ||
922 | .prepare = playback_pcm_prepare, | ||
923 | .trigger = playback_pcm_trigger, | ||
924 | .pointer = playback_pcm_pointer, | ||
925 | .page = snd_pcm_lib_get_vmalloc_page, | ||
926 | }; | ||
927 | |||
928 | static const struct uac_format_type_i_discrete_descriptor * | ||
929 | find_format_descriptor(struct usb_interface *interface) | ||
930 | { | ||
931 | struct usb_host_interface *alt; | ||
932 | u8 *extra; | ||
933 | int extralen; | ||
934 | |||
935 | if (interface->num_altsetting != 2) { | ||
936 | dev_err(&interface->dev, "invalid num_altsetting\n"); | ||
937 | return NULL; | ||
938 | } | ||
939 | |||
940 | alt = &interface->altsetting[0]; | ||
941 | if (alt->desc.bNumEndpoints != 0) { | ||
942 | dev_err(&interface->dev, "invalid bNumEndpoints\n"); | ||
943 | return NULL; | ||
944 | } | ||
945 | |||
946 | alt = &interface->altsetting[1]; | ||
947 | if (alt->desc.bNumEndpoints != 1) { | ||
948 | dev_err(&interface->dev, "invalid bNumEndpoints\n"); | ||
949 | return NULL; | ||
950 | } | ||
951 | |||
952 | extra = alt->extra; | ||
953 | extralen = alt->extralen; | ||
954 | while (extralen >= sizeof(struct usb_descriptor_header)) { | ||
955 | struct uac_format_type_i_discrete_descriptor *desc; | ||
956 | |||
957 | desc = (struct uac_format_type_i_discrete_descriptor *)extra; | ||
958 | if (desc->bLength > extralen) { | ||
959 | dev_err(&interface->dev, "descriptor overflow\n"); | ||
960 | return NULL; | ||
961 | } | ||
962 | if (desc->bLength == UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1) && | ||
963 | desc->bDescriptorType == USB_DT_CS_INTERFACE && | ||
964 | desc->bDescriptorSubtype == UAC_FORMAT_TYPE) { | ||
965 | if (desc->bFormatType != UAC_FORMAT_TYPE_I_PCM || | ||
966 | desc->bSamFreqType != 1) { | ||
967 | dev_err(&interface->dev, | ||
968 | "invalid format type\n"); | ||
969 | return NULL; | ||
970 | } | ||
971 | return desc; | ||
972 | } | ||
973 | extralen -= desc->bLength; | ||
974 | extra += desc->bLength; | ||
975 | } | ||
976 | dev_err(&interface->dev, "sample format descriptor not found\n"); | ||
977 | return NULL; | ||
978 | } | ||
979 | |||
980 | static int detect_usb_format(struct ua101 *ua) | ||
981 | { | ||
982 | const struct uac_format_type_i_discrete_descriptor *fmt_capture; | ||
983 | const struct uac_format_type_i_discrete_descriptor *fmt_playback; | ||
984 | const struct usb_endpoint_descriptor *epd; | ||
985 | unsigned int rate2; | ||
986 | |||
987 | fmt_capture = find_format_descriptor(ua->intf[INTF_CAPTURE]); | ||
988 | fmt_playback = find_format_descriptor(ua->intf[INTF_PLAYBACK]); | ||
989 | if (!fmt_capture || !fmt_playback) | ||
990 | return -ENXIO; | ||
991 | |||
992 | switch (fmt_capture->bSubframeSize) { | ||
993 | case 3: | ||
994 | ua->format_bit = SNDRV_PCM_FMTBIT_S24_3LE; | ||
995 | break; | ||
996 | case 4: | ||
997 | ua->format_bit = SNDRV_PCM_FMTBIT_S32_LE; | ||
998 | break; | ||
999 | default: | ||
1000 | dev_err(&ua->dev->dev, "sample width is not 24 or 32 bits\n"); | ||
1001 | return -ENXIO; | ||
1002 | } | ||
1003 | if (fmt_capture->bSubframeSize != fmt_playback->bSubframeSize) { | ||
1004 | dev_err(&ua->dev->dev, | ||
1005 | "playback/capture sample widths do not match\n"); | ||
1006 | return -ENXIO; | ||
1007 | } | ||
1008 | |||
1009 | if (fmt_capture->bBitResolution != 24 || | ||
1010 | fmt_playback->bBitResolution != 24) { | ||
1011 | dev_err(&ua->dev->dev, "sample width is not 24 bits\n"); | ||
1012 | return -ENXIO; | ||
1013 | } | ||
1014 | |||
1015 | ua->rate = combine_triple(fmt_capture->tSamFreq[0]); | ||
1016 | rate2 = combine_triple(fmt_playback->tSamFreq[0]); | ||
1017 | if (ua->rate != rate2) { | ||
1018 | dev_err(&ua->dev->dev, | ||
1019 | "playback/capture rates do not match: %u/%u\n", | ||
1020 | rate2, ua->rate); | ||
1021 | return -ENXIO; | ||
1022 | } | ||
1023 | |||
1024 | switch (ua->dev->speed) { | ||
1025 | case USB_SPEED_FULL: | ||
1026 | ua->packets_per_second = 1000; | ||
1027 | break; | ||
1028 | case USB_SPEED_HIGH: | ||
1029 | ua->packets_per_second = 8000; | ||
1030 | break; | ||
1031 | default: | ||
1032 | dev_err(&ua->dev->dev, "unknown device speed\n"); | ||
1033 | return -ENXIO; | ||
1034 | } | ||
1035 | |||
1036 | ua->capture.channels = fmt_capture->bNrChannels; | ||
1037 | ua->playback.channels = fmt_playback->bNrChannels; | ||
1038 | ua->capture.frame_bytes = | ||
1039 | fmt_capture->bSubframeSize * ua->capture.channels; | ||
1040 | ua->playback.frame_bytes = | ||
1041 | fmt_playback->bSubframeSize * ua->playback.channels; | ||
1042 | |||
1043 | epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc; | ||
1044 | if (!usb_endpoint_is_isoc_in(epd)) { | ||
1045 | dev_err(&ua->dev->dev, "invalid capture endpoint\n"); | ||
1046 | return -ENXIO; | ||
1047 | } | ||
1048 | ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, usb_endpoint_num(epd)); | ||
1049 | ua->capture.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize); | ||
1050 | |||
1051 | epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc; | ||
1052 | if (!usb_endpoint_is_isoc_out(epd)) { | ||
1053 | dev_err(&ua->dev->dev, "invalid playback endpoint\n"); | ||
1054 | return -ENXIO; | ||
1055 | } | ||
1056 | ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd)); | ||
1057 | ua->playback.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize); | ||
1058 | return 0; | ||
1059 | } | ||
1060 | |||
1061 | static int alloc_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) | ||
1062 | { | ||
1063 | unsigned int remaining_packets, packets, packets_per_page, i; | ||
1064 | size_t size; | ||
1065 | |||
1066 | stream->queue_length = queue_length; | ||
1067 | stream->queue_length = max(stream->queue_length, | ||
1068 | (unsigned int)MIN_QUEUE_LENGTH); | ||
1069 | stream->queue_length = min(stream->queue_length, | ||
1070 | (unsigned int)MAX_QUEUE_LENGTH); | ||
1071 | |||
1072 | /* | ||
1073 | * The cache pool sizes used by usb_buffer_alloc() (128, 512, 2048) are | ||
1074 | * quite bad when used with the packet sizes of this device (e.g. 280, | ||
1075 | * 520, 624). Therefore, we allocate and subdivide entire pages, using | ||
1076 | * a smaller buffer only for the last chunk. | ||
1077 | */ | ||
1078 | remaining_packets = stream->queue_length; | ||
1079 | packets_per_page = PAGE_SIZE / stream->max_packet_bytes; | ||
1080 | for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) { | ||
1081 | packets = min(remaining_packets, packets_per_page); | ||
1082 | size = packets * stream->max_packet_bytes; | ||
1083 | stream->buffers[i].addr = | ||
1084 | usb_buffer_alloc(ua->dev, size, GFP_KERNEL, | ||
1085 | &stream->buffers[i].dma); | ||
1086 | if (!stream->buffers[i].addr) | ||
1087 | return -ENOMEM; | ||
1088 | stream->buffers[i].size = size; | ||
1089 | remaining_packets -= packets; | ||
1090 | if (!remaining_packets) | ||
1091 | break; | ||
1092 | } | ||
1093 | if (remaining_packets) { | ||
1094 | dev_err(&ua->dev->dev, "too many packets\n"); | ||
1095 | return -ENXIO; | ||
1096 | } | ||
1097 | return 0; | ||
1098 | } | ||
1099 | |||
1100 | static void free_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) | ||
1101 | { | ||
1102 | unsigned int i; | ||
1103 | |||
1104 | for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) | ||
1105 | usb_buffer_free(ua->dev, | ||
1106 | stream->buffers[i].size, | ||
1107 | stream->buffers[i].addr, | ||
1108 | stream->buffers[i].dma); | ||
1109 | } | ||
1110 | |||
1111 | static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream, | ||
1112 | void (*urb_complete)(struct urb *)) | ||
1113 | { | ||
1114 | unsigned max_packet_size = stream->max_packet_bytes; | ||
1115 | struct ua101_urb *urb; | ||
1116 | unsigned int b, u = 0; | ||
1117 | |||
1118 | for (b = 0; b < ARRAY_SIZE(stream->buffers); ++b) { | ||
1119 | unsigned int size = stream->buffers[b].size; | ||
1120 | u8 *addr = stream->buffers[b].addr; | ||
1121 | dma_addr_t dma = stream->buffers[b].dma; | ||
1122 | |||
1123 | while (size >= max_packet_size) { | ||
1124 | if (u >= stream->queue_length) | ||
1125 | goto bufsize_error; | ||
1126 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); | ||
1127 | if (!urb) | ||
1128 | return -ENOMEM; | ||
1129 | usb_init_urb(&urb->urb); | ||
1130 | urb->urb.dev = ua->dev; | ||
1131 | urb->urb.pipe = stream->usb_pipe; | ||
1132 | urb->urb.transfer_flags = URB_ISO_ASAP | | ||
1133 | URB_NO_TRANSFER_DMA_MAP; | ||
1134 | urb->urb.transfer_buffer = addr; | ||
1135 | urb->urb.transfer_dma = dma; | ||
1136 | urb->urb.transfer_buffer_length = max_packet_size; | ||
1137 | urb->urb.number_of_packets = 1; | ||
1138 | urb->urb.interval = 1; | ||
1139 | urb->urb.context = ua; | ||
1140 | urb->urb.complete = urb_complete; | ||
1141 | urb->urb.iso_frame_desc[0].offset = 0; | ||
1142 | urb->urb.iso_frame_desc[0].length = max_packet_size; | ||
1143 | stream->urbs[u++] = urb; | ||
1144 | size -= max_packet_size; | ||
1145 | addr += max_packet_size; | ||
1146 | dma += max_packet_size; | ||
1147 | } | ||
1148 | } | ||
1149 | if (u == stream->queue_length) | ||
1150 | return 0; | ||
1151 | bufsize_error: | ||
1152 | dev_err(&ua->dev->dev, "internal buffer size error\n"); | ||
1153 | return -ENXIO; | ||
1154 | } | ||
1155 | |||
1156 | static void free_stream_urbs(struct ua101_stream *stream) | ||
1157 | { | ||
1158 | unsigned int i; | ||
1159 | |||
1160 | for (i = 0; i < stream->queue_length; ++i) | ||
1161 | kfree(stream->urbs[i]); | ||
1162 | } | ||
1163 | |||
1164 | static void free_usb_related_resources(struct ua101 *ua, | ||
1165 | struct usb_interface *interface) | ||
1166 | { | ||
1167 | unsigned int i; | ||
1168 | |||
1169 | free_stream_urbs(&ua->capture); | ||
1170 | free_stream_urbs(&ua->playback); | ||
1171 | free_stream_buffers(ua, &ua->capture); | ||
1172 | free_stream_buffers(ua, &ua->playback); | ||
1173 | |||
1174 | for (i = 0; i < ARRAY_SIZE(ua->intf); ++i) | ||
1175 | if (ua->intf[i]) { | ||
1176 | usb_set_intfdata(ua->intf[i], NULL); | ||
1177 | if (ua->intf[i] != interface) | ||
1178 | usb_driver_release_interface(&ua101_driver, | ||
1179 | ua->intf[i]); | ||
1180 | } | ||
1181 | } | ||
1182 | |||
1183 | static void ua101_card_free(struct snd_card *card) | ||
1184 | { | ||
1185 | struct ua101 *ua = card->private_data; | ||
1186 | |||
1187 | mutex_destroy(&ua->mutex); | ||
1188 | } | ||
1189 | |||
1190 | static int ua101_probe(struct usb_interface *interface, | ||
1191 | const struct usb_device_id *usb_id) | ||
1192 | { | ||
1193 | static const struct snd_usb_midi_endpoint_info midi_ep = { | ||
1194 | .out_cables = 0x0001, | ||
1195 | .in_cables = 0x0001 | ||
1196 | }; | ||
1197 | static const struct snd_usb_audio_quirk midi_quirk = { | ||
1198 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
1199 | .data = &midi_ep | ||
1200 | }; | ||
1201 | struct snd_card *card; | ||
1202 | struct ua101 *ua; | ||
1203 | unsigned int card_index, i; | ||
1204 | char usb_path[32]; | ||
1205 | int err; | ||
1206 | |||
1207 | if (interface->altsetting->desc.bInterfaceNumber != 0) | ||
1208 | return -ENODEV; | ||
1209 | |||
1210 | mutex_lock(&devices_mutex); | ||
1211 | |||
1212 | for (card_index = 0; card_index < SNDRV_CARDS; ++card_index) | ||
1213 | if (enable[card_index] && !(devices_used & (1 << card_index))) | ||
1214 | break; | ||
1215 | if (card_index >= SNDRV_CARDS) { | ||
1216 | mutex_unlock(&devices_mutex); | ||
1217 | return -ENOENT; | ||
1218 | } | ||
1219 | err = snd_card_create(index[card_index], id[card_index], THIS_MODULE, | ||
1220 | sizeof(*ua), &card); | ||
1221 | if (err < 0) { | ||
1222 | mutex_unlock(&devices_mutex); | ||
1223 | return err; | ||
1224 | } | ||
1225 | card->private_free = ua101_card_free; | ||
1226 | ua = card->private_data; | ||
1227 | ua->dev = interface_to_usbdev(interface); | ||
1228 | ua->card = card; | ||
1229 | ua->card_index = card_index; | ||
1230 | INIT_LIST_HEAD(&ua->midi_list); | ||
1231 | spin_lock_init(&ua->lock); | ||
1232 | mutex_init(&ua->mutex); | ||
1233 | INIT_LIST_HEAD(&ua->ready_playback_urbs); | ||
1234 | tasklet_init(&ua->playback_tasklet, | ||
1235 | playback_tasklet, (unsigned long)ua); | ||
1236 | init_waitqueue_head(&ua->alsa_capture_wait); | ||
1237 | init_waitqueue_head(&ua->rate_feedback_wait); | ||
1238 | init_waitqueue_head(&ua->alsa_playback_wait); | ||
1239 | |||
1240 | #ifdef UA1A_HACK | ||
1241 | if (ua->dev->descriptor.idProduct == cpu_to_le16(0x0018)) { | ||
1242 | ua->intf[2] = interface; | ||
1243 | ua->intf[0] = usb_ifnum_to_if(ua->dev, 1); | ||
1244 | ua->intf[1] = usb_ifnum_to_if(ua->dev, 2); | ||
1245 | usb_driver_claim_interface(&ua101_driver, ua->intf[0], ua); | ||
1246 | usb_driver_claim_interface(&ua101_driver, ua->intf[1], ua); | ||
1247 | } else { | ||
1248 | #endif | ||
1249 | ua->intf[0] = interface; | ||
1250 | for (i = 1; i < ARRAY_SIZE(ua->intf); ++i) { | ||
1251 | ua->intf[i] = usb_ifnum_to_if(ua->dev, i); | ||
1252 | if (!ua->intf[i]) { | ||
1253 | dev_err(&ua->dev->dev, "interface %u not found\n", i); | ||
1254 | err = -ENXIO; | ||
1255 | goto probe_error; | ||
1256 | } | ||
1257 | err = usb_driver_claim_interface(&ua101_driver, | ||
1258 | ua->intf[i], ua); | ||
1259 | if (err < 0) { | ||
1260 | ua->intf[i] = NULL; | ||
1261 | err = -EBUSY; | ||
1262 | goto probe_error; | ||
1263 | } | ||
1264 | } | ||
1265 | #ifdef UA1A_HACK | ||
1266 | } | ||
1267 | #endif | ||
1268 | |||
1269 | snd_card_set_dev(card, &interface->dev); | ||
1270 | |||
1271 | #ifdef UA1A_HACK | ||
1272 | if (ua->dev->descriptor.idProduct == cpu_to_le16(0x0018)) { | ||
1273 | ua->format_bit = SNDRV_PCM_FMTBIT_S16_LE; | ||
1274 | ua->rate = 44100; | ||
1275 | ua->packets_per_second = 1000; | ||
1276 | ua->capture.channels = 2; | ||
1277 | ua->playback.channels = 2; | ||
1278 | ua->capture.frame_bytes = 4; | ||
1279 | ua->playback.frame_bytes = 4; | ||
1280 | ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, 2); | ||
1281 | ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, 1); | ||
1282 | ua->capture.max_packet_bytes = 192; | ||
1283 | ua->playback.max_packet_bytes = 192; | ||
1284 | } else { | ||
1285 | #endif | ||
1286 | err = detect_usb_format(ua); | ||
1287 | if (err < 0) | ||
1288 | goto probe_error; | ||
1289 | #ifdef UA1A_HACK | ||
1290 | } | ||
1291 | #endif | ||
1292 | |||
1293 | strcpy(card->driver, "UA-101"); | ||
1294 | strcpy(card->shortname, "UA-101"); | ||
1295 | usb_make_path(ua->dev, usb_path, sizeof(usb_path)); | ||
1296 | snprintf(ua->card->longname, sizeof(ua->card->longname), | ||
1297 | "EDIROL UA-101 (serial %s), %u Hz at %s, %s speed", | ||
1298 | ua->dev->serial ? ua->dev->serial : "?", ua->rate, usb_path, | ||
1299 | ua->dev->speed == USB_SPEED_HIGH ? "high" : "full"); | ||
1300 | |||
1301 | err = alloc_stream_buffers(ua, &ua->capture); | ||
1302 | if (err < 0) | ||
1303 | goto probe_error; | ||
1304 | err = alloc_stream_buffers(ua, &ua->playback); | ||
1305 | if (err < 0) | ||
1306 | goto probe_error; | ||
1307 | |||
1308 | err = alloc_stream_urbs(ua, &ua->capture, capture_urb_complete); | ||
1309 | if (err < 0) | ||
1310 | goto probe_error; | ||
1311 | err = alloc_stream_urbs(ua, &ua->playback, playback_urb_complete); | ||
1312 | if (err < 0) | ||
1313 | goto probe_error; | ||
1314 | |||
1315 | err = snd_pcm_new(card, "UA-101", 0, 1, 1, &ua->pcm); | ||
1316 | if (err < 0) | ||
1317 | goto probe_error; | ||
1318 | ua->pcm->private_data = ua; | ||
1319 | strcpy(ua->pcm->name, "UA-101"); | ||
1320 | snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); | ||
1321 | snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); | ||
1322 | |||
1323 | #ifdef UA1A_HACK | ||
1324 | if (ua->dev->descriptor.idProduct != cpu_to_le16(0x0018)) { | ||
1325 | #endif | ||
1326 | err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], | ||
1327 | &ua->midi_list, &midi_quirk); | ||
1328 | if (err < 0) | ||
1329 | goto probe_error; | ||
1330 | #ifdef UA1A_HACK | ||
1331 | } | ||
1332 | #endif | ||
1333 | |||
1334 | err = snd_card_register(card); | ||
1335 | if (err < 0) | ||
1336 | goto probe_error; | ||
1337 | |||
1338 | usb_set_intfdata(interface, ua); | ||
1339 | devices_used |= 1 << card_index; | ||
1340 | |||
1341 | mutex_unlock(&devices_mutex); | ||
1342 | return 0; | ||
1343 | |||
1344 | probe_error: | ||
1345 | free_usb_related_resources(ua, interface); | ||
1346 | snd_card_free(card); | ||
1347 | mutex_unlock(&devices_mutex); | ||
1348 | return err; | ||
1349 | } | ||
1350 | |||
1351 | static void ua101_disconnect(struct usb_interface *interface) | ||
1352 | { | ||
1353 | struct ua101 *ua = usb_get_intfdata(interface); | ||
1354 | struct list_head *midi; | ||
1355 | |||
1356 | if (!ua) | ||
1357 | return; | ||
1358 | |||
1359 | mutex_lock(&devices_mutex); | ||
1360 | |||
1361 | set_bit(DISCONNECTED, &ua->states); | ||
1362 | wake_up(&ua->rate_feedback_wait); | ||
1363 | |||
1364 | /* make sure that userspace cannot create new requests */ | ||
1365 | snd_card_disconnect(ua->card); | ||
1366 | |||
1367 | /* make sure that there are no pending USB requests */ | ||
1368 | __list_for_each(midi, &ua->midi_list) | ||
1369 | snd_usbmidi_disconnect(midi); | ||
1370 | abort_alsa_playback(ua); | ||
1371 | abort_alsa_capture(ua); | ||
1372 | mutex_lock(&ua->mutex); | ||
1373 | stop_usb_playback(ua); | ||
1374 | stop_usb_capture(ua); | ||
1375 | mutex_unlock(&ua->mutex); | ||
1376 | |||
1377 | free_usb_related_resources(ua, interface); | ||
1378 | |||
1379 | devices_used &= ~(1 << ua->card_index); | ||
1380 | |||
1381 | snd_card_free_when_closed(ua->card); | ||
1382 | |||
1383 | mutex_unlock(&devices_mutex); | ||
1384 | } | ||
1385 | |||
1386 | static struct usb_device_id ua101_ids[] = { | ||
1387 | #ifdef UA1A_HACK | ||
1388 | { USB_DEVICE(0x0582, 0x0018) }, | ||
1389 | #endif | ||
1390 | { USB_DEVICE(0x0582, 0x007d) }, | ||
1391 | { USB_DEVICE(0x0582, 0x008d) }, | ||
1392 | { } | ||
1393 | }; | ||
1394 | MODULE_DEVICE_TABLE(usb, ua101_ids); | ||
1395 | |||
1396 | static struct usb_driver ua101_driver = { | ||
1397 | .name = "snd-ua101", | ||
1398 | .id_table = ua101_ids, | ||
1399 | .probe = ua101_probe, | ||
1400 | .disconnect = ua101_disconnect, | ||
1401 | #if 0 | ||
1402 | .suspend = ua101_suspend, | ||
1403 | .resume = ua101_resume, | ||
1404 | #endif | ||
1405 | }; | ||
1406 | |||
1407 | static int __init alsa_card_ua101_init(void) | ||
1408 | { | ||
1409 | return usb_register(&ua101_driver); | ||
1410 | } | ||
1411 | |||
1412 | static void __exit alsa_card_ua101_exit(void) | ||
1413 | { | ||
1414 | usb_deregister(&ua101_driver); | ||
1415 | mutex_destroy(&devices_mutex); | ||
1416 | } | ||
1417 | |||
1418 | module_init(alsa_card_ua101_init); | ||
1419 | module_exit(alsa_card_ua101_exit); | ||
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index b074a594c595..4ada98e16309 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/string.h> | 45 | #include <linux/string.h> |
46 | #include <linux/usb.h> | 46 | #include <linux/usb.h> |
47 | #include <linux/vmalloc.h> | ||
48 | #include <linux/moduleparam.h> | 47 | #include <linux/moduleparam.h> |
49 | #include <linux/mutex.h> | 48 | #include <linux/mutex.h> |
50 | #include <sound/core.h> | 49 | #include <sound/core.h> |
@@ -170,11 +169,12 @@ struct snd_usb_substream { | |||
170 | unsigned int curpacksize; /* current packet size in bytes (for capture) */ | 169 | unsigned int curpacksize; /* current packet size in bytes (for capture) */ |
171 | unsigned int curframesize; /* current packet size in frames (for capture) */ | 170 | unsigned int curframesize; /* current packet size in frames (for capture) */ |
172 | unsigned int fill_max: 1; /* fill max packet size always */ | 171 | unsigned int fill_max: 1; /* fill max packet size always */ |
172 | unsigned int txfr_quirk:1; /* allow sub-frame alignment */ | ||
173 | unsigned int fmt_type; /* USB audio format type (1-3) */ | 173 | unsigned int fmt_type; /* USB audio format type (1-3) */ |
174 | 174 | ||
175 | unsigned int running: 1; /* running status */ | 175 | unsigned int running: 1; /* running status */ |
176 | 176 | ||
177 | unsigned int hwptr_done; /* processed frame position in the buffer */ | 177 | unsigned int hwptr_done; /* processed byte position in the buffer */ |
178 | unsigned int transfer_done; /* processed frames since last period update */ | 178 | unsigned int transfer_done; /* processed frames since last period update */ |
179 | unsigned long active_mask; /* bitmask of active urbs */ | 179 | unsigned long active_mask; /* bitmask of active urbs */ |
180 | unsigned long unlink_mask; /* bitmask of unlinked urbs */ | 180 | unsigned long unlink_mask; /* bitmask of unlinked urbs */ |
@@ -343,7 +343,7 @@ static int retire_capture_urb(struct snd_usb_substream *subs, | |||
343 | unsigned long flags; | 343 | unsigned long flags; |
344 | unsigned char *cp; | 344 | unsigned char *cp; |
345 | int i; | 345 | int i; |
346 | unsigned int stride, len, oldptr; | 346 | unsigned int stride, frames, bytes, oldptr; |
347 | int period_elapsed = 0; | 347 | int period_elapsed = 0; |
348 | 348 | ||
349 | stride = runtime->frame_bits >> 3; | 349 | stride = runtime->frame_bits >> 3; |
@@ -354,29 +354,39 @@ static int retire_capture_urb(struct snd_usb_substream *subs, | |||
354 | snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); | 354 | snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); |
355 | // continue; | 355 | // continue; |
356 | } | 356 | } |
357 | len = urb->iso_frame_desc[i].actual_length / stride; | 357 | bytes = urb->iso_frame_desc[i].actual_length; |
358 | if (! len) | 358 | frames = bytes / stride; |
359 | continue; | 359 | if (!subs->txfr_quirk) |
360 | bytes = frames * stride; | ||
361 | if (bytes % (runtime->sample_bits >> 3) != 0) { | ||
362 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
363 | int oldbytes = bytes; | ||
364 | #endif | ||
365 | bytes = frames * stride; | ||
366 | snd_printdd(KERN_ERR "Corrected urb data len. %d->%d\n", | ||
367 | oldbytes, bytes); | ||
368 | } | ||
360 | /* update the current pointer */ | 369 | /* update the current pointer */ |
361 | spin_lock_irqsave(&subs->lock, flags); | 370 | spin_lock_irqsave(&subs->lock, flags); |
362 | oldptr = subs->hwptr_done; | 371 | oldptr = subs->hwptr_done; |
363 | subs->hwptr_done += len; | 372 | subs->hwptr_done += bytes; |
364 | if (subs->hwptr_done >= runtime->buffer_size) | 373 | if (subs->hwptr_done >= runtime->buffer_size * stride) |
365 | subs->hwptr_done -= runtime->buffer_size; | 374 | subs->hwptr_done -= runtime->buffer_size * stride; |
366 | subs->transfer_done += len; | 375 | frames = (bytes + (oldptr % stride)) / stride; |
376 | subs->transfer_done += frames; | ||
367 | if (subs->transfer_done >= runtime->period_size) { | 377 | if (subs->transfer_done >= runtime->period_size) { |
368 | subs->transfer_done -= runtime->period_size; | 378 | subs->transfer_done -= runtime->period_size; |
369 | period_elapsed = 1; | 379 | period_elapsed = 1; |
370 | } | 380 | } |
371 | spin_unlock_irqrestore(&subs->lock, flags); | 381 | spin_unlock_irqrestore(&subs->lock, flags); |
372 | /* copy a data chunk */ | 382 | /* copy a data chunk */ |
373 | if (oldptr + len > runtime->buffer_size) { | 383 | if (oldptr + bytes > runtime->buffer_size * stride) { |
374 | unsigned int cnt = runtime->buffer_size - oldptr; | 384 | unsigned int bytes1 = |
375 | unsigned int blen = cnt * stride; | 385 | runtime->buffer_size * stride - oldptr; |
376 | memcpy(runtime->dma_area + oldptr * stride, cp, blen); | 386 | memcpy(runtime->dma_area + oldptr, cp, bytes1); |
377 | memcpy(runtime->dma_area, cp + blen, len * stride - blen); | 387 | memcpy(runtime->dma_area, cp + bytes1, bytes - bytes1); |
378 | } else { | 388 | } else { |
379 | memcpy(runtime->dma_area + oldptr * stride, cp, len * stride); | 389 | memcpy(runtime->dma_area + oldptr, cp, bytes); |
380 | } | 390 | } |
381 | } | 391 | } |
382 | if (period_elapsed) | 392 | if (period_elapsed) |
@@ -563,24 +573,24 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
563 | struct snd_pcm_runtime *runtime, | 573 | struct snd_pcm_runtime *runtime, |
564 | struct urb *urb) | 574 | struct urb *urb) |
565 | { | 575 | { |
566 | int i, stride, offs; | 576 | int i, stride; |
567 | unsigned int counts; | 577 | unsigned int counts, frames, bytes; |
568 | unsigned long flags; | 578 | unsigned long flags; |
569 | int period_elapsed = 0; | 579 | int period_elapsed = 0; |
570 | struct snd_urb_ctx *ctx = urb->context; | 580 | struct snd_urb_ctx *ctx = urb->context; |
571 | 581 | ||
572 | stride = runtime->frame_bits >> 3; | 582 | stride = runtime->frame_bits >> 3; |
573 | 583 | ||
574 | offs = 0; | 584 | frames = 0; |
575 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ | 585 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ |
576 | urb->number_of_packets = 0; | 586 | urb->number_of_packets = 0; |
577 | spin_lock_irqsave(&subs->lock, flags); | 587 | spin_lock_irqsave(&subs->lock, flags); |
578 | for (i = 0; i < ctx->packets; i++) { | 588 | for (i = 0; i < ctx->packets; i++) { |
579 | counts = snd_usb_audio_next_packet_size(subs); | 589 | counts = snd_usb_audio_next_packet_size(subs); |
580 | /* set up descriptor */ | 590 | /* set up descriptor */ |
581 | urb->iso_frame_desc[i].offset = offs * stride; | 591 | urb->iso_frame_desc[i].offset = frames * stride; |
582 | urb->iso_frame_desc[i].length = counts * stride; | 592 | urb->iso_frame_desc[i].length = counts * stride; |
583 | offs += counts; | 593 | frames += counts; |
584 | urb->number_of_packets++; | 594 | urb->number_of_packets++; |
585 | subs->transfer_done += counts; | 595 | subs->transfer_done += counts; |
586 | if (subs->transfer_done >= runtime->period_size) { | 596 | if (subs->transfer_done >= runtime->period_size) { |
@@ -590,7 +600,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
590 | if (subs->transfer_done > 0) { | 600 | if (subs->transfer_done > 0) { |
591 | /* FIXME: fill-max mode is not | 601 | /* FIXME: fill-max mode is not |
592 | * supported yet */ | 602 | * supported yet */ |
593 | offs -= subs->transfer_done; | 603 | frames -= subs->transfer_done; |
594 | counts -= subs->transfer_done; | 604 | counts -= subs->transfer_done; |
595 | urb->iso_frame_desc[i].length = | 605 | urb->iso_frame_desc[i].length = |
596 | counts * stride; | 606 | counts * stride; |
@@ -600,7 +610,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
600 | if (i < ctx->packets) { | 610 | if (i < ctx->packets) { |
601 | /* add a transfer delimiter */ | 611 | /* add a transfer delimiter */ |
602 | urb->iso_frame_desc[i].offset = | 612 | urb->iso_frame_desc[i].offset = |
603 | offs * stride; | 613 | frames * stride; |
604 | urb->iso_frame_desc[i].length = 0; | 614 | urb->iso_frame_desc[i].length = 0; |
605 | urb->number_of_packets++; | 615 | urb->number_of_packets++; |
606 | } | 616 | } |
@@ -610,26 +620,25 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
610 | if (period_elapsed) /* finish at the period boundary */ | 620 | if (period_elapsed) /* finish at the period boundary */ |
611 | break; | 621 | break; |
612 | } | 622 | } |
613 | if (subs->hwptr_done + offs > runtime->buffer_size) { | 623 | bytes = frames * stride; |
624 | if (subs->hwptr_done + bytes > runtime->buffer_size * stride) { | ||
614 | /* err, the transferred area goes over buffer boundary. */ | 625 | /* err, the transferred area goes over buffer boundary. */ |
615 | unsigned int len = runtime->buffer_size - subs->hwptr_done; | 626 | unsigned int bytes1 = |
627 | runtime->buffer_size * stride - subs->hwptr_done; | ||
616 | memcpy(urb->transfer_buffer, | 628 | memcpy(urb->transfer_buffer, |
617 | runtime->dma_area + subs->hwptr_done * stride, | 629 | runtime->dma_area + subs->hwptr_done, bytes1); |
618 | len * stride); | 630 | memcpy(urb->transfer_buffer + bytes1, |
619 | memcpy(urb->transfer_buffer + len * stride, | 631 | runtime->dma_area, bytes - bytes1); |
620 | runtime->dma_area, | ||
621 | (offs - len) * stride); | ||
622 | } else { | 632 | } else { |
623 | memcpy(urb->transfer_buffer, | 633 | memcpy(urb->transfer_buffer, |
624 | runtime->dma_area + subs->hwptr_done * stride, | 634 | runtime->dma_area + subs->hwptr_done, bytes); |
625 | offs * stride); | ||
626 | } | 635 | } |
627 | subs->hwptr_done += offs; | 636 | subs->hwptr_done += bytes; |
628 | if (subs->hwptr_done >= runtime->buffer_size) | 637 | if (subs->hwptr_done >= runtime->buffer_size * stride) |
629 | subs->hwptr_done -= runtime->buffer_size; | 638 | subs->hwptr_done -= runtime->buffer_size * stride; |
630 | runtime->delay += offs; | 639 | runtime->delay += frames; |
631 | spin_unlock_irqrestore(&subs->lock, flags); | 640 | spin_unlock_irqrestore(&subs->lock, flags); |
632 | urb->transfer_buffer_length = offs * stride; | 641 | urb->transfer_buffer_length = bytes; |
633 | if (period_elapsed) | 642 | if (period_elapsed) |
634 | snd_pcm_period_elapsed(subs->pcm_substream); | 643 | snd_pcm_period_elapsed(subs->pcm_substream); |
635 | return 0; | 644 | return 0; |
@@ -735,41 +744,6 @@ static void snd_complete_sync_urb(struct urb *urb) | |||
735 | } | 744 | } |
736 | 745 | ||
737 | 746 | ||
738 | /* get the physical page pointer at the given offset */ | ||
739 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
740 | unsigned long offset) | ||
741 | { | ||
742 | void *pageptr = subs->runtime->dma_area + offset; | ||
743 | return vmalloc_to_page(pageptr); | ||
744 | } | ||
745 | |||
746 | /* allocate virtual buffer; may be called more than once */ | ||
747 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
748 | { | ||
749 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
750 | if (runtime->dma_area) { | ||
751 | if (runtime->dma_bytes >= size) | ||
752 | return 0; /* already large enough */ | ||
753 | vfree(runtime->dma_area); | ||
754 | } | ||
755 | runtime->dma_area = vmalloc(size); | ||
756 | if (!runtime->dma_area) | ||
757 | return -ENOMEM; | ||
758 | runtime->dma_bytes = size; | ||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | /* free virtual buffer; may be called more than once */ | ||
763 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
764 | { | ||
765 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
766 | |||
767 | vfree(runtime->dma_area); | ||
768 | runtime->dma_area = NULL; | ||
769 | return 0; | ||
770 | } | ||
771 | |||
772 | |||
773 | /* | 747 | /* |
774 | * unlink active urbs. | 748 | * unlink active urbs. |
775 | */ | 749 | */ |
@@ -937,18 +911,18 @@ static int wait_clear_urbs(struct snd_usb_substream *subs) | |||
937 | 911 | ||
938 | 912 | ||
939 | /* | 913 | /* |
940 | * return the current pcm pointer. just return the hwptr_done value. | 914 | * return the current pcm pointer. just based on the hwptr_done value. |
941 | */ | 915 | */ |
942 | static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream) | 916 | static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream) |
943 | { | 917 | { |
944 | struct snd_usb_substream *subs; | 918 | struct snd_usb_substream *subs; |
945 | snd_pcm_uframes_t hwptr_done; | 919 | unsigned int hwptr_done; |
946 | 920 | ||
947 | subs = (struct snd_usb_substream *)substream->runtime->private_data; | 921 | subs = (struct snd_usb_substream *)substream->runtime->private_data; |
948 | spin_lock(&subs->lock); | 922 | spin_lock(&subs->lock); |
949 | hwptr_done = subs->hwptr_done; | 923 | hwptr_done = subs->hwptr_done; |
950 | spin_unlock(&subs->lock); | 924 | spin_unlock(&subs->lock); |
951 | return hwptr_done; | 925 | return hwptr_done / (substream->runtime->frame_bits >> 3); |
952 | } | 926 | } |
953 | 927 | ||
954 | 928 | ||
@@ -1307,6 +1281,47 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, | |||
1307 | } | 1281 | } |
1308 | 1282 | ||
1309 | /* | 1283 | /* |
1284 | * For E-Mu 0404USB/0202USB/TrackerPre sample rate should be set for device, | ||
1285 | * not for interface. | ||
1286 | */ | ||
1287 | static void set_format_emu_quirk(struct snd_usb_substream *subs, | ||
1288 | struct audioformat *fmt) | ||
1289 | { | ||
1290 | unsigned char emu_samplerate_id = 0; | ||
1291 | |||
1292 | /* When capture is active | ||
1293 | * sample rate shouldn't be changed | ||
1294 | * by playback substream | ||
1295 | */ | ||
1296 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) { | ||
1297 | if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].interface != -1) | ||
1298 | return; | ||
1299 | } | ||
1300 | |||
1301 | switch (fmt->rate_min) { | ||
1302 | case 48000: | ||
1303 | emu_samplerate_id = EMU_QUIRK_SR_48000HZ; | ||
1304 | break; | ||
1305 | case 88200: | ||
1306 | emu_samplerate_id = EMU_QUIRK_SR_88200HZ; | ||
1307 | break; | ||
1308 | case 96000: | ||
1309 | emu_samplerate_id = EMU_QUIRK_SR_96000HZ; | ||
1310 | break; | ||
1311 | case 176400: | ||
1312 | emu_samplerate_id = EMU_QUIRK_SR_176400HZ; | ||
1313 | break; | ||
1314 | case 192000: | ||
1315 | emu_samplerate_id = EMU_QUIRK_SR_192000HZ; | ||
1316 | break; | ||
1317 | default: | ||
1318 | emu_samplerate_id = EMU_QUIRK_SR_44100HZ; | ||
1319 | break; | ||
1320 | } | ||
1321 | snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); | ||
1322 | } | ||
1323 | |||
1324 | /* | ||
1310 | * find a matching format and set up the interface | 1325 | * find a matching format and set up the interface |
1311 | */ | 1326 | */ |
1312 | static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | 1327 | static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) |
@@ -1419,6 +1434,14 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1419 | 1434 | ||
1420 | subs->cur_audiofmt = fmt; | 1435 | subs->cur_audiofmt = fmt; |
1421 | 1436 | ||
1437 | switch (subs->stream->chip->usb_id) { | ||
1438 | case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */ | ||
1439 | case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */ | ||
1440 | case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */ | ||
1441 | set_format_emu_quirk(subs, fmt); | ||
1442 | break; | ||
1443 | } | ||
1444 | |||
1422 | #if 0 | 1445 | #if 0 |
1423 | printk(KERN_DEBUG | 1446 | printk(KERN_DEBUG |
1424 | "setting done: format = %d, rate = %d..%d, channels = %d\n", | 1447 | "setting done: format = %d, rate = %d..%d, channels = %d\n", |
@@ -1449,8 +1472,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, | |||
1449 | unsigned int channels, rate, format; | 1472 | unsigned int channels, rate, format; |
1450 | int ret, changed; | 1473 | int ret, changed; |
1451 | 1474 | ||
1452 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | 1475 | ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, |
1453 | params_buffer_bytes(hw_params)); | 1476 | params_buffer_bytes(hw_params)); |
1454 | if (ret < 0) | 1477 | if (ret < 0) |
1455 | return ret; | 1478 | return ret; |
1456 | 1479 | ||
@@ -1507,7 +1530,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) | |||
1507 | subs->period_bytes = 0; | 1530 | subs->period_bytes = 0; |
1508 | if (!subs->stream->chip->shutdown) | 1531 | if (!subs->stream->chip->shutdown) |
1509 | release_substream_urbs(subs, 0); | 1532 | release_substream_urbs(subs, 0); |
1510 | return snd_pcm_free_vmalloc_buffer(substream); | 1533 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
1511 | } | 1534 | } |
1512 | 1535 | ||
1513 | /* | 1536 | /* |
@@ -1973,7 +1996,7 @@ static struct snd_pcm_ops snd_usb_playback_ops = { | |||
1973 | .prepare = snd_usb_pcm_prepare, | 1996 | .prepare = snd_usb_pcm_prepare, |
1974 | .trigger = snd_usb_pcm_playback_trigger, | 1997 | .trigger = snd_usb_pcm_playback_trigger, |
1975 | .pointer = snd_usb_pcm_pointer, | 1998 | .pointer = snd_usb_pcm_pointer, |
1976 | .page = snd_pcm_get_vmalloc_page, | 1999 | .page = snd_pcm_lib_get_vmalloc_page, |
1977 | }; | 2000 | }; |
1978 | 2001 | ||
1979 | static struct snd_pcm_ops snd_usb_capture_ops = { | 2002 | static struct snd_pcm_ops snd_usb_capture_ops = { |
@@ -1985,7 +2008,7 @@ static struct snd_pcm_ops snd_usb_capture_ops = { | |||
1985 | .prepare = snd_usb_pcm_prepare, | 2008 | .prepare = snd_usb_pcm_prepare, |
1986 | .trigger = snd_usb_pcm_capture_trigger, | 2009 | .trigger = snd_usb_pcm_capture_trigger, |
1987 | .pointer = snd_usb_pcm_pointer, | 2010 | .pointer = snd_usb_pcm_pointer, |
1988 | .page = snd_pcm_get_vmalloc_page, | 2011 | .page = snd_pcm_lib_get_vmalloc_page, |
1989 | }; | 2012 | }; |
1990 | 2013 | ||
1991 | 2014 | ||
@@ -2227,6 +2250,7 @@ static void init_substream(struct snd_usb_stream *as, int stream, struct audiofo | |||
2227 | subs->stream = as; | 2250 | subs->stream = as; |
2228 | subs->direction = stream; | 2251 | subs->direction = stream; |
2229 | subs->dev = as->chip->dev; | 2252 | subs->dev = as->chip->dev; |
2253 | subs->txfr_quirk = as->chip->txfr_quirk; | ||
2230 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) { | 2254 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) { |
2231 | subs->ops = audio_urb_ops[stream]; | 2255 | subs->ops = audio_urb_ops[stream]; |
2232 | } else { | 2256 | } else { |
@@ -3142,59 +3166,6 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip, | |||
3142 | return 0; | 3166 | return 0; |
3143 | } | 3167 | } |
3144 | 3168 | ||
3145 | /* | ||
3146 | * Create a stream for an Edirol UA-101 interface. | ||
3147 | * Copy, paste and modify from Edirol UA-1000 | ||
3148 | */ | ||
3149 | static int create_ua101_quirk(struct snd_usb_audio *chip, | ||
3150 | struct usb_interface *iface, | ||
3151 | const struct snd_usb_audio_quirk *quirk) | ||
3152 | { | ||
3153 | static const struct audioformat ua101_format = { | ||
3154 | .format = SNDRV_PCM_FORMAT_S32_LE, | ||
3155 | .fmt_type = USB_FORMAT_TYPE_I, | ||
3156 | .altsetting = 1, | ||
3157 | .altset_idx = 1, | ||
3158 | .attributes = 0, | ||
3159 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
3160 | }; | ||
3161 | struct usb_host_interface *alts; | ||
3162 | struct usb_interface_descriptor *altsd; | ||
3163 | struct audioformat *fp; | ||
3164 | int stream, err; | ||
3165 | |||
3166 | if (iface->num_altsetting != 2) | ||
3167 | return -ENXIO; | ||
3168 | alts = &iface->altsetting[1]; | ||
3169 | altsd = get_iface_desc(alts); | ||
3170 | if (alts->extralen != 18 || alts->extra[1] != USB_DT_CS_INTERFACE || | ||
3171 | altsd->bNumEndpoints != 1) | ||
3172 | return -ENXIO; | ||
3173 | |||
3174 | fp = kmemdup(&ua101_format, sizeof(*fp), GFP_KERNEL); | ||
3175 | if (!fp) | ||
3176 | return -ENOMEM; | ||
3177 | |||
3178 | fp->channels = alts->extra[11]; | ||
3179 | fp->iface = altsd->bInterfaceNumber; | ||
3180 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | ||
3181 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | ||
3182 | fp->datainterval = parse_datainterval(chip, alts); | ||
3183 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
3184 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); | ||
3185 | |||
3186 | stream = (fp->endpoint & USB_DIR_IN) | ||
3187 | ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; | ||
3188 | err = add_audio_endpoint(chip, stream, fp); | ||
3189 | if (err < 0) { | ||
3190 | kfree(fp); | ||
3191 | return err; | ||
3192 | } | ||
3193 | /* FIXME: playback must be synchronized to capture */ | ||
3194 | usb_set_interface(chip->dev, fp->iface, 0); | ||
3195 | return 0; | ||
3196 | } | ||
3197 | |||
3198 | static int snd_usb_create_quirk(struct snd_usb_audio *chip, | 3169 | static int snd_usb_create_quirk(struct snd_usb_audio *chip, |
3199 | struct usb_interface *iface, | 3170 | struct usb_interface *iface, |
3200 | const struct snd_usb_audio_quirk *quirk); | 3171 | const struct snd_usb_audio_quirk *quirk); |
@@ -3232,6 +3203,18 @@ static int ignore_interface_quirk(struct snd_usb_audio *chip, | |||
3232 | return 0; | 3203 | return 0; |
3233 | } | 3204 | } |
3234 | 3205 | ||
3206 | /* | ||
3207 | * Allow alignment on audio sub-slot (channel samples) rather than | ||
3208 | * on audio slots (audio frames) | ||
3209 | */ | ||
3210 | static int create_align_transfer_quirk(struct snd_usb_audio *chip, | ||
3211 | struct usb_interface *iface, | ||
3212 | const struct snd_usb_audio_quirk *quirk) | ||
3213 | { | ||
3214 | chip->txfr_quirk = 1; | ||
3215 | return 1; /* Continue with creating streams and mixer */ | ||
3216 | } | ||
3217 | |||
3235 | 3218 | ||
3236 | /* | 3219 | /* |
3237 | * boot quirks | 3220 | * boot quirks |
@@ -3406,8 +3389,8 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip, | |||
3406 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, | 3389 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, |
3407 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, | 3390 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, |
3408 | [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, | 3391 | [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, |
3409 | [QUIRK_AUDIO_EDIROL_UA101] = create_ua101_quirk, | 3392 | [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, |
3410 | [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk | 3393 | [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk |
3411 | }; | 3394 | }; |
3412 | 3395 | ||
3413 | if (quirk->type < QUIRK_TYPE_COUNT) { | 3396 | if (quirk->type < QUIRK_TYPE_COUNT) { |
@@ -3661,6 +3644,7 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3661 | } | 3644 | } |
3662 | } | 3645 | } |
3663 | 3646 | ||
3647 | chip->txfr_quirk = 0; | ||
3664 | err = 1; /* continue */ | 3648 | err = 1; /* continue */ |
3665 | if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) { | 3649 | if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) { |
3666 | /* need some special handlings */ | 3650 | /* need some special handlings */ |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 40ba8115fb81..9d8cea48fc5f 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
@@ -125,6 +125,7 @@ struct snd_usb_audio { | |||
125 | struct snd_card *card; | 125 | struct snd_card *card; |
126 | u32 usb_id; | 126 | u32 usb_id; |
127 | int shutdown; | 127 | int shutdown; |
128 | unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ | ||
128 | int num_interfaces; | 129 | int num_interfaces; |
129 | int num_suspended_intf; | 130 | int num_suspended_intf; |
130 | 131 | ||
@@ -159,8 +160,8 @@ enum quirk_type { | |||
159 | QUIRK_AUDIO_STANDARD_INTERFACE, | 160 | QUIRK_AUDIO_STANDARD_INTERFACE, |
160 | QUIRK_AUDIO_FIXED_ENDPOINT, | 161 | QUIRK_AUDIO_FIXED_ENDPOINT, |
161 | QUIRK_AUDIO_EDIROL_UA1000, | 162 | QUIRK_AUDIO_EDIROL_UA1000, |
162 | QUIRK_AUDIO_EDIROL_UA101, | ||
163 | QUIRK_AUDIO_EDIROL_UAXX, | 163 | QUIRK_AUDIO_EDIROL_UAXX, |
164 | QUIRK_AUDIO_ALIGN_TRANSFER, | ||
164 | 165 | ||
165 | QUIRK_TYPE_COUNT | 166 | QUIRK_TYPE_COUNT |
166 | }; | 167 | }; |
@@ -209,6 +210,16 @@ struct snd_usb_midi_endpoint_info { | |||
209 | /* | 210 | /* |
210 | */ | 211 | */ |
211 | 212 | ||
213 | /*E-mu USB samplerate control quirk*/ | ||
214 | enum { | ||
215 | EMU_QUIRK_SR_44100HZ = 0, | ||
216 | EMU_QUIRK_SR_48000HZ, | ||
217 | EMU_QUIRK_SR_88200HZ, | ||
218 | EMU_QUIRK_SR_96000HZ, | ||
219 | EMU_QUIRK_SR_176400HZ, | ||
220 | EMU_QUIRK_SR_192000HZ | ||
221 | }; | ||
222 | |||
212 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) | 223 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) |
213 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) | 224 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) |
214 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) | 225 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) |
@@ -234,6 +245,9 @@ void snd_usbmidi_input_stop(struct list_head* p); | |||
234 | void snd_usbmidi_input_start(struct list_head* p); | 245 | void snd_usbmidi_input_start(struct list_head* p); |
235 | void snd_usbmidi_disconnect(struct list_head *p); | 246 | void snd_usbmidi_disconnect(struct list_head *p); |
236 | 247 | ||
248 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, | ||
249 | unsigned char samplerate_id); | ||
250 | |||
237 | /* | 251 | /* |
238 | * retrieve usb_interface descriptor from the host interface | 252 | * retrieve usb_interface descriptor from the host interface |
239 | * (conditional for compatibility with the older API) | 253 | * (conditional for compatibility with the older API) |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index c998220b99c6..f5596cfdbde1 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -186,6 +186,21 @@ enum { | |||
186 | USB_PROC_DCR_RELEASE = 6, | 186 | USB_PROC_DCR_RELEASE = 6, |
187 | }; | 187 | }; |
188 | 188 | ||
189 | /*E-mu 0202(0404) eXtension Unit(XU) control*/ | ||
190 | enum { | ||
191 | USB_XU_CLOCK_RATE = 0xe301, | ||
192 | USB_XU_CLOCK_SOURCE = 0xe302, | ||
193 | USB_XU_DIGITAL_IO_STATUS = 0xe303, | ||
194 | USB_XU_DEVICE_OPTIONS = 0xe304, | ||
195 | USB_XU_DIRECT_MONITORING = 0xe305, | ||
196 | USB_XU_METERING = 0xe306 | ||
197 | }; | ||
198 | enum { | ||
199 | USB_XU_CLOCK_SOURCE_SELECTOR = 0x02, /* clock source*/ | ||
200 | USB_XU_CLOCK_RATE_SELECTOR = 0x03, /* clock rate */ | ||
201 | USB_XU_DIGITAL_FORMAT_SELECTOR = 0x01, /* the spdif format */ | ||
202 | USB_XU_SOFT_LIMIT_SELECTOR = 0x03 /* soft limiter */ | ||
203 | }; | ||
189 | 204 | ||
190 | /* | 205 | /* |
191 | * manual mapping of mixer names | 206 | * manual mapping of mixer names |
@@ -1330,7 +1345,32 @@ static struct procunit_info procunits[] = { | |||
1330 | { USB_PROC_DCR, "DCR", dcr_proc_info }, | 1345 | { USB_PROC_DCR, "DCR", dcr_proc_info }, |
1331 | { 0 }, | 1346 | { 0 }, |
1332 | }; | 1347 | }; |
1333 | 1348 | /* | |
1349 | * predefined data for extension units | ||
1350 | */ | ||
1351 | static struct procunit_value_info clock_rate_xu_info[] = { | ||
1352 | { USB_XU_CLOCK_RATE_SELECTOR, "Selector", USB_MIXER_U8, 0 }, | ||
1353 | { 0 } | ||
1354 | }; | ||
1355 | static struct procunit_value_info clock_source_xu_info[] = { | ||
1356 | { USB_XU_CLOCK_SOURCE_SELECTOR, "External", USB_MIXER_BOOLEAN }, | ||
1357 | { 0 } | ||
1358 | }; | ||
1359 | static struct procunit_value_info spdif_format_xu_info[] = { | ||
1360 | { USB_XU_DIGITAL_FORMAT_SELECTOR, "SPDIF/AC3", USB_MIXER_BOOLEAN }, | ||
1361 | { 0 } | ||
1362 | }; | ||
1363 | static struct procunit_value_info soft_limit_xu_info[] = { | ||
1364 | { USB_XU_SOFT_LIMIT_SELECTOR, " ", USB_MIXER_BOOLEAN }, | ||
1365 | { 0 } | ||
1366 | }; | ||
1367 | static struct procunit_info extunits[] = { | ||
1368 | { USB_XU_CLOCK_RATE, "Clock rate", clock_rate_xu_info }, | ||
1369 | { USB_XU_CLOCK_SOURCE, "DigitalIn CLK source", clock_source_xu_info }, | ||
1370 | { USB_XU_DIGITAL_IO_STATUS, "DigitalOut format:", spdif_format_xu_info }, | ||
1371 | { USB_XU_DEVICE_OPTIONS, "AnalogueIn Soft Limit", soft_limit_xu_info }, | ||
1372 | { 0 } | ||
1373 | }; | ||
1334 | /* | 1374 | /* |
1335 | * build a processing/extension unit | 1375 | * build a processing/extension unit |
1336 | */ | 1376 | */ |
@@ -1391,8 +1431,18 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, unsigned | |||
1391 | cval->max = dsc[15]; | 1431 | cval->max = dsc[15]; |
1392 | cval->res = 1; | 1432 | cval->res = 1; |
1393 | cval->initialized = 1; | 1433 | cval->initialized = 1; |
1394 | } else | 1434 | } else { |
1395 | get_min_max(cval, valinfo->min_value); | 1435 | if (type == USB_XU_CLOCK_RATE) { |
1436 | /* E-Mu USB 0404/0202/TrackerPre | ||
1437 | * samplerate control quirk | ||
1438 | */ | ||
1439 | cval->min = 0; | ||
1440 | cval->max = 5; | ||
1441 | cval->res = 1; | ||
1442 | cval->initialized = 1; | ||
1443 | } else | ||
1444 | get_min_max(cval, valinfo->min_value); | ||
1445 | } | ||
1396 | 1446 | ||
1397 | kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); | 1447 | kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); |
1398 | if (! kctl) { | 1448 | if (! kctl) { |
@@ -1433,7 +1483,7 @@ static int parse_audio_processing_unit(struct mixer_build *state, int unitid, un | |||
1433 | 1483 | ||
1434 | static int parse_audio_extension_unit(struct mixer_build *state, int unitid, unsigned char *desc) | 1484 | static int parse_audio_extension_unit(struct mixer_build *state, int unitid, unsigned char *desc) |
1435 | { | 1485 | { |
1436 | return build_audio_procunit(state, unitid, desc, NULL, "Extension Unit"); | 1486 | return build_audio_procunit(state, unitid, desc, extunits, "Extension Unit"); |
1437 | } | 1487 | } |
1438 | 1488 | ||
1439 | 1489 | ||
@@ -2109,6 +2159,23 @@ static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer) | |||
2109 | return 0; | 2159 | return 0; |
2110 | } | 2160 | } |
2111 | 2161 | ||
2162 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, | ||
2163 | unsigned char samplerate_id) | ||
2164 | { | ||
2165 | struct usb_mixer_interface *mixer; | ||
2166 | struct usb_mixer_elem_info *cval; | ||
2167 | int unitid = 12; /* SamleRate ExtensionUnit ID */ | ||
2168 | |||
2169 | list_for_each_entry(mixer, &chip->mixer_list, list) { | ||
2170 | cval = mixer->id_elems[unitid]; | ||
2171 | if (cval) { | ||
2172 | set_cur_ctl_value(cval, cval->control << 8, samplerate_id); | ||
2173 | snd_usb_mixer_notify_id(mixer, unitid); | ||
2174 | } | ||
2175 | break; | ||
2176 | } | ||
2177 | } | ||
2178 | |||
2112 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | 2179 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
2113 | int ignore_error) | 2180 | int ignore_error) |
2114 | { | 2181 | { |
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index a892bda03df9..65bbd22f2e0c 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h | |||
@@ -1266,37 +1266,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1266 | } | 1266 | } |
1267 | } | 1267 | } |
1268 | }, | 1268 | }, |
1269 | /* Roland UA-101 in High-Speed Mode only */ | ||
1270 | { | ||
1271 | USB_DEVICE(0x0582, 0x007d), | ||
1272 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
1273 | .vendor_name = "Roland", | ||
1274 | .product_name = "UA-101", | ||
1275 | .ifnum = QUIRK_ANY_INTERFACE, | ||
1276 | .type = QUIRK_COMPOSITE, | ||
1277 | .data = (const struct snd_usb_audio_quirk[]) { | ||
1278 | { | ||
1279 | .ifnum = 0, | ||
1280 | .type = QUIRK_AUDIO_EDIROL_UA101 | ||
1281 | }, | ||
1282 | { | ||
1283 | .ifnum = 1, | ||
1284 | .type = QUIRK_AUDIO_EDIROL_UA101 | ||
1285 | }, | ||
1286 | { | ||
1287 | .ifnum = 2, | ||
1288 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
1289 | .data = & (const struct snd_usb_midi_endpoint_info) { | ||
1290 | .out_cables = 0x0001, | ||
1291 | .in_cables = 0x0001 | ||
1292 | } | ||
1293 | }, | ||
1294 | { | ||
1295 | .ifnum = -1 | ||
1296 | } | ||
1297 | } | ||
1298 | } | ||
1299 | }, | ||
1300 | { | 1269 | { |
1301 | /* has ID 0x0081 when not in "Advanced Driver" mode */ | 1270 | /* has ID 0x0081 when not in "Advanced Driver" mode */ |
1302 | USB_DEVICE(0x0582, 0x0080), | 1271 | USB_DEVICE(0x0582, 0x0080), |
@@ -2105,6 +2074,120 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2105 | } | 2074 | } |
2106 | }, | 2075 | }, |
2107 | 2076 | ||
2077 | /* Hauppauge HVR-950Q and HVR-850 */ | ||
2078 | { | ||
2079 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7200), | ||
2080 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2081 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2082 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2083 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2084 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2085 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2086 | .vendor_name = "Hauppauge", | ||
2087 | .product_name = "HVR-950Q", | ||
2088 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2089 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2090 | } | ||
2091 | }, | ||
2092 | { | ||
2093 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7201), | ||
2094 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2095 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2096 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2097 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2098 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2099 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2100 | .vendor_name = "Hauppauge", | ||
2101 | .product_name = "HVR-950Q", | ||
2102 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2103 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2104 | } | ||
2105 | }, | ||
2106 | { | ||
2107 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7202), | ||
2108 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2109 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2110 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2111 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2112 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2113 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2114 | .vendor_name = "Hauppauge", | ||
2115 | .product_name = "HVR-950Q", | ||
2116 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2117 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2118 | } | ||
2119 | }, | ||
2120 | { | ||
2121 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7203), | ||
2122 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2123 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2124 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2125 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2126 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2127 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2128 | .vendor_name = "Hauppauge", | ||
2129 | .product_name = "HVR-950Q", | ||
2130 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2131 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2132 | } | ||
2133 | }, | ||
2134 | { | ||
2135 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7204), | ||
2136 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2137 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2138 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2139 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2140 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2141 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2142 | .vendor_name = "Hauppauge", | ||
2143 | .product_name = "HVR-950Q", | ||
2144 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2145 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2146 | } | ||
2147 | }, | ||
2148 | { | ||
2149 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7205), | ||
2150 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2151 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2152 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2153 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2154 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2155 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2156 | .vendor_name = "Hauppauge", | ||
2157 | .product_name = "HVR-950Q", | ||
2158 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2159 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2160 | } | ||
2161 | }, | ||
2162 | { | ||
2163 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7250), | ||
2164 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2165 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2166 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2167 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2168 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2169 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2170 | .vendor_name = "Hauppauge", | ||
2171 | .product_name = "HVR-950Q", | ||
2172 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2173 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2174 | } | ||
2175 | }, | ||
2176 | { | ||
2177 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7230), | ||
2178 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2179 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2180 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2181 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2182 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, | ||
2183 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2184 | .vendor_name = "Hauppauge", | ||
2185 | .product_name = "HVR-850", | ||
2186 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2187 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2188 | } | ||
2189 | }, | ||
2190 | |||
2108 | { | 2191 | { |
2109 | /* | 2192 | /* |
2110 | * Some USB MIDI devices don't have an audio control interface, | 2193 | * Some USB MIDI devices don't have an audio control interface, |