diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-12-26 09:52:54 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-12-26 09:52:54 -0500 |
commit | 7f50548abb5454bd82c25aae15f0a3bf6a530f46 (patch) | |
tree | 175b5d695437151f0f9f778ad8eb7f274468842f /sound | |
parent | b3172f222ab5afdc91ea058bd11c42cf169728f3 (diff) | |
parent | 6b7b284958d47b77d06745b36bc7f36dab769d9b (diff) |
Merge commit 'v2.6.33-rc2' into for-2.6.33
Diffstat (limited to 'sound')
166 files changed, 12670 insertions, 5662 deletions
diff --git a/sound/Kconfig b/sound/Kconfig index 439e15c8faa3..fcad760f5691 100644 --- a/sound/Kconfig +++ b/sound/Kconfig | |||
@@ -1,6 +1,3 @@ | |||
1 | # sound/Config.in | ||
2 | # | ||
3 | |||
4 | menuconfig SOUND | 1 | menuconfig SOUND |
5 | tristate "Sound card support" | 2 | tristate "Sound card support" |
6 | depends on HAS_IOMEM | 3 | depends on HAS_IOMEM |
@@ -58,7 +55,7 @@ config SOUND_OSS_CORE_PRECLAIM | |||
58 | Please read Documentation/feature-removal-schedule.txt for | 55 | Please read Documentation/feature-removal-schedule.txt for |
59 | details. | 56 | details. |
60 | 57 | ||
61 | If unusre, say Y. | 58 | If unsure, say Y. |
62 | 59 | ||
63 | source "sound/oss/dmasound/Kconfig" | 60 | source "sound/oss/dmasound/Kconfig" |
64 | 61 | ||
@@ -136,4 +133,3 @@ config AC97_BUS | |||
136 | sound subsystem and other function drivers completely unrelated to | 133 | sound subsystem and other function drivers completely unrelated to |
137 | sound although they're sharing the AC97 bus. Concerned drivers | 134 | sound although they're sharing the AC97 bus. Concerned drivers |
138 | should "select" this. | 135 | should "select" this. |
139 | |||
diff --git a/sound/arm/Makefile b/sound/arm/Makefile index 5a549ed6c8aa..8c0c851d4641 100644 --- a/sound/arm/Makefile +++ b/sound/arm/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_SND_ARMAACI) += snd-aaci.o | 5 | obj-$(CONFIG_SND_ARMAACI) += snd-aaci.o |
6 | snd-aaci-objs := aaci.o devdma.o | 6 | snd-aaci-objs := aaci.o |
7 | 7 | ||
8 | obj-$(CONFIG_SND_PXA2XX_PCM) += snd-pxa2xx-pcm.o | 8 | obj-$(CONFIG_SND_PXA2XX_PCM) += snd-pxa2xx-pcm.o |
9 | snd-pxa2xx-pcm-objs := pxa2xx-pcm.o | 9 | snd-pxa2xx-pcm-objs := pxa2xx-pcm.o |
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 1f0f8213e2d5..c5699863643b 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c | |||
@@ -18,10 +18,7 @@ | |||
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/err.h> | 19 | #include <linux/err.h> |
20 | #include <linux/amba/bus.h> | 20 | #include <linux/amba/bus.h> |
21 | 21 | #include <linux/io.h> | |
22 | #include <asm/io.h> | ||
23 | #include <asm/irq.h> | ||
24 | #include <asm/sizes.h> | ||
25 | 22 | ||
26 | #include <sound/core.h> | 23 | #include <sound/core.h> |
27 | #include <sound/initval.h> | 24 | #include <sound/initval.h> |
@@ -30,7 +27,6 @@ | |||
30 | #include <sound/pcm_params.h> | 27 | #include <sound/pcm_params.h> |
31 | 28 | ||
32 | #include "aaci.h" | 29 | #include "aaci.h" |
33 | #include "devdma.h" | ||
34 | 30 | ||
35 | #define DRIVER_NAME "aaci-pl041" | 31 | #define DRIVER_NAME "aaci-pl041" |
36 | 32 | ||
@@ -176,14 +172,15 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg) | |||
176 | return v; | 172 | return v; |
177 | } | 173 | } |
178 | 174 | ||
179 | 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) | ||
180 | { | 177 | { |
181 | u32 val; | 178 | u32 val; |
182 | int timeout = 5000; | 179 | int timeout = 5000; |
183 | 180 | ||
184 | do { | 181 | do { |
185 | val = readl(aacirun->base + AACI_SR); | 182 | val = readl(aacirun->base + AACI_SR); |
186 | } while (val & (SR_TXB|SR_RXB) && timeout--); | 183 | } while (val & mask && timeout--); |
187 | } | 184 | } |
188 | 185 | ||
189 | 186 | ||
@@ -212,8 +209,10 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
212 | writel(0, aacirun->base + AACI_IE); | 209 | writel(0, aacirun->base + AACI_IE); |
213 | return; | 210 | return; |
214 | } | 211 | } |
215 | ptr = aacirun->ptr; | ||
216 | 212 | ||
213 | spin_lock(&aacirun->lock); | ||
214 | |||
215 | ptr = aacirun->ptr; | ||
217 | do { | 216 | do { |
218 | unsigned int len = aacirun->fifosz; | 217 | unsigned int len = aacirun->fifosz; |
219 | u32 val; | 218 | u32 val; |
@@ -221,9 +220,9 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
221 | if (aacirun->bytes <= 0) { | 220 | if (aacirun->bytes <= 0) { |
222 | aacirun->bytes += aacirun->period; | 221 | aacirun->bytes += aacirun->period; |
223 | aacirun->ptr = ptr; | 222 | aacirun->ptr = ptr; |
224 | spin_unlock(&aaci->lock); | 223 | spin_unlock(&aacirun->lock); |
225 | snd_pcm_period_elapsed(aacirun->substream); | 224 | snd_pcm_period_elapsed(aacirun->substream); |
226 | spin_lock(&aaci->lock); | 225 | spin_lock(&aacirun->lock); |
227 | } | 226 | } |
228 | if (!(aacirun->cr & CR_EN)) | 227 | if (!(aacirun->cr & CR_EN)) |
229 | break; | 228 | break; |
@@ -249,7 +248,10 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
249 | ptr = aacirun->start; | 248 | ptr = aacirun->start; |
250 | } | 249 | } |
251 | } while(1); | 250 | } while(1); |
251 | |||
252 | aacirun->ptr = ptr; | 252 | aacirun->ptr = ptr; |
253 | |||
254 | spin_unlock(&aacirun->lock); | ||
253 | } | 255 | } |
254 | 256 | ||
255 | if (mask & ISR_URINTR) { | 257 | if (mask & ISR_URINTR) { |
@@ -267,6 +269,8 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
267 | return; | 269 | return; |
268 | } | 270 | } |
269 | 271 | ||
272 | spin_lock(&aacirun->lock); | ||
273 | |||
270 | ptr = aacirun->ptr; | 274 | ptr = aacirun->ptr; |
271 | do { | 275 | do { |
272 | unsigned int len = aacirun->fifosz; | 276 | unsigned int len = aacirun->fifosz; |
@@ -275,9 +279,9 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
275 | if (aacirun->bytes <= 0) { | 279 | if (aacirun->bytes <= 0) { |
276 | aacirun->bytes += aacirun->period; | 280 | aacirun->bytes += aacirun->period; |
277 | aacirun->ptr = ptr; | 281 | aacirun->ptr = ptr; |
278 | spin_unlock(&aaci->lock); | 282 | spin_unlock(&aacirun->lock); |
279 | snd_pcm_period_elapsed(aacirun->substream); | 283 | snd_pcm_period_elapsed(aacirun->substream); |
280 | spin_lock(&aaci->lock); | 284 | spin_lock(&aacirun->lock); |
281 | } | 285 | } |
282 | if (!(aacirun->cr & CR_EN)) | 286 | if (!(aacirun->cr & CR_EN)) |
283 | break; | 287 | break; |
@@ -305,6 +309,8 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) | |||
305 | } while (1); | 309 | } while (1); |
306 | 310 | ||
307 | aacirun->ptr = ptr; | 311 | aacirun->ptr = ptr; |
312 | |||
313 | spin_unlock(&aacirun->lock); | ||
308 | } | 314 | } |
309 | } | 315 | } |
310 | 316 | ||
@@ -314,7 +320,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
314 | u32 mask; | 320 | u32 mask; |
315 | int i; | 321 | int i; |
316 | 322 | ||
317 | spin_lock(&aaci->lock); | ||
318 | mask = readl(aaci->base + AACI_ALLINTS); | 323 | mask = readl(aaci->base + AACI_ALLINTS); |
319 | if (mask) { | 324 | if (mask) { |
320 | u32 m = mask; | 325 | u32 m = mask; |
@@ -324,7 +329,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
324 | } | 329 | } |
325 | } | 330 | } |
326 | } | 331 | } |
327 | spin_unlock(&aaci->lock); | ||
328 | 332 | ||
329 | return mask ? IRQ_HANDLED : IRQ_NONE; | 333 | return mask ? IRQ_HANDLED : IRQ_NONE; |
330 | } | 334 | } |
@@ -334,63 +338,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
334 | /* | 338 | /* |
335 | * ALSA support. | 339 | * ALSA support. |
336 | */ | 340 | */ |
337 | |||
338 | struct aaci_stream { | ||
339 | unsigned char codec_idx; | ||
340 | unsigned char rate_idx; | ||
341 | }; | ||
342 | |||
343 | static struct aaci_stream aaci_streams[] = { | ||
344 | [ACSTREAM_FRONT] = { | ||
345 | .codec_idx = 0, | ||
346 | .rate_idx = AC97_RATES_FRONT_DAC, | ||
347 | }, | ||
348 | [ACSTREAM_SURROUND] = { | ||
349 | .codec_idx = 0, | ||
350 | .rate_idx = AC97_RATES_SURR_DAC, | ||
351 | }, | ||
352 | [ACSTREAM_LFE] = { | ||
353 | .codec_idx = 0, | ||
354 | .rate_idx = AC97_RATES_LFE_DAC, | ||
355 | }, | ||
356 | }; | ||
357 | |||
358 | static inline unsigned int aaci_rate_mask(struct aaci *aaci, int streamid) | ||
359 | { | ||
360 | struct aaci_stream *s = aaci_streams + streamid; | ||
361 | return aaci->ac97_bus->codec[s->codec_idx]->rates[s->rate_idx]; | ||
362 | } | ||
363 | |||
364 | static unsigned int rate_list[] = { | ||
365 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, | ||
366 | 48000, 64000, 88200, 96000, 176400, 192000 | ||
367 | }; | ||
368 | |||
369 | /* | ||
370 | * Double-rate rule: we can support double rate iff channels == 2 | ||
371 | * (unimplemented) | ||
372 | */ | ||
373 | static int | ||
374 | aaci_rule_rate_by_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule) | ||
375 | { | ||
376 | struct aaci *aaci = rule->private; | ||
377 | unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512; | ||
378 | struct snd_interval *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
379 | |||
380 | switch (c->max) { | ||
381 | case 6: | ||
382 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE); | ||
383 | case 4: | ||
384 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND); | ||
385 | case 2: | ||
386 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT); | ||
387 | } | ||
388 | |||
389 | return snd_interval_list(hw_param_interval(p, rule->var), | ||
390 | ARRAY_SIZE(rate_list), rate_list, | ||
391 | rate_mask); | ||
392 | } | ||
393 | |||
394 | static struct snd_pcm_hardware aaci_hw_info = { | 341 | static struct snd_pcm_hardware aaci_hw_info = { |
395 | .info = SNDRV_PCM_INFO_MMAP | | 342 | .info = SNDRV_PCM_INFO_MMAP | |
396 | SNDRV_PCM_INFO_MMAP_VALID | | 343 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -404,10 +351,7 @@ static struct snd_pcm_hardware aaci_hw_info = { | |||
404 | */ | 351 | */ |
405 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 352 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
406 | 353 | ||
407 | /* should this be continuous or knot? */ | 354 | /* rates are setup from the AC'97 codec */ |
408 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
409 | .rate_max = 48000, | ||
410 | .rate_min = 4000, | ||
411 | .channels_min = 2, | 355 | .channels_min = 2, |
412 | .channels_max = 6, | 356 | .channels_max = 6, |
413 | .buffer_bytes_max = 64 * 1024, | 357 | .buffer_bytes_max = 64 * 1024, |
@@ -427,6 +371,12 @@ static int __aaci_pcm_open(struct aaci *aaci, | |||
427 | aacirun->substream = substream; | 371 | aacirun->substream = substream; |
428 | runtime->private_data = aacirun; | 372 | runtime->private_data = aacirun; |
429 | 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); | ||
430 | 380 | ||
431 | /* | 381 | /* |
432 | * 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 |
@@ -437,17 +387,6 @@ static int __aaci_pcm_open(struct aaci *aaci, | |||
437 | */ | 387 | */ |
438 | runtime->hw.fifo_size = aaci->fifosize * 2; | 388 | runtime->hw.fifo_size = aaci->fifosize * 2; |
439 | 389 | ||
440 | /* | ||
441 | * Add rule describing hardware rate dependency | ||
442 | * on the number of channels. | ||
443 | */ | ||
444 | ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
445 | aaci_rule_rate_by_channels, aaci, | ||
446 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
447 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
448 | if (ret) | ||
449 | goto out; | ||
450 | |||
451 | 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, |
452 | DRIVER_NAME, aaci); | 391 | DRIVER_NAME, aaci); |
453 | if (ret) | 392 | if (ret) |
@@ -492,7 +431,7 @@ static int aaci_pcm_hw_free(struct snd_pcm_substream *substream) | |||
492 | /* | 431 | /* |
493 | * Clear out the DMA and any allocated buffers. | 432 | * Clear out the DMA and any allocated buffers. |
494 | */ | 433 | */ |
495 | devdma_hw_free(NULL, substream); | 434 | snd_pcm_lib_free_pages(substream); |
496 | 435 | ||
497 | return 0; | 436 | return 0; |
498 | } | 437 | } |
@@ -504,27 +443,29 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, | |||
504 | int err; | 443 | int err; |
505 | 444 | ||
506 | aaci_pcm_hw_free(substream); | 445 | aaci_pcm_hw_free(substream); |
446 | if (aacirun->pcm_open) { | ||
447 | snd_ac97_pcm_close(aacirun->pcm); | ||
448 | aacirun->pcm_open = 0; | ||
449 | } | ||
507 | 450 | ||
508 | err = devdma_hw_alloc(NULL, 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 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 457 | err = snd_ac97_pcm_open(aacirun->pcm, rate, |
514 | err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), | ||
515 | params_channels(params), | ||
516 | aacirun->pcm->r[0].slots); | ||
517 | else | ||
518 | err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), | ||
519 | params_channels(params), | 458 | params_channels(params), |
520 | aacirun->pcm->r[1].slots); | 459 | aacirun->pcm->r[dbl].slots); |
521 | 460 | ||
522 | if (err) | 461 | aacirun->pcm_open = err == 0; |
523 | goto out; | 462 | aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; |
463 | aacirun->fifosz = aaci->fifosize * 4; | ||
524 | 464 | ||
525 | aacirun->pcm_open = 1; | 465 | if (aacirun->cr & CR_COMPACT) |
466 | aacirun->fifosz >>= 1; | ||
467 | } | ||
526 | 468 | ||
527 | out: | ||
528 | return err; | 469 | return err; |
529 | } | 470 | } |
530 | 471 | ||
@@ -533,8 +474,8 @@ static int aaci_pcm_prepare(struct snd_pcm_substream *substream) | |||
533 | struct snd_pcm_runtime *runtime = substream->runtime; | 474 | struct snd_pcm_runtime *runtime = substream->runtime; |
534 | struct aaci_runtime *aacirun = runtime->private_data; | 475 | struct aaci_runtime *aacirun = runtime->private_data; |
535 | 476 | ||
536 | aacirun->start = (void *)runtime->dma_area; | 477 | aacirun->start = runtime->dma_area; |
537 | aacirun->end = aacirun->start + runtime->dma_bytes; | 478 | aacirun->end = aacirun->start + snd_pcm_lib_buffer_bytes(substream); |
538 | aacirun->ptr = aacirun->start; | 479 | aacirun->ptr = aacirun->start; |
539 | aacirun->period = | 480 | aacirun->period = |
540 | aacirun->bytes = frames_to_bytes(runtime, runtime->period_size); | 481 | aacirun->bytes = frames_to_bytes(runtime, runtime->period_size); |
@@ -551,11 +492,6 @@ static snd_pcm_uframes_t aaci_pcm_pointer(struct snd_pcm_substream *substream) | |||
551 | return bytes_to_frames(runtime, bytes); | 492 | return bytes_to_frames(runtime, bytes); |
552 | } | 493 | } |
553 | 494 | ||
554 | static int aaci_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) | ||
555 | { | ||
556 | return devdma_mmap(NULL, substream, vma); | ||
557 | } | ||
558 | |||
559 | 495 | ||
560 | /* | 496 | /* |
561 | * Playback specific ALSA stuff | 497 | * Playback specific ALSA stuff |
@@ -638,14 +574,9 @@ static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream, | |||
638 | * Enable FIFO, compact mode, 16 bits per sample. | 574 | * Enable FIFO, compact mode, 16 bits per sample. |
639 | * FIXME: double rate slots? | 575 | * FIXME: double rate slots? |
640 | */ | 576 | */ |
641 | if (ret >= 0) { | 577 | if (ret >= 0) |
642 | aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; | ||
643 | aacirun->cr |= channels_to_txmask[channels]; | 578 | aacirun->cr |= channels_to_txmask[channels]; |
644 | 579 | ||
645 | aacirun->fifosz = aaci->fifosize * 4; | ||
646 | if (aacirun->cr & CR_COMPACT) | ||
647 | aacirun->fifosz >>= 1; | ||
648 | } | ||
649 | return ret; | 580 | return ret; |
650 | } | 581 | } |
651 | 582 | ||
@@ -657,7 +588,7 @@ static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun) | |||
657 | ie &= ~(IE_URIE|IE_TXIE); | 588 | ie &= ~(IE_URIE|IE_TXIE); |
658 | writel(ie, aacirun->base + AACI_IE); | 589 | writel(ie, aacirun->base + AACI_IE); |
659 | aacirun->cr &= ~CR_EN; | 590 | aacirun->cr &= ~CR_EN; |
660 | aaci_chan_wait_ready(aacirun); | 591 | aaci_chan_wait_ready(aacirun, SR_TXB); |
661 | writel(aacirun->cr, aacirun->base + AACI_TXCR); | 592 | writel(aacirun->cr, aacirun->base + AACI_TXCR); |
662 | } | 593 | } |
663 | 594 | ||
@@ -665,7 +596,7 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) | |||
665 | { | 596 | { |
666 | u32 ie; | 597 | u32 ie; |
667 | 598 | ||
668 | aaci_chan_wait_ready(aacirun); | 599 | aaci_chan_wait_ready(aacirun, SR_TXB); |
669 | aacirun->cr |= CR_EN; | 600 | aacirun->cr |= CR_EN; |
670 | 601 | ||
671 | ie = readl(aacirun->base + AACI_IE); | 602 | ie = readl(aacirun->base + AACI_IE); |
@@ -676,12 +607,12 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) | |||
676 | 607 | ||
677 | 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) |
678 | { | 609 | { |
679 | struct aaci *aaci = substream->private_data; | ||
680 | struct aaci_runtime *aacirun = substream->runtime->private_data; | 610 | struct aaci_runtime *aacirun = substream->runtime->private_data; |
681 | unsigned long flags; | 611 | unsigned long flags; |
682 | int ret = 0; | 612 | int ret = 0; |
683 | 613 | ||
684 | spin_lock_irqsave(&aaci->lock, flags); | 614 | spin_lock_irqsave(&aacirun->lock, flags); |
615 | |||
685 | switch (cmd) { | 616 | switch (cmd) { |
686 | case SNDRV_PCM_TRIGGER_START: | 617 | case SNDRV_PCM_TRIGGER_START: |
687 | aaci_pcm_playback_start(aacirun); | 618 | aaci_pcm_playback_start(aacirun); |
@@ -708,7 +639,8 @@ static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cm | |||
708 | default: | 639 | default: |
709 | ret = -EINVAL; | 640 | ret = -EINVAL; |
710 | } | 641 | } |
711 | spin_unlock_irqrestore(&aaci->lock, flags); | 642 | |
643 | spin_unlock_irqrestore(&aacirun->lock, flags); | ||
712 | 644 | ||
713 | return ret; | 645 | return ret; |
714 | } | 646 | } |
@@ -722,7 +654,6 @@ static struct snd_pcm_ops aaci_playback_ops = { | |||
722 | .prepare = aaci_pcm_prepare, | 654 | .prepare = aaci_pcm_prepare, |
723 | .trigger = aaci_pcm_playback_trigger, | 655 | .trigger = aaci_pcm_playback_trigger, |
724 | .pointer = aaci_pcm_pointer, | 656 | .pointer = aaci_pcm_pointer, |
725 | .mmap = aaci_pcm_mmap, | ||
726 | }; | 657 | }; |
727 | 658 | ||
728 | static int aaci_pcm_capture_hw_params(struct snd_pcm_substream *substream, | 659 | static int aaci_pcm_capture_hw_params(struct snd_pcm_substream *substream, |
@@ -733,18 +664,10 @@ static int aaci_pcm_capture_hw_params(struct snd_pcm_substream *substream, | |||
733 | int ret; | 664 | int ret; |
734 | 665 | ||
735 | ret = aaci_pcm_hw_params(substream, aacirun, params); | 666 | ret = aaci_pcm_hw_params(substream, aacirun, params); |
736 | 667 | if (ret >= 0) | |
737 | if (ret >= 0) { | ||
738 | aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; | ||
739 | |||
740 | /* Line in record: slot 3 and 4 */ | 668 | /* Line in record: slot 3 and 4 */ |
741 | aacirun->cr |= CR_SL3 | CR_SL4; | 669 | aacirun->cr |= CR_SL3 | CR_SL4; |
742 | 670 | ||
743 | aacirun->fifosz = aaci->fifosize * 4; | ||
744 | |||
745 | if (aacirun->cr & CR_COMPACT) | ||
746 | aacirun->fifosz >>= 1; | ||
747 | } | ||
748 | return ret; | 671 | return ret; |
749 | } | 672 | } |
750 | 673 | ||
@@ -752,7 +675,7 @@ static void aaci_pcm_capture_stop(struct aaci_runtime *aacirun) | |||
752 | { | 675 | { |
753 | u32 ie; | 676 | u32 ie; |
754 | 677 | ||
755 | aaci_chan_wait_ready(aacirun); | 678 | aaci_chan_wait_ready(aacirun, SR_RXB); |
756 | 679 | ||
757 | ie = readl(aacirun->base + AACI_IE); | 680 | ie = readl(aacirun->base + AACI_IE); |
758 | ie &= ~(IE_ORIE | IE_RXIE); | 681 | ie &= ~(IE_ORIE | IE_RXIE); |
@@ -767,7 +690,7 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun) | |||
767 | { | 690 | { |
768 | u32 ie; | 691 | u32 ie; |
769 | 692 | ||
770 | aaci_chan_wait_ready(aacirun); | 693 | aaci_chan_wait_ready(aacirun, SR_RXB); |
771 | 694 | ||
772 | #ifdef DEBUG | 695 | #ifdef DEBUG |
773 | /* RX Timeout value: bits 28:17 in RXCR */ | 696 | /* RX Timeout value: bits 28:17 in RXCR */ |
@@ -784,12 +707,11 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun) | |||
784 | 707 | ||
785 | 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) |
786 | { | 709 | { |
787 | struct aaci *aaci = substream->private_data; | ||
788 | struct aaci_runtime *aacirun = substream->runtime->private_data; | 710 | struct aaci_runtime *aacirun = substream->runtime->private_data; |
789 | unsigned long flags; | 711 | unsigned long flags; |
790 | int ret = 0; | 712 | int ret = 0; |
791 | 713 | ||
792 | spin_lock_irqsave(&aaci->lock, flags); | 714 | spin_lock_irqsave(&aacirun->lock, flags); |
793 | 715 | ||
794 | switch (cmd) { | 716 | switch (cmd) { |
795 | case SNDRV_PCM_TRIGGER_START: | 717 | case SNDRV_PCM_TRIGGER_START: |
@@ -818,7 +740,7 @@ static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd | |||
818 | ret = -EINVAL; | 740 | ret = -EINVAL; |
819 | } | 741 | } |
820 | 742 | ||
821 | spin_unlock_irqrestore(&aaci->lock, flags); | 743 | spin_unlock_irqrestore(&aacirun->lock, flags); |
822 | 744 | ||
823 | return ret; | 745 | return ret; |
824 | } | 746 | } |
@@ -850,7 +772,6 @@ static struct snd_pcm_ops aaci_capture_ops = { | |||
850 | .prepare = aaci_pcm_capture_prepare, | 772 | .prepare = aaci_pcm_capture_prepare, |
851 | .trigger = aaci_pcm_capture_trigger, | 773 | .trigger = aaci_pcm_capture_trigger, |
852 | .pointer = aaci_pcm_pointer, | 774 | .pointer = aaci_pcm_pointer, |
853 | .mmap = aaci_pcm_mmap, | ||
854 | }; | 775 | }; |
855 | 776 | ||
856 | /* | 777 | /* |
@@ -902,6 +823,12 @@ static struct ac97_pcm ac97_defs[] __devinitdata = { | |||
902 | (1 << AC97_SLOT_PCM_SRIGHT) | | 823 | (1 << AC97_SLOT_PCM_SRIGHT) | |
903 | (1 << AC97_SLOT_LFE), | 824 | (1 << AC97_SLOT_LFE), |
904 | }, | 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 | }, | ||
905 | }, | 832 | }, |
906 | }, | 833 | }, |
907 | [1] = { /* PCM in */ | 834 | [1] = { /* PCM in */ |
@@ -1014,7 +941,6 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev) | |||
1014 | 941 | ||
1015 | aaci = card->private_data; | 942 | aaci = card->private_data; |
1016 | mutex_init(&aaci->ac97_sem); | 943 | mutex_init(&aaci->ac97_sem); |
1017 | spin_lock_init(&aaci->lock); | ||
1018 | aaci->card = card; | 944 | aaci->card = card; |
1019 | aaci->dev = dev; | 945 | aaci->dev = dev; |
1020 | 946 | ||
@@ -1040,6 +966,8 @@ static int __devinit aaci_init_pcm(struct aaci *aaci) | |||
1040 | 966 | ||
1041 | 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); |
1042 | 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); |
969 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
970 | NULL, 0, 64 * 1024); | ||
1043 | } | 971 | } |
1044 | 972 | ||
1045 | return ret; | 973 | return ret; |
@@ -1099,12 +1027,14 @@ static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id) | |||
1099 | /* | 1027 | /* |
1100 | * Playback uses AACI channel 0 | 1028 | * Playback uses AACI channel 0 |
1101 | */ | 1029 | */ |
1030 | spin_lock_init(&aaci->playback.lock); | ||
1102 | aaci->playback.base = aaci->base + AACI_CSCH1; | 1031 | aaci->playback.base = aaci->base + AACI_CSCH1; |
1103 | aaci->playback.fifo = aaci->base + AACI_DR1; | 1032 | aaci->playback.fifo = aaci->base + AACI_DR1; |
1104 | 1033 | ||
1105 | /* | 1034 | /* |
1106 | * Capture uses AACI channel 0 | 1035 | * Capture uses AACI channel 0 |
1107 | */ | 1036 | */ |
1037 | spin_lock_init(&aaci->capture.lock); | ||
1108 | aaci->capture.base = aaci->base + AACI_CSCH1; | 1038 | aaci->capture.base = aaci->base + AACI_CSCH1; |
1109 | aaci->capture.fifo = aaci->base + AACI_DR1; | 1039 | aaci->capture.fifo = aaci->base + AACI_DR1; |
1110 | 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/devdma.c b/sound/arm/devdma.c deleted file mode 100644 index 9d1e6665b546..000000000000 --- a/sound/arm/devdma.c +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /* | ||
2 | * linux/sound/arm/devdma.c | ||
3 | * | ||
4 | * Copyright (C) 2003-2004 Russell King, All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * ARM DMA shim for ALSA. | ||
11 | */ | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/dma-mapping.h> | ||
14 | |||
15 | #include <sound/core.h> | ||
16 | #include <sound/pcm.h> | ||
17 | |||
18 | #include "devdma.h" | ||
19 | |||
20 | void devdma_hw_free(struct device *dev, struct snd_pcm_substream *substream) | ||
21 | { | ||
22 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
23 | struct snd_dma_buffer *buf = runtime->dma_buffer_p; | ||
24 | |||
25 | if (runtime->dma_area == NULL) | ||
26 | return; | ||
27 | |||
28 | if (buf != &substream->dma_buffer) { | ||
29 | dma_free_coherent(buf->dev.dev, buf->bytes, buf->area, buf->addr); | ||
30 | kfree(runtime->dma_buffer_p); | ||
31 | } | ||
32 | |||
33 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
34 | } | ||
35 | |||
36 | int devdma_hw_alloc(struct device *dev, struct snd_pcm_substream *substream, size_t size) | ||
37 | { | ||
38 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
39 | struct snd_dma_buffer *buf = runtime->dma_buffer_p; | ||
40 | int ret = 0; | ||
41 | |||
42 | if (buf) { | ||
43 | if (buf->bytes >= size) | ||
44 | goto out; | ||
45 | devdma_hw_free(dev, substream); | ||
46 | } | ||
47 | |||
48 | if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) { | ||
49 | buf = &substream->dma_buffer; | ||
50 | } else { | ||
51 | buf = kmalloc(sizeof(struct snd_dma_buffer), GFP_KERNEL); | ||
52 | if (!buf) | ||
53 | goto nomem; | ||
54 | |||
55 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
56 | buf->dev.dev = dev; | ||
57 | buf->area = dma_alloc_coherent(dev, size, &buf->addr, GFP_KERNEL); | ||
58 | buf->bytes = size; | ||
59 | buf->private_data = NULL; | ||
60 | |||
61 | if (!buf->area) | ||
62 | goto free; | ||
63 | } | ||
64 | snd_pcm_set_runtime_buffer(substream, buf); | ||
65 | ret = 1; | ||
66 | out: | ||
67 | runtime->dma_bytes = size; | ||
68 | return ret; | ||
69 | |||
70 | free: | ||
71 | kfree(buf); | ||
72 | nomem: | ||
73 | return -ENOMEM; | ||
74 | } | ||
75 | |||
76 | int devdma_mmap(struct device *dev, struct snd_pcm_substream *substream, struct vm_area_struct *vma) | ||
77 | { | ||
78 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
79 | return dma_mmap_coherent(dev, vma, runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
80 | } | ||
diff --git a/sound/arm/devdma.h b/sound/arm/devdma.h deleted file mode 100644 index d025329c8a0f..000000000000 --- a/sound/arm/devdma.h +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | void devdma_hw_free(struct device *dev, struct snd_pcm_substream *substream); | ||
2 | int devdma_hw_alloc(struct device *dev, struct snd_pcm_substream *substream, size_t size); | ||
3 | int devdma_mmap(struct device *dev, struct snd_pcm_substream *substream, struct vm_area_struct *vma); | ||
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/control.c b/sound/core/control.c index a8b7fabe645e..268ab7471224 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -75,7 +75,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) | |||
75 | ctl->card = card; | 75 | ctl->card = card; |
76 | ctl->prefer_pcm_subdevice = -1; | 76 | ctl->prefer_pcm_subdevice = -1; |
77 | ctl->prefer_rawmidi_subdevice = -1; | 77 | ctl->prefer_rawmidi_subdevice = -1; |
78 | ctl->pid = current->pid; | 78 | ctl->pid = get_pid(task_pid(current)); |
79 | file->private_data = ctl; | 79 | file->private_data = ctl; |
80 | write_lock_irqsave(&card->ctl_files_rwlock, flags); | 80 | write_lock_irqsave(&card->ctl_files_rwlock, flags); |
81 | list_add_tail(&ctl->list, &card->ctl_files); | 81 | list_add_tail(&ctl->list, &card->ctl_files); |
@@ -125,6 +125,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file) | |||
125 | control->vd[idx].owner = NULL; | 125 | control->vd[idx].owner = NULL; |
126 | up_write(&card->controls_rwsem); | 126 | up_write(&card->controls_rwsem); |
127 | snd_ctl_empty_read_queue(ctl); | 127 | snd_ctl_empty_read_queue(ctl); |
128 | put_pid(ctl->pid); | ||
128 | kfree(ctl); | 129 | kfree(ctl); |
129 | module_put(card->module); | 130 | module_put(card->module); |
130 | snd_card_file_remove(card, file); | 131 | snd_card_file_remove(card, file); |
@@ -672,7 +673,7 @@ static int snd_ctl_elem_info(struct snd_ctl_file *ctl, | |||
672 | info->access |= SNDRV_CTL_ELEM_ACCESS_LOCK; | 673 | info->access |= SNDRV_CTL_ELEM_ACCESS_LOCK; |
673 | if (vd->owner == ctl) | 674 | if (vd->owner == ctl) |
674 | info->access |= SNDRV_CTL_ELEM_ACCESS_OWNER; | 675 | info->access |= SNDRV_CTL_ELEM_ACCESS_OWNER; |
675 | info->owner = vd->owner_pid; | 676 | info->owner = pid_vnr(vd->owner->pid); |
676 | } else { | 677 | } else { |
677 | info->owner = -1; | 678 | info->owner = -1; |
678 | } | 679 | } |
@@ -827,7 +828,6 @@ static int snd_ctl_elem_lock(struct snd_ctl_file *file, | |||
827 | result = -EBUSY; | 828 | result = -EBUSY; |
828 | else { | 829 | else { |
829 | vd->owner = file; | 830 | vd->owner = file; |
830 | vd->owner_pid = current->pid; | ||
831 | result = 0; | 831 | result = 0; |
832 | } | 832 | } |
833 | } | 833 | } |
@@ -858,7 +858,6 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file, | |||
858 | result = -EPERM; | 858 | result = -EPERM; |
859 | else { | 859 | else { |
860 | vd->owner = NULL; | 860 | vd->owner = NULL; |
861 | vd->owner_pid = 0; | ||
862 | result = 0; | 861 | result = 0; |
863 | } | 862 | } |
864 | } | 863 | } |
@@ -1120,7 +1119,7 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, | |||
1120 | goto __kctl_end; | 1119 | goto __kctl_end; |
1121 | } | 1120 | } |
1122 | if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { | 1121 | if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { |
1123 | if (file && vd->owner != NULL && vd->owner != file) { | 1122 | if (vd->owner != NULL && vd->owner != file) { |
1124 | err = -EPERM; | 1123 | err = -EPERM; |
1125 | goto __kctl_end; | 1124 | goto __kctl_end; |
1126 | } | 1125 | } |
diff --git a/sound/core/hrtimer.c b/sound/core/hrtimer.c index 34c7d48f5061..7f4d744ae40a 100644 --- a/sound/core/hrtimer.c +++ b/sound/core/hrtimer.c | |||
@@ -37,14 +37,22 @@ static unsigned int resolution; | |||
37 | struct snd_hrtimer { | 37 | struct snd_hrtimer { |
38 | struct snd_timer *timer; | 38 | struct snd_timer *timer; |
39 | struct hrtimer hrt; | 39 | struct hrtimer hrt; |
40 | atomic_t running; | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) | 43 | static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) |
43 | { | 44 | { |
44 | struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt); | 45 | struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt); |
45 | struct snd_timer *t = stime->timer; | 46 | struct snd_timer *t = stime->timer; |
47 | |||
48 | if (!atomic_read(&stime->running)) | ||
49 | return HRTIMER_NORESTART; | ||
50 | |||
46 | hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution)); | 51 | hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution)); |
47 | snd_timer_interrupt(stime->timer, t->sticks); | 52 | snd_timer_interrupt(stime->timer, t->sticks); |
53 | |||
54 | if (!atomic_read(&stime->running)) | ||
55 | return HRTIMER_NORESTART; | ||
48 | return HRTIMER_RESTART; | 56 | return HRTIMER_RESTART; |
49 | } | 57 | } |
50 | 58 | ||
@@ -58,6 +66,7 @@ static int snd_hrtimer_open(struct snd_timer *t) | |||
58 | hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 66 | hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
59 | stime->timer = t; | 67 | stime->timer = t; |
60 | stime->hrt.function = snd_hrtimer_callback; | 68 | stime->hrt.function = snd_hrtimer_callback; |
69 | atomic_set(&stime->running, 0); | ||
61 | t->private_data = stime; | 70 | t->private_data = stime; |
62 | return 0; | 71 | return 0; |
63 | } | 72 | } |
@@ -78,16 +87,18 @@ static int snd_hrtimer_start(struct snd_timer *t) | |||
78 | { | 87 | { |
79 | struct snd_hrtimer *stime = t->private_data; | 88 | struct snd_hrtimer *stime = t->private_data; |
80 | 89 | ||
90 | atomic_set(&stime->running, 0); | ||
91 | hrtimer_cancel(&stime->hrt); | ||
81 | hrtimer_start(&stime->hrt, ns_to_ktime(t->sticks * resolution), | 92 | hrtimer_start(&stime->hrt, ns_to_ktime(t->sticks * resolution), |
82 | HRTIMER_MODE_REL); | 93 | HRTIMER_MODE_REL); |
94 | atomic_set(&stime->running, 1); | ||
83 | return 0; | 95 | return 0; |
84 | } | 96 | } |
85 | 97 | ||
86 | static int snd_hrtimer_stop(struct snd_timer *t) | 98 | static int snd_hrtimer_stop(struct snd_timer *t) |
87 | { | 99 | { |
88 | struct snd_hrtimer *stime = t->private_data; | 100 | struct snd_hrtimer *stime = t->private_data; |
89 | 101 | atomic_set(&stime->running, 0); | |
90 | hrtimer_cancel(&stime->hrt); | ||
91 | return 0; | 102 | return 0; |
92 | } | 103 | } |
93 | 104 | ||
diff --git a/sound/core/isadma.c b/sound/core/isadma.c index 79f0f16af339..950e19ba91fc 100644 --- a/sound/core/isadma.c +++ b/sound/core/isadma.c | |||
@@ -85,16 +85,24 @@ EXPORT_SYMBOL(snd_dma_disable); | |||
85 | unsigned int snd_dma_pointer(unsigned long dma, unsigned int size) | 85 | unsigned int snd_dma_pointer(unsigned long dma, unsigned int size) |
86 | { | 86 | { |
87 | unsigned long flags; | 87 | unsigned long flags; |
88 | unsigned int result; | 88 | unsigned int result, result1; |
89 | 89 | ||
90 | flags = claim_dma_lock(); | 90 | flags = claim_dma_lock(); |
91 | clear_dma_ff(dma); | 91 | clear_dma_ff(dma); |
92 | if (!isa_dma_bridge_buggy) | 92 | if (!isa_dma_bridge_buggy) |
93 | disable_dma(dma); | 93 | disable_dma(dma); |
94 | result = get_dma_residue(dma); | 94 | result = get_dma_residue(dma); |
95 | /* | ||
96 | * HACK - read the counter again and choose higher value in order to | ||
97 | * avoid reading during counter lower byte roll over if the | ||
98 | * isa_dma_bridge_buggy is set. | ||
99 | */ | ||
100 | result1 = get_dma_residue(dma); | ||
95 | if (!isa_dma_bridge_buggy) | 101 | if (!isa_dma_bridge_buggy) |
96 | enable_dma(dma); | 102 | enable_dma(dma); |
97 | release_dma_lock(flags); | 103 | release_dma_lock(flags); |
104 | if (unlikely(result < result1)) | ||
105 | result = result1; | ||
98 | #ifdef CONFIG_SND_DEBUG | 106 | #ifdef CONFIG_SND_DEBUG |
99 | if (result > size) | 107 | if (result > size) |
100 | snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size); | 108 | snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size); |
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 772423889eb3..54e2eb56e4c2 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c | |||
@@ -1251,7 +1251,9 @@ static void snd_mixer_oss_build(struct snd_mixer_oss *mixer) | |||
1251 | { SOUND_MIXER_SYNTH, "FM", 0 }, /* fallback */ | 1251 | { SOUND_MIXER_SYNTH, "FM", 0 }, /* fallback */ |
1252 | { SOUND_MIXER_SYNTH, "Music", 0 }, /* fallback */ | 1252 | { SOUND_MIXER_SYNTH, "Music", 0 }, /* fallback */ |
1253 | { SOUND_MIXER_PCM, "PCM", 0 }, | 1253 | { SOUND_MIXER_PCM, "PCM", 0 }, |
1254 | { SOUND_MIXER_SPEAKER, "PC Speaker", 0 }, | 1254 | { SOUND_MIXER_SPEAKER, "Beep", 0 }, |
1255 | { SOUND_MIXER_SPEAKER, "PC Speaker", 0 }, /* fallback */ | ||
1256 | { SOUND_MIXER_SPEAKER, "Speaker", 0 }, /* fallback */ | ||
1255 | { SOUND_MIXER_LINE, "Line", 0 }, | 1257 | { SOUND_MIXER_LINE, "Line", 0 }, |
1256 | { SOUND_MIXER_MIC, "Mic", 0 }, | 1258 | { SOUND_MIXER_MIC, "Mic", 0 }, |
1257 | { SOUND_MIXER_CD, "CD", 0 }, | 1259 | { SOUND_MIXER_CD, "CD", 0 }, |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index c69c60b2a48a..6884ae031f6f 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -435,6 +435,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry, | |||
435 | return; | 435 | return; |
436 | } | 436 | } |
437 | snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state)); | 437 | snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state)); |
438 | snd_iprintf(buffer, "owner_pid : %d\n", pid_vnr(substream->pid)); | ||
438 | snd_iprintf(buffer, "trigger_time: %ld.%09ld\n", | 439 | snd_iprintf(buffer, "trigger_time: %ld.%09ld\n", |
439 | status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec); | 440 | status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec); |
440 | snd_iprintf(buffer, "tstamp : %ld.%09ld\n", | 441 | snd_iprintf(buffer, "tstamp : %ld.%09ld\n", |
@@ -809,7 +810,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, | |||
809 | card = pcm->card; | 810 | card = pcm->card; |
810 | read_lock(&card->ctl_files_rwlock); | 811 | read_lock(&card->ctl_files_rwlock); |
811 | list_for_each_entry(kctl, &card->ctl_files, list) { | 812 | list_for_each_entry(kctl, &card->ctl_files, list) { |
812 | if (kctl->pid == current->pid) { | 813 | if (kctl->pid == task_pid(current)) { |
813 | prefer_subdevice = kctl->prefer_pcm_subdevice; | 814 | prefer_subdevice = kctl->prefer_pcm_subdevice; |
814 | if (prefer_subdevice != -1) | 815 | if (prefer_subdevice != -1) |
815 | break; | 816 | break; |
@@ -900,6 +901,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, | |||
900 | substream->private_data = pcm->private_data; | 901 | substream->private_data = pcm->private_data; |
901 | substream->ref_count = 1; | 902 | substream->ref_count = 1; |
902 | substream->f_flags = file->f_flags; | 903 | substream->f_flags = file->f_flags; |
904 | substream->pid = get_pid(task_pid(current)); | ||
903 | pstr->substream_opened++; | 905 | pstr->substream_opened++; |
904 | *rsubstream = substream; | 906 | *rsubstream = substream; |
905 | return 0; | 907 | return 0; |
@@ -921,6 +923,8 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream) | |||
921 | kfree(runtime->hw_constraints.rules); | 923 | kfree(runtime->hw_constraints.rules); |
922 | kfree(runtime); | 924 | kfree(runtime); |
923 | substream->runtime = NULL; | 925 | substream->runtime = NULL; |
926 | put_pid(substream->pid); | ||
927 | substream->pid = NULL; | ||
924 | substream->pstr->substream_opened--; | 928 | substream->pstr->substream_opened--; |
925 | } | 929 | } |
926 | 930 | ||
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 30f410832a25..a27545b23ee9 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -758,7 +758,7 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
758 | int diff; | 758 | int diff; |
759 | if (q == 0) | 759 | if (q == 0) |
760 | q = 1; | 760 | q = 1; |
761 | den = div_down(num, q); | 761 | den = div_up(num, q); |
762 | if (den < rats[k].den_min) | 762 | if (den < rats[k].den_min) |
763 | continue; | 763 | continue; |
764 | if (den > rats[k].den_max) | 764 | if (den > rats[k].den_max) |
@@ -794,7 +794,7 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
794 | i->empty = 1; | 794 | i->empty = 1; |
795 | return -EINVAL; | 795 | return -EINVAL; |
796 | } | 796 | } |
797 | den = div_up(num, q); | 797 | den = div_down(num, q); |
798 | if (den > rats[k].den_max) | 798 | if (den > rats[k].den_max) |
799 | continue; | 799 | continue; |
800 | if (den < rats[k].den_min) | 800 | if (den < rats[k].den_min) |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index ab73edf2c89a..29ab46a12e11 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/pm_qos_params.h> | 27 | #include <linux/pm_qos_params.h> |
28 | #include <linux/uio.h> | 28 | #include <linux/uio.h> |
29 | #include <linux/dma-mapping.h> | ||
29 | #include <sound/core.h> | 30 | #include <sound/core.h> |
30 | #include <sound/control.h> | 31 | #include <sound/control.h> |
31 | #include <sound/info.h> | 32 | #include <sound/info.h> |
@@ -3061,6 +3062,27 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file | |||
3061 | } | 3062 | } |
3062 | #endif /* coherent mmap */ | 3063 | #endif /* coherent mmap */ |
3063 | 3064 | ||
3065 | static inline struct page * | ||
3066 | snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) | ||
3067 | { | ||
3068 | void *vaddr = substream->runtime->dma_area + ofs; | ||
3069 | #if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT) | ||
3070 | if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) | ||
3071 | return virt_to_page(CAC_ADDR(vaddr)); | ||
3072 | #endif | ||
3073 | #if defined(CONFIG_PPC32) && defined(CONFIG_NOT_COHERENT_CACHE) | ||
3074 | if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) { | ||
3075 | dma_addr_t addr = substream->runtime->dma_addr + ofs; | ||
3076 | addr -= get_dma_offset(substream->dma_buffer.dev.dev); | ||
3077 | /* assume dma_handle set via pfn_to_phys() in | ||
3078 | * mm/dma-noncoherent.c | ||
3079 | */ | ||
3080 | return pfn_to_page(addr >> PAGE_SHIFT); | ||
3081 | } | ||
3082 | #endif | ||
3083 | return virt_to_page(vaddr); | ||
3084 | } | ||
3085 | |||
3064 | /* | 3086 | /* |
3065 | * fault callback for mmapping a RAM page | 3087 | * fault callback for mmapping a RAM page |
3066 | */ | 3088 | */ |
@@ -3071,7 +3093,6 @@ static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, | |||
3071 | struct snd_pcm_runtime *runtime; | 3093 | struct snd_pcm_runtime *runtime; |
3072 | unsigned long offset; | 3094 | unsigned long offset; |
3073 | struct page * page; | 3095 | struct page * page; |
3074 | void *vaddr; | ||
3075 | size_t dma_bytes; | 3096 | size_t dma_bytes; |
3076 | 3097 | ||
3077 | if (substream == NULL) | 3098 | if (substream == NULL) |
@@ -3081,36 +3102,53 @@ static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, | |||
3081 | dma_bytes = PAGE_ALIGN(runtime->dma_bytes); | 3102 | dma_bytes = PAGE_ALIGN(runtime->dma_bytes); |
3082 | if (offset > dma_bytes - PAGE_SIZE) | 3103 | if (offset > dma_bytes - PAGE_SIZE) |
3083 | return VM_FAULT_SIGBUS; | 3104 | return VM_FAULT_SIGBUS; |
3084 | if (substream->ops->page) { | 3105 | if (substream->ops->page) |
3085 | page = substream->ops->page(substream, offset); | 3106 | page = substream->ops->page(substream, offset); |
3086 | if (!page) | 3107 | else |
3087 | return VM_FAULT_SIGBUS; | 3108 | page = snd_pcm_default_page_ops(substream, offset); |
3088 | } else { | 3109 | if (!page) |
3089 | vaddr = runtime->dma_area + offset; | 3110 | return VM_FAULT_SIGBUS; |
3090 | page = virt_to_page(vaddr); | ||
3091 | } | ||
3092 | get_page(page); | 3111 | get_page(page); |
3093 | vmf->page = page; | 3112 | vmf->page = page; |
3094 | return 0; | 3113 | return 0; |
3095 | } | 3114 | } |
3096 | 3115 | ||
3097 | static const struct vm_operations_struct snd_pcm_vm_ops_data = | 3116 | static const struct vm_operations_struct snd_pcm_vm_ops_data = { |
3098 | { | 3117 | .open = snd_pcm_mmap_data_open, |
3118 | .close = snd_pcm_mmap_data_close, | ||
3119 | }; | ||
3120 | |||
3121 | static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = { | ||
3099 | .open = snd_pcm_mmap_data_open, | 3122 | .open = snd_pcm_mmap_data_open, |
3100 | .close = snd_pcm_mmap_data_close, | 3123 | .close = snd_pcm_mmap_data_close, |
3101 | .fault = snd_pcm_mmap_data_fault, | 3124 | .fault = snd_pcm_mmap_data_fault, |
3102 | }; | 3125 | }; |
3103 | 3126 | ||
3127 | #ifndef ARCH_HAS_DMA_MMAP_COHERENT | ||
3128 | /* This should be defined / handled globally! */ | ||
3129 | #ifdef CONFIG_ARM | ||
3130 | #define ARCH_HAS_DMA_MMAP_COHERENT | ||
3131 | #endif | ||
3132 | #endif | ||
3133 | |||
3104 | /* | 3134 | /* |
3105 | * mmap the DMA buffer on RAM | 3135 | * mmap the DMA buffer on RAM |
3106 | */ | 3136 | */ |
3107 | static int snd_pcm_default_mmap(struct snd_pcm_substream *substream, | 3137 | static int snd_pcm_default_mmap(struct snd_pcm_substream *substream, |
3108 | struct vm_area_struct *area) | 3138 | struct vm_area_struct *area) |
3109 | { | 3139 | { |
3110 | area->vm_ops = &snd_pcm_vm_ops_data; | ||
3111 | area->vm_private_data = substream; | ||
3112 | area->vm_flags |= VM_RESERVED; | 3140 | area->vm_flags |= VM_RESERVED; |
3113 | atomic_inc(&substream->mmap_count); | 3141 | #ifdef ARCH_HAS_DMA_MMAP_COHERENT |
3142 | if (!substream->ops->page && | ||
3143 | substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) | ||
3144 | return dma_mmap_coherent(substream->dma_buffer.dev.dev, | ||
3145 | area, | ||
3146 | substream->runtime->dma_area, | ||
3147 | substream->runtime->dma_addr, | ||
3148 | area->vm_end - area->vm_start); | ||
3149 | #endif /* ARCH_HAS_DMA_MMAP_COHERENT */ | ||
3150 | /* mmap with fault handler */ | ||
3151 | area->vm_ops = &snd_pcm_vm_ops_data_fault; | ||
3114 | return 0; | 3152 | return 0; |
3115 | } | 3153 | } |
3116 | 3154 | ||
@@ -3118,12 +3156,6 @@ static int snd_pcm_default_mmap(struct snd_pcm_substream *substream, | |||
3118 | * mmap the DMA buffer on I/O memory area | 3156 | * mmap the DMA buffer on I/O memory area |
3119 | */ | 3157 | */ |
3120 | #if SNDRV_PCM_INFO_MMAP_IOMEM | 3158 | #if SNDRV_PCM_INFO_MMAP_IOMEM |
3121 | static const struct vm_operations_struct snd_pcm_vm_ops_data_mmio = | ||
3122 | { | ||
3123 | .open = snd_pcm_mmap_data_open, | ||
3124 | .close = snd_pcm_mmap_data_close, | ||
3125 | }; | ||
3126 | |||
3127 | int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, | 3159 | int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, |
3128 | struct vm_area_struct *area) | 3160 | struct vm_area_struct *area) |
3129 | { | 3161 | { |
@@ -3133,8 +3165,6 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, | |||
3133 | #ifdef pgprot_noncached | 3165 | #ifdef pgprot_noncached |
3134 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); | 3166 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); |
3135 | #endif | 3167 | #endif |
3136 | area->vm_ops = &snd_pcm_vm_ops_data_mmio; | ||
3137 | area->vm_private_data = substream; | ||
3138 | area->vm_flags |= VM_IO; | 3168 | area->vm_flags |= VM_IO; |
3139 | size = area->vm_end - area->vm_start; | 3169 | size = area->vm_end - area->vm_start; |
3140 | offset = area->vm_pgoff << PAGE_SHIFT; | 3170 | offset = area->vm_pgoff << PAGE_SHIFT; |
@@ -3142,7 +3172,6 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, | |||
3142 | (substream->runtime->dma_addr + offset) >> PAGE_SHIFT, | 3172 | (substream->runtime->dma_addr + offset) >> PAGE_SHIFT, |
3143 | size, area->vm_page_prot)) | 3173 | size, area->vm_page_prot)) |
3144 | return -EAGAIN; | 3174 | return -EAGAIN; |
3145 | atomic_inc(&substream->mmap_count); | ||
3146 | return 0; | 3175 | return 0; |
3147 | } | 3176 | } |
3148 | 3177 | ||
@@ -3159,6 +3188,7 @@ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, | |||
3159 | long size; | 3188 | long size; |
3160 | unsigned long offset; | 3189 | unsigned long offset; |
3161 | size_t dma_bytes; | 3190 | size_t dma_bytes; |
3191 | int err; | ||
3162 | 3192 | ||
3163 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 3193 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
3164 | if (!(area->vm_flags & (VM_WRITE|VM_READ))) | 3194 | if (!(area->vm_flags & (VM_WRITE|VM_READ))) |
@@ -3183,10 +3213,15 @@ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, | |||
3183 | if (offset > dma_bytes - size) | 3213 | if (offset > dma_bytes - size) |
3184 | return -EINVAL; | 3214 | return -EINVAL; |
3185 | 3215 | ||
3216 | area->vm_ops = &snd_pcm_vm_ops_data; | ||
3217 | area->vm_private_data = substream; | ||
3186 | if (substream->ops->mmap) | 3218 | if (substream->ops->mmap) |
3187 | return substream->ops->mmap(substream, area); | 3219 | err = substream->ops->mmap(substream, area); |
3188 | else | 3220 | else |
3189 | return snd_pcm_default_mmap(substream, area); | 3221 | err = snd_pcm_default_mmap(substream, area); |
3222 | if (!err) | ||
3223 | atomic_inc(&substream->mmap_count); | ||
3224 | return err; | ||
3190 | } | 3225 | } |
3191 | 3226 | ||
3192 | EXPORT_SYMBOL(snd_pcm_mmap_data); | 3227 | EXPORT_SYMBOL(snd_pcm_mmap_data); |
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/core/rawmidi.c b/sound/core/rawmidi.c index c0adc14c91f0..0f5a194695d9 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -242,13 +242,12 @@ static int assign_substream(struct snd_rawmidi *rmidi, int subdevice, | |||
242 | return -ENXIO; | 242 | return -ENXIO; |
243 | if (subdevice >= 0 && subdevice >= s->substream_count) | 243 | if (subdevice >= 0 && subdevice >= s->substream_count) |
244 | return -ENODEV; | 244 | return -ENODEV; |
245 | if (s->substream_opened >= s->substream_count) | ||
246 | return -EAGAIN; | ||
247 | 245 | ||
248 | list_for_each_entry(substream, &s->substreams, list) { | 246 | list_for_each_entry(substream, &s->substreams, list) { |
249 | if (substream->opened) { | 247 | if (substream->opened) { |
250 | if (stream == SNDRV_RAWMIDI_STREAM_INPUT || | 248 | if (stream == SNDRV_RAWMIDI_STREAM_INPUT || |
251 | !(mode & SNDRV_RAWMIDI_LFLG_APPEND)) | 249 | !(mode & SNDRV_RAWMIDI_LFLG_APPEND) || |
250 | !substream->append) | ||
252 | continue; | 251 | continue; |
253 | } | 252 | } |
254 | if (subdevice < 0 || subdevice == substream->number) { | 253 | if (subdevice < 0 || subdevice == substream->number) { |
@@ -266,18 +265,23 @@ static int open_substream(struct snd_rawmidi *rmidi, | |||
266 | { | 265 | { |
267 | int err; | 266 | int err; |
268 | 267 | ||
269 | err = snd_rawmidi_runtime_create(substream); | 268 | if (substream->use_count == 0) { |
270 | if (err < 0) | 269 | err = snd_rawmidi_runtime_create(substream); |
271 | return err; | 270 | if (err < 0) |
272 | err = substream->ops->open(substream); | 271 | return err; |
273 | if (err < 0) | 272 | err = substream->ops->open(substream); |
274 | return err; | 273 | if (err < 0) { |
275 | substream->opened = 1; | 274 | snd_rawmidi_runtime_free(substream); |
276 | if (substream->use_count++ == 0) | 275 | return err; |
276 | } | ||
277 | substream->opened = 1; | ||
277 | substream->active_sensing = 0; | 278 | substream->active_sensing = 0; |
278 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) | 279 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) |
279 | substream->append = 1; | 280 | substream->append = 1; |
280 | rmidi->streams[substream->stream].substream_opened++; | 281 | substream->pid = get_pid(task_pid(current)); |
282 | rmidi->streams[substream->stream].substream_opened++; | ||
283 | } | ||
284 | substream->use_count++; | ||
281 | return 0; | 285 | return 0; |
282 | } | 286 | } |
283 | 287 | ||
@@ -297,27 +301,27 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode, | |||
297 | SNDRV_RAWMIDI_STREAM_INPUT, | 301 | SNDRV_RAWMIDI_STREAM_INPUT, |
298 | mode, &sinput); | 302 | mode, &sinput); |
299 | if (err < 0) | 303 | if (err < 0) |
300 | goto __error; | 304 | return err; |
301 | } | 305 | } |
302 | if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { | 306 | if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { |
303 | err = assign_substream(rmidi, subdevice, | 307 | err = assign_substream(rmidi, subdevice, |
304 | SNDRV_RAWMIDI_STREAM_OUTPUT, | 308 | SNDRV_RAWMIDI_STREAM_OUTPUT, |
305 | mode, &soutput); | 309 | mode, &soutput); |
306 | if (err < 0) | 310 | if (err < 0) |
307 | goto __error; | 311 | return err; |
308 | } | 312 | } |
309 | 313 | ||
310 | if (sinput) { | 314 | if (sinput) { |
311 | err = open_substream(rmidi, sinput, mode); | 315 | err = open_substream(rmidi, sinput, mode); |
312 | if (err < 0) | 316 | if (err < 0) |
313 | goto __error; | 317 | return err; |
314 | } | 318 | } |
315 | if (soutput) { | 319 | if (soutput) { |
316 | err = open_substream(rmidi, soutput, mode); | 320 | err = open_substream(rmidi, soutput, mode); |
317 | if (err < 0) { | 321 | if (err < 0) { |
318 | if (sinput) | 322 | if (sinput) |
319 | close_substream(rmidi, sinput, 0); | 323 | close_substream(rmidi, sinput, 0); |
320 | goto __error; | 324 | return err; |
321 | } | 325 | } |
322 | } | 326 | } |
323 | 327 | ||
@@ -325,13 +329,6 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode, | |||
325 | rfile->input = sinput; | 329 | rfile->input = sinput; |
326 | rfile->output = soutput; | 330 | rfile->output = soutput; |
327 | return 0; | 331 | return 0; |
328 | |||
329 | __error: | ||
330 | if (sinput && sinput->runtime) | ||
331 | snd_rawmidi_runtime_free(sinput); | ||
332 | if (soutput && soutput->runtime) | ||
333 | snd_rawmidi_runtime_free(soutput); | ||
334 | return err; | ||
335 | } | 332 | } |
336 | 333 | ||
337 | /* called from sound/core/seq/seq_midi.c */ | 334 | /* called from sound/core/seq/seq_midi.c */ |
@@ -415,7 +412,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
415 | subdevice = -1; | 412 | subdevice = -1; |
416 | read_lock(&card->ctl_files_rwlock); | 413 | read_lock(&card->ctl_files_rwlock); |
417 | list_for_each_entry(kctl, &card->ctl_files, list) { | 414 | list_for_each_entry(kctl, &card->ctl_files, list) { |
418 | if (kctl->pid == current->pid) { | 415 | if (kctl->pid == task_pid(current)) { |
419 | subdevice = kctl->prefer_rawmidi_subdevice; | 416 | subdevice = kctl->prefer_rawmidi_subdevice; |
420 | if (subdevice != -1) | 417 | if (subdevice != -1) |
421 | break; | 418 | break; |
@@ -468,7 +465,6 @@ static void close_substream(struct snd_rawmidi *rmidi, | |||
468 | struct snd_rawmidi_substream *substream, | 465 | struct snd_rawmidi_substream *substream, |
469 | int cleanup) | 466 | int cleanup) |
470 | { | 467 | { |
471 | rmidi->streams[substream->stream].substream_opened--; | ||
472 | if (--substream->use_count) | 468 | if (--substream->use_count) |
473 | return; | 469 | return; |
474 | 470 | ||
@@ -493,6 +489,9 @@ static void close_substream(struct snd_rawmidi *rmidi, | |||
493 | snd_rawmidi_runtime_free(substream); | 489 | snd_rawmidi_runtime_free(substream); |
494 | substream->opened = 0; | 490 | substream->opened = 0; |
495 | substream->append = 0; | 491 | substream->append = 0; |
492 | put_pid(substream->pid); | ||
493 | substream->pid = NULL; | ||
494 | rmidi->streams[substream->stream].substream_opened--; | ||
496 | } | 495 | } |
497 | 496 | ||
498 | static void rawmidi_release_priv(struct snd_rawmidi_file *rfile) | 497 | static void rawmidi_release_priv(struct snd_rawmidi_file *rfile) |
@@ -1258,7 +1257,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, | |||
1258 | break; | 1257 | break; |
1259 | count -= count1; | 1258 | count -= count1; |
1260 | } | 1259 | } |
1261 | if (file->f_flags & O_SYNC) { | 1260 | if (file->f_flags & O_DSYNC) { |
1262 | spin_lock_irq(&runtime->lock); | 1261 | spin_lock_irq(&runtime->lock); |
1263 | while (runtime->avail != runtime->buffer_size) { | 1262 | while (runtime->avail != runtime->buffer_size) { |
1264 | wait_queue_t wait; | 1263 | wait_queue_t wait; |
@@ -1340,6 +1339,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, | |||
1340 | substream->number, | 1339 | substream->number, |
1341 | (unsigned long) substream->bytes); | 1340 | (unsigned long) substream->bytes); |
1342 | if (substream->opened) { | 1341 | if (substream->opened) { |
1342 | snd_iprintf(buffer, | ||
1343 | " Owner PID : %d\n", | ||
1344 | pid_vnr(substream->pid)); | ||
1343 | runtime = substream->runtime; | 1345 | runtime = substream->runtime; |
1344 | snd_iprintf(buffer, | 1346 | snd_iprintf(buffer, |
1345 | " Mode : %s\n" | 1347 | " Mode : %s\n" |
@@ -1361,6 +1363,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, | |||
1361 | substream->number, | 1363 | substream->number, |
1362 | (unsigned long) substream->bytes); | 1364 | (unsigned long) substream->bytes); |
1363 | if (substream->opened) { | 1365 | if (substream->opened) { |
1366 | snd_iprintf(buffer, | ||
1367 | " Owner PID : %d\n", | ||
1368 | pid_vnr(substream->pid)); | ||
1364 | runtime = substream->runtime; | 1369 | runtime = substream->runtime; |
1365 | snd_iprintf(buffer, | 1370 | snd_iprintf(buffer, |
1366 | " Buffer size : %lu\n" | 1371 | " Buffer size : %lu\n" |
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index b60cef257b58..f165c77d6273 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c | |||
@@ -26,6 +26,7 @@ MODULE_ALIAS("platform:pcspkr"); | |||
26 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ | 26 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ |
27 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ | 27 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ |
28 | static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ | 28 | static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ |
29 | static int nopcm; /* Disable PCM capability of the driver */ | ||
29 | 30 | ||
30 | module_param(index, int, 0444); | 31 | module_param(index, int, 0444); |
31 | MODULE_PARM_DESC(index, "Index value for pcsp soundcard."); | 32 | MODULE_PARM_DESC(index, "Index value for pcsp soundcard."); |
@@ -33,6 +34,8 @@ module_param(id, charp, 0444); | |||
33 | MODULE_PARM_DESC(id, "ID string for pcsp soundcard."); | 34 | MODULE_PARM_DESC(id, "ID string for pcsp soundcard."); |
34 | module_param(enable, bool, 0444); | 35 | module_param(enable, bool, 0444); |
35 | MODULE_PARM_DESC(enable, "Enable PC-Speaker sound."); | 36 | MODULE_PARM_DESC(enable, "Enable PC-Speaker sound."); |
37 | module_param(nopcm, bool, 0444); | ||
38 | MODULE_PARM_DESC(nopcm, "Disable PC-Speaker PCM sound. Only beeps remain."); | ||
36 | 39 | ||
37 | struct snd_pcsp pcsp_chip; | 40 | struct snd_pcsp pcsp_chip; |
38 | 41 | ||
@@ -43,13 +46,16 @@ static int __devinit snd_pcsp_create(struct snd_card *card) | |||
43 | int err; | 46 | int err; |
44 | int div, min_div, order; | 47 | int div, min_div, order; |
45 | 48 | ||
46 | hrtimer_get_res(CLOCK_MONOTONIC, &tp); | 49 | if (!nopcm) { |
47 | if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { | 50 | hrtimer_get_res(CLOCK_MONOTONIC, &tp); |
48 | printk(KERN_ERR "PCSP: Timer resolution is not sufficient " | 51 | if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { |
49 | "(%linS)\n", tp.tv_nsec); | 52 | printk(KERN_ERR "PCSP: Timer resolution is not sufficient " |
50 | printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI " | 53 | "(%linS)\n", tp.tv_nsec); |
51 | "enabled.\n"); | 54 | printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI " |
52 | return -EIO; | 55 | "enabled.\n"); |
56 | printk(KERN_ERR "PCSP: Turned into nopcm mode.\n"); | ||
57 | nopcm = 1; | ||
58 | } | ||
53 | } | 59 | } |
54 | 60 | ||
55 | if (loops_per_jiffy >= PCSP_MIN_LPJ && tp.tv_nsec <= PCSP_MIN_PERIOD_NS) | 61 | if (loops_per_jiffy >= PCSP_MIN_LPJ && tp.tv_nsec <= PCSP_MIN_PERIOD_NS) |
@@ -107,12 +113,14 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev) | |||
107 | snd_card_free(card); | 113 | snd_card_free(card); |
108 | return err; | 114 | return err; |
109 | } | 115 | } |
110 | err = snd_pcsp_new_pcm(&pcsp_chip); | 116 | if (!nopcm) { |
111 | if (err < 0) { | 117 | err = snd_pcsp_new_pcm(&pcsp_chip); |
112 | snd_card_free(card); | 118 | if (err < 0) { |
113 | return err; | 119 | snd_card_free(card); |
120 | return err; | ||
121 | } | ||
114 | } | 122 | } |
115 | err = snd_pcsp_new_mixer(&pcsp_chip); | 123 | err = snd_pcsp_new_mixer(&pcsp_chip, nopcm); |
116 | if (err < 0) { | 124 | if (err < 0) { |
117 | snd_card_free(card); | 125 | snd_card_free(card); |
118 | return err; | 126 | return err; |
diff --git a/sound/drivers/pcsp/pcsp.h b/sound/drivers/pcsp/pcsp.h index 174dd2ff0f22..1e123077923d 100644 --- a/sound/drivers/pcsp/pcsp.h +++ b/sound/drivers/pcsp/pcsp.h | |||
@@ -83,6 +83,6 @@ extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle); | |||
83 | extern void pcsp_sync_stop(struct snd_pcsp *chip); | 83 | extern void pcsp_sync_stop(struct snd_pcsp *chip); |
84 | 84 | ||
85 | extern int snd_pcsp_new_pcm(struct snd_pcsp *chip); | 85 | extern int snd_pcsp_new_pcm(struct snd_pcsp *chip); |
86 | extern int snd_pcsp_new_mixer(struct snd_pcsp *chip); | 86 | extern int snd_pcsp_new_mixer(struct snd_pcsp *chip, int nopcm); |
87 | 87 | ||
88 | #endif | 88 | #endif |
diff --git a/sound/drivers/pcsp/pcsp_mixer.c b/sound/drivers/pcsp/pcsp_mixer.c index 903bc846763f..6f633f4f3b96 100644 --- a/sound/drivers/pcsp/pcsp_mixer.c +++ b/sound/drivers/pcsp/pcsp_mixer.c | |||
@@ -119,24 +119,43 @@ static int pcsp_pcspkr_put(struct snd_kcontrol *kcontrol, | |||
119 | .put = pcsp_##ctl_type##_put, \ | 119 | .put = pcsp_##ctl_type##_put, \ |
120 | } | 120 | } |
121 | 121 | ||
122 | static struct snd_kcontrol_new __devinitdata snd_pcsp_controls[] = { | 122 | static struct snd_kcontrol_new __devinitdata snd_pcsp_controls_pcm[] = { |
123 | PCSP_MIXER_CONTROL(enable, "Master Playback Switch"), | 123 | PCSP_MIXER_CONTROL(enable, "Master Playback Switch"), |
124 | PCSP_MIXER_CONTROL(treble, "BaseFRQ Playback Volume"), | 124 | PCSP_MIXER_CONTROL(treble, "BaseFRQ Playback Volume"), |
125 | PCSP_MIXER_CONTROL(pcspkr, "PC Speaker Playback Switch"), | ||
126 | }; | 125 | }; |
127 | 126 | ||
128 | int __devinit snd_pcsp_new_mixer(struct snd_pcsp *chip) | 127 | static struct snd_kcontrol_new __devinitdata snd_pcsp_controls_spkr[] = { |
128 | PCSP_MIXER_CONTROL(pcspkr, "Beep Playback Switch"), | ||
129 | }; | ||
130 | |||
131 | static int __devinit snd_pcsp_ctls_add(struct snd_pcsp *chip, | ||
132 | struct snd_kcontrol_new *ctls, int num) | ||
129 | { | 133 | { |
130 | struct snd_card *card = chip->card; | ||
131 | int i, err; | 134 | int i, err; |
135 | struct snd_card *card = chip->card; | ||
136 | for (i = 0; i < num; i++) { | ||
137 | err = snd_ctl_add(card, snd_ctl_new1(ctls + i, chip)); | ||
138 | if (err < 0) | ||
139 | return err; | ||
140 | } | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | int __devinit snd_pcsp_new_mixer(struct snd_pcsp *chip, int nopcm) | ||
145 | { | ||
146 | int err; | ||
147 | struct snd_card *card = chip->card; | ||
132 | 148 | ||
133 | for (i = 0; i < ARRAY_SIZE(snd_pcsp_controls); i++) { | 149 | if (!nopcm) { |
134 | err = snd_ctl_add(card, | 150 | err = snd_pcsp_ctls_add(chip, snd_pcsp_controls_pcm, |
135 | snd_ctl_new1(snd_pcsp_controls + i, | 151 | ARRAY_SIZE(snd_pcsp_controls_pcm)); |
136 | chip)); | ||
137 | if (err < 0) | 152 | if (err < 0) |
138 | return err; | 153 | return err; |
139 | } | 154 | } |
155 | err = snd_pcsp_ctls_add(chip, snd_pcsp_controls_spkr, | ||
156 | ARRAY_SIZE(snd_pcsp_controls_spkr)); | ||
157 | if (err < 0) | ||
158 | return err; | ||
140 | 159 | ||
141 | strcpy(card->mixername, "PC-Speaker"); | 160 | strcpy(card->mixername, "PC-Speaker"); |
142 | 161 | ||
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index 020a5d512472..04ae8704cdcd 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/bitrev.h> | ||
26 | #include <asm/unaligned.h> | 27 | #include <asm/unaligned.h> |
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include <sound/control.h> | 29 | #include <sound/control.h> |
@@ -55,18 +56,6 @@ struct cs8427 { | |||
55 | struct cs8427_stream capture; | 56 | struct cs8427_stream capture; |
56 | }; | 57 | }; |
57 | 58 | ||
58 | static unsigned char swapbits(unsigned char val) | ||
59 | { | ||
60 | int bit; | ||
61 | unsigned char res = 0; | ||
62 | for (bit = 0; bit < 8; bit++) { | ||
63 | res <<= 1; | ||
64 | res |= val & 1; | ||
65 | val >>= 1; | ||
66 | } | ||
67 | return res; | ||
68 | } | ||
69 | |||
70 | int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, | 59 | int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, |
71 | unsigned char val) | 60 | unsigned char val) |
72 | { | 61 | { |
@@ -149,7 +138,7 @@ static int snd_cs8427_send_corudata(struct snd_i2c_device *device, | |||
149 | } | 138 | } |
150 | data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF; | 139 | data[0] = CS8427_REG_AUTOINC | CS8427_REG_CORU_DATABUF; |
151 | for (idx = 0; idx < count; idx++) | 140 | for (idx = 0; idx < count; idx++) |
152 | data[idx + 1] = swapbits(ndata[idx]); | 141 | data[idx + 1] = bitrev8(ndata[idx]); |
153 | if (snd_i2c_sendbytes(device, data, count + 1) != count + 1) | 142 | if (snd_i2c_sendbytes(device, data, count + 1) != count + 1) |
154 | return -EIO; | 143 | return -EIO; |
155 | return 1; | 144 | return 1; |
diff --git a/sound/i2c/other/Makefile b/sound/i2c/other/Makefile index 703d954238f4..2dad40f3f622 100644 --- a/sound/i2c/other/Makefile +++ b/sound/i2c/other/Makefile | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | snd-ak4114-objs := ak4114.o | 6 | snd-ak4114-objs := ak4114.o |
7 | snd-ak4117-objs := ak4117.o | 7 | snd-ak4117-objs := ak4117.o |
8 | snd-ak4113-objs := ak4113.o | ||
8 | snd-ak4xxx-adda-objs := ak4xxx-adda.o | 9 | snd-ak4xxx-adda-objs := ak4xxx-adda.o |
9 | snd-pt2258-objs := pt2258.o | 10 | snd-pt2258-objs := pt2258.o |
10 | snd-tea575x-tuner-objs := tea575x-tuner.o | 11 | snd-tea575x-tuner-objs := tea575x-tuner.o |
@@ -12,5 +13,5 @@ snd-tea575x-tuner-objs := tea575x-tuner.o | |||
12 | # Module Dependency | 13 | # Module Dependency |
13 | obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o | 14 | obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o |
14 | obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o | 15 | obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o |
15 | obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4xxx-adda.o snd-pt2258.o | 16 | obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4113.o snd-ak4xxx-adda.o snd-pt2258.o |
16 | obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o | 17 | obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o |
diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c new file mode 100644 index 000000000000..fff62cc8607c --- /dev/null +++ b/sound/i2c/other/ak4113.c | |||
@@ -0,0 +1,639 @@ | |||
1 | /* | ||
2 | * Routines for control of the AK4113 via I2C/4-wire serial interface | ||
3 | * IEC958 (S/PDIF) receiver by Asahi Kasei | ||
4 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> | ||
5 | * Copyright (c) by Pavel Hofman <pavel.hofman@ivitera.com> | ||
6 | * | ||
7 | * | ||
8 | * 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 | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/slab.h> | ||
25 | #include <linux/delay.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/control.h> | ||
28 | #include <sound/pcm.h> | ||
29 | #include <sound/ak4113.h> | ||
30 | #include <sound/asoundef.h> | ||
31 | #include <sound/info.h> | ||
32 | |||
33 | MODULE_AUTHOR("Pavel Hofman <pavel.hofman@ivitera.com>"); | ||
34 | MODULE_DESCRIPTION("AK4113 IEC958 (S/PDIF) receiver by Asahi Kasei"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | |||
37 | #define AK4113_ADDR 0x00 /* fixed address */ | ||
38 | |||
39 | static void ak4113_stats(struct work_struct *work); | ||
40 | static void ak4113_init_regs(struct ak4113 *chip); | ||
41 | |||
42 | |||
43 | static void reg_write(struct ak4113 *ak4113, unsigned char reg, | ||
44 | unsigned char val) | ||
45 | { | ||
46 | ak4113->write(ak4113->private_data, reg, val); | ||
47 | if (reg < sizeof(ak4113->regmap)) | ||
48 | ak4113->regmap[reg] = val; | ||
49 | } | ||
50 | |||
51 | static inline unsigned char reg_read(struct ak4113 *ak4113, unsigned char reg) | ||
52 | { | ||
53 | return ak4113->read(ak4113->private_data, reg); | ||
54 | } | ||
55 | |||
56 | static void snd_ak4113_free(struct ak4113 *chip) | ||
57 | { | ||
58 | chip->init = 1; /* don't schedule new work */ | ||
59 | mb(); | ||
60 | cancel_delayed_work(&chip->work); | ||
61 | flush_scheduled_work(); | ||
62 | kfree(chip); | ||
63 | } | ||
64 | |||
65 | static int snd_ak4113_dev_free(struct snd_device *device) | ||
66 | { | ||
67 | struct ak4113 *chip = device->device_data; | ||
68 | snd_ak4113_free(chip); | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read, | ||
73 | ak4113_write_t *write, const unsigned char pgm[5], | ||
74 | void *private_data, struct ak4113 **r_ak4113) | ||
75 | { | ||
76 | struct ak4113 *chip; | ||
77 | int err = 0; | ||
78 | unsigned char reg; | ||
79 | static struct snd_device_ops ops = { | ||
80 | .dev_free = snd_ak4113_dev_free, | ||
81 | }; | ||
82 | |||
83 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
84 | if (chip == NULL) | ||
85 | return -ENOMEM; | ||
86 | spin_lock_init(&chip->lock); | ||
87 | chip->card = card; | ||
88 | chip->read = read; | ||
89 | chip->write = write; | ||
90 | chip->private_data = private_data; | ||
91 | INIT_DELAYED_WORK(&chip->work, ak4113_stats); | ||
92 | |||
93 | for (reg = 0; reg < AK4113_WRITABLE_REGS ; reg++) | ||
94 | chip->regmap[reg] = pgm[reg]; | ||
95 | ak4113_init_regs(chip); | ||
96 | |||
97 | chip->rcs0 = reg_read(chip, AK4113_REG_RCS0) & ~(AK4113_QINT | | ||
98 | AK4113_CINT | AK4113_STC); | ||
99 | chip->rcs1 = reg_read(chip, AK4113_REG_RCS1); | ||
100 | chip->rcs2 = reg_read(chip, AK4113_REG_RCS2); | ||
101 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); | ||
102 | if (err < 0) | ||
103 | goto __fail; | ||
104 | |||
105 | if (r_ak4113) | ||
106 | *r_ak4113 = chip; | ||
107 | return 0; | ||
108 | |||
109 | __fail: | ||
110 | snd_ak4113_free(chip); | ||
111 | return err < 0 ? err : -EIO; | ||
112 | } | ||
113 | EXPORT_SYMBOL_GPL(snd_ak4113_create); | ||
114 | |||
115 | void snd_ak4113_reg_write(struct ak4113 *chip, unsigned char reg, | ||
116 | unsigned char mask, unsigned char val) | ||
117 | { | ||
118 | if (reg >= AK4113_WRITABLE_REGS) | ||
119 | return; | ||
120 | reg_write(chip, reg, (chip->regmap[reg] & ~mask) | val); | ||
121 | } | ||
122 | EXPORT_SYMBOL_GPL(snd_ak4113_reg_write); | ||
123 | |||
124 | static void ak4113_init_regs(struct ak4113 *chip) | ||
125 | { | ||
126 | unsigned char old = chip->regmap[AK4113_REG_PWRDN], reg; | ||
127 | |||
128 | /* bring the chip to reset state and powerdown state */ | ||
129 | reg_write(chip, AK4113_REG_PWRDN, old & ~(AK4113_RST|AK4113_PWN)); | ||
130 | udelay(200); | ||
131 | /* release reset, but leave powerdown */ | ||
132 | reg_write(chip, AK4113_REG_PWRDN, (old | AK4113_RST) & ~AK4113_PWN); | ||
133 | udelay(200); | ||
134 | for (reg = 1; reg < AK4113_WRITABLE_REGS; reg++) | ||
135 | reg_write(chip, reg, chip->regmap[reg]); | ||
136 | /* release powerdown, everything is initialized now */ | ||
137 | reg_write(chip, AK4113_REG_PWRDN, old | AK4113_RST | AK4113_PWN); | ||
138 | } | ||
139 | |||
140 | void snd_ak4113_reinit(struct ak4113 *chip) | ||
141 | { | ||
142 | chip->init = 1; | ||
143 | mb(); | ||
144 | flush_scheduled_work(); | ||
145 | ak4113_init_regs(chip); | ||
146 | /* bring up statistics / event queing */ | ||
147 | chip->init = 0; | ||
148 | if (chip->kctls[0]) | ||
149 | schedule_delayed_work(&chip->work, HZ / 10); | ||
150 | } | ||
151 | EXPORT_SYMBOL_GPL(snd_ak4113_reinit); | ||
152 | |||
153 | static unsigned int external_rate(unsigned char rcs1) | ||
154 | { | ||
155 | switch (rcs1 & (AK4113_FS0|AK4113_FS1|AK4113_FS2|AK4113_FS3)) { | ||
156 | case AK4113_FS_8000HZ: | ||
157 | return 8000; | ||
158 | case AK4113_FS_11025HZ: | ||
159 | return 11025; | ||
160 | case AK4113_FS_16000HZ: | ||
161 | return 16000; | ||
162 | case AK4113_FS_22050HZ: | ||
163 | return 22050; | ||
164 | case AK4113_FS_24000HZ: | ||
165 | return 24000; | ||
166 | case AK4113_FS_32000HZ: | ||
167 | return 32000; | ||
168 | case AK4113_FS_44100HZ: | ||
169 | return 44100; | ||
170 | case AK4113_FS_48000HZ: | ||
171 | return 48000; | ||
172 | case AK4113_FS_64000HZ: | ||
173 | return 64000; | ||
174 | case AK4113_FS_88200HZ: | ||
175 | return 88200; | ||
176 | case AK4113_FS_96000HZ: | ||
177 | return 96000; | ||
178 | case AK4113_FS_176400HZ: | ||
179 | return 176400; | ||
180 | case AK4113_FS_192000HZ: | ||
181 | return 192000; | ||
182 | default: | ||
183 | return 0; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | static int snd_ak4113_in_error_info(struct snd_kcontrol *kcontrol, | ||
188 | struct snd_ctl_elem_info *uinfo) | ||
189 | { | ||
190 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
191 | uinfo->count = 1; | ||
192 | uinfo->value.integer.min = 0; | ||
193 | uinfo->value.integer.max = LONG_MAX; | ||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static int snd_ak4113_in_error_get(struct snd_kcontrol *kcontrol, | ||
198 | struct snd_ctl_elem_value *ucontrol) | ||
199 | { | ||
200 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
201 | long *ptr; | ||
202 | |||
203 | spin_lock_irq(&chip->lock); | ||
204 | ptr = (long *)(((char *)chip) + kcontrol->private_value); | ||
205 | ucontrol->value.integer.value[0] = *ptr; | ||
206 | *ptr = 0; | ||
207 | spin_unlock_irq(&chip->lock); | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | #define snd_ak4113_in_bit_info snd_ctl_boolean_mono_info | ||
212 | |||
213 | static int snd_ak4113_in_bit_get(struct snd_kcontrol *kcontrol, | ||
214 | struct snd_ctl_elem_value *ucontrol) | ||
215 | { | ||
216 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
217 | unsigned char reg = kcontrol->private_value & 0xff; | ||
218 | unsigned char bit = (kcontrol->private_value >> 8) & 0xff; | ||
219 | unsigned char inv = (kcontrol->private_value >> 31) & 1; | ||
220 | |||
221 | ucontrol->value.integer.value[0] = | ||
222 | ((reg_read(chip, reg) & (1 << bit)) ? 1 : 0) ^ inv; | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static int snd_ak4113_rx_info(struct snd_kcontrol *kcontrol, | ||
227 | struct snd_ctl_elem_info *uinfo) | ||
228 | { | ||
229 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
230 | uinfo->count = 1; | ||
231 | uinfo->value.integer.min = 0; | ||
232 | uinfo->value.integer.max = 5; | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int snd_ak4113_rx_get(struct snd_kcontrol *kcontrol, | ||
237 | struct snd_ctl_elem_value *ucontrol) | ||
238 | { | ||
239 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
240 | |||
241 | ucontrol->value.integer.value[0] = | ||
242 | (AK4113_IPS(chip->regmap[AK4113_REG_IO1])); | ||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | static int snd_ak4113_rx_put(struct snd_kcontrol *kcontrol, | ||
247 | struct snd_ctl_elem_value *ucontrol) | ||
248 | { | ||
249 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
250 | int change; | ||
251 | u8 old_val; | ||
252 | |||
253 | spin_lock_irq(&chip->lock); | ||
254 | old_val = chip->regmap[AK4113_REG_IO1]; | ||
255 | change = ucontrol->value.integer.value[0] != AK4113_IPS(old_val); | ||
256 | if (change) | ||
257 | reg_write(chip, AK4113_REG_IO1, | ||
258 | (old_val & (~AK4113_IPS(0xff))) | | ||
259 | (AK4113_IPS(ucontrol->value.integer.value[0]))); | ||
260 | spin_unlock_irq(&chip->lock); | ||
261 | return change; | ||
262 | } | ||
263 | |||
264 | static int snd_ak4113_rate_info(struct snd_kcontrol *kcontrol, | ||
265 | struct snd_ctl_elem_info *uinfo) | ||
266 | { | ||
267 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
268 | uinfo->count = 1; | ||
269 | uinfo->value.integer.min = 0; | ||
270 | uinfo->value.integer.max = 192000; | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static int snd_ak4113_rate_get(struct snd_kcontrol *kcontrol, | ||
275 | struct snd_ctl_elem_value *ucontrol) | ||
276 | { | ||
277 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
278 | |||
279 | ucontrol->value.integer.value[0] = external_rate(reg_read(chip, | ||
280 | AK4113_REG_RCS1)); | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | static int snd_ak4113_spdif_info(struct snd_kcontrol *kcontrol, | ||
285 | struct snd_ctl_elem_info *uinfo) | ||
286 | { | ||
287 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; | ||
288 | uinfo->count = 1; | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int snd_ak4113_spdif_get(struct snd_kcontrol *kcontrol, | ||
293 | struct snd_ctl_elem_value *ucontrol) | ||
294 | { | ||
295 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
296 | unsigned i; | ||
297 | |||
298 | for (i = 0; i < AK4113_REG_RXCSB_SIZE; i++) | ||
299 | ucontrol->value.iec958.status[i] = reg_read(chip, | ||
300 | AK4113_REG_RXCSB0 + i); | ||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | static int snd_ak4113_spdif_mask_info(struct snd_kcontrol *kcontrol, | ||
305 | struct snd_ctl_elem_info *uinfo) | ||
306 | { | ||
307 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; | ||
308 | uinfo->count = 1; | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static int snd_ak4113_spdif_mask_get(struct snd_kcontrol *kcontrol, | ||
313 | struct snd_ctl_elem_value *ucontrol) | ||
314 | { | ||
315 | memset(ucontrol->value.iec958.status, 0xff, AK4113_REG_RXCSB_SIZE); | ||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static int snd_ak4113_spdif_pinfo(struct snd_kcontrol *kcontrol, | ||
320 | struct snd_ctl_elem_info *uinfo) | ||
321 | { | ||
322 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
323 | uinfo->value.integer.min = 0; | ||
324 | uinfo->value.integer.max = 0xffff; | ||
325 | uinfo->count = 4; | ||
326 | return 0; | ||
327 | } | ||
328 | |||
329 | static int snd_ak4113_spdif_pget(struct snd_kcontrol *kcontrol, | ||
330 | struct snd_ctl_elem_value *ucontrol) | ||
331 | { | ||
332 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
333 | unsigned short tmp; | ||
334 | |||
335 | ucontrol->value.integer.value[0] = 0xf8f2; | ||
336 | ucontrol->value.integer.value[1] = 0x4e1f; | ||
337 | tmp = reg_read(chip, AK4113_REG_Pc0) | | ||
338 | (reg_read(chip, AK4113_REG_Pc1) << 8); | ||
339 | ucontrol->value.integer.value[2] = tmp; | ||
340 | tmp = reg_read(chip, AK4113_REG_Pd0) | | ||
341 | (reg_read(chip, AK4113_REG_Pd1) << 8); | ||
342 | ucontrol->value.integer.value[3] = tmp; | ||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | static int snd_ak4113_spdif_qinfo(struct snd_kcontrol *kcontrol, | ||
347 | struct snd_ctl_elem_info *uinfo) | ||
348 | { | ||
349 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | ||
350 | uinfo->count = AK4113_REG_QSUB_SIZE; | ||
351 | return 0; | ||
352 | } | ||
353 | |||
354 | static int snd_ak4113_spdif_qget(struct snd_kcontrol *kcontrol, | ||
355 | struct snd_ctl_elem_value *ucontrol) | ||
356 | { | ||
357 | struct ak4113 *chip = snd_kcontrol_chip(kcontrol); | ||
358 | unsigned i; | ||
359 | |||
360 | for (i = 0; i < AK4113_REG_QSUB_SIZE; i++) | ||
361 | ucontrol->value.bytes.data[i] = reg_read(chip, | ||
362 | AK4113_REG_QSUB_ADDR + i); | ||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | /* Don't forget to change AK4113_CONTROLS define!!! */ | ||
367 | static struct snd_kcontrol_new snd_ak4113_iec958_controls[] = { | ||
368 | { | ||
369 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
370 | .name = "IEC958 Parity Errors", | ||
371 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
372 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
373 | .info = snd_ak4113_in_error_info, | ||
374 | .get = snd_ak4113_in_error_get, | ||
375 | .private_value = offsetof(struct ak4113, parity_errors), | ||
376 | }, | ||
377 | { | ||
378 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
379 | .name = "IEC958 V-Bit Errors", | ||
380 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
381 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
382 | .info = snd_ak4113_in_error_info, | ||
383 | .get = snd_ak4113_in_error_get, | ||
384 | .private_value = offsetof(struct ak4113, v_bit_errors), | ||
385 | }, | ||
386 | { | ||
387 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
388 | .name = "IEC958 C-CRC Errors", | ||
389 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
390 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
391 | .info = snd_ak4113_in_error_info, | ||
392 | .get = snd_ak4113_in_error_get, | ||
393 | .private_value = offsetof(struct ak4113, ccrc_errors), | ||
394 | }, | ||
395 | { | ||
396 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
397 | .name = "IEC958 Q-CRC Errors", | ||
398 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
399 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
400 | .info = snd_ak4113_in_error_info, | ||
401 | .get = snd_ak4113_in_error_get, | ||
402 | .private_value = offsetof(struct ak4113, qcrc_errors), | ||
403 | }, | ||
404 | { | ||
405 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
406 | .name = "IEC958 External Rate", | ||
407 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
408 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
409 | .info = snd_ak4113_rate_info, | ||
410 | .get = snd_ak4113_rate_get, | ||
411 | }, | ||
412 | { | ||
413 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
414 | .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, MASK), | ||
415 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | ||
416 | .info = snd_ak4113_spdif_mask_info, | ||
417 | .get = snd_ak4113_spdif_mask_get, | ||
418 | }, | ||
419 | { | ||
420 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
421 | .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT), | ||
422 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
423 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
424 | .info = snd_ak4113_spdif_info, | ||
425 | .get = snd_ak4113_spdif_get, | ||
426 | }, | ||
427 | { | ||
428 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
429 | .name = "IEC958 Preample Capture Default", | ||
430 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
431 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
432 | .info = snd_ak4113_spdif_pinfo, | ||
433 | .get = snd_ak4113_spdif_pget, | ||
434 | }, | ||
435 | { | ||
436 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
437 | .name = "IEC958 Q-subcode Capture Default", | ||
438 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
439 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
440 | .info = snd_ak4113_spdif_qinfo, | ||
441 | .get = snd_ak4113_spdif_qget, | ||
442 | }, | ||
443 | { | ||
444 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
445 | .name = "IEC958 Audio", | ||
446 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
447 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
448 | .info = snd_ak4113_in_bit_info, | ||
449 | .get = snd_ak4113_in_bit_get, | ||
450 | .private_value = (1<<31) | (1<<8) | AK4113_REG_RCS0, | ||
451 | }, | ||
452 | { | ||
453 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
454 | .name = "IEC958 Non-PCM Bitstream", | ||
455 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
456 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
457 | .info = snd_ak4113_in_bit_info, | ||
458 | .get = snd_ak4113_in_bit_get, | ||
459 | .private_value = (0<<8) | AK4113_REG_RCS1, | ||
460 | }, | ||
461 | { | ||
462 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
463 | .name = "IEC958 DTS Bitstream", | ||
464 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
465 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, | ||
466 | .info = snd_ak4113_in_bit_info, | ||
467 | .get = snd_ak4113_in_bit_get, | ||
468 | .private_value = (1<<8) | AK4113_REG_RCS1, | ||
469 | }, | ||
470 | { | ||
471 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
472 | .name = "AK4113 Input Select", | ||
473 | .access = SNDRV_CTL_ELEM_ACCESS_READ | | ||
474 | SNDRV_CTL_ELEM_ACCESS_WRITE, | ||
475 | .info = snd_ak4113_rx_info, | ||
476 | .get = snd_ak4113_rx_get, | ||
477 | .put = snd_ak4113_rx_put, | ||
478 | } | ||
479 | }; | ||
480 | |||
481 | static void snd_ak4113_proc_regs_read(struct snd_info_entry *entry, | ||
482 | struct snd_info_buffer *buffer) | ||
483 | { | ||
484 | struct ak4113 *ak4113 = entry->private_data; | ||
485 | int reg, val; | ||
486 | /* all ak4113 registers 0x00 - 0x1c */ | ||
487 | for (reg = 0; reg < 0x1d; reg++) { | ||
488 | val = reg_read(ak4113, reg); | ||
489 | snd_iprintf(buffer, "0x%02x = 0x%02x\n", reg, val); | ||
490 | } | ||
491 | } | ||
492 | |||
493 | static void snd_ak4113_proc_init(struct ak4113 *ak4113) | ||
494 | { | ||
495 | struct snd_info_entry *entry; | ||
496 | if (!snd_card_proc_new(ak4113->card, "ak4113", &entry)) | ||
497 | snd_info_set_text_ops(entry, ak4113, snd_ak4113_proc_regs_read); | ||
498 | } | ||
499 | |||
500 | int snd_ak4113_build(struct ak4113 *ak4113, | ||
501 | struct snd_pcm_substream *cap_substream) | ||
502 | { | ||
503 | struct snd_kcontrol *kctl; | ||
504 | unsigned int idx; | ||
505 | int err; | ||
506 | |||
507 | if (snd_BUG_ON(!cap_substream)) | ||
508 | return -EINVAL; | ||
509 | ak4113->substream = cap_substream; | ||
510 | for (idx = 0; idx < AK4113_CONTROLS; idx++) { | ||
511 | kctl = snd_ctl_new1(&snd_ak4113_iec958_controls[idx], ak4113); | ||
512 | if (kctl == NULL) | ||
513 | return -ENOMEM; | ||
514 | kctl->id.device = cap_substream->pcm->device; | ||
515 | kctl->id.subdevice = cap_substream->number; | ||
516 | err = snd_ctl_add(ak4113->card, kctl); | ||
517 | if (err < 0) | ||
518 | return err; | ||
519 | ak4113->kctls[idx] = kctl; | ||
520 | } | ||
521 | snd_ak4113_proc_init(ak4113); | ||
522 | /* trigger workq */ | ||
523 | schedule_delayed_work(&ak4113->work, HZ / 10); | ||
524 | return 0; | ||
525 | } | ||
526 | EXPORT_SYMBOL_GPL(snd_ak4113_build); | ||
527 | |||
528 | int snd_ak4113_external_rate(struct ak4113 *ak4113) | ||
529 | { | ||
530 | unsigned char rcs1; | ||
531 | |||
532 | rcs1 = reg_read(ak4113, AK4113_REG_RCS1); | ||
533 | return external_rate(rcs1); | ||
534 | } | ||
535 | EXPORT_SYMBOL_GPL(snd_ak4113_external_rate); | ||
536 | |||
537 | int snd_ak4113_check_rate_and_errors(struct ak4113 *ak4113, unsigned int flags) | ||
538 | { | ||
539 | struct snd_pcm_runtime *runtime = | ||
540 | ak4113->substream ? ak4113->substream->runtime : NULL; | ||
541 | unsigned long _flags; | ||
542 | int res = 0; | ||
543 | unsigned char rcs0, rcs1, rcs2; | ||
544 | unsigned char c0, c1; | ||
545 | |||
546 | rcs1 = reg_read(ak4113, AK4113_REG_RCS1); | ||
547 | if (flags & AK4113_CHECK_NO_STAT) | ||
548 | goto __rate; | ||
549 | rcs0 = reg_read(ak4113, AK4113_REG_RCS0); | ||
550 | rcs2 = reg_read(ak4113, AK4113_REG_RCS2); | ||
551 | spin_lock_irqsave(&ak4113->lock, _flags); | ||
552 | if (rcs0 & AK4113_PAR) | ||
553 | ak4113->parity_errors++; | ||
554 | if (rcs0 & AK4113_V) | ||
555 | ak4113->v_bit_errors++; | ||
556 | if (rcs2 & AK4113_CCRC) | ||
557 | ak4113->ccrc_errors++; | ||
558 | if (rcs2 & AK4113_QCRC) | ||
559 | ak4113->qcrc_errors++; | ||
560 | c0 = (ak4113->rcs0 & (AK4113_QINT | AK4113_CINT | AK4113_STC | | ||
561 | AK4113_AUDION | AK4113_AUTO | AK4113_UNLCK)) ^ | ||
562 | (rcs0 & (AK4113_QINT | AK4113_CINT | AK4113_STC | | ||
563 | AK4113_AUDION | AK4113_AUTO | AK4113_UNLCK)); | ||
564 | c1 = (ak4113->rcs1 & (AK4113_DTSCD | AK4113_NPCM | AK4113_PEM | | ||
565 | AK4113_DAT | 0xf0)) ^ | ||
566 | (rcs1 & (AK4113_DTSCD | AK4113_NPCM | AK4113_PEM | | ||
567 | AK4113_DAT | 0xf0)); | ||
568 | ak4113->rcs0 = rcs0 & ~(AK4113_QINT | AK4113_CINT | AK4113_STC); | ||
569 | ak4113->rcs1 = rcs1; | ||
570 | ak4113->rcs2 = rcs2; | ||
571 | spin_unlock_irqrestore(&ak4113->lock, _flags); | ||
572 | |||
573 | if (rcs0 & AK4113_PAR) | ||
574 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
575 | &ak4113->kctls[0]->id); | ||
576 | if (rcs0 & AK4113_V) | ||
577 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
578 | &ak4113->kctls[1]->id); | ||
579 | if (rcs2 & AK4113_CCRC) | ||
580 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
581 | &ak4113->kctls[2]->id); | ||
582 | if (rcs2 & AK4113_QCRC) | ||
583 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
584 | &ak4113->kctls[3]->id); | ||
585 | |||
586 | /* rate change */ | ||
587 | if (c1 & 0xf0) | ||
588 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
589 | &ak4113->kctls[4]->id); | ||
590 | |||
591 | if ((c1 & AK4113_PEM) | (c0 & AK4113_CINT)) | ||
592 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
593 | &ak4113->kctls[6]->id); | ||
594 | if (c0 & AK4113_QINT) | ||
595 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
596 | &ak4113->kctls[8]->id); | ||
597 | |||
598 | if (c0 & AK4113_AUDION) | ||
599 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
600 | &ak4113->kctls[9]->id); | ||
601 | if (c1 & AK4113_NPCM) | ||
602 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
603 | &ak4113->kctls[10]->id); | ||
604 | if (c1 & AK4113_DTSCD) | ||
605 | snd_ctl_notify(ak4113->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
606 | &ak4113->kctls[11]->id); | ||
607 | |||
608 | if (ak4113->change_callback && (c0 | c1) != 0) | ||
609 | ak4113->change_callback(ak4113, c0, c1); | ||
610 | |||
611 | __rate: | ||
612 | /* compare rate */ | ||
613 | res = external_rate(rcs1); | ||
614 | if (!(flags & AK4113_CHECK_NO_RATE) && runtime && | ||
615 | (runtime->rate != res)) { | ||
616 | snd_pcm_stream_lock_irqsave(ak4113->substream, _flags); | ||
617 | if (snd_pcm_running(ak4113->substream)) { | ||
618 | /*printk(KERN_DEBUG "rate changed (%i <- %i)\n", | ||
619 | * runtime->rate, res); */ | ||
620 | snd_pcm_stop(ak4113->substream, | ||
621 | SNDRV_PCM_STATE_DRAINING); | ||
622 | wake_up(&runtime->sleep); | ||
623 | res = 1; | ||
624 | } | ||
625 | snd_pcm_stream_unlock_irqrestore(ak4113->substream, _flags); | ||
626 | } | ||
627 | return res; | ||
628 | } | ||
629 | EXPORT_SYMBOL_GPL(snd_ak4113_check_rate_and_errors); | ||
630 | |||
631 | static void ak4113_stats(struct work_struct *work) | ||
632 | { | ||
633 | struct ak4113 *chip = container_of(work, struct ak4113, work.work); | ||
634 | |||
635 | if (!chip->init) | ||
636 | snd_ak4113_check_rate_and_errors(chip, chip->check_flags); | ||
637 | |||
638 | schedule_delayed_work(&chip->work, HZ / 10); | ||
639 | } | ||
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index ee47abab764e..1adb8a3c2b62 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
@@ -29,6 +29,7 @@ | |||
29 | #include <sound/control.h> | 29 | #include <sound/control.h> |
30 | #include <sound/tlv.h> | 30 | #include <sound/tlv.h> |
31 | #include <sound/ak4xxx-adda.h> | 31 | #include <sound/ak4xxx-adda.h> |
32 | #include <sound/info.h> | ||
32 | 33 | ||
33 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>"); | 34 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>"); |
34 | MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters"); | 35 | MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters"); |
@@ -52,26 +53,21 @@ EXPORT_SYMBOL(snd_akm4xxx_write); | |||
52 | static void ak4524_reset(struct snd_akm4xxx *ak, int state) | 53 | static void ak4524_reset(struct snd_akm4xxx *ak, int state) |
53 | { | 54 | { |
54 | unsigned int chip; | 55 | unsigned int chip; |
55 | unsigned char reg, maxreg; | 56 | unsigned char reg; |
56 | 57 | ||
57 | if (ak->type == SND_AK4528) | ||
58 | maxreg = 0x06; | ||
59 | else | ||
60 | maxreg = 0x08; | ||
61 | for (chip = 0; chip < ak->num_dacs/2; chip++) { | 58 | for (chip = 0; chip < ak->num_dacs/2; chip++) { |
62 | snd_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03); | 59 | snd_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03); |
63 | if (state) | 60 | if (state) |
64 | continue; | 61 | continue; |
65 | /* DAC volumes */ | 62 | /* DAC volumes */ |
66 | for (reg = 0x04; reg < maxreg; reg++) | 63 | for (reg = 0x04; reg < ak->total_regs; reg++) |
67 | snd_akm4xxx_write(ak, chip, reg, | 64 | snd_akm4xxx_write(ak, chip, reg, |
68 | snd_akm4xxx_get(ak, chip, reg)); | 65 | snd_akm4xxx_get(ak, chip, reg)); |
69 | } | 66 | } |
70 | } | 67 | } |
71 | 68 | ||
72 | /* reset procedure for AK4355 and AK4358 */ | 69 | /* reset procedure for AK4355 and AK4358 */ |
73 | static void ak435X_reset(struct snd_akm4xxx *ak, int state, | 70 | static void ak435X_reset(struct snd_akm4xxx *ak, int state) |
74 | unsigned char total_regs) | ||
75 | { | 71 | { |
76 | unsigned char reg; | 72 | unsigned char reg; |
77 | 73 | ||
@@ -79,7 +75,7 @@ static void ak435X_reset(struct snd_akm4xxx *ak, int state, | |||
79 | snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */ | 75 | snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */ |
80 | return; | 76 | return; |
81 | } | 77 | } |
82 | for (reg = 0x00; reg < total_regs; reg++) | 78 | for (reg = 0x00; reg < ak->total_regs; reg++) |
83 | if (reg != 0x01) | 79 | if (reg != 0x01) |
84 | snd_akm4xxx_write(ak, 0, reg, | 80 | snd_akm4xxx_write(ak, 0, reg, |
85 | snd_akm4xxx_get(ak, 0, reg)); | 81 | snd_akm4xxx_get(ak, 0, reg)); |
@@ -91,12 +87,11 @@ static void ak4381_reset(struct snd_akm4xxx *ak, int state) | |||
91 | { | 87 | { |
92 | unsigned int chip; | 88 | unsigned int chip; |
93 | unsigned char reg; | 89 | unsigned char reg; |
94 | |||
95 | for (chip = 0; chip < ak->num_dacs/2; chip++) { | 90 | for (chip = 0; chip < ak->num_dacs/2; chip++) { |
96 | snd_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f); | 91 | snd_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f); |
97 | if (state) | 92 | if (state) |
98 | continue; | 93 | continue; |
99 | for (reg = 0x01; reg < 0x05; reg++) | 94 | for (reg = 0x01; reg < ak->total_regs; reg++) |
100 | snd_akm4xxx_write(ak, chip, reg, | 95 | snd_akm4xxx_write(ak, chip, reg, |
101 | snd_akm4xxx_get(ak, chip, reg)); | 96 | snd_akm4xxx_get(ak, chip, reg)); |
102 | } | 97 | } |
@@ -113,16 +108,17 @@ void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state) | |||
113 | switch (ak->type) { | 108 | switch (ak->type) { |
114 | case SND_AK4524: | 109 | case SND_AK4524: |
115 | case SND_AK4528: | 110 | case SND_AK4528: |
111 | case SND_AK4620: | ||
116 | ak4524_reset(ak, state); | 112 | ak4524_reset(ak, state); |
117 | break; | 113 | break; |
118 | case SND_AK4529: | 114 | case SND_AK4529: |
119 | /* FIXME: needed for ak4529? */ | 115 | /* FIXME: needed for ak4529? */ |
120 | break; | 116 | break; |
121 | case SND_AK4355: | 117 | case SND_AK4355: |
122 | ak435X_reset(ak, state, 0x0b); | 118 | ak435X_reset(ak, state); |
123 | break; | 119 | break; |
124 | case SND_AK4358: | 120 | case SND_AK4358: |
125 | ak435X_reset(ak, state, 0x10); | 121 | ak435X_reset(ak, state); |
126 | break; | 122 | break; |
127 | case SND_AK4381: | 123 | case SND_AK4381: |
128 | ak4381_reset(ak, state); | 124 | ak4381_reset(ak, state); |
@@ -139,7 +135,7 @@ EXPORT_SYMBOL(snd_akm4xxx_reset); | |||
139 | * Volume conversion table for non-linear volumes | 135 | * Volume conversion table for non-linear volumes |
140 | * from -63.5dB (mute) to 0dB step 0.5dB | 136 | * from -63.5dB (mute) to 0dB step 0.5dB |
141 | * | 137 | * |
142 | * Used for AK4524 input/ouput attenuation, AK4528, and | 138 | * Used for AK4524/AK4620 input/ouput attenuation, AK4528, and |
143 | * AK5365 input attenuation | 139 | * AK5365 input attenuation |
144 | */ | 140 | */ |
145 | static const unsigned char vol_cvt_datt[128] = { | 141 | static const unsigned char vol_cvt_datt[128] = { |
@@ -259,8 +255,22 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak) | |||
259 | 0x00, 0x0f, /* 0: power-up, un-reset */ | 255 | 0x00, 0x0f, /* 0: power-up, un-reset */ |
260 | 0xff, 0xff | 256 | 0xff, 0xff |
261 | }; | 257 | }; |
258 | static const unsigned char inits_ak4620[] = { | ||
259 | 0x00, 0x07, /* 0: normal */ | ||
260 | 0x01, 0x00, /* 0: reset */ | ||
261 | 0x01, 0x02, /* 1: RSTAD */ | ||
262 | 0x01, 0x03, /* 1: RSTDA */ | ||
263 | 0x01, 0x0f, /* 1: normal */ | ||
264 | 0x02, 0x60, /* 2: 24bit I2S */ | ||
265 | 0x03, 0x01, /* 3: deemphasis off */ | ||
266 | 0x04, 0x00, /* 4: LIN muted */ | ||
267 | 0x05, 0x00, /* 5: RIN muted */ | ||
268 | 0x06, 0x00, /* 6: LOUT muted */ | ||
269 | 0x07, 0x00, /* 7: ROUT muted */ | ||
270 | 0xff, 0xff | ||
271 | }; | ||
262 | 272 | ||
263 | int chip, num_chips; | 273 | int chip; |
264 | const unsigned char *ptr, *inits; | 274 | const unsigned char *ptr, *inits; |
265 | unsigned char reg, data; | 275 | unsigned char reg, data; |
266 | 276 | ||
@@ -270,42 +280,64 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak) | |||
270 | switch (ak->type) { | 280 | switch (ak->type) { |
271 | case SND_AK4524: | 281 | case SND_AK4524: |
272 | inits = inits_ak4524; | 282 | inits = inits_ak4524; |
273 | num_chips = ak->num_dacs / 2; | 283 | ak->num_chips = ak->num_dacs / 2; |
284 | ak->name = "ak4524"; | ||
285 | ak->total_regs = 0x08; | ||
274 | break; | 286 | break; |
275 | case SND_AK4528: | 287 | case SND_AK4528: |
276 | inits = inits_ak4528; | 288 | inits = inits_ak4528; |
277 | num_chips = ak->num_dacs / 2; | 289 | ak->num_chips = ak->num_dacs / 2; |
290 | ak->name = "ak4528"; | ||
291 | ak->total_regs = 0x06; | ||
278 | break; | 292 | break; |
279 | case SND_AK4529: | 293 | case SND_AK4529: |
280 | inits = inits_ak4529; | 294 | inits = inits_ak4529; |
281 | num_chips = 1; | 295 | ak->num_chips = 1; |
296 | ak->name = "ak4529"; | ||
297 | ak->total_regs = 0x0d; | ||
282 | break; | 298 | break; |
283 | case SND_AK4355: | 299 | case SND_AK4355: |
284 | inits = inits_ak4355; | 300 | inits = inits_ak4355; |
285 | num_chips = 1; | 301 | ak->num_chips = 1; |
302 | ak->name = "ak4355"; | ||
303 | ak->total_regs = 0x0b; | ||
286 | break; | 304 | break; |
287 | case SND_AK4358: | 305 | case SND_AK4358: |
288 | inits = inits_ak4358; | 306 | inits = inits_ak4358; |
289 | num_chips = 1; | 307 | ak->num_chips = 1; |
308 | ak->name = "ak4358"; | ||
309 | ak->total_regs = 0x10; | ||
290 | break; | 310 | break; |
291 | case SND_AK4381: | 311 | case SND_AK4381: |
292 | inits = inits_ak4381; | 312 | inits = inits_ak4381; |
293 | num_chips = ak->num_dacs / 2; | 313 | ak->num_chips = ak->num_dacs / 2; |
314 | ak->name = "ak4381"; | ||
315 | ak->total_regs = 0x05; | ||
294 | break; | 316 | break; |
295 | case SND_AK5365: | 317 | case SND_AK5365: |
296 | /* FIXME: any init sequence? */ | 318 | /* FIXME: any init sequence? */ |
319 | ak->num_chips = 1; | ||
320 | ak->name = "ak5365"; | ||
321 | ak->total_regs = 0x08; | ||
297 | return; | 322 | return; |
323 | case SND_AK4620: | ||
324 | inits = inits_ak4620; | ||
325 | ak->num_chips = ak->num_dacs / 2; | ||
326 | ak->name = "ak4620"; | ||
327 | ak->total_regs = 0x08; | ||
328 | break; | ||
298 | default: | 329 | default: |
299 | snd_BUG(); | 330 | snd_BUG(); |
300 | return; | 331 | return; |
301 | } | 332 | } |
302 | 333 | ||
303 | for (chip = 0; chip < num_chips; chip++) { | 334 | for (chip = 0; chip < ak->num_chips; chip++) { |
304 | ptr = inits; | 335 | ptr = inits; |
305 | while (*ptr != 0xff) { | 336 | while (*ptr != 0xff) { |
306 | reg = *ptr++; | 337 | reg = *ptr++; |
307 | data = *ptr++; | 338 | data = *ptr++; |
308 | snd_akm4xxx_write(ak, chip, reg, data); | 339 | snd_akm4xxx_write(ak, chip, reg, data); |
340 | udelay(10); | ||
309 | } | 341 | } |
310 | } | 342 | } |
311 | } | 343 | } |
@@ -688,6 +720,12 @@ static int build_dac_controls(struct snd_akm4xxx *ak) | |||
688 | AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); | 720 | AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); |
689 | knew.tlv.p = db_scale_linear; | 721 | knew.tlv.p = db_scale_linear; |
690 | break; | 722 | break; |
723 | case SND_AK4620: | ||
724 | /* register 6 & 7 */ | ||
725 | knew.private_value = | ||
726 | AK_COMPOSE(idx/2, (idx%2) + 6, 0, 255); | ||
727 | knew.tlv.p = db_scale_linear; | ||
728 | break; | ||
691 | default: | 729 | default: |
692 | return -EINVAL; | 730 | return -EINVAL; |
693 | } | 731 | } |
@@ -704,10 +742,12 @@ static int build_dac_controls(struct snd_akm4xxx *ak) | |||
704 | 742 | ||
705 | static int build_adc_controls(struct snd_akm4xxx *ak) | 743 | static int build_adc_controls(struct snd_akm4xxx *ak) |
706 | { | 744 | { |
707 | int idx, err, mixer_ch, num_stereo; | 745 | int idx, err, mixer_ch, num_stereo, max_steps; |
708 | struct snd_kcontrol_new knew; | 746 | struct snd_kcontrol_new knew; |
709 | 747 | ||
710 | mixer_ch = 0; | 748 | mixer_ch = 0; |
749 | if (ak->type == SND_AK4528) | ||
750 | return 0; /* no controls */ | ||
711 | for (idx = 0; idx < ak->num_adcs;) { | 751 | for (idx = 0; idx < ak->num_adcs;) { |
712 | memset(&knew, 0, sizeof(knew)); | 752 | memset(&knew, 0, sizeof(knew)); |
713 | if (! ak->adc_info || ! ak->adc_info[mixer_ch].name) { | 753 | if (! ak->adc_info || ! ak->adc_info[mixer_ch].name) { |
@@ -733,13 +773,12 @@ static int build_adc_controls(struct snd_akm4xxx *ak) | |||
733 | } | 773 | } |
734 | /* register 4 & 5 */ | 774 | /* register 4 & 5 */ |
735 | if (ak->type == SND_AK5365) | 775 | if (ak->type == SND_AK5365) |
736 | knew.private_value = | 776 | max_steps = 152; |
737 | AK_COMPOSE(idx/2, (idx%2) + 4, 0, 151) | | ||
738 | AK_VOL_CVT | AK_IPGA; | ||
739 | else | 777 | else |
740 | knew.private_value = | 778 | max_steps = 164; |
741 | AK_COMPOSE(idx/2, (idx%2) + 4, 0, 163) | | 779 | knew.private_value = |
742 | AK_VOL_CVT | AK_IPGA; | 780 | AK_COMPOSE(idx/2, (idx%2) + 4, 0, max_steps) | |
781 | AK_VOL_CVT | AK_IPGA; | ||
743 | knew.tlv.p = db_scale_vol_datt; | 782 | knew.tlv.p = db_scale_vol_datt; |
744 | err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak)); | 783 | err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak)); |
745 | if (err < 0) | 784 | if (err < 0) |
@@ -808,6 +847,7 @@ static int build_deemphasis(struct snd_akm4xxx *ak, int num_emphs) | |||
808 | switch (ak->type) { | 847 | switch (ak->type) { |
809 | case SND_AK4524: | 848 | case SND_AK4524: |
810 | case SND_AK4528: | 849 | case SND_AK4528: |
850 | case SND_AK4620: | ||
811 | /* register 3 */ | 851 | /* register 3 */ |
812 | knew.private_value = AK_COMPOSE(idx, 3, 0, 0); | 852 | knew.private_value = AK_COMPOSE(idx, 3, 0, 0); |
813 | break; | 853 | break; |
@@ -834,6 +874,35 @@ static int build_deemphasis(struct snd_akm4xxx *ak, int num_emphs) | |||
834 | return 0; | 874 | return 0; |
835 | } | 875 | } |
836 | 876 | ||
877 | #ifdef CONFIG_PROC_FS | ||
878 | static void proc_regs_read(struct snd_info_entry *entry, | ||
879 | struct snd_info_buffer *buffer) | ||
880 | { | ||
881 | struct snd_akm4xxx *ak = (struct snd_akm4xxx *)entry->private_data; | ||
882 | int reg, val, chip; | ||
883 | for (chip = 0; chip < ak->num_chips; chip++) { | ||
884 | for (reg = 0; reg < ak->total_regs; reg++) { | ||
885 | val = snd_akm4xxx_get(ak, chip, reg); | ||
886 | snd_iprintf(buffer, "chip %d: 0x%02x = 0x%02x\n", chip, | ||
887 | reg, val); | ||
888 | } | ||
889 | } | ||
890 | } | ||
891 | |||
892 | static int proc_init(struct snd_akm4xxx *ak) | ||
893 | { | ||
894 | struct snd_info_entry *entry; | ||
895 | int err; | ||
896 | err = snd_card_proc_new(ak->card, ak->name, &entry); | ||
897 | if (err < 0) | ||
898 | return err; | ||
899 | snd_info_set_text_ops(entry, ak, proc_regs_read); | ||
900 | return 0; | ||
901 | } | ||
902 | #else /* !CONFIG_PROC_FS */ | ||
903 | static int proc_init(struct snd_akm4xxx *ak) {} | ||
904 | #endif | ||
905 | |||
837 | int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak) | 906 | int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak) |
838 | { | 907 | { |
839 | int err, num_emphs; | 908 | int err, num_emphs; |
@@ -845,18 +914,21 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak) | |||
845 | err = build_adc_controls(ak); | 914 | err = build_adc_controls(ak); |
846 | if (err < 0) | 915 | if (err < 0) |
847 | return err; | 916 | return err; |
848 | |||
849 | if (ak->type == SND_AK4355 || ak->type == SND_AK4358) | 917 | if (ak->type == SND_AK4355 || ak->type == SND_AK4358) |
850 | num_emphs = 1; | 918 | num_emphs = 1; |
919 | else if (ak->type == SND_AK4620) | ||
920 | num_emphs = 0; | ||
851 | else | 921 | else |
852 | num_emphs = ak->num_dacs / 2; | 922 | num_emphs = ak->num_dacs / 2; |
853 | err = build_deemphasis(ak, num_emphs); | 923 | err = build_deemphasis(ak, num_emphs); |
854 | if (err < 0) | 924 | if (err < 0) |
855 | return err; | 925 | return err; |
926 | err = proc_init(ak); | ||
927 | if (err < 0) | ||
928 | return err; | ||
856 | 929 | ||
857 | return 0; | 930 | return 0; |
858 | } | 931 | } |
859 | |||
860 | EXPORT_SYMBOL(snd_akm4xxx_build_controls); | 932 | EXPORT_SYMBOL(snd_akm4xxx_build_controls); |
861 | 933 | ||
862 | static int __init alsa_akm4xxx_module_init(void) | 934 | static int __init alsa_akm4xxx_module_init(void) |
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index d31c373e076d..c4c6ef73f9bf 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c | |||
@@ -225,7 +225,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
225 | case V4L2_CID_AUDIO_MUTE: | 225 | case V4L2_CID_AUDIO_MUTE: |
226 | if (tea->ops->mute) { | 226 | if (tea->ops->mute) { |
227 | tea->ops->mute(tea, ctrl->value); | 227 | tea->ops->mute(tea, ctrl->value); |
228 | tea->mute = 1; | 228 | tea->mute = ctrl->value; |
229 | return 0; | 229 | return 0; |
230 | } | 230 | } |
231 | } | 231 | } |
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 51a7e3777e17..02fe81ca88fd 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
@@ -372,15 +372,21 @@ config SND_SGALAXY | |||
372 | 372 | ||
373 | config SND_SSCAPE | 373 | config SND_SSCAPE |
374 | tristate "Ensoniq SoundScape driver" | 374 | tristate "Ensoniq SoundScape driver" |
375 | select SND_HWDEP | ||
376 | select SND_MPU401_UART | 375 | select SND_MPU401_UART |
377 | select SND_WSS_LIB | 376 | select SND_WSS_LIB |
377 | select FW_LOADER | ||
378 | help | 378 | help |
379 | Say Y here to include support for Ensoniq SoundScape | 379 | Say Y here to include support for Ensoniq SoundScape |
380 | soundcards. | 380 | and Ensoniq OEM soundcards. |
381 | 381 | ||
382 | The PCM audio is supported on SoundScape Classic, Elite, PnP | 382 | The PCM audio is supported on SoundScape Classic, Elite, PnP |
383 | and VIVO cards. The MIDI support is very experimental. | 383 | and VIVO cards. The supported OEM cards are SPEA Media FX and |
384 | Reveal SC-600. | ||
385 | The MIDI support is very experimental and requires binary | ||
386 | firmware files called "scope.cod" and "sndscape.co?" where the | ||
387 | ? is digit 0, 1, 2, 3 or 4. The firmware files can be found | ||
388 | in DOS or Windows driver packages. One has to put the firmware | ||
389 | files into the /lib/firmware directory. | ||
384 | 390 | ||
385 | To compile this driver as a module, choose M here: the module | 391 | To compile this driver as a module, choose M here: the module |
386 | will be called snd-sscape. | 392 | will be called snd-sscape. |
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 02f79d252718..8246aae32ab4 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c | |||
@@ -237,7 +237,7 @@ WSS_DOUBLE("Wavetable Capture Volume", 0, | |||
237 | CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), | 237 | CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), |
238 | WSS_SINGLE("3D Control - Switch", 0, | 238 | WSS_SINGLE("3D Control - Switch", 0, |
239 | CMI8330_RMUX3D, 5, 1, 1), | 239 | CMI8330_RMUX3D, 5, 1, 1), |
240 | WSS_SINGLE("PC Speaker Playback Volume", 0, | 240 | WSS_SINGLE("Beep Playback Volume", 0, |
241 | CMI8330_OUTPUTVOL, 3, 3, 0), | 241 | CMI8330_OUTPUTVOL, 3, 3, 0), |
242 | WSS_DOUBLE("FM Playback Switch", 0, | 242 | WSS_DOUBLE("FM Playback Switch", 0, |
243 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 243 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
@@ -262,7 +262,7 @@ SB_DOUBLE("SB Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, | |||
262 | SB_DOUBLE("SB Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), | 262 | SB_DOUBLE("SB Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), |
263 | SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), | 263 | SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
264 | SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), | 264 | SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), |
265 | SB_SINGLE("SB PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3), | 265 | SB_SINGLE("SB Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3), |
266 | SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), | 266 | SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), |
267 | SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), | 267 | SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), |
268 | SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), | 268 | SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), |
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index a076a6ce8071..cc15d1d65a22 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c | |||
@@ -177,7 +177,7 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { | |||
177 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 177 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
178 | /* Digital PC 5000 Onboard - CS4236B */ | 178 | /* Digital PC 5000 Onboard - CS4236B */ |
179 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, | 179 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
180 | /* some uknown CS4236B */ | 180 | /* some unknown CS4236B */ |
181 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 181 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
182 | /* Intel PR440FX Onboard sound */ | 182 | /* Intel PR440FX Onboard sound */ |
183 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 183 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
@@ -394,21 +394,15 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) | |||
394 | return -EBUSY; | 394 | return -EBUSY; |
395 | } | 395 | } |
396 | 396 | ||
397 | err = snd_wss_create(card, port[dev], cport[dev], | 397 | err = snd_cs4236_create(card, port[dev], cport[dev], |
398 | irq[dev], | 398 | irq[dev], |
399 | dma1[dev], dma2[dev], | 399 | dma1[dev], dma2[dev], |
400 | WSS_HW_DETECT3, 0, &chip); | 400 | WSS_HW_DETECT3, 0, &chip); |
401 | if (err < 0) | 401 | if (err < 0) |
402 | return err; | 402 | return err; |
403 | |||
404 | acard->chip = chip; | ||
403 | if (chip->hardware & WSS_HW_CS4236B_MASK) { | 405 | if (chip->hardware & WSS_HW_CS4236B_MASK) { |
404 | snd_wss_free(chip); | ||
405 | err = snd_cs4236_create(card, | ||
406 | port[dev], cport[dev], | ||
407 | irq[dev], dma1[dev], dma2[dev], | ||
408 | WSS_HW_DETECT, 0, &chip); | ||
409 | if (err < 0) | ||
410 | return err; | ||
411 | acard->chip = chip; | ||
412 | 406 | ||
413 | err = snd_cs4236_pcm(chip, 0, &pcm); | 407 | err = snd_cs4236_pcm(chip, 0, &pcm); |
414 | if (err < 0) | 408 | if (err < 0) |
@@ -418,7 +412,6 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) | |||
418 | if (err < 0) | 412 | if (err < 0) |
419 | return err; | 413 | return err; |
420 | } else { | 414 | } else { |
421 | acard->chip = chip; | ||
422 | err = snd_wss_pcm(chip, 0, &pcm); | 415 | err = snd_wss_pcm(chip, 0, &pcm); |
423 | if (err < 0) | 416 | if (err < 0) |
424 | return err; | 417 | return err; |
diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 38835f31298b..c5adca300632 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c | |||
@@ -87,6 +87,8 @@ | |||
87 | #include <sound/core.h> | 87 | #include <sound/core.h> |
88 | #include <sound/wss.h> | 88 | #include <sound/wss.h> |
89 | #include <sound/asoundef.h> | 89 | #include <sound/asoundef.h> |
90 | #include <sound/initval.h> | ||
91 | #include <sound/tlv.h> | ||
90 | 92 | ||
91 | /* | 93 | /* |
92 | * | 94 | * |
@@ -264,7 +266,10 @@ static void snd_cs4236_resume(struct snd_wss *chip) | |||
264 | } | 266 | } |
265 | 267 | ||
266 | #endif /* CONFIG_PM */ | 268 | #endif /* CONFIG_PM */ |
267 | 269 | /* | |
270 | * This function does no fail if the chip is not CS4236B or compatible. | ||
271 | * It just an equivalent to the snd_wss_create() then. | ||
272 | */ | ||
268 | int snd_cs4236_create(struct snd_card *card, | 273 | int snd_cs4236_create(struct snd_card *card, |
269 | unsigned long port, | 274 | unsigned long port, |
270 | unsigned long cport, | 275 | unsigned long cport, |
@@ -281,21 +286,17 @@ int snd_cs4236_create(struct snd_card *card, | |||
281 | *rchip = NULL; | 286 | *rchip = NULL; |
282 | if (hardware == WSS_HW_DETECT) | 287 | if (hardware == WSS_HW_DETECT) |
283 | hardware = WSS_HW_DETECT3; | 288 | hardware = WSS_HW_DETECT3; |
284 | if (cport < 0x100) { | 289 | |
285 | snd_printk(KERN_ERR "please, specify control port " | ||
286 | "for CS4236+ chips\n"); | ||
287 | return -ENODEV; | ||
288 | } | ||
289 | err = snd_wss_create(card, port, cport, | 290 | err = snd_wss_create(card, port, cport, |
290 | irq, dma1, dma2, hardware, hwshare, &chip); | 291 | irq, dma1, dma2, hardware, hwshare, &chip); |
291 | if (err < 0) | 292 | if (err < 0) |
292 | return err; | 293 | return err; |
293 | 294 | ||
294 | if (!(chip->hardware & WSS_HW_CS4236B_MASK)) { | 295 | if ((chip->hardware & WSS_HW_CS4236B_MASK) == 0) { |
295 | snd_printk(KERN_ERR "CS4236+: MODE3 and extended registers " | 296 | snd_printd("chip is not CS4236+, hardware=0x%x\n", |
296 | "not available, hardware=0x%x\n", chip->hardware); | 297 | chip->hardware); |
297 | snd_device_free(card, chip); | 298 | *rchip = chip; |
298 | return -ENODEV; | 299 | return 0; |
299 | } | 300 | } |
300 | #if 0 | 301 | #if 0 |
301 | { | 302 | { |
@@ -308,9 +309,16 @@ int snd_cs4236_create(struct snd_card *card, | |||
308 | idx, snd_cs4236_ctrl_in(chip, idx)); | 309 | idx, snd_cs4236_ctrl_in(chip, idx)); |
309 | } | 310 | } |
310 | #endif | 311 | #endif |
312 | if (cport < 0x100 || cport == SNDRV_AUTO_PORT) { | ||
313 | snd_printk(KERN_ERR "please, specify control port " | ||
314 | "for CS4236+ chips\n"); | ||
315 | snd_device_free(card, chip); | ||
316 | return -ENODEV; | ||
317 | } | ||
311 | ver1 = snd_cs4236_ctrl_in(chip, 1); | 318 | ver1 = snd_cs4236_ctrl_in(chip, 1); |
312 | ver2 = snd_cs4236_ext_in(chip, CS4236_VERSION); | 319 | ver2 = snd_cs4236_ext_in(chip, CS4236_VERSION); |
313 | snd_printdd("CS4236: [0x%lx] C1 (version) = 0x%x, ext = 0x%x\n", cport, ver1, ver2); | 320 | snd_printdd("CS4236: [0x%lx] C1 (version) = 0x%x, ext = 0x%x\n", |
321 | cport, ver1, ver2); | ||
314 | if (ver1 != ver2) { | 322 | if (ver1 != ver2) { |
315 | snd_printk(KERN_ERR "CS4236+ chip detected, but " | 323 | snd_printk(KERN_ERR "CS4236+ chip detected, but " |
316 | "control port 0x%lx is not valid\n", cport); | 324 | "control port 0x%lx is not valid\n", cport); |
@@ -321,13 +329,17 @@ int snd_cs4236_create(struct snd_card *card, | |||
321 | snd_cs4236_ctrl_out(chip, 2, 0xff); | 329 | snd_cs4236_ctrl_out(chip, 2, 0xff); |
322 | snd_cs4236_ctrl_out(chip, 3, 0x00); | 330 | snd_cs4236_ctrl_out(chip, 3, 0x00); |
323 | snd_cs4236_ctrl_out(chip, 4, 0x80); | 331 | snd_cs4236_ctrl_out(chip, 4, 0x80); |
324 | snd_cs4236_ctrl_out(chip, 5, ((IEC958_AES1_CON_PCM_CODER & 3) << 6) | IEC958_AES0_CON_EMPHASIS_NONE); | 332 | reg = ((IEC958_AES1_CON_PCM_CODER & 3) << 6) | |
333 | IEC958_AES0_CON_EMPHASIS_NONE; | ||
334 | snd_cs4236_ctrl_out(chip, 5, reg); | ||
325 | snd_cs4236_ctrl_out(chip, 6, IEC958_AES1_CON_PCM_CODER >> 2); | 335 | snd_cs4236_ctrl_out(chip, 6, IEC958_AES1_CON_PCM_CODER >> 2); |
326 | snd_cs4236_ctrl_out(chip, 7, 0x00); | 336 | snd_cs4236_ctrl_out(chip, 7, 0x00); |
327 | /* 0x8c for C8 is valid for Turtle Beach Malibu - the IEC-958 output */ | 337 | /* |
328 | /* is working with this setup, other hardware should have */ | 338 | * 0x8c for C8 is valid for Turtle Beach Malibu - the IEC-958 |
329 | /* different signal paths and this value should be selectable */ | 339 | * output is working with this setup, other hardware should |
330 | /* in the future */ | 340 | * have different signal paths and this value should be |
341 | * selectable in the future | ||
342 | */ | ||
331 | snd_cs4236_ctrl_out(chip, 8, 0x8c); | 343 | snd_cs4236_ctrl_out(chip, 8, 0x8c); |
332 | chip->rate_constraint = snd_cs4236_xrate; | 344 | chip->rate_constraint = snd_cs4236_xrate; |
333 | chip->set_playback_format = snd_cs4236_playback_format; | 345 | chip->set_playback_format = snd_cs4236_playback_format; |
@@ -339,9 +351,10 @@ int snd_cs4236_create(struct snd_card *card, | |||
339 | 351 | ||
340 | /* initialize extended registers */ | 352 | /* initialize extended registers */ |
341 | for (reg = 0; reg < sizeof(snd_cs4236_ext_map); reg++) | 353 | for (reg = 0; reg < sizeof(snd_cs4236_ext_map); reg++) |
342 | snd_cs4236_ext_out(chip, CS4236_I23VAL(reg), snd_cs4236_ext_map[reg]); | 354 | snd_cs4236_ext_out(chip, CS4236_I23VAL(reg), |
355 | snd_cs4236_ext_map[reg]); | ||
343 | 356 | ||
344 | /* initialize compatible but more featured registers */ | 357 | /* initialize compatible but more featured registers */ |
345 | snd_wss_out(chip, CS4231_LEFT_INPUT, 0x40); | 358 | snd_wss_out(chip, CS4231_LEFT_INPUT, 0x40); |
346 | snd_wss_out(chip, CS4231_RIGHT_INPUT, 0x40); | 359 | snd_wss_out(chip, CS4231_RIGHT_INPUT, 0x40); |
347 | snd_wss_out(chip, CS4231_AUX1_LEFT_INPUT, 0xff); | 360 | snd_wss_out(chip, CS4231_AUX1_LEFT_INPUT, 0xff); |
@@ -387,6 +400,14 @@ int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm) | |||
387 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ | 400 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ |
388 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } | 401 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } |
389 | 402 | ||
403 | #define CS4236_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ | ||
404 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | ||
405 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
406 | .info = snd_cs4236_info_single, \ | ||
407 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ | ||
408 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \ | ||
409 | .tlv = { .p = (xtlv) } } | ||
410 | |||
390 | static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 411 | static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
391 | { | 412 | { |
392 | int mask = (kcontrol->private_value >> 16) & 0xff; | 413 | int mask = (kcontrol->private_value >> 16) & 0xff; |
@@ -490,6 +511,16 @@ static int snd_cs4236_put_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
490 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ | 511 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ |
491 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } | 512 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } |
492 | 513 | ||
514 | #define CS4236_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, \ | ||
515 | shift_right, mask, invert, xtlv) \ | ||
516 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | ||
517 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
518 | .info = snd_cs4236_info_double, \ | ||
519 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ | ||
520 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \ | ||
521 | (shift_right << 19) | (mask << 24) | (invert << 22), \ | ||
522 | .tlv = { .p = (xtlv) } } | ||
523 | |||
493 | static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 524 | static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
494 | { | 525 | { |
495 | int mask = (kcontrol->private_value >> 24) & 0xff; | 526 | int mask = (kcontrol->private_value >> 24) & 0xff; |
@@ -560,12 +591,23 @@ static int snd_cs4236_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
560 | return change; | 591 | return change; |
561 | } | 592 | } |
562 | 593 | ||
563 | #define CS4236_DOUBLE1(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ | 594 | #define CS4236_DOUBLE1(xname, xindex, left_reg, right_reg, shift_left, \ |
595 | shift_right, mask, invert) \ | ||
564 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 596 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
565 | .info = snd_cs4236_info_double, \ | 597 | .info = snd_cs4236_info_double, \ |
566 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ | 598 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ |
567 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } | 599 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } |
568 | 600 | ||
601 | #define CS4236_DOUBLE1_TLV(xname, xindex, left_reg, right_reg, shift_left, \ | ||
602 | shift_right, mask, invert, xtlv) \ | ||
603 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | ||
604 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
605 | .info = snd_cs4236_info_double, \ | ||
606 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ | ||
607 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \ | ||
608 | (shift_right << 19) | (mask << 24) | (invert << 22), \ | ||
609 | .tlv = { .p = (xtlv) } } | ||
610 | |||
569 | static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 611 | static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
570 | { | 612 | { |
571 | struct snd_wss *chip = snd_kcontrol_chip(kcontrol); | 613 | struct snd_wss *chip = snd_kcontrol_chip(kcontrol); |
@@ -619,16 +661,18 @@ static int snd_cs4236_put_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
619 | return change; | 661 | return change; |
620 | } | 662 | } |
621 | 663 | ||
622 | #define CS4236_MASTER_DIGITAL(xname, xindex) \ | 664 | #define CS4236_MASTER_DIGITAL(xname, xindex, xtlv) \ |
623 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 665 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
666 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
624 | .info = snd_cs4236_info_double, \ | 667 | .info = snd_cs4236_info_double, \ |
625 | .get = snd_cs4236_get_master_digital, .put = snd_cs4236_put_master_digital, \ | 668 | .get = snd_cs4236_get_master_digital, .put = snd_cs4236_put_master_digital, \ |
626 | .private_value = 71 << 24 } | 669 | .private_value = 71 << 24, \ |
670 | .tlv = { .p = (xtlv) } } | ||
627 | 671 | ||
628 | static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) | 672 | static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) |
629 | { | 673 | { |
630 | return (vol < 64) ? 63 - vol : 64 + (71 - vol); | 674 | return (vol < 64) ? 63 - vol : 64 + (71 - vol); |
631 | } | 675 | } |
632 | 676 | ||
633 | static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 677 | static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
634 | { | 678 | { |
@@ -661,11 +705,13 @@ static int snd_cs4236_put_master_digital(struct snd_kcontrol *kcontrol, struct s | |||
661 | return change; | 705 | return change; |
662 | } | 706 | } |
663 | 707 | ||
664 | #define CS4235_OUTPUT_ACCU(xname, xindex) \ | 708 | #define CS4235_OUTPUT_ACCU(xname, xindex, xtlv) \ |
665 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 709 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
710 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
666 | .info = snd_cs4236_info_double, \ | 711 | .info = snd_cs4236_info_double, \ |
667 | .get = snd_cs4235_get_output_accu, .put = snd_cs4235_put_output_accu, \ | 712 | .get = snd_cs4235_get_output_accu, .put = snd_cs4235_put_output_accu, \ |
668 | .private_value = 3 << 24 } | 713 | .private_value = 3 << 24, \ |
714 | .tlv = { .p = (xtlv) } } | ||
669 | 715 | ||
670 | static inline int snd_cs4235_mixer_output_accu_get_volume(int vol) | 716 | static inline int snd_cs4235_mixer_output_accu_get_volume(int vol) |
671 | { | 717 | { |
@@ -720,41 +766,56 @@ static int snd_cs4235_put_output_accu(struct snd_kcontrol *kcontrol, struct snd_ | |||
720 | return change; | 766 | return change; |
721 | } | 767 | } |
722 | 768 | ||
769 | static const DECLARE_TLV_DB_SCALE(db_scale_7bit, -9450, 150, 0); | ||
770 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | ||
771 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit_12db_max, -8250, 150, 0); | ||
772 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); | ||
773 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_22db_max, -2400, 150, 0); | ||
774 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); | ||
775 | static const DECLARE_TLV_DB_SCALE(db_scale_2bit, -1800, 600, 0); | ||
776 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); | ||
777 | |||
723 | static struct snd_kcontrol_new snd_cs4236_controls[] = { | 778 | static struct snd_kcontrol_new snd_cs4236_controls[] = { |
724 | 779 | ||
725 | CS4236_DOUBLE("Master Digital Playback Switch", 0, | 780 | CS4236_DOUBLE("Master Digital Playback Switch", 0, |
726 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), | 781 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), |
727 | CS4236_DOUBLE("Master Digital Capture Switch", 0, | 782 | CS4236_DOUBLE("Master Digital Capture Switch", 0, |
728 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), | 783 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), |
729 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0), | 784 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0, db_scale_7bit), |
730 | 785 | ||
731 | CS4236_DOUBLE("Capture Boost Volume", 0, | 786 | CS4236_DOUBLE_TLV("Capture Boost Volume", 0, |
732 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1), | 787 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1, |
788 | db_scale_2bit), | ||
733 | 789 | ||
734 | WSS_DOUBLE("PCM Playback Switch", 0, | 790 | WSS_DOUBLE("PCM Playback Switch", 0, |
735 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 791 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
736 | WSS_DOUBLE("PCM Playback Volume", 0, | 792 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
737 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 793 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
794 | db_scale_6bit), | ||
738 | 795 | ||
739 | CS4236_DOUBLE("DSP Playback Switch", 0, | 796 | CS4236_DOUBLE("DSP Playback Switch", 0, |
740 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), | 797 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), |
741 | CS4236_DOUBLE("DSP Playback Volume", 0, | 798 | CS4236_DOUBLE_TLV("DSP Playback Volume", 0, |
742 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1), | 799 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1, |
800 | db_scale_6bit), | ||
743 | 801 | ||
744 | CS4236_DOUBLE("FM Playback Switch", 0, | 802 | CS4236_DOUBLE("FM Playback Switch", 0, |
745 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1), | 803 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1), |
746 | CS4236_DOUBLE("FM Playback Volume", 0, | 804 | CS4236_DOUBLE_TLV("FM Playback Volume", 0, |
747 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1), | 805 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1, |
806 | db_scale_6bit), | ||
748 | 807 | ||
749 | CS4236_DOUBLE("Wavetable Playback Switch", 0, | 808 | CS4236_DOUBLE("Wavetable Playback Switch", 0, |
750 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1), | 809 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1), |
751 | CS4236_DOUBLE("Wavetable Playback Volume", 0, | 810 | CS4236_DOUBLE_TLV("Wavetable Playback Volume", 0, |
752 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1), | 811 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1, |
812 | db_scale_6bit_12db_max), | ||
753 | 813 | ||
754 | WSS_DOUBLE("Synth Playback Switch", 0, | 814 | WSS_DOUBLE("Synth Playback Switch", 0, |
755 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 815 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
756 | WSS_DOUBLE("Synth Volume", 0, | 816 | WSS_DOUBLE_TLV("Synth Volume", 0, |
757 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 817 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
818 | db_scale_5bit_12db_max), | ||
758 | WSS_DOUBLE("Synth Capture Switch", 0, | 819 | WSS_DOUBLE("Synth Capture Switch", 0, |
759 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), | 820 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), |
760 | WSS_DOUBLE("Synth Capture Bypass", 0, | 821 | WSS_DOUBLE("Synth Capture Bypass", 0, |
@@ -764,14 +825,16 @@ CS4236_DOUBLE("Mic Playback Switch", 0, | |||
764 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), | 825 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), |
765 | CS4236_DOUBLE("Mic Capture Switch", 0, | 826 | CS4236_DOUBLE("Mic Capture Switch", 0, |
766 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), | 827 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), |
767 | CS4236_DOUBLE("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 0, 0, 31, 1), | 828 | CS4236_DOUBLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC, |
768 | CS4236_DOUBLE("Mic Playback Boost", 0, | 829 | 0, 0, 31, 1, db_scale_5bit_22db_max), |
830 | CS4236_DOUBLE("Mic Playback Boost (+20dB)", 0, | ||
769 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0), | 831 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0), |
770 | 832 | ||
771 | WSS_DOUBLE("Line Playback Switch", 0, | 833 | WSS_DOUBLE("Line Playback Switch", 0, |
772 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 834 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
773 | WSS_DOUBLE("Line Volume", 0, | 835 | WSS_DOUBLE_TLV("Line Volume", 0, |
774 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 836 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
837 | db_scale_5bit_12db_max), | ||
775 | WSS_DOUBLE("Line Capture Switch", 0, | 838 | WSS_DOUBLE("Line Capture Switch", 0, |
776 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), | 839 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), |
777 | WSS_DOUBLE("Line Capture Bypass", 0, | 840 | WSS_DOUBLE("Line Capture Bypass", 0, |
@@ -779,57 +842,63 @@ WSS_DOUBLE("Line Capture Bypass", 0, | |||
779 | 842 | ||
780 | WSS_DOUBLE("CD Playback Switch", 0, | 843 | WSS_DOUBLE("CD Playback Switch", 0, |
781 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 844 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
782 | WSS_DOUBLE("CD Volume", 0, | 845 | WSS_DOUBLE_TLV("CD Volume", 0, |
783 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 846 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
847 | db_scale_5bit_12db_max), | ||
784 | WSS_DOUBLE("CD Capture Switch", 0, | 848 | WSS_DOUBLE("CD Capture Switch", 0, |
785 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), | 849 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), |
786 | 850 | ||
787 | CS4236_DOUBLE1("Mono Output Playback Switch", 0, | 851 | CS4236_DOUBLE1("Mono Output Playback Switch", 0, |
788 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), | 852 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), |
789 | CS4236_DOUBLE1("Mono Playback Switch", 0, | 853 | CS4236_DOUBLE1("Beep Playback Switch", 0, |
790 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), | 854 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), |
791 | WSS_SINGLE("Mono Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), | 855 | WSS_SINGLE_TLV("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1, |
792 | WSS_SINGLE("Mono Playback Bypass", 0, CS4231_MONO_CTRL, 5, 1, 0), | 856 | db_scale_4bit), |
857 | WSS_SINGLE("Beep Bypass Playback Switch", 0, CS4231_MONO_CTRL, 5, 1, 0), | ||
793 | 858 | ||
794 | WSS_DOUBLE("Capture Volume", 0, | 859 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, |
795 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | 860 | 0, 0, 15, 0, db_scale_rec_gain), |
796 | WSS_DOUBLE("Analog Loopback Capture Switch", 0, | 861 | WSS_DOUBLE("Analog Loopback Capture Switch", 0, |
797 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), | 862 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), |
798 | 863 | ||
799 | WSS_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | 864 | WSS_SINGLE("Loopback Digital Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), |
800 | CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, | 865 | CS4236_DOUBLE1_TLV("Loopback Digital Playback Volume", 0, |
801 | CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1) | 866 | CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1, |
867 | db_scale_6bit), | ||
802 | }; | 868 | }; |
803 | 869 | ||
870 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_6db_max, -5600, 200, 0); | ||
871 | static const DECLARE_TLV_DB_SCALE(db_scale_2bit_16db_max, -2400, 800, 0); | ||
872 | |||
804 | static struct snd_kcontrol_new snd_cs4235_controls[] = { | 873 | static struct snd_kcontrol_new snd_cs4235_controls[] = { |
805 | 874 | ||
806 | WSS_DOUBLE("Master Switch", 0, | 875 | WSS_DOUBLE("Master Playback Switch", 0, |
807 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), | 876 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), |
808 | WSS_DOUBLE("Master Volume", 0, | 877 | WSS_DOUBLE_TLV("Master Playback Volume", 0, |
809 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1), | 878 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1, |
810 | 879 | db_scale_5bit_6db_max), | |
811 | CS4235_OUTPUT_ACCU("Playback Volume", 0), | ||
812 | 880 | ||
813 | CS4236_DOUBLE("Master Digital Playback Switch", 0, | 881 | CS4235_OUTPUT_ACCU("Playback Volume", 0, db_scale_2bit_16db_max), |
814 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), | ||
815 | CS4236_DOUBLE("Master Digital Capture Switch", 0, | ||
816 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), | ||
817 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0), | ||
818 | 882 | ||
819 | WSS_DOUBLE("Master Digital Playback Switch", 1, | 883 | WSS_DOUBLE("Synth Playback Switch", 1, |
820 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 884 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
821 | WSS_DOUBLE("Master Digital Capture Switch", 1, | 885 | WSS_DOUBLE("Synth Capture Switch", 1, |
822 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), | 886 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), |
823 | WSS_DOUBLE("Master Digital Volume", 1, | 887 | WSS_DOUBLE_TLV("Synth Volume", 1, |
824 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 888 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
889 | db_scale_5bit_12db_max), | ||
825 | 890 | ||
826 | CS4236_DOUBLE("Capture Volume", 0, | 891 | CS4236_DOUBLE_TLV("Capture Volume", 0, |
827 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1), | 892 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1, |
893 | db_scale_2bit), | ||
828 | 894 | ||
829 | WSS_DOUBLE("PCM Switch", 0, | 895 | WSS_DOUBLE("PCM Playback Switch", 0, |
830 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 896 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
831 | WSS_DOUBLE("PCM Volume", 0, | 897 | WSS_DOUBLE("PCM Capture Switch", 0, |
832 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 898 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), |
899 | WSS_DOUBLE_TLV("PCM Volume", 0, | ||
900 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, | ||
901 | db_scale_6bit), | ||
833 | 902 | ||
834 | CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), | 903 | CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), |
835 | 904 | ||
@@ -842,29 +911,29 @@ CS4236_DOUBLE("Mic Capture Switch", 0, | |||
842 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), | 911 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), |
843 | CS4236_DOUBLE("Mic Playback Switch", 0, | 912 | CS4236_DOUBLE("Mic Playback Switch", 0, |
844 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), | 913 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), |
845 | CS4236_SINGLE("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1), | 914 | CS4236_SINGLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1, |
846 | CS4236_SINGLE("Mic Playback Boost", 0, CS4236_LEFT_MIC, 5, 1, 0), | 915 | db_scale_5bit_22db_max), |
916 | CS4236_SINGLE("Mic Boost (+20dB)", 0, CS4236_LEFT_MIC, 5, 1, 0), | ||
847 | 917 | ||
848 | WSS_DOUBLE("Aux Playback Switch", 0, | 918 | WSS_DOUBLE("Line Playback Switch", 0, |
849 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 919 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
850 | WSS_DOUBLE("Aux Capture Switch", 0, | 920 | WSS_DOUBLE("Line Capture Switch", 0, |
851 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), | 921 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), |
852 | WSS_DOUBLE("Aux Volume", 0, | 922 | WSS_DOUBLE_TLV("Line Volume", 0, |
853 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 923 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
924 | db_scale_5bit_12db_max), | ||
854 | 925 | ||
855 | WSS_DOUBLE("Aux Playback Switch", 1, | 926 | WSS_DOUBLE("CD Playback Switch", 1, |
856 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 927 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
857 | WSS_DOUBLE("Aux Capture Switch", 1, | 928 | WSS_DOUBLE("CD Capture Switch", 1, |
858 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), | 929 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), |
859 | WSS_DOUBLE("Aux Volume", 1, | 930 | WSS_DOUBLE_TLV("CD Volume", 1, |
860 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 931 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
861 | 932 | db_scale_5bit_12db_max), | |
862 | CS4236_DOUBLE1("Master Mono Switch", 0, | ||
863 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), | ||
864 | 933 | ||
865 | CS4236_DOUBLE1("Mono Switch", 0, | 934 | CS4236_DOUBLE1("Beep Playback Switch", 0, |
866 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), | 935 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), |
867 | WSS_SINGLE("Mono Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), | 936 | WSS_SINGLE("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), |
868 | 937 | ||
869 | WSS_DOUBLE("Analog Loopback Switch", 0, | 938 | WSS_DOUBLE("Analog Loopback Switch", 0, |
870 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), | 939 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), |
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 4c6e14f87f2d..c76bb00c9d15 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c | |||
@@ -982,7 +982,7 @@ ES1688_DOUBLE("CD Playback Volume", 0, ES1688_CD_DEV, ES1688_CD_DEV, 4, 0, 15, 0 | |||
982 | ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0), | 982 | ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0), |
983 | ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0), | 983 | ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0), |
984 | ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0), | 984 | ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0), |
985 | ES1688_SINGLE("PC Speaker Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0), | 985 | ES1688_SINGLE("Beep Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0), |
986 | ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0), | 986 | ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0), |
987 | ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1), | 987 | ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1), |
988 | { | 988 | { |
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 8cfbff73a835..9a43baae7250 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c | |||
@@ -102,8 +102,6 @@ | |||
102 | 102 | ||
103 | struct snd_es18xx { | 103 | struct snd_es18xx { |
104 | unsigned long port; /* port of ESS chip */ | 104 | unsigned long port; /* port of ESS chip */ |
105 | unsigned long mpu_port; /* MPU-401 port of ESS chip */ | ||
106 | unsigned long fm_port; /* FM port */ | ||
107 | unsigned long ctrl_port; /* Control port of ESS chip */ | 105 | unsigned long ctrl_port; /* Control port of ESS chip */ |
108 | struct resource *res_port; | 106 | struct resource *res_port; |
109 | struct resource *res_mpu_port; | 107 | struct resource *res_mpu_port; |
@@ -116,12 +114,9 @@ struct snd_es18xx { | |||
116 | unsigned short audio2_vol; /* volume level of audio2 */ | 114 | unsigned short audio2_vol; /* volume level of audio2 */ |
117 | 115 | ||
118 | unsigned short active; /* active channel mask */ | 116 | unsigned short active; /* active channel mask */ |
119 | unsigned int dma1_size; | ||
120 | unsigned int dma2_size; | ||
121 | unsigned int dma1_shift; | 117 | unsigned int dma1_shift; |
122 | unsigned int dma2_shift; | 118 | unsigned int dma2_shift; |
123 | 119 | ||
124 | struct snd_card *card; | ||
125 | struct snd_pcm *pcm; | 120 | struct snd_pcm *pcm; |
126 | struct snd_pcm_substream *playback_a_substream; | 121 | struct snd_pcm_substream *playback_a_substream; |
127 | struct snd_pcm_substream *capture_a_substream; | 122 | struct snd_pcm_substream *capture_a_substream; |
@@ -136,14 +131,9 @@ struct snd_es18xx { | |||
136 | 131 | ||
137 | spinlock_t reg_lock; | 132 | spinlock_t reg_lock; |
138 | spinlock_t mixer_lock; | 133 | spinlock_t mixer_lock; |
139 | spinlock_t ctrl_lock; | ||
140 | #ifdef CONFIG_PM | 134 | #ifdef CONFIG_PM |
141 | unsigned char pm_reg; | 135 | unsigned char pm_reg; |
142 | #endif | 136 | #endif |
143 | }; | ||
144 | |||
145 | struct snd_audiodrive { | ||
146 | struct snd_es18xx *chip; | ||
147 | #ifdef CONFIG_PNP | 137 | #ifdef CONFIG_PNP |
148 | struct pnp_dev *dev; | 138 | struct pnp_dev *dev; |
149 | struct pnp_dev *devc; | 139 | struct pnp_dev *devc; |
@@ -359,7 +349,7 @@ static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned ch | |||
359 | } | 349 | } |
360 | 350 | ||
361 | 351 | ||
362 | static int snd_es18xx_reset(struct snd_es18xx *chip) | 352 | static int __devinit snd_es18xx_reset(struct snd_es18xx *chip) |
363 | { | 353 | { |
364 | int i; | 354 | int i; |
365 | outb(0x03, chip->port + 0x06); | 355 | outb(0x03, chip->port + 0x06); |
@@ -495,8 +485,6 @@ static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, | |||
495 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 485 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
496 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 486 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
497 | 487 | ||
498 | chip->dma2_size = size; | ||
499 | |||
500 | snd_es18xx_rate_set(chip, substream, DAC2); | 488 | snd_es18xx_rate_set(chip, substream, DAC2); |
501 | 489 | ||
502 | /* Transfer Count Reload */ | 490 | /* Transfer Count Reload */ |
@@ -596,8 +584,6 @@ static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream) | |||
596 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 584 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
597 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 585 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
598 | 586 | ||
599 | chip->dma1_size = size; | ||
600 | |||
601 | snd_es18xx_reset_fifo(chip); | 587 | snd_es18xx_reset_fifo(chip); |
602 | 588 | ||
603 | /* Set stereo/mono */ | 589 | /* Set stereo/mono */ |
@@ -664,8 +650,6 @@ static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip, | |||
664 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 650 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
665 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 651 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
666 | 652 | ||
667 | chip->dma1_size = size; | ||
668 | |||
669 | snd_es18xx_reset_fifo(chip); | 653 | snd_es18xx_reset_fifo(chip); |
670 | 654 | ||
671 | /* Set stereo/mono */ | 655 | /* Set stereo/mono */ |
@@ -755,7 +739,8 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, | |||
755 | 739 | ||
756 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | 740 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) |
757 | { | 741 | { |
758 | struct snd_es18xx *chip = dev_id; | 742 | struct snd_card *card = dev_id; |
743 | struct snd_es18xx *chip = card->private_data; | ||
759 | unsigned char status; | 744 | unsigned char status; |
760 | 745 | ||
761 | if (chip->caps & ES18XX_CONTROL) { | 746 | if (chip->caps & ES18XX_CONTROL) { |
@@ -805,12 +790,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | |||
805 | int split = 0; | 790 | int split = 0; |
806 | if (chip->caps & ES18XX_HWV) { | 791 | if (chip->caps & ES18XX_HWV) { |
807 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; | 792 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; |
808 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); | 793 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
809 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); | 794 | &chip->hw_switch->id); |
795 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
796 | &chip->hw_volume->id); | ||
810 | } | 797 | } |
811 | if (!split) { | 798 | if (!split) { |
812 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); | 799 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
813 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); | 800 | &chip->master_switch->id); |
801 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
802 | &chip->master_volume->id); | ||
814 | } | 803 | } |
815 | /* ack interrupt */ | 804 | /* ack interrupt */ |
816 | snd_es18xx_mixer_write(chip, 0x66, 0x00); | 805 | snd_es18xx_mixer_write(chip, 0x66, 0x00); |
@@ -821,17 +810,18 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | |||
821 | static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) | 810 | static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) |
822 | { | 811 | { |
823 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); | 812 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
813 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
824 | int pos; | 814 | int pos; |
825 | 815 | ||
826 | if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { | 816 | if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { |
827 | if (!(chip->active & DAC2)) | 817 | if (!(chip->active & DAC2)) |
828 | return 0; | 818 | return 0; |
829 | pos = snd_dma_pointer(chip->dma2, chip->dma2_size); | 819 | pos = snd_dma_pointer(chip->dma2, size); |
830 | return pos >> chip->dma2_shift; | 820 | return pos >> chip->dma2_shift; |
831 | } else { | 821 | } else { |
832 | if (!(chip->active & DAC1)) | 822 | if (!(chip->active & DAC1)) |
833 | return 0; | 823 | return 0; |
834 | pos = snd_dma_pointer(chip->dma1, chip->dma1_size); | 824 | pos = snd_dma_pointer(chip->dma1, size); |
835 | return pos >> chip->dma1_shift; | 825 | return pos >> chip->dma1_shift; |
836 | } | 826 | } |
837 | } | 827 | } |
@@ -839,11 +829,12 @@ static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *s | |||
839 | static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) | 829 | static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) |
840 | { | 830 | { |
841 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); | 831 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
832 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
842 | int pos; | 833 | int pos; |
843 | 834 | ||
844 | if (!(chip->active & ADC1)) | 835 | if (!(chip->active & ADC1)) |
845 | return 0; | 836 | return 0; |
846 | pos = snd_dma_pointer(chip->dma1, chip->dma1_size); | 837 | pos = snd_dma_pointer(chip->dma1, size); |
847 | return pos >> chip->dma1_shift; | 838 | return pos >> chip->dma1_shift; |
848 | } | 839 | } |
849 | 840 | ||
@@ -974,9 +965,6 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) | |||
974 | 965 | ||
975 | static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 966 | static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
976 | { | 967 | { |
977 | static char *texts4Source[4] = { | ||
978 | "Mic", "CD", "Line", "Master" | ||
979 | }; | ||
980 | static char *texts5Source[5] = { | 968 | static char *texts5Source[5] = { |
981 | "Mic", "CD", "Line", "Master", "Mix" | 969 | "Mic", "CD", "Line", "Master", "Mix" |
982 | }; | 970 | }; |
@@ -994,7 +982,8 @@ static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_ele | |||
994 | uinfo->value.enumerated.items = 4; | 982 | uinfo->value.enumerated.items = 4; |
995 | if (uinfo->value.enumerated.item > 3) | 983 | if (uinfo->value.enumerated.item > 3) |
996 | uinfo->value.enumerated.item = 3; | 984 | uinfo->value.enumerated.item = 3; |
997 | strcpy(uinfo->value.enumerated.name, texts4Source[uinfo->value.enumerated.item]); | 985 | strcpy(uinfo->value.enumerated.name, |
986 | texts5Source[uinfo->value.enumerated.item]); | ||
998 | break; | 987 | break; |
999 | case 0x1887: | 988 | case 0x1887: |
1000 | case 0x1888: | 989 | case 0x1888: |
@@ -1313,7 +1302,7 @@ ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) | |||
1313 | * The chipset specific mixer controls | 1302 | * The chipset specific mixer controls |
1314 | */ | 1303 | */ |
1315 | static struct snd_kcontrol_new snd_es18xx_opt_speaker = | 1304 | static struct snd_kcontrol_new snd_es18xx_opt_speaker = |
1316 | ES18XX_SINGLE("PC Speaker Playback Volume", 0, 0x3c, 0, 7, 0); | 1305 | ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0); |
1317 | 1306 | ||
1318 | static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { | 1307 | static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { |
1319 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), | 1308 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), |
@@ -1378,11 +1367,9 @@ ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0), | |||
1378 | static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) | 1367 | static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) |
1379 | { | 1368 | { |
1380 | int data; | 1369 | int data; |
1381 | unsigned long flags; | 1370 | |
1382 | spin_lock_irqsave(&chip->ctrl_lock, flags); | ||
1383 | outb(reg, chip->ctrl_port); | 1371 | outb(reg, chip->ctrl_port); |
1384 | data = inb(chip->ctrl_port + 1); | 1372 | data = inb(chip->ctrl_port + 1); |
1385 | spin_unlock_irqrestore(&chip->ctrl_lock, flags); | ||
1386 | return data; | 1373 | return data; |
1387 | } | 1374 | } |
1388 | 1375 | ||
@@ -1398,7 +1385,9 @@ static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip, | |||
1398 | #endif | 1385 | #endif |
1399 | } | 1386 | } |
1400 | 1387 | ||
1401 | static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | 1388 | static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip, |
1389 | unsigned long mpu_port, | ||
1390 | unsigned long fm_port) | ||
1402 | { | 1391 | { |
1403 | int mask = 0; | 1392 | int mask = 0; |
1404 | 1393 | ||
@@ -1412,15 +1401,15 @@ static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | |||
1412 | if (chip->caps & ES18XX_CONTROL) { | 1401 | if (chip->caps & ES18XX_CONTROL) { |
1413 | /* Hardware volume IRQ */ | 1402 | /* Hardware volume IRQ */ |
1414 | snd_es18xx_config_write(chip, 0x27, chip->irq); | 1403 | snd_es18xx_config_write(chip, 0x27, chip->irq); |
1415 | if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { | 1404 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
1416 | /* FM I/O */ | 1405 | /* FM I/O */ |
1417 | snd_es18xx_config_write(chip, 0x62, chip->fm_port >> 8); | 1406 | snd_es18xx_config_write(chip, 0x62, fm_port >> 8); |
1418 | snd_es18xx_config_write(chip, 0x63, chip->fm_port & 0xff); | 1407 | snd_es18xx_config_write(chip, 0x63, fm_port & 0xff); |
1419 | } | 1408 | } |
1420 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { | 1409 | if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) { |
1421 | /* MPU-401 I/O */ | 1410 | /* MPU-401 I/O */ |
1422 | snd_es18xx_config_write(chip, 0x64, chip->mpu_port >> 8); | 1411 | snd_es18xx_config_write(chip, 0x64, mpu_port >> 8); |
1423 | snd_es18xx_config_write(chip, 0x65, chip->mpu_port & 0xff); | 1412 | snd_es18xx_config_write(chip, 0x65, mpu_port & 0xff); |
1424 | /* MPU-401 IRQ */ | 1413 | /* MPU-401 IRQ */ |
1425 | snd_es18xx_config_write(chip, 0x28, chip->irq); | 1414 | snd_es18xx_config_write(chip, 0x28, chip->irq); |
1426 | } | 1415 | } |
@@ -1507,11 +1496,12 @@ static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | |||
1507 | snd_es18xx_mixer_write(chip, 0x7A, 0x68); | 1496 | snd_es18xx_mixer_write(chip, 0x7A, 0x68); |
1508 | /* Enable and set hardware volume interrupt */ | 1497 | /* Enable and set hardware volume interrupt */ |
1509 | snd_es18xx_mixer_write(chip, 0x64, 0x06); | 1498 | snd_es18xx_mixer_write(chip, 0x64, 0x06); |
1510 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { | 1499 | if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) { |
1511 | /* MPU401 share irq with audio | 1500 | /* MPU401 share irq with audio |
1512 | Joystick enabled | 1501 | Joystick enabled |
1513 | FM enabled */ | 1502 | FM enabled */ |
1514 | snd_es18xx_mixer_write(chip, 0x40, 0x43 | (chip->mpu_port & 0xf0) >> 1); | 1503 | snd_es18xx_mixer_write(chip, 0x40, |
1504 | 0x43 | (mpu_port & 0xf0) >> 1); | ||
1515 | } | 1505 | } |
1516 | snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01); | 1506 | snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01); |
1517 | } | 1507 | } |
@@ -1629,7 +1619,9 @@ static int __devinit snd_es18xx_identify(struct snd_es18xx *chip) | |||
1629 | return 0; | 1619 | return 0; |
1630 | } | 1620 | } |
1631 | 1621 | ||
1632 | static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | 1622 | static int __devinit snd_es18xx_probe(struct snd_es18xx *chip, |
1623 | unsigned long mpu_port, | ||
1624 | unsigned long fm_port) | ||
1633 | { | 1625 | { |
1634 | if (snd_es18xx_identify(chip) < 0) { | 1626 | if (snd_es18xx_identify(chip) < 0) { |
1635 | snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); | 1627 | snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); |
@@ -1650,8 +1642,6 @@ static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | |||
1650 | chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_I2S | ES18XX_CONTROL | ES18XX_HWV; | 1642 | chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_I2S | ES18XX_CONTROL | ES18XX_HWV; |
1651 | break; | 1643 | break; |
1652 | case 0x1887: | 1644 | case 0x1887: |
1653 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; | ||
1654 | break; | ||
1655 | case 0x1888: | 1645 | case 0x1888: |
1656 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; | 1646 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; |
1657 | break; | 1647 | break; |
@@ -1666,7 +1656,7 @@ static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | |||
1666 | if (chip->dma1 == chip->dma2) | 1656 | if (chip->dma1 == chip->dma2) |
1667 | chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); | 1657 | chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); |
1668 | 1658 | ||
1669 | return snd_es18xx_initialize(chip); | 1659 | return snd_es18xx_initialize(chip, mpu_port, fm_port); |
1670 | } | 1660 | } |
1671 | 1661 | ||
1672 | static struct snd_pcm_ops snd_es18xx_playback_ops = { | 1662 | static struct snd_pcm_ops snd_es18xx_playback_ops = { |
@@ -1691,8 +1681,10 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = { | |||
1691 | .pointer = snd_es18xx_capture_pointer, | 1681 | .pointer = snd_es18xx_capture_pointer, |
1692 | }; | 1682 | }; |
1693 | 1683 | ||
1694 | static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) | 1684 | static int __devinit snd_es18xx_pcm(struct snd_card *card, int device, |
1685 | struct snd_pcm **rpcm) | ||
1695 | { | 1686 | { |
1687 | struct snd_es18xx *chip = card->private_data; | ||
1696 | struct snd_pcm *pcm; | 1688 | struct snd_pcm *pcm; |
1697 | char str[16]; | 1689 | char str[16]; |
1698 | int err; | 1690 | int err; |
@@ -1701,9 +1693,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
1701 | *rpcm = NULL; | 1693 | *rpcm = NULL; |
1702 | sprintf(str, "ES%x", chip->version); | 1694 | sprintf(str, "ES%x", chip->version); |
1703 | if (chip->caps & ES18XX_PCM2) | 1695 | if (chip->caps & ES18XX_PCM2) |
1704 | err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); | 1696 | err = snd_pcm_new(card, str, device, 2, 1, &pcm); |
1705 | else | 1697 | else |
1706 | err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); | 1698 | err = snd_pcm_new(card, str, device, 1, 1, &pcm); |
1707 | if (err < 0) | 1699 | if (err < 0) |
1708 | return err; | 1700 | return err; |
1709 | 1701 | ||
@@ -1734,10 +1726,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
1734 | #ifdef CONFIG_PM | 1726 | #ifdef CONFIG_PM |
1735 | static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | 1727 | static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) |
1736 | { | 1728 | { |
1737 | struct snd_audiodrive *acard = card->private_data; | 1729 | struct snd_es18xx *chip = card->private_data; |
1738 | struct snd_es18xx *chip = acard->chip; | ||
1739 | 1730 | ||
1740 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); | 1731 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
1741 | 1732 | ||
1742 | snd_pcm_suspend_all(chip->pcm); | 1733 | snd_pcm_suspend_all(chip->pcm); |
1743 | 1734 | ||
@@ -1752,24 +1743,25 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | |||
1752 | 1743 | ||
1753 | static int snd_es18xx_resume(struct snd_card *card) | 1744 | static int snd_es18xx_resume(struct snd_card *card) |
1754 | { | 1745 | { |
1755 | struct snd_audiodrive *acard = card->private_data; | 1746 | struct snd_es18xx *chip = card->private_data; |
1756 | struct snd_es18xx *chip = acard->chip; | ||
1757 | 1747 | ||
1758 | /* restore PM register, we won't wake till (not 0x07) i/o activity though */ | 1748 | /* restore PM register, we won't wake till (not 0x07) i/o activity though */ |
1759 | snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); | 1749 | snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); |
1760 | 1750 | ||
1761 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); | 1751 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
1762 | return 0; | 1752 | return 0; |
1763 | } | 1753 | } |
1764 | #endif /* CONFIG_PM */ | 1754 | #endif /* CONFIG_PM */ |
1765 | 1755 | ||
1766 | static int snd_es18xx_free(struct snd_es18xx *chip) | 1756 | static int snd_es18xx_free(struct snd_card *card) |
1767 | { | 1757 | { |
1758 | struct snd_es18xx *chip = card->private_data; | ||
1759 | |||
1768 | release_and_free_resource(chip->res_port); | 1760 | release_and_free_resource(chip->res_port); |
1769 | release_and_free_resource(chip->res_ctrl_port); | 1761 | release_and_free_resource(chip->res_ctrl_port); |
1770 | release_and_free_resource(chip->res_mpu_port); | 1762 | release_and_free_resource(chip->res_mpu_port); |
1771 | if (chip->irq >= 0) | 1763 | if (chip->irq >= 0) |
1772 | free_irq(chip->irq, (void *) chip); | 1764 | free_irq(chip->irq, (void *) card); |
1773 | if (chip->dma1 >= 0) { | 1765 | if (chip->dma1 >= 0) { |
1774 | disable_dma(chip->dma1); | 1766 | disable_dma(chip->dma1); |
1775 | free_dma(chip->dma1); | 1767 | free_dma(chip->dma1); |
@@ -1778,93 +1770,82 @@ static int snd_es18xx_free(struct snd_es18xx *chip) | |||
1778 | disable_dma(chip->dma2); | 1770 | disable_dma(chip->dma2); |
1779 | free_dma(chip->dma2); | 1771 | free_dma(chip->dma2); |
1780 | } | 1772 | } |
1781 | kfree(chip); | ||
1782 | return 0; | 1773 | return 0; |
1783 | } | 1774 | } |
1784 | 1775 | ||
1785 | static int snd_es18xx_dev_free(struct snd_device *device) | 1776 | static int snd_es18xx_dev_free(struct snd_device *device) |
1786 | { | 1777 | { |
1787 | struct snd_es18xx *chip = device->device_data; | 1778 | return snd_es18xx_free(device->card); |
1788 | return snd_es18xx_free(chip); | ||
1789 | } | 1779 | } |
1790 | 1780 | ||
1791 | static int __devinit snd_es18xx_new_device(struct snd_card *card, | 1781 | static int __devinit snd_es18xx_new_device(struct snd_card *card, |
1792 | unsigned long port, | 1782 | unsigned long port, |
1793 | unsigned long mpu_port, | 1783 | unsigned long mpu_port, |
1794 | unsigned long fm_port, | 1784 | unsigned long fm_port, |
1795 | int irq, int dma1, int dma2, | 1785 | int irq, int dma1, int dma2) |
1796 | struct snd_es18xx ** rchip) | ||
1797 | { | 1786 | { |
1798 | struct snd_es18xx *chip; | 1787 | struct snd_es18xx *chip = card->private_data; |
1799 | static struct snd_device_ops ops = { | 1788 | static struct snd_device_ops ops = { |
1800 | .dev_free = snd_es18xx_dev_free, | 1789 | .dev_free = snd_es18xx_dev_free, |
1801 | }; | 1790 | }; |
1802 | int err; | 1791 | int err; |
1803 | 1792 | ||
1804 | *rchip = NULL; | ||
1805 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
1806 | if (chip == NULL) | ||
1807 | return -ENOMEM; | ||
1808 | spin_lock_init(&chip->reg_lock); | 1793 | spin_lock_init(&chip->reg_lock); |
1809 | spin_lock_init(&chip->mixer_lock); | 1794 | spin_lock_init(&chip->mixer_lock); |
1810 | spin_lock_init(&chip->ctrl_lock); | ||
1811 | chip->card = card; | ||
1812 | chip->port = port; | 1795 | chip->port = port; |
1813 | chip->mpu_port = mpu_port; | ||
1814 | chip->fm_port = fm_port; | ||
1815 | chip->irq = -1; | 1796 | chip->irq = -1; |
1816 | chip->dma1 = -1; | 1797 | chip->dma1 = -1; |
1817 | chip->dma2 = -1; | 1798 | chip->dma2 = -1; |
1818 | chip->audio2_vol = 0x00; | 1799 | chip->audio2_vol = 0x00; |
1819 | chip->active = 0; | 1800 | chip->active = 0; |
1820 | 1801 | ||
1821 | if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { | 1802 | chip->res_port = request_region(port, 16, "ES18xx"); |
1822 | snd_es18xx_free(chip); | 1803 | if (chip->res_port == NULL) { |
1804 | snd_es18xx_free(card); | ||
1823 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); | 1805 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); |
1824 | return -EBUSY; | 1806 | return -EBUSY; |
1825 | } | 1807 | } |
1826 | 1808 | ||
1827 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) { | 1809 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", |
1828 | snd_es18xx_free(chip); | 1810 | (void *) card)) { |
1811 | snd_es18xx_free(card); | ||
1829 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); | 1812 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); |
1830 | return -EBUSY; | 1813 | return -EBUSY; |
1831 | } | 1814 | } |
1832 | chip->irq = irq; | 1815 | chip->irq = irq; |
1833 | 1816 | ||
1834 | if (request_dma(dma1, "ES18xx DMA 1")) { | 1817 | if (request_dma(dma1, "ES18xx DMA 1")) { |
1835 | snd_es18xx_free(chip); | 1818 | snd_es18xx_free(card); |
1836 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); | 1819 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); |
1837 | return -EBUSY; | 1820 | return -EBUSY; |
1838 | } | 1821 | } |
1839 | chip->dma1 = dma1; | 1822 | chip->dma1 = dma1; |
1840 | 1823 | ||
1841 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { | 1824 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { |
1842 | snd_es18xx_free(chip); | 1825 | snd_es18xx_free(card); |
1843 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); | 1826 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); |
1844 | return -EBUSY; | 1827 | return -EBUSY; |
1845 | } | 1828 | } |
1846 | chip->dma2 = dma2; | 1829 | chip->dma2 = dma2; |
1847 | 1830 | ||
1848 | if (snd_es18xx_probe(chip) < 0) { | 1831 | if (snd_es18xx_probe(chip, mpu_port, fm_port) < 0) { |
1849 | snd_es18xx_free(chip); | 1832 | snd_es18xx_free(card); |
1850 | return -ENODEV; | 1833 | return -ENODEV; |
1851 | } | 1834 | } |
1852 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1835 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); |
1853 | snd_es18xx_free(chip); | 1836 | if (err < 0) { |
1837 | snd_es18xx_free(card); | ||
1854 | return err; | 1838 | return err; |
1855 | } | 1839 | } |
1856 | *rchip = chip; | ||
1857 | return 0; | 1840 | return 0; |
1858 | } | 1841 | } |
1859 | 1842 | ||
1860 | static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) | 1843 | static int __devinit snd_es18xx_mixer(struct snd_card *card) |
1861 | { | 1844 | { |
1862 | struct snd_card *card; | 1845 | struct snd_es18xx *chip = card->private_data; |
1863 | int err; | 1846 | int err; |
1864 | unsigned int idx; | 1847 | unsigned int idx; |
1865 | 1848 | ||
1866 | card = chip->card; | ||
1867 | |||
1868 | strcpy(card->mixername, chip->pcm->name); | 1849 | strcpy(card->mixername, chip->pcm->name); |
1869 | 1850 | ||
1870 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { | 1851 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { |
@@ -1986,7 +1967,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | |||
1986 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 1967 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
1987 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ | 1968 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ |
1988 | #ifdef CONFIG_PNP | 1969 | #ifdef CONFIG_PNP |
1989 | static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | 1970 | static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; |
1990 | #endif | 1971 | #endif |
1991 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ | 1972 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ |
1992 | #ifndef CONFIG_PNP | 1973 | #ifndef CONFIG_PNP |
@@ -2063,11 +2044,11 @@ static int __devinit snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev) | |||
2063 | return 0; | 2044 | return 0; |
2064 | } | 2045 | } |
2065 | 2046 | ||
2066 | static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, | 2047 | static int __devinit snd_audiodrive_pnp(int dev, struct snd_es18xx *chip, |
2067 | struct pnp_dev *pdev) | 2048 | struct pnp_dev *pdev) |
2068 | { | 2049 | { |
2069 | acard->dev = pdev; | 2050 | chip->dev = pdev; |
2070 | if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) | 2051 | if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) |
2071 | return -EBUSY; | 2052 | return -EBUSY; |
2072 | return 0; | 2053 | return 0; |
2073 | } | 2054 | } |
@@ -2093,26 +2074,26 @@ static struct pnp_card_device_id snd_audiodrive_pnpids[] = { | |||
2093 | 2074 | ||
2094 | MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); | 2075 | MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); |
2095 | 2076 | ||
2096 | static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, | 2077 | static int __devinit snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip, |
2097 | struct pnp_card_link *card, | 2078 | struct pnp_card_link *card, |
2098 | const struct pnp_card_device_id *id) | 2079 | const struct pnp_card_device_id *id) |
2099 | { | 2080 | { |
2100 | acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); | 2081 | chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL); |
2101 | if (acard->dev == NULL) | 2082 | if (chip->dev == NULL) |
2102 | return -EBUSY; | 2083 | return -EBUSY; |
2103 | 2084 | ||
2104 | acard->devc = pnp_request_card_device(card, id->devs[1].id, NULL); | 2085 | chip->devc = pnp_request_card_device(card, id->devs[1].id, NULL); |
2105 | if (acard->devc == NULL) | 2086 | if (chip->devc == NULL) |
2106 | return -EBUSY; | 2087 | return -EBUSY; |
2107 | 2088 | ||
2108 | /* Control port initialization */ | 2089 | /* Control port initialization */ |
2109 | if (pnp_activate_dev(acard->devc) < 0) { | 2090 | if (pnp_activate_dev(chip->devc) < 0) { |
2110 | snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); | 2091 | snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); |
2111 | return -EAGAIN; | 2092 | return -EAGAIN; |
2112 | } | 2093 | } |
2113 | snd_printdd("pnp: port=0x%llx\n", | 2094 | snd_printdd("pnp: port=0x%llx\n", |
2114 | (unsigned long long)pnp_port_start(acard->devc, 0)); | 2095 | (unsigned long long)pnp_port_start(chip->devc, 0)); |
2115 | if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) | 2096 | if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) |
2116 | return -EBUSY; | 2097 | return -EBUSY; |
2117 | 2098 | ||
2118 | return 0; | 2099 | return 0; |
@@ -2128,24 +2109,20 @@ static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, | |||
2128 | static int snd_es18xx_card_new(int dev, struct snd_card **cardp) | 2109 | static int snd_es18xx_card_new(int dev, struct snd_card **cardp) |
2129 | { | 2110 | { |
2130 | return snd_card_create(index[dev], id[dev], THIS_MODULE, | 2111 | return snd_card_create(index[dev], id[dev], THIS_MODULE, |
2131 | sizeof(struct snd_audiodrive), cardp); | 2112 | sizeof(struct snd_es18xx), cardp); |
2132 | } | 2113 | } |
2133 | 2114 | ||
2134 | static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | 2115 | static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) |
2135 | { | 2116 | { |
2136 | struct snd_audiodrive *acard = card->private_data; | 2117 | struct snd_es18xx *chip = card->private_data; |
2137 | struct snd_es18xx *chip; | ||
2138 | struct snd_opl3 *opl3; | 2118 | struct snd_opl3 *opl3; |
2139 | int err; | 2119 | int err; |
2140 | 2120 | ||
2141 | if ((err = snd_es18xx_new_device(card, | 2121 | err = snd_es18xx_new_device(card, |
2142 | port[dev], | 2122 | port[dev], mpu_port[dev], fm_port[dev], |
2143 | mpu_port[dev], | 2123 | irq[dev], dma1[dev], dma2[dev]); |
2144 | fm_port[dev], | 2124 | if (err < 0) |
2145 | irq[dev], dma1[dev], dma2[dev], | ||
2146 | &chip)) < 0) | ||
2147 | return err; | 2125 | return err; |
2148 | acard->chip = chip; | ||
2149 | 2126 | ||
2150 | sprintf(card->driver, "ES%x", chip->version); | 2127 | sprintf(card->driver, "ES%x", chip->version); |
2151 | 2128 | ||
@@ -2161,26 +2138,32 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | |||
2161 | chip->port, | 2138 | chip->port, |
2162 | irq[dev], dma1[dev]); | 2139 | irq[dev], dma1[dev]); |
2163 | 2140 | ||
2164 | if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) | 2141 | err = snd_es18xx_pcm(card, 0, NULL); |
2142 | if (err < 0) | ||
2165 | return err; | 2143 | return err; |
2166 | 2144 | ||
2167 | if ((err = snd_es18xx_mixer(chip)) < 0) | 2145 | err = snd_es18xx_mixer(card); |
2146 | if (err < 0) | ||
2168 | return err; | 2147 | return err; |
2169 | 2148 | ||
2170 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | 2149 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { |
2171 | if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { | 2150 | if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, |
2172 | snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port); | 2151 | OPL3_HW_OPL3, 0, &opl3) < 0) { |
2152 | snd_printk(KERN_WARNING PFX | ||
2153 | "opl3 not detected at 0x%lx\n", | ||
2154 | fm_port[dev]); | ||
2173 | } else { | 2155 | } else { |
2174 | if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) | 2156 | err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); |
2157 | if (err < 0) | ||
2175 | return err; | 2158 | return err; |
2176 | } | 2159 | } |
2177 | } | 2160 | } |
2178 | 2161 | ||
2179 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | 2162 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
2180 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, | 2163 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, |
2181 | chip->mpu_port, 0, | 2164 | mpu_port[dev], 0, |
2182 | irq[dev], 0, | 2165 | irq[dev], 0, &chip->rmidi); |
2183 | &chip->rmidi)) < 0) | 2166 | if (err < 0) |
2184 | return err; | 2167 | return err; |
2185 | } | 2168 | } |
2186 | 2169 | ||
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/miro.c b/sound/isa/opti9xx/miro.c index 02e30d7c6a93..b865e45a8f9b 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/isa.h> | 27 | #include <linux/isa.h> |
28 | #include <linux/pnp.h> | ||
28 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
29 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
30 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
@@ -40,7 +41,7 @@ | |||
40 | #define SNDRV_LEGACY_FIND_FREE_IRQ | 41 | #define SNDRV_LEGACY_FIND_FREE_IRQ |
41 | #define SNDRV_LEGACY_FIND_FREE_DMA | 42 | #define SNDRV_LEGACY_FIND_FREE_DMA |
42 | #include <sound/initval.h> | 43 | #include <sound/initval.h> |
43 | #include "miro.h" | 44 | #include <sound/aci.h> |
44 | 45 | ||
45 | MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); | 46 | MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); |
46 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
@@ -60,6 +61,9 @@ static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ | |||
60 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ | 61 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ |
61 | static int wss; | 62 | static int wss; |
62 | static int ide; | 63 | static int ide; |
64 | #ifdef CONFIG_PNP | ||
65 | static int isapnp = 1; /* Enable ISA PnP detection */ | ||
66 | #endif | ||
63 | 67 | ||
64 | module_param(index, int, 0444); | 68 | module_param(index, int, 0444); |
65 | MODULE_PARM_DESC(index, "Index value for miro soundcard."); | 69 | MODULE_PARM_DESC(index, "Index value for miro soundcard."); |
@@ -83,6 +87,10 @@ module_param(wss, int, 0444); | |||
83 | MODULE_PARM_DESC(wss, "wss mode"); | 87 | MODULE_PARM_DESC(wss, "wss mode"); |
84 | module_param(ide, int, 0444); | 88 | module_param(ide, int, 0444); |
85 | MODULE_PARM_DESC(ide, "enable ide port"); | 89 | MODULE_PARM_DESC(ide, "enable ide port"); |
90 | #ifdef CONFIG_PNP | ||
91 | module_param(isapnp, bool, 0444); | ||
92 | MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard."); | ||
93 | #endif | ||
86 | 94 | ||
87 | #define OPTi9XX_HW_DETECT 0 | 95 | #define OPTi9XX_HW_DETECT 0 |
88 | #define OPTi9XX_HW_82C928 1 | 96 | #define OPTi9XX_HW_82C928 1 |
@@ -96,7 +104,6 @@ MODULE_PARM_DESC(ide, "enable ide port"); | |||
96 | 104 | ||
97 | #define OPTi9XX_MC_REG(n) n | 105 | #define OPTi9XX_MC_REG(n) n |
98 | 106 | ||
99 | |||
100 | struct snd_miro { | 107 | struct snd_miro { |
101 | unsigned short hardware; | 108 | unsigned short hardware; |
102 | unsigned char password; | 109 | unsigned char password; |
@@ -110,7 +117,6 @@ struct snd_miro { | |||
110 | unsigned long pwd_reg; | 117 | unsigned long pwd_reg; |
111 | 118 | ||
112 | spinlock_t lock; | 119 | spinlock_t lock; |
113 | struct snd_card *card; | ||
114 | struct snd_pcm *pcm; | 120 | struct snd_pcm *pcm; |
115 | 121 | ||
116 | long wss_base; | 122 | long wss_base; |
@@ -118,42 +124,48 @@ struct snd_miro { | |||
118 | int dma1; | 124 | int dma1; |
119 | int dma2; | 125 | int dma2; |
120 | 126 | ||
121 | long fm_port; | ||
122 | |||
123 | long mpu_port; | 127 | long mpu_port; |
124 | int mpu_irq; | 128 | int mpu_irq; |
125 | 129 | ||
126 | unsigned long aci_port; | 130 | struct snd_miro_aci *aci; |
127 | int aci_vendor; | ||
128 | int aci_product; | ||
129 | int aci_version; | ||
130 | int aci_amp; | ||
131 | int aci_preamp; | ||
132 | int aci_solomode; | ||
133 | |||
134 | struct mutex aci_mutex; | ||
135 | }; | 131 | }; |
136 | 132 | ||
137 | static void snd_miro_proc_init(struct snd_miro * miro); | 133 | static struct snd_miro_aci aci_device; |
138 | 134 | ||
139 | static char * snd_opti9xx_names[] = { | 135 | static char * snd_opti9xx_names[] = { |
140 | "unkown", | 136 | "unknown", |
141 | "82C928", "82C929", | 137 | "82C928", "82C929", |
142 | "82C924", "82C925", | 138 | "82C924", "82C925", |
143 | "82C930", "82C931", "82C933" | 139 | "82C930", "82C931", "82C933" |
144 | }; | 140 | }; |
145 | 141 | ||
142 | static int snd_miro_pnp_is_probed; | ||
143 | |||
144 | #ifdef CONFIG_PNP | ||
145 | |||
146 | static struct pnp_card_device_id snd_miro_pnpids[] = { | ||
147 | /* PCM20 and PCM12 in PnP mode */ | ||
148 | { .id = "MIR0924", | ||
149 | .devs = { { "MIR0000" }, { "MIR0002" }, { "MIR0005" } }, }, | ||
150 | { .id = "" } | ||
151 | }; | ||
152 | |||
153 | MODULE_DEVICE_TABLE(pnp_card, snd_miro_pnpids); | ||
154 | |||
155 | #endif /* CONFIG_PNP */ | ||
156 | |||
146 | /* | 157 | /* |
147 | * ACI control | 158 | * ACI control |
148 | */ | 159 | */ |
149 | 160 | ||
150 | static int aci_busy_wait(struct snd_miro * miro) | 161 | static int aci_busy_wait(struct snd_miro_aci *aci) |
151 | { | 162 | { |
152 | long timeout; | 163 | long timeout; |
153 | unsigned char byte; | 164 | unsigned char byte; |
154 | 165 | ||
155 | for (timeout = 1; timeout <= ACI_MINTIME+30; timeout++) { | 166 | for (timeout = 1; timeout <= ACI_MINTIME + 30; timeout++) { |
156 | if (((byte=inb(miro->aci_port + ACI_REG_BUSY)) & 1) == 0) { | 167 | byte = inb(aci->aci_port + ACI_REG_BUSY); |
168 | if ((byte & 1) == 0) { | ||
157 | if (timeout >= ACI_MINTIME) | 169 | if (timeout >= ACI_MINTIME) |
158 | snd_printd("aci ready in round %ld.\n", | 170 | snd_printd("aci ready in round %ld.\n", |
159 | timeout-ACI_MINTIME); | 171 | timeout-ACI_MINTIME); |
@@ -179,10 +191,10 @@ static int aci_busy_wait(struct snd_miro * miro) | |||
179 | return -EBUSY; | 191 | return -EBUSY; |
180 | } | 192 | } |
181 | 193 | ||
182 | static inline int aci_write(struct snd_miro * miro, unsigned char byte) | 194 | static inline int aci_write(struct snd_miro_aci *aci, unsigned char byte) |
183 | { | 195 | { |
184 | if (aci_busy_wait(miro) >= 0) { | 196 | if (aci_busy_wait(aci) >= 0) { |
185 | outb(byte, miro->aci_port + ACI_REG_COMMAND); | 197 | outb(byte, aci->aci_port + ACI_REG_COMMAND); |
186 | return 0; | 198 | return 0; |
187 | } else { | 199 | } else { |
188 | snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte); | 200 | snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte); |
@@ -190,12 +202,12 @@ static inline int aci_write(struct snd_miro * miro, unsigned char byte) | |||
190 | } | 202 | } |
191 | } | 203 | } |
192 | 204 | ||
193 | static inline int aci_read(struct snd_miro * miro) | 205 | static inline int aci_read(struct snd_miro_aci *aci) |
194 | { | 206 | { |
195 | unsigned char byte; | 207 | unsigned char byte; |
196 | 208 | ||
197 | if (aci_busy_wait(miro) >= 0) { | 209 | if (aci_busy_wait(aci) >= 0) { |
198 | byte=inb(miro->aci_port + ACI_REG_STATUS); | 210 | byte = inb(aci->aci_port + ACI_REG_STATUS); |
199 | return byte; | 211 | return byte; |
200 | } else { | 212 | } else { |
201 | snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n"); | 213 | snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n"); |
@@ -203,39 +215,49 @@ static inline int aci_read(struct snd_miro * miro) | |||
203 | } | 215 | } |
204 | } | 216 | } |
205 | 217 | ||
206 | static int aci_cmd(struct snd_miro * miro, int write1, int write2, int write3) | 218 | int snd_aci_cmd(struct snd_miro_aci *aci, int write1, int write2, int write3) |
207 | { | 219 | { |
208 | int write[] = {write1, write2, write3}; | 220 | int write[] = {write1, write2, write3}; |
209 | int value, i; | 221 | int value, i; |
210 | 222 | ||
211 | if (mutex_lock_interruptible(&miro->aci_mutex)) | 223 | if (mutex_lock_interruptible(&aci->aci_mutex)) |
212 | return -EINTR; | 224 | return -EINTR; |
213 | 225 | ||
214 | for (i=0; i<3; i++) { | 226 | for (i=0; i<3; i++) { |
215 | if (write[i]< 0 || write[i] > 255) | 227 | if (write[i]< 0 || write[i] > 255) |
216 | break; | 228 | break; |
217 | else { | 229 | else { |
218 | value = aci_write(miro, write[i]); | 230 | value = aci_write(aci, write[i]); |
219 | if (value < 0) | 231 | if (value < 0) |
220 | goto out; | 232 | goto out; |
221 | } | 233 | } |
222 | } | 234 | } |
223 | 235 | ||
224 | value = aci_read(miro); | 236 | value = aci_read(aci); |
225 | 237 | ||
226 | out: mutex_unlock(&miro->aci_mutex); | 238 | out: mutex_unlock(&aci->aci_mutex); |
227 | return value; | 239 | return value; |
228 | } | 240 | } |
241 | EXPORT_SYMBOL(snd_aci_cmd); | ||
242 | |||
243 | static int aci_getvalue(struct snd_miro_aci *aci, unsigned char index) | ||
244 | { | ||
245 | return snd_aci_cmd(aci, ACI_STATUS, index, -1); | ||
246 | } | ||
229 | 247 | ||
230 | static int aci_getvalue(struct snd_miro * miro, unsigned char index) | 248 | static int aci_setvalue(struct snd_miro_aci *aci, unsigned char index, |
249 | int value) | ||
231 | { | 250 | { |
232 | return aci_cmd(miro, ACI_STATUS, index, -1); | 251 | return snd_aci_cmd(aci, index, value, -1); |
233 | } | 252 | } |
234 | 253 | ||
235 | static int aci_setvalue(struct snd_miro * miro, unsigned char index, int value) | 254 | struct snd_miro_aci *snd_aci_get_aci(void) |
236 | { | 255 | { |
237 | return aci_cmd(miro, index, value, -1); | 256 | if (aci_device.aci_port == 0) |
257 | return NULL; | ||
258 | return &aci_device; | ||
238 | } | 259 | } |
260 | EXPORT_SYMBOL(snd_aci_get_aci); | ||
239 | 261 | ||
240 | /* | 262 | /* |
241 | * MIXER part | 263 | * MIXER part |
@@ -249,8 +271,10 @@ static int snd_miro_get_capture(struct snd_kcontrol *kcontrol, | |||
249 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 271 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
250 | int value; | 272 | int value; |
251 | 273 | ||
252 | if ((value = aci_getvalue(miro, ACI_S_GENERAL)) < 0) { | 274 | value = aci_getvalue(miro->aci, ACI_S_GENERAL); |
253 | snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n", value); | 275 | if (value < 0) { |
276 | snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n", | ||
277 | value); | ||
254 | return value; | 278 | return value; |
255 | } | 279 | } |
256 | 280 | ||
@@ -267,13 +291,15 @@ static int snd_miro_put_capture(struct snd_kcontrol *kcontrol, | |||
267 | 291 | ||
268 | value = !(ucontrol->value.integer.value[0]); | 292 | value = !(ucontrol->value.integer.value[0]); |
269 | 293 | ||
270 | if ((error = aci_setvalue(miro, ACI_SET_SOLOMODE, value)) < 0) { | 294 | error = aci_setvalue(miro->aci, ACI_SET_SOLOMODE, value); |
271 | snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n", error); | 295 | if (error < 0) { |
296 | snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n", | ||
297 | error); | ||
272 | return error; | 298 | return error; |
273 | } | 299 | } |
274 | 300 | ||
275 | change = (value != miro->aci_solomode); | 301 | change = (value != miro->aci->aci_solomode); |
276 | miro->aci_solomode = value; | 302 | miro->aci->aci_solomode = value; |
277 | 303 | ||
278 | return change; | 304 | return change; |
279 | } | 305 | } |
@@ -295,7 +321,7 @@ static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol, | |||
295 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 321 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
296 | int value; | 322 | int value; |
297 | 323 | ||
298 | if (miro->aci_version <= 176) { | 324 | if (miro->aci->aci_version <= 176) { |
299 | 325 | ||
300 | /* | 326 | /* |
301 | OSS says it's not readable with versions < 176. | 327 | OSS says it's not readable with versions < 176. |
@@ -303,12 +329,14 @@ static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol, | |||
303 | which is a PCM12 with aci_version = 176. | 329 | which is a PCM12 with aci_version = 176. |
304 | */ | 330 | */ |
305 | 331 | ||
306 | ucontrol->value.integer.value[0] = miro->aci_preamp; | 332 | ucontrol->value.integer.value[0] = miro->aci->aci_preamp; |
307 | return 0; | 333 | return 0; |
308 | } | 334 | } |
309 | 335 | ||
310 | if ((value = aci_getvalue(miro, ACI_GET_PREAMP)) < 0) { | 336 | value = aci_getvalue(miro->aci, ACI_GET_PREAMP); |
311 | snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n", value); | 337 | if (value < 0) { |
338 | snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n", | ||
339 | value); | ||
312 | return value; | 340 | return value; |
313 | } | 341 | } |
314 | 342 | ||
@@ -325,13 +353,15 @@ static int snd_miro_put_preamp(struct snd_kcontrol *kcontrol, | |||
325 | 353 | ||
326 | value = ucontrol->value.integer.value[0]; | 354 | value = ucontrol->value.integer.value[0]; |
327 | 355 | ||
328 | if ((error = aci_setvalue(miro, ACI_SET_PREAMP, value)) < 0) { | 356 | error = aci_setvalue(miro->aci, ACI_SET_PREAMP, value); |
329 | snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n", error); | 357 | if (error < 0) { |
358 | snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n", | ||
359 | error); | ||
330 | return error; | 360 | return error; |
331 | } | 361 | } |
332 | 362 | ||
333 | change = (value != miro->aci_preamp); | 363 | change = (value != miro->aci->aci_preamp); |
334 | miro->aci_preamp = value; | 364 | miro->aci->aci_preamp = value; |
335 | 365 | ||
336 | return change; | 366 | return change; |
337 | } | 367 | } |
@@ -342,7 +372,7 @@ static int snd_miro_get_amp(struct snd_kcontrol *kcontrol, | |||
342 | struct snd_ctl_elem_value *ucontrol) | 372 | struct snd_ctl_elem_value *ucontrol) |
343 | { | 373 | { |
344 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 374 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
345 | ucontrol->value.integer.value[0] = miro->aci_amp; | 375 | ucontrol->value.integer.value[0] = miro->aci->aci_amp; |
346 | 376 | ||
347 | return 0; | 377 | return 0; |
348 | } | 378 | } |
@@ -355,13 +385,14 @@ static int snd_miro_put_amp(struct snd_kcontrol *kcontrol, | |||
355 | 385 | ||
356 | value = ucontrol->value.integer.value[0]; | 386 | value = ucontrol->value.integer.value[0]; |
357 | 387 | ||
358 | if ((error = aci_setvalue(miro, ACI_SET_POWERAMP, value)) < 0) { | 388 | error = aci_setvalue(miro->aci, ACI_SET_POWERAMP, value); |
389 | if (error < 0) { | ||
359 | snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error); | 390 | snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error); |
360 | return error; | 391 | return error; |
361 | } | 392 | } |
362 | 393 | ||
363 | change = (value != miro->aci_amp); | 394 | change = (value != miro->aci->aci_amp); |
364 | miro->aci_amp = value; | 395 | miro->aci->aci_amp = value; |
365 | 396 | ||
366 | return change; | 397 | return change; |
367 | } | 398 | } |
@@ -410,12 +441,14 @@ static int snd_miro_get_double(struct snd_kcontrol *kcontrol, | |||
410 | int right_reg = kcontrol->private_value & 0xff; | 441 | int right_reg = kcontrol->private_value & 0xff; |
411 | int left_reg = right_reg + 1; | 442 | int left_reg = right_reg + 1; |
412 | 443 | ||
413 | if ((right_val = aci_getvalue(miro, right_reg)) < 0) { | 444 | right_val = aci_getvalue(miro->aci, right_reg); |
445 | if (right_val < 0) { | ||
414 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val); | 446 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val); |
415 | return right_val; | 447 | return right_val; |
416 | } | 448 | } |
417 | 449 | ||
418 | if ((left_val = aci_getvalue(miro, left_reg)) < 0) { | 450 | left_val = aci_getvalue(miro->aci, left_reg); |
451 | if (left_val < 0) { | ||
419 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val); | 452 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val); |
420 | return left_val; | 453 | return left_val; |
421 | } | 454 | } |
@@ -451,6 +484,7 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
451 | struct snd_ctl_elem_value *ucontrol) | 484 | struct snd_ctl_elem_value *ucontrol) |
452 | { | 485 | { |
453 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 486 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
487 | struct snd_miro_aci *aci = miro->aci; | ||
454 | int left, right, left_old, right_old; | 488 | int left, right, left_old, right_old; |
455 | int setreg_left, setreg_right, getreg_left, getreg_right; | 489 | int setreg_left, setreg_right, getreg_left, getreg_right; |
456 | int change, error; | 490 | int change, error; |
@@ -459,21 +493,21 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
459 | right = ucontrol->value.integer.value[1]; | 493 | right = ucontrol->value.integer.value[1]; |
460 | 494 | ||
461 | setreg_right = (kcontrol->private_value >> 8) & 0xff; | 495 | setreg_right = (kcontrol->private_value >> 8) & 0xff; |
462 | if (setreg_right == ACI_SET_MASTER) { | 496 | setreg_left = setreg_right + 8; |
463 | setreg_left = setreg_right + 1; | 497 | if (setreg_right == ACI_SET_MASTER) |
464 | } else { | 498 | setreg_left -= 7; |
465 | setreg_left = setreg_right + 8; | ||
466 | } | ||
467 | 499 | ||
468 | getreg_right = kcontrol->private_value & 0xff; | 500 | getreg_right = kcontrol->private_value & 0xff; |
469 | getreg_left = getreg_right + 1; | 501 | getreg_left = getreg_right + 1; |
470 | 502 | ||
471 | if ((left_old = aci_getvalue(miro, getreg_left)) < 0) { | 503 | left_old = aci_getvalue(aci, getreg_left); |
504 | if (left_old < 0) { | ||
472 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old); | 505 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old); |
473 | return left_old; | 506 | return left_old; |
474 | } | 507 | } |
475 | 508 | ||
476 | if ((right_old = aci_getvalue(miro, getreg_right)) < 0) { | 509 | right_old = aci_getvalue(aci, getreg_right); |
510 | if (right_old < 0) { | ||
477 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old); | 511 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old); |
478 | return right_old; | 512 | return right_old; |
479 | } | 513 | } |
@@ -492,13 +526,15 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
492 | right_old = 0x80 - right_old; | 526 | right_old = 0x80 - right_old; |
493 | 527 | ||
494 | if (left >= 0) { | 528 | if (left >= 0) { |
495 | if ((error = aci_setvalue(miro, setreg_left, left)) < 0) { | 529 | error = aci_setvalue(aci, setreg_left, left); |
530 | if (error < 0) { | ||
496 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 531 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
497 | left, error); | 532 | left, error); |
498 | return error; | 533 | return error; |
499 | } | 534 | } |
500 | } else { | 535 | } else { |
501 | if ((error = aci_setvalue(miro, setreg_left, 0x80 - left)) < 0) { | 536 | error = aci_setvalue(aci, setreg_left, 0x80 - left); |
537 | if (error < 0) { | ||
502 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 538 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
503 | 0x80 - left, error); | 539 | 0x80 - left, error); |
504 | return error; | 540 | return error; |
@@ -506,13 +542,15 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
506 | } | 542 | } |
507 | 543 | ||
508 | if (right >= 0) { | 544 | if (right >= 0) { |
509 | if ((error = aci_setvalue(miro, setreg_right, right)) < 0) { | 545 | error = aci_setvalue(aci, setreg_right, right); |
546 | if (error < 0) { | ||
510 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 547 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
511 | right, error); | 548 | right, error); |
512 | return error; | 549 | return error; |
513 | } | 550 | } |
514 | } else { | 551 | } else { |
515 | if ((error = aci_setvalue(miro, setreg_right, 0x80 - right)) < 0) { | 552 | error = aci_setvalue(aci, setreg_right, 0x80 - right); |
553 | if (error < 0) { | ||
516 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 554 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
517 | 0x80 - right, error); | 555 | 0x80 - right, error); |
518 | return error; | 556 | return error; |
@@ -530,12 +568,14 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
530 | left_old = 0x20 - left_old; | 568 | left_old = 0x20 - left_old; |
531 | right_old = 0x20 - right_old; | 569 | right_old = 0x20 - right_old; |
532 | 570 | ||
533 | if ((error = aci_setvalue(miro, setreg_left, 0x20 - left)) < 0) { | 571 | error = aci_setvalue(aci, setreg_left, 0x20 - left); |
572 | if (error < 0) { | ||
534 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 573 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
535 | 0x20 - left, error); | 574 | 0x20 - left, error); |
536 | return error; | 575 | return error; |
537 | } | 576 | } |
538 | if ((error = aci_setvalue(miro, setreg_right, 0x20 - right)) < 0) { | 577 | error = aci_setvalue(aci, setreg_right, 0x20 - right); |
578 | if (error < 0) { | ||
539 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 579 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
540 | 0x20 - right, error); | 580 | 0x20 - right, error); |
541 | return error; | 581 | return error; |
@@ -633,11 +673,13 @@ static unsigned char aci_init_values[][2] __devinitdata = { | |||
633 | static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | 673 | static int __devinit snd_set_aci_init_values(struct snd_miro *miro) |
634 | { | 674 | { |
635 | int idx, error; | 675 | int idx, error; |
676 | struct snd_miro_aci *aci = miro->aci; | ||
636 | 677 | ||
637 | /* enable WSS on PCM1 */ | 678 | /* enable WSS on PCM1 */ |
638 | 679 | ||
639 | if ((miro->aci_product == 'A') && wss) { | 680 | if ((aci->aci_product == 'A') && wss) { |
640 | if ((error = aci_setvalue(miro, ACI_SET_WSS, wss)) < 0) { | 681 | error = aci_setvalue(aci, ACI_SET_WSS, wss); |
682 | if (error < 0) { | ||
641 | snd_printk(KERN_ERR "enabling WSS mode failed\n"); | 683 | snd_printk(KERN_ERR "enabling WSS mode failed\n"); |
642 | return error; | 684 | return error; |
643 | } | 685 | } |
@@ -646,7 +688,8 @@ static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | |||
646 | /* enable IDE port */ | 688 | /* enable IDE port */ |
647 | 689 | ||
648 | if (ide) { | 690 | if (ide) { |
649 | if ((error = aci_setvalue(miro, ACI_SET_IDE, ide)) < 0) { | 691 | error = aci_setvalue(aci, ACI_SET_IDE, ide); |
692 | if (error < 0) { | ||
650 | snd_printk(KERN_ERR "enabling IDE port failed\n"); | 693 | snd_printk(KERN_ERR "enabling IDE port failed\n"); |
651 | return error; | 694 | return error; |
652 | } | 695 | } |
@@ -654,32 +697,31 @@ static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | |||
654 | 697 | ||
655 | /* set common aci values */ | 698 | /* set common aci values */ |
656 | 699 | ||
657 | for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) | 700 | for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) { |
658 | if ((error = aci_setvalue(miro, aci_init_values[idx][0], | 701 | error = aci_setvalue(aci, aci_init_values[idx][0], |
659 | aci_init_values[idx][1])) < 0) { | 702 | aci_init_values[idx][1]); |
703 | if (error < 0) { | ||
660 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 704 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
661 | aci_init_values[idx][0], error); | 705 | aci_init_values[idx][0], error); |
662 | return error; | 706 | return error; |
663 | } | 707 | } |
664 | 708 | } | |
665 | miro->aci_amp = 0; | 709 | aci->aci_amp = 0; |
666 | miro->aci_preamp = 0; | 710 | aci->aci_preamp = 0; |
667 | miro->aci_solomode = 1; | 711 | aci->aci_solomode = 1; |
668 | 712 | ||
669 | return 0; | 713 | return 0; |
670 | } | 714 | } |
671 | 715 | ||
672 | static int __devinit snd_miro_mixer(struct snd_miro *miro) | 716 | static int __devinit snd_miro_mixer(struct snd_card *card, |
717 | struct snd_miro *miro) | ||
673 | { | 718 | { |
674 | struct snd_card *card; | ||
675 | unsigned int idx; | 719 | unsigned int idx; |
676 | int err; | 720 | int err; |
677 | 721 | ||
678 | if (snd_BUG_ON(!miro || !miro->card)) | 722 | if (snd_BUG_ON(!miro || !card)) |
679 | return -EINVAL; | 723 | return -EINVAL; |
680 | 724 | ||
681 | card = miro->card; | ||
682 | |||
683 | switch (miro->hardware) { | 725 | switch (miro->hardware) { |
684 | case OPTi9XX_HW_82C924: | 726 | case OPTi9XX_HW_82C924: |
685 | strcpy(card->mixername, "ACI & OPTi924"); | 727 | strcpy(card->mixername, "ACI & OPTi924"); |
@@ -697,7 +739,8 @@ static int __devinit snd_miro_mixer(struct snd_miro *miro) | |||
697 | return err; | 739 | return err; |
698 | } | 740 | } |
699 | 741 | ||
700 | if ((miro->aci_product == 'A') || (miro->aci_product == 'B')) { | 742 | if ((miro->aci->aci_product == 'A') || |
743 | (miro->aci->aci_product == 'B')) { | ||
701 | /* PCM1/PCM12 with power-amp and Line 2 */ | 744 | /* PCM1/PCM12 with power-amp and Line 2 */ |
702 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) | 745 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) |
703 | return err; | 746 | return err; |
@@ -705,16 +748,17 @@ static int __devinit snd_miro_mixer(struct snd_miro *miro) | |||
705 | return err; | 748 | return err; |
706 | } | 749 | } |
707 | 750 | ||
708 | if ((miro->aci_product == 'B') || (miro->aci_product == 'C')) { | 751 | if ((miro->aci->aci_product == 'B') || |
752 | (miro->aci->aci_product == 'C')) { | ||
709 | /* PCM12/PCM20 with mic-preamp */ | 753 | /* PCM12/PCM20 with mic-preamp */ |
710 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) | 754 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) |
711 | return err; | 755 | return err; |
712 | if (miro->aci_version >= 176) | 756 | if (miro->aci->aci_version >= 176) |
713 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) | 757 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) |
714 | return err; | 758 | return err; |
715 | } | 759 | } |
716 | 760 | ||
717 | if (miro->aci_product == 'C') { | 761 | if (miro->aci->aci_product == 'C') { |
718 | /* PCM20 with radio and 7 band equalizer */ | 762 | /* PCM20 with radio and 7 band equalizer */ |
719 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) | 763 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) |
720 | return err; | 764 | return err; |
@@ -757,21 +801,26 @@ static int __devinit snd_miro_init(struct snd_miro *chip, | |||
757 | chip->irq = -1; | 801 | chip->irq = -1; |
758 | chip->dma1 = -1; | 802 | chip->dma1 = -1; |
759 | chip->dma2 = -1; | 803 | chip->dma2 = -1; |
760 | chip->fm_port = -1; | ||
761 | chip->mpu_port = -1; | 804 | chip->mpu_port = -1; |
762 | chip->mpu_irq = -1; | 805 | chip->mpu_irq = -1; |
763 | 806 | ||
807 | chip->pwd_reg = 3; | ||
808 | |||
809 | #ifdef CONFIG_PNP | ||
810 | if (isapnp && chip->mc_base) | ||
811 | /* PnP resource gives the least 10 bits */ | ||
812 | chip->mc_base |= 0xc00; | ||
813 | else | ||
814 | #endif | ||
815 | chip->mc_base = 0xf8c; | ||
816 | |||
764 | switch (hardware) { | 817 | switch (hardware) { |
765 | case OPTi9XX_HW_82C929: | 818 | case OPTi9XX_HW_82C929: |
766 | chip->mc_base = 0xf8c; | ||
767 | chip->password = 0xe3; | 819 | chip->password = 0xe3; |
768 | chip->pwd_reg = 3; | ||
769 | break; | 820 | break; |
770 | 821 | ||
771 | case OPTi9XX_HW_82C924: | 822 | case OPTi9XX_HW_82C924: |
772 | chip->mc_base = 0xf8c; | ||
773 | chip->password = 0xe5; | 823 | chip->password = 0xe5; |
774 | chip->pwd_reg = 3; | ||
775 | break; | 824 | break; |
776 | 825 | ||
777 | default: | 826 | default: |
@@ -853,14 +902,15 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
853 | struct snd_info_buffer *buffer) | 902 | struct snd_info_buffer *buffer) |
854 | { | 903 | { |
855 | struct snd_miro *miro = (struct snd_miro *) entry->private_data; | 904 | struct snd_miro *miro = (struct snd_miro *) entry->private_data; |
905 | struct snd_miro_aci *aci = miro->aci; | ||
856 | char* model = "unknown"; | 906 | char* model = "unknown"; |
857 | 907 | ||
858 | /* miroSOUND PCM1 pro, early PCM12 */ | 908 | /* miroSOUND PCM1 pro, early PCM12 */ |
859 | 909 | ||
860 | if ((miro->hardware == OPTi9XX_HW_82C929) && | 910 | if ((miro->hardware == OPTi9XX_HW_82C929) && |
861 | (miro->aci_vendor == 'm') && | 911 | (aci->aci_vendor == 'm') && |
862 | (miro->aci_product == 'A')) { | 912 | (aci->aci_product == 'A')) { |
863 | switch(miro->aci_version) { | 913 | switch (aci->aci_version) { |
864 | case 3: | 914 | case 3: |
865 | model = "miroSOUND PCM1 pro"; | 915 | model = "miroSOUND PCM1 pro"; |
866 | break; | 916 | break; |
@@ -873,9 +923,9 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
873 | /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ | 923 | /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ |
874 | 924 | ||
875 | if ((miro->hardware == OPTi9XX_HW_82C924) && | 925 | if ((miro->hardware == OPTi9XX_HW_82C924) && |
876 | (miro->aci_vendor == 'm') && | 926 | (aci->aci_vendor == 'm') && |
877 | (miro->aci_product == 'B')) { | 927 | (aci->aci_product == 'B')) { |
878 | switch(miro->aci_version) { | 928 | switch (aci->aci_version) { |
879 | case 4: | 929 | case 4: |
880 | model = "miroSOUND PCM12"; | 930 | model = "miroSOUND PCM12"; |
881 | break; | 931 | break; |
@@ -891,9 +941,9 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
891 | /* miroSOUND PCM20 radio */ | 941 | /* miroSOUND PCM20 radio */ |
892 | 942 | ||
893 | if ((miro->hardware == OPTi9XX_HW_82C924) && | 943 | if ((miro->hardware == OPTi9XX_HW_82C924) && |
894 | (miro->aci_vendor == 'm') && | 944 | (aci->aci_vendor == 'm') && |
895 | (miro->aci_product == 'C')) { | 945 | (aci->aci_product == 'C')) { |
896 | switch(miro->aci_version) { | 946 | switch (aci->aci_version) { |
897 | case 7: | 947 | case 7: |
898 | model = "miroSOUND PCM20 radio (Rev. E)"; | 948 | model = "miroSOUND PCM20 radio (Rev. E)"; |
899 | break; | 949 | break; |
@@ -917,17 +967,17 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
917 | 967 | ||
918 | snd_iprintf(buffer, "ACI information:\n"); | 968 | snd_iprintf(buffer, "ACI information:\n"); |
919 | snd_iprintf(buffer, " vendor : "); | 969 | snd_iprintf(buffer, " vendor : "); |
920 | switch(miro->aci_vendor) { | 970 | switch (aci->aci_vendor) { |
921 | case 'm': | 971 | case 'm': |
922 | snd_iprintf(buffer, "Miro\n"); | 972 | snd_iprintf(buffer, "Miro\n"); |
923 | break; | 973 | break; |
924 | default: | 974 | default: |
925 | snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_vendor); | 975 | snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_vendor); |
926 | break; | 976 | break; |
927 | } | 977 | } |
928 | 978 | ||
929 | snd_iprintf(buffer, " product : "); | 979 | snd_iprintf(buffer, " product : "); |
930 | switch(miro->aci_product) { | 980 | switch (aci->aci_product) { |
931 | case 'A': | 981 | case 'A': |
932 | snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); | 982 | snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); |
933 | break; | 983 | break; |
@@ -938,26 +988,27 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
938 | snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); | 988 | snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); |
939 | break; | 989 | break; |
940 | default: | 990 | default: |
941 | snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_product); | 991 | snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_product); |
942 | break; | 992 | break; |
943 | } | 993 | } |
944 | 994 | ||
945 | snd_iprintf(buffer, " firmware: %d (0x%x)\n", | 995 | snd_iprintf(buffer, " firmware: %d (0x%x)\n", |
946 | miro->aci_version, miro->aci_version); | 996 | aci->aci_version, aci->aci_version); |
947 | snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", | 997 | snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", |
948 | miro->aci_port, miro->aci_port+2); | 998 | aci->aci_port, aci->aci_port+2); |
949 | snd_iprintf(buffer, " wss : 0x%x\n", wss); | 999 | snd_iprintf(buffer, " wss : 0x%x\n", wss); |
950 | snd_iprintf(buffer, " ide : 0x%x\n", ide); | 1000 | snd_iprintf(buffer, " ide : 0x%x\n", ide); |
951 | snd_iprintf(buffer, " solomode: 0x%x\n", miro->aci_solomode); | 1001 | snd_iprintf(buffer, " solomode: 0x%x\n", aci->aci_solomode); |
952 | snd_iprintf(buffer, " amp : 0x%x\n", miro->aci_amp); | 1002 | snd_iprintf(buffer, " amp : 0x%x\n", aci->aci_amp); |
953 | snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp); | 1003 | snd_iprintf(buffer, " preamp : 0x%x\n", aci->aci_preamp); |
954 | } | 1004 | } |
955 | 1005 | ||
956 | static void __devinit snd_miro_proc_init(struct snd_miro * miro) | 1006 | static void __devinit snd_miro_proc_init(struct snd_card *card, |
1007 | struct snd_miro *miro) | ||
957 | { | 1008 | { |
958 | struct snd_info_entry *entry; | 1009 | struct snd_info_entry *entry; |
959 | 1010 | ||
960 | if (! snd_card_proc_new(miro->card, "miro", &entry)) | 1011 | if (!snd_card_proc_new(card, "miro", &entry)) |
961 | snd_info_set_text_ops(entry, miro, snd_miro_proc_read); | 1012 | snd_info_set_text_ops(entry, miro, snd_miro_proc_read); |
962 | } | 1013 | } |
963 | 1014 | ||
@@ -974,37 +1025,40 @@ static int __devinit snd_miro_configure(struct snd_miro *chip) | |||
974 | unsigned char mpu_irq_bits; | 1025 | unsigned char mpu_irq_bits; |
975 | unsigned long flags; | 1026 | unsigned long flags; |
976 | 1027 | ||
1028 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
1029 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
1030 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
1031 | |||
977 | switch (chip->hardware) { | 1032 | switch (chip->hardware) { |
978 | case OPTi9XX_HW_82C924: | 1033 | case OPTi9XX_HW_82C924: |
979 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); | 1034 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); |
980 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
981 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
982 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); | 1035 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); |
983 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
984 | break; | 1036 | break; |
985 | case OPTi9XX_HW_82C929: | 1037 | case OPTi9XX_HW_82C929: |
986 | /* untested init commands for OPTi929 */ | 1038 | /* untested init commands for OPTi929 */ |
987 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
988 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
989 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c); | 1039 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c); |
990 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
991 | break; | 1040 | break; |
992 | default: | 1041 | default: |
993 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); | 1042 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); |
994 | return -EINVAL; | 1043 | return -EINVAL; |
995 | } | 1044 | } |
996 | 1045 | ||
997 | switch (chip->wss_base) { | 1046 | /* PnP resource says it decodes only 10 bits of address */ |
998 | case 0x530: | 1047 | switch (chip->wss_base & 0x3ff) { |
1048 | case 0x130: | ||
1049 | chip->wss_base = 0x530; | ||
999 | wss_base_bits = 0x00; | 1050 | wss_base_bits = 0x00; |
1000 | break; | 1051 | break; |
1001 | case 0x604: | 1052 | case 0x204: |
1053 | chip->wss_base = 0x604; | ||
1002 | wss_base_bits = 0x03; | 1054 | wss_base_bits = 0x03; |
1003 | break; | 1055 | break; |
1004 | case 0xe80: | 1056 | case 0x280: |
1057 | chip->wss_base = 0xe80; | ||
1005 | wss_base_bits = 0x01; | 1058 | wss_base_bits = 0x01; |
1006 | break; | 1059 | break; |
1007 | case 0xf40: | 1060 | case 0x340: |
1061 | chip->wss_base = 0xf40; | ||
1008 | wss_base_bits = 0x02; | 1062 | wss_base_bits = 0x02; |
1009 | break; | 1063 | break; |
1010 | default: | 1064 | default: |
@@ -1122,75 +1176,92 @@ __skip_mpu: | |||
1122 | return 0; | 1176 | return 0; |
1123 | } | 1177 | } |
1124 | 1178 | ||
1179 | static int __devinit snd_miro_opti_check(struct snd_miro *chip) | ||
1180 | { | ||
1181 | unsigned char value; | ||
1182 | |||
1183 | chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, | ||
1184 | "OPTi9xx MC"); | ||
1185 | if (chip->res_mc_base == NULL) | ||
1186 | return -ENOMEM; | ||
1187 | |||
1188 | value = snd_miro_read(chip, OPTi9XX_MC_REG(1)); | ||
1189 | if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1))) | ||
1190 | if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1))) | ||
1191 | return 0; | ||
1192 | |||
1193 | release_and_free_resource(chip->res_mc_base); | ||
1194 | chip->res_mc_base = NULL; | ||
1195 | |||
1196 | return -ENODEV; | ||
1197 | } | ||
1198 | |||
1125 | static int __devinit snd_card_miro_detect(struct snd_card *card, | 1199 | static int __devinit snd_card_miro_detect(struct snd_card *card, |
1126 | struct snd_miro *chip) | 1200 | struct snd_miro *chip) |
1127 | { | 1201 | { |
1128 | int i, err; | 1202 | int i, err; |
1129 | unsigned char value; | ||
1130 | 1203 | ||
1131 | for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { | 1204 | for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { |
1132 | 1205 | ||
1133 | if ((err = snd_miro_init(chip, i)) < 0) | 1206 | if ((err = snd_miro_init(chip, i)) < 0) |
1134 | return err; | 1207 | return err; |
1135 | 1208 | ||
1136 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 1209 | err = snd_miro_opti_check(chip); |
1137 | continue; | 1210 | if (err == 0) |
1138 | 1211 | return 1; | |
1139 | value = snd_miro_read(chip, OPTi9XX_MC_REG(1)); | ||
1140 | if ((value != 0xff) && (value != inb(chip->mc_base + 1))) | ||
1141 | if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1))) | ||
1142 | return 1; | ||
1143 | |||
1144 | release_and_free_resource(chip->res_mc_base); | ||
1145 | chip->res_mc_base = NULL; | ||
1146 | |||
1147 | } | 1212 | } |
1148 | 1213 | ||
1149 | return -ENODEV; | 1214 | return -ENODEV; |
1150 | } | 1215 | } |
1151 | 1216 | ||
1152 | static int __devinit snd_card_miro_aci_detect(struct snd_card *card, | 1217 | static int __devinit snd_card_miro_aci_detect(struct snd_card *card, |
1153 | struct snd_miro * miro) | 1218 | struct snd_miro *miro) |
1154 | { | 1219 | { |
1155 | unsigned char regval; | 1220 | unsigned char regval; |
1156 | int i; | 1221 | int i; |
1222 | struct snd_miro_aci *aci = &aci_device; | ||
1223 | |||
1224 | miro->aci = aci; | ||
1157 | 1225 | ||
1158 | mutex_init(&miro->aci_mutex); | 1226 | mutex_init(&aci->aci_mutex); |
1159 | 1227 | ||
1160 | /* get ACI port from OPTi9xx MC 4 */ | 1228 | /* get ACI port from OPTi9xx MC 4 */ |
1161 | 1229 | ||
1162 | miro->mc_base = 0xf8c; | ||
1163 | regval=inb(miro->mc_base + 4); | 1230 | regval=inb(miro->mc_base + 4); |
1164 | miro->aci_port = (regval & 0x10) ? 0x344: 0x354; | 1231 | aci->aci_port = (regval & 0x10) ? 0x344 : 0x354; |
1165 | 1232 | ||
1166 | if ((miro->res_aci_port = request_region(miro->aci_port, 3, "miro aci")) == NULL) { | 1233 | miro->res_aci_port = request_region(aci->aci_port, 3, "miro aci"); |
1234 | if (miro->res_aci_port == NULL) { | ||
1167 | snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", | 1235 | snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", |
1168 | miro->aci_port, miro->aci_port+2); | 1236 | aci->aci_port, aci->aci_port+2); |
1169 | return -ENOMEM; | 1237 | return -ENOMEM; |
1170 | } | 1238 | } |
1171 | 1239 | ||
1172 | /* force ACI into a known state */ | 1240 | /* force ACI into a known state */ |
1173 | for (i = 0; i < 3; i++) | 1241 | for (i = 0; i < 3; i++) |
1174 | if (aci_cmd(miro, ACI_ERROR_OP, -1, -1) < 0) { | 1242 | if (snd_aci_cmd(aci, ACI_ERROR_OP, -1, -1) < 0) { |
1175 | snd_printk(KERN_ERR "can't force aci into known state.\n"); | 1243 | snd_printk(KERN_ERR "can't force aci into known state.\n"); |
1176 | return -ENXIO; | 1244 | return -ENXIO; |
1177 | } | 1245 | } |
1178 | 1246 | ||
1179 | if ((miro->aci_vendor=aci_cmd(miro, ACI_READ_IDCODE, -1, -1)) < 0 || | 1247 | aci->aci_vendor = snd_aci_cmd(aci, ACI_READ_IDCODE, -1, -1); |
1180 | (miro->aci_product=aci_cmd(miro, ACI_READ_IDCODE, -1, -1)) < 0) { | 1248 | aci->aci_product = snd_aci_cmd(aci, ACI_READ_IDCODE, -1, -1); |
1181 | snd_printk(KERN_ERR "can't read aci id on 0x%lx.\n", miro->aci_port); | 1249 | if (aci->aci_vendor < 0 || aci->aci_product < 0) { |
1250 | snd_printk(KERN_ERR "can't read aci id on 0x%lx.\n", | ||
1251 | aci->aci_port); | ||
1182 | return -ENXIO; | 1252 | return -ENXIO; |
1183 | } | 1253 | } |
1184 | 1254 | ||
1185 | if ((miro->aci_version=aci_cmd(miro, ACI_READ_VERSION, -1, -1)) < 0) { | 1255 | aci->aci_version = snd_aci_cmd(aci, ACI_READ_VERSION, -1, -1); |
1256 | if (aci->aci_version < 0) { | ||
1186 | snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n", | 1257 | snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n", |
1187 | miro->aci_port); | 1258 | aci->aci_port); |
1188 | return -ENXIO; | 1259 | return -ENXIO; |
1189 | } | 1260 | } |
1190 | 1261 | ||
1191 | if (aci_cmd(miro, ACI_INIT, -1, -1) < 0 || | 1262 | if (snd_aci_cmd(aci, ACI_INIT, -1, -1) < 0 || |
1192 | aci_cmd(miro, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0 || | 1263 | snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0 || |
1193 | aci_cmd(miro, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) { | 1264 | snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) { |
1194 | snd_printk(KERN_ERR "can't initialize aci.\n"); | 1265 | snd_printk(KERN_ERR "can't initialize aci.\n"); |
1195 | return -ENXIO; | 1266 | return -ENXIO; |
1196 | } | 1267 | } |
@@ -1201,157 +1272,80 @@ static int __devinit snd_card_miro_aci_detect(struct snd_card *card, | |||
1201 | static void snd_card_miro_free(struct snd_card *card) | 1272 | static void snd_card_miro_free(struct snd_card *card) |
1202 | { | 1273 | { |
1203 | struct snd_miro *miro = card->private_data; | 1274 | struct snd_miro *miro = card->private_data; |
1204 | 1275 | ||
1205 | release_and_free_resource(miro->res_aci_port); | 1276 | release_and_free_resource(miro->res_aci_port); |
1277 | if (miro->aci) | ||
1278 | miro->aci->aci_port = 0; | ||
1206 | release_and_free_resource(miro->res_mc_base); | 1279 | release_and_free_resource(miro->res_mc_base); |
1207 | } | 1280 | } |
1208 | 1281 | ||
1209 | static int __devinit snd_miro_match(struct device *devptr, unsigned int n) | 1282 | static int __devinit snd_miro_probe(struct snd_card *card) |
1210 | { | ||
1211 | return 1; | ||
1212 | } | ||
1213 | |||
1214 | static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | ||
1215 | { | 1283 | { |
1216 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | ||
1217 | static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; | ||
1218 | static int possible_irqs[] = {11, 9, 10, 7, -1}; | ||
1219 | static int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; | ||
1220 | static int possible_dma1s[] = {3, 1, 0, -1}; | ||
1221 | static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; | ||
1222 | |||
1223 | int error; | 1284 | int error; |
1224 | struct snd_miro *miro; | 1285 | struct snd_miro *miro = card->private_data; |
1225 | struct snd_wss *codec; | 1286 | struct snd_wss *codec; |
1226 | struct snd_timer *timer; | 1287 | struct snd_timer *timer; |
1227 | struct snd_card *card; | ||
1228 | struct snd_pcm *pcm; | 1288 | struct snd_pcm *pcm; |
1229 | struct snd_rawmidi *rmidi; | 1289 | struct snd_rawmidi *rmidi; |
1230 | 1290 | ||
1231 | error = snd_card_create(index, id, THIS_MODULE, | 1291 | if (!miro->res_mc_base) { |
1232 | sizeof(struct snd_miro), &card); | 1292 | miro->res_mc_base = request_region(miro->mc_base, |
1233 | if (error < 0) | 1293 | miro->mc_base_size, |
1234 | return error; | 1294 | "miro (OPTi9xx MC)"); |
1235 | 1295 | if (miro->res_mc_base == NULL) { | |
1236 | card->private_free = snd_card_miro_free; | 1296 | snd_printk(KERN_ERR "request for OPTI9xx MC failed\n"); |
1237 | miro = card->private_data; | 1297 | return -ENOMEM; |
1238 | miro->card = card; | 1298 | } |
1239 | |||
1240 | if ((error = snd_card_miro_aci_detect(card, miro)) < 0) { | ||
1241 | snd_card_free(card); | ||
1242 | snd_printk(KERN_ERR "unable to detect aci chip\n"); | ||
1243 | return -ENODEV; | ||
1244 | } | 1299 | } |
1245 | 1300 | ||
1246 | /* init proc interface */ | 1301 | error = snd_card_miro_aci_detect(card, miro); |
1247 | snd_miro_proc_init(miro); | 1302 | if (error < 0) { |
1248 | |||
1249 | if ((error = snd_card_miro_detect(card, miro)) < 0) { | ||
1250 | snd_card_free(card); | 1303 | snd_card_free(card); |
1251 | snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); | 1304 | snd_printk(KERN_ERR "unable to detect aci chip\n"); |
1252 | return -ENODEV; | 1305 | return -ENODEV; |
1253 | } | 1306 | } |
1254 | 1307 | ||
1255 | if (! miro->res_mc_base && | ||
1256 | (miro->res_mc_base = request_region(miro->mc_base, miro->mc_base_size, | ||
1257 | "miro (OPTi9xx MC)")) == NULL) { | ||
1258 | snd_card_free(card); | ||
1259 | snd_printk(KERN_ERR "request for OPTI9xx MC failed\n"); | ||
1260 | return -ENOMEM; | ||
1261 | } | ||
1262 | |||
1263 | miro->wss_base = port; | 1308 | miro->wss_base = port; |
1264 | miro->fm_port = fm_port; | ||
1265 | miro->mpu_port = mpu_port; | 1309 | miro->mpu_port = mpu_port; |
1266 | miro->irq = irq; | 1310 | miro->irq = irq; |
1267 | miro->mpu_irq = mpu_irq; | 1311 | miro->mpu_irq = mpu_irq; |
1268 | miro->dma1 = dma1; | 1312 | miro->dma1 = dma1; |
1269 | miro->dma2 = dma2; | 1313 | miro->dma2 = dma2; |
1270 | 1314 | ||
1271 | if (miro->wss_base == SNDRV_AUTO_PORT) { | 1315 | /* init proc interface */ |
1272 | if ((miro->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) { | 1316 | snd_miro_proc_init(card, miro); |
1273 | snd_card_free(card); | ||
1274 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | ||
1275 | return -EBUSY; | ||
1276 | } | ||
1277 | } | ||
1278 | |||
1279 | if (miro->mpu_port == SNDRV_AUTO_PORT) { | ||
1280 | if ((miro->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { | ||
1281 | snd_card_free(card); | ||
1282 | snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); | ||
1283 | return -EBUSY; | ||
1284 | } | ||
1285 | } | ||
1286 | if (miro->irq == SNDRV_AUTO_IRQ) { | ||
1287 | if ((miro->irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { | ||
1288 | snd_card_free(card); | ||
1289 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
1290 | return -EBUSY; | ||
1291 | } | ||
1292 | } | ||
1293 | if (miro->mpu_irq == SNDRV_AUTO_IRQ) { | ||
1294 | if ((miro->mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { | ||
1295 | snd_card_free(card); | ||
1296 | snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); | ||
1297 | return -EBUSY; | ||
1298 | } | ||
1299 | } | ||
1300 | if (miro->dma1 == SNDRV_AUTO_DMA) { | ||
1301 | if ((miro->dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { | ||
1302 | snd_card_free(card); | ||
1303 | snd_printk(KERN_ERR "unable to find a free DMA1\n"); | ||
1304 | return -EBUSY; | ||
1305 | } | ||
1306 | } | ||
1307 | if (miro->dma2 == SNDRV_AUTO_DMA) { | ||
1308 | if ((miro->dma2 = snd_legacy_find_free_dma(possible_dma2s[miro->dma1 % 4])) < 0) { | ||
1309 | snd_card_free(card); | ||
1310 | snd_printk(KERN_ERR "unable to find a free DMA2\n"); | ||
1311 | return -EBUSY; | ||
1312 | } | ||
1313 | } | ||
1314 | 1317 | ||
1315 | error = snd_miro_configure(miro); | 1318 | error = snd_miro_configure(miro); |
1316 | if (error) { | 1319 | if (error) |
1317 | snd_card_free(card); | ||
1318 | return error; | 1320 | return error; |
1319 | } | ||
1320 | 1321 | ||
1321 | error = snd_wss_create(card, miro->wss_base + 4, -1, | 1322 | error = snd_wss_create(card, miro->wss_base + 4, -1, |
1322 | miro->irq, miro->dma1, miro->dma2, | 1323 | miro->irq, miro->dma1, miro->dma2, |
1323 | WSS_HW_AD1845, 0, &codec); | 1324 | WSS_HW_DETECT, 0, &codec); |
1324 | if (error < 0) { | 1325 | if (error < 0) |
1325 | snd_card_free(card); | ||
1326 | return error; | 1326 | return error; |
1327 | } | ||
1328 | 1327 | ||
1329 | error = snd_wss_pcm(codec, 0, &pcm); | 1328 | error = snd_wss_pcm(codec, 0, &pcm); |
1330 | if (error < 0) { | 1329 | if (error < 0) |
1331 | snd_card_free(card); | ||
1332 | return error; | 1330 | return error; |
1333 | } | 1331 | |
1334 | error = snd_wss_mixer(codec); | 1332 | error = snd_wss_mixer(codec); |
1335 | if (error < 0) { | 1333 | if (error < 0) |
1336 | snd_card_free(card); | ||
1337 | return error; | 1334 | return error; |
1338 | } | 1335 | |
1339 | error = snd_wss_timer(codec, 0, &timer); | 1336 | error = snd_wss_timer(codec, 0, &timer); |
1340 | if (error < 0) { | 1337 | if (error < 0) |
1341 | snd_card_free(card); | ||
1342 | return error; | 1338 | return error; |
1343 | } | ||
1344 | 1339 | ||
1345 | miro->pcm = pcm; | 1340 | miro->pcm = pcm; |
1346 | 1341 | ||
1347 | if ((error = snd_miro_mixer(miro)) < 0) { | 1342 | error = snd_miro_mixer(card, miro); |
1348 | snd_card_free(card); | 1343 | if (error < 0) |
1349 | return error; | 1344 | return error; |
1350 | } | ||
1351 | 1345 | ||
1352 | if (miro->aci_vendor == 'm') { | 1346 | if (miro->aci->aci_vendor == 'm') { |
1353 | /* It looks like a miro sound card. */ | 1347 | /* It looks like a miro sound card. */ |
1354 | switch (miro->aci_product) { | 1348 | switch (miro->aci->aci_product) { |
1355 | case 'A': | 1349 | case 'A': |
1356 | sprintf(card->shortname, | 1350 | sprintf(card->shortname, |
1357 | "miroSOUND PCM1 pro / PCM12"); | 1351 | "miroSOUND PCM1 pro / PCM12"); |
@@ -1380,30 +1374,131 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | |||
1380 | card->shortname, miro->name, pcm->name, miro->wss_base + 4, | 1374 | card->shortname, miro->name, pcm->name, miro->wss_base + 4, |
1381 | miro->irq, miro->dma1, miro->dma2); | 1375 | miro->irq, miro->dma1, miro->dma2); |
1382 | 1376 | ||
1383 | if (miro->mpu_port <= 0 || miro->mpu_port == SNDRV_AUTO_PORT) | 1377 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
1384 | rmidi = NULL; | 1378 | rmidi = NULL; |
1385 | else | 1379 | else { |
1386 | if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, | 1380 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
1387 | miro->mpu_port, 0, miro->mpu_irq, IRQF_DISABLED, | 1381 | mpu_port, 0, miro->mpu_irq, IRQF_DISABLED, |
1388 | &rmidi))) | 1382 | &rmidi); |
1389 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", miro->mpu_port); | 1383 | if (error < 0) |
1384 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", | ||
1385 | mpu_port); | ||
1386 | } | ||
1390 | 1387 | ||
1391 | if (miro->fm_port > 0 && miro->fm_port != SNDRV_AUTO_PORT) { | 1388 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
1392 | struct snd_opl3 *opl3 = NULL; | 1389 | struct snd_opl3 *opl3 = NULL; |
1393 | struct snd_opl4 *opl4; | 1390 | struct snd_opl4 *opl4; |
1394 | if (snd_opl4_create(card, miro->fm_port, miro->fm_port - 8, | 1391 | |
1392 | if (snd_opl4_create(card, fm_port, fm_port - 8, | ||
1395 | 2, &opl3, &opl4) < 0) | 1393 | 2, &opl3, &opl4) < 0) |
1396 | snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n", miro->fm_port); | 1394 | snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n", |
1395 | fm_port); | ||
1397 | } | 1396 | } |
1398 | 1397 | ||
1399 | if ((error = snd_set_aci_init_values(miro)) < 0) { | 1398 | error = snd_set_aci_init_values(miro); |
1400 | snd_card_free(card); | 1399 | if (error < 0) |
1401 | return error; | 1400 | return error; |
1401 | |||
1402 | return snd_card_register(card); | ||
1403 | } | ||
1404 | |||
1405 | static int __devinit snd_miro_isa_match(struct device *devptr, unsigned int n) | ||
1406 | { | ||
1407 | #ifdef CONFIG_PNP | ||
1408 | if (snd_miro_pnp_is_probed) | ||
1409 | return 0; | ||
1410 | if (isapnp) | ||
1411 | return 0; | ||
1412 | #endif | ||
1413 | return 1; | ||
1414 | } | ||
1415 | |||
1416 | static int __devinit snd_miro_isa_probe(struct device *devptr, unsigned int n) | ||
1417 | { | ||
1418 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | ||
1419 | static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; | ||
1420 | static int possible_irqs[] = {11, 9, 10, 7, -1}; | ||
1421 | static int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; | ||
1422 | static int possible_dma1s[] = {3, 1, 0, -1}; | ||
1423 | static int possible_dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, | ||
1424 | {0, -1} }; | ||
1425 | |||
1426 | int error; | ||
1427 | struct snd_miro *miro; | ||
1428 | struct snd_card *card; | ||
1429 | |||
1430 | error = snd_card_create(index, id, THIS_MODULE, | ||
1431 | sizeof(struct snd_miro), &card); | ||
1432 | if (error < 0) | ||
1433 | return error; | ||
1434 | |||
1435 | card->private_free = snd_card_miro_free; | ||
1436 | miro = card->private_data; | ||
1437 | |||
1438 | error = snd_card_miro_detect(card, miro); | ||
1439 | if (error < 0) { | ||
1440 | snd_card_free(card); | ||
1441 | snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); | ||
1442 | return -ENODEV; | ||
1443 | } | ||
1444 | |||
1445 | if (port == SNDRV_AUTO_PORT) { | ||
1446 | port = snd_legacy_find_free_ioport(possible_ports, 4); | ||
1447 | if (port < 0) { | ||
1448 | snd_card_free(card); | ||
1449 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | ||
1450 | return -EBUSY; | ||
1451 | } | ||
1452 | } | ||
1453 | |||
1454 | if (mpu_port == SNDRV_AUTO_PORT) { | ||
1455 | mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2); | ||
1456 | if (mpu_port < 0) { | ||
1457 | snd_card_free(card); | ||
1458 | snd_printk(KERN_ERR | ||
1459 | "unable to find a free MPU401 port\n"); | ||
1460 | return -EBUSY; | ||
1461 | } | ||
1462 | } | ||
1463 | |||
1464 | if (irq == SNDRV_AUTO_IRQ) { | ||
1465 | irq = snd_legacy_find_free_irq(possible_irqs); | ||
1466 | if (irq < 0) { | ||
1467 | snd_card_free(card); | ||
1468 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
1469 | return -EBUSY; | ||
1470 | } | ||
1471 | } | ||
1472 | if (mpu_irq == SNDRV_AUTO_IRQ) { | ||
1473 | mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs); | ||
1474 | if (mpu_irq < 0) { | ||
1475 | snd_card_free(card); | ||
1476 | snd_printk(KERN_ERR | ||
1477 | "unable to find a free MPU401 IRQ\n"); | ||
1478 | return -EBUSY; | ||
1479 | } | ||
1480 | } | ||
1481 | if (dma1 == SNDRV_AUTO_DMA) { | ||
1482 | dma1 = snd_legacy_find_free_dma(possible_dma1s); | ||
1483 | if (dma1 < 0) { | ||
1484 | snd_card_free(card); | ||
1485 | snd_printk(KERN_ERR "unable to find a free DMA1\n"); | ||
1486 | return -EBUSY; | ||
1487 | } | ||
1488 | } | ||
1489 | if (dma2 == SNDRV_AUTO_DMA) { | ||
1490 | dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4]); | ||
1491 | if (dma2 < 0) { | ||
1492 | snd_card_free(card); | ||
1493 | snd_printk(KERN_ERR "unable to find a free DMA2\n"); | ||
1494 | return -EBUSY; | ||
1495 | } | ||
1402 | } | 1496 | } |
1403 | 1497 | ||
1404 | snd_card_set_dev(card, devptr); | 1498 | snd_card_set_dev(card, devptr); |
1405 | 1499 | ||
1406 | if ((error = snd_card_register(card))) { | 1500 | error = snd_miro_probe(card); |
1501 | if (error < 0) { | ||
1407 | snd_card_free(card); | 1502 | snd_card_free(card); |
1408 | return error; | 1503 | return error; |
1409 | } | 1504 | } |
@@ -1412,7 +1507,8 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | |||
1412 | return 0; | 1507 | return 0; |
1413 | } | 1508 | } |
1414 | 1509 | ||
1415 | static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) | 1510 | static int __devexit snd_miro_isa_remove(struct device *devptr, |
1511 | unsigned int dev) | ||
1416 | { | 1512 | { |
1417 | snd_card_free(dev_get_drvdata(devptr)); | 1513 | snd_card_free(dev_get_drvdata(devptr)); |
1418 | dev_set_drvdata(devptr, NULL); | 1514 | dev_set_drvdata(devptr, NULL); |
@@ -1422,23 +1518,164 @@ static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) | |||
1422 | #define DEV_NAME "miro" | 1518 | #define DEV_NAME "miro" |
1423 | 1519 | ||
1424 | static struct isa_driver snd_miro_driver = { | 1520 | static struct isa_driver snd_miro_driver = { |
1425 | .match = snd_miro_match, | 1521 | .match = snd_miro_isa_match, |
1426 | .probe = snd_miro_probe, | 1522 | .probe = snd_miro_isa_probe, |
1427 | .remove = __devexit_p(snd_miro_remove), | 1523 | .remove = __devexit_p(snd_miro_isa_remove), |
1428 | /* FIXME: suspend/resume */ | 1524 | /* FIXME: suspend/resume */ |
1429 | .driver = { | 1525 | .driver = { |
1430 | .name = DEV_NAME | 1526 | .name = DEV_NAME |
1431 | }, | 1527 | }, |
1432 | }; | 1528 | }; |
1433 | 1529 | ||
1530 | #ifdef CONFIG_PNP | ||
1531 | |||
1532 | static int __devinit snd_card_miro_pnp(struct snd_miro *chip, | ||
1533 | struct pnp_card_link *card, | ||
1534 | const struct pnp_card_device_id *pid) | ||
1535 | { | ||
1536 | struct pnp_dev *pdev; | ||
1537 | int err; | ||
1538 | struct pnp_dev *devmpu; | ||
1539 | struct pnp_dev *devmc; | ||
1540 | |||
1541 | pdev = pnp_request_card_device(card, pid->devs[0].id, NULL); | ||
1542 | if (pdev == NULL) | ||
1543 | return -EBUSY; | ||
1544 | |||
1545 | devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
1546 | if (devmpu == NULL) | ||
1547 | return -EBUSY; | ||
1548 | |||
1549 | devmc = pnp_request_card_device(card, pid->devs[2].id, NULL); | ||
1550 | if (devmc == NULL) | ||
1551 | return -EBUSY; | ||
1552 | |||
1553 | err = pnp_activate_dev(pdev); | ||
1554 | if (err < 0) { | ||
1555 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); | ||
1556 | return err; | ||
1557 | } | ||
1558 | |||
1559 | err = pnp_activate_dev(devmc); | ||
1560 | if (err < 0) { | ||
1561 | snd_printk(KERN_ERR "OPL syntg pnp configure failure: %d\n", | ||
1562 | err); | ||
1563 | return err; | ||
1564 | } | ||
1565 | |||
1566 | port = pnp_port_start(pdev, 1); | ||
1567 | fm_port = pnp_port_start(pdev, 2) + 8; | ||
1568 | |||
1569 | /* | ||
1570 | * The MC(0) is never accessed and the miroSOUND PCM20 card does not | ||
1571 | * include it in the PnP resource range. OPTI93x include it. | ||
1572 | */ | ||
1573 | chip->mc_base = pnp_port_start(devmc, 0) - 1; | ||
1574 | chip->mc_base_size = pnp_port_len(devmc, 0) + 1; | ||
1575 | |||
1576 | irq = pnp_irq(pdev, 0); | ||
1577 | dma1 = pnp_dma(pdev, 0); | ||
1578 | dma2 = pnp_dma(pdev, 1); | ||
1579 | |||
1580 | if (mpu_port > 0) { | ||
1581 | err = pnp_activate_dev(devmpu); | ||
1582 | if (err < 0) { | ||
1583 | snd_printk(KERN_ERR "MPU401 pnp configure failure\n"); | ||
1584 | mpu_port = -1; | ||
1585 | return err; | ||
1586 | } | ||
1587 | mpu_port = pnp_port_start(devmpu, 0); | ||
1588 | mpu_irq = pnp_irq(devmpu, 0); | ||
1589 | } | ||
1590 | return 0; | ||
1591 | } | ||
1592 | |||
1593 | static int __devinit snd_miro_pnp_probe(struct pnp_card_link *pcard, | ||
1594 | const struct pnp_card_device_id *pid) | ||
1595 | { | ||
1596 | struct snd_card *card; | ||
1597 | int err; | ||
1598 | struct snd_miro *miro; | ||
1599 | |||
1600 | if (snd_miro_pnp_is_probed) | ||
1601 | return -EBUSY; | ||
1602 | if (!isapnp) | ||
1603 | return -ENODEV; | ||
1604 | err = snd_card_create(index, id, THIS_MODULE, | ||
1605 | sizeof(struct snd_miro), &card); | ||
1606 | if (err < 0) | ||
1607 | return err; | ||
1608 | |||
1609 | card->private_free = snd_card_miro_free; | ||
1610 | miro = card->private_data; | ||
1611 | |||
1612 | err = snd_card_miro_pnp(miro, pcard, pid); | ||
1613 | if (err) { | ||
1614 | snd_card_free(card); | ||
1615 | return err; | ||
1616 | } | ||
1617 | |||
1618 | /* only miroSOUND PCM20 and PCM12 == OPTi924 */ | ||
1619 | err = snd_miro_init(miro, OPTi9XX_HW_82C924); | ||
1620 | if (err) { | ||
1621 | snd_card_free(card); | ||
1622 | return err; | ||
1623 | } | ||
1624 | |||
1625 | err = snd_miro_opti_check(miro); | ||
1626 | if (err) { | ||
1627 | snd_printk(KERN_ERR "OPTI chip not found\n"); | ||
1628 | snd_card_free(card); | ||
1629 | return err; | ||
1630 | } | ||
1631 | |||
1632 | snd_card_set_dev(card, &pcard->card->dev); | ||
1633 | err = snd_miro_probe(card); | ||
1634 | if (err < 0) { | ||
1635 | snd_card_free(card); | ||
1636 | return err; | ||
1637 | } | ||
1638 | pnp_set_card_drvdata(pcard, card); | ||
1639 | snd_miro_pnp_is_probed = 1; | ||
1640 | return 0; | ||
1641 | } | ||
1642 | |||
1643 | static void __devexit snd_miro_pnp_remove(struct pnp_card_link * pcard) | ||
1644 | { | ||
1645 | snd_card_free(pnp_get_card_drvdata(pcard)); | ||
1646 | pnp_set_card_drvdata(pcard, NULL); | ||
1647 | snd_miro_pnp_is_probed = 0; | ||
1648 | } | ||
1649 | |||
1650 | static struct pnp_card_driver miro_pnpc_driver = { | ||
1651 | .flags = PNP_DRIVER_RES_DISABLE, | ||
1652 | .name = "miro", | ||
1653 | .id_table = snd_miro_pnpids, | ||
1654 | .probe = snd_miro_pnp_probe, | ||
1655 | .remove = __devexit_p(snd_miro_pnp_remove), | ||
1656 | }; | ||
1657 | #endif | ||
1658 | |||
1434 | static int __init alsa_card_miro_init(void) | 1659 | static int __init alsa_card_miro_init(void) |
1435 | { | 1660 | { |
1661 | #ifdef CONFIG_PNP | ||
1662 | pnp_register_card_driver(&miro_pnpc_driver); | ||
1663 | if (snd_miro_pnp_is_probed) | ||
1664 | return 0; | ||
1665 | pnp_unregister_card_driver(&miro_pnpc_driver); | ||
1666 | #endif | ||
1436 | return isa_register_driver(&snd_miro_driver, 1); | 1667 | return isa_register_driver(&snd_miro_driver, 1); |
1437 | } | 1668 | } |
1438 | 1669 | ||
1439 | static void __exit alsa_card_miro_exit(void) | 1670 | static void __exit alsa_card_miro_exit(void) |
1440 | { | 1671 | { |
1441 | isa_unregister_driver(&snd_miro_driver); | 1672 | if (!snd_miro_pnp_is_probed) { |
1673 | isa_unregister_driver(&snd_miro_driver); | ||
1674 | return; | ||
1675 | } | ||
1676 | #ifdef CONFIG_PNP | ||
1677 | pnp_unregister_card_driver(&miro_pnpc_driver); | ||
1678 | #endif | ||
1442 | } | 1679 | } |
1443 | 1680 | ||
1444 | module_init(alsa_card_miro_init) | 1681 | module_init(alsa_card_miro_init) |
diff --git a/sound/isa/opti9xx/miro.h b/sound/isa/opti9xx/miro.h deleted file mode 100644 index 6e1385b8e07e..000000000000 --- a/sound/isa/opti9xx/miro.h +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | #ifndef _MIRO_H_ | ||
2 | #define _MIRO_H_ | ||
3 | |||
4 | #define ACI_REG_COMMAND 0 /* write register offset */ | ||
5 | #define ACI_REG_STATUS 1 /* read register offset */ | ||
6 | #define ACI_REG_BUSY 2 /* busy register offset */ | ||
7 | #define ACI_REG_RDS 2 /* PCM20: RDS register offset */ | ||
8 | #define ACI_MINTIME 500 /* ACI time out limit */ | ||
9 | |||
10 | #define ACI_SET_MUTE 0x0d | ||
11 | #define ACI_SET_POWERAMP 0x0f | ||
12 | #define ACI_SET_TUNERMUTE 0xa3 | ||
13 | #define ACI_SET_TUNERMONO 0xa4 | ||
14 | #define ACI_SET_IDE 0xd0 | ||
15 | #define ACI_SET_WSS 0xd1 | ||
16 | #define ACI_SET_SOLOMODE 0xd2 | ||
17 | #define ACI_SET_PREAMP 0x03 | ||
18 | #define ACI_GET_PREAMP 0x21 | ||
19 | #define ACI_WRITE_TUNE 0xa7 | ||
20 | #define ACI_READ_TUNERSTEREO 0xa8 | ||
21 | #define ACI_READ_TUNERSTATION 0xa9 | ||
22 | #define ACI_READ_VERSION 0xf1 | ||
23 | #define ACI_READ_IDCODE 0xf2 | ||
24 | #define ACI_INIT 0xff | ||
25 | #define ACI_STATUS 0xf0 | ||
26 | #define ACI_S_GENERAL 0x00 | ||
27 | #define ACI_ERROR_OP 0xdf | ||
28 | |||
29 | /* ACI Mixer */ | ||
30 | |||
31 | /* These are the values for the right channel GET registers. | ||
32 | Add an offset of 0x01 for the left channel register. | ||
33 | (left=right+0x01) */ | ||
34 | |||
35 | #define ACI_GET_MASTER 0x03 | ||
36 | #define ACI_GET_MIC 0x05 | ||
37 | #define ACI_GET_LINE 0x07 | ||
38 | #define ACI_GET_CD 0x09 | ||
39 | #define ACI_GET_SYNTH 0x0b | ||
40 | #define ACI_GET_PCM 0x0d | ||
41 | #define ACI_GET_LINE1 0x10 /* Radio on PCM20 */ | ||
42 | #define ACI_GET_LINE2 0x12 | ||
43 | |||
44 | #define ACI_GET_EQ1 0x22 /* from Bass ... */ | ||
45 | #define ACI_GET_EQ2 0x24 | ||
46 | #define ACI_GET_EQ3 0x26 | ||
47 | #define ACI_GET_EQ4 0x28 | ||
48 | #define ACI_GET_EQ5 0x2a | ||
49 | #define ACI_GET_EQ6 0x2c | ||
50 | #define ACI_GET_EQ7 0x2e /* ... to Treble */ | ||
51 | |||
52 | /* And these are the values for the right channel SET registers. | ||
53 | For left channel access you have to add an offset of 0x08. | ||
54 | MASTER is an exception, which needs an offset of 0x01 */ | ||
55 | |||
56 | #define ACI_SET_MASTER 0x00 | ||
57 | #define ACI_SET_MIC 0x30 | ||
58 | #define ACI_SET_LINE 0x31 | ||
59 | #define ACI_SET_CD 0x34 | ||
60 | #define ACI_SET_SYNTH 0x33 | ||
61 | #define ACI_SET_PCM 0x32 | ||
62 | #define ACI_SET_LINE1 0x35 /* Radio on PCM20 */ | ||
63 | #define ACI_SET_LINE2 0x36 | ||
64 | |||
65 | #define ACI_SET_EQ1 0x40 /* from Bass ... */ | ||
66 | #define ACI_SET_EQ2 0x41 | ||
67 | #define ACI_SET_EQ3 0x42 | ||
68 | #define ACI_SET_EQ4 0x43 | ||
69 | #define ACI_SET_EQ5 0x44 | ||
70 | #define ACI_SET_EQ6 0x45 | ||
71 | #define ACI_SET_EQ7 0x46 /* ... to Treble */ | ||
72 | |||
73 | #endif /* _MIRO_H_ */ | ||
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 5cd555325b9d..c8a8da0d4036 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
@@ -135,21 +135,15 @@ struct snd_opti9xx { | |||
135 | unsigned long mc_base_size; | 135 | unsigned long mc_base_size; |
136 | #ifdef OPTi93X | 136 | #ifdef OPTi93X |
137 | unsigned long mc_indir_index; | 137 | unsigned long mc_indir_index; |
138 | unsigned long mc_indir_size; | ||
139 | struct resource *res_mc_indir; | ||
138 | struct snd_wss *codec; | 140 | struct snd_wss *codec; |
139 | #endif /* OPTi93X */ | 141 | #endif /* OPTi93X */ |
140 | unsigned long pwd_reg; | 142 | unsigned long pwd_reg; |
141 | 143 | ||
142 | spinlock_t lock; | 144 | spinlock_t lock; |
143 | 145 | ||
144 | long wss_base; | ||
145 | int irq; | 146 | int irq; |
146 | int dma1; | ||
147 | int dma2; | ||
148 | |||
149 | long fm_port; | ||
150 | |||
151 | long mpu_port; | ||
152 | int mpu_irq; | ||
153 | 147 | ||
154 | #ifdef CONFIG_PNP | 148 | #ifdef CONFIG_PNP |
155 | struct pnp_dev *dev; | 149 | struct pnp_dev *dev; |
@@ -185,7 +179,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids); | |||
185 | #endif | 179 | #endif |
186 | 180 | ||
187 | static char * snd_opti9xx_names[] = { | 181 | static char * snd_opti9xx_names[] = { |
188 | "unkown", | 182 | "unknown", |
189 | "82C928", "82C929", | 183 | "82C928", "82C929", |
190 | "82C924", "82C925", | 184 | "82C924", "82C925", |
191 | "82C930", "82C931", "82C933" | 185 | "82C930", "82C931", "82C933" |
@@ -216,13 +210,7 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
216 | 210 | ||
217 | spin_lock_init(&chip->lock); | 211 | spin_lock_init(&chip->lock); |
218 | 212 | ||
219 | chip->wss_base = -1; | ||
220 | chip->irq = -1; | 213 | chip->irq = -1; |
221 | chip->dma1 = -1; | ||
222 | chip->dma2 = -1; | ||
223 | chip->fm_port = -1; | ||
224 | chip->mpu_port = -1; | ||
225 | chip->mpu_irq = -1; | ||
226 | 214 | ||
227 | switch (hardware) { | 215 | switch (hardware) { |
228 | #ifndef OPTi93X | 216 | #ifndef OPTi93X |
@@ -245,7 +233,10 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
245 | case OPTi9XX_HW_82C931: | 233 | case OPTi9XX_HW_82C931: |
246 | case OPTi9XX_HW_82C933: | 234 | case OPTi9XX_HW_82C933: |
247 | chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; | 235 | chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; |
248 | chip->mc_indir_index = 0xe0e; | 236 | if (!chip->mc_indir_index) { |
237 | chip->mc_indir_index = 0xe0e; | ||
238 | chip->mc_indir_size = 2; | ||
239 | } | ||
249 | chip->password = 0xe4; | 240 | chip->password = 0xe4; |
250 | chip->pwd_reg = 0; | 241 | chip->pwd_reg = 0; |
251 | break; | 242 | break; |
@@ -348,7 +339,10 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, | |||
348 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) | 339 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) |
349 | 340 | ||
350 | 341 | ||
351 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | 342 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, |
343 | long wss_base, | ||
344 | int irq, int dma1, int dma2, | ||
345 | long mpu_port, int mpu_irq) | ||
352 | { | 346 | { |
353 | unsigned char wss_base_bits; | 347 | unsigned char wss_base_bits; |
354 | unsigned char irq_bits; | 348 | unsigned char irq_bits; |
@@ -416,7 +410,7 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | |||
416 | return -EINVAL; | 410 | return -EINVAL; |
417 | } | 411 | } |
418 | 412 | ||
419 | switch (chip->wss_base) { | 413 | switch (wss_base) { |
420 | case 0x530: | 414 | case 0x530: |
421 | wss_base_bits = 0x00; | 415 | wss_base_bits = 0x00; |
422 | break; | 416 | break; |
@@ -430,14 +424,13 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | |||
430 | wss_base_bits = 0x02; | 424 | wss_base_bits = 0x02; |
431 | break; | 425 | break; |
432 | default: | 426 | default: |
433 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", | 427 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", wss_base); |
434 | chip->wss_base); | ||
435 | goto __skip_base; | 428 | goto __skip_base; |
436 | } | 429 | } |
437 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); | 430 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); |
438 | 431 | ||
439 | __skip_base: | 432 | __skip_base: |
440 | switch (chip->irq) { | 433 | switch (irq) { |
441 | //#ifdef OPTi93X | 434 | //#ifdef OPTi93X |
442 | case 5: | 435 | case 5: |
443 | irq_bits = 0x05; | 436 | irq_bits = 0x05; |
@@ -456,11 +449,11 @@ __skip_base: | |||
456 | irq_bits = 0x04; | 449 | irq_bits = 0x04; |
457 | break; | 450 | break; |
458 | default: | 451 | default: |
459 | snd_printk(KERN_WARNING "WSS irq # %d not valid\n", chip->irq); | 452 | snd_printk(KERN_WARNING "WSS irq # %d not valid\n", irq); |
460 | goto __skip_resources; | 453 | goto __skip_resources; |
461 | } | 454 | } |
462 | 455 | ||
463 | switch (chip->dma1) { | 456 | switch (dma1) { |
464 | case 0: | 457 | case 0: |
465 | dma_bits = 0x01; | 458 | dma_bits = 0x01; |
466 | break; | 459 | break; |
@@ -471,38 +464,36 @@ __skip_base: | |||
471 | dma_bits = 0x03; | 464 | dma_bits = 0x03; |
472 | break; | 465 | break; |
473 | default: | 466 | default: |
474 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", | 467 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1); |
475 | chip->dma1); | ||
476 | goto __skip_resources; | 468 | goto __skip_resources; |
477 | } | 469 | } |
478 | 470 | ||
479 | #if defined(CS4231) || defined(OPTi93X) | 471 | #if defined(CS4231) || defined(OPTi93X) |
480 | if (chip->dma1 == chip->dma2) { | 472 | if (dma1 == dma2) { |
481 | snd_printk(KERN_ERR "don't want to share dmas\n"); | 473 | snd_printk(KERN_ERR "don't want to share dmas\n"); |
482 | return -EBUSY; | 474 | return -EBUSY; |
483 | } | 475 | } |
484 | 476 | ||
485 | switch (chip->dma2) { | 477 | switch (dma2) { |
486 | case 0: | 478 | case 0: |
487 | case 1: | 479 | case 1: |
488 | break; | 480 | break; |
489 | default: | 481 | default: |
490 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", | 482 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2); |
491 | chip->dma2); | ||
492 | goto __skip_resources; | 483 | goto __skip_resources; |
493 | } | 484 | } |
494 | dma_bits |= 0x04; | 485 | dma_bits |= 0x04; |
495 | #endif /* CS4231 || OPTi93X */ | 486 | #endif /* CS4231 || OPTi93X */ |
496 | 487 | ||
497 | #ifndef OPTi93X | 488 | #ifndef OPTi93X |
498 | outb(irq_bits << 3 | dma_bits, chip->wss_base); | 489 | outb(irq_bits << 3 | dma_bits, wss_base); |
499 | #else /* OPTi93X */ | 490 | #else /* OPTi93X */ |
500 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); | 491 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); |
501 | #endif /* OPTi93X */ | 492 | #endif /* OPTi93X */ |
502 | 493 | ||
503 | __skip_resources: | 494 | __skip_resources: |
504 | if (chip->hardware > OPTi9XX_HW_82C928) { | 495 | if (chip->hardware > OPTi9XX_HW_82C928) { |
505 | switch (chip->mpu_port) { | 496 | switch (mpu_port) { |
506 | case 0: | 497 | case 0: |
507 | case -1: | 498 | case -1: |
508 | break; | 499 | break; |
@@ -520,12 +511,11 @@ __skip_resources: | |||
520 | break; | 511 | break; |
521 | default: | 512 | default: |
522 | snd_printk(KERN_WARNING | 513 | snd_printk(KERN_WARNING |
523 | "MPU-401 port 0x%lx not valid\n", | 514 | "MPU-401 port 0x%lx not valid\n", mpu_port); |
524 | chip->mpu_port); | ||
525 | goto __skip_mpu; | 515 | goto __skip_mpu; |
526 | } | 516 | } |
527 | 517 | ||
528 | switch (chip->mpu_irq) { | 518 | switch (mpu_irq) { |
529 | case 5: | 519 | case 5: |
530 | mpu_irq_bits = 0x02; | 520 | mpu_irq_bits = 0x02; |
531 | break; | 521 | break; |
@@ -540,12 +530,12 @@ __skip_resources: | |||
540 | break; | 530 | break; |
541 | default: | 531 | default: |
542 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", | 532 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", |
543 | chip->mpu_irq); | 533 | mpu_irq); |
544 | goto __skip_mpu; | 534 | goto __skip_mpu; |
545 | } | 535 | } |
546 | 536 | ||
547 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), | 537 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), |
548 | (chip->mpu_port <= 0) ? 0x00 : | 538 | (mpu_port <= 0) ? 0x00 : |
549 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, | 539 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, |
550 | 0xf8); | 540 | 0xf8); |
551 | } | 541 | } |
@@ -558,10 +548,13 @@ __skip_mpu: | |||
558 | 548 | ||
559 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | 549 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
560 | { | 550 | { |
561 | struct snd_wss *codec = dev_id; | 551 | struct snd_opti9xx *chip = dev_id; |
562 | struct snd_opti9xx *chip = codec->card->private_data; | 552 | struct snd_wss *codec = chip->codec; |
563 | unsigned char status; | 553 | unsigned char status; |
564 | 554 | ||
555 | if (!codec) | ||
556 | return IRQ_HANDLED; | ||
557 | |||
565 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); | 558 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); |
566 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) | 559 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) |
567 | snd_pcm_period_elapsed(codec->playback_substream); | 560 | snd_pcm_period_elapsed(codec->playback_substream); |
@@ -575,57 +568,69 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | |||
575 | 568 | ||
576 | #endif /* OPTi93X */ | 569 | #endif /* OPTi93X */ |
577 | 570 | ||
578 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, | 571 | static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip) |
579 | struct snd_opti9xx *chip) | ||
580 | { | 572 | { |
581 | int i, err; | 573 | unsigned char value; |
574 | #ifdef OPTi93X | ||
575 | unsigned long flags; | ||
576 | #endif | ||
582 | 577 | ||
578 | chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, | ||
579 | "OPTi9xx MC"); | ||
580 | if (chip->res_mc_base == NULL) | ||
581 | return -EBUSY; | ||
583 | #ifndef OPTi93X | 582 | #ifndef OPTi93X |
584 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { | 583 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); |
585 | unsigned char value; | 584 | if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1))) |
585 | if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) | ||
586 | return 0; | ||
587 | #else /* OPTi93X */ | ||
588 | chip->res_mc_indir = request_region(chip->mc_indir_index, | ||
589 | chip->mc_indir_size, | ||
590 | "OPTi93x MC"); | ||
591 | if (chip->res_mc_indir == NULL) | ||
592 | return -EBUSY; | ||
586 | 593 | ||
587 | if ((err = snd_opti9xx_init(chip, i)) < 0) | 594 | spin_lock_irqsave(&chip->lock, flags); |
588 | return err; | 595 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
596 | outb(((chip->mc_indir_index & 0x1f0) >> 4), chip->mc_base); | ||
597 | spin_unlock_irqrestore(&chip->lock, flags); | ||
589 | 598 | ||
590 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 599 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)); |
591 | continue; | 600 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value); |
601 | if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) | ||
602 | return 0; | ||
592 | 603 | ||
593 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); | 604 | release_and_free_resource(chip->res_mc_indir); |
594 | if ((value != 0xff) && (value != inb(chip->mc_base + 1))) | 605 | chip->res_mc_indir = NULL; |
595 | if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) | 606 | #endif /* OPTi93X */ |
596 | return 1; | 607 | release_and_free_resource(chip->res_mc_base); |
608 | chip->res_mc_base = NULL; | ||
597 | 609 | ||
598 | release_and_free_resource(chip->res_mc_base); | 610 | return -ENODEV; |
599 | chip->res_mc_base = NULL; | 611 | } |
600 | 612 | ||
601 | } | 613 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, |
602 | #else /* OPTi93X */ | 614 | struct snd_opti9xx *chip) |
603 | for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { | 615 | { |
604 | unsigned long flags; | 616 | int i, err; |
605 | unsigned char value; | ||
606 | 617 | ||
607 | if ((err = snd_opti9xx_init(chip, i)) < 0) | 618 | #ifndef OPTi93X |
619 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { | ||
620 | #else | ||
621 | for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { | ||
622 | #endif | ||
623 | err = snd_opti9xx_init(chip, i); | ||
624 | if (err < 0) | ||
608 | return err; | 625 | return err; |
609 | 626 | ||
610 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 627 | err = snd_opti9xx_read_check(chip); |
611 | continue; | 628 | if (err == 0) |
612 | |||
613 | spin_lock_irqsave(&chip->lock, flags); | ||
614 | outb(chip->password, chip->mc_base + chip->pwd_reg); | ||
615 | outb(((chip->mc_indir_index & (1 << 8)) >> 4) | | ||
616 | ((chip->mc_indir_index & 0xf0) >> 4), chip->mc_base); | ||
617 | spin_unlock_irqrestore(&chip->lock, flags); | ||
618 | |||
619 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)); | ||
620 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value); | ||
621 | if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) | ||
622 | return 1; | 629 | return 1; |
623 | 630 | #ifdef OPTi93X | |
624 | release_and_free_resource(chip->res_mc_base); | 631 | chip->mc_indir_index = 0; |
625 | chip->res_mc_base = NULL; | 632 | #endif |
626 | } | 633 | } |
627 | #endif /* OPTi93X */ | ||
628 | |||
629 | return -ENODEV; | 634 | return -ENODEV; |
630 | } | 635 | } |
631 | 636 | ||
@@ -654,6 +659,8 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
654 | #ifdef OPTi93X | 659 | #ifdef OPTi93X |
655 | port = pnp_port_start(pdev, 0) - 4; | 660 | port = pnp_port_start(pdev, 0) - 4; |
656 | fm_port = pnp_port_start(pdev, 1) + 8; | 661 | fm_port = pnp_port_start(pdev, 1) + 8; |
662 | chip->mc_indir_index = pnp_port_start(pdev, 3) + 2; | ||
663 | chip->mc_indir_size = pnp_port_len(pdev, 3) - 2; | ||
657 | #else | 664 | #else |
658 | if (pid->driver_data != 0x0924) | 665 | if (pid->driver_data != 0x0924) |
659 | port = pnp_port_start(pdev, 1); | 666 | port = pnp_port_start(pdev, 1); |
@@ -684,14 +691,14 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
684 | static void snd_card_opti9xx_free(struct snd_card *card) | 691 | static void snd_card_opti9xx_free(struct snd_card *card) |
685 | { | 692 | { |
686 | struct snd_opti9xx *chip = card->private_data; | 693 | struct snd_opti9xx *chip = card->private_data; |
687 | 694 | ||
688 | if (chip) { | 695 | if (chip) { |
689 | #ifdef OPTi93X | 696 | #ifdef OPTi93X |
690 | struct snd_wss *codec = chip->codec; | 697 | if (chip->irq > 0) { |
691 | if (codec && codec->irq > 0) { | 698 | disable_irq(chip->irq); |
692 | disable_irq(codec->irq); | 699 | free_irq(chip->irq, chip); |
693 | free_irq(codec->irq, codec); | ||
694 | } | 700 | } |
701 | release_and_free_resource(chip->res_mc_indir); | ||
695 | #endif | 702 | #endif |
696 | release_and_free_resource(chip->res_mc_base); | 703 | release_and_free_resource(chip->res_mc_base); |
697 | } | 704 | } |
@@ -701,6 +708,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
701 | { | 708 | { |
702 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | 709 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; |
703 | int error; | 710 | int error; |
711 | int xdma2; | ||
704 | struct snd_opti9xx *chip = card->private_data; | 712 | struct snd_opti9xx *chip = card->private_data; |
705 | struct snd_wss *codec; | 713 | struct snd_wss *codec; |
706 | #ifdef CS4231 | 714 | #ifdef CS4231 |
@@ -710,36 +718,25 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
710 | struct snd_rawmidi *rmidi; | 718 | struct snd_rawmidi *rmidi; |
711 | struct snd_hwdep *synth; | 719 | struct snd_hwdep *synth; |
712 | 720 | ||
713 | if (! chip->res_mc_base && | ||
714 | (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, | ||
715 | "OPTi9xx MC")) == NULL) | ||
716 | return -ENOMEM; | ||
717 | |||
718 | chip->wss_base = port; | ||
719 | chip->fm_port = fm_port; | ||
720 | chip->mpu_port = mpu_port; | ||
721 | chip->irq = irq; | ||
722 | chip->mpu_irq = mpu_irq; | ||
723 | chip->dma1 = dma1; | ||
724 | #if defined(CS4231) || defined(OPTi93X) | 721 | #if defined(CS4231) || defined(OPTi93X) |
725 | chip->dma2 = dma2; | 722 | xdma2 = dma2; |
726 | #else | 723 | #else |
727 | chip->dma2 = -1; | 724 | xdma2 = -1; |
728 | #endif | 725 | #endif |
729 | 726 | ||
730 | if (chip->wss_base == SNDRV_AUTO_PORT) { | 727 | if (port == SNDRV_AUTO_PORT) { |
731 | chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4); | 728 | port = snd_legacy_find_free_ioport(possible_ports, 4); |
732 | if (chip->wss_base < 0) { | 729 | if (port < 0) { |
733 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | 730 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); |
734 | return -EBUSY; | 731 | return -EBUSY; |
735 | } | 732 | } |
736 | } | 733 | } |
737 | error = snd_opti9xx_configure(chip); | 734 | error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2, |
735 | mpu_port, mpu_irq); | ||
738 | if (error) | 736 | if (error) |
739 | return error; | 737 | return error; |
740 | 738 | ||
741 | error = snd_wss_create(card, chip->wss_base + 4, -1, | 739 | error = snd_wss_create(card, port + 4, -1, irq, dma1, xdma2, |
742 | chip->irq, chip->dma1, chip->dma2, | ||
743 | #ifdef OPTi93X | 740 | #ifdef OPTi93X |
744 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, | 741 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, |
745 | #else | 742 | #else |
@@ -763,35 +760,35 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
763 | return error; | 760 | return error; |
764 | #endif | 761 | #endif |
765 | #ifdef OPTi93X | 762 | #ifdef OPTi93X |
766 | error = request_irq(chip->irq, snd_opti93x_interrupt, | 763 | error = request_irq(irq, snd_opti93x_interrupt, |
767 | IRQF_DISABLED, DEV_NAME" - WSS", codec); | 764 | IRQF_DISABLED, DEV_NAME" - WSS", chip); |
768 | if (error < 0) { | 765 | if (error < 0) { |
769 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); | 766 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq); |
770 | return error; | 767 | return error; |
771 | } | 768 | } |
772 | #endif | 769 | #endif |
770 | chip->irq = irq; | ||
773 | strcpy(card->driver, chip->name); | 771 | strcpy(card->driver, chip->name); |
774 | sprintf(card->shortname, "OPTi %s", card->driver); | 772 | sprintf(card->shortname, "OPTi %s", card->driver); |
775 | #if defined(CS4231) || defined(OPTi93X) | 773 | #if defined(CS4231) || defined(OPTi93X) |
776 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 774 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", |
777 | card->shortname, pcm->name, chip->wss_base + 4, | 775 | card->shortname, pcm->name, port + 4, irq, dma1, xdma2); |
778 | chip->irq, chip->dma1, chip->dma2); | ||
779 | #else | 776 | #else |
780 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | 777 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
781 | card->shortname, pcm->name, chip->wss_base + 4, | 778 | card->shortname, pcm->name, port + 4, irq, dma1); |
782 | chip->irq, chip->dma1); | ||
783 | #endif /* CS4231 || OPTi93X */ | 779 | #endif /* CS4231 || OPTi93X */ |
784 | 780 | ||
785 | if (chip->mpu_port <= 0 || chip->mpu_port == SNDRV_AUTO_PORT) | 781 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
786 | rmidi = NULL; | 782 | rmidi = NULL; |
787 | else | 783 | else { |
788 | if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, | 784 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
789 | chip->mpu_port, 0, chip->mpu_irq, IRQF_DISABLED, | 785 | mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi); |
790 | &rmidi))) | 786 | if (error) |
791 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", | 787 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", |
792 | chip->mpu_port); | 788 | mpu_port); |
789 | } | ||
793 | 790 | ||
794 | if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { | 791 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
795 | struct snd_opl3 *opl3 = NULL; | 792 | struct snd_opl3 *opl3 = NULL; |
796 | #ifndef OPTi93X | 793 | #ifndef OPTi93X |
797 | if (chip->hardware == OPTi9XX_HW_82C928 || | 794 | if (chip->hardware == OPTi9XX_HW_82C928 || |
@@ -801,9 +798,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
801 | /* assume we have an OPL4 */ | 798 | /* assume we have an OPL4 */ |
802 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), | 799 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
803 | 0x20, 0x20); | 800 | 0x20, 0x20); |
804 | if (snd_opl4_create(card, | 801 | if (snd_opl4_create(card, fm_port, fm_port - 8, |
805 | chip->fm_port, | ||
806 | chip->fm_port - 8, | ||
807 | 2, &opl3, &opl4) < 0) { | 802 | 2, &opl3, &opl4) < 0) { |
808 | /* no luck, use OPL3 instead */ | 803 | /* no luck, use OPL3 instead */ |
809 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), | 804 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
@@ -811,12 +806,10 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
811 | } | 806 | } |
812 | } | 807 | } |
813 | #endif /* !OPTi93X */ | 808 | #endif /* !OPTi93X */ |
814 | if (!opl3 && snd_opl3_create(card, | 809 | if (!opl3 && snd_opl3_create(card, fm_port, fm_port + 2, |
815 | chip->fm_port, | ||
816 | chip->fm_port + 2, | ||
817 | OPL3_HW_AUTO, 0, &opl3) < 0) { | 810 | OPL3_HW_AUTO, 0, &opl3) < 0) { |
818 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", | 811 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", |
819 | chip->fm_port, chip->fm_port + 4 - 1); | 812 | fm_port, fm_port + 4 - 1); |
820 | } | 813 | } |
821 | if (opl3) { | 814 | if (opl3) { |
822 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); | 815 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); |
@@ -978,6 +971,13 @@ static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, | |||
978 | } | 971 | } |
979 | if (hw <= OPTi9XX_HW_82C930) | 972 | if (hw <= OPTi9XX_HW_82C930) |
980 | chip->mc_base -= 0x80; | 973 | chip->mc_base -= 0x80; |
974 | |||
975 | error = snd_opti9xx_read_check(chip); | ||
976 | if (error) { | ||
977 | snd_printk(KERN_ERR "OPTI chip not found\n"); | ||
978 | snd_card_free(card); | ||
979 | return error; | ||
980 | } | ||
981 | snd_card_set_dev(card, &pcard->card->dev); | 981 | snd_card_set_dev(card, &pcard->card->dev); |
982 | if ((error = snd_opti9xx_probe(card)) < 0) { | 982 | if ((error = snd_opti9xx_probe(card)) < 0) { |
983 | snd_card_free(card); | 983 | snd_card_free(card); |
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/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 475220bbcc96..318ff0c823e7 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c | |||
@@ -631,7 +631,7 @@ static struct sbmix_elem snd_sb16_ctl_mic_play_switch = | |||
631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = | 631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = |
632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); | 632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); |
633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = | 633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = |
634 | SB_SINGLE("PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3); | 634 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3); |
635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = | 635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = |
636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); | 636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); |
637 | static struct sbmix_elem snd_sb16_ctl_play_vol = | 637 | static struct sbmix_elem snd_sb16_ctl_play_vol = |
@@ -689,7 +689,7 @@ static struct sbmix_elem snd_dt019x_ctl_cd_play_vol = | |||
689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = | 689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = |
690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); | 690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); |
691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = | 691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = |
692 | SB_SINGLE("PC Speaker Volume", SB_DT019X_SPKR_DEV, 0, 7); | 692 | SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7); |
693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = | 693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = |
694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); | 694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); |
695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = | 695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = |
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 66187122377c..e2d5d2d3ed96 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Low-level ALSA driver for the ENSONIQ SoundScape PnP | 2 | * Low-level ALSA driver for the ENSONIQ SoundScape |
3 | * Copyright (c) by Chris Rankin | 3 | * Copyright (c) by Chris Rankin |
4 | * | 4 | * |
5 | * This driver was written in part using information obtained from | 5 | * This driver was written in part using information obtained from |
@@ -25,31 +25,36 @@ | |||
25 | #include <linux/err.h> | 25 | #include <linux/err.h> |
26 | #include <linux/isa.h> | 26 | #include <linux/isa.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/firmware.h> | ||
28 | #include <linux/pnp.h> | 29 | #include <linux/pnp.h> |
29 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
30 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
31 | #include <asm/dma.h> | 32 | #include <asm/dma.h> |
32 | #include <sound/core.h> | 33 | #include <sound/core.h> |
33 | #include <sound/hwdep.h> | ||
34 | #include <sound/wss.h> | 34 | #include <sound/wss.h> |
35 | #include <sound/mpu401.h> | 35 | #include <sound/mpu401.h> |
36 | #include <sound/initval.h> | 36 | #include <sound/initval.h> |
37 | 37 | ||
38 | #include <sound/sscape_ioctl.h> | ||
39 | |||
40 | 38 | ||
41 | MODULE_AUTHOR("Chris Rankin"); | 39 | MODULE_AUTHOR("Chris Rankin"); |
42 | MODULE_DESCRIPTION("ENSONIQ SoundScape PnP driver"); | 40 | MODULE_DESCRIPTION("ENSONIQ SoundScape driver"); |
43 | MODULE_LICENSE("GPL"); | 41 | MODULE_LICENSE("GPL"); |
44 | 42 | MODULE_FIRMWARE("sndscape.co0"); | |
45 | static int index[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IDX; | 43 | MODULE_FIRMWARE("sndscape.co1"); |
46 | static char* id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_STR; | 44 | MODULE_FIRMWARE("sndscape.co2"); |
47 | static long port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; | 45 | MODULE_FIRMWARE("sndscape.co3"); |
48 | static long wss_port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; | 46 | MODULE_FIRMWARE("sndscape.co4"); |
49 | static int irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; | 47 | MODULE_FIRMWARE("scope.cod"); |
50 | static int mpu_irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; | 48 | |
51 | static int dma[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; | 49 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
52 | static int dma2[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; | 50 | static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
51 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
52 | static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
53 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
54 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
55 | static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
56 | static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
57 | static bool joystick[SNDRV_CARDS]; | ||
53 | 58 | ||
54 | module_param_array(index, int, NULL, 0444); | 59 | module_param_array(index, int, NULL, 0444); |
55 | MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); | 60 | MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); |
@@ -75,6 +80,9 @@ MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); | |||
75 | module_param_array(dma2, int, NULL, 0444); | 80 | module_param_array(dma2, int, NULL, 0444); |
76 | MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); | 81 | MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); |
77 | 82 | ||
83 | module_param_array(joystick, bool, NULL, 0444); | ||
84 | MODULE_PARM_DESC(joystick, "Enable gameport."); | ||
85 | |||
78 | #ifdef CONFIG_PNP | 86 | #ifdef CONFIG_PNP |
79 | static int isa_registered; | 87 | static int isa_registered; |
80 | static int pnp_registered; | 88 | static int pnp_registered; |
@@ -101,14 +109,14 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); | |||
101 | #define RX_READY 0x01 | 109 | #define RX_READY 0x01 |
102 | #define TX_READY 0x02 | 110 | #define TX_READY 0x02 |
103 | 111 | ||
104 | #define CMD_ACK 0x80 | 112 | #define CMD_ACK 0x80 |
105 | #define CMD_SET_MIDI_VOL 0x84 | 113 | #define CMD_SET_MIDI_VOL 0x84 |
106 | #define CMD_GET_MIDI_VOL 0x85 | 114 | #define CMD_GET_MIDI_VOL 0x85 |
107 | #define CMD_XXX_MIDI_VOL 0x86 | 115 | #define CMD_XXX_MIDI_VOL 0x86 |
108 | #define CMD_SET_EXTMIDI 0x8a | 116 | #define CMD_SET_EXTMIDI 0x8a |
109 | #define CMD_GET_EXTMIDI 0x8b | 117 | #define CMD_GET_EXTMIDI 0x8b |
110 | #define CMD_SET_MT32 0x8c | 118 | #define CMD_SET_MT32 0x8c |
111 | #define CMD_GET_MT32 0x8d | 119 | #define CMD_GET_MT32 0x8d |
112 | 120 | ||
113 | enum GA_REG { | 121 | enum GA_REG { |
114 | GA_INTSTAT_REG = 0, | 122 | GA_INTSTAT_REG = 0, |
@@ -127,7 +135,8 @@ enum GA_REG { | |||
127 | 135 | ||
128 | 136 | ||
129 | enum card_type { | 137 | enum card_type { |
130 | SSCAPE, | 138 | MEDIA_FX, /* Sequoia S-1000 */ |
139 | SSCAPE, /* Sequoia S-2000 */ | ||
131 | SSCAPE_PNP, | 140 | SSCAPE_PNP, |
132 | SSCAPE_VIVO, | 141 | SSCAPE_VIVO, |
133 | }; | 142 | }; |
@@ -140,16 +149,7 @@ struct soundscape { | |||
140 | struct resource *io_res; | 149 | struct resource *io_res; |
141 | struct resource *wss_res; | 150 | struct resource *wss_res; |
142 | struct snd_wss *chip; | 151 | struct snd_wss *chip; |
143 | struct snd_mpu401 *mpu; | ||
144 | struct snd_hwdep *hw; | ||
145 | 152 | ||
146 | /* | ||
147 | * The MIDI device won't work until we've loaded | ||
148 | * its firmware via a hardware-dependent device IOCTL | ||
149 | */ | ||
150 | spinlock_t fwlock; | ||
151 | int hw_in_use; | ||
152 | unsigned long midi_usage; | ||
153 | unsigned char midi_vol; | 153 | unsigned char midi_vol; |
154 | }; | 154 | }; |
155 | 155 | ||
@@ -161,28 +161,21 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c) | |||
161 | return (struct soundscape *) (c->private_data); | 161 | return (struct soundscape *) (c->private_data); |
162 | } | 162 | } |
163 | 163 | ||
164 | static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu) | ||
165 | { | ||
166 | return (struct soundscape *) (mpu->private_data); | ||
167 | } | ||
168 | |||
169 | static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw) | ||
170 | { | ||
171 | return (struct soundscape *) (hw->private_data); | ||
172 | } | ||
173 | |||
174 | |||
175 | /* | 164 | /* |
176 | * Allocates some kernel memory that we can use for DMA. | 165 | * Allocates some kernel memory that we can use for DMA. |
177 | * I think this means that the memory has to map to | 166 | * I think this means that the memory has to map to |
178 | * contiguous pages of physical memory. | 167 | * contiguous pages of physical memory. |
179 | */ | 168 | */ |
180 | static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned long size) | 169 | static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, |
170 | unsigned long size) | ||
181 | { | 171 | { |
182 | if (buf) { | 172 | if (buf) { |
183 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), | 173 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, |
174 | snd_dma_isa_data(), | ||
184 | size, buf) < 0) { | 175 | size, buf) < 0) { |
185 | snd_printk(KERN_ERR "sscape: Failed to allocate %lu bytes for DMA\n", size); | 176 | snd_printk(KERN_ERR "sscape: Failed to allocate " |
177 | "%lu bytes for DMA\n", | ||
178 | size); | ||
186 | return NULL; | 179 | return NULL; |
187 | } | 180 | } |
188 | } | 181 | } |
@@ -199,13 +192,13 @@ static void free_dmabuf(struct snd_dma_buffer *buf) | |||
199 | snd_dma_free_pages(buf); | 192 | snd_dma_free_pages(buf); |
200 | } | 193 | } |
201 | 194 | ||
202 | |||
203 | /* | 195 | /* |
204 | * This function writes to the SoundScape's control registers, | 196 | * This function writes to the SoundScape's control registers, |
205 | * but doesn't do any locking. It's up to the caller to do that. | 197 | * but doesn't do any locking. It's up to the caller to do that. |
206 | * This is why this function is "unsafe" ... | 198 | * This is why this function is "unsafe" ... |
207 | */ | 199 | */ |
208 | static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsigned char val) | 200 | static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, |
201 | unsigned char val) | ||
209 | { | 202 | { |
210 | outb(reg, ODIE_ADDR_IO(io_base)); | 203 | outb(reg, ODIE_ADDR_IO(io_base)); |
211 | outb(val, ODIE_DATA_IO(io_base)); | 204 | outb(val, ODIE_DATA_IO(io_base)); |
@@ -215,7 +208,8 @@ static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsign | |||
215 | * Write to the SoundScape's control registers, and do the | 208 | * Write to the SoundScape's control registers, and do the |
216 | * necessary locking ... | 209 | * necessary locking ... |
217 | */ | 210 | */ |
218 | static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char val) | 211 | static void sscape_write(struct soundscape *s, enum GA_REG reg, |
212 | unsigned char val) | ||
219 | { | 213 | { |
220 | unsigned long flags; | 214 | unsigned long flags; |
221 | 215 | ||
@@ -228,7 +222,8 @@ static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char va | |||
228 | * Read from the SoundScape's control registers, but leave any | 222 | * Read from the SoundScape's control registers, but leave any |
229 | * locking to the caller. This is why the function is "unsafe" ... | 223 | * locking to the caller. This is why the function is "unsafe" ... |
230 | */ | 224 | */ |
231 | static inline unsigned char sscape_read_unsafe(unsigned io_base, enum GA_REG reg) | 225 | static inline unsigned char sscape_read_unsafe(unsigned io_base, |
226 | enum GA_REG reg) | ||
232 | { | 227 | { |
233 | outb(reg, ODIE_ADDR_IO(io_base)); | 228 | outb(reg, ODIE_ADDR_IO(io_base)); |
234 | return inb(ODIE_DATA_IO(io_base)); | 229 | return inb(ODIE_DATA_IO(io_base)); |
@@ -257,9 +252,8 @@ static inline void set_midi_mode_unsafe(unsigned io_base) | |||
257 | static inline int host_read_unsafe(unsigned io_base) | 252 | static inline int host_read_unsafe(unsigned io_base) |
258 | { | 253 | { |
259 | int data = -1; | 254 | int data = -1; |
260 | if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) { | 255 | if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) |
261 | data = inb(HOST_DATA_IO(io_base)); | 256 | data = inb(HOST_DATA_IO(io_base)); |
262 | } | ||
263 | 257 | ||
264 | return data; | 258 | return data; |
265 | } | 259 | } |
@@ -301,7 +295,7 @@ static inline int host_write_unsafe(unsigned io_base, unsigned char data) | |||
301 | * Also leaves all locking-issues to the caller ... | 295 | * Also leaves all locking-issues to the caller ... |
302 | */ | 296 | */ |
303 | static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, | 297 | static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, |
304 | unsigned timeout) | 298 | unsigned timeout) |
305 | { | 299 | { |
306 | int err; | 300 | int err; |
307 | 301 | ||
@@ -320,7 +314,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, | |||
320 | * | 314 | * |
321 | * NOTE: This check is based upon observation, not documentation. | 315 | * NOTE: This check is based upon observation, not documentation. |
322 | */ | 316 | */ |
323 | static inline int verify_mpu401(const struct snd_mpu401 * mpu) | 317 | static inline int verify_mpu401(const struct snd_mpu401 *mpu) |
324 | { | 318 | { |
325 | return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); | 319 | return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); |
326 | } | 320 | } |
@@ -328,7 +322,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu) | |||
328 | /* | 322 | /* |
329 | * This is apparently the standard way to initailise an MPU-401 | 323 | * This is apparently the standard way to initailise an MPU-401 |
330 | */ | 324 | */ |
331 | static inline void initialise_mpu401(const struct snd_mpu401 * mpu) | 325 | static inline void initialise_mpu401(const struct snd_mpu401 *mpu) |
332 | { | 326 | { |
333 | outb(0, MPU401D(mpu)); | 327 | outb(0, MPU401D(mpu)); |
334 | } | 328 | } |
@@ -338,9 +332,10 @@ static inline void initialise_mpu401(const struct snd_mpu401 * mpu) | |||
338 | * The AD1845 detection fails if we *don't* do this, so I | 332 | * The AD1845 detection fails if we *don't* do this, so I |
339 | * think that this is a good idea ... | 333 | * think that this is a good idea ... |
340 | */ | 334 | */ |
341 | static inline void activate_ad1845_unsafe(unsigned io_base) | 335 | static void activate_ad1845_unsafe(unsigned io_base) |
342 | { | 336 | { |
343 | sscape_write_unsafe(io_base, GA_HMCTL_REG, (sscape_read_unsafe(io_base, GA_HMCTL_REG) & 0xcf) | 0x10); | 337 | unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG); |
338 | sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10); | ||
344 | sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); | 339 | sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); |
345 | } | 340 | } |
346 | 341 | ||
@@ -359,24 +354,27 @@ static void soundscape_free(struct snd_card *c) | |||
359 | * Tell the SoundScape to begin a DMA tranfer using the given channel. | 354 | * Tell the SoundScape to begin a DMA tranfer using the given channel. |
360 | * All locking issues are left to the caller. | 355 | * All locking issues are left to the caller. |
361 | */ | 356 | */ |
362 | static inline void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) | 357 | static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) |
363 | { | 358 | { |
364 | sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) | 0x01); | 359 | sscape_write_unsafe(io_base, reg, |
365 | sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) & 0xfe); | 360 | sscape_read_unsafe(io_base, reg) | 0x01); |
361 | sscape_write_unsafe(io_base, reg, | ||
362 | sscape_read_unsafe(io_base, reg) & 0xfe); | ||
366 | } | 363 | } |
367 | 364 | ||
368 | /* | 365 | /* |
369 | * Wait for a DMA transfer to complete. This is a "limited busy-wait", | 366 | * Wait for a DMA transfer to complete. This is a "limited busy-wait", |
370 | * and all locking issues are left to the caller. | 367 | * and all locking issues are left to the caller. |
371 | */ | 368 | */ |
372 | static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned timeout) | 369 | static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, |
370 | unsigned timeout) | ||
373 | { | 371 | { |
374 | while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { | 372 | while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { |
375 | udelay(100); | 373 | udelay(100); |
376 | --timeout; | 374 | --timeout; |
377 | } /* while */ | 375 | } /* while */ |
378 | 376 | ||
379 | return (sscape_read_unsafe(io_base, reg) & 0x01); | 377 | return sscape_read_unsafe(io_base, reg) & 0x01; |
380 | } | 378 | } |
381 | 379 | ||
382 | /* | 380 | /* |
@@ -392,12 +390,12 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout) | |||
392 | 390 | ||
393 | do { | 391 | do { |
394 | unsigned long flags; | 392 | unsigned long flags; |
395 | unsigned char x; | 393 | int x; |
396 | 394 | ||
397 | spin_lock_irqsave(&s->lock, flags); | 395 | spin_lock_irqsave(&s->lock, flags); |
398 | x = inb(HOST_DATA_IO(s->io_base)); | 396 | x = host_read_unsafe(s->io_base); |
399 | spin_unlock_irqrestore(&s->lock, flags); | 397 | spin_unlock_irqrestore(&s->lock, flags); |
400 | if ((x & 0xfe) == 0xfe) | 398 | if (x == 0xfe || x == 0xff) |
401 | return 1; | 399 | return 1; |
402 | 400 | ||
403 | msleep(10); | 401 | msleep(10); |
@@ -419,10 +417,10 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) | |||
419 | 417 | ||
420 | do { | 418 | do { |
421 | unsigned long flags; | 419 | unsigned long flags; |
422 | unsigned char x; | 420 | int x; |
423 | 421 | ||
424 | spin_lock_irqsave(&s->lock, flags); | 422 | spin_lock_irqsave(&s->lock, flags); |
425 | x = inb(HOST_DATA_IO(s->io_base)); | 423 | x = host_read_unsafe(s->io_base); |
426 | spin_unlock_irqrestore(&s->lock, flags); | 424 | spin_unlock_irqrestore(&s->lock, flags); |
427 | if (x == 0xfe) | 425 | if (x == 0xfe) |
428 | return 1; | 426 | return 1; |
@@ -436,15 +434,15 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) | |||
436 | /* | 434 | /* |
437 | * Upload a byte-stream into the SoundScape using DMA channel A. | 435 | * Upload a byte-stream into the SoundScape using DMA channel A. |
438 | */ | 436 | */ |
439 | static int upload_dma_data(struct soundscape *s, | 437 | static int upload_dma_data(struct soundscape *s, const unsigned char *data, |
440 | const unsigned char __user *data, | 438 | size_t size) |
441 | size_t size) | ||
442 | { | 439 | { |
443 | unsigned long flags; | 440 | unsigned long flags; |
444 | struct snd_dma_buffer dma; | 441 | struct snd_dma_buffer dma; |
445 | int ret; | 442 | int ret; |
443 | unsigned char val; | ||
446 | 444 | ||
447 | if (!get_dmabuf(&dma, PAGE_ALIGN(size))) | 445 | if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024))) |
448 | return -ENOMEM; | 446 | return -ENOMEM; |
449 | 447 | ||
450 | spin_lock_irqsave(&s->lock, flags); | 448 | spin_lock_irqsave(&s->lock, flags); |
@@ -452,70 +450,57 @@ static int upload_dma_data(struct soundscape *s, | |||
452 | /* | 450 | /* |
453 | * Reset the board ... | 451 | * Reset the board ... |
454 | */ | 452 | */ |
455 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f); | 453 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
454 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f); | ||
456 | 455 | ||
457 | /* | 456 | /* |
458 | * Enable the DMA channels and configure them ... | 457 | * Enable the DMA channels and configure them ... |
459 | */ | 458 | */ |
460 | sscape_write_unsafe(s->io_base, GA_DMACFG_REG, 0x50); | 459 | val = (s->chip->dma1 << 4) | DMA_8BIT; |
461 | sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT); | 460 | sscape_write_unsafe(s->io_base, GA_DMAA_REG, val); |
462 | sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); | 461 | sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); |
463 | 462 | ||
464 | /* | 463 | /* |
465 | * Take the board out of reset ... | 464 | * Take the board out of reset ... |
466 | */ | 465 | */ |
467 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80); | 466 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
467 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80); | ||
468 | 468 | ||
469 | /* | 469 | /* |
470 | * Upload the user's data (firmware?) to the SoundScape | 470 | * Upload the firmware to the SoundScape |
471 | * board through the DMA channel ... | 471 | * board through the DMA channel ... |
472 | */ | 472 | */ |
473 | while (size != 0) { | 473 | while (size != 0) { |
474 | unsigned long len; | 474 | unsigned long len; |
475 | 475 | ||
476 | /* | ||
477 | * Apparently, copying to/from userspace can sleep. | ||
478 | * We are therefore forbidden from holding any | ||
479 | * spinlocks while we copy ... | ||
480 | */ | ||
481 | spin_unlock_irqrestore(&s->lock, flags); | ||
482 | |||
483 | /* | ||
484 | * Remember that the data that we want to DMA | ||
485 | * comes from USERSPACE. We have already verified | ||
486 | * the userspace pointer ... | ||
487 | */ | ||
488 | len = min(size, dma.bytes); | 476 | len = min(size, dma.bytes); |
489 | len -= __copy_from_user(dma.area, data, len); | 477 | memcpy(dma.area, data, len); |
490 | data += len; | 478 | data += len; |
491 | size -= len; | 479 | size -= len; |
492 | 480 | ||
493 | /* | ||
494 | * Grab that spinlock again, now that we've | ||
495 | * finished copying! | ||
496 | */ | ||
497 | spin_lock_irqsave(&s->lock, flags); | ||
498 | |||
499 | snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); | 481 | snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); |
500 | sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); | 482 | sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); |
501 | if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { | 483 | if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { |
502 | /* | 484 | /* |
503 | * Don't forget to release this spinlock we're holding ... | 485 | * Don't forget to release this spinlock we're holding |
504 | */ | 486 | */ |
505 | spin_unlock_irqrestore(&s->lock, flags); | 487 | spin_unlock_irqrestore(&s->lock, flags); |
506 | 488 | ||
507 | snd_printk(KERN_ERR "sscape: DMA upload has timed out\n"); | 489 | snd_printk(KERN_ERR |
490 | "sscape: DMA upload has timed out\n"); | ||
508 | ret = -EAGAIN; | 491 | ret = -EAGAIN; |
509 | goto _release_dma; | 492 | goto _release_dma; |
510 | } | 493 | } |
511 | } /* while */ | 494 | } /* while */ |
512 | 495 | ||
513 | set_host_mode_unsafe(s->io_base); | 496 | set_host_mode_unsafe(s->io_base); |
497 | outb(0x0, s->io_base); | ||
514 | 498 | ||
515 | /* | 499 | /* |
516 | * Boot the board ... (I think) | 500 | * Boot the board ... (I think) |
517 | */ | 501 | */ |
518 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x40); | 502 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
503 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40); | ||
519 | spin_unlock_irqrestore(&s->lock, flags); | 504 | spin_unlock_irqrestore(&s->lock, flags); |
520 | 505 | ||
521 | /* | 506 | /* |
@@ -525,10 +510,12 @@ static int upload_dma_data(struct soundscape *s, | |||
525 | */ | 510 | */ |
526 | ret = 0; | 511 | ret = 0; |
527 | if (!obp_startup_ack(s, 5000)) { | 512 | if (!obp_startup_ack(s, 5000)) { |
528 | snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); | 513 | snd_printk(KERN_ERR "sscape: No response " |
514 | "from on-board processor after upload\n"); | ||
529 | ret = -EAGAIN; | 515 | ret = -EAGAIN; |
530 | } else if (!host_startup_ack(s, 5000)) { | 516 | } else if (!host_startup_ack(s, 5000)) { |
531 | snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); | 517 | snd_printk(KERN_ERR |
518 | "sscape: SoundScape failed to initialise\n"); | ||
532 | ret = -EAGAIN; | 519 | ret = -EAGAIN; |
533 | } | 520 | } |
534 | 521 | ||
@@ -536,7 +523,7 @@ _release_dma: | |||
536 | /* | 523 | /* |
537 | * NOTE!!! We are NOT holding any spinlocks at this point !!! | 524 | * NOTE!!! We are NOT holding any spinlocks at this point !!! |
538 | */ | 525 | */ |
539 | sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_ODIE ? 0x70 : 0x40)); | 526 | sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70)); |
540 | free_dmabuf(&dma); | 527 | free_dmabuf(&dma); |
541 | 528 | ||
542 | return ret; | 529 | return ret; |
@@ -546,167 +533,76 @@ _release_dma: | |||
546 | * Upload the bootblock(?) into the SoundScape. The only | 533 | * Upload the bootblock(?) into the SoundScape. The only |
547 | * purpose of this block of code seems to be to tell | 534 | * purpose of this block of code seems to be to tell |
548 | * us which version of the microcode we should be using. | 535 | * us which version of the microcode we should be using. |
549 | * | ||
550 | * NOTE: The boot-block data resides in USER-SPACE!!! | ||
551 | * However, we have already verified its memory | ||
552 | * addresses by the time we get here. | ||
553 | */ | 536 | */ |
554 | static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_bootblock __user *bb) | 537 | static int sscape_upload_bootblock(struct snd_card *card) |
555 | { | 538 | { |
539 | struct soundscape *sscape = get_card_soundscape(card); | ||
556 | unsigned long flags; | 540 | unsigned long flags; |
541 | const struct firmware *init_fw = NULL; | ||
557 | int data = 0; | 542 | int data = 0; |
558 | int ret; | 543 | int ret; |
559 | 544 | ||
560 | ret = upload_dma_data(sscape, bb->code, sizeof(bb->code)); | 545 | ret = request_firmware(&init_fw, "scope.cod", card->dev); |
561 | 546 | if (ret < 0) { | |
562 | spin_lock_irqsave(&sscape->lock, flags); | 547 | snd_printk(KERN_ERR "sscape: Error loading scope.cod"); |
563 | if (ret == 0) { | 548 | return ret; |
564 | data = host_read_ctrl_unsafe(sscape->io_base, 100); | ||
565 | } | ||
566 | set_midi_mode_unsafe(sscape->io_base); | ||
567 | spin_unlock_irqrestore(&sscape->lock, flags); | ||
568 | |||
569 | if (ret == 0) { | ||
570 | if (data < 0) { | ||
571 | snd_printk(KERN_ERR "sscape: timeout reading firmware version\n"); | ||
572 | ret = -EAGAIN; | ||
573 | } | ||
574 | else if (__copy_to_user(&bb->version, &data, sizeof(bb->version))) { | ||
575 | ret = -EFAULT; | ||
576 | } | ||
577 | } | 549 | } |
550 | ret = upload_dma_data(sscape, init_fw->data, init_fw->size); | ||
578 | 551 | ||
579 | return ret; | 552 | release_firmware(init_fw); |
580 | } | ||
581 | |||
582 | /* | ||
583 | * Upload the microcode into the SoundScape. The | ||
584 | * microcode is 64K of data, and if we try to copy | ||
585 | * it into a local variable then we will SMASH THE | ||
586 | * KERNEL'S STACK! We therefore leave it in USER | ||
587 | * SPACE, and save ourselves from copying it at all. | ||
588 | */ | ||
589 | static int sscape_upload_microcode(struct soundscape *sscape, | ||
590 | const struct sscape_microcode __user *mc) | ||
591 | { | ||
592 | unsigned long flags; | ||
593 | char __user *code; | ||
594 | int err; | ||
595 | 553 | ||
596 | /* | 554 | spin_lock_irqsave(&sscape->lock, flags); |
597 | * We are going to have to copy this data into a special | 555 | if (ret == 0) |
598 | * DMA-able buffer before we can upload it. We shall therefore | 556 | data = host_read_ctrl_unsafe(sscape->io_base, 100); |
599 | * just check that the data pointer is valid for now. | ||
600 | * | ||
601 | * NOTE: This buffer is 64K long! That's WAY too big to | ||
602 | * copy into a stack-temporary anyway. | ||
603 | */ | ||
604 | if ( get_user(code, &mc->code) || | ||
605 | !access_ok(VERIFY_READ, code, SSCAPE_MICROCODE_SIZE) ) | ||
606 | return -EFAULT; | ||
607 | 557 | ||
608 | if ((err = upload_dma_data(sscape, code, SSCAPE_MICROCODE_SIZE)) == 0) { | 558 | if (data & 0x10) |
609 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded\n"); | 559 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f); |
610 | } | ||
611 | 560 | ||
612 | spin_lock_irqsave(&sscape->lock, flags); | ||
613 | set_midi_mode_unsafe(sscape->io_base); | ||
614 | spin_unlock_irqrestore(&sscape->lock, flags); | 561 | spin_unlock_irqrestore(&sscape->lock, flags); |
615 | 562 | ||
616 | initialise_mpu401(sscape->mpu); | 563 | data &= 0xf; |
564 | if (ret == 0 && data > 7) { | ||
565 | snd_printk(KERN_ERR | ||
566 | "sscape: timeout reading firmware version\n"); | ||
567 | ret = -EAGAIN; | ||
568 | } | ||
617 | 569 | ||
618 | return err; | 570 | return (ret == 0) ? data : ret; |
619 | } | 571 | } |
620 | 572 | ||
621 | /* | 573 | /* |
622 | * Hardware-specific device functions, to implement special | 574 | * Upload the microcode into the SoundScape. |
623 | * IOCTLs for the SoundScape card. This is how we upload | ||
624 | * the microcode into the card, for example, and so we | ||
625 | * must ensure that no two processes can open this device | ||
626 | * simultaneously, and that we can't open it at all if | ||
627 | * someone is using the MIDI device. | ||
628 | */ | 575 | */ |
629 | static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) | 576 | static int sscape_upload_microcode(struct snd_card *card, int version) |
630 | { | 577 | { |
631 | register struct soundscape *sscape = get_hwdep_soundscape(hw); | 578 | struct soundscape *sscape = get_card_soundscape(card); |
632 | unsigned long flags; | 579 | const struct firmware *init_fw = NULL; |
580 | char name[14]; | ||
633 | int err; | 581 | int err; |
634 | 582 | ||
635 | spin_lock_irqsave(&sscape->fwlock, flags); | 583 | snprintf(name, sizeof(name), "sndscape.co%d", version); |
636 | 584 | ||
637 | if ((sscape->midi_usage != 0) || sscape->hw_in_use) { | 585 | err = request_firmware(&init_fw, name, card->dev); |
638 | err = -EBUSY; | 586 | if (err < 0) { |
639 | } else { | 587 | snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d", |
640 | sscape->hw_in_use = 1; | 588 | version); |
641 | err = 0; | 589 | return err; |
642 | } | 590 | } |
591 | err = upload_dma_data(sscape, init_fw->data, init_fw->size); | ||
592 | if (err == 0) | ||
593 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded %d KBs\n", | ||
594 | init_fw->size >> 10); | ||
643 | 595 | ||
644 | spin_unlock_irqrestore(&sscape->fwlock, flags); | 596 | release_firmware(init_fw); |
645 | return err; | ||
646 | } | ||
647 | |||
648 | static int sscape_hw_release(struct snd_hwdep * hw, struct file *file) | ||
649 | { | ||
650 | register struct soundscape *sscape = get_hwdep_soundscape(hw); | ||
651 | unsigned long flags; | ||
652 | |||
653 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
654 | sscape->hw_in_use = 0; | ||
655 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file, | ||
660 | unsigned int cmd, unsigned long arg) | ||
661 | { | ||
662 | struct soundscape *sscape = get_hwdep_soundscape(hw); | ||
663 | int err = -EBUSY; | ||
664 | |||
665 | switch (cmd) { | ||
666 | case SND_SSCAPE_LOAD_BOOTB: | ||
667 | { | ||
668 | register struct sscape_bootblock __user *bb = (struct sscape_bootblock __user *) arg; | ||
669 | |||
670 | /* | ||
671 | * We are going to have to copy this data into a special | ||
672 | * DMA-able buffer before we can upload it. We shall therefore | ||
673 | * just check that the data pointer is valid for now ... | ||
674 | */ | ||
675 | if ( !access_ok(VERIFY_READ, bb->code, sizeof(bb->code)) ) | ||
676 | return -EFAULT; | ||
677 | |||
678 | /* | ||
679 | * Now check that we can write the firmware version number too... | ||
680 | */ | ||
681 | if ( !access_ok(VERIFY_WRITE, &bb->version, sizeof(bb->version)) ) | ||
682 | return -EFAULT; | ||
683 | |||
684 | err = sscape_upload_bootblock(sscape, bb); | ||
685 | } | ||
686 | break; | ||
687 | |||
688 | case SND_SSCAPE_LOAD_MCODE: | ||
689 | { | ||
690 | register const struct sscape_microcode __user *mc = (const struct sscape_microcode __user *) arg; | ||
691 | |||
692 | err = sscape_upload_microcode(sscape, mc); | ||
693 | } | ||
694 | break; | ||
695 | |||
696 | default: | ||
697 | err = -EINVAL; | ||
698 | break; | ||
699 | } /* switch */ | ||
700 | 597 | ||
701 | return err; | 598 | return err; |
702 | } | 599 | } |
703 | 600 | ||
704 | |||
705 | /* | 601 | /* |
706 | * Mixer control for the SoundScape's MIDI device. | 602 | * Mixer control for the SoundScape's MIDI device. |
707 | */ | 603 | */ |
708 | static int sscape_midi_info(struct snd_kcontrol *ctl, | 604 | static int sscape_midi_info(struct snd_kcontrol *ctl, |
709 | struct snd_ctl_elem_info *uinfo) | 605 | struct snd_ctl_elem_info *uinfo) |
710 | { | 606 | { |
711 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 607 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
712 | uinfo->count = 1; | 608 | uinfo->count = 1; |
@@ -716,7 +612,7 @@ static int sscape_midi_info(struct snd_kcontrol *ctl, | |||
716 | } | 612 | } |
717 | 613 | ||
718 | static int sscape_midi_get(struct snd_kcontrol *kctl, | 614 | static int sscape_midi_get(struct snd_kcontrol *kctl, |
719 | struct snd_ctl_elem_value *uctl) | 615 | struct snd_ctl_elem_value *uctl) |
720 | { | 616 | { |
721 | struct snd_wss *chip = snd_kcontrol_chip(kctl); | 617 | struct snd_wss *chip = snd_kcontrol_chip(kctl); |
722 | struct snd_card *card = chip->card; | 618 | struct snd_card *card = chip->card; |
@@ -730,16 +626,18 @@ static int sscape_midi_get(struct snd_kcontrol *kctl, | |||
730 | } | 626 | } |
731 | 627 | ||
732 | static int sscape_midi_put(struct snd_kcontrol *kctl, | 628 | static int sscape_midi_put(struct snd_kcontrol *kctl, |
733 | struct snd_ctl_elem_value *uctl) | 629 | struct snd_ctl_elem_value *uctl) |
734 | { | 630 | { |
735 | struct snd_wss *chip = snd_kcontrol_chip(kctl); | 631 | struct snd_wss *chip = snd_kcontrol_chip(kctl); |
736 | struct snd_card *card = chip->card; | 632 | struct snd_card *card = chip->card; |
737 | register struct soundscape *s = get_card_soundscape(card); | 633 | struct soundscape *s = get_card_soundscape(card); |
738 | unsigned long flags; | 634 | unsigned long flags; |
739 | int change; | 635 | int change; |
636 | unsigned char new_val; | ||
740 | 637 | ||
741 | spin_lock_irqsave(&s->lock, flags); | 638 | spin_lock_irqsave(&s->lock, flags); |
742 | 639 | ||
640 | new_val = uctl->value.integer.value[0] & 127; | ||
743 | /* | 641 | /* |
744 | * We need to put the board into HOST mode before we | 642 | * We need to put the board into HOST mode before we |
745 | * can send any volume-changing HOST commands ... | 643 | * can send any volume-changing HOST commands ... |
@@ -752,15 +650,16 @@ static int sscape_midi_put(struct snd_kcontrol *kctl, | |||
752 | * and then perform another volume-related command. Perhaps the | 650 | * and then perform another volume-related command. Perhaps the |
753 | * first command is an "open" and the second command is a "close"? | 651 | * first command is an "open" and the second command is a "close"? |
754 | */ | 652 | */ |
755 | if (s->midi_vol == ((unsigned char) uctl->value.integer. value[0] & 127)) { | 653 | if (s->midi_vol == new_val) { |
756 | change = 0; | 654 | change = 0; |
757 | goto __skip_change; | 655 | goto __skip_change; |
758 | } | 656 | } |
759 | change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) | 657 | change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) |
760 | && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100) | 658 | && host_write_ctrl_unsafe(s->io_base, new_val, 100) |
761 | && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)); | 659 | && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100) |
762 | s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127; | 660 | && host_write_ctrl_unsafe(s->io_base, new_val, 100); |
763 | __skip_change: | 661 | s->midi_vol = new_val; |
662 | __skip_change: | ||
764 | 663 | ||
765 | /* | 664 | /* |
766 | * Take the board out of HOST mode and back into MIDI mode ... | 665 | * Take the board out of HOST mode and back into MIDI mode ... |
@@ -784,20 +683,25 @@ static struct snd_kcontrol_new midi_mixer_ctl = { | |||
784 | * These IRQs are encoded as bit patterns so that they can be | 683 | * These IRQs are encoded as bit patterns so that they can be |
785 | * written to the control registers. | 684 | * written to the control registers. |
786 | */ | 685 | */ |
787 | static unsigned __devinit get_irq_config(int irq) | 686 | static unsigned __devinit get_irq_config(int sscape_type, int irq) |
788 | { | 687 | { |
789 | static const int valid_irq[] = { 9, 5, 7, 10 }; | 688 | static const int valid_irq[] = { 9, 5, 7, 10 }; |
689 | static const int old_irq[] = { 9, 7, 5, 15 }; | ||
790 | unsigned cfg; | 690 | unsigned cfg; |
791 | 691 | ||
792 | for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) { | 692 | if (sscape_type == MEDIA_FX) { |
793 | if (irq == valid_irq[cfg]) | 693 | for (cfg = 0; cfg < ARRAY_SIZE(old_irq); ++cfg) |
794 | return cfg; | 694 | if (irq == old_irq[cfg]) |
795 | } /* for */ | 695 | return cfg; |
696 | } else { | ||
697 | for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) | ||
698 | if (irq == valid_irq[cfg]) | ||
699 | return cfg; | ||
700 | } | ||
796 | 701 | ||
797 | return INVALID_IRQ; | 702 | return INVALID_IRQ; |
798 | } | 703 | } |
799 | 704 | ||
800 | |||
801 | /* | 705 | /* |
802 | * Perform certain arcane port-checks to see whether there | 706 | * Perform certain arcane port-checks to see whether there |
803 | * is a SoundScape board lurking behind the given ports. | 707 | * is a SoundScape board lurking behind the given ports. |
@@ -842,11 +746,38 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
842 | if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) | 746 | if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) |
843 | goto _done; | 747 | goto _done; |
844 | 748 | ||
845 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; | 749 | if (s->ic_type == IC_OPUS) |
846 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | 750 | activate_ad1845_unsafe(s->io_base); |
847 | 751 | ||
848 | if (s->type == SSCAPE_VIVO) | 752 | if (s->type == SSCAPE_VIVO) |
849 | wss_io += 4; | 753 | wss_io += 4; |
754 | |||
755 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); | ||
756 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | ||
757 | |||
758 | /* wait for WSS codec */ | ||
759 | for (d = 0; d < 500; d++) { | ||
760 | if ((inb(wss_io) & 0x80) == 0) | ||
761 | break; | ||
762 | spin_unlock_irqrestore(&s->lock, flags); | ||
763 | msleep(1); | ||
764 | spin_lock_irqsave(&s->lock, flags); | ||
765 | } | ||
766 | |||
767 | if ((inb(wss_io) & 0x80) != 0) | ||
768 | goto _done; | ||
769 | |||
770 | if (inb(wss_io + 2) == 0xff) | ||
771 | goto _done; | ||
772 | |||
773 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; | ||
774 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d); | ||
775 | |||
776 | if ((inb(wss_io) & 0x80) != 0) | ||
777 | s->type = MEDIA_FX; | ||
778 | |||
779 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); | ||
780 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | ||
850 | /* wait for WSS codec */ | 781 | /* wait for WSS codec */ |
851 | for (d = 0; d < 500; d++) { | 782 | for (d = 0; d < 500; d++) { |
852 | if ((inb(wss_io) & 0x80) == 0) | 783 | if ((inb(wss_io) & 0x80) == 0) |
@@ -855,14 +786,13 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
855 | msleep(1); | 786 | msleep(1); |
856 | spin_lock_irqsave(&s->lock, flags); | 787 | spin_lock_irqsave(&s->lock, flags); |
857 | } | 788 | } |
858 | snd_printd(KERN_INFO "init delay = %d ms\n", d); | ||
859 | 789 | ||
860 | /* | 790 | /* |
861 | * SoundScape successfully detected! | 791 | * SoundScape successfully detected! |
862 | */ | 792 | */ |
863 | retval = 1; | 793 | retval = 1; |
864 | 794 | ||
865 | _done: | 795 | _done: |
866 | spin_unlock_irqrestore(&s->lock, flags); | 796 | spin_unlock_irqrestore(&s->lock, flags); |
867 | return retval; | 797 | return retval; |
868 | } | 798 | } |
@@ -873,63 +803,35 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
873 | * to crash the machine. Also check that someone isn't using the hardware | 803 | * to crash the machine. Also check that someone isn't using the hardware |
874 | * IOCTL device. | 804 | * IOCTL device. |
875 | */ | 805 | */ |
876 | static int mpu401_open(struct snd_mpu401 * mpu) | 806 | static int mpu401_open(struct snd_mpu401 *mpu) |
877 | { | 807 | { |
878 | int err; | ||
879 | |||
880 | if (!verify_mpu401(mpu)) { | 808 | if (!verify_mpu401(mpu)) { |
881 | snd_printk(KERN_ERR "sscape: MIDI disabled, please load firmware\n"); | 809 | snd_printk(KERN_ERR "sscape: MIDI disabled, " |
882 | err = -ENODEV; | 810 | "please load firmware\n"); |
883 | } else { | 811 | return -ENODEV; |
884 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
885 | unsigned long flags; | ||
886 | |||
887 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
888 | |||
889 | if (sscape->hw_in_use || (sscape->midi_usage == ULONG_MAX)) { | ||
890 | err = -EBUSY; | ||
891 | } else { | ||
892 | ++(sscape->midi_usage); | ||
893 | err = 0; | ||
894 | } | ||
895 | |||
896 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
897 | } | 812 | } |
898 | 813 | ||
899 | return err; | 814 | return 0; |
900 | } | ||
901 | |||
902 | static void mpu401_close(struct snd_mpu401 * mpu) | ||
903 | { | ||
904 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
905 | unsigned long flags; | ||
906 | |||
907 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
908 | --(sscape->midi_usage); | ||
909 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
910 | } | 815 | } |
911 | 816 | ||
912 | /* | 817 | /* |
913 | * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. | 818 | * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. |
914 | */ | 819 | */ |
915 | static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq) | 820 | static int __devinit create_mpu401(struct snd_card *card, int devnum, |
821 | unsigned long port, int irq) | ||
916 | { | 822 | { |
917 | struct soundscape *sscape = get_card_soundscape(card); | 823 | struct soundscape *sscape = get_card_soundscape(card); |
918 | struct snd_rawmidi *rawmidi; | 824 | struct snd_rawmidi *rawmidi; |
919 | int err; | 825 | int err; |
920 | 826 | ||
921 | if ((err = snd_mpu401_uart_new(card, devnum, | 827 | err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port, |
922 | MPU401_HW_MPU401, | 828 | MPU401_INFO_INTEGRATED, irq, IRQF_DISABLED, |
923 | port, MPU401_INFO_INTEGRATED, | 829 | &rawmidi); |
924 | irq, IRQF_DISABLED, | 830 | if (err == 0) { |
925 | &rawmidi)) == 0) { | 831 | struct snd_mpu401 *mpu = rawmidi->private_data; |
926 | struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; | ||
927 | mpu->open_input = mpu401_open; | 832 | mpu->open_input = mpu401_open; |
928 | mpu->open_output = mpu401_open; | 833 | mpu->open_output = mpu401_open; |
929 | mpu->close_input = mpu401_close; | ||
930 | mpu->close_output = mpu401_close; | ||
931 | mpu->private_data = sscape; | 834 | mpu->private_data = sscape; |
932 | sscape->mpu = mpu; | ||
933 | 835 | ||
934 | initialise_mpu401(mpu); | 836 | initialise_mpu401(mpu); |
935 | } | 837 | } |
@@ -950,32 +852,34 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, | |||
950 | register struct soundscape *sscape = get_card_soundscape(card); | 852 | register struct soundscape *sscape = get_card_soundscape(card); |
951 | struct snd_wss *chip; | 853 | struct snd_wss *chip; |
952 | int err; | 854 | int err; |
855 | int codec_type = WSS_HW_DETECT; | ||
953 | 856 | ||
954 | if (sscape->type == SSCAPE_VIVO) | 857 | switch (sscape->type) { |
955 | port += 4; | 858 | case MEDIA_FX: |
859 | case SSCAPE: | ||
860 | /* | ||
861 | * There are some freak examples of early Soundscape cards | ||
862 | * with CS4231 instead of AD1848/CS4248. Unfortunately, the | ||
863 | * CS4231 works only in CS4248 compatibility mode on | ||
864 | * these cards so force it. | ||
865 | */ | ||
866 | if (sscape->ic_type != IC_OPUS) | ||
867 | codec_type = WSS_HW_AD1848; | ||
868 | break; | ||
956 | 869 | ||
957 | if (dma1 == dma2) | 870 | case SSCAPE_VIVO: |
958 | dma2 = -1; | 871 | port += 4; |
872 | break; | ||
873 | default: | ||
874 | break; | ||
875 | } | ||
959 | 876 | ||
960 | err = snd_wss_create(card, port, -1, irq, dma1, dma2, | 877 | err = snd_wss_create(card, port, -1, irq, dma1, dma2, |
961 | WSS_HW_DETECT, WSS_HWSHARE_DMA1, &chip); | 878 | codec_type, WSS_HWSHARE_DMA1, &chip); |
962 | if (!err) { | 879 | if (!err) { |
963 | unsigned long flags; | 880 | unsigned long flags; |
964 | struct snd_pcm *pcm; | 881 | struct snd_pcm *pcm; |
965 | 882 | ||
966 | /* | ||
967 | * It turns out that the PLAYBACK_ENABLE bit is set | ||
968 | * by the lowlevel driver ... | ||
969 | * | ||
970 | #define AD1845_IFACE_CONFIG \ | ||
971 | (CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE) | ||
972 | snd_wss_mce_up(chip); | ||
973 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
974 | snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG); | ||
975 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
976 | snd_wss_mce_down(chip); | ||
977 | */ | ||
978 | |||
979 | if (sscape->type != SSCAPE_VIVO) { | 883 | if (sscape->type != SSCAPE_VIVO) { |
980 | /* | 884 | /* |
981 | * The input clock frequency on the SoundScape must | 885 | * The input clock frequency on the SoundScape must |
@@ -1022,17 +926,10 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, | |||
1022 | } | 926 | } |
1023 | } | 927 | } |
1024 | 928 | ||
1025 | strcpy(card->driver, "SoundScape"); | ||
1026 | strcpy(card->shortname, pcm->name); | ||
1027 | snprintf(card->longname, sizeof(card->longname), | ||
1028 | "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", | ||
1029 | pcm->name, chip->port, chip->irq, | ||
1030 | chip->dma1, chip->dma2); | ||
1031 | |||
1032 | sscape->chip = chip; | 929 | sscape->chip = chip; |
1033 | } | 930 | } |
1034 | 931 | ||
1035 | _error: | 932 | _error: |
1036 | return err; | 933 | return err; |
1037 | } | 934 | } |
1038 | 935 | ||
@@ -1051,21 +948,8 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1051 | struct resource *wss_res; | 948 | struct resource *wss_res; |
1052 | unsigned long flags; | 949 | unsigned long flags; |
1053 | int err; | 950 | int err; |
1054 | 951 | int val; | |
1055 | /* | 952 | const char *name; |
1056 | * Check that the user didn't pass us garbage data ... | ||
1057 | */ | ||
1058 | irq_cfg = get_irq_config(irq[dev]); | ||
1059 | if (irq_cfg == INVALID_IRQ) { | ||
1060 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); | ||
1061 | return -ENXIO; | ||
1062 | } | ||
1063 | |||
1064 | mpu_irq_cfg = get_irq_config(mpu_irq[dev]); | ||
1065 | if (mpu_irq_cfg == INVALID_IRQ) { | ||
1066 | printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); | ||
1067 | return -ENXIO; | ||
1068 | } | ||
1069 | 953 | ||
1070 | /* | 954 | /* |
1071 | * Grab IO ports that we will need to probe so that we | 955 | * Grab IO ports that we will need to probe so that we |
@@ -1098,41 +982,51 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1098 | } | 982 | } |
1099 | 983 | ||
1100 | spin_lock_init(&sscape->lock); | 984 | spin_lock_init(&sscape->lock); |
1101 | spin_lock_init(&sscape->fwlock); | ||
1102 | sscape->io_res = io_res; | 985 | sscape->io_res = io_res; |
1103 | sscape->wss_res = wss_res; | 986 | sscape->wss_res = wss_res; |
1104 | sscape->io_base = port[dev]; | 987 | sscape->io_base = port[dev]; |
1105 | 988 | ||
1106 | if (!detect_sscape(sscape, wss_port[dev])) { | 989 | if (!detect_sscape(sscape, wss_port[dev])) { |
1107 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); | 990 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", |
991 | sscape->io_base); | ||
1108 | err = -ENODEV; | 992 | err = -ENODEV; |
1109 | goto _release_dma; | 993 | goto _release_dma; |
1110 | } | 994 | } |
1111 | 995 | ||
1112 | printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", | 996 | switch (sscape->type) { |
1113 | sscape->io_base, irq[dev], dma[dev]); | 997 | case MEDIA_FX: |
998 | name = "MediaFX/SoundFX"; | ||
999 | break; | ||
1000 | case SSCAPE: | ||
1001 | name = "Soundscape"; | ||
1002 | break; | ||
1003 | case SSCAPE_PNP: | ||
1004 | name = "Soundscape PnP"; | ||
1005 | break; | ||
1006 | case SSCAPE_VIVO: | ||
1007 | name = "Soundscape VIVO"; | ||
1008 | break; | ||
1009 | default: | ||
1010 | name = "unknown Soundscape"; | ||
1011 | break; | ||
1012 | } | ||
1114 | 1013 | ||
1115 | if (sscape->type != SSCAPE_VIVO) { | 1014 | printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n", |
1116 | /* | 1015 | name, sscape->io_base, irq[dev], dma[dev]); |
1117 | * Now create the hardware-specific device so that we can | 1016 | |
1118 | * load the microcode into the on-board processor. | 1017 | /* |
1119 | * We cannot use the MPU-401 MIDI system until this firmware | 1018 | * Check that the user didn't pass us garbage data ... |
1120 | * has been loaded into the card. | 1019 | */ |
1121 | */ | 1020 | irq_cfg = get_irq_config(sscape->type, irq[dev]); |
1122 | err = snd_hwdep_new(card, "MC68EC000", 0, &(sscape->hw)); | 1021 | if (irq_cfg == INVALID_IRQ) { |
1123 | if (err < 0) { | 1022 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); |
1124 | printk(KERN_ERR "sscape: Failed to create " | 1023 | return -ENXIO; |
1125 | "firmware device\n"); | 1024 | } |
1126 | goto _release_dma; | 1025 | |
1127 | } | 1026 | mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); |
1128 | strlcpy(sscape->hw->name, "SoundScape M68K", | 1027 | if (mpu_irq_cfg == INVALID_IRQ) { |
1129 | sizeof(sscape->hw->name)); | 1028 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); |
1130 | sscape->hw->name[sizeof(sscape->hw->name) - 1] = '\0'; | 1029 | return -ENXIO; |
1131 | sscape->hw->iface = SNDRV_HWDEP_IFACE_SSCAPE; | ||
1132 | sscape->hw->ops.open = sscape_hw_open; | ||
1133 | sscape->hw->ops.release = sscape_hw_release; | ||
1134 | sscape->hw->ops.ioctl = sscape_hw_ioctl; | ||
1135 | sscape->hw->private_data = sscape; | ||
1136 | } | 1030 | } |
1137 | 1031 | ||
1138 | /* | 1032 | /* |
@@ -1141,9 +1035,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1141 | */ | 1035 | */ |
1142 | spin_lock_irqsave(&sscape->lock, flags); | 1036 | spin_lock_irqsave(&sscape->lock, flags); |
1143 | 1037 | ||
1144 | activate_ad1845_unsafe(sscape->io_base); | ||
1145 | |||
1146 | sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x00); /* disable */ | ||
1147 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); | 1038 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); |
1148 | sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); | 1039 | sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); |
1149 | 1040 | ||
@@ -1151,15 +1042,23 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1151 | * Enable and configure the DMA channels ... | 1042 | * Enable and configure the DMA channels ... |
1152 | */ | 1043 | */ |
1153 | sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); | 1044 | sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); |
1154 | dma_cfg = (sscape->ic_type == IC_ODIE ? 0x70 : 0x40); | 1045 | dma_cfg = (sscape->ic_type == IC_OPUS ? 0x40 : 0x70); |
1155 | sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); | 1046 | sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); |
1156 | sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); | 1047 | sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); |
1157 | 1048 | ||
1158 | sscape_write_unsafe(sscape->io_base, | 1049 | mpu_irq_cfg |= mpu_irq_cfg << 2; |
1159 | GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); | 1050 | val = sscape_read_unsafe(sscape->io_base, GA_HMCTL_REG) & 0xF7; |
1051 | if (joystick[dev]) | ||
1052 | val |= 8; | ||
1053 | sscape_write_unsafe(sscape->io_base, GA_HMCTL_REG, val | 0x10); | ||
1054 | sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | mpu_irq_cfg); | ||
1160 | sscape_write_unsafe(sscape->io_base, | 1055 | sscape_write_unsafe(sscape->io_base, |
1161 | GA_CDCFG_REG, 0x09 | DMA_8BIT | 1056 | GA_CDCFG_REG, 0x09 | DMA_8BIT |
1162 | | (dma[dev] << 4) | (irq_cfg << 1)); | 1057 | | (dma[dev] << 4) | (irq_cfg << 1)); |
1058 | /* | ||
1059 | * Enable the master IRQ ... | ||
1060 | */ | ||
1061 | sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x80); | ||
1163 | 1062 | ||
1164 | spin_unlock_irqrestore(&sscape->lock, flags); | 1063 | spin_unlock_irqrestore(&sscape->lock, flags); |
1165 | 1064 | ||
@@ -1170,32 +1069,56 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1170 | err = create_ad1845(card, wss_port[dev], irq[dev], | 1069 | err = create_ad1845(card, wss_port[dev], irq[dev], |
1171 | dma[dev], dma2[dev]); | 1070 | dma[dev], dma2[dev]); |
1172 | if (err < 0) { | 1071 | if (err < 0) { |
1173 | printk(KERN_ERR "sscape: No AD1845 device at 0x%lx, IRQ %d\n", | 1072 | snd_printk(KERN_ERR |
1174 | wss_port[dev], irq[dev]); | 1073 | "sscape: No AD1845 device at 0x%lx, IRQ %d\n", |
1074 | wss_port[dev], irq[dev]); | ||
1175 | goto _release_dma; | 1075 | goto _release_dma; |
1176 | } | 1076 | } |
1077 | strcpy(card->driver, "SoundScape"); | ||
1078 | strcpy(card->shortname, name); | ||
1079 | snprintf(card->longname, sizeof(card->longname), | ||
1080 | "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", | ||
1081 | name, sscape->chip->port, sscape->chip->irq, | ||
1082 | sscape->chip->dma1, sscape->chip->dma2); | ||
1083 | |||
1177 | #define MIDI_DEVNUM 0 | 1084 | #define MIDI_DEVNUM 0 |
1178 | if (sscape->type != SSCAPE_VIVO) { | 1085 | if (sscape->type != SSCAPE_VIVO) { |
1179 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]); | 1086 | err = sscape_upload_bootblock(card); |
1180 | if (err < 0) { | 1087 | if (err >= 0) |
1181 | printk(KERN_ERR "sscape: Failed to create " | 1088 | err = sscape_upload_microcode(card, err); |
1182 | "MPU-401 device at 0x%lx\n", | ||
1183 | port[dev]); | ||
1184 | goto _release_dma; | ||
1185 | } | ||
1186 | 1089 | ||
1187 | /* | 1090 | if (err == 0) { |
1188 | * Enable the master IRQ ... | 1091 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], |
1189 | */ | 1092 | mpu_irq[dev]); |
1190 | sscape_write(sscape, GA_INTENA_REG, 0x80); | 1093 | if (err < 0) { |
1094 | snd_printk(KERN_ERR "sscape: Failed to create " | ||
1095 | "MPU-401 device at 0x%lx\n", | ||
1096 | port[dev]); | ||
1097 | goto _release_dma; | ||
1098 | } | ||
1191 | 1099 | ||
1192 | /* | 1100 | /* |
1193 | * Initialize mixer | 1101 | * Initialize mixer |
1194 | */ | 1102 | */ |
1195 | sscape->midi_vol = 0; | 1103 | spin_lock_irqsave(&sscape->lock, flags); |
1196 | host_write_ctrl_unsafe(sscape->io_base, CMD_SET_MIDI_VOL, 100); | 1104 | sscape->midi_vol = 0; |
1197 | host_write_ctrl_unsafe(sscape->io_base, 0, 100); | 1105 | host_write_ctrl_unsafe(sscape->io_base, |
1198 | host_write_ctrl_unsafe(sscape->io_base, CMD_XXX_MIDI_VOL, 100); | 1106 | CMD_SET_MIDI_VOL, 100); |
1107 | host_write_ctrl_unsafe(sscape->io_base, | ||
1108 | sscape->midi_vol, 100); | ||
1109 | host_write_ctrl_unsafe(sscape->io_base, | ||
1110 | CMD_XXX_MIDI_VOL, 100); | ||
1111 | host_write_ctrl_unsafe(sscape->io_base, | ||
1112 | sscape->midi_vol, 100); | ||
1113 | host_write_ctrl_unsafe(sscape->io_base, | ||
1114 | CMD_SET_EXTMIDI, 100); | ||
1115 | host_write_ctrl_unsafe(sscape->io_base, | ||
1116 | 0, 100); | ||
1117 | host_write_ctrl_unsafe(sscape->io_base, CMD_ACK, 100); | ||
1118 | |||
1119 | set_midi_mode_unsafe(sscape->io_base); | ||
1120 | spin_unlock_irqrestore(&sscape->lock, flags); | ||
1121 | } | ||
1199 | } | 1122 | } |
1200 | 1123 | ||
1201 | /* | 1124 | /* |
@@ -1231,7 +1154,8 @@ static int __devinit snd_sscape_match(struct device *pdev, unsigned int i) | |||
1231 | mpu_irq[i] == SNDRV_AUTO_IRQ || | 1154 | mpu_irq[i] == SNDRV_AUTO_IRQ || |
1232 | dma[i] == SNDRV_AUTO_DMA) { | 1155 | dma[i] == SNDRV_AUTO_DMA) { |
1233 | printk(KERN_INFO | 1156 | printk(KERN_INFO |
1234 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); | 1157 | "sscape: insufficient parameters, " |
1158 | "need IO, IRQ, MPU-IRQ and DMA\n"); | ||
1235 | return 0; | 1159 | return 0; |
1236 | } | 1160 | } |
1237 | 1161 | ||
@@ -1253,13 +1177,15 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) | |||
1253 | sscape->type = SSCAPE; | 1177 | sscape->type = SSCAPE; |
1254 | 1178 | ||
1255 | dma[dev] &= 0x03; | 1179 | dma[dev] &= 0x03; |
1180 | snd_card_set_dev(card, pdev); | ||
1181 | |||
1256 | ret = create_sscape(dev, card); | 1182 | ret = create_sscape(dev, card); |
1257 | if (ret < 0) | 1183 | if (ret < 0) |
1258 | goto _release_card; | 1184 | goto _release_card; |
1259 | 1185 | ||
1260 | snd_card_set_dev(card, pdev); | 1186 | ret = snd_card_register(card); |
1261 | if ((ret = snd_card_register(card)) < 0) { | 1187 | if (ret < 0) { |
1262 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1188 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1263 | goto _release_card; | 1189 | goto _release_card; |
1264 | } | 1190 | } |
1265 | dev_set_drvdata(pdev, card); | 1191 | dev_set_drvdata(pdev, card); |
@@ -1311,36 +1237,20 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1311 | * Allow this function to fail *quietly* if all the ISA PnP | 1237 | * Allow this function to fail *quietly* if all the ISA PnP |
1312 | * devices were configured using module parameters instead. | 1238 | * devices were configured using module parameters instead. |
1313 | */ | 1239 | */ |
1314 | if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) | 1240 | idx = get_next_autoindex(idx); |
1241 | if (idx >= SNDRV_CARDS) | ||
1315 | return -ENOSPC; | 1242 | return -ENOSPC; |
1316 | 1243 | ||
1317 | /* | 1244 | /* |
1318 | * We have found a candidate ISA PnP card. Now we | ||
1319 | * have to check that it has the devices that we | ||
1320 | * expect it to have. | ||
1321 | * | ||
1322 | * We will NOT try and autoconfigure all of the resources | ||
1323 | * needed and then activate the card as we are assuming that | ||
1324 | * has already been done at boot-time using /proc/isapnp. | ||
1325 | * We shall simply try to give each active card the resources | ||
1326 | * that it wants. This is a sensible strategy for a modular | ||
1327 | * system where unused modules are unloaded regularly. | ||
1328 | * | ||
1329 | * This strategy is utterly useless if we compile the driver | ||
1330 | * into the kernel, of course. | ||
1331 | */ | ||
1332 | // printk(KERN_INFO "sscape: %s\n", card->name); | ||
1333 | |||
1334 | /* | ||
1335 | * Check that we still have room for another sound card ... | 1245 | * Check that we still have room for another sound card ... |
1336 | */ | 1246 | */ |
1337 | dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); | 1247 | dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); |
1338 | if (! dev) | 1248 | if (!dev) |
1339 | return -ENODEV; | 1249 | return -ENODEV; |
1340 | 1250 | ||
1341 | if (!pnp_is_active(dev)) { | 1251 | if (!pnp_is_active(dev)) { |
1342 | if (pnp_activate_dev(dev) < 0) { | 1252 | if (pnp_activate_dev(dev) < 0) { |
1343 | printk(KERN_INFO "sscape: device is inactive\n"); | 1253 | snd_printk(KERN_INFO "sscape: device is inactive\n"); |
1344 | return -EBUSY; | 1254 | return -EBUSY; |
1345 | } | 1255 | } |
1346 | } | 1256 | } |
@@ -1378,14 +1288,15 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1378 | wss_port[idx] = pnp_port_start(dev, 1); | 1288 | wss_port[idx] = pnp_port_start(dev, 1); |
1379 | dma2[idx] = pnp_dma(dev, 1); | 1289 | dma2[idx] = pnp_dma(dev, 1); |
1380 | } | 1290 | } |
1291 | snd_card_set_dev(card, &pcard->card->dev); | ||
1381 | 1292 | ||
1382 | ret = create_sscape(idx, card); | 1293 | ret = create_sscape(idx, card); |
1383 | if (ret < 0) | 1294 | if (ret < 0) |
1384 | goto _release_card; | 1295 | goto _release_card; |
1385 | 1296 | ||
1386 | snd_card_set_dev(card, &pcard->card->dev); | 1297 | ret = snd_card_register(card); |
1387 | if ((ret = snd_card_register(card)) < 0) { | 1298 | if (ret < 0) { |
1388 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1299 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1389 | goto _release_card; | 1300 | goto _release_card; |
1390 | } | 1301 | } |
1391 | 1302 | ||
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 5d2ba1b749ab..5b9d6c18bc45 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c | |||
@@ -1682,7 +1682,7 @@ static void snd_wss_resume(struct snd_wss *chip) | |||
1682 | } | 1682 | } |
1683 | #endif /* CONFIG_PM */ | 1683 | #endif /* CONFIG_PM */ |
1684 | 1684 | ||
1685 | int snd_wss_free(struct snd_wss *chip) | 1685 | static int snd_wss_free(struct snd_wss *chip) |
1686 | { | 1686 | { |
1687 | release_and_free_resource(chip->res_port); | 1687 | release_and_free_resource(chip->res_port); |
1688 | release_and_free_resource(chip->res_cport); | 1688 | release_and_free_resource(chip->res_cport); |
@@ -1705,7 +1705,6 @@ int snd_wss_free(struct snd_wss *chip) | |||
1705 | kfree(chip); | 1705 | kfree(chip); |
1706 | return 0; | 1706 | return 0; |
1707 | } | 1707 | } |
1708 | EXPORT_SYMBOL(snd_wss_free); | ||
1709 | 1708 | ||
1710 | static int snd_wss_dev_free(struct snd_device *device) | 1709 | static int snd_wss_dev_free(struct snd_device *device) |
1711 | { | 1710 | { |
@@ -2198,84 +2197,61 @@ EXPORT_SYMBOL(snd_wss_put_double); | |||
2198 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | 2197 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); |
2199 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); | 2198 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); |
2200 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); | 2199 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); |
2200 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); | ||
2201 | 2201 | ||
2202 | static struct snd_kcontrol_new snd_ad1848_controls[] = { | 2202 | static struct snd_kcontrol_new snd_wss_controls[] = { |
2203 | WSS_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, | 2203 | WSS_DOUBLE("PCM Playback Switch", 0, |
2204 | 7, 7, 1, 1), | 2204 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
2205 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, | 2205 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
2206 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, | 2206 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
2207 | db_scale_6bit), | 2207 | db_scale_6bit), |
2208 | WSS_DOUBLE("Aux Playback Switch", 0, | 2208 | WSS_DOUBLE("Aux Playback Switch", 0, |
2209 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 2209 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
2210 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, | 2210 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, |
2211 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, | 2211 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
2212 | db_scale_5bit_12db_max), | 2212 | db_scale_5bit_12db_max), |
2213 | WSS_DOUBLE("Aux Playback Switch", 1, | 2213 | WSS_DOUBLE("Aux Playback Switch", 1, |
2214 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 2214 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
2215 | WSS_DOUBLE_TLV("Aux Playback Volume", 1, | 2215 | WSS_DOUBLE_TLV("Aux Playback Volume", 1, |
2216 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, | 2216 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
2217 | db_scale_5bit_12db_max), | 2217 | db_scale_5bit_12db_max), |
2218 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, | 2218 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, |
2219 | 0, 0, 15, 0, db_scale_rec_gain), | 2219 | 0, 0, 15, 0, db_scale_rec_gain), |
2220 | { | 2220 | { |
2221 | .name = "Capture Source", | ||
2222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2221 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2222 | .name = "Capture Source", | ||
2223 | .info = snd_wss_info_mux, | 2223 | .info = snd_wss_info_mux, |
2224 | .get = snd_wss_get_mux, | 2224 | .get = snd_wss_get_mux, |
2225 | .put = snd_wss_put_mux, | 2225 | .put = snd_wss_put_mux, |
2226 | }, | 2226 | }, |
2227 | WSS_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | 2227 | WSS_DOUBLE("Mic Boost (+20dB)", 0, |
2228 | WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 1, 63, 0, | 2228 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), |
2229 | db_scale_6bit), | 2229 | WSS_SINGLE("Loopback Capture Switch", 0, |
2230 | }; | 2230 | CS4231_LOOPBACK, 0, 1, 0), |
2231 | 2231 | WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1, | |
2232 | static struct snd_kcontrol_new snd_wss_controls[] = { | 2232 | db_scale_6bit), |
2233 | WSS_DOUBLE("PCM Playback Switch", 0, | ||
2234 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | ||
2235 | WSS_DOUBLE("PCM Playback Volume", 0, | ||
2236 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | ||
2237 | WSS_DOUBLE("Line Playback Switch", 0, | 2233 | WSS_DOUBLE("Line Playback Switch", 0, |
2238 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 2234 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
2239 | WSS_DOUBLE("Line Playback Volume", 0, | 2235 | WSS_DOUBLE_TLV("Line Playback Volume", 0, |
2240 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 2236 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
2241 | WSS_DOUBLE("Aux Playback Switch", 0, | 2237 | db_scale_5bit_12db_max), |
2242 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 2238 | WSS_SINGLE("Beep Playback Switch", 0, |
2243 | WSS_DOUBLE("Aux Playback Volume", 0, | ||
2244 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | ||
2245 | WSS_DOUBLE("Aux Playback Switch", 1, | ||
2246 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | ||
2247 | WSS_DOUBLE("Aux Playback Volume", 1, | ||
2248 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | ||
2249 | WSS_SINGLE("Mono Playback Switch", 0, | ||
2250 | CS4231_MONO_CTRL, 7, 1, 1), | 2239 | CS4231_MONO_CTRL, 7, 1, 1), |
2251 | WSS_SINGLE("Mono Playback Volume", 0, | 2240 | WSS_SINGLE_TLV("Beep Playback Volume", 0, |
2252 | CS4231_MONO_CTRL, 0, 15, 1), | 2241 | CS4231_MONO_CTRL, 0, 15, 1, |
2242 | db_scale_4bit), | ||
2253 | WSS_SINGLE("Mono Output Playback Switch", 0, | 2243 | WSS_SINGLE("Mono Output Playback Switch", 0, |
2254 | CS4231_MONO_CTRL, 6, 1, 1), | 2244 | CS4231_MONO_CTRL, 6, 1, 1), |
2255 | WSS_SINGLE("Mono Output Playback Bypass", 0, | 2245 | WSS_SINGLE("Beep Bypass Playback Switch", 0, |
2256 | CS4231_MONO_CTRL, 5, 1, 0), | 2246 | CS4231_MONO_CTRL, 5, 1, 0), |
2257 | WSS_DOUBLE("Capture Volume", 0, | ||
2258 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | ||
2259 | { | ||
2260 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2261 | .name = "Capture Source", | ||
2262 | .info = snd_wss_info_mux, | ||
2263 | .get = snd_wss_get_mux, | ||
2264 | .put = snd_wss_put_mux, | ||
2265 | }, | ||
2266 | WSS_DOUBLE("Mic Boost", 0, | ||
2267 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), | ||
2268 | WSS_SINGLE("Loopback Capture Switch", 0, | ||
2269 | CS4231_LOOPBACK, 0, 1, 0), | ||
2270 | WSS_SINGLE("Loopback Capture Volume", 0, | ||
2271 | CS4231_LOOPBACK, 2, 63, 1) | ||
2272 | }; | 2247 | }; |
2273 | 2248 | ||
2274 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | 2249 | static struct snd_kcontrol_new snd_opti93x_controls[] = { |
2275 | WSS_DOUBLE("Master Playback Switch", 0, | 2250 | WSS_DOUBLE("Master Playback Switch", 0, |
2276 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | 2251 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), |
2277 | WSS_DOUBLE("Master Playback Volume", 0, | 2252 | WSS_DOUBLE_TLV("Master Playback Volume", 0, |
2278 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), | 2253 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, |
2254 | db_scale_6bit), | ||
2279 | WSS_DOUBLE("PCM Playback Switch", 0, | 2255 | WSS_DOUBLE("PCM Playback Switch", 0, |
2280 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 2256 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
2281 | WSS_DOUBLE("PCM Playback Volume", 0, | 2257 | WSS_DOUBLE("PCM Playback Volume", 0, |
@@ -2334,22 +2310,21 @@ int snd_wss_mixer(struct snd_wss *chip) | |||
2334 | if (err < 0) | 2310 | if (err < 0) |
2335 | return err; | 2311 | return err; |
2336 | } | 2312 | } |
2337 | else if (chip->hardware & WSS_HW_AD1848_MASK) | 2313 | else { |
2338 | for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++) { | 2314 | int count = ARRAY_SIZE(snd_wss_controls); |
2339 | err = snd_ctl_add(card, | 2315 | |
2340 | snd_ctl_new1(&snd_ad1848_controls[idx], | 2316 | /* Use only the first 11 entries on AD1848 */ |
2341 | chip)); | 2317 | if (chip->hardware & WSS_HW_AD1848_MASK) |
2342 | if (err < 0) | 2318 | count = 11; |
2343 | return err; | 2319 | |
2344 | } | 2320 | for (idx = 0; idx < count; idx++) { |
2345 | else | ||
2346 | for (idx = 0; idx < ARRAY_SIZE(snd_wss_controls); idx++) { | ||
2347 | err = snd_ctl_add(card, | 2321 | err = snd_ctl_add(card, |
2348 | snd_ctl_new1(&snd_wss_controls[idx], | 2322 | snd_ctl_new1(&snd_wss_controls[idx], |
2349 | chip)); | 2323 | chip)); |
2350 | if (err < 0) | 2324 | if (err < 0) |
2351 | return err; | 2325 | return err; |
2352 | } | 2326 | } |
2327 | } | ||
2353 | return 0; | 2328 | return 0; |
2354 | } | 2329 | } |
2355 | EXPORT_SYMBOL(snd_wss_mixer); | 2330 | EXPORT_SYMBOL(snd_wss_mixer); |
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 8691f4cf6191..f1d9d16b5486 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c | |||
@@ -609,7 +609,7 @@ static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, | |||
609 | /* alloc virtual 'dma' area */ | 609 | /* alloc virtual 'dma' area */ |
610 | if (runtime->dma_area) | 610 | if (runtime->dma_area) |
611 | vfree(runtime->dma_area); | 611 | vfree(runtime->dma_area); |
612 | runtime->dma_area = vmalloc(size); | 612 | runtime->dma_area = vmalloc_user(size); |
613 | if (runtime->dma_area == NULL) | 613 | if (runtime->dma_area == NULL) |
614 | return -ENOMEM; | 614 | return -ENOMEM; |
615 | runtime->dma_bytes = size; | 615 | runtime->dma_bytes = size; |
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig index bcf2a0698d54..a513651fa149 100644 --- a/sound/oss/Kconfig +++ b/sound/oss/Kconfig | |||
@@ -1,5 +1,3 @@ | |||
1 | # drivers/sound/Config.in | ||
2 | # | ||
3 | # 18 Apr 1998, Michael Elizabeth Chastain, <mailto:mec@shout.net> | 1 | # 18 Apr 1998, Michael Elizabeth Chastain, <mailto:mec@shout.net> |
4 | # More hacking for modularisation. | 2 | # More hacking for modularisation. |
5 | # | 3 | # |
@@ -287,18 +285,6 @@ config SOUND_DMAP | |||
287 | 285 | ||
288 | Say Y unless you have 16MB or more RAM or a PCI sound card. | 286 | Say Y unless you have 16MB or more RAM or a PCI sound card. |
289 | 287 | ||
290 | config SOUND_SSCAPE | ||
291 | tristate "Ensoniq SoundScape support" | ||
292 | help | ||
293 | Answer Y if you have a sound card based on the Ensoniq SoundScape | ||
294 | chipset. Such cards are being manufactured at least by Ensoniq, Spea | ||
295 | and Reveal (Reveal makes also other cards). | ||
296 | |||
297 | If you compile the driver into the kernel, you have to add | ||
298 | "sscape=<io>,<irq>,<dma>,<mpuio>,<mpuirq>" to the kernel command | ||
299 | line. | ||
300 | |||
301 | |||
302 | config SOUND_VMIDI | 288 | config SOUND_VMIDI |
303 | tristate "Loopback MIDI device support" | 289 | tristate "Loopback MIDI device support" |
304 | help | 290 | help |
diff --git a/sound/oss/Makefile b/sound/oss/Makefile index e0ae4d4d6a5c..567b8a74178a 100644 --- a/sound/oss/Makefile +++ b/sound/oss/Makefile | |||
@@ -13,7 +13,6 @@ obj-$(CONFIG_SOUND_SH_DAC_AUDIO) += sh_dac_audio.o | |||
13 | obj-$(CONFIG_SOUND_AEDSP16) += aedsp16.o | 13 | obj-$(CONFIG_SOUND_AEDSP16) += aedsp16.o |
14 | obj-$(CONFIG_SOUND_PSS) += pss.o ad1848.o mpu401.o | 14 | obj-$(CONFIG_SOUND_PSS) += pss.o ad1848.o mpu401.o |
15 | obj-$(CONFIG_SOUND_TRIX) += trix.o ad1848.o sb_lib.o uart401.o | 15 | obj-$(CONFIG_SOUND_TRIX) += trix.o ad1848.o sb_lib.o uart401.o |
16 | obj-$(CONFIG_SOUND_SSCAPE) += sscape.o ad1848.o mpu401.o | ||
17 | obj-$(CONFIG_SOUND_MSS) += ad1848.o | 16 | obj-$(CONFIG_SOUND_MSS) += ad1848.o |
18 | obj-$(CONFIG_SOUND_PAS) += pas2.o sb.o sb_lib.o uart401.o | 17 | obj-$(CONFIG_SOUND_PAS) += pas2.o sb.o sb_lib.o uart401.o |
19 | obj-$(CONFIG_SOUND_SB) += sb.o sb_lib.o uart401.o | 18 | obj-$(CONFIG_SOUND_SB) += sb.o sb_lib.o uart401.o |
diff --git a/sound/oss/audio.c b/sound/oss/audio.c index b69c05b7ea7b..7df48a25c4ee 100644 --- a/sound/oss/audio.c +++ b/sound/oss/audio.c | |||
@@ -838,7 +838,7 @@ static int dma_ioctl(int dev, unsigned int cmd, void __user *arg) | |||
838 | if ((err = audio_devs[dev]->d->prepare_for_input(dev, | 838 | if ((err = audio_devs[dev]->d->prepare_for_input(dev, |
839 | dmap_in->fragment_size, dmap_in->nbufs)) < 0) { | 839 | dmap_in->fragment_size, dmap_in->nbufs)) < 0) { |
840 | spin_unlock_irqrestore(&dmap_in->lock,flags); | 840 | spin_unlock_irqrestore(&dmap_in->lock,flags); |
841 | return -err; | 841 | return err; |
842 | } | 842 | } |
843 | dmap_in->dma_mode = DMODE_INPUT; | 843 | dmap_in->dma_mode = DMODE_INPUT; |
844 | audio_devs[dev]->enable_bits |= PCM_ENABLE_INPUT; | 844 | audio_devs[dev]->enable_bits |= PCM_ENABLE_INPUT; |
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index 793b7f478433..3f3c3f71db4b 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c | |||
@@ -219,7 +219,9 @@ static int shared_resources_initialised; | |||
219 | * Mid level stuff | 219 | * Mid level stuff |
220 | */ | 220 | */ |
221 | 221 | ||
222 | struct sound_settings dmasound = { .lock = SPIN_LOCK_UNLOCKED }; | 222 | struct sound_settings dmasound = { |
223 | .lock = __SPIN_LOCK_UNLOCKED(dmasound.lock) | ||
224 | }; | ||
223 | 225 | ||
224 | static inline void sound_silence(void) | 226 | static inline void sound_silence(void) |
225 | { | 227 | { |
diff --git a/sound/oss/dmasound/dmasound_paula.c b/sound/oss/dmasound/dmasound_paula.c index 06e9e88e4c05..bb14e4c67e89 100644 --- a/sound/oss/dmasound/dmasound_paula.c +++ b/sound/oss/dmasound/dmasound_paula.c | |||
@@ -657,7 +657,7 @@ static int AmiStateInfo(char *buffer, size_t space) | |||
657 | len += sprintf(buffer+len, "\tsound.volume_right = %d [0...64]\n", | 657 | len += sprintf(buffer+len, "\tsound.volume_right = %d [0...64]\n", |
658 | dmasound.volume_right); | 658 | dmasound.volume_right); |
659 | if (len >= space) { | 659 | if (len >= space) { |
660 | printk(KERN_ERR "dmasound_paula: overlowed state buffer alloc.\n") ; | 660 | printk(KERN_ERR "dmasound_paula: overflowed state buffer alloc.\n") ; |
661 | len = space ; | 661 | len = space ; |
662 | } | 662 | } |
663 | return len; | 663 | return len; |
diff --git a/sound/oss/hex2hex.c b/sound/oss/hex2hex.c index 5460faae98c9..041ef5c52bc2 100644 --- a/sound/oss/hex2hex.c +++ b/sound/oss/hex2hex.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #define MAX_SIZE (256*1024) | 12 | #define MAX_SIZE (256*1024) |
13 | unsigned char buf[MAX_SIZE]; | 13 | unsigned char buf[MAX_SIZE]; |
14 | 14 | ||
15 | int loadhex(FILE *inf, unsigned char *buf) | 15 | static int loadhex(FILE *inf, unsigned char *buf) |
16 | { | 16 | { |
17 | int l=0, c, i; | 17 | int l=0, c, i; |
18 | 18 | ||
diff --git a/sound/oss/midi_synth.c b/sound/oss/midi_synth.c index 9e450988ed36..3bc7104c5379 100644 --- a/sound/oss/midi_synth.c +++ b/sound/oss/midi_synth.c | |||
@@ -426,7 +426,7 @@ midi_synth_open(int dev, int mode) | |||
426 | int err; | 426 | int err; |
427 | struct midi_input_info *inc; | 427 | struct midi_input_info *inc; |
428 | 428 | ||
429 | if (orig_dev < 0 || orig_dev > num_midis || midi_devs[orig_dev] == NULL) | 429 | if (orig_dev < 0 || orig_dev >= num_midis || midi_devs[orig_dev] == NULL) |
430 | return -ENXIO; | 430 | return -ENXIO; |
431 | 431 | ||
432 | midi2synth[orig_dev] = dev; | 432 | midi2synth[orig_dev] = dev; |
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c index 734b8f9e2f78..0af9d24feb8f 100644 --- a/sound/oss/mpu401.c +++ b/sound/oss/mpu401.c | |||
@@ -770,7 +770,7 @@ static int mpu_synth_ioctl(int dev, unsigned int cmd, void __user *arg) | |||
770 | 770 | ||
771 | midi_dev = synth_devs[dev]->midi_dev; | 771 | midi_dev = synth_devs[dev]->midi_dev; |
772 | 772 | ||
773 | if (midi_dev < 0 || midi_dev > num_midis || midi_devs[midi_dev] == NULL) | 773 | if (midi_dev < 0 || midi_dev >= num_midis || midi_devs[midi_dev] == NULL) |
774 | return -ENXIO; | 774 | return -ENXIO; |
775 | 775 | ||
776 | devc = &dev_conf[midi_dev]; | 776 | devc = &dev_conf[midi_dev]; |
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/oss/sb_common.c b/sound/oss/sb_common.c index 77d0e5efda76..ce4db49291f7 100644 --- a/sound/oss/sb_common.c +++ b/sound/oss/sb_common.c | |||
@@ -157,7 +157,7 @@ static void sb_intr (sb_devc *devc) | |||
157 | break; | 157 | break; |
158 | 158 | ||
159 | default: | 159 | default: |
160 | /* printk(KERN_WARN "Sound Blaster: Unexpected interrupt\n"); */ | 160 | /* printk(KERN_WARNING "Sound Blaster: Unexpected interrupt\n"); */ |
161 | ; | 161 | ; |
162 | } | 162 | } |
163 | } | 163 | } |
@@ -177,7 +177,7 @@ static void sb_intr (sb_devc *devc) | |||
177 | break; | 177 | break; |
178 | 178 | ||
179 | default: | 179 | default: |
180 | /* printk(KERN_WARN "Sound Blaster: Unexpected interrupt\n"); */ | 180 | /* printk(KERN_WARNING "Sound Blaster: Unexpected interrupt\n"); */ |
181 | ; | 181 | ; |
182 | } | 182 | } |
183 | } | 183 | } |
diff --git a/sound/oss/sb_ess.c b/sound/oss/sb_ess.c index 180e95c87e3e..51a3d381a59e 100644 --- a/sound/oss/sb_ess.c +++ b/sound/oss/sb_ess.c | |||
@@ -782,7 +782,7 @@ printk(KERN_INFO "FKS: ess_handle_channel %s irq_mode=%d\n", channel, irq_mode); | |||
782 | break; | 782 | break; |
783 | 783 | ||
784 | default:; | 784 | default:; |
785 | /* printk(KERN_WARN "ESS: Unexpected interrupt\n"); */ | 785 | /* printk(KERN_WARNING "ESS: Unexpected interrupt\n"); */ |
786 | } | 786 | } |
787 | } | 787 | } |
788 | 788 | ||
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c index b2ed8757542a..4153752507e3 100644 --- a/sound/oss/sh_dac_audio.c +++ b/sound/oss/sh_dac_audio.c | |||
@@ -164,9 +164,6 @@ static ssize_t dac_audio_write(struct file *file, const char *buf, size_t count, | |||
164 | int free; | 164 | int free; |
165 | int nbytes; | 165 | int nbytes; |
166 | 166 | ||
167 | if (count < 0) | ||
168 | return -EINVAL; | ||
169 | |||
170 | if (!count) { | 167 | if (!count) { |
171 | dac_audio_sync(); | 168 | dac_audio_sync(); |
172 | return 0; | 169 | return 0; |
diff --git a/sound/oss/sscape.c b/sound/oss/sscape.c deleted file mode 100644 index 30c36d1f35d7..000000000000 --- a/sound/oss/sscape.c +++ /dev/null | |||
@@ -1,1480 +0,0 @@ | |||
1 | /* | ||
2 | * sound/oss/sscape.c | ||
3 | * | ||
4 | * Low level driver for Ensoniq SoundScape | ||
5 | * | ||
6 | * | ||
7 | * Copyright (C) by Hannu Savolainen 1993-1997 | ||
8 | * | ||
9 | * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL) | ||
10 | * Version 2 (June 1991). See the "COPYING" file distributed with this software | ||
11 | * for more info. | ||
12 | * | ||
13 | * | ||
14 | * Thomas Sailer : ioctl code reworked (vmalloc/vfree removed) | ||
15 | * Sergey Smitienko : ensoniq p'n'p support | ||
16 | * Christoph Hellwig : adapted to module_init/module_exit | ||
17 | * Bartlomiej Zolnierkiewicz : added __init to attach_sscape() | ||
18 | * Chris Rankin : Specify that this module owns the coprocessor | ||
19 | * Arnaldo C. de Melo : added missing restore_flags in sscape_pnp_upload_file | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | |||
25 | #include "sound_config.h" | ||
26 | #include "sound_firmware.h" | ||
27 | |||
28 | #include <linux/types.h> | ||
29 | #include <linux/errno.h> | ||
30 | #include <linux/signal.h> | ||
31 | #include <linux/fcntl.h> | ||
32 | #include <linux/ctype.h> | ||
33 | #include <linux/stddef.h> | ||
34 | #include <linux/kmod.h> | ||
35 | #include <asm/dma.h> | ||
36 | #include <asm/io.h> | ||
37 | #include <linux/wait.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/ioport.h> | ||
40 | #include <linux/delay.h> | ||
41 | #include <linux/proc_fs.h> | ||
42 | #include <linux/mm.h> | ||
43 | #include <linux/spinlock.h> | ||
44 | |||
45 | #include "coproc.h" | ||
46 | |||
47 | #include "ad1848.h" | ||
48 | #include "mpu401.h" | ||
49 | |||
50 | /* | ||
51 | * I/O ports | ||
52 | */ | ||
53 | #define MIDI_DATA 0 | ||
54 | #define MIDI_CTRL 1 | ||
55 | #define HOST_CTRL 2 | ||
56 | #define TX_READY 0x02 | ||
57 | #define RX_READY 0x01 | ||
58 | #define HOST_DATA 3 | ||
59 | #define ODIE_ADDR 4 | ||
60 | #define ODIE_DATA 5 | ||
61 | |||
62 | /* | ||
63 | * Indirect registers | ||
64 | */ | ||
65 | |||
66 | #define GA_INTSTAT_REG 0 | ||
67 | #define GA_INTENA_REG 1 | ||
68 | #define GA_DMAA_REG 2 | ||
69 | #define GA_DMAB_REG 3 | ||
70 | #define GA_INTCFG_REG 4 | ||
71 | #define GA_DMACFG_REG 5 | ||
72 | #define GA_CDCFG_REG 6 | ||
73 | #define GA_SMCFGA_REG 7 | ||
74 | #define GA_SMCFGB_REG 8 | ||
75 | #define GA_HMCTL_REG 9 | ||
76 | |||
77 | /* | ||
78 | * DMA channel identifiers (A and B) | ||
79 | */ | ||
80 | |||
81 | #define SSCAPE_DMA_A 0 | ||
82 | #define SSCAPE_DMA_B 1 | ||
83 | |||
84 | #define PORT(name) (devc->base+name) | ||
85 | |||
86 | /* | ||
87 | * Host commands recognized by the OBP microcode | ||
88 | */ | ||
89 | |||
90 | #define CMD_GEN_HOST_ACK 0x80 | ||
91 | #define CMD_GEN_MPU_ACK 0x81 | ||
92 | #define CMD_GET_BOARD_TYPE 0x82 | ||
93 | #define CMD_SET_CONTROL 0x88 /* Old firmware only */ | ||
94 | #define CMD_GET_CONTROL 0x89 /* Old firmware only */ | ||
95 | #define CTL_MASTER_VOL 0 | ||
96 | #define CTL_MIC_MODE 2 | ||
97 | #define CTL_SYNTH_VOL 4 | ||
98 | #define CTL_WAVE_VOL 7 | ||
99 | #define CMD_SET_EXTMIDI 0x8a | ||
100 | #define CMD_GET_EXTMIDI 0x8b | ||
101 | #define CMD_SET_MT32 0x8c | ||
102 | #define CMD_GET_MT32 0x8d | ||
103 | |||
104 | #define CMD_ACK 0x80 | ||
105 | |||
106 | #define IC_ODIE 1 | ||
107 | #define IC_OPUS 2 | ||
108 | |||
109 | typedef struct sscape_info | ||
110 | { | ||
111 | int base, irq, dma; | ||
112 | |||
113 | int codec, codec_irq; /* required to setup pnp cards*/ | ||
114 | int codec_type; | ||
115 | int ic_type; | ||
116 | char* raw_buf; | ||
117 | unsigned long raw_buf_phys; | ||
118 | int buffsize; /* -------------------------- */ | ||
119 | spinlock_t lock; | ||
120 | int ok; /* Properly detected */ | ||
121 | int failed; | ||
122 | int dma_allocated; | ||
123 | int codec_audiodev; | ||
124 | int opened; | ||
125 | int *osp; | ||
126 | int my_audiodev; | ||
127 | } sscape_info; | ||
128 | |||
129 | static struct sscape_info adev_info = { | ||
130 | 0 | ||
131 | }; | ||
132 | |||
133 | static struct sscape_info *devc = &adev_info; | ||
134 | static int sscape_mididev = -1; | ||
135 | |||
136 | /* Some older cards have assigned interrupt bits differently than new ones */ | ||
137 | static char valid_interrupts_old[] = { | ||
138 | 9, 7, 5, 15 | ||
139 | }; | ||
140 | |||
141 | static char valid_interrupts_new[] = { | ||
142 | 9, 5, 7, 10 | ||
143 | }; | ||
144 | |||
145 | static char *valid_interrupts = valid_interrupts_new; | ||
146 | |||
147 | /* | ||
148 | * See the bottom of the driver. This can be set by spea =0/1. | ||
149 | */ | ||
150 | |||
151 | #ifdef REVEAL_SPEA | ||
152 | static char old_hardware = 1; | ||
153 | #else | ||
154 | static char old_hardware; | ||
155 | #endif | ||
156 | |||
157 | static void sleep(unsigned howlong) | ||
158 | { | ||
159 | current->state = TASK_INTERRUPTIBLE; | ||
160 | schedule_timeout(howlong); | ||
161 | } | ||
162 | |||
163 | static unsigned char sscape_read(struct sscape_info *devc, int reg) | ||
164 | { | ||
165 | unsigned long flags; | ||
166 | unsigned char val; | ||
167 | |||
168 | spin_lock_irqsave(&devc->lock,flags); | ||
169 | outb(reg, PORT(ODIE_ADDR)); | ||
170 | val = inb(PORT(ODIE_DATA)); | ||
171 | spin_unlock_irqrestore(&devc->lock,flags); | ||
172 | return val; | ||
173 | } | ||
174 | |||
175 | static void __sscape_write(int reg, int data) | ||
176 | { | ||
177 | outb(reg, PORT(ODIE_ADDR)); | ||
178 | outb(data, PORT(ODIE_DATA)); | ||
179 | } | ||
180 | |||
181 | static void sscape_write(struct sscape_info *devc, int reg, int data) | ||
182 | { | ||
183 | unsigned long flags; | ||
184 | |||
185 | spin_lock_irqsave(&devc->lock,flags); | ||
186 | __sscape_write(reg, data); | ||
187 | spin_unlock_irqrestore(&devc->lock,flags); | ||
188 | } | ||
189 | |||
190 | static unsigned char sscape_pnp_read_codec(sscape_info* devc, unsigned char reg) | ||
191 | { | ||
192 | unsigned char res; | ||
193 | unsigned long flags; | ||
194 | |||
195 | spin_lock_irqsave(&devc->lock,flags); | ||
196 | outb( reg, devc -> codec); | ||
197 | res = inb (devc -> codec + 1); | ||
198 | spin_unlock_irqrestore(&devc->lock,flags); | ||
199 | return res; | ||
200 | |||
201 | } | ||
202 | |||
203 | static void sscape_pnp_write_codec(sscape_info* devc, unsigned char reg, unsigned char data) | ||
204 | { | ||
205 | unsigned long flags; | ||
206 | |||
207 | spin_lock_irqsave(&devc->lock,flags); | ||
208 | outb( reg, devc -> codec); | ||
209 | outb( data, devc -> codec + 1); | ||
210 | spin_unlock_irqrestore(&devc->lock,flags); | ||
211 | } | ||
212 | |||
213 | static void host_open(struct sscape_info *devc) | ||
214 | { | ||
215 | outb((0x00), PORT(HOST_CTRL)); /* Put the board to the host mode */ | ||
216 | } | ||
217 | |||
218 | static void host_close(struct sscape_info *devc) | ||
219 | { | ||
220 | outb((0x03), PORT(HOST_CTRL)); /* Put the board to the MIDI mode */ | ||
221 | } | ||
222 | |||
223 | static int host_write(struct sscape_info *devc, unsigned char *data, int count) | ||
224 | { | ||
225 | unsigned long flags; | ||
226 | int i, timeout_val; | ||
227 | |||
228 | spin_lock_irqsave(&devc->lock,flags); | ||
229 | /* | ||
230 | * Send the command and data bytes | ||
231 | */ | ||
232 | |||
233 | for (i = 0; i < count; i++) | ||
234 | { | ||
235 | for (timeout_val = 10000; timeout_val > 0; timeout_val--) | ||
236 | if (inb(PORT(HOST_CTRL)) & TX_READY) | ||
237 | break; | ||
238 | |||
239 | if (timeout_val <= 0) | ||
240 | { | ||
241 | spin_unlock_irqrestore(&devc->lock,flags); | ||
242 | return 0; | ||
243 | } | ||
244 | outb(data[i], PORT(HOST_DATA)); | ||
245 | } | ||
246 | spin_unlock_irqrestore(&devc->lock,flags); | ||
247 | return 1; | ||
248 | } | ||
249 | |||
250 | static int host_read(struct sscape_info *devc) | ||
251 | { | ||
252 | unsigned long flags; | ||
253 | int timeout_val; | ||
254 | unsigned char data; | ||
255 | |||
256 | spin_lock_irqsave(&devc->lock,flags); | ||
257 | /* | ||
258 | * Read a byte | ||
259 | */ | ||
260 | |||
261 | for (timeout_val = 10000; timeout_val > 0; timeout_val--) | ||
262 | if (inb(PORT(HOST_CTRL)) & RX_READY) | ||
263 | break; | ||
264 | |||
265 | if (timeout_val <= 0) | ||
266 | { | ||
267 | spin_unlock_irqrestore(&devc->lock,flags); | ||
268 | return -1; | ||
269 | } | ||
270 | data = inb(PORT(HOST_DATA)); | ||
271 | spin_unlock_irqrestore(&devc->lock,flags); | ||
272 | return data; | ||
273 | } | ||
274 | |||
275 | #if 0 /* unused */ | ||
276 | static int host_command1(struct sscape_info *devc, int cmd) | ||
277 | { | ||
278 | unsigned char buf[10]; | ||
279 | buf[0] = (unsigned char) (cmd & 0xff); | ||
280 | return host_write(devc, buf, 1); | ||
281 | } | ||
282 | #endif /* unused */ | ||
283 | |||
284 | |||
285 | static int host_command2(struct sscape_info *devc, int cmd, int parm1) | ||
286 | { | ||
287 | unsigned char buf[10]; | ||
288 | |||
289 | buf[0] = (unsigned char) (cmd & 0xff); | ||
290 | buf[1] = (unsigned char) (parm1 & 0xff); | ||
291 | |||
292 | return host_write(devc, buf, 2); | ||
293 | } | ||
294 | |||
295 | static int host_command3(struct sscape_info *devc, int cmd, int parm1, int parm2) | ||
296 | { | ||
297 | unsigned char buf[10]; | ||
298 | |||
299 | buf[0] = (unsigned char) (cmd & 0xff); | ||
300 | buf[1] = (unsigned char) (parm1 & 0xff); | ||
301 | buf[2] = (unsigned char) (parm2 & 0xff); | ||
302 | return host_write(devc, buf, 3); | ||
303 | } | ||
304 | |||
305 | static void set_mt32(struct sscape_info *devc, int value) | ||
306 | { | ||
307 | host_open(devc); | ||
308 | host_command2(devc, CMD_SET_MT32, value ? 1 : 0); | ||
309 | if (host_read(devc) != CMD_ACK) | ||
310 | { | ||
311 | /* printk( "SNDSCAPE: Setting MT32 mode failed\n"); */ | ||
312 | } | ||
313 | host_close(devc); | ||
314 | } | ||
315 | |||
316 | static void set_control(struct sscape_info *devc, int ctrl, int value) | ||
317 | { | ||
318 | host_open(devc); | ||
319 | host_command3(devc, CMD_SET_CONTROL, ctrl, value); | ||
320 | if (host_read(devc) != CMD_ACK) | ||
321 | { | ||
322 | /* printk( "SNDSCAPE: Setting control (%d) failed\n", ctrl); */ | ||
323 | } | ||
324 | host_close(devc); | ||
325 | } | ||
326 | |||
327 | static void do_dma(struct sscape_info *devc, int dma_chan, unsigned long buf, int blk_size, int mode) | ||
328 | { | ||
329 | unsigned char temp; | ||
330 | |||
331 | if (dma_chan != SSCAPE_DMA_A) | ||
332 | { | ||
333 | printk(KERN_WARNING "soundscape: Tried to use DMA channel != A. Why?\n"); | ||
334 | return; | ||
335 | } | ||
336 | audio_devs[devc->codec_audiodev]->flags &= ~DMA_AUTOMODE; | ||
337 | DMAbuf_start_dma(devc->codec_audiodev, buf, blk_size, mode); | ||
338 | audio_devs[devc->codec_audiodev]->flags |= DMA_AUTOMODE; | ||
339 | |||
340 | temp = devc->dma << 4; /* Setup DMA channel select bits */ | ||
341 | if (devc->dma <= 3) | ||
342 | temp |= 0x80; /* 8 bit DMA channel */ | ||
343 | |||
344 | temp |= 1; /* Trigger DMA */ | ||
345 | sscape_write(devc, GA_DMAA_REG, temp); | ||
346 | temp &= 0xfe; /* Clear DMA trigger */ | ||
347 | sscape_write(devc, GA_DMAA_REG, temp); | ||
348 | } | ||
349 | |||
350 | static int verify_mpu(struct sscape_info *devc) | ||
351 | { | ||
352 | /* | ||
353 | * The SoundScape board could be in three modes (MPU, 8250 and host). | ||
354 | * If the card is not in the MPU mode, enabling the MPU driver will | ||
355 | * cause infinite loop (the driver believes that there is always some | ||
356 | * received data in the buffer. | ||
357 | * | ||
358 | * Detect this by looking if there are more than 10 received MIDI bytes | ||
359 | * (0x00) in the buffer. | ||
360 | */ | ||
361 | |||
362 | int i; | ||
363 | |||
364 | for (i = 0; i < 10; i++) | ||
365 | { | ||
366 | if (inb(devc->base + HOST_CTRL) & 0x80) | ||
367 | return 1; | ||
368 | |||
369 | if (inb(devc->base) != 0x00) | ||
370 | return 1; | ||
371 | } | ||
372 | printk(KERN_WARNING "SoundScape: The device is not in the MPU-401 mode\n"); | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int sscape_coproc_open(void *dev_info, int sub_device) | ||
377 | { | ||
378 | if (sub_device == COPR_MIDI) | ||
379 | { | ||
380 | set_mt32(devc, 0); | ||
381 | if (!verify_mpu(devc)) | ||
382 | return -EIO; | ||
383 | } | ||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static void sscape_coproc_close(void *dev_info, int sub_device) | ||
388 | { | ||
389 | struct sscape_info *devc = dev_info; | ||
390 | unsigned long flags; | ||
391 | |||
392 | spin_lock_irqsave(&devc->lock,flags); | ||
393 | if (devc->dma_allocated) | ||
394 | { | ||
395 | __sscape_write(GA_DMAA_REG, 0x20); /* DMA channel disabled */ | ||
396 | devc->dma_allocated = 0; | ||
397 | } | ||
398 | spin_unlock_irqrestore(&devc->lock,flags); | ||
399 | return; | ||
400 | } | ||
401 | |||
402 | static void sscape_coproc_reset(void *dev_info) | ||
403 | { | ||
404 | } | ||
405 | |||
406 | static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, int size, int flag) | ||
407 | { | ||
408 | unsigned long flags; | ||
409 | unsigned char temp; | ||
410 | volatile int done, timeout_val; | ||
411 | static unsigned char codec_dma_bits; | ||
412 | |||
413 | if (flag & CPF_FIRST) | ||
414 | { | ||
415 | /* | ||
416 | * First block. Have to allocate DMA and to reset the board | ||
417 | * before continuing. | ||
418 | */ | ||
419 | |||
420 | spin_lock_irqsave(&devc->lock,flags); | ||
421 | codec_dma_bits = sscape_read(devc, GA_CDCFG_REG); | ||
422 | |||
423 | if (devc->dma_allocated == 0) | ||
424 | devc->dma_allocated = 1; | ||
425 | |||
426 | spin_unlock_irqrestore(&devc->lock,flags); | ||
427 | |||
428 | sscape_write(devc, GA_HMCTL_REG, | ||
429 | (temp = sscape_read(devc, GA_HMCTL_REG)) & 0x3f); /*Reset */ | ||
430 | |||
431 | for (timeout_val = 10000; timeout_val > 0; timeout_val--) | ||
432 | sscape_read(devc, GA_HMCTL_REG); /* Delay */ | ||
433 | |||
434 | /* Take board out of reset */ | ||
435 | sscape_write(devc, GA_HMCTL_REG, | ||
436 | (temp = sscape_read(devc, GA_HMCTL_REG)) | 0x80); | ||
437 | } | ||
438 | /* | ||
439 | * Transfer one code block using DMA | ||
440 | */ | ||
441 | if (audio_devs[devc->codec_audiodev]->dmap_out->raw_buf == NULL) | ||
442 | { | ||
443 | printk(KERN_WARNING "soundscape: DMA buffer not available\n"); | ||
444 | return 0; | ||
445 | } | ||
446 | memcpy(audio_devs[devc->codec_audiodev]->dmap_out->raw_buf, block, size); | ||
447 | |||
448 | spin_lock_irqsave(&devc->lock,flags); | ||
449 | |||
450 | /******** INTERRUPTS DISABLED NOW ********/ | ||
451 | |||
452 | do_dma(devc, SSCAPE_DMA_A, | ||
453 | audio_devs[devc->codec_audiodev]->dmap_out->raw_buf_phys, | ||
454 | size, DMA_MODE_WRITE); | ||
455 | |||
456 | /* | ||
457 | * Wait until transfer completes. | ||
458 | */ | ||
459 | |||
460 | done = 0; | ||
461 | timeout_val = 30; | ||
462 | while (!done && timeout_val-- > 0) | ||
463 | { | ||
464 | int resid; | ||
465 | |||
466 | if (HZ / 50) | ||
467 | sleep(HZ / 50); | ||
468 | clear_dma_ff(devc->dma); | ||
469 | if ((resid = get_dma_residue(devc->dma)) == 0) | ||
470 | done = 1; | ||
471 | } | ||
472 | |||
473 | spin_unlock_irqrestore(&devc->lock,flags); | ||
474 | if (!done) | ||
475 | return 0; | ||
476 | |||
477 | if (flag & CPF_LAST) | ||
478 | { | ||
479 | /* | ||
480 | * Take the board out of reset | ||
481 | */ | ||
482 | outb((0x00), PORT(HOST_CTRL)); | ||
483 | outb((0x00), PORT(MIDI_CTRL)); | ||
484 | |||
485 | temp = sscape_read(devc, GA_HMCTL_REG); | ||
486 | temp |= 0x40; | ||
487 | sscape_write(devc, GA_HMCTL_REG, temp); /* Kickstart the board */ | ||
488 | |||
489 | /* | ||
490 | * Wait until the ODB wakes up | ||
491 | */ | ||
492 | spin_lock_irqsave(&devc->lock,flags); | ||
493 | done = 0; | ||
494 | timeout_val = 5 * HZ; | ||
495 | while (!done && timeout_val-- > 0) | ||
496 | { | ||
497 | unsigned char x; | ||
498 | |||
499 | sleep(1); | ||
500 | x = inb(PORT(HOST_DATA)); | ||
501 | if (x == 0xff || x == 0xfe) /* OBP startup acknowledge */ | ||
502 | { | ||
503 | DDB(printk("Soundscape: Acknowledge = %x\n", x)); | ||
504 | done = 1; | ||
505 | } | ||
506 | } | ||
507 | sscape_write(devc, GA_CDCFG_REG, codec_dma_bits); | ||
508 | |||
509 | spin_unlock_irqrestore(&devc->lock,flags); | ||
510 | if (!done) | ||
511 | { | ||
512 | printk(KERN_ERR "soundscape: The OBP didn't respond after code download\n"); | ||
513 | return 0; | ||
514 | } | ||
515 | spin_lock_irqsave(&devc->lock,flags); | ||
516 | done = 0; | ||
517 | timeout_val = 5 * HZ; | ||
518 | while (!done && timeout_val-- > 0) | ||
519 | { | ||
520 | sleep(1); | ||
521 | if (inb(PORT(HOST_DATA)) == 0xfe) /* Host startup acknowledge */ | ||
522 | done = 1; | ||
523 | } | ||
524 | spin_unlock_irqrestore(&devc->lock,flags); | ||
525 | if (!done) | ||
526 | { | ||
527 | printk(KERN_ERR "soundscape: OBP Initialization failed.\n"); | ||
528 | return 0; | ||
529 | } | ||
530 | printk(KERN_INFO "SoundScape board initialized OK\n"); | ||
531 | set_control(devc, CTL_MASTER_VOL, 100); | ||
532 | set_control(devc, CTL_SYNTH_VOL, 100); | ||
533 | |||
534 | #ifdef SSCAPE_DEBUG3 | ||
535 | /* | ||
536 | * Temporary debugging aid. Print contents of the registers after | ||
537 | * downloading the code. | ||
538 | */ | ||
539 | { | ||
540 | int i; | ||
541 | |||
542 | for (i = 0; i < 13; i++) | ||
543 | printk("I%d = %02x (new value)\n", i, sscape_read(devc, i)); | ||
544 | } | ||
545 | #endif | ||
546 | |||
547 | } | ||
548 | return 1; | ||
549 | } | ||
550 | |||
551 | static int download_boot_block(void *dev_info, copr_buffer * buf) | ||
552 | { | ||
553 | if (buf->len <= 0 || buf->len > sizeof(buf->data)) | ||
554 | return -EINVAL; | ||
555 | |||
556 | if (!sscape_download_boot(devc, buf->data, buf->len, buf->flags)) | ||
557 | { | ||
558 | printk(KERN_ERR "soundscape: Unable to load microcode block to the OBP.\n"); | ||
559 | return -EIO; | ||
560 | } | ||
561 | return 0; | ||
562 | } | ||
563 | |||
564 | static int sscape_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg, int local) | ||
565 | { | ||
566 | copr_buffer *buf; | ||
567 | int err; | ||
568 | |||
569 | switch (cmd) | ||
570 | { | ||
571 | case SNDCTL_COPR_RESET: | ||
572 | sscape_coproc_reset(dev_info); | ||
573 | return 0; | ||
574 | |||
575 | case SNDCTL_COPR_LOAD: | ||
576 | buf = (copr_buffer *) vmalloc(sizeof(copr_buffer)); | ||
577 | if (buf == NULL) | ||
578 | return -ENOSPC; | ||
579 | if (copy_from_user(buf, arg, sizeof(copr_buffer))) | ||
580 | { | ||
581 | vfree(buf); | ||
582 | return -EFAULT; | ||
583 | } | ||
584 | err = download_boot_block(dev_info, buf); | ||
585 | vfree(buf); | ||
586 | return err; | ||
587 | |||
588 | default: | ||
589 | return -EINVAL; | ||
590 | } | ||
591 | } | ||
592 | |||
593 | static coproc_operations sscape_coproc_operations = | ||
594 | { | ||
595 | "SoundScape M68K", | ||
596 | THIS_MODULE, | ||
597 | sscape_coproc_open, | ||
598 | sscape_coproc_close, | ||
599 | sscape_coproc_ioctl, | ||
600 | sscape_coproc_reset, | ||
601 | &adev_info | ||
602 | }; | ||
603 | |||
604 | static struct resource *sscape_ports; | ||
605 | static int sscape_is_pnp; | ||
606 | |||
607 | static void __init attach_sscape(struct address_info *hw_config) | ||
608 | { | ||
609 | #ifndef SSCAPE_REGS | ||
610 | /* | ||
611 | * Config register values for Spea/V7 Media FX and Ensoniq S-2000. | ||
612 | * These values are card | ||
613 | * dependent. If you have another SoundScape based card, you have to | ||
614 | * find the correct values. Do the following: | ||
615 | * - Compile this driver with SSCAPE_DEBUG1 defined. | ||
616 | * - Shut down and power off your machine. | ||
617 | * - Boot with DOS so that the SSINIT.EXE program is run. | ||
618 | * - Warm boot to {Linux|SYSV|BSD} and write down the lines displayed | ||
619 | * when detecting the SoundScape. | ||
620 | * - Modify the following list to use the values printed during boot. | ||
621 | * Undefine the SSCAPE_DEBUG1 | ||
622 | */ | ||
623 | #define SSCAPE_REGS { \ | ||
624 | /* I0 */ 0x00, \ | ||
625 | /* I1 */ 0xf0, /* Note! Ignored. Set always to 0xf0 */ \ | ||
626 | /* I2 */ 0x20, /* Note! Ignored. Set always to 0x20 */ \ | ||
627 | /* I3 */ 0x20, /* Note! Ignored. Set always to 0x20 */ \ | ||
628 | /* I4 */ 0xf5, /* Ignored */ \ | ||
629 | /* I5 */ 0x10, \ | ||
630 | /* I6 */ 0x00, \ | ||
631 | /* I7 */ 0x2e, /* I7 MEM config A. Likely to vary between models */ \ | ||
632 | /* I8 */ 0x00, /* I8 MEM config B. Likely to vary between models */ \ | ||
633 | /* I9 */ 0x40 /* Ignored */ \ | ||
634 | } | ||
635 | #endif | ||
636 | |||
637 | unsigned long flags; | ||
638 | static unsigned char regs[10] = SSCAPE_REGS; | ||
639 | |||
640 | int i, irq_bits = 0xff; | ||
641 | |||
642 | if (old_hardware) | ||
643 | { | ||
644 | valid_interrupts = valid_interrupts_old; | ||
645 | conf_printf("Ensoniq SoundScape (old)", hw_config); | ||
646 | } | ||
647 | else | ||
648 | conf_printf("Ensoniq SoundScape", hw_config); | ||
649 | |||
650 | for (i = 0; i < 4; i++) | ||
651 | { | ||
652 | if (hw_config->irq == valid_interrupts[i]) | ||
653 | { | ||
654 | irq_bits = i; | ||
655 | break; | ||
656 | } | ||
657 | } | ||
658 | if (hw_config->irq > 15 || (regs[4] = irq_bits == 0xff)) | ||
659 | { | ||
660 | printk(KERN_ERR "Invalid IRQ%d\n", hw_config->irq); | ||
661 | release_region(devc->base, 2); | ||
662 | release_region(devc->base + 2, 6); | ||
663 | if (sscape_is_pnp) | ||
664 | release_region(devc->codec, 2); | ||
665 | return; | ||
666 | } | ||
667 | |||
668 | if (!sscape_is_pnp) { | ||
669 | |||
670 | spin_lock_irqsave(&devc->lock,flags); | ||
671 | /* Host interrupt enable */ | ||
672 | sscape_write(devc, 1, 0xf0); /* All interrupts enabled */ | ||
673 | /* DMA A status/trigger register */ | ||
674 | sscape_write(devc, 2, 0x20); /* DMA channel disabled */ | ||
675 | /* DMA B status/trigger register */ | ||
676 | sscape_write(devc, 3, 0x20); /* DMA channel disabled */ | ||
677 | /* Host interrupt config reg */ | ||
678 | sscape_write(devc, 4, 0xf0 | (irq_bits << 2) | irq_bits); | ||
679 | /* Don't destroy CD-ROM DMA config bits (0xc0) */ | ||
680 | sscape_write(devc, 5, (regs[5] & 0x3f) | (sscape_read(devc, 5) & 0xc0)); | ||
681 | /* CD-ROM config (WSS codec actually) */ | ||
682 | sscape_write(devc, 6, regs[6]); | ||
683 | sscape_write(devc, 7, regs[7]); | ||
684 | sscape_write(devc, 8, regs[8]); | ||
685 | /* Master control reg. Don't modify CR-ROM bits. Disable SB emul */ | ||
686 | sscape_write(devc, 9, (sscape_read(devc, 9) & 0xf0) | 0x08); | ||
687 | spin_unlock_irqrestore(&devc->lock,flags); | ||
688 | } | ||
689 | #ifdef SSCAPE_DEBUG2 | ||
690 | /* | ||
691 | * Temporary debugging aid. Print contents of the registers after | ||
692 | * changing them. | ||
693 | */ | ||
694 | { | ||
695 | int i; | ||
696 | |||
697 | for (i = 0; i < 13; i++) | ||
698 | printk("I%d = %02x (new value)\n", i, sscape_read(devc, i)); | ||
699 | } | ||
700 | #endif | ||
701 | |||
702 | if (probe_mpu401(hw_config, sscape_ports)) | ||
703 | hw_config->always_detect = 1; | ||
704 | hw_config->name = "SoundScape"; | ||
705 | |||
706 | hw_config->irq *= -1; /* Negative value signals IRQ sharing */ | ||
707 | attach_mpu401(hw_config, THIS_MODULE); | ||
708 | hw_config->irq *= -1; /* Restore it */ | ||
709 | |||
710 | if (hw_config->slots[1] != -1) /* The MPU driver installed itself */ | ||
711 | { | ||
712 | sscape_mididev = hw_config->slots[1]; | ||
713 | midi_devs[hw_config->slots[1]]->coproc = &sscape_coproc_operations; | ||
714 | } | ||
715 | sscape_write(devc, GA_INTENA_REG, 0x80); /* Master IRQ enable */ | ||
716 | devc->ok = 1; | ||
717 | devc->failed = 0; | ||
718 | } | ||
719 | |||
720 | static int detect_ga(sscape_info * devc) | ||
721 | { | ||
722 | unsigned char save; | ||
723 | |||
724 | DDB(printk("Entered Soundscape detect_ga(%x)\n", devc->base)); | ||
725 | |||
726 | /* | ||
727 | * First check that the address register of "ODIE" is | ||
728 | * there and that it has exactly 4 writable bits. | ||
729 | * First 4 bits | ||
730 | */ | ||
731 | |||
732 | if ((save = inb(PORT(ODIE_ADDR))) & 0xf0) | ||
733 | { | ||
734 | DDB(printk("soundscape: Detect error A\n")); | ||
735 | return 0; | ||
736 | } | ||
737 | outb((0x00), PORT(ODIE_ADDR)); | ||
738 | if (inb(PORT(ODIE_ADDR)) != 0x00) | ||
739 | { | ||
740 | DDB(printk("soundscape: Detect error B\n")); | ||
741 | return 0; | ||
742 | } | ||
743 | outb((0xff), PORT(ODIE_ADDR)); | ||
744 | if (inb(PORT(ODIE_ADDR)) != 0x0f) | ||
745 | { | ||
746 | DDB(printk("soundscape: Detect error C\n")); | ||
747 | return 0; | ||
748 | } | ||
749 | outb((save), PORT(ODIE_ADDR)); | ||
750 | |||
751 | /* | ||
752 | * Now verify that some indirect registers return zero on some bits. | ||
753 | * This may break the driver with some future revisions of "ODIE" but... | ||
754 | */ | ||
755 | |||
756 | if (sscape_read(devc, 0) & 0x0c) | ||
757 | { | ||
758 | DDB(printk("soundscape: Detect error D (%x)\n", sscape_read(devc, 0))); | ||
759 | return 0; | ||
760 | } | ||
761 | if (sscape_read(devc, 1) & 0x0f) | ||
762 | { | ||
763 | DDB(printk("soundscape: Detect error E\n")); | ||
764 | return 0; | ||
765 | } | ||
766 | if (sscape_read(devc, 5) & 0x0f) | ||
767 | { | ||
768 | DDB(printk("soundscape: Detect error F\n")); | ||
769 | return 0; | ||
770 | } | ||
771 | return 1; | ||
772 | } | ||
773 | |||
774 | static int sscape_read_host_ctrl(sscape_info* devc) | ||
775 | { | ||
776 | return host_read(devc); | ||
777 | } | ||
778 | |||
779 | static void sscape_write_host_ctrl2(sscape_info *devc, int a, int b) | ||
780 | { | ||
781 | host_command2(devc, a, b); | ||
782 | } | ||
783 | |||
784 | static int sscape_alloc_dma(sscape_info *devc) | ||
785 | { | ||
786 | char *start_addr, *end_addr; | ||
787 | int dma_pagesize; | ||
788 | int sz, size; | ||
789 | struct page *page; | ||
790 | |||
791 | if (devc->raw_buf != NULL) return 0; /* Already done */ | ||
792 | dma_pagesize = (devc->dma < 4) ? (64 * 1024) : (128 * 1024); | ||
793 | devc->raw_buf = NULL; | ||
794 | devc->buffsize = 8192*4; | ||
795 | if (devc->buffsize > dma_pagesize) devc->buffsize = dma_pagesize; | ||
796 | start_addr = NULL; | ||
797 | /* | ||
798 | * Now loop until we get a free buffer. Try to get smaller buffer if | ||
799 | * it fails. Don't accept smaller than 8k buffer for performance | ||
800 | * reasons. | ||
801 | */ | ||
802 | while (start_addr == NULL && devc->buffsize > PAGE_SIZE) { | ||
803 | for (sz = 0, size = PAGE_SIZE; size < devc->buffsize; sz++, size <<= 1); | ||
804 | devc->buffsize = PAGE_SIZE * (1 << sz); | ||
805 | start_addr = (char *) __get_free_pages(GFP_ATOMIC|GFP_DMA, sz); | ||
806 | if (start_addr == NULL) devc->buffsize /= 2; | ||
807 | } | ||
808 | |||
809 | if (start_addr == NULL) { | ||
810 | printk(KERN_ERR "sscape pnp init error: Couldn't allocate DMA buffer\n"); | ||
811 | return 0; | ||
812 | } else { | ||
813 | /* make some checks */ | ||
814 | end_addr = start_addr + devc->buffsize - 1; | ||
815 | /* now check if it fits into the same dma-pagesize */ | ||
816 | |||
817 | if (((long) start_addr & ~(dma_pagesize - 1)) != ((long) end_addr & ~(dma_pagesize - 1)) | ||
818 | || end_addr >= (char *) (MAX_DMA_ADDRESS)) { | ||
819 | printk(KERN_ERR "sscape pnp: Got invalid address 0x%lx for %db DMA-buffer\n", (long) start_addr, devc->buffsize); | ||
820 | return 0; | ||
821 | } | ||
822 | } | ||
823 | devc->raw_buf = start_addr; | ||
824 | devc->raw_buf_phys = virt_to_bus(start_addr); | ||
825 | |||
826 | for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++) | ||
827 | SetPageReserved(page); | ||
828 | return 1; | ||
829 | } | ||
830 | |||
831 | static void sscape_free_dma(sscape_info *devc) | ||
832 | { | ||
833 | int sz, size; | ||
834 | unsigned long start_addr, end_addr; | ||
835 | struct page *page; | ||
836 | |||
837 | if (devc->raw_buf == NULL) return; | ||
838 | for (sz = 0, size = PAGE_SIZE; size < devc->buffsize; sz++, size <<= 1); | ||
839 | start_addr = (unsigned long) devc->raw_buf; | ||
840 | end_addr = start_addr + devc->buffsize; | ||
841 | |||
842 | for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++) | ||
843 | ClearPageReserved(page); | ||
844 | |||
845 | free_pages((unsigned long) devc->raw_buf, sz); | ||
846 | devc->raw_buf = NULL; | ||
847 | } | ||
848 | |||
849 | /* Intel version !!!!!!!!! */ | ||
850 | |||
851 | static int sscape_start_dma(int chan, unsigned long physaddr, int count, int dma_mode) | ||
852 | { | ||
853 | unsigned long flags; | ||
854 | |||
855 | flags = claim_dma_lock(); | ||
856 | disable_dma(chan); | ||
857 | clear_dma_ff(chan); | ||
858 | set_dma_mode(chan, dma_mode); | ||
859 | set_dma_addr(chan, physaddr); | ||
860 | set_dma_count(chan, count); | ||
861 | enable_dma(chan); | ||
862 | release_dma_lock(flags); | ||
863 | return 0; | ||
864 | } | ||
865 | |||
866 | static void sscape_pnp_start_dma(sscape_info* devc, int arg ) | ||
867 | { | ||
868 | int reg; | ||
869 | if (arg == 0) reg = 2; | ||
870 | else reg = 3; | ||
871 | |||
872 | sscape_write(devc, reg, sscape_read( devc, reg) | 0x01); | ||
873 | sscape_write(devc, reg, sscape_read( devc, reg) & 0xFE); | ||
874 | } | ||
875 | |||
876 | static int sscape_pnp_wait_dma (sscape_info* devc, int arg ) | ||
877 | { | ||
878 | int reg; | ||
879 | unsigned long i; | ||
880 | unsigned char d; | ||
881 | |||
882 | if (arg == 0) reg = 2; | ||
883 | else reg = 3; | ||
884 | |||
885 | sleep ( 1 ); | ||
886 | i = 0; | ||
887 | do { | ||
888 | d = sscape_read(devc, reg) & 1; | ||
889 | if ( d == 1) break; | ||
890 | i++; | ||
891 | } while (i < 500000); | ||
892 | d = sscape_read(devc, reg) & 1; | ||
893 | return d; | ||
894 | } | ||
895 | |||
896 | static int sscape_pnp_alloc_dma(sscape_info* devc) | ||
897 | { | ||
898 | /* printk(KERN_INFO "sscape: requesting dma\n"); */ | ||
899 | if (request_dma(devc -> dma, "sscape")) return 0; | ||
900 | /* printk(KERN_INFO "sscape: dma channel allocated\n"); */ | ||
901 | if (!sscape_alloc_dma(devc)) { | ||
902 | free_dma(devc -> dma); | ||
903 | return 0; | ||
904 | }; | ||
905 | return 1; | ||
906 | } | ||
907 | |||
908 | static void sscape_pnp_free_dma(sscape_info* devc) | ||
909 | { | ||
910 | sscape_free_dma( devc); | ||
911 | free_dma(devc -> dma ); | ||
912 | /* printk(KERN_INFO "sscape: dma released\n"); */ | ||
913 | } | ||
914 | |||
915 | static int sscape_pnp_upload_file(sscape_info* devc, char* fn) | ||
916 | { | ||
917 | int done = 0; | ||
918 | int timeout_val; | ||
919 | char* data,*dt; | ||
920 | int len,l; | ||
921 | unsigned long flags; | ||
922 | |||
923 | sscape_write( devc, 9, sscape_read(devc, 9 ) & 0x3F ); | ||
924 | sscape_write( devc, 2, (devc -> dma << 4) | 0x80 ); | ||
925 | sscape_write( devc, 3, 0x20 ); | ||
926 | sscape_write( devc, 9, sscape_read( devc, 9 ) | 0x80 ); | ||
927 | |||
928 | len = mod_firmware_load(fn, &data); | ||
929 | if (len == 0) { | ||
930 | printk(KERN_ERR "sscape: file not found: %s\n", fn); | ||
931 | return 0; | ||
932 | } | ||
933 | dt = data; | ||
934 | spin_lock_irqsave(&devc->lock,flags); | ||
935 | while ( len > 0 ) { | ||
936 | if (len > devc -> buffsize) l = devc->buffsize; | ||
937 | else l = len; | ||
938 | len -= l; | ||
939 | memcpy(devc->raw_buf, dt, l); dt += l; | ||
940 | sscape_start_dma(devc->dma, devc->raw_buf_phys, l, 0x48); | ||
941 | sscape_pnp_start_dma ( devc, 0 ); | ||
942 | if (sscape_pnp_wait_dma ( devc, 0 ) == 0) { | ||
943 | spin_unlock_irqrestore(&devc->lock,flags); | ||
944 | return 0; | ||
945 | } | ||
946 | } | ||
947 | |||
948 | spin_unlock_irqrestore(&devc->lock,flags); | ||
949 | vfree(data); | ||
950 | |||
951 | outb(0, devc -> base + 2); | ||
952 | outb(0, devc -> base); | ||
953 | |||
954 | sscape_write ( devc, 9, sscape_read( devc, 9 ) | 0x40); | ||
955 | |||
956 | timeout_val = 5 * HZ; | ||
957 | while (!done && timeout_val-- > 0) | ||
958 | { | ||
959 | unsigned char x; | ||
960 | sleep(1); | ||
961 | x = inb( devc -> base + 3); | ||
962 | if (x == 0xff || x == 0xfe) /* OBP startup acknowledge */ | ||
963 | { | ||
964 | //printk(KERN_ERR "Soundscape: Acknowledge = %x\n", x); | ||
965 | done = 1; | ||
966 | } | ||
967 | } | ||
968 | timeout_val = 5 * HZ; | ||
969 | done = 0; | ||
970 | while (!done && timeout_val-- > 0) | ||
971 | { | ||
972 | unsigned char x; | ||
973 | sleep(1); | ||
974 | x = inb( devc -> base + 3); | ||
975 | if (x == 0xfe) /* OBP startup acknowledge */ | ||
976 | { | ||
977 | //printk(KERN_ERR "Soundscape: Acknowledge = %x\n", x); | ||
978 | done = 1; | ||
979 | } | ||
980 | } | ||
981 | |||
982 | if ( !done ) printk(KERN_ERR "soundscape: OBP Initialization failed.\n"); | ||
983 | |||
984 | sscape_write( devc, 2, devc->ic_type == IC_ODIE ? 0x70 : 0x40); | ||
985 | sscape_write( devc, 3, (devc -> dma << 4) + 0x80); | ||
986 | return 1; | ||
987 | } | ||
988 | |||
989 | static void __init sscape_pnp_init_hw(sscape_info* devc) | ||
990 | { | ||
991 | unsigned char midi_irq = 0, sb_irq = 0; | ||
992 | unsigned i; | ||
993 | static char code_file_name[23] = "/sndscape/sndscape.cox"; | ||
994 | |||
995 | int sscape_joystic_enable = 0x7f; | ||
996 | int sscape_mic_enable = 0; | ||
997 | int sscape_ext_midi = 0; | ||
998 | |||
999 | if ( !sscape_pnp_alloc_dma(devc) ) { | ||
1000 | printk(KERN_ERR "sscape: faild to allocate dma\n"); | ||
1001 | return; | ||
1002 | } | ||
1003 | |||
1004 | for (i = 0; i < 4; i++) { | ||
1005 | if ( devc -> irq == valid_interrupts[i] ) | ||
1006 | midi_irq = i; | ||
1007 | if ( devc -> codec_irq == valid_interrupts[i] ) | ||
1008 | sb_irq = i; | ||
1009 | } | ||
1010 | |||
1011 | sscape_write( devc, 5, 0x50); | ||
1012 | sscape_write( devc, 7, 0x2e); | ||
1013 | sscape_write( devc, 8, 0x00); | ||
1014 | |||
1015 | sscape_write( devc, 2, devc->ic_type == IC_ODIE ? 0x70 : 0x40); | ||
1016 | sscape_write( devc, 3, ( devc -> dma << 4) | 0x80); | ||
1017 | |||
1018 | sscape_write (devc, 4, 0xF0 | (midi_irq<<2) | midi_irq); | ||
1019 | |||
1020 | i = 0x10; //sscape_read(devc, 9) & (devc->ic_type == IC_ODIE ? 0xf0 : 0xc0); | ||
1021 | if (sscape_joystic_enable) i |= 8; | ||
1022 | |||
1023 | sscape_write (devc, 9, i); | ||
1024 | sscape_write (devc, 6, 0x80); | ||
1025 | sscape_write (devc, 1, 0x80); | ||
1026 | |||
1027 | if (devc -> codec_type == 2) { | ||
1028 | sscape_pnp_write_codec( devc, 0x0C, 0x50); | ||
1029 | sscape_pnp_write_codec( devc, 0x10, sscape_pnp_read_codec( devc, 0x10) & 0x3F); | ||
1030 | sscape_pnp_write_codec( devc, 0x11, sscape_pnp_read_codec( devc, 0x11) | 0xC0); | ||
1031 | sscape_pnp_write_codec( devc, 29, 0x20); | ||
1032 | } | ||
1033 | |||
1034 | if (sscape_pnp_upload_file(devc, "/sndscape/scope.cod") == 0 ) { | ||
1035 | printk(KERN_ERR "sscape: faild to upload file /sndscape/scope.cod\n"); | ||
1036 | sscape_pnp_free_dma(devc); | ||
1037 | return; | ||
1038 | } | ||
1039 | |||
1040 | i = sscape_read_host_ctrl( devc ); | ||
1041 | |||
1042 | if ( (i & 0x0F) > 7 ) { | ||
1043 | printk(KERN_ERR "sscape: scope.cod faild\n"); | ||
1044 | sscape_pnp_free_dma(devc); | ||
1045 | return; | ||
1046 | } | ||
1047 | if ( i & 0x10 ) sscape_write( devc, 7, 0x2F); | ||
1048 | code_file_name[21] = (char) ( i & 0x0F) + 0x30; | ||
1049 | if (sscape_pnp_upload_file( devc, code_file_name) == 0) { | ||
1050 | printk(KERN_ERR "sscape: faild to upload file %s\n", code_file_name); | ||
1051 | sscape_pnp_free_dma(devc); | ||
1052 | return; | ||
1053 | } | ||
1054 | |||
1055 | if (devc->ic_type != IC_ODIE) { | ||
1056 | sscape_pnp_write_codec( devc, 10, (sscape_pnp_read_codec(devc, 10) & 0x7f) | | ||
1057 | ( sscape_mic_enable == 0 ? 0x00 : 0x80) ); | ||
1058 | } | ||
1059 | sscape_write_host_ctrl2( devc, 0x84, 0x64 ); /* MIDI volume */ | ||
1060 | sscape_write_host_ctrl2( devc, 0x86, 0x64 ); /* MIDI volume?? */ | ||
1061 | sscape_write_host_ctrl2( devc, 0x8A, sscape_ext_midi); | ||
1062 | |||
1063 | sscape_pnp_write_codec ( devc, 6, 0x3f ); //WAV_VOL | ||
1064 | sscape_pnp_write_codec ( devc, 7, 0x3f ); //WAV_VOL | ||
1065 | sscape_pnp_write_codec ( devc, 2, 0x1F ); //WD_CDXVOLL | ||
1066 | sscape_pnp_write_codec ( devc, 3, 0x1F ); //WD_CDXVOLR | ||
1067 | |||
1068 | if (devc -> codec_type == 1) { | ||
1069 | sscape_pnp_write_codec ( devc, 4, 0x1F ); | ||
1070 | sscape_pnp_write_codec ( devc, 5, 0x1F ); | ||
1071 | sscape_write_host_ctrl2( devc, 0x88, sscape_mic_enable); | ||
1072 | } else { | ||
1073 | int t; | ||
1074 | sscape_pnp_write_codec ( devc, 0x10, 0x1F << 1); | ||
1075 | sscape_pnp_write_codec ( devc, 0x11, 0xC0 | (0x1F << 1)); | ||
1076 | |||
1077 | t = sscape_pnp_read_codec( devc, 0x00) & 0xDF; | ||
1078 | if ( (sscape_mic_enable == 0)) t |= 0; | ||
1079 | else t |= 0x20; | ||
1080 | sscape_pnp_write_codec ( devc, 0x00, t); | ||
1081 | t = sscape_pnp_read_codec( devc, 0x01) & 0xDF; | ||
1082 | if ( (sscape_mic_enable == 0) ) t |= 0; | ||
1083 | else t |= 0x20; | ||
1084 | sscape_pnp_write_codec ( devc, 0x01, t); | ||
1085 | sscape_pnp_write_codec ( devc, 0x40 | 29 , 0x20); | ||
1086 | outb(0, devc -> codec); | ||
1087 | } | ||
1088 | if (devc -> ic_type == IC_OPUS ) { | ||
1089 | int i = sscape_read( devc, 9 ); | ||
1090 | sscape_write( devc, 9, i | 3 ); | ||
1091 | sscape_write( devc, 3, 0x40); | ||
1092 | |||
1093 | if (request_region(0x228, 1, "sscape setup junk")) { | ||
1094 | outb(0, 0x228); | ||
1095 | release_region(0x228,1); | ||
1096 | } | ||
1097 | sscape_write( devc, 3, (devc -> dma << 4) | 0x80); | ||
1098 | sscape_write( devc, 9, i ); | ||
1099 | } | ||
1100 | |||
1101 | host_close ( devc ); | ||
1102 | sscape_pnp_free_dma(devc); | ||
1103 | } | ||
1104 | |||
1105 | static int __init detect_sscape_pnp(sscape_info* devc) | ||
1106 | { | ||
1107 | long i, irq_bits = 0xff; | ||
1108 | unsigned int d; | ||
1109 | |||
1110 | DDB(printk("Entered detect_sscape_pnp(%x)\n", devc->base)); | ||
1111 | |||
1112 | if (!request_region(devc->codec, 2, "sscape codec")) { | ||
1113 | printk(KERN_ERR "detect_sscape_pnp: port %x is not free\n", devc->codec); | ||
1114 | return 0; | ||
1115 | } | ||
1116 | |||
1117 | if ((inb(devc->base + 2) & 0x78) != 0) | ||
1118 | goto fail; | ||
1119 | |||
1120 | d = inb ( devc -> base + 4) & 0xF0; | ||
1121 | if (d & 0x80) | ||
1122 | goto fail; | ||
1123 | |||
1124 | if (d == 0) { | ||
1125 | devc->codec_type = 1; | ||
1126 | devc->ic_type = IC_ODIE; | ||
1127 | } else if ( (d & 0x60) != 0) { | ||
1128 | devc->codec_type = 2; | ||
1129 | devc->ic_type = IC_OPUS; | ||
1130 | } else if ( (d & 0x40) != 0) { /* WTF? */ | ||
1131 | devc->codec_type = 2; | ||
1132 | devc->ic_type = IC_ODIE; | ||
1133 | } else | ||
1134 | goto fail; | ||
1135 | |||
1136 | sscape_is_pnp = 1; | ||
1137 | |||
1138 | outb(0xFA, devc -> base+4); | ||
1139 | if ((inb( devc -> base+4) & 0x9F) != 0x0A) | ||
1140 | goto fail; | ||
1141 | outb(0xFE, devc -> base+4); | ||
1142 | if ( (inb(devc -> base+4) & 0x9F) != 0x0E) | ||
1143 | goto fail; | ||
1144 | if ( (inb(devc -> base+5) & 0x9F) != 0x0E) | ||
1145 | goto fail; | ||
1146 | |||
1147 | if (devc->codec_type == 2) { | ||
1148 | if (devc->codec != devc->base + 8) { | ||
1149 | printk("soundscape warning: incorrect codec port specified\n"); | ||
1150 | goto fail; | ||
1151 | } | ||
1152 | d = 0x10 | (sscape_read(devc, 9) & 0xCF); | ||
1153 | sscape_write(devc, 9, d); | ||
1154 | sscape_write(devc, 6, 0x80); | ||
1155 | } else { | ||
1156 | //todo: check codec is not base + 8 | ||
1157 | } | ||
1158 | |||
1159 | d = (sscape_read(devc, 9) & 0x3F) | 0xC0; | ||
1160 | sscape_write(devc, 9, d); | ||
1161 | |||
1162 | for (i = 0; i < 550000; i++) | ||
1163 | if ( !(inb(devc -> codec) & 0x80) ) break; | ||
1164 | |||
1165 | d = inb(devc -> codec); | ||
1166 | if (d & 0x80) | ||
1167 | goto fail; | ||
1168 | if ( inb(devc -> codec + 2) == 0xFF) | ||
1169 | goto fail; | ||
1170 | |||
1171 | sscape_write(devc, 9, sscape_read(devc, 9) & 0x3F ); | ||
1172 | |||
1173 | d = inb(devc -> codec) & 0x80; | ||
1174 | if ( d == 0) { | ||
1175 | printk(KERN_INFO "soundscape: hardware detected\n"); | ||
1176 | valid_interrupts = valid_interrupts_new; | ||
1177 | } else { | ||
1178 | printk(KERN_INFO "soundscape: board looks like media fx\n"); | ||
1179 | valid_interrupts = valid_interrupts_old; | ||
1180 | old_hardware = 1; | ||
1181 | } | ||
1182 | |||
1183 | sscape_write( devc, 9, 0xC0 | (sscape_read(devc, 9) & 0x3F) ); | ||
1184 | |||
1185 | for (i = 0; i < 550000; i++) | ||
1186 | if ( !(inb(devc -> codec) & 0x80)) | ||
1187 | break; | ||
1188 | |||
1189 | sscape_pnp_init_hw(devc); | ||
1190 | |||
1191 | for (i = 0; i < 4; i++) | ||
1192 | { | ||
1193 | if (devc->codec_irq == valid_interrupts[i]) { | ||
1194 | irq_bits = i; | ||
1195 | break; | ||
1196 | } | ||
1197 | } | ||
1198 | sscape_write(devc, GA_INTENA_REG, 0x00); | ||
1199 | sscape_write(devc, GA_DMACFG_REG, 0x50); | ||
1200 | sscape_write(devc, GA_DMAA_REG, 0x70); | ||
1201 | sscape_write(devc, GA_DMAB_REG, 0x20); | ||
1202 | sscape_write(devc, GA_INTCFG_REG, 0xf0); | ||
1203 | sscape_write(devc, GA_CDCFG_REG, 0x89 | (devc->dma << 4) | (irq_bits << 1)); | ||
1204 | |||
1205 | sscape_pnp_write_codec( devc, 0, sscape_pnp_read_codec( devc, 0) | 0x20); | ||
1206 | sscape_pnp_write_codec( devc, 0, sscape_pnp_read_codec( devc, 1) | 0x20); | ||
1207 | |||
1208 | return 1; | ||
1209 | fail: | ||
1210 | release_region(devc->codec, 2); | ||
1211 | return 0; | ||
1212 | } | ||
1213 | |||
1214 | static int __init probe_sscape(struct address_info *hw_config) | ||
1215 | { | ||
1216 | devc->base = hw_config->io_base; | ||
1217 | devc->irq = hw_config->irq; | ||
1218 | devc->dma = hw_config->dma; | ||
1219 | devc->osp = hw_config->osp; | ||
1220 | |||
1221 | #ifdef SSCAPE_DEBUG1 | ||
1222 | /* | ||
1223 | * Temporary debugging aid. Print contents of the registers before | ||
1224 | * changing them. | ||
1225 | */ | ||
1226 | { | ||
1227 | int i; | ||
1228 | |||
1229 | for (i = 0; i < 13; i++) | ||
1230 | printk("I%d = %02x (old value)\n", i, sscape_read(devc, i)); | ||
1231 | } | ||
1232 | #endif | ||
1233 | devc->failed = 1; | ||
1234 | |||
1235 | sscape_ports = request_region(devc->base, 2, "mpu401"); | ||
1236 | if (!sscape_ports) | ||
1237 | return 0; | ||
1238 | |||
1239 | if (!request_region(devc->base + 2, 6, "SoundScape")) { | ||
1240 | release_region(devc->base, 2); | ||
1241 | return 0; | ||
1242 | } | ||
1243 | |||
1244 | if (!detect_ga(devc)) { | ||
1245 | if (detect_sscape_pnp(devc)) | ||
1246 | return 1; | ||
1247 | release_region(devc->base, 2); | ||
1248 | release_region(devc->base + 2, 6); | ||
1249 | return 0; | ||
1250 | } | ||
1251 | |||
1252 | if (old_hardware) /* Check that it's really an old Spea/Reveal card. */ | ||
1253 | { | ||
1254 | unsigned char tmp; | ||
1255 | int cc; | ||
1256 | |||
1257 | if (!((tmp = sscape_read(devc, GA_HMCTL_REG)) & 0xc0)) | ||
1258 | { | ||
1259 | sscape_write(devc, GA_HMCTL_REG, tmp | 0x80); | ||
1260 | for (cc = 0; cc < 200000; ++cc) | ||
1261 | inb(devc->base + ODIE_ADDR); | ||
1262 | } | ||
1263 | } | ||
1264 | return 1; | ||
1265 | } | ||
1266 | |||
1267 | static int __init init_ss_ms_sound(struct address_info *hw_config) | ||
1268 | { | ||
1269 | int i, irq_bits = 0xff; | ||
1270 | int ad_flags = 0; | ||
1271 | struct resource *ports; | ||
1272 | |||
1273 | if (devc->failed) | ||
1274 | { | ||
1275 | printk(KERN_ERR "soundscape: Card not detected\n"); | ||
1276 | return 0; | ||
1277 | } | ||
1278 | if (devc->ok == 0) | ||
1279 | { | ||
1280 | printk(KERN_ERR "soundscape: Invalid initialization order.\n"); | ||
1281 | return 0; | ||
1282 | } | ||
1283 | for (i = 0; i < 4; i++) | ||
1284 | { | ||
1285 | if (hw_config->irq == valid_interrupts[i]) | ||
1286 | { | ||
1287 | irq_bits = i; | ||
1288 | break; | ||
1289 | } | ||
1290 | } | ||
1291 | if (irq_bits == 0xff) { | ||
1292 | printk(KERN_ERR "soundscape: Invalid MSS IRQ%d\n", hw_config->irq); | ||
1293 | return 0; | ||
1294 | } | ||
1295 | |||
1296 | if (old_hardware) | ||
1297 | ad_flags = 0x12345677; /* Tell that we may have a CS4248 chip (Spea-V7 Media FX) */ | ||
1298 | else if (sscape_is_pnp) | ||
1299 | ad_flags = 0x87654321; /* Tell that we have a soundscape pnp with 1845 chip */ | ||
1300 | |||
1301 | ports = request_region(hw_config->io_base, 4, "ad1848"); | ||
1302 | if (!ports) { | ||
1303 | printk(KERN_ERR "soundscape: ports busy\n"); | ||
1304 | return 0; | ||
1305 | } | ||
1306 | |||
1307 | if (!ad1848_detect(ports, &ad_flags, hw_config->osp)) { | ||
1308 | release_region(hw_config->io_base, 4); | ||
1309 | return 0; | ||
1310 | } | ||
1311 | |||
1312 | if (!sscape_is_pnp) /*pnp is already setup*/ | ||
1313 | { | ||
1314 | /* | ||
1315 | * Setup the DMA polarity. | ||
1316 | */ | ||
1317 | sscape_write(devc, GA_DMACFG_REG, 0x50); | ||
1318 | |||
1319 | /* | ||
1320 | * Take the gate-array off of the DMA channel. | ||
1321 | */ | ||
1322 | sscape_write(devc, GA_DMAB_REG, 0x20); | ||
1323 | |||
1324 | /* | ||
1325 | * Init the AD1848 (CD-ROM) config reg. | ||
1326 | */ | ||
1327 | sscape_write(devc, GA_CDCFG_REG, 0x89 | (hw_config->dma << 4) | (irq_bits << 1)); | ||
1328 | } | ||
1329 | |||
1330 | if (hw_config->irq == devc->irq) | ||
1331 | printk(KERN_WARNING "soundscape: Warning! The WSS mode can't share IRQ with MIDI\n"); | ||
1332 | |||
1333 | hw_config->slots[0] = ad1848_init( | ||
1334 | sscape_is_pnp ? "SoundScape" : "SoundScape PNP", | ||
1335 | ports, | ||
1336 | hw_config->irq, | ||
1337 | hw_config->dma, | ||
1338 | hw_config->dma, | ||
1339 | 0, | ||
1340 | devc->osp, | ||
1341 | THIS_MODULE); | ||
1342 | |||
1343 | |||
1344 | if (hw_config->slots[0] != -1) /* The AD1848 driver installed itself */ | ||
1345 | { | ||
1346 | audio_devs[hw_config->slots[0]]->coproc = &sscape_coproc_operations; | ||
1347 | devc->codec_audiodev = hw_config->slots[0]; | ||
1348 | devc->my_audiodev = hw_config->slots[0]; | ||
1349 | |||
1350 | /* Set proper routings here (what are they) */ | ||
1351 | AD1848_REROUTE(SOUND_MIXER_LINE1, SOUND_MIXER_LINE); | ||
1352 | } | ||
1353 | |||
1354 | #ifdef SSCAPE_DEBUG5 | ||
1355 | /* | ||
1356 | * Temporary debugging aid. Print contents of the registers | ||
1357 | * after the AD1848 device has been initialized. | ||
1358 | */ | ||
1359 | { | ||
1360 | int i; | ||
1361 | |||
1362 | for (i = 0; i < 13; i++) | ||
1363 | printk("I%d = %02x\n", i, sscape_read(devc, i)); | ||
1364 | } | ||
1365 | #endif | ||
1366 | return 1; | ||
1367 | } | ||
1368 | |||
1369 | static void __exit unload_sscape(struct address_info *hw_config) | ||
1370 | { | ||
1371 | release_region(devc->base + 2, 6); | ||
1372 | unload_mpu401(hw_config); | ||
1373 | if (sscape_is_pnp) | ||
1374 | release_region(devc->codec, 2); | ||
1375 | } | ||
1376 | |||
1377 | static void __exit unload_ss_ms_sound(struct address_info *hw_config) | ||
1378 | { | ||
1379 | ad1848_unload(hw_config->io_base, | ||
1380 | hw_config->irq, | ||
1381 | devc->dma, | ||
1382 | devc->dma, | ||
1383 | 0); | ||
1384 | sound_unload_audiodev(hw_config->slots[0]); | ||
1385 | } | ||
1386 | |||
1387 | static struct address_info cfg; | ||
1388 | static struct address_info cfg_mpu; | ||
1389 | |||
1390 | static int __initdata spea = -1; | ||
1391 | static int mss = 0; | ||
1392 | static int __initdata dma = -1; | ||
1393 | static int __initdata irq = -1; | ||
1394 | static int __initdata io = -1; | ||
1395 | static int __initdata mpu_irq = -1; | ||
1396 | static int __initdata mpu_io = -1; | ||
1397 | |||
1398 | module_param(dma, int, 0); | ||
1399 | module_param(irq, int, 0); | ||
1400 | module_param(io, int, 0); | ||
1401 | module_param(spea, int, 0); /* spea=0/1 set the old_hardware */ | ||
1402 | module_param(mpu_irq, int, 0); | ||
1403 | module_param(mpu_io, int, 0); | ||
1404 | module_param(mss, int, 0); | ||
1405 | |||
1406 | static int __init init_sscape(void) | ||
1407 | { | ||
1408 | printk(KERN_INFO "Soundscape driver Copyright (C) by Hannu Savolainen 1993-1996\n"); | ||
1409 | |||
1410 | cfg.irq = irq; | ||
1411 | cfg.dma = dma; | ||
1412 | cfg.io_base = io; | ||
1413 | |||
1414 | cfg_mpu.irq = mpu_irq; | ||
1415 | cfg_mpu.io_base = mpu_io; | ||
1416 | /* WEH - Try to get right dma channel */ | ||
1417 | cfg_mpu.dma = dma; | ||
1418 | |||
1419 | devc->codec = cfg.io_base; | ||
1420 | devc->codec_irq = cfg.irq; | ||
1421 | devc->codec_type = 0; | ||
1422 | devc->ic_type = 0; | ||
1423 | devc->raw_buf = NULL; | ||
1424 | spin_lock_init(&devc->lock); | ||
1425 | |||
1426 | if (cfg.dma == -1 || cfg.irq == -1 || cfg.io_base == -1) { | ||
1427 | printk(KERN_ERR "DMA, IRQ, and IO port must be specified.\n"); | ||
1428 | return -EINVAL; | ||
1429 | } | ||
1430 | |||
1431 | if (cfg_mpu.irq == -1 && cfg_mpu.io_base != -1) { | ||
1432 | printk(KERN_ERR "MPU_IRQ must be specified if MPU_IO is set.\n"); | ||
1433 | return -EINVAL; | ||
1434 | } | ||
1435 | |||
1436 | if(spea != -1) { | ||
1437 | old_hardware = spea; | ||
1438 | printk(KERN_INFO "Forcing %s hardware support.\n", | ||
1439 | spea?"new":"old"); | ||
1440 | } | ||
1441 | if (probe_sscape(&cfg_mpu) == 0) | ||
1442 | return -ENODEV; | ||
1443 | |||
1444 | attach_sscape(&cfg_mpu); | ||
1445 | |||
1446 | mss = init_ss_ms_sound(&cfg); | ||
1447 | |||
1448 | return 0; | ||
1449 | } | ||
1450 | |||
1451 | static void __exit cleanup_sscape(void) | ||
1452 | { | ||
1453 | if (mss) | ||
1454 | unload_ss_ms_sound(&cfg); | ||
1455 | unload_sscape(&cfg_mpu); | ||
1456 | } | ||
1457 | |||
1458 | module_init(init_sscape); | ||
1459 | module_exit(cleanup_sscape); | ||
1460 | |||
1461 | #ifndef MODULE | ||
1462 | static int __init setup_sscape(char *str) | ||
1463 | { | ||
1464 | /* io, irq, dma, mpu_io, mpu_irq */ | ||
1465 | int ints[6]; | ||
1466 | |||
1467 | str = get_options(str, ARRAY_SIZE(ints), ints); | ||
1468 | |||
1469 | io = ints[1]; | ||
1470 | irq = ints[2]; | ||
1471 | dma = ints[3]; | ||
1472 | mpu_io = ints[4]; | ||
1473 | mpu_irq = ints[5]; | ||
1474 | |||
1475 | return 1; | ||
1476 | } | ||
1477 | |||
1478 | __setup("sscape=", setup_sscape); | ||
1479 | #endif | ||
1480 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 75c602b5b132..351654cf7b09 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -570,6 +570,7 @@ config SND_ICE1712 | |||
570 | tristate "ICEnsemble ICE1712 (Envy24)" | 570 | tristate "ICEnsemble ICE1712 (Envy24)" |
571 | select SND_MPU401_UART | 571 | select SND_MPU401_UART |
572 | select SND_AC97_CODEC | 572 | select SND_AC97_CODEC |
573 | select BITREVERSE | ||
573 | help | 574 | help |
574 | Say Y here to include support for soundcards based on the | 575 | Say Y here to include support for soundcards based on the |
575 | ICE1712 (Envy24) chip. | 576 | ICE1712 (Envy24) chip. |
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 78288dbfc17a..c11920623009 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c | |||
@@ -603,8 +603,8 @@ AC97_SINGLE("Tone Control - Treble", AC97_MASTER_TONE, 0, 15, 1) | |||
603 | }; | 603 | }; |
604 | 604 | ||
605 | static const struct snd_kcontrol_new snd_ac97_controls_pc_beep[2] = { | 605 | static const struct snd_kcontrol_new snd_ac97_controls_pc_beep[2] = { |
606 | AC97_SINGLE("PC Speaker Playback Switch", AC97_PC_BEEP, 15, 1, 1), | 606 | AC97_SINGLE("Beep Playback Switch", AC97_PC_BEEP, 15, 1, 1), |
607 | AC97_SINGLE("PC Speaker Playback Volume", AC97_PC_BEEP, 1, 15, 1) | 607 | AC97_SINGLE("Beep Playback Volume", AC97_PC_BEEP, 1, 15, 1) |
608 | }; | 608 | }; |
609 | 609 | ||
610 | static const struct snd_kcontrol_new snd_ac97_controls_mic_boost = | 610 | static const struct snd_kcontrol_new snd_ac97_controls_mic_boost = |
@@ -1393,7 +1393,7 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) | |||
1393 | } | 1393 | } |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | /* build PC Speaker controls */ | 1396 | /* build Beep controls */ |
1397 | if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && | 1397 | if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && |
1398 | ((ac97->flags & AC97_HAS_PC_BEEP) || | 1398 | ((ac97->flags & AC97_HAS_PC_BEEP) || |
1399 | snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) { | 1399 | snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) { |
@@ -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/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 7337abdbe4e3..139cf3b2b9d7 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -800,12 +800,12 @@ AC97_SINGLE("Mono Switch", AC97_MASTER_TONE, 7, 1, 1), | |||
800 | AC97_SINGLE("Mono ZC Switch", AC97_MASTER_TONE, 6, 1, 0), | 800 | AC97_SINGLE("Mono ZC Switch", AC97_MASTER_TONE, 6, 1, 0), |
801 | AC97_SINGLE("Mono Volume", AC97_MASTER_TONE, 0, 31, 1), | 801 | AC97_SINGLE("Mono Volume", AC97_MASTER_TONE, 0, 31, 1), |
802 | 802 | ||
803 | AC97_SINGLE("PC Beep to Headphone Switch", AC97_AUX, 15, 1, 1), | 803 | AC97_SINGLE("Beep to Headphone Switch", AC97_AUX, 15, 1, 1), |
804 | AC97_SINGLE("PC Beep to Headphone Volume", AC97_AUX, 12, 7, 1), | 804 | AC97_SINGLE("Beep to Headphone Volume", AC97_AUX, 12, 7, 1), |
805 | AC97_SINGLE("PC Beep to Master Switch", AC97_AUX, 11, 1, 1), | 805 | AC97_SINGLE("Beep to Master Switch", AC97_AUX, 11, 1, 1), |
806 | AC97_SINGLE("PC Beep to Master Volume", AC97_AUX, 8, 7, 1), | 806 | AC97_SINGLE("Beep to Master Volume", AC97_AUX, 8, 7, 1), |
807 | AC97_SINGLE("PC Beep to Mono Switch", AC97_AUX, 7, 1, 1), | 807 | AC97_SINGLE("Beep to Mono Switch", AC97_AUX, 7, 1, 1), |
808 | AC97_SINGLE("PC Beep to Mono Volume", AC97_AUX, 4, 7, 1), | 808 | AC97_SINGLE("Beep to Mono Volume", AC97_AUX, 4, 7, 1), |
809 | 809 | ||
810 | AC97_SINGLE("Voice to Headphone Switch", AC97_PCM, 15, 1, 1), | 810 | AC97_SINGLE("Voice to Headphone Switch", AC97_PCM, 15, 1, 1), |
811 | AC97_SINGLE("Voice to Headphone Volume", AC97_PCM, 12, 7, 1), | 811 | AC97_SINGLE("Voice to Headphone Volume", AC97_PCM, 12, 7, 1), |
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 8451a0169f32..69867ace7860 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c | |||
@@ -830,8 +830,8 @@ static struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = { | |||
830 | AZF3328_MIXER_SWITCH("Mic Boost (+20dB)", IDX_MIXER_MIC, 6, 0), | 830 | AZF3328_MIXER_SWITCH("Mic Boost (+20dB)", IDX_MIXER_MIC, 6, 0), |
831 | AZF3328_MIXER_SWITCH("Line Playback Switch", IDX_MIXER_LINEIN, 15, 1), | 831 | AZF3328_MIXER_SWITCH("Line Playback Switch", IDX_MIXER_LINEIN, 15, 1), |
832 | AZF3328_MIXER_VOL_STEREO("Line Playback Volume", IDX_MIXER_LINEIN, 0x1f, 1), | 832 | AZF3328_MIXER_VOL_STEREO("Line Playback Volume", IDX_MIXER_LINEIN, 0x1f, 1), |
833 | AZF3328_MIXER_SWITCH("PC Speaker Playback Switch", IDX_MIXER_PCBEEP, 15, 1), | 833 | AZF3328_MIXER_SWITCH("Beep Playback Switch", IDX_MIXER_PCBEEP, 15, 1), |
834 | AZF3328_MIXER_VOL_SPECIAL("PC Speaker Playback Volume", IDX_MIXER_PCBEEP, 0x0f, 1, 1), | 834 | AZF3328_MIXER_VOL_SPECIAL("Beep Playback Volume", IDX_MIXER_PCBEEP, 0x0f, 1, 1), |
835 | AZF3328_MIXER_SWITCH("Video Playback Switch", IDX_MIXER_VIDEO, 15, 1), | 835 | AZF3328_MIXER_SWITCH("Video Playback Switch", IDX_MIXER_VIDEO, 15, 1), |
836 | AZF3328_MIXER_VOL_STEREO("Video Playback Volume", IDX_MIXER_VIDEO, 0x1f, 1), | 836 | AZF3328_MIXER_VOL_STEREO("Video Playback Volume", IDX_MIXER_VIDEO, 0x1f, 1), |
837 | AZF3328_MIXER_SWITCH("Aux Playback Switch", IDX_MIXER_AUX, 15, 1), | 837 | AZF3328_MIXER_SWITCH("Aux Playback Switch", IDX_MIXER_AUX, 15, 1), |
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index c8c6f437f5b3..8f443a9d61ec 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c | |||
@@ -792,8 +792,8 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) | |||
792 | "Phone Playback Volume", | 792 | "Phone Playback Volume", |
793 | "Video Playback Switch", | 793 | "Video Playback Switch", |
794 | "Video Playback Volume", | 794 | "Video Playback Volume", |
795 | "PC Speaker Playback Switch", | 795 | "Beep Playback Switch", |
796 | "PC Speaker Playback Volume", | 796 | "Beep Playback Volume", |
797 | "Mono Output Select", | 797 | "Mono Output Select", |
798 | "Capture Source", | 798 | "Capture Source", |
799 | "Capture Switch", | 799 | "Capture Switch", |
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c index c62b7d10ec61..0470461cc03e 100644 --- a/sound/pci/ca0106/ca0106_proc.c +++ b/sound/pci/ca0106/ca0106_proc.c | |||
@@ -233,7 +233,7 @@ static void snd_ca0106_proc_dump_iec958( struct snd_info_buffer *buffer, u32 val | |||
233 | snd_iprintf(buffer, "user-defined\n"); | 233 | snd_iprintf(buffer, "user-defined\n"); |
234 | break; | 234 | break; |
235 | default: | 235 | default: |
236 | snd_iprintf(buffer, "unkown\n"); | 236 | snd_iprintf(buffer, "unknown\n"); |
237 | break; | 237 | break; |
238 | } | 238 | } |
239 | snd_iprintf(buffer, "Sample Bits: "); | 239 | snd_iprintf(buffer, "Sample Bits: "); |
@@ -304,7 +304,7 @@ static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry, | |||
304 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 304 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
305 | if (sscanf(line, "%x %x", ®, &val) != 2) | 305 | if (sscanf(line, "%x %x", ®, &val) != 2) |
306 | continue; | 306 | continue; |
307 | if ((reg < 0x40) && (reg >=0) && (val <= 0xffffffff) ) { | 307 | if (reg < 0x40 && val <= 0xffffffff) { |
308 | spin_lock_irqsave(&emu->emu_lock, flags); | 308 | spin_lock_irqsave(&emu->emu_lock, flags); |
309 | outl(val, emu->port + (reg & 0xfffffffc)); | 309 | outl(val, emu->port + (reg & 0xfffffffc)); |
310 | spin_unlock_irqrestore(&emu->emu_lock, flags); | 310 | spin_unlock_irqrestore(&emu->emu_lock, flags); |
@@ -405,7 +405,7 @@ static void snd_ca0106_proc_reg_write(struct snd_info_entry *entry, | |||
405 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 405 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
406 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) | 406 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) |
407 | continue; | 407 | continue; |
408 | if ((reg < 0x80) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) ) | 408 | if (reg < 0x80 && val <= 0xffffffff && channel_id <= 3) |
409 | snd_ca0106_ptr_write(emu, reg, channel_id, val); | 409 | snd_ca0106_ptr_write(emu, reg, channel_id, val); |
410 | } | 410 | } |
411 | } | 411 | } |
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index ddcd4a9fd7e6..a312bae08f52 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c | |||
@@ -2302,7 +2302,7 @@ static struct snd_kcontrol_new snd_cmipci_mixers[] __devinitdata = { | |||
2302 | CMIPCI_SB_VOL_MONO("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), | 2302 | CMIPCI_SB_VOL_MONO("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), |
2303 | CMIPCI_SB_SW_MONO("Mic Playback Switch", 0), | 2303 | CMIPCI_SB_SW_MONO("Mic Playback Switch", 0), |
2304 | CMIPCI_DOUBLE("Mic Capture Switch", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0, 1, 0, 0), | 2304 | CMIPCI_DOUBLE("Mic Capture Switch", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0, 1, 0, 0), |
2305 | CMIPCI_SB_VOL_MONO("PC Speaker Playback Volume", SB_DSP4_SPEAKER_DEV, 6, 3), | 2305 | CMIPCI_SB_VOL_MONO("Beep Playback Volume", SB_DSP4_SPEAKER_DEV, 6, 3), |
2306 | CMIPCI_MIXER_VOL_STEREO("Aux Playback Volume", CM_REG_AUX_VOL, 4, 0, 15), | 2306 | CMIPCI_MIXER_VOL_STEREO("Aux Playback Volume", CM_REG_AUX_VOL, 4, 0, 15), |
2307 | CMIPCI_MIXER_SW_STEREO("Aux Playback Switch", CM_REG_MIXER2, CM_VAUXLM_SHIFT, CM_VAUXRM_SHIFT, 0), | 2307 | CMIPCI_MIXER_SW_STEREO("Aux Playback Switch", CM_REG_MIXER2, CM_VAUXLM_SHIFT, CM_VAUXRM_SHIFT, 0), |
2308 | CMIPCI_MIXER_SW_STEREO("Aux Capture Switch", CM_REG_MIXER2, CM_RAUXLEN_SHIFT, CM_RAUXREN_SHIFT, 0), | 2308 | CMIPCI_MIXER_SW_STEREO("Aux Capture Switch", CM_REG_MIXER2, CM_RAUXLEN_SHIFT, CM_RAUXREN_SHIFT, 0), |
@@ -2310,7 +2310,7 @@ static struct snd_kcontrol_new snd_cmipci_mixers[] __devinitdata = { | |||
2310 | CMIPCI_MIXER_VOL_MONO("Mic Capture Volume", CM_REG_MIXER2, CM_VADMIC_SHIFT, 7), | 2310 | CMIPCI_MIXER_VOL_MONO("Mic Capture Volume", CM_REG_MIXER2, CM_VADMIC_SHIFT, 7), |
2311 | CMIPCI_SB_VOL_MONO("Phone Playback Volume", CM_REG_EXTENT_IND, 5, 7), | 2311 | CMIPCI_SB_VOL_MONO("Phone Playback Volume", CM_REG_EXTENT_IND, 5, 7), |
2312 | CMIPCI_DOUBLE("Phone Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 4, 4, 1, 0, 0), | 2312 | CMIPCI_DOUBLE("Phone Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 4, 4, 1, 0, 0), |
2313 | CMIPCI_DOUBLE("PC Speaker Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 3, 3, 1, 0, 0), | 2313 | CMIPCI_DOUBLE("Beep Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 3, 3, 1, 0, 0), |
2314 | CMIPCI_DOUBLE("Mic Boost Capture Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 0, 0, 1, 0, 0), | 2314 | CMIPCI_DOUBLE("Mic Boost Capture Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 0, 0, 1, 0, 0), |
2315 | }; | 2315 | }; |
2316 | 2316 | ||
diff --git a/sound/pci/cs46xx/imgs/cwcdma.asp b/sound/pci/cs46xx/imgs/cwcdma.asp index 09d24c76f034..a65e1193c89a 100644 --- a/sound/pci/cs46xx/imgs/cwcdma.asp +++ b/sound/pci/cs46xx/imgs/cwcdma.asp | |||
@@ -26,10 +26,11 @@ | |||
26 | // | 26 | // |
27 | // | 27 | // |
28 | // The purpose of this code is very simple: make it possible to tranfser | 28 | // The purpose of this code is very simple: make it possible to tranfser |
29 | // the samples 'as they are' with no alteration from a PCMreader SCB (DMA from host) | 29 | // the samples 'as they are' with no alteration from a PCMreader |
30 | // to any other SCB. This is useful for AC3 throug SPDIF. SRC (source rate converters) | 30 | // SCB (DMA from host) to any other SCB. This is useful for AC3 through SPDIF. |
31 | // task always alters the samples in some how, however it's from 48khz -> 48khz. The | 31 | // SRC (source rate converters) task always alters the samples in somehow, |
32 | // alterations are not audible, but AC3 wont work. | 32 | // however it's from 48khz -> 48khz. |
33 | // The alterations are not audible, but AC3 wont work. | ||
33 | // | 34 | // |
34 | // ... | 35 | // ... |
35 | // | | 36 | // | |
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/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 75454648d50c..cb65bd0dd35b 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -240,7 +240,7 @@ static int select_rom(unsigned int pitch) | |||
240 | } else if (pitch == 0x02000000) { | 240 | } else if (pitch == 0x02000000) { |
241 | /* pitch == 2 */ | 241 | /* pitch == 2 */ |
242 | return 3; | 242 | return 3; |
243 | } else if (pitch >= 0x0 && pitch <= 0x08000000) { | 243 | } else if (pitch <= 0x08000000) { |
244 | /* 0 <= pitch <= 8 */ | 244 | /* 0 <= pitch <= 8 */ |
245 | return 0; | 245 | return 0; |
246 | } else { | 246 | } else { |
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 36e08bd2b3cc..1d369ff73805 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c | |||
@@ -184,7 +184,7 @@ MODULE_PARM_DESC(enable, "Enable the EMU10K1X soundcard."); | |||
184 | * The hardware has 3 channels for playback and 1 for capture. | 184 | * The hardware has 3 channels for playback and 1 for capture. |
185 | * - channel 0 is the front channel | 185 | * - channel 0 is the front channel |
186 | * - channel 1 is the rear channel | 186 | * - channel 1 is the rear channel |
187 | * - channel 2 is the center/lfe chanel | 187 | * - channel 2 is the center/lfe channel |
188 | * Volume is controlled by the AC97 for the front and rear channels by | 188 | * Volume is controlled by the AC97 for the front and rear channels by |
189 | * the PCM Playback Volume, Sigmatel Surround Playback Volume and | 189 | * the PCM Playback Volume, Sigmatel Surround Playback Volume and |
190 | * Surround Playback Volume. The Sigmatel 4-Speaker Stereo switch affects | 190 | * Surround Playback Volume. The Sigmatel 4-Speaker Stereo switch affects |
@@ -1040,8 +1040,7 @@ static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, | |||
1040 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) | 1040 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) |
1041 | continue; | 1041 | continue; |
1042 | 1042 | ||
1043 | if ((reg < 0x49) && (reg >= 0) && (val <= 0xffffffff) | 1043 | if (reg < 0x49 && val <= 0xffffffff && channel_id <= 2) |
1044 | && (channel_id >= 0) && (channel_id <= 2) ) | ||
1045 | snd_emu10k1x_ptr_write(emu, reg, channel_id, val); | 1044 | snd_emu10k1x_ptr_write(emu, reg, channel_id, val); |
1046 | } | 1045 | } |
1047 | } | 1046 | } |
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index b0fb6c917c38..05afe06e353a 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c | |||
@@ -1818,8 +1818,8 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu, | |||
1818 | "Master Playback Switch", "Master Capture Switch", | 1818 | "Master Playback Switch", "Master Capture Switch", |
1819 | "Master Playback Volume", "Master Capture Volume", | 1819 | "Master Playback Volume", "Master Capture Volume", |
1820 | "Wave Master Playback Volume", "Master Playback Volume", | 1820 | "Wave Master Playback Volume", "Master Playback Volume", |
1821 | "PC Speaker Playback Switch", "PC Speaker Capture Switch", | 1821 | "Beep Playback Switch", "Beep Capture Switch", |
1822 | "PC Speaker Playback Volume", "PC Speaker Capture Volume", | 1822 | "Beep Playback Volume", "Beep Capture Volume", |
1823 | "Phone Playback Switch", "Phone Capture Switch", | 1823 | "Phone Playback Switch", "Phone Capture Switch", |
1824 | "Phone Playback Volume", "Phone Capture Volume", | 1824 | "Phone Playback Volume", "Phone Capture Volume", |
1825 | "Mic Playback Switch", "Mic Capture Switch", | 1825 | "Mic Playback Switch", "Mic Capture Switch", |
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index 216f9748aff5..baa7cd508cd8 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c | |||
@@ -451,7 +451,7 @@ static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry, | |||
451 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 451 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
452 | if (sscanf(line, "%x %x", ®, &val) != 2) | 452 | if (sscanf(line, "%x %x", ®, &val) != 2) |
453 | continue; | 453 | continue; |
454 | if ((reg < 0x40) && (reg >= 0) && (val <= 0xffffffff) ) { | 454 | if (reg < 0x40 && val <= 0xffffffff) { |
455 | spin_lock_irqsave(&emu->emu_lock, flags); | 455 | spin_lock_irqsave(&emu->emu_lock, flags); |
456 | outl(val, emu->port + (reg & 0xfffffffc)); | 456 | outl(val, emu->port + (reg & 0xfffffffc)); |
457 | spin_unlock_irqrestore(&emu->emu_lock, flags); | 457 | spin_unlock_irqrestore(&emu->emu_lock, flags); |
@@ -527,7 +527,7 @@ static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry, | |||
527 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 527 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
528 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) | 528 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) |
529 | continue; | 529 | continue; |
530 | if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) ) | 530 | if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3) |
531 | snd_ptr_write(emu, iobase, reg, channel_id, val); | 531 | snd_ptr_write(emu, iobase, reg, channel_id, val); |
532 | } | 532 | } |
533 | } | 533 | } |
diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index c1a5aa15af8f..5ef7080e14d0 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c | |||
@@ -256,7 +256,7 @@ int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, u32 reg, u32 value) | |||
256 | if (reg > 0x3f) | 256 | if (reg > 0x3f) |
257 | return 1; | 257 | return 1; |
258 | reg += 0x40; /* 0x40 upwards are registers. */ | 258 | reg += 0x40; /* 0x40 upwards are registers. */ |
259 | if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */ | 259 | if (value > 0x3f) /* 0 to 0x3f are values */ |
260 | return 1; | 260 | return 1; |
261 | spin_lock_irqsave(&emu->emu_lock, flags); | 261 | spin_lock_irqsave(&emu->emu_lock, flags); |
262 | outl(reg, emu->port + A_IOCFG); | 262 | outl(reg, emu->port + A_IOCFG); |
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 820318ee62c1..fb83e1ffa5cb 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c | |||
@@ -1387,7 +1387,7 @@ ES1938_DOUBLE_TLV("Aux Playback Volume", 0, 0x3a, 0x3a, 4, 0, 15, 0, | |||
1387 | db_scale_line), | 1387 | db_scale_line), |
1388 | ES1938_DOUBLE_TLV("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0, | 1388 | ES1938_DOUBLE_TLV("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0, |
1389 | db_scale_capture), | 1389 | db_scale_capture), |
1390 | ES1938_SINGLE("PC Speaker Volume", 0, 0x3c, 0, 7, 0), | 1390 | ES1938_SINGLE("Beep Volume", 0, 0x3c, 0, 7, 0), |
1391 | ES1938_SINGLE("Record Monitor", 0, 0xa8, 3, 1, 0), | 1391 | ES1938_SINGLE("Record Monitor", 0, 0xa8, 3, 1, 0), |
1392 | ES1938_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), | 1392 | ES1938_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), |
1393 | { | 1393 | { |
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 60cdb9e0b68d..83508b3964fb 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c | |||
@@ -55,7 +55,7 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card * | |||
55 | * 1 = MediaForte 256-PCS | 55 | * 1 = MediaForte 256-PCS |
56 | * 2 = MediaForte 256-PCPR | 56 | * 2 = MediaForte 256-PCPR |
57 | * 3 = MediaForte 64-PCR | 57 | * 3 = MediaForte 64-PCR |
58 | * 16 = setup tuner only (this is additional bit), i.e. SF-64-PCR FM card | 58 | * 16 = setup tuner only (this is additional bit), i.e. SF64-PCR FM card |
59 | * High 16-bits are video (radio) device number + 1 | 59 | * High 16-bits are video (radio) device number + 1 |
60 | */ | 60 | */ |
61 | static int tea575x_tuner[SNDRV_CARDS]; | 61 | static int tea575x_tuner[SNDRV_CARDS]; |
@@ -67,7 +67,10 @@ MODULE_PARM_DESC(id, "ID string for the FM801 soundcard."); | |||
67 | module_param_array(enable, bool, NULL, 0444); | 67 | module_param_array(enable, bool, NULL, 0444); |
68 | MODULE_PARM_DESC(enable, "Enable FM801 soundcard."); | 68 | MODULE_PARM_DESC(enable, "Enable FM801 soundcard."); |
69 | module_param_array(tea575x_tuner, int, NULL, 0444); | 69 | module_param_array(tea575x_tuner, int, NULL, 0444); |
70 | MODULE_PARM_DESC(tea575x_tuner, "Enable TEA575x tuner."); | 70 | MODULE_PARM_DESC(tea575x_tuner, "TEA575x tuner access method (1 = SF256-PCS, 2=SF256-PCPR, 3=SF64-PCR, +16=tuner-only)."); |
71 | |||
72 | #define TUNER_ONLY (1<<4) | ||
73 | #define TUNER_TYPE_MASK (~TUNER_ONLY & 0xFFFF) | ||
71 | 74 | ||
72 | /* | 75 | /* |
73 | * Direct registers | 76 | * Direct registers |
@@ -160,7 +163,7 @@ struct fm801 { | |||
160 | unsigned int multichannel: 1, /* multichannel support */ | 163 | unsigned int multichannel: 1, /* multichannel support */ |
161 | secondary: 1; /* secondary codec */ | 164 | secondary: 1; /* secondary codec */ |
162 | unsigned char secondary_addr; /* address of the secondary codec */ | 165 | unsigned char secondary_addr; /* address of the secondary codec */ |
163 | unsigned int tea575x_tuner; /* tuner flags */ | 166 | unsigned int tea575x_tuner; /* tuner access method & flags */ |
164 | 167 | ||
165 | unsigned short ply_ctrl; /* playback control */ | 168 | unsigned short ply_ctrl; /* playback control */ |
166 | unsigned short cap_ctrl; /* capture control */ | 169 | unsigned short cap_ctrl; /* capture control */ |
@@ -1287,7 +1290,7 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume) | |||
1287 | { | 1290 | { |
1288 | unsigned short cmdw; | 1291 | unsigned short cmdw; |
1289 | 1292 | ||
1290 | if (chip->tea575x_tuner & 0x0010) | 1293 | if (chip->tea575x_tuner & TUNER_ONLY) |
1291 | goto __ac97_ok; | 1294 | goto __ac97_ok; |
1292 | 1295 | ||
1293 | /* codec cold reset + AC'97 warm reset */ | 1296 | /* codec cold reset + AC'97 warm reset */ |
@@ -1296,11 +1299,13 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume) | |||
1296 | udelay(100); | 1299 | udelay(100); |
1297 | outw(0, FM801_REG(chip, CODEC_CTRL)); | 1300 | outw(0, FM801_REG(chip, CODEC_CTRL)); |
1298 | 1301 | ||
1299 | if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0) { | 1302 | if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0) |
1300 | snd_printk(KERN_ERR "Primary AC'97 codec not found\n"); | 1303 | if (!resume) { |
1301 | if (! resume) | 1304 | snd_printk(KERN_INFO "Primary AC'97 codec not found, " |
1302 | return -EIO; | 1305 | "assume SF64-PCR (tuner-only)\n"); |
1303 | } | 1306 | chip->tea575x_tuner = 3 | TUNER_ONLY; |
1307 | goto __ac97_ok; | ||
1308 | } | ||
1304 | 1309 | ||
1305 | if (chip->multichannel) { | 1310 | if (chip->multichannel) { |
1306 | if (chip->secondary_addr) { | 1311 | if (chip->secondary_addr) { |
@@ -1414,7 +1419,7 @@ static int __devinit snd_fm801_create(struct snd_card *card, | |||
1414 | return err; | 1419 | return err; |
1415 | } | 1420 | } |
1416 | chip->port = pci_resource_start(pci, 0); | 1421 | chip->port = pci_resource_start(pci, 0); |
1417 | if ((tea575x_tuner & 0x0010) == 0) { | 1422 | if ((tea575x_tuner & TUNER_ONLY) == 0) { |
1418 | if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED, | 1423 | if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED, |
1419 | "FM801", chip)) { | 1424 | "FM801", chip)) { |
1420 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->irq); | 1425 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->irq); |
@@ -1429,6 +1434,14 @@ static int __devinit snd_fm801_create(struct snd_card *card, | |||
1429 | chip->multichannel = 1; | 1434 | chip->multichannel = 1; |
1430 | 1435 | ||
1431 | snd_fm801_chip_init(chip, 0); | 1436 | snd_fm801_chip_init(chip, 0); |
1437 | /* init might set tuner access method */ | ||
1438 | tea575x_tuner = chip->tea575x_tuner; | ||
1439 | |||
1440 | if (chip->irq >= 0 && (tea575x_tuner & TUNER_ONLY)) { | ||
1441 | pci_clear_master(pci); | ||
1442 | free_irq(chip->irq, chip); | ||
1443 | chip->irq = -1; | ||
1444 | } | ||
1432 | 1445 | ||
1433 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1446 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
1434 | snd_fm801_free(chip); | 1447 | snd_fm801_free(chip); |
@@ -1438,12 +1451,13 @@ static int __devinit snd_fm801_create(struct snd_card *card, | |||
1438 | snd_card_set_dev(card, &pci->dev); | 1451 | snd_card_set_dev(card, &pci->dev); |
1439 | 1452 | ||
1440 | #ifdef TEA575X_RADIO | 1453 | #ifdef TEA575X_RADIO |
1441 | if (tea575x_tuner > 0 && (tea575x_tuner & 0x000f) < 4) { | 1454 | if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 && |
1455 | (tea575x_tuner & TUNER_TYPE_MASK) < 4) { | ||
1442 | chip->tea.dev_nr = tea575x_tuner >> 16; | 1456 | chip->tea.dev_nr = tea575x_tuner >> 16; |
1443 | chip->tea.card = card; | 1457 | chip->tea.card = card; |
1444 | chip->tea.freq_fixup = 10700; | 1458 | chip->tea.freq_fixup = 10700; |
1445 | chip->tea.private_data = chip; | 1459 | chip->tea.private_data = chip; |
1446 | chip->tea.ops = &snd_fm801_tea_ops[(tea575x_tuner & 0x000f) - 1]; | 1460 | chip->tea.ops = &snd_fm801_tea_ops[(tea575x_tuner & TUNER_TYPE_MASK) - 1]; |
1447 | snd_tea575x_init(&chip->tea); | 1461 | snd_tea575x_init(&chip->tea); |
1448 | } | 1462 | } |
1449 | #endif | 1463 | #endif |
@@ -1483,7 +1497,7 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci, | |||
1483 | sprintf(card->longname, "%s at 0x%lx, irq %i", | 1497 | sprintf(card->longname, "%s at 0x%lx, irq %i", |
1484 | card->shortname, chip->port, chip->irq); | 1498 | card->shortname, chip->port, chip->irq); |
1485 | 1499 | ||
1486 | if (tea575x_tuner[dev] & 0x0010) | 1500 | if (chip->tea575x_tuner & TUNER_ONLY) |
1487 | goto __fm801_tuner_only; | 1501 | goto __fm801_tuner_only; |
1488 | 1502 | ||
1489 | if ((err = snd_fm801_pcm(chip, 0, NULL)) < 0) { | 1503 | if ((err = snd_fm801_pcm(chip, 0, NULL)) < 0) { |
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 55545e0818b5..556cff937be7 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -38,9 +38,20 @@ config SND_HDA_INPUT_BEEP | |||
38 | Say Y here to build a digital beep interface for HD-audio | 38 | Say Y here to build a digital beep interface for HD-audio |
39 | driver. This interface is used to generate digital beeps. | 39 | driver. This interface is used to generate digital beeps. |
40 | 40 | ||
41 | config SND_HDA_INPUT_BEEP_MODE | ||
42 | int "Digital beep registration mode (0=off, 1=on, 2=mute sw on/off)" | ||
43 | depends on SND_HDA_INPUT_BEEP=y | ||
44 | default "1" | ||
45 | range 0 2 | ||
46 | help | ||
47 | Set 0 to disable the digital beep interface for HD-audio by default. | ||
48 | Set 1 to always enable the digital beep interface for HD-audio by | ||
49 | default. Set 2 to control the beep device registration to input | ||
50 | layer using a "Beep Switch" in mixer applications. | ||
51 | |||
41 | config SND_HDA_INPUT_JACK | 52 | config SND_HDA_INPUT_JACK |
42 | bool "Support jack plugging notification via input layer" | 53 | bool "Support jack plugging notification via input layer" |
43 | depends on INPUT=y || INPUT=SND_HDA_INTEL | 54 | depends on INPUT=y || INPUT=SND |
44 | select SND_JACK | 55 | select SND_JACK |
45 | help | 56 | help |
46 | Say Y here to enable the jack plugging notification via | 57 | Say Y here to enable the jack plugging notification via |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 3f51a981e604..5fe34a8d8c81 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -113,23 +113,25 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, | |||
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | 116 | static void snd_hda_do_detach(struct hda_beep *beep) |
117 | { | ||
118 | input_unregister_device(beep->dev); | ||
119 | beep->dev = NULL; | ||
120 | cancel_work_sync(&beep->beep_work); | ||
121 | /* turn off beep for sure */ | ||
122 | snd_hda_codec_write_cache(beep->codec, beep->nid, 0, | ||
123 | AC_VERB_SET_BEEP_CONTROL, 0); | ||
124 | } | ||
125 | |||
126 | static int snd_hda_do_attach(struct hda_beep *beep) | ||
117 | { | 127 | { |
118 | struct input_dev *input_dev; | 128 | struct input_dev *input_dev; |
119 | struct hda_beep *beep; | 129 | struct hda_codec *codec = beep->codec; |
120 | int err; | 130 | int err; |
121 | 131 | ||
122 | if (!snd_hda_get_bool_hint(codec, "beep")) | ||
123 | return 0; /* disabled explicitly */ | ||
124 | |||
125 | beep = kzalloc(sizeof(*beep), GFP_KERNEL); | ||
126 | if (beep == NULL) | ||
127 | return -ENOMEM; | ||
128 | snprintf(beep->phys, sizeof(beep->phys), | ||
129 | "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); | ||
130 | input_dev = input_allocate_device(); | 132 | input_dev = input_allocate_device(); |
131 | if (!input_dev) { | 133 | if (!input_dev) { |
132 | kfree(beep); | 134 | printk(KERN_INFO "hda_beep: unable to allocate input device\n"); |
133 | return -ENOMEM; | 135 | return -ENOMEM; |
134 | } | 136 | } |
135 | 137 | ||
@@ -151,21 +153,96 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
151 | err = input_register_device(input_dev); | 153 | err = input_register_device(input_dev); |
152 | if (err < 0) { | 154 | if (err < 0) { |
153 | input_free_device(input_dev); | 155 | input_free_device(input_dev); |
154 | kfree(beep); | 156 | printk(KERN_INFO "hda_beep: unable to register input device\n"); |
155 | return err; | 157 | return err; |
156 | } | 158 | } |
159 | beep->dev = input_dev; | ||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | static void snd_hda_do_register(struct work_struct *work) | ||
164 | { | ||
165 | struct hda_beep *beep = | ||
166 | container_of(work, struct hda_beep, register_work); | ||
167 | |||
168 | mutex_lock(&beep->mutex); | ||
169 | if (beep->enabled && !beep->dev) | ||
170 | snd_hda_do_attach(beep); | ||
171 | mutex_unlock(&beep->mutex); | ||
172 | } | ||
173 | |||
174 | static void snd_hda_do_unregister(struct work_struct *work) | ||
175 | { | ||
176 | struct hda_beep *beep = | ||
177 | container_of(work, struct hda_beep, unregister_work.work); | ||
178 | |||
179 | mutex_lock(&beep->mutex); | ||
180 | if (!beep->enabled && beep->dev) | ||
181 | snd_hda_do_detach(beep); | ||
182 | mutex_unlock(&beep->mutex); | ||
183 | } | ||
157 | 184 | ||
185 | int snd_hda_enable_beep_device(struct hda_codec *codec, int enable) | ||
186 | { | ||
187 | struct hda_beep *beep = codec->beep; | ||
188 | enable = !!enable; | ||
189 | if (beep == NULL) | ||
190 | return 0; | ||
191 | if (beep->enabled != enable) { | ||
192 | beep->enabled = enable; | ||
193 | if (!enable) { | ||
194 | /* turn off beep */ | ||
195 | snd_hda_codec_write_cache(beep->codec, beep->nid, 0, | ||
196 | AC_VERB_SET_BEEP_CONTROL, 0); | ||
197 | } | ||
198 | if (beep->mode == HDA_BEEP_MODE_SWREG) { | ||
199 | if (enable) { | ||
200 | cancel_delayed_work(&beep->unregister_work); | ||
201 | schedule_work(&beep->register_work); | ||
202 | } else { | ||
203 | schedule_delayed_work(&beep->unregister_work, | ||
204 | HZ); | ||
205 | } | ||
206 | } | ||
207 | return 1; | ||
208 | } | ||
209 | return 0; | ||
210 | } | ||
211 | EXPORT_SYMBOL_HDA(snd_hda_enable_beep_device); | ||
212 | |||
213 | int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | ||
214 | { | ||
215 | struct hda_beep *beep; | ||
216 | |||
217 | if (!snd_hda_get_bool_hint(codec, "beep")) | ||
218 | return 0; /* disabled explicitly by hints */ | ||
219 | if (codec->beep_mode == HDA_BEEP_MODE_OFF) | ||
220 | return 0; /* disabled by module option */ | ||
221 | |||
222 | beep = kzalloc(sizeof(*beep), GFP_KERNEL); | ||
223 | if (beep == NULL) | ||
224 | return -ENOMEM; | ||
225 | snprintf(beep->phys, sizeof(beep->phys), | ||
226 | "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); | ||
158 | /* enable linear scale */ | 227 | /* enable linear scale */ |
159 | snd_hda_codec_write(codec, nid, 0, | 228 | snd_hda_codec_write(codec, nid, 0, |
160 | AC_VERB_SET_DIGI_CONVERT_2, 0x01); | 229 | AC_VERB_SET_DIGI_CONVERT_2, 0x01); |
161 | 230 | ||
162 | beep->nid = nid; | 231 | beep->nid = nid; |
163 | beep->dev = input_dev; | ||
164 | beep->codec = codec; | 232 | beep->codec = codec; |
165 | beep->enabled = 1; | 233 | beep->mode = codec->beep_mode; |
166 | codec->beep = beep; | 234 | codec->beep = beep; |
167 | 235 | ||
236 | INIT_WORK(&beep->register_work, &snd_hda_do_register); | ||
237 | INIT_DELAYED_WORK(&beep->unregister_work, &snd_hda_do_unregister); | ||
168 | INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); | 238 | INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); |
239 | mutex_init(&beep->mutex); | ||
240 | |||
241 | if (beep->mode == HDA_BEEP_MODE_ON) { | ||
242 | beep->enabled = 1; | ||
243 | snd_hda_do_register(&beep->register_work); | ||
244 | } | ||
245 | |||
169 | return 0; | 246 | return 0; |
170 | } | 247 | } |
171 | EXPORT_SYMBOL_HDA(snd_hda_attach_beep_device); | 248 | EXPORT_SYMBOL_HDA(snd_hda_attach_beep_device); |
@@ -174,11 +251,12 @@ void snd_hda_detach_beep_device(struct hda_codec *codec) | |||
174 | { | 251 | { |
175 | struct hda_beep *beep = codec->beep; | 252 | struct hda_beep *beep = codec->beep; |
176 | if (beep) { | 253 | if (beep) { |
177 | cancel_work_sync(&beep->beep_work); | 254 | cancel_work_sync(&beep->register_work); |
178 | 255 | cancel_delayed_work(&beep->unregister_work); | |
179 | input_unregister_device(beep->dev); | 256 | if (beep->enabled) |
180 | kfree(beep); | 257 | snd_hda_do_detach(beep); |
181 | codec->beep = NULL; | 258 | codec->beep = NULL; |
259 | kfree(beep); | ||
182 | } | 260 | } |
183 | } | 261 | } |
184 | EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); | 262 | EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); |
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h index 0c3de787c717..f1de1bac042c 100644 --- a/sound/pci/hda/hda_beep.h +++ b/sound/pci/hda/hda_beep.h | |||
@@ -24,19 +24,29 @@ | |||
24 | 24 | ||
25 | #include "hda_codec.h" | 25 | #include "hda_codec.h" |
26 | 26 | ||
27 | #define HDA_BEEP_MODE_OFF 0 | ||
28 | #define HDA_BEEP_MODE_ON 1 | ||
29 | #define HDA_BEEP_MODE_SWREG 2 | ||
30 | |||
27 | /* beep information */ | 31 | /* beep information */ |
28 | struct hda_beep { | 32 | struct hda_beep { |
29 | struct input_dev *dev; | 33 | struct input_dev *dev; |
30 | struct hda_codec *codec; | 34 | struct hda_codec *codec; |
35 | unsigned int mode; | ||
31 | char phys[32]; | 36 | char phys[32]; |
32 | int tone; | 37 | int tone; |
33 | hda_nid_t nid; | 38 | hda_nid_t nid; |
34 | unsigned int enabled:1; | 39 | unsigned int enabled:1; |
40 | unsigned int request_enable:1; | ||
35 | unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */ | 41 | unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */ |
42 | struct work_struct register_work; /* registration work */ | ||
43 | struct delayed_work unregister_work; /* unregistration work */ | ||
36 | struct work_struct beep_work; /* scheduled task for beep event */ | 44 | struct work_struct beep_work; /* scheduled task for beep event */ |
45 | struct mutex mutex; | ||
37 | }; | 46 | }; |
38 | 47 | ||
39 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 48 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
49 | int snd_hda_enable_beep_device(struct hda_codec *codec, int enable); | ||
40 | int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); | 50 | int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); |
41 | void snd_hda_detach_beep_device(struct hda_codec *codec); | 51 | void snd_hda_detach_beep_device(struct hda_codec *codec); |
42 | #else | 52 | #else |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index af989f660cca..950ee5cfcacf 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <sound/tlv.h> | 30 | #include <sound/tlv.h> |
31 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
32 | #include "hda_local.h" | 32 | #include "hda_local.h" |
33 | #include "hda_beep.h" | ||
33 | #include <sound/hda_hwdep.h> | 34 | #include <sound/hda_hwdep.h> |
34 | 35 | ||
35 | /* | 36 | /* |
@@ -93,6 +94,13 @@ static void hda_keep_power_on(struct hda_codec *codec); | |||
93 | static inline void hda_keep_power_on(struct hda_codec *codec) {} | 94 | static inline void hda_keep_power_on(struct hda_codec *codec) {} |
94 | #endif | 95 | #endif |
95 | 96 | ||
97 | /** | ||
98 | * snd_hda_get_jack_location - Give a location string of the jack | ||
99 | * @cfg: pin default config value | ||
100 | * | ||
101 | * Parse the pin default config value and returns the string of the | ||
102 | * jack location, e.g. "Rear", "Front", etc. | ||
103 | */ | ||
96 | const char *snd_hda_get_jack_location(u32 cfg) | 104 | const char *snd_hda_get_jack_location(u32 cfg) |
97 | { | 105 | { |
98 | static char *bases[7] = { | 106 | static char *bases[7] = { |
@@ -120,6 +128,13 @@ const char *snd_hda_get_jack_location(u32 cfg) | |||
120 | } | 128 | } |
121 | EXPORT_SYMBOL_HDA(snd_hda_get_jack_location); | 129 | EXPORT_SYMBOL_HDA(snd_hda_get_jack_location); |
122 | 130 | ||
131 | /** | ||
132 | * snd_hda_get_jack_connectivity - Give a connectivity string of the jack | ||
133 | * @cfg: pin default config value | ||
134 | * | ||
135 | * Parse the pin default config value and returns the string of the | ||
136 | * jack connectivity, i.e. external or internal connection. | ||
137 | */ | ||
123 | const char *snd_hda_get_jack_connectivity(u32 cfg) | 138 | const char *snd_hda_get_jack_connectivity(u32 cfg) |
124 | { | 139 | { |
125 | static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" }; | 140 | static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" }; |
@@ -128,6 +143,13 @@ const char *snd_hda_get_jack_connectivity(u32 cfg) | |||
128 | } | 143 | } |
129 | EXPORT_SYMBOL_HDA(snd_hda_get_jack_connectivity); | 144 | EXPORT_SYMBOL_HDA(snd_hda_get_jack_connectivity); |
130 | 145 | ||
146 | /** | ||
147 | * snd_hda_get_jack_type - Give a type string of the jack | ||
148 | * @cfg: pin default config value | ||
149 | * | ||
150 | * Parse the pin default config value and returns the string of the | ||
151 | * jack type, i.e. the purpose of the jack, such as Line-Out or CD. | ||
152 | */ | ||
131 | const char *snd_hda_get_jack_type(u32 cfg) | 153 | const char *snd_hda_get_jack_type(u32 cfg) |
132 | { | 154 | { |
133 | static char *jack_types[16] = { | 155 | static char *jack_types[16] = { |
@@ -515,6 +537,7 @@ static int snd_hda_bus_dev_register(struct snd_device *device) | |||
515 | struct hda_codec *codec; | 537 | struct hda_codec *codec; |
516 | list_for_each_entry(codec, &bus->codec_list, list) { | 538 | list_for_each_entry(codec, &bus->codec_list, list) { |
517 | snd_hda_hwdep_add_sysfs(codec); | 539 | snd_hda_hwdep_add_sysfs(codec); |
540 | snd_hda_hwdep_add_power_sysfs(codec); | ||
518 | } | 541 | } |
519 | return 0; | 542 | return 0; |
520 | } | 543 | } |
@@ -820,6 +843,16 @@ int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, | |||
820 | return 0; | 843 | return 0; |
821 | } | 844 | } |
822 | 845 | ||
846 | /** | ||
847 | * snd_hda_codec_set_pincfg - Override a pin default configuration | ||
848 | * @codec: the HDA codec | ||
849 | * @nid: NID to set the pin config | ||
850 | * @cfg: the pin default config value | ||
851 | * | ||
852 | * Override a pin default configuration value in the cache. | ||
853 | * This value can be read by snd_hda_codec_get_pincfg() in a higher | ||
854 | * priority than the real hardware value. | ||
855 | */ | ||
823 | int snd_hda_codec_set_pincfg(struct hda_codec *codec, | 856 | int snd_hda_codec_set_pincfg(struct hda_codec *codec, |
824 | hda_nid_t nid, unsigned int cfg) | 857 | hda_nid_t nid, unsigned int cfg) |
825 | { | 858 | { |
@@ -827,7 +860,15 @@ int snd_hda_codec_set_pincfg(struct hda_codec *codec, | |||
827 | } | 860 | } |
828 | EXPORT_SYMBOL_HDA(snd_hda_codec_set_pincfg); | 861 | EXPORT_SYMBOL_HDA(snd_hda_codec_set_pincfg); |
829 | 862 | ||
830 | /* get the current pin config value of the given pin NID */ | 863 | /** |
864 | * snd_hda_codec_get_pincfg - Obtain a pin-default configuration | ||
865 | * @codec: the HDA codec | ||
866 | * @nid: NID to get the pin config | ||
867 | * | ||
868 | * Get the current pin config value of the given pin NID. | ||
869 | * If the pincfg value is cached or overridden via sysfs or driver, | ||
870 | * returns the cached value. | ||
871 | */ | ||
831 | unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid) | 872 | unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid) |
832 | { | 873 | { |
833 | struct hda_pincfg *pin; | 874 | struct hda_pincfg *pin; |
@@ -944,7 +985,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
944 | mutex_init(&codec->control_mutex); | 985 | mutex_init(&codec->control_mutex); |
945 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | 986 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); |
946 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | 987 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); |
947 | snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); | 988 | snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 60); |
948 | snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); | 989 | snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); |
949 | snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); | 990 | snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); |
950 | if (codec->bus->modelname) { | 991 | if (codec->bus->modelname) { |
@@ -1026,6 +1067,15 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
1026 | } | 1067 | } |
1027 | EXPORT_SYMBOL_HDA(snd_hda_codec_new); | 1068 | EXPORT_SYMBOL_HDA(snd_hda_codec_new); |
1028 | 1069 | ||
1070 | /** | ||
1071 | * snd_hda_codec_configure - (Re-)configure the HD-audio codec | ||
1072 | * @codec: the HDA codec | ||
1073 | * | ||
1074 | * Start parsing of the given codec tree and (re-)initialize the whole | ||
1075 | * patch instance. | ||
1076 | * | ||
1077 | * Returns 0 if successful or a negative error code. | ||
1078 | */ | ||
1029 | int snd_hda_codec_configure(struct hda_codec *codec) | 1079 | int snd_hda_codec_configure(struct hda_codec *codec) |
1030 | { | 1080 | { |
1031 | int err; | 1081 | int err; |
@@ -1036,11 +1086,6 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1036 | if (err < 0) | 1086 | if (err < 0) |
1037 | return err; | 1087 | return err; |
1038 | } | 1088 | } |
1039 | /* audio codec should override the mixer name */ | ||
1040 | if (codec->afg || !*codec->bus->card->mixername) | ||
1041 | snprintf(codec->bus->card->mixername, | ||
1042 | sizeof(codec->bus->card->mixername), | ||
1043 | "%s %s", codec->vendor_name, codec->chip_name); | ||
1044 | 1089 | ||
1045 | if (is_generic_config(codec)) { | 1090 | if (is_generic_config(codec)) { |
1046 | err = snd_hda_parse_generic_codec(codec); | 1091 | err = snd_hda_parse_generic_codec(codec); |
@@ -1059,6 +1104,11 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1059 | patched: | 1104 | patched: |
1060 | if (!err && codec->patch_ops.unsol_event) | 1105 | if (!err && codec->patch_ops.unsol_event) |
1061 | err = init_unsol_queue(codec->bus); | 1106 | err = init_unsol_queue(codec->bus); |
1107 | /* audio codec should override the mixer name */ | ||
1108 | if (!err && (codec->afg || !*codec->bus->card->mixername)) | ||
1109 | snprintf(codec->bus->card->mixername, | ||
1110 | sizeof(codec->bus->card->mixername), | ||
1111 | "%s %s", codec->vendor_name, codec->chip_name); | ||
1062 | return err; | 1112 | return err; |
1063 | } | 1113 | } |
1064 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); | 1114 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); |
@@ -1088,6 +1138,11 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, | |||
1088 | } | 1138 | } |
1089 | EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); | 1139 | EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); |
1090 | 1140 | ||
1141 | /** | ||
1142 | * snd_hda_codec_cleanup_stream - clean up the codec for closing | ||
1143 | * @codec: the CODEC to clean up | ||
1144 | * @nid: the NID to clean up | ||
1145 | */ | ||
1091 | void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) | 1146 | void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) |
1092 | { | 1147 | { |
1093 | if (!nid) | 1148 | if (!nid) |
@@ -1163,8 +1218,17 @@ get_alloc_amp_hash(struct hda_codec *codec, u32 key) | |||
1163 | return (struct hda_amp_info *)get_alloc_hash(&codec->amp_cache, key); | 1218 | return (struct hda_amp_info *)get_alloc_hash(&codec->amp_cache, key); |
1164 | } | 1219 | } |
1165 | 1220 | ||
1166 | /* | 1221 | /** |
1167 | * query AMP capabilities for the given widget and direction | 1222 | * query_amp_caps - query AMP capabilities |
1223 | * @codec: the HD-auio codec | ||
1224 | * @nid: the NID to query | ||
1225 | * @direction: either #HDA_INPUT or #HDA_OUTPUT | ||
1226 | * | ||
1227 | * Query AMP capabilities for the given widget and direction. | ||
1228 | * Returns the obtained capability bits. | ||
1229 | * | ||
1230 | * When cap bits have been already read, this doesn't read again but | ||
1231 | * returns the cached value. | ||
1168 | */ | 1232 | */ |
1169 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) | 1233 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) |
1170 | { | 1234 | { |
@@ -1187,6 +1251,19 @@ u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) | |||
1187 | } | 1251 | } |
1188 | EXPORT_SYMBOL_HDA(query_amp_caps); | 1252 | EXPORT_SYMBOL_HDA(query_amp_caps); |
1189 | 1253 | ||
1254 | /** | ||
1255 | * snd_hda_override_amp_caps - Override the AMP capabilities | ||
1256 | * @codec: the CODEC to clean up | ||
1257 | * @nid: the NID to clean up | ||
1258 | * @direction: either #HDA_INPUT or #HDA_OUTPUT | ||
1259 | * @caps: the capability bits to set | ||
1260 | * | ||
1261 | * Override the cached AMP caps bits value by the given one. | ||
1262 | * This function is useful if the driver needs to adjust the AMP ranges, | ||
1263 | * e.g. limit to 0dB, etc. | ||
1264 | * | ||
1265 | * Returns zero if successful or a negative error code. | ||
1266 | */ | ||
1190 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, | 1267 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, |
1191 | unsigned int caps) | 1268 | unsigned int caps) |
1192 | { | 1269 | { |
@@ -1222,6 +1299,17 @@ static unsigned int read_pin_cap(struct hda_codec *codec, hda_nid_t nid) | |||
1222 | return snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | 1299 | return snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
1223 | } | 1300 | } |
1224 | 1301 | ||
1302 | /** | ||
1303 | * snd_hda_query_pin_caps - Query PIN capabilities | ||
1304 | * @codec: the HD-auio codec | ||
1305 | * @nid: the NID to query | ||
1306 | * | ||
1307 | * Query PIN capabilities for the given widget. | ||
1308 | * Returns the obtained capability bits. | ||
1309 | * | ||
1310 | * When cap bits have been already read, this doesn't read again but | ||
1311 | * returns the cached value. | ||
1312 | */ | ||
1225 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) | 1313 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) |
1226 | { | 1314 | { |
1227 | return query_caps_hash(codec, nid, HDA_HASH_PINCAP_KEY(nid), | 1315 | return query_caps_hash(codec, nid, HDA_HASH_PINCAP_KEY(nid), |
@@ -1229,6 +1317,40 @@ u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) | |||
1229 | } | 1317 | } |
1230 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); | 1318 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); |
1231 | 1319 | ||
1320 | /** | ||
1321 | * snd_hda_pin_sense - execute pin sense measurement | ||
1322 | * @codec: the CODEC to sense | ||
1323 | * @nid: the pin NID to sense | ||
1324 | * | ||
1325 | * Execute necessary pin sense measurement and return its Presence Detect, | ||
1326 | * Impedance, ELD Valid etc. status bits. | ||
1327 | */ | ||
1328 | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) | ||
1329 | { | ||
1330 | u32 pincap = snd_hda_query_pin_caps(codec, nid); | ||
1331 | |||
1332 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
1333 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
1334 | |||
1335 | return snd_hda_codec_read(codec, nid, 0, | ||
1336 | AC_VERB_GET_PIN_SENSE, 0); | ||
1337 | } | ||
1338 | EXPORT_SYMBOL_HDA(snd_hda_pin_sense); | ||
1339 | |||
1340 | /** | ||
1341 | * snd_hda_jack_detect - query pin Presence Detect status | ||
1342 | * @codec: the CODEC to sense | ||
1343 | * @nid: the pin NID to sense | ||
1344 | * | ||
1345 | * Query and return the pin's Presence Detect status. | ||
1346 | */ | ||
1347 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) | ||
1348 | { | ||
1349 | u32 sense = snd_hda_pin_sense(codec, nid); | ||
1350 | return !!(sense & AC_PINSENSE_PRESENCE); | ||
1351 | } | ||
1352 | EXPORT_SYMBOL_HDA(snd_hda_jack_detect); | ||
1353 | |||
1232 | /* | 1354 | /* |
1233 | * read the current volume to info | 1355 | * read the current volume to info |
1234 | * if the cache exists, read the cache value. | 1356 | * if the cache exists, read the cache value. |
@@ -1269,8 +1391,15 @@ static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, | |||
1269 | info->vol[ch] = val; | 1391 | info->vol[ch] = val; |
1270 | } | 1392 | } |
1271 | 1393 | ||
1272 | /* | 1394 | /** |
1273 | * read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit. | 1395 | * snd_hda_codec_amp_read - Read AMP value |
1396 | * @codec: HD-audio codec | ||
1397 | * @nid: NID to read the AMP value | ||
1398 | * @ch: channel (left=0 or right=1) | ||
1399 | * @direction: #HDA_INPUT or #HDA_OUTPUT | ||
1400 | * @index: the index value (only for input direction) | ||
1401 | * | ||
1402 | * Read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit. | ||
1274 | */ | 1403 | */ |
1275 | int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, | 1404 | int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, |
1276 | int direction, int index) | 1405 | int direction, int index) |
@@ -1283,8 +1412,18 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, | |||
1283 | } | 1412 | } |
1284 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read); | 1413 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read); |
1285 | 1414 | ||
1286 | /* | 1415 | /** |
1287 | * update the AMP value, mask = bit mask to set, val = the value | 1416 | * snd_hda_codec_amp_update - update the AMP value |
1417 | * @codec: HD-audio codec | ||
1418 | * @nid: NID to read the AMP value | ||
1419 | * @ch: channel (left=0 or right=1) | ||
1420 | * @direction: #HDA_INPUT or #HDA_OUTPUT | ||
1421 | * @idx: the index value (only for input direction) | ||
1422 | * @mask: bit mask to set | ||
1423 | * @val: the bits value to set | ||
1424 | * | ||
1425 | * Update the AMP value with a bit mask. | ||
1426 | * Returns 0 if the value is unchanged, 1 if changed. | ||
1288 | */ | 1427 | */ |
1289 | int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, | 1428 | int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, |
1290 | int direction, int idx, int mask, int val) | 1429 | int direction, int idx, int mask, int val) |
@@ -1303,8 +1442,17 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, | |||
1303 | } | 1442 | } |
1304 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_update); | 1443 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_update); |
1305 | 1444 | ||
1306 | /* | 1445 | /** |
1307 | * update the AMP stereo with the same mask and value | 1446 | * snd_hda_codec_amp_stereo - update the AMP stereo values |
1447 | * @codec: HD-audio codec | ||
1448 | * @nid: NID to read the AMP value | ||
1449 | * @direction: #HDA_INPUT or #HDA_OUTPUT | ||
1450 | * @idx: the index value (only for input direction) | ||
1451 | * @mask: bit mask to set | ||
1452 | * @val: the bits value to set | ||
1453 | * | ||
1454 | * Update the AMP values like snd_hda_codec_amp_update(), but for a | ||
1455 | * stereo widget with the same mask and value. | ||
1308 | */ | 1456 | */ |
1309 | int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid, | 1457 | int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid, |
1310 | int direction, int idx, int mask, int val) | 1458 | int direction, int idx, int mask, int val) |
@@ -1318,7 +1466,12 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid, | |||
1318 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_stereo); | 1466 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_stereo); |
1319 | 1467 | ||
1320 | #ifdef SND_HDA_NEEDS_RESUME | 1468 | #ifdef SND_HDA_NEEDS_RESUME |
1321 | /* resume the all amp commands from the cache */ | 1469 | /** |
1470 | * snd_hda_codec_resume_amp - Resume all AMP commands from the cache | ||
1471 | * @codec: HD-audio codec | ||
1472 | * | ||
1473 | * Resume the all amp commands from the cache. | ||
1474 | */ | ||
1322 | void snd_hda_codec_resume_amp(struct hda_codec *codec) | 1475 | void snd_hda_codec_resume_amp(struct hda_codec *codec) |
1323 | { | 1476 | { |
1324 | struct hda_amp_info *buffer = codec->amp_cache.buf.list; | 1477 | struct hda_amp_info *buffer = codec->amp_cache.buf.list; |
@@ -1344,7 +1497,12 @@ void snd_hda_codec_resume_amp(struct hda_codec *codec) | |||
1344 | EXPORT_SYMBOL_HDA(snd_hda_codec_resume_amp); | 1497 | EXPORT_SYMBOL_HDA(snd_hda_codec_resume_amp); |
1345 | #endif /* SND_HDA_NEEDS_RESUME */ | 1498 | #endif /* SND_HDA_NEEDS_RESUME */ |
1346 | 1499 | ||
1347 | /* volume */ | 1500 | /** |
1501 | * snd_hda_mixer_amp_volume_info - Info callback for a standard AMP mixer | ||
1502 | * | ||
1503 | * The control element is supposed to have the private_value field | ||
1504 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1505 | */ | ||
1348 | int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, | 1506 | int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, |
1349 | struct snd_ctl_elem_info *uinfo) | 1507 | struct snd_ctl_elem_info *uinfo) |
1350 | { | 1508 | { |
@@ -1400,6 +1558,12 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid, | |||
1400 | HDA_AMP_VOLMASK, val); | 1558 | HDA_AMP_VOLMASK, val); |
1401 | } | 1559 | } |
1402 | 1560 | ||
1561 | /** | ||
1562 | * snd_hda_mixer_amp_volume_get - Get callback for a standard AMP mixer volume | ||
1563 | * | ||
1564 | * The control element is supposed to have the private_value field | ||
1565 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1566 | */ | ||
1403 | int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, | 1567 | int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, |
1404 | struct snd_ctl_elem_value *ucontrol) | 1568 | struct snd_ctl_elem_value *ucontrol) |
1405 | { | 1569 | { |
@@ -1419,6 +1583,12 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, | |||
1419 | } | 1583 | } |
1420 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get); | 1584 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get); |
1421 | 1585 | ||
1586 | /** | ||
1587 | * snd_hda_mixer_amp_volume_put - Put callback for a standard AMP mixer volume | ||
1588 | * | ||
1589 | * The control element is supposed to have the private_value field | ||
1590 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1591 | */ | ||
1422 | int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, | 1592 | int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, |
1423 | struct snd_ctl_elem_value *ucontrol) | 1593 | struct snd_ctl_elem_value *ucontrol) |
1424 | { | 1594 | { |
@@ -1443,6 +1613,12 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, | |||
1443 | } | 1613 | } |
1444 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_put); | 1614 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_put); |
1445 | 1615 | ||
1616 | /** | ||
1617 | * snd_hda_mixer_amp_volume_put - TLV callback for a standard AMP mixer volume | ||
1618 | * | ||
1619 | * The control element is supposed to have the private_value field | ||
1620 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1621 | */ | ||
1446 | int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, | 1622 | int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
1447 | unsigned int size, unsigned int __user *_tlv) | 1623 | unsigned int size, unsigned int __user *_tlv) |
1448 | { | 1624 | { |
@@ -1472,8 +1648,16 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
1472 | } | 1648 | } |
1473 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_tlv); | 1649 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_tlv); |
1474 | 1650 | ||
1475 | /* | 1651 | /** |
1476 | * set (static) TLV for virtual master volume; recalculated as max 0dB | 1652 | * snd_hda_set_vmaster_tlv - Set TLV for a virtual master control |
1653 | * @codec: HD-audio codec | ||
1654 | * @nid: NID of a reference widget | ||
1655 | * @dir: #HDA_INPUT or #HDA_OUTPUT | ||
1656 | * @tlv: TLV data to be stored, at least 4 elements | ||
1657 | * | ||
1658 | * Set (static) TLV data for a virtual master volume using the AMP caps | ||
1659 | * obtained from the reference NID. | ||
1660 | * The volume range is recalculated as if the max volume is 0dB. | ||
1477 | */ | 1661 | */ |
1478 | void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir, | 1662 | void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir, |
1479 | unsigned int *tlv) | 1663 | unsigned int *tlv) |
@@ -1507,6 +1691,13 @@ _snd_hda_find_mixer_ctl(struct hda_codec *codec, | |||
1507 | return snd_ctl_find_id(codec->bus->card, &id); | 1691 | return snd_ctl_find_id(codec->bus->card, &id); |
1508 | } | 1692 | } |
1509 | 1693 | ||
1694 | /** | ||
1695 | * snd_hda_find_mixer_ctl - Find a mixer control element with the given name | ||
1696 | * @codec: HD-audio codec | ||
1697 | * @name: ctl id name string | ||
1698 | * | ||
1699 | * Get the control element with the given id string and IFACE_MIXER. | ||
1700 | */ | ||
1510 | struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, | 1701 | struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, |
1511 | const char *name) | 1702 | const char *name) |
1512 | { | 1703 | { |
@@ -1514,30 +1705,57 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, | |||
1514 | } | 1705 | } |
1515 | EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); | 1706 | EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); |
1516 | 1707 | ||
1517 | /* Add a control element and assign to the codec */ | 1708 | /** |
1518 | int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl) | 1709 | * snd_hda_ctl-add - Add a control element and assign to the codec |
1710 | * @codec: HD-audio codec | ||
1711 | * @nid: corresponding NID (optional) | ||
1712 | * @kctl: the control element to assign | ||
1713 | * | ||
1714 | * Add the given control element to an array inside the codec instance. | ||
1715 | * All control elements belonging to a codec are supposed to be added | ||
1716 | * by this function so that a proper clean-up works at the free or | ||
1717 | * reconfiguration time. | ||
1718 | * | ||
1719 | * If non-zero @nid is passed, the NID is assigned to the control element. | ||
1720 | * The assignment is shown in the codec proc file. | ||
1721 | * | ||
1722 | * snd_hda_ctl_add() checks the control subdev id field whether | ||
1723 | * #HDA_SUBDEV_NID_FLAG bit is set. If set (and @nid is zero), the lower | ||
1724 | * bits value is taken as the NID to assign. | ||
1725 | */ | ||
1726 | int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, | ||
1727 | struct snd_kcontrol *kctl) | ||
1519 | { | 1728 | { |
1520 | int err; | 1729 | int err; |
1521 | struct snd_kcontrol **knewp; | 1730 | struct hda_nid_item *item; |
1522 | 1731 | ||
1732 | if (kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) { | ||
1733 | if (nid == 0) | ||
1734 | nid = kctl->id.subdevice & 0xffff; | ||
1735 | kctl->id.subdevice = 0; | ||
1736 | } | ||
1523 | err = snd_ctl_add(codec->bus->card, kctl); | 1737 | err = snd_ctl_add(codec->bus->card, kctl); |
1524 | if (err < 0) | 1738 | if (err < 0) |
1525 | return err; | 1739 | return err; |
1526 | knewp = snd_array_new(&codec->mixers); | 1740 | item = snd_array_new(&codec->mixers); |
1527 | if (!knewp) | 1741 | if (!item) |
1528 | return -ENOMEM; | 1742 | return -ENOMEM; |
1529 | *knewp = kctl; | 1743 | item->kctl = kctl; |
1744 | item->nid = nid; | ||
1530 | return 0; | 1745 | return 0; |
1531 | } | 1746 | } |
1532 | EXPORT_SYMBOL_HDA(snd_hda_ctl_add); | 1747 | EXPORT_SYMBOL_HDA(snd_hda_ctl_add); |
1533 | 1748 | ||
1534 | /* Clear all controls assigned to the given codec */ | 1749 | /** |
1750 | * snd_hda_ctls_clear - Clear all controls assigned to the given codec | ||
1751 | * @codec: HD-audio codec | ||
1752 | */ | ||
1535 | void snd_hda_ctls_clear(struct hda_codec *codec) | 1753 | void snd_hda_ctls_clear(struct hda_codec *codec) |
1536 | { | 1754 | { |
1537 | int i; | 1755 | int i; |
1538 | struct snd_kcontrol **kctls = codec->mixers.list; | 1756 | struct hda_nid_item *items = codec->mixers.list; |
1539 | for (i = 0; i < codec->mixers.used; i++) | 1757 | for (i = 0; i < codec->mixers.used; i++) |
1540 | snd_ctl_remove(codec->bus->card, kctls[i]); | 1758 | snd_ctl_remove(codec->bus->card, items[i].kctl); |
1541 | snd_array_free(&codec->mixers); | 1759 | snd_array_free(&codec->mixers); |
1542 | } | 1760 | } |
1543 | 1761 | ||
@@ -1563,6 +1781,16 @@ static void hda_unlock_devices(struct snd_card *card) | |||
1563 | spin_unlock(&card->files_lock); | 1781 | spin_unlock(&card->files_lock); |
1564 | } | 1782 | } |
1565 | 1783 | ||
1784 | /** | ||
1785 | * snd_hda_codec_reset - Clear all objects assigned to the codec | ||
1786 | * @codec: HD-audio codec | ||
1787 | * | ||
1788 | * This frees the all PCM and control elements assigned to the codec, and | ||
1789 | * clears the caches and restores the pin default configurations. | ||
1790 | * | ||
1791 | * When a device is being used, it returns -EBSY. If successfully freed, | ||
1792 | * returns zero. | ||
1793 | */ | ||
1566 | int snd_hda_codec_reset(struct hda_codec *codec) | 1794 | int snd_hda_codec_reset(struct hda_codec *codec) |
1567 | { | 1795 | { |
1568 | struct snd_card *card = codec->bus->card; | 1796 | struct snd_card *card = codec->bus->card; |
@@ -1626,7 +1854,22 @@ int snd_hda_codec_reset(struct hda_codec *codec) | |||
1626 | return 0; | 1854 | return 0; |
1627 | } | 1855 | } |
1628 | 1856 | ||
1629 | /* create a virtual master control and add slaves */ | 1857 | /** |
1858 | * snd_hda_add_vmaster - create a virtual master control and add slaves | ||
1859 | * @codec: HD-audio codec | ||
1860 | * @name: vmaster control name | ||
1861 | * @tlv: TLV data (optional) | ||
1862 | * @slaves: slave control names (optional) | ||
1863 | * | ||
1864 | * Create a virtual master control with the given name. The TLV data | ||
1865 | * must be either NULL or a valid data. | ||
1866 | * | ||
1867 | * @slaves is a NULL-terminated array of strings, each of which is a | ||
1868 | * slave control name. All controls with these names are assigned to | ||
1869 | * the new virtual master control. | ||
1870 | * | ||
1871 | * This function returns zero if successful or a negative error code. | ||
1872 | */ | ||
1630 | int snd_hda_add_vmaster(struct hda_codec *codec, char *name, | 1873 | int snd_hda_add_vmaster(struct hda_codec *codec, char *name, |
1631 | unsigned int *tlv, const char **slaves) | 1874 | unsigned int *tlv, const char **slaves) |
1632 | { | 1875 | { |
@@ -1643,7 +1886,7 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name, | |||
1643 | kctl = snd_ctl_make_virtual_master(name, tlv); | 1886 | kctl = snd_ctl_make_virtual_master(name, tlv); |
1644 | if (!kctl) | 1887 | if (!kctl) |
1645 | return -ENOMEM; | 1888 | return -ENOMEM; |
1646 | err = snd_hda_ctl_add(codec, kctl); | 1889 | err = snd_hda_ctl_add(codec, 0, kctl); |
1647 | if (err < 0) | 1890 | if (err < 0) |
1648 | return err; | 1891 | return err; |
1649 | 1892 | ||
@@ -1668,7 +1911,12 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name, | |||
1668 | } | 1911 | } |
1669 | EXPORT_SYMBOL_HDA(snd_hda_add_vmaster); | 1912 | EXPORT_SYMBOL_HDA(snd_hda_add_vmaster); |
1670 | 1913 | ||
1671 | /* switch */ | 1914 | /** |
1915 | * snd_hda_mixer_amp_switch_info - Info callback for a standard AMP mixer switch | ||
1916 | * | ||
1917 | * The control element is supposed to have the private_value field | ||
1918 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1919 | */ | ||
1672 | int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, | 1920 | int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, |
1673 | struct snd_ctl_elem_info *uinfo) | 1921 | struct snd_ctl_elem_info *uinfo) |
1674 | { | 1922 | { |
@@ -1682,6 +1930,12 @@ int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, | |||
1682 | } | 1930 | } |
1683 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_info); | 1931 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_info); |
1684 | 1932 | ||
1933 | /** | ||
1934 | * snd_hda_mixer_amp_switch_get - Get callback for a standard AMP mixer switch | ||
1935 | * | ||
1936 | * The control element is supposed to have the private_value field | ||
1937 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1938 | */ | ||
1685 | int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, | 1939 | int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, |
1686 | struct snd_ctl_elem_value *ucontrol) | 1940 | struct snd_ctl_elem_value *ucontrol) |
1687 | { | 1941 | { |
@@ -1702,6 +1956,12 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, | |||
1702 | } | 1956 | } |
1703 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_get); | 1957 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_get); |
1704 | 1958 | ||
1959 | /** | ||
1960 | * snd_hda_mixer_amp_switch_put - Put callback for a standard AMP mixer switch | ||
1961 | * | ||
1962 | * The control element is supposed to have the private_value field | ||
1963 | * set up via HDA_COMPOSE_AMP_VAL*() or related macros. | ||
1964 | */ | ||
1705 | int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, | 1965 | int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, |
1706 | struct snd_ctl_elem_value *ucontrol) | 1966 | struct snd_ctl_elem_value *ucontrol) |
1707 | { | 1967 | { |
@@ -1733,6 +1993,25 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, | |||
1733 | } | 1993 | } |
1734 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put); | 1994 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put); |
1735 | 1995 | ||
1996 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
1997 | /** | ||
1998 | * snd_hda_mixer_amp_switch_put_beep - Put callback for a beep AMP switch | ||
1999 | * | ||
2000 | * This function calls snd_hda_enable_beep_device(), which behaves differently | ||
2001 | * depending on beep_mode option. | ||
2002 | */ | ||
2003 | int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol, | ||
2004 | struct snd_ctl_elem_value *ucontrol) | ||
2005 | { | ||
2006 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2007 | long *valp = ucontrol->value.integer.value; | ||
2008 | |||
2009 | snd_hda_enable_beep_device(codec, *valp); | ||
2010 | return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); | ||
2011 | } | ||
2012 | EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep); | ||
2013 | #endif /* CONFIG_SND_HDA_INPUT_BEEP */ | ||
2014 | |||
1736 | /* | 2015 | /* |
1737 | * bound volume controls | 2016 | * bound volume controls |
1738 | * | 2017 | * |
@@ -1742,6 +2021,12 @@ EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put); | |||
1742 | #define AMP_VAL_IDX_SHIFT 19 | 2021 | #define AMP_VAL_IDX_SHIFT 19 |
1743 | #define AMP_VAL_IDX_MASK (0x0f<<19) | 2022 | #define AMP_VAL_IDX_MASK (0x0f<<19) |
1744 | 2023 | ||
2024 | /** | ||
2025 | * snd_hda_mixer_bind_switch_get - Get callback for a bound volume control | ||
2026 | * | ||
2027 | * The control element is supposed to have the private_value field | ||
2028 | * set up via HDA_BIND_MUTE*() macros. | ||
2029 | */ | ||
1745 | int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, | 2030 | int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, |
1746 | struct snd_ctl_elem_value *ucontrol) | 2031 | struct snd_ctl_elem_value *ucontrol) |
1747 | { | 2032 | { |
@@ -1759,6 +2044,12 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, | |||
1759 | } | 2044 | } |
1760 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get); | 2045 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get); |
1761 | 2046 | ||
2047 | /** | ||
2048 | * snd_hda_mixer_bind_switch_put - Put callback for a bound volume control | ||
2049 | * | ||
2050 | * The control element is supposed to have the private_value field | ||
2051 | * set up via HDA_BIND_MUTE*() macros. | ||
2052 | */ | ||
1762 | int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, | 2053 | int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, |
1763 | struct snd_ctl_elem_value *ucontrol) | 2054 | struct snd_ctl_elem_value *ucontrol) |
1764 | { | 2055 | { |
@@ -1783,8 +2074,11 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, | |||
1783 | } | 2074 | } |
1784 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put); | 2075 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put); |
1785 | 2076 | ||
1786 | /* | 2077 | /** |
1787 | * generic bound volume/swtich controls | 2078 | * snd_hda_mixer_bind_ctls_info - Info callback for a generic bound control |
2079 | * | ||
2080 | * The control element is supposed to have the private_value field | ||
2081 | * set up via HDA_BIND_VOL() or HDA_BIND_SW() macros. | ||
1788 | */ | 2082 | */ |
1789 | int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, | 2083 | int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, |
1790 | struct snd_ctl_elem_info *uinfo) | 2084 | struct snd_ctl_elem_info *uinfo) |
@@ -1803,6 +2097,12 @@ int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, | |||
1803 | } | 2097 | } |
1804 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info); | 2098 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info); |
1805 | 2099 | ||
2100 | /** | ||
2101 | * snd_hda_mixer_bind_ctls_get - Get callback for a generic bound control | ||
2102 | * | ||
2103 | * The control element is supposed to have the private_value field | ||
2104 | * set up via HDA_BIND_VOL() or HDA_BIND_SW() macros. | ||
2105 | */ | ||
1806 | int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, | 2106 | int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, |
1807 | struct snd_ctl_elem_value *ucontrol) | 2107 | struct snd_ctl_elem_value *ucontrol) |
1808 | { | 2108 | { |
@@ -1820,6 +2120,12 @@ int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, | |||
1820 | } | 2120 | } |
1821 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get); | 2121 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get); |
1822 | 2122 | ||
2123 | /** | ||
2124 | * snd_hda_mixer_bind_ctls_put - Put callback for a generic bound control | ||
2125 | * | ||
2126 | * The control element is supposed to have the private_value field | ||
2127 | * set up via HDA_BIND_VOL() or HDA_BIND_SW() macros. | ||
2128 | */ | ||
1823 | int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, | 2129 | int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, |
1824 | struct snd_ctl_elem_value *ucontrol) | 2130 | struct snd_ctl_elem_value *ucontrol) |
1825 | { | 2131 | { |
@@ -1843,6 +2149,12 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, | |||
1843 | } | 2149 | } |
1844 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put); | 2150 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put); |
1845 | 2151 | ||
2152 | /** | ||
2153 | * snd_hda_mixer_bind_tlv - TLV callback for a generic bound control | ||
2154 | * | ||
2155 | * The control element is supposed to have the private_value field | ||
2156 | * set up via HDA_BIND_VOL() macro. | ||
2157 | */ | ||
1846 | int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, | 2158 | int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
1847 | unsigned int size, unsigned int __user *tlv) | 2159 | unsigned int size, unsigned int __user *tlv) |
1848 | { | 2160 | { |
@@ -2126,7 +2438,7 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) | |||
2126 | return -ENOMEM; | 2438 | return -ENOMEM; |
2127 | kctl->id.index = idx; | 2439 | kctl->id.index = idx; |
2128 | kctl->private_value = nid; | 2440 | kctl->private_value = nid; |
2129 | err = snd_hda_ctl_add(codec, kctl); | 2441 | err = snd_hda_ctl_add(codec, nid, kctl); |
2130 | if (err < 0) | 2442 | if (err < 0) |
2131 | return err; | 2443 | return err; |
2132 | } | 2444 | } |
@@ -2165,14 +2477,19 @@ static struct snd_kcontrol_new spdif_share_sw = { | |||
2165 | .put = spdif_share_sw_put, | 2477 | .put = spdif_share_sw_put, |
2166 | }; | 2478 | }; |
2167 | 2479 | ||
2480 | /** | ||
2481 | * snd_hda_create_spdif_share_sw - create Default PCM switch | ||
2482 | * @codec: the HDA codec | ||
2483 | * @mout: multi-out instance | ||
2484 | */ | ||
2168 | int snd_hda_create_spdif_share_sw(struct hda_codec *codec, | 2485 | int snd_hda_create_spdif_share_sw(struct hda_codec *codec, |
2169 | struct hda_multi_out *mout) | 2486 | struct hda_multi_out *mout) |
2170 | { | 2487 | { |
2171 | if (!mout->dig_out_nid) | 2488 | if (!mout->dig_out_nid) |
2172 | return 0; | 2489 | return 0; |
2173 | /* ATTENTION: here mout is passed as private_data, instead of codec */ | 2490 | /* ATTENTION: here mout is passed as private_data, instead of codec */ |
2174 | return snd_hda_ctl_add(codec, | 2491 | return snd_hda_ctl_add(codec, mout->dig_out_nid, |
2175 | snd_ctl_new1(&spdif_share_sw, mout)); | 2492 | snd_ctl_new1(&spdif_share_sw, mout)); |
2176 | } | 2493 | } |
2177 | EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw); | 2494 | EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw); |
2178 | 2495 | ||
@@ -2276,7 +2593,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) | |||
2276 | if (!kctl) | 2593 | if (!kctl) |
2277 | return -ENOMEM; | 2594 | return -ENOMEM; |
2278 | kctl->private_value = nid; | 2595 | kctl->private_value = nid; |
2279 | err = snd_hda_ctl_add(codec, kctl); | 2596 | err = snd_hda_ctl_add(codec, nid, kctl); |
2280 | if (err < 0) | 2597 | if (err < 0) |
2281 | return err; | 2598 | return err; |
2282 | } | 2599 | } |
@@ -2332,7 +2649,12 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, | |||
2332 | } | 2649 | } |
2333 | EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); | 2650 | EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); |
2334 | 2651 | ||
2335 | /* resume the all commands from the cache */ | 2652 | /** |
2653 | * snd_hda_codec_resume_cache - Resume the all commands from the cache | ||
2654 | * @codec: HD-audio codec | ||
2655 | * | ||
2656 | * Execute all verbs recorded in the command caches to resume. | ||
2657 | */ | ||
2336 | void snd_hda_codec_resume_cache(struct hda_codec *codec) | 2658 | void snd_hda_codec_resume_cache(struct hda_codec *codec) |
2337 | { | 2659 | { |
2338 | struct hda_cache_head *buffer = codec->cmd_cache.buf.list; | 2660 | struct hda_cache_head *buffer = codec->cmd_cache.buf.list; |
@@ -2452,9 +2774,11 @@ static void hda_call_codec_suspend(struct hda_codec *codec) | |||
2452 | codec->afg ? codec->afg : codec->mfg, | 2774 | codec->afg ? codec->afg : codec->mfg, |
2453 | AC_PWRST_D3); | 2775 | AC_PWRST_D3); |
2454 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2776 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2777 | snd_hda_update_power_acct(codec); | ||
2455 | cancel_delayed_work(&codec->power_work); | 2778 | cancel_delayed_work(&codec->power_work); |
2456 | codec->power_on = 0; | 2779 | codec->power_on = 0; |
2457 | codec->power_transition = 0; | 2780 | codec->power_transition = 0; |
2781 | codec->power_jiffies = jiffies; | ||
2458 | #endif | 2782 | #endif |
2459 | } | 2783 | } |
2460 | 2784 | ||
@@ -2756,8 +3080,12 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, | |||
2756 | } | 3080 | } |
2757 | 3081 | ||
2758 | /** | 3082 | /** |
2759 | * snd_hda_is_supported_format - check whether the given node supports | 3083 | * snd_hda_is_supported_format - Check the validity of the format |
2760 | * the format val | 3084 | * @codec: HD-audio codec |
3085 | * @nid: NID to check | ||
3086 | * @format: the HD-audio format value to check | ||
3087 | * | ||
3088 | * Check whether the given node supports the format value. | ||
2761 | * | 3089 | * |
2762 | * Returns 1 if supported, 0 if not. | 3090 | * Returns 1 if supported, 0 if not. |
2763 | */ | 3091 | */ |
@@ -2877,51 +3205,36 @@ static int set_pcm_default_values(struct hda_codec *codec, | |||
2877 | return 0; | 3205 | return 0; |
2878 | } | 3206 | } |
2879 | 3207 | ||
3208 | /* global */ | ||
3209 | const char *snd_hda_pcm_type_name[HDA_PCM_NTYPES] = { | ||
3210 | "Audio", "SPDIF", "HDMI", "Modem" | ||
3211 | }; | ||
3212 | |||
2880 | /* | 3213 | /* |
2881 | * get the empty PCM device number to assign | 3214 | * get the empty PCM device number to assign |
2882 | */ | 3215 | */ |
2883 | static int get_empty_pcm_device(struct hda_bus *bus, int type) | 3216 | static int get_empty_pcm_device(struct hda_bus *bus, int type) |
2884 | { | 3217 | { |
2885 | static const char *dev_name[HDA_PCM_NTYPES] = { | 3218 | /* audio device indices; not linear to keep compatibility */ |
2886 | "Audio", "SPDIF", "HDMI", "Modem" | 3219 | static int audio_idx[HDA_PCM_NTYPES][5] = { |
2887 | }; | 3220 | [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 }, |
2888 | /* starting device index for each PCM type */ | 3221 | [HDA_PCM_TYPE_SPDIF] = { 1, -1 }, |
2889 | static int dev_idx[HDA_PCM_NTYPES] = { | 3222 | [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 }, |
2890 | [HDA_PCM_TYPE_AUDIO] = 0, | 3223 | [HDA_PCM_TYPE_MODEM] = { 6, -1 }, |
2891 | [HDA_PCM_TYPE_SPDIF] = 1, | ||
2892 | [HDA_PCM_TYPE_HDMI] = 3, | ||
2893 | [HDA_PCM_TYPE_MODEM] = 6 | ||
2894 | }; | 3224 | }; |
2895 | /* normal audio device indices; not linear to keep compatibility */ | 3225 | int i; |
2896 | static int audio_idx[4] = { 0, 2, 4, 5 }; | 3226 | |
2897 | int i, dev; | 3227 | if (type >= HDA_PCM_NTYPES) { |
2898 | |||
2899 | switch (type) { | ||
2900 | case HDA_PCM_TYPE_AUDIO: | ||
2901 | for (i = 0; i < ARRAY_SIZE(audio_idx); i++) { | ||
2902 | dev = audio_idx[i]; | ||
2903 | if (!test_bit(dev, bus->pcm_dev_bits)) | ||
2904 | goto ok; | ||
2905 | } | ||
2906 | snd_printk(KERN_WARNING "Too many audio devices\n"); | ||
2907 | return -EAGAIN; | ||
2908 | case HDA_PCM_TYPE_SPDIF: | ||
2909 | case HDA_PCM_TYPE_HDMI: | ||
2910 | case HDA_PCM_TYPE_MODEM: | ||
2911 | dev = dev_idx[type]; | ||
2912 | if (test_bit(dev, bus->pcm_dev_bits)) { | ||
2913 | snd_printk(KERN_WARNING "%s already defined\n", | ||
2914 | dev_name[type]); | ||
2915 | return -EAGAIN; | ||
2916 | } | ||
2917 | break; | ||
2918 | default: | ||
2919 | snd_printk(KERN_WARNING "Invalid PCM type %d\n", type); | 3228 | snd_printk(KERN_WARNING "Invalid PCM type %d\n", type); |
2920 | return -EINVAL; | 3229 | return -EINVAL; |
2921 | } | 3230 | } |
2922 | ok: | 3231 | |
2923 | set_bit(dev, bus->pcm_dev_bits); | 3232 | for (i = 0; audio_idx[type][i] >= 0 ; i++) |
2924 | return dev; | 3233 | if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) |
3234 | return audio_idx[type][i]; | ||
3235 | |||
3236 | snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]); | ||
3237 | return -EAGAIN; | ||
2925 | } | 3238 | } |
2926 | 3239 | ||
2927 | /* | 3240 | /* |
@@ -3159,14 +3472,14 @@ EXPORT_SYMBOL_HDA(snd_hda_check_board_codec_sid_config); | |||
3159 | */ | 3472 | */ |
3160 | int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) | 3473 | int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) |
3161 | { | 3474 | { |
3162 | int err; | 3475 | int err; |
3163 | 3476 | ||
3164 | for (; knew->name; knew++) { | 3477 | for (; knew->name; knew++) { |
3165 | struct snd_kcontrol *kctl; | 3478 | struct snd_kcontrol *kctl; |
3166 | kctl = snd_ctl_new1(knew, codec); | 3479 | kctl = snd_ctl_new1(knew, codec); |
3167 | if (!kctl) | 3480 | if (!kctl) |
3168 | return -ENOMEM; | 3481 | return -ENOMEM; |
3169 | err = snd_hda_ctl_add(codec, kctl); | 3482 | err = snd_hda_ctl_add(codec, 0, kctl); |
3170 | if (err < 0) { | 3483 | if (err < 0) { |
3171 | if (!codec->addr) | 3484 | if (!codec->addr) |
3172 | return err; | 3485 | return err; |
@@ -3174,7 +3487,7 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) | |||
3174 | if (!kctl) | 3487 | if (!kctl) |
3175 | return -ENOMEM; | 3488 | return -ENOMEM; |
3176 | kctl->id.device = codec->addr; | 3489 | kctl->id.device = codec->addr; |
3177 | err = snd_hda_ctl_add(codec, kctl); | 3490 | err = snd_hda_ctl_add(codec, 0, kctl); |
3178 | if (err < 0) | 3491 | if (err < 0) |
3179 | return err; | 3492 | return err; |
3180 | } | 3493 | } |
@@ -3207,8 +3520,27 @@ static void hda_keep_power_on(struct hda_codec *codec) | |||
3207 | { | 3520 | { |
3208 | codec->power_count++; | 3521 | codec->power_count++; |
3209 | codec->power_on = 1; | 3522 | codec->power_on = 1; |
3523 | codec->power_jiffies = jiffies; | ||
3210 | } | 3524 | } |
3211 | 3525 | ||
3526 | /* update the power on/off account with the current jiffies */ | ||
3527 | void snd_hda_update_power_acct(struct hda_codec *codec) | ||
3528 | { | ||
3529 | unsigned long delta = jiffies - codec->power_jiffies; | ||
3530 | if (codec->power_on) | ||
3531 | codec->power_on_acct += delta; | ||
3532 | else | ||
3533 | codec->power_off_acct += delta; | ||
3534 | codec->power_jiffies += delta; | ||
3535 | } | ||
3536 | |||
3537 | /** | ||
3538 | * snd_hda_power_up - Power-up the codec | ||
3539 | * @codec: HD-audio codec | ||
3540 | * | ||
3541 | * Increment the power-up counter and power up the hardware really when | ||
3542 | * not turned on yet. | ||
3543 | */ | ||
3212 | void snd_hda_power_up(struct hda_codec *codec) | 3544 | void snd_hda_power_up(struct hda_codec *codec) |
3213 | { | 3545 | { |
3214 | struct hda_bus *bus = codec->bus; | 3546 | struct hda_bus *bus = codec->bus; |
@@ -3217,7 +3549,9 @@ void snd_hda_power_up(struct hda_codec *codec) | |||
3217 | if (codec->power_on || codec->power_transition) | 3549 | if (codec->power_on || codec->power_transition) |
3218 | return; | 3550 | return; |
3219 | 3551 | ||
3552 | snd_hda_update_power_acct(codec); | ||
3220 | codec->power_on = 1; | 3553 | codec->power_on = 1; |
3554 | codec->power_jiffies = jiffies; | ||
3221 | if (bus->ops.pm_notify) | 3555 | if (bus->ops.pm_notify) |
3222 | bus->ops.pm_notify(bus); | 3556 | bus->ops.pm_notify(bus); |
3223 | hda_call_codec_resume(codec); | 3557 | hda_call_codec_resume(codec); |
@@ -3229,9 +3563,13 @@ EXPORT_SYMBOL_HDA(snd_hda_power_up); | |||
3229 | #define power_save(codec) \ | 3563 | #define power_save(codec) \ |
3230 | ((codec)->bus->power_save ? *(codec)->bus->power_save : 0) | 3564 | ((codec)->bus->power_save ? *(codec)->bus->power_save : 0) |
3231 | 3565 | ||
3232 | #define power_save(codec) \ | 3566 | /** |
3233 | ((codec)->bus->power_save ? *(codec)->bus->power_save : 0) | 3567 | * snd_hda_power_down - Power-down the codec |
3234 | 3568 | * @codec: HD-audio codec | |
3569 | * | ||
3570 | * Decrement the power-up counter and schedules the power-off work if | ||
3571 | * the counter rearches to zero. | ||
3572 | */ | ||
3235 | void snd_hda_power_down(struct hda_codec *codec) | 3573 | void snd_hda_power_down(struct hda_codec *codec) |
3236 | { | 3574 | { |
3237 | --codec->power_count; | 3575 | --codec->power_count; |
@@ -3245,6 +3583,19 @@ void snd_hda_power_down(struct hda_codec *codec) | |||
3245 | } | 3583 | } |
3246 | EXPORT_SYMBOL_HDA(snd_hda_power_down); | 3584 | EXPORT_SYMBOL_HDA(snd_hda_power_down); |
3247 | 3585 | ||
3586 | /** | ||
3587 | * snd_hda_check_amp_list_power - Check the amp list and update the power | ||
3588 | * @codec: HD-audio codec | ||
3589 | * @check: the object containing an AMP list and the status | ||
3590 | * @nid: NID to check / update | ||
3591 | * | ||
3592 | * Check whether the given NID is in the amp list. If it's in the list, | ||
3593 | * check the current AMP status, and update the the power-status according | ||
3594 | * to the mute status. | ||
3595 | * | ||
3596 | * This function is supposed to be set or called from the check_power_status | ||
3597 | * patch ops. | ||
3598 | */ | ||
3248 | int snd_hda_check_amp_list_power(struct hda_codec *codec, | 3599 | int snd_hda_check_amp_list_power(struct hda_codec *codec, |
3249 | struct hda_loopback_check *check, | 3600 | struct hda_loopback_check *check, |
3250 | hda_nid_t nid) | 3601 | hda_nid_t nid) |
@@ -3286,6 +3637,10 @@ EXPORT_SYMBOL_HDA(snd_hda_check_amp_list_power); | |||
3286 | /* | 3637 | /* |
3287 | * Channel mode helper | 3638 | * Channel mode helper |
3288 | */ | 3639 | */ |
3640 | |||
3641 | /** | ||
3642 | * snd_hda_ch_mode_info - Info callback helper for the channel mode enum | ||
3643 | */ | ||
3289 | int snd_hda_ch_mode_info(struct hda_codec *codec, | 3644 | int snd_hda_ch_mode_info(struct hda_codec *codec, |
3290 | struct snd_ctl_elem_info *uinfo, | 3645 | struct snd_ctl_elem_info *uinfo, |
3291 | const struct hda_channel_mode *chmode, | 3646 | const struct hda_channel_mode *chmode, |
@@ -3302,6 +3657,9 @@ int snd_hda_ch_mode_info(struct hda_codec *codec, | |||
3302 | } | 3657 | } |
3303 | EXPORT_SYMBOL_HDA(snd_hda_ch_mode_info); | 3658 | EXPORT_SYMBOL_HDA(snd_hda_ch_mode_info); |
3304 | 3659 | ||
3660 | /** | ||
3661 | * snd_hda_ch_mode_get - Get callback helper for the channel mode enum | ||
3662 | */ | ||
3305 | int snd_hda_ch_mode_get(struct hda_codec *codec, | 3663 | int snd_hda_ch_mode_get(struct hda_codec *codec, |
3306 | struct snd_ctl_elem_value *ucontrol, | 3664 | struct snd_ctl_elem_value *ucontrol, |
3307 | const struct hda_channel_mode *chmode, | 3665 | const struct hda_channel_mode *chmode, |
@@ -3320,6 +3678,9 @@ int snd_hda_ch_mode_get(struct hda_codec *codec, | |||
3320 | } | 3678 | } |
3321 | EXPORT_SYMBOL_HDA(snd_hda_ch_mode_get); | 3679 | EXPORT_SYMBOL_HDA(snd_hda_ch_mode_get); |
3322 | 3680 | ||
3681 | /** | ||
3682 | * snd_hda_ch_mode_put - Put callback helper for the channel mode enum | ||
3683 | */ | ||
3323 | int snd_hda_ch_mode_put(struct hda_codec *codec, | 3684 | int snd_hda_ch_mode_put(struct hda_codec *codec, |
3324 | struct snd_ctl_elem_value *ucontrol, | 3685 | struct snd_ctl_elem_value *ucontrol, |
3325 | const struct hda_channel_mode *chmode, | 3686 | const struct hda_channel_mode *chmode, |
@@ -3344,6 +3705,10 @@ EXPORT_SYMBOL_HDA(snd_hda_ch_mode_put); | |||
3344 | /* | 3705 | /* |
3345 | * input MUX helper | 3706 | * input MUX helper |
3346 | */ | 3707 | */ |
3708 | |||
3709 | /** | ||
3710 | * snd_hda_input_mux_info_info - Info callback helper for the input-mux enum | ||
3711 | */ | ||
3347 | int snd_hda_input_mux_info(const struct hda_input_mux *imux, | 3712 | int snd_hda_input_mux_info(const struct hda_input_mux *imux, |
3348 | struct snd_ctl_elem_info *uinfo) | 3713 | struct snd_ctl_elem_info *uinfo) |
3349 | { | 3714 | { |
@@ -3362,6 +3727,9 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux, | |||
3362 | } | 3727 | } |
3363 | EXPORT_SYMBOL_HDA(snd_hda_input_mux_info); | 3728 | EXPORT_SYMBOL_HDA(snd_hda_input_mux_info); |
3364 | 3729 | ||
3730 | /** | ||
3731 | * snd_hda_input_mux_info_put - Put callback helper for the input-mux enum | ||
3732 | */ | ||
3365 | int snd_hda_input_mux_put(struct hda_codec *codec, | 3733 | int snd_hda_input_mux_put(struct hda_codec *codec, |
3366 | const struct hda_input_mux *imux, | 3734 | const struct hda_input_mux *imux, |
3367 | struct snd_ctl_elem_value *ucontrol, | 3735 | struct snd_ctl_elem_value *ucontrol, |
@@ -3421,8 +3789,29 @@ static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid) | |||
3421 | } | 3789 | } |
3422 | } | 3790 | } |
3423 | 3791 | ||
3424 | /* | 3792 | /** |
3425 | * open the digital out in the exclusive mode | 3793 | * snd_hda_bus_reboot_notify - call the reboot notifier of each codec |
3794 | * @bus: HD-audio bus | ||
3795 | */ | ||
3796 | void snd_hda_bus_reboot_notify(struct hda_bus *bus) | ||
3797 | { | ||
3798 | struct hda_codec *codec; | ||
3799 | |||
3800 | if (!bus) | ||
3801 | return; | ||
3802 | list_for_each_entry(codec, &bus->codec_list, list) { | ||
3803 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3804 | if (!codec->power_on) | ||
3805 | continue; | ||
3806 | #endif | ||
3807 | if (codec->patch_ops.reboot_notify) | ||
3808 | codec->patch_ops.reboot_notify(codec); | ||
3809 | } | ||
3810 | } | ||
3811 | EXPORT_SYMBOL_HDA(snd_hda_bus_reboot_notify); | ||
3812 | |||
3813 | /** | ||
3814 | * snd_hda_multi_out_dig_open - open the digital out in the exclusive mode | ||
3426 | */ | 3815 | */ |
3427 | int snd_hda_multi_out_dig_open(struct hda_codec *codec, | 3816 | int snd_hda_multi_out_dig_open(struct hda_codec *codec, |
3428 | struct hda_multi_out *mout) | 3817 | struct hda_multi_out *mout) |
@@ -3437,6 +3826,9 @@ int snd_hda_multi_out_dig_open(struct hda_codec *codec, | |||
3437 | } | 3826 | } |
3438 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_open); | 3827 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_open); |
3439 | 3828 | ||
3829 | /** | ||
3830 | * snd_hda_multi_out_dig_prepare - prepare the digital out stream | ||
3831 | */ | ||
3440 | int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, | 3832 | int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, |
3441 | struct hda_multi_out *mout, | 3833 | struct hda_multi_out *mout, |
3442 | unsigned int stream_tag, | 3834 | unsigned int stream_tag, |
@@ -3450,6 +3842,9 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, | |||
3450 | } | 3842 | } |
3451 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare); | 3843 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare); |
3452 | 3844 | ||
3845 | /** | ||
3846 | * snd_hda_multi_out_dig_cleanup - clean-up the digital out stream | ||
3847 | */ | ||
3453 | int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec, | 3848 | int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec, |
3454 | struct hda_multi_out *mout) | 3849 | struct hda_multi_out *mout) |
3455 | { | 3850 | { |
@@ -3460,8 +3855,8 @@ int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec, | |||
3460 | } | 3855 | } |
3461 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_cleanup); | 3856 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_cleanup); |
3462 | 3857 | ||
3463 | /* | 3858 | /** |
3464 | * release the digital out | 3859 | * snd_hda_multi_out_dig_close - release the digital out stream |
3465 | */ | 3860 | */ |
3466 | int snd_hda_multi_out_dig_close(struct hda_codec *codec, | 3861 | int snd_hda_multi_out_dig_close(struct hda_codec *codec, |
3467 | struct hda_multi_out *mout) | 3862 | struct hda_multi_out *mout) |
@@ -3473,8 +3868,12 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec, | |||
3473 | } | 3868 | } |
3474 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_close); | 3869 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_close); |
3475 | 3870 | ||
3476 | /* | 3871 | /** |
3477 | * set up more restrictions for analog out | 3872 | * snd_hda_multi_out_analog_open - open analog outputs |
3873 | * | ||
3874 | * Open analog outputs and set up the hw-constraints. | ||
3875 | * If the digital outputs can be opened as slave, open the digital | ||
3876 | * outputs, too. | ||
3478 | */ | 3877 | */ |
3479 | int snd_hda_multi_out_analog_open(struct hda_codec *codec, | 3878 | int snd_hda_multi_out_analog_open(struct hda_codec *codec, |
3480 | struct hda_multi_out *mout, | 3879 | struct hda_multi_out *mout, |
@@ -3519,9 +3918,11 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, | |||
3519 | } | 3918 | } |
3520 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_open); | 3919 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_open); |
3521 | 3920 | ||
3522 | /* | 3921 | /** |
3523 | * set up the i/o for analog out | 3922 | * snd_hda_multi_out_analog_prepare - Preapre the analog outputs. |
3524 | * when the digital out is available, copy the front out to digital out, too. | 3923 | * |
3924 | * Set up the i/o for analog out. | ||
3925 | * When the digital out is available, copy the front out to digital out, too. | ||
3525 | */ | 3926 | */ |
3526 | int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, | 3927 | int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, |
3527 | struct hda_multi_out *mout, | 3928 | struct hda_multi_out *mout, |
@@ -3578,8 +3979,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, | |||
3578 | } | 3979 | } |
3579 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare); | 3980 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare); |
3580 | 3981 | ||
3581 | /* | 3982 | /** |
3582 | * clean up the setting for analog out | 3983 | * snd_hda_multi_out_analog_cleanup - clean up the setting for analog out |
3583 | */ | 3984 | */ |
3584 | int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, | 3985 | int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, |
3585 | struct hda_multi_out *mout) | 3986 | struct hda_multi_out *mout) |
@@ -3965,8 +4366,14 @@ EXPORT_SYMBOL_HDA(snd_hda_resume); | |||
3965 | * generic arrays | 4366 | * generic arrays |
3966 | */ | 4367 | */ |
3967 | 4368 | ||
3968 | /* get a new element from the given array | 4369 | /** |
3969 | * if it exceeds the pre-allocated array size, re-allocate the array | 4370 | * snd_array_new - get a new element from the given array |
4371 | * @array: the array object | ||
4372 | * | ||
4373 | * Get a new element from the given array. If it exceeds the | ||
4374 | * pre-allocated array size, re-allocate the array. | ||
4375 | * | ||
4376 | * Returns NULL if allocation failed. | ||
3970 | */ | 4377 | */ |
3971 | void *snd_array_new(struct snd_array *array) | 4378 | void *snd_array_new(struct snd_array *array) |
3972 | { | 4379 | { |
@@ -3990,7 +4397,10 @@ void *snd_array_new(struct snd_array *array) | |||
3990 | } | 4397 | } |
3991 | EXPORT_SYMBOL_HDA(snd_array_new); | 4398 | EXPORT_SYMBOL_HDA(snd_array_new); |
3992 | 4399 | ||
3993 | /* free the given array elements */ | 4400 | /** |
4401 | * snd_array_free - free the given array elements | ||
4402 | * @array: the array object | ||
4403 | */ | ||
3994 | void snd_array_free(struct snd_array *array) | 4404 | void snd_array_free(struct snd_array *array) |
3995 | { | 4405 | { |
3996 | kfree(array->list); | 4406 | kfree(array->list); |
@@ -4000,7 +4410,12 @@ void snd_array_free(struct snd_array *array) | |||
4000 | } | 4410 | } |
4001 | EXPORT_SYMBOL_HDA(snd_array_free); | 4411 | EXPORT_SYMBOL_HDA(snd_array_free); |
4002 | 4412 | ||
4003 | /* | 4413 | /** |
4414 | * snd_print_pcm_rates - Print the supported PCM rates to the string buffer | ||
4415 | * @pcm: PCM caps bits | ||
4416 | * @buf: the string buffer to write | ||
4417 | * @buflen: the max buffer length | ||
4418 | * | ||
4004 | * used by hda_proc.c and hda_eld.c | 4419 | * used by hda_proc.c and hda_eld.c |
4005 | */ | 4420 | */ |
4006 | void snd_print_pcm_rates(int pcm, char *buf, int buflen) | 4421 | void snd_print_pcm_rates(int pcm, char *buf, int buflen) |
@@ -4019,6 +4434,14 @@ void snd_print_pcm_rates(int pcm, char *buf, int buflen) | |||
4019 | } | 4434 | } |
4020 | EXPORT_SYMBOL_HDA(snd_print_pcm_rates); | 4435 | EXPORT_SYMBOL_HDA(snd_print_pcm_rates); |
4021 | 4436 | ||
4437 | /** | ||
4438 | * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer | ||
4439 | * @pcm: PCM caps bits | ||
4440 | * @buf: the string buffer to write | ||
4441 | * @buflen: the max buffer length | ||
4442 | * | ||
4443 | * used by hda_proc.c and hda_eld.c | ||
4444 | */ | ||
4022 | void snd_print_pcm_bits(int pcm, char *buf, int buflen) | 4445 | void snd_print_pcm_bits(int pcm, char *buf, int buflen) |
4023 | { | 4446 | { |
4024 | static unsigned int bits[] = { 8, 16, 20, 24, 32 }; | 4447 | static unsigned int bits[] = { 8, 16, 20, 24, 32 }; |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 99552fb5f756..1d541b7f5547 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -255,9 +255,13 @@ enum { | |||
255 | * in HD-audio specification | 255 | * in HD-audio specification |
256 | */ | 256 | */ |
257 | #define AC_PINCAP_HDMI (1<<7) /* HDMI pin */ | 257 | #define AC_PINCAP_HDMI (1<<7) /* HDMI pin */ |
258 | #define AC_PINCAP_DP (1<<24) /* DisplayPort pin, can | ||
259 | * coexist with AC_PINCAP_HDMI | ||
260 | */ | ||
258 | #define AC_PINCAP_VREF (0x37<<8) | 261 | #define AC_PINCAP_VREF (0x37<<8) |
259 | #define AC_PINCAP_VREF_SHIFT 8 | 262 | #define AC_PINCAP_VREF_SHIFT 8 |
260 | #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ | 263 | #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ |
264 | #define AC_PINCAP_HBR (1<<27) /* High Bit Rate */ | ||
261 | /* Vref status (used in pin cap) */ | 265 | /* Vref status (used in pin cap) */ |
262 | #define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */ | 266 | #define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */ |
263 | #define AC_PINCAP_VREF_50 (1<<1) /* 50% */ | 267 | #define AC_PINCAP_VREF_50 (1<<1) /* 50% */ |
@@ -286,6 +290,10 @@ enum { | |||
286 | #define AC_PWRST_D1SUP (1<<1) | 290 | #define AC_PWRST_D1SUP (1<<1) |
287 | #define AC_PWRST_D2SUP (1<<2) | 291 | #define AC_PWRST_D2SUP (1<<2) |
288 | #define AC_PWRST_D3SUP (1<<3) | 292 | #define AC_PWRST_D3SUP (1<<3) |
293 | #define AC_PWRST_D3COLDSUP (1<<4) | ||
294 | #define AC_PWRST_S3D3COLDSUP (1<<29) | ||
295 | #define AC_PWRST_CLKSTOP (1<<30) | ||
296 | #define AC_PWRST_EPSS (1U<<31) | ||
289 | 297 | ||
290 | /* Power state values */ | 298 | /* Power state values */ |
291 | #define AC_PWRST_SETTING (0xf<<0) | 299 | #define AC_PWRST_SETTING (0xf<<0) |
@@ -631,6 +639,7 @@ struct hda_bus { | |||
631 | unsigned int rirb_error:1; /* error in codec communication */ | 639 | unsigned int rirb_error:1; /* error in codec communication */ |
632 | unsigned int response_reset:1; /* controller was reset */ | 640 | unsigned int response_reset:1; /* controller was reset */ |
633 | unsigned int in_reset:1; /* during reset operation */ | 641 | unsigned int in_reset:1; /* during reset operation */ |
642 | unsigned int power_keep_link_on:1; /* don't power off HDA link */ | ||
634 | }; | 643 | }; |
635 | 644 | ||
636 | /* | 645 | /* |
@@ -674,6 +683,7 @@ struct hda_codec_ops { | |||
674 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 683 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
675 | int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid); | 684 | int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid); |
676 | #endif | 685 | #endif |
686 | void (*reboot_notify)(struct hda_codec *codec); | ||
677 | }; | 687 | }; |
678 | 688 | ||
679 | /* record for amp information cache */ | 689 | /* record for amp information cache */ |
@@ -771,6 +781,7 @@ struct hda_codec { | |||
771 | 781 | ||
772 | /* beep device */ | 782 | /* beep device */ |
773 | struct hda_beep *beep; | 783 | struct hda_beep *beep; |
784 | unsigned int beep_mode; | ||
774 | 785 | ||
775 | /* widget capabilities cache */ | 786 | /* widget capabilities cache */ |
776 | unsigned int num_nodes; | 787 | unsigned int num_nodes; |
@@ -811,6 +822,9 @@ struct hda_codec { | |||
811 | unsigned int power_transition :1; /* power-state in transition */ | 822 | unsigned int power_transition :1; /* power-state in transition */ |
812 | int power_count; /* current (global) power refcount */ | 823 | int power_count; /* current (global) power refcount */ |
813 | struct delayed_work power_work; /* delayed task for powerdown */ | 824 | struct delayed_work power_work; /* delayed task for powerdown */ |
825 | unsigned long power_on_acct; | ||
826 | unsigned long power_off_acct; | ||
827 | unsigned long power_jiffies; | ||
814 | #endif | 828 | #endif |
815 | 829 | ||
816 | /* codec-specific additional proc output */ | 830 | /* codec-specific additional proc output */ |
@@ -910,6 +924,7 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, | |||
910 | * Misc | 924 | * Misc |
911 | */ | 925 | */ |
912 | void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen); | 926 | void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen); |
927 | void snd_hda_bus_reboot_notify(struct hda_bus *bus); | ||
913 | 928 | ||
914 | /* | 929 | /* |
915 | * power management | 930 | * power management |
@@ -933,6 +948,7 @@ const char *snd_hda_get_jack_location(u32 cfg); | |||
933 | void snd_hda_power_up(struct hda_codec *codec); | 948 | void snd_hda_power_up(struct hda_codec *codec); |
934 | void snd_hda_power_down(struct hda_codec *codec); | 949 | void snd_hda_power_down(struct hda_codec *codec); |
935 | #define snd_hda_codec_needs_resume(codec) codec->power_count | 950 | #define snd_hda_codec_needs_resume(codec) codec->power_count |
951 | void snd_hda_update_power_acct(struct hda_codec *codec); | ||
936 | #else | 952 | #else |
937 | static inline void snd_hda_power_up(struct hda_codec *codec) {} | 953 | static inline void snd_hda_power_up(struct hda_codec *codec) {} |
938 | static inline void snd_hda_power_down(struct hda_codec *codec) {} | 954 | static inline void snd_hda_power_down(struct hda_codec *codec) {} |
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 9446a5abea13..4228f2fe5956 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
@@ -309,17 +309,12 @@ out_fail: | |||
309 | return -EINVAL; | 309 | return -EINVAL; |
310 | } | 310 | } |
311 | 311 | ||
312 | static int hdmi_present_sense(struct hda_codec *codec, hda_nid_t nid) | ||
313 | { | ||
314 | return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0); | ||
315 | } | ||
316 | |||
317 | static int hdmi_eld_valid(struct hda_codec *codec, hda_nid_t nid) | 312 | static int hdmi_eld_valid(struct hda_codec *codec, hda_nid_t nid) |
318 | { | 313 | { |
319 | int eldv; | 314 | int eldv; |
320 | int present; | 315 | int present; |
321 | 316 | ||
322 | present = hdmi_present_sense(codec, nid); | 317 | present = snd_hda_pin_sense(codec, nid); |
323 | eldv = (present & AC_PINSENSE_ELDV); | 318 | eldv = (present & AC_PINSENSE_ELDV); |
324 | present = (present & AC_PINSENSE_PRESENCE); | 319 | present = (present & AC_PINSENSE_PRESENCE); |
325 | 320 | ||
@@ -477,6 +472,8 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry, | |||
477 | [4 ... 7] = "reserved" | 472 | [4 ... 7] = "reserved" |
478 | }; | 473 | }; |
479 | 474 | ||
475 | snd_iprintf(buffer, "monitor_present\t\t%d\n", e->monitor_present); | ||
476 | snd_iprintf(buffer, "eld_valid\t\t%d\n", e->eld_valid); | ||
480 | snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name); | 477 | snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name); |
481 | snd_iprintf(buffer, "connection_type\t\t%s\n", | 478 | snd_iprintf(buffer, "connection_type\t\t%s\n", |
482 | eld_connection_type_names[e->conn_type]); | 479 | eld_connection_type_names[e->conn_type]); |
@@ -518,7 +515,11 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, | |||
518 | * monitor_name manufacture_id product_id | 515 | * monitor_name manufacture_id product_id |
519 | * eld_version edid_version | 516 | * eld_version edid_version |
520 | */ | 517 | */ |
521 | if (!strcmp(name, "connection_type")) | 518 | if (!strcmp(name, "monitor_present")) |
519 | e->monitor_present = val; | ||
520 | else if (!strcmp(name, "eld_valid")) | ||
521 | e->eld_valid = val; | ||
522 | else if (!strcmp(name, "connection_type")) | ||
522 | e->conn_type = val; | 523 | e->conn_type = val; |
523 | else if (!strcmp(name, "port_id")) | 524 | else if (!strcmp(name, "port_id")) |
524 | e->port_id = val; | 525 | e->port_id = val; |
@@ -560,13 +561,14 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, | |||
560 | } | 561 | } |
561 | 562 | ||
562 | 563 | ||
563 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld) | 564 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, |
565 | int index) | ||
564 | { | 566 | { |
565 | char name[32]; | 567 | char name[32]; |
566 | struct snd_info_entry *entry; | 568 | struct snd_info_entry *entry; |
567 | int err; | 569 | int err; |
568 | 570 | ||
569 | snprintf(name, sizeof(name), "eld#%d", codec->addr); | 571 | snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); |
570 | err = snd_card_proc_new(codec->bus->card, name, &entry); | 572 | err = snd_card_proc_new(codec->bus->card, name, &entry); |
571 | if (err < 0) | 573 | if (err < 0) |
572 | return err; | 574 | return err; |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index b36f6c5a92df..092c6a7c2ff3 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -727,7 +727,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, | |||
727 | if (is_loopback) | 727 | if (is_loopback) |
728 | add_input_loopback(codec, node->nid, HDA_INPUT, index); | 728 | add_input_loopback(codec, node->nid, HDA_INPUT, index); |
729 | snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); | 729 | snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); |
730 | err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 730 | err = snd_hda_ctl_add(codec, node->nid, |
731 | snd_ctl_new1(&knew, codec)); | ||
731 | if (err < 0) | 732 | if (err < 0) |
732 | return err; | 733 | return err; |
733 | created = 1; | 734 | created = 1; |
@@ -737,7 +738,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, | |||
737 | if (is_loopback) | 738 | if (is_loopback) |
738 | add_input_loopback(codec, node->nid, HDA_OUTPUT, 0); | 739 | add_input_loopback(codec, node->nid, HDA_OUTPUT, 0); |
739 | snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); | 740 | snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); |
740 | err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 741 | err = snd_hda_ctl_add(codec, node->nid, |
742 | snd_ctl_new1(&knew, codec)); | ||
741 | if (err < 0) | 743 | if (err < 0) |
742 | return err; | 744 | return err; |
743 | created = 1; | 745 | created = 1; |
@@ -751,7 +753,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, | |||
751 | (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) { | 753 | (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) { |
752 | knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); | 754 | knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); |
753 | snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); | 755 | snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); |
754 | err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 756 | err = snd_hda_ctl_add(codec, node->nid, |
757 | snd_ctl_new1(&knew, codec)); | ||
755 | if (err < 0) | 758 | if (err < 0) |
756 | return err; | 759 | return err; |
757 | created = 1; | 760 | created = 1; |
@@ -759,7 +762,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, | |||
759 | (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) { | 762 | (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) { |
760 | knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); | 763 | knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); |
761 | snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); | 764 | snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); |
762 | err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 765 | err = snd_hda_ctl_add(codec, node->nid, |
766 | snd_ctl_new1(&knew, codec)); | ||
763 | if (err < 0) | 767 | if (err < 0) |
764 | return err; | 768 | return err; |
765 | created = 1; | 769 | created = 1; |
@@ -857,7 +861,7 @@ static int build_input_controls(struct hda_codec *codec) | |||
857 | } | 861 | } |
858 | 862 | ||
859 | /* create input MUX if multiple sources are available */ | 863 | /* create input MUX if multiple sources are available */ |
860 | err = snd_hda_ctl_add(codec, snd_ctl_new1(&cap_sel, codec)); | 864 | err = snd_hda_ctl_add(codec, 0, snd_ctl_new1(&cap_sel, codec)); |
861 | if (err < 0) | 865 | if (err < 0) |
862 | return err; | 866 | return err; |
863 | 867 | ||
@@ -875,7 +879,8 @@ static int build_input_controls(struct hda_codec *codec) | |||
875 | HDA_CODEC_VOLUME(name, adc_node->nid, | 879 | HDA_CODEC_VOLUME(name, adc_node->nid, |
876 | spec->input_mux.items[i].index, | 880 | spec->input_mux.items[i].index, |
877 | HDA_INPUT); | 881 | HDA_INPUT); |
878 | err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 882 | err = snd_hda_ctl_add(codec, adc_node->nid, |
883 | snd_ctl_new1(&knew, codec)); | ||
879 | if (err < 0) | 884 | if (err < 0) |
880 | return err; | 885 | return err; |
881 | } | 886 | } |
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index cc24e6721d74..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" |
@@ -154,6 +155,44 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec) | |||
154 | return 0; | 155 | return 0; |
155 | } | 156 | } |
156 | 157 | ||
158 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
159 | static ssize_t power_on_acct_show(struct device *dev, | ||
160 | struct device_attribute *attr, | ||
161 | char *buf) | ||
162 | { | ||
163 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
164 | struct hda_codec *codec = hwdep->private_data; | ||
165 | snd_hda_update_power_acct(codec); | ||
166 | return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct)); | ||
167 | } | ||
168 | |||
169 | static ssize_t power_off_acct_show(struct device *dev, | ||
170 | struct device_attribute *attr, | ||
171 | char *buf) | ||
172 | { | ||
173 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
174 | struct hda_codec *codec = hwdep->private_data; | ||
175 | snd_hda_update_power_acct(codec); | ||
176 | return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct)); | ||
177 | } | ||
178 | |||
179 | static struct device_attribute power_attrs[] = { | ||
180 | __ATTR_RO(power_on_acct), | ||
181 | __ATTR_RO(power_off_acct), | ||
182 | }; | ||
183 | |||
184 | int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec) | ||
185 | { | ||
186 | struct snd_hwdep *hwdep = codec->hwdep; | ||
187 | int i; | ||
188 | |||
189 | for (i = 0; i < ARRAY_SIZE(power_attrs); i++) | ||
190 | snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, | ||
191 | hwdep->device, &power_attrs[i]); | ||
192 | return 0; | ||
193 | } | ||
194 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ | ||
195 | |||
157 | #ifdef CONFIG_SND_HDA_RECONFIG | 196 | #ifdef CONFIG_SND_HDA_RECONFIG |
158 | 197 | ||
159 | /* | 198 | /* |
@@ -390,8 +429,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf) | |||
390 | char *key, *val; | 429 | char *key, *val; |
391 | struct hda_hint *hint; | 430 | struct hda_hint *hint; |
392 | 431 | ||
393 | while (isspace(*buf)) | 432 | buf = skip_spaces(buf); |
394 | buf++; | ||
395 | if (!*buf || *buf == '#' || *buf == '\n') | 433 | if (!*buf || *buf == '#' || *buf == '\n') |
396 | return 0; | 434 | return 0; |
397 | if (*buf == '=') | 435 | if (*buf == '=') |
@@ -406,8 +444,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf) | |||
406 | return -EINVAL; | 444 | return -EINVAL; |
407 | } | 445 | } |
408 | *val++ = 0; | 446 | *val++ = 0; |
409 | while (isspace(*val)) | 447 | val = skip_spaces(val); |
410 | val++; | ||
411 | remove_trail_spaces(key); | 448 | remove_trail_spaces(key); |
412 | remove_trail_spaces(val); | 449 | remove_trail_spaces(val); |
413 | 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 e340792f6cb3..ff8ad46cc50e 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -60,10 +60,14 @@ static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; | |||
60 | static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; | 60 | static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; |
61 | static int probe_only[SNDRV_CARDS]; | 61 | static int probe_only[SNDRV_CARDS]; |
62 | static int single_cmd; | 62 | static int single_cmd; |
63 | static int enable_msi; | 63 | static int enable_msi = -1; |
64 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | 64 | #ifdef CONFIG_SND_HDA_PATCH_LOADER |
65 | static char *patch[SNDRV_CARDS]; | 65 | static char *patch[SNDRV_CARDS]; |
66 | #endif | 66 | #endif |
67 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
68 | static int beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = | ||
69 | CONFIG_SND_HDA_INPUT_BEEP_MODE}; | ||
70 | #endif | ||
67 | 71 | ||
68 | module_param_array(index, int, NULL, 0444); | 72 | module_param_array(index, int, NULL, 0444); |
69 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); | 73 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); |
@@ -91,6 +95,11 @@ MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); | |||
91 | module_param_array(patch, charp, NULL, 0444); | 95 | module_param_array(patch, charp, NULL, 0444); |
92 | MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface."); | 96 | MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface."); |
93 | #endif | 97 | #endif |
98 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
99 | module_param_array(beep_mode, int, NULL, 0444); | ||
100 | MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode " | ||
101 | "(0=off, 1=on, 2=mute switch on/off) (default=1)."); | ||
102 | #endif | ||
94 | 103 | ||
95 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 104 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
96 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; | 105 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; |
@@ -404,6 +413,7 @@ struct azx { | |||
404 | unsigned short codec_mask; | 413 | unsigned short codec_mask; |
405 | int codec_probe_mask; /* copied from probe_mask option */ | 414 | int codec_probe_mask; /* copied from probe_mask option */ |
406 | struct hda_bus *bus; | 415 | struct hda_bus *bus; |
416 | unsigned int beep_mode; | ||
407 | 417 | ||
408 | /* CORB/RIRB */ | 418 | /* CORB/RIRB */ |
409 | struct azx_rb corb; | 419 | struct azx_rb corb; |
@@ -677,6 +687,14 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus, | |||
677 | } | 687 | } |
678 | } | 688 | } |
679 | 689 | ||
690 | if (!chip->polling_mode) { | ||
691 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " | ||
692 | "switching to polling mode: last cmd=0x%08x\n", | ||
693 | chip->last_cmd[addr]); | ||
694 | chip->polling_mode = 1; | ||
695 | goto again; | ||
696 | } | ||
697 | |||
680 | if (chip->msi) { | 698 | if (chip->msi) { |
681 | snd_printk(KERN_WARNING SFX "No response from codec, " | 699 | snd_printk(KERN_WARNING SFX "No response from codec, " |
682 | "disabling MSI: last cmd=0x%08x\n", | 700 | "disabling MSI: last cmd=0x%08x\n", |
@@ -692,14 +710,6 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus, | |||
692 | goto again; | 710 | goto again; |
693 | } | 711 | } |
694 | 712 | ||
695 | if (!chip->polling_mode) { | ||
696 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " | ||
697 | "switching to polling mode: last cmd=0x%08x\n", | ||
698 | chip->last_cmd[addr]); | ||
699 | chip->polling_mode = 1; | ||
700 | goto again; | ||
701 | } | ||
702 | |||
703 | if (chip->probing) { | 713 | if (chip->probing) { |
704 | /* If this critical timeout happens during the codec probing | 714 | /* If this critical timeout happens during the codec probing |
705 | * phase, this is likely an access to a non-existing codec | 715 | * phase, this is likely an access to a non-existing codec |
@@ -722,9 +732,10 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus, | |||
722 | chip->last_cmd[addr]); | 732 | chip->last_cmd[addr]); |
723 | chip->single_cmd = 1; | 733 | chip->single_cmd = 1; |
724 | bus->response_reset = 0; | 734 | bus->response_reset = 0; |
725 | /* re-initialize CORB/RIRB */ | 735 | /* release CORB/RIRB */ |
726 | azx_free_cmd_io(chip); | 736 | azx_free_cmd_io(chip); |
727 | azx_init_cmd_io(chip); | 737 | /* disable unsolicited responses */ |
738 | azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_UNSOL); | ||
728 | return -1; | 739 | return -1; |
729 | } | 740 | } |
730 | 741 | ||
@@ -865,7 +876,9 @@ static int azx_reset(struct azx *chip) | |||
865 | } | 876 | } |
866 | 877 | ||
867 | /* Accept unsolicited responses */ | 878 | /* Accept unsolicited responses */ |
868 | azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UNSOL); | 879 | if (!chip->single_cmd) |
880 | azx_writel(chip, GCTL, azx_readl(chip, GCTL) | | ||
881 | ICH6_GCTL_UNSOL); | ||
869 | 882 | ||
870 | /* detect codecs */ | 883 | /* detect codecs */ |
871 | if (!chip->codec_mask) { | 884 | if (!chip->codec_mask) { |
@@ -980,7 +993,8 @@ static void azx_init_chip(struct azx *chip) | |||
980 | azx_int_enable(chip); | 993 | azx_int_enable(chip); |
981 | 994 | ||
982 | /* initialize the codec command I/O */ | 995 | /* initialize the codec command I/O */ |
983 | azx_init_cmd_io(chip); | 996 | if (!chip->single_cmd) |
997 | azx_init_cmd_io(chip); | ||
984 | 998 | ||
985 | /* program the position buffer */ | 999 | /* program the position buffer */ |
986 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); | 1000 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); |
@@ -1400,6 +1414,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model) | |||
1400 | err = snd_hda_codec_new(chip->bus, c, &codec); | 1414 | err = snd_hda_codec_new(chip->bus, c, &codec); |
1401 | if (err < 0) | 1415 | if (err < 0) |
1402 | continue; | 1416 | continue; |
1417 | codec->beep_mode = chip->beep_mode; | ||
1403 | codecs++; | 1418 | codecs++; |
1404 | } | 1419 | } |
1405 | } | 1420 | } |
@@ -2067,7 +2082,8 @@ static void azx_power_notify(struct hda_bus *bus) | |||
2067 | } | 2082 | } |
2068 | if (power_on) | 2083 | if (power_on) |
2069 | azx_init_chip(chip); | 2084 | azx_init_chip(chip); |
2070 | else if (chip->running && power_save_controller) | 2085 | else if (chip->running && power_save_controller && |
2086 | !bus->power_keep_link_on) | ||
2071 | azx_stop_chip(chip); | 2087 | azx_stop_chip(chip); |
2072 | } | 2088 | } |
2073 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ | 2089 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ |
@@ -2150,6 +2166,7 @@ static int azx_resume(struct pci_dev *pci) | |||
2150 | static int azx_halt(struct notifier_block *nb, unsigned long event, void *buf) | 2166 | static int azx_halt(struct notifier_block *nb, unsigned long event, void *buf) |
2151 | { | 2167 | { |
2152 | struct azx *chip = container_of(nb, struct azx, reboot_notifier); | 2168 | struct azx *chip = container_of(nb, struct azx, reboot_notifier); |
2169 | snd_hda_bus_reboot_notify(chip->bus); | ||
2153 | azx_stop_chip(chip); | 2170 | azx_stop_chip(chip); |
2154 | return NOTIFY_OK; | 2171 | return NOTIFY_OK; |
2155 | } | 2172 | } |
@@ -2217,7 +2234,9 @@ static int azx_dev_free(struct snd_device *device) | |||
2217 | static struct snd_pci_quirk position_fix_list[] __devinitdata = { | 2234 | static struct snd_pci_quirk position_fix_list[] __devinitdata = { |
2218 | SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), | 2235 | SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), |
2219 | SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), | 2236 | SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), |
2237 | SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), | ||
2220 | SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), | 2238 | SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), |
2239 | SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), | ||
2221 | {} | 2240 | {} |
2222 | }; | 2241 | }; |
2223 | 2242 | ||
@@ -2300,11 +2319,10 @@ static void __devinit check_probe_mask(struct azx *chip, int dev) | |||
2300 | } | 2319 | } |
2301 | 2320 | ||
2302 | /* | 2321 | /* |
2303 | * white-list for enable_msi | 2322 | * white/black-list for enable_msi |
2304 | */ | 2323 | */ |
2305 | static struct snd_pci_quirk msi_white_list[] __devinitdata = { | 2324 | static struct snd_pci_quirk msi_black_list[] __devinitdata = { |
2306 | SND_PCI_QUIRK(0x103c, 0x30f7, "HP Pavilion dv4t-1300", 1), | 2325 | SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ |
2307 | SND_PCI_QUIRK(0x103c, 0x3607, "HP Compa CQ40", 1), | ||
2308 | {} | 2326 | {} |
2309 | }; | 2327 | }; |
2310 | 2328 | ||
@@ -2312,10 +2330,12 @@ static void __devinit check_msi(struct azx *chip) | |||
2312 | { | 2330 | { |
2313 | const struct snd_pci_quirk *q; | 2331 | const struct snd_pci_quirk *q; |
2314 | 2332 | ||
2315 | chip->msi = enable_msi; | 2333 | if (enable_msi >= 0) { |
2316 | if (chip->msi) | 2334 | chip->msi = !!enable_msi; |
2317 | return; | 2335 | return; |
2318 | q = snd_pci_quirk_lookup(chip->pci, msi_white_list); | 2336 | } |
2337 | chip->msi = 1; /* enable MSI as default */ | ||
2338 | q = snd_pci_quirk_lookup(chip->pci, msi_black_list); | ||
2319 | if (q) { | 2339 | if (q) { |
2320 | printk(KERN_INFO | 2340 | printk(KERN_INFO |
2321 | "hda_intel: msi for device %04x:%04x set to %d\n", | 2341 | "hda_intel: msi for device %04x:%04x set to %d\n", |
@@ -2432,6 +2452,11 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2432 | } | 2452 | } |
2433 | } | 2453 | } |
2434 | 2454 | ||
2455 | /* disable 64bit DMA address for Teradici */ | ||
2456 | /* it does not work with device 6549:1200 subsys e4a2:040b */ | ||
2457 | if (chip->driver_type == AZX_DRIVER_TERA) | ||
2458 | gcap &= ~ICH6_GCAP_64OK; | ||
2459 | |||
2435 | /* allow 64bit DMA address if supported by H/W */ | 2460 | /* allow 64bit DMA address if supported by H/W */ |
2436 | if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) | 2461 | if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) |
2437 | pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); | 2462 | pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); |
@@ -2574,6 +2599,10 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2574 | goto out_free; | 2599 | goto out_free; |
2575 | card->private_data = chip; | 2600 | card->private_data = chip; |
2576 | 2601 | ||
2602 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2603 | chip->beep_mode = beep_mode[dev]; | ||
2604 | #endif | ||
2605 | |||
2577 | /* create codec instances */ | 2606 | /* create codec instances */ |
2578 | err = azx_codec_create(chip, model[dev]); | 2607 | err = azx_codec_create(chip, model[dev]); |
2579 | if (err < 0) | 2608 | if (err < 0) |
@@ -2685,6 +2714,9 @@ static struct pci_device_id azx_ids[] = { | |||
2685 | { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, | 2714 | { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, |
2686 | { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, | 2715 | { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, |
2687 | { 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 }, | ||
2688 | { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA }, | 2720 | { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA }, |
2689 | { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA }, | 2721 | { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA }, |
2690 | { 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/hda_local.h b/sound/pci/hda/hda_local.h index 5f1dcc59002b..5778ae882b83 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -23,6 +23,15 @@ | |||
23 | #ifndef __SOUND_HDA_LOCAL_H | 23 | #ifndef __SOUND_HDA_LOCAL_H |
24 | #define __SOUND_HDA_LOCAL_H | 24 | #define __SOUND_HDA_LOCAL_H |
25 | 25 | ||
26 | /* We abuse kcontrol_new.subdev field to pass the NID corresponding to | ||
27 | * the given new control. If id.subdev has a bit flag HDA_SUBDEV_NID_FLAG, | ||
28 | * snd_hda_ctl_add() takes the lower-bit subdev value as a valid NID. | ||
29 | * | ||
30 | * Note that the subdevice field is cleared again before the real registration | ||
31 | * in snd_hda_ctl_add(), so that this value won't appear in the outside. | ||
32 | */ | ||
33 | #define HDA_SUBDEV_NID_FLAG (1U << 31) | ||
34 | |||
26 | /* | 35 | /* |
27 | * for mixer controls | 36 | * for mixer controls |
28 | */ | 37 | */ |
@@ -33,6 +42,7 @@ | |||
33 | /* mono volume with index (index=0,1,...) (channel=1,2) */ | 42 | /* mono volume with index (index=0,1,...) (channel=1,2) */ |
34 | #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ | 43 | #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ |
35 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ | 44 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ |
45 | .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ | ||
36 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | 46 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
37 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 47 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
38 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | 48 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
@@ -53,6 +63,7 @@ | |||
53 | /* mono mute switch with index (index=0,1,...) (channel=1,2) */ | 63 | /* mono mute switch with index (index=0,1,...) (channel=1,2) */ |
54 | #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ | 64 | #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ |
55 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ | 65 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ |
66 | .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ | ||
56 | .info = snd_hda_mixer_amp_switch_info, \ | 67 | .info = snd_hda_mixer_amp_switch_info, \ |
57 | .get = snd_hda_mixer_amp_switch_get, \ | 68 | .get = snd_hda_mixer_amp_switch_get, \ |
58 | .put = snd_hda_mixer_amp_switch_put, \ | 69 | .put = snd_hda_mixer_amp_switch_put, \ |
@@ -66,6 +77,28 @@ | |||
66 | /* stereo mute switch */ | 77 | /* stereo mute switch */ |
67 | #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \ | 78 | #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \ |
68 | HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction) | 79 | HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction) |
80 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
81 | /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */ | ||
82 | #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ | ||
83 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ | ||
84 | .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ | ||
85 | .info = snd_hda_mixer_amp_switch_info, \ | ||
86 | .get = snd_hda_mixer_amp_switch_get, \ | ||
87 | .put = snd_hda_mixer_amp_switch_put_beep, \ | ||
88 | .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) } | ||
89 | #else | ||
90 | /* no digital beep - just the standard one */ | ||
91 | #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, ch, xidx, dir) \ | ||
92 | HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, ch, xidx, dir) | ||
93 | #endif /* CONFIG_SND_HDA_INPUT_BEEP */ | ||
94 | /* special beep mono mute switch */ | ||
95 | #define HDA_CODEC_MUTE_BEEP_MONO(xname, nid, channel, xindex, direction) \ | ||
96 | HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, 0, nid, channel, xindex, direction) | ||
97 | /* special beep stereo mute switch */ | ||
98 | #define HDA_CODEC_MUTE_BEEP(xname, nid, xindex, direction) \ | ||
99 | HDA_CODEC_MUTE_BEEP_MONO(xname, nid, 3, xindex, direction) | ||
100 | |||
101 | extern const char *snd_hda_pcm_type_name[]; | ||
69 | 102 | ||
70 | int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, | 103 | int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, |
71 | struct snd_ctl_elem_info *uinfo); | 104 | struct snd_ctl_elem_info *uinfo); |
@@ -81,6 +114,10 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, | |||
81 | struct snd_ctl_elem_value *ucontrol); | 114 | struct snd_ctl_elem_value *ucontrol); |
82 | int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, | 115 | int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, |
83 | struct snd_ctl_elem_value *ucontrol); | 116 | struct snd_ctl_elem_value *ucontrol); |
117 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
118 | int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol, | ||
119 | struct snd_ctl_elem_value *ucontrol); | ||
120 | #endif | ||
84 | /* lowlevel accessor with caching; use carefully */ | 121 | /* lowlevel accessor with caching; use carefully */ |
85 | int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, | 122 | int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, |
86 | int direction, int index); | 123 | int direction, int index); |
@@ -424,8 +461,16 @@ u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); | |||
424 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, | 461 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, |
425 | unsigned int caps); | 462 | unsigned int caps); |
426 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid); | 463 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid); |
464 | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid); | ||
465 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); | ||
427 | 466 | ||
428 | int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl); | 467 | struct hda_nid_item { |
468 | struct snd_kcontrol *kctl; | ||
469 | hda_nid_t nid; | ||
470 | }; | ||
471 | |||
472 | int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, | ||
473 | struct snd_kcontrol *kctl); | ||
429 | void snd_hda_ctls_clear(struct hda_codec *codec); | 474 | void snd_hda_ctls_clear(struct hda_codec *codec); |
430 | 475 | ||
431 | /* | 476 | /* |
@@ -437,6 +482,15 @@ int snd_hda_create_hwdep(struct hda_codec *codec); | |||
437 | static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; } | 482 | static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; } |
438 | #endif | 483 | #endif |
439 | 484 | ||
485 | #if defined(CONFIG_SND_HDA_POWER_SAVE) && defined(CONFIG_SND_HDA_HWDEP) | ||
486 | int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec); | ||
487 | #else | ||
488 | static inline int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec) | ||
489 | { | ||
490 | return 0; | ||
491 | } | ||
492 | #endif | ||
493 | |||
440 | #ifdef CONFIG_SND_HDA_RECONFIG | 494 | #ifdef CONFIG_SND_HDA_RECONFIG |
441 | int snd_hda_hwdep_add_sysfs(struct hda_codec *codec); | 495 | int snd_hda_hwdep_add_sysfs(struct hda_codec *codec); |
442 | #else | 496 | #else |
@@ -490,7 +544,8 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec, | |||
490 | * AMP control callbacks | 544 | * AMP control callbacks |
491 | */ | 545 | */ |
492 | /* retrieve parameters from private_value */ | 546 | /* retrieve parameters from private_value */ |
493 | #define get_amp_nid(kc) ((kc)->private_value & 0xffff) | 547 | #define get_amp_nid_(pv) ((pv) & 0xffff) |
548 | #define get_amp_nid(kc) get_amp_nid_((kc)->private_value) | ||
494 | #define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) | 549 | #define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) |
495 | #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) | 550 | #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) |
496 | #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) | 551 | #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) |
@@ -516,9 +571,11 @@ struct cea_sad { | |||
516 | * ELD: EDID Like Data | 571 | * ELD: EDID Like Data |
517 | */ | 572 | */ |
518 | struct hdmi_eld { | 573 | struct hdmi_eld { |
574 | bool monitor_present; | ||
575 | bool eld_valid; | ||
519 | int eld_size; | 576 | int eld_size; |
520 | int baseline_len; | 577 | int baseline_len; |
521 | int eld_ver; /* (eld_ver == 0) indicates invalid ELD */ | 578 | int eld_ver; |
522 | int cea_edid_ver; | 579 | int cea_edid_ver; |
523 | char monitor_name[ELD_MAX_MNL + 1]; | 580 | char monitor_name[ELD_MAX_MNL + 1]; |
524 | int manufacture_id; | 581 | int manufacture_id; |
@@ -541,11 +598,13 @@ int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); | |||
541 | void snd_hdmi_show_eld(struct hdmi_eld *eld); | 598 | void snd_hdmi_show_eld(struct hdmi_eld *eld); |
542 | 599 | ||
543 | #ifdef CONFIG_PROC_FS | 600 | #ifdef CONFIG_PROC_FS |
544 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld); | 601 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, |
602 | int index); | ||
545 | void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld); | 603 | void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld); |
546 | #else | 604 | #else |
547 | static inline int snd_hda_eld_proc_new(struct hda_codec *codec, | 605 | static inline int snd_hda_eld_proc_new(struct hda_codec *codec, |
548 | struct hdmi_eld *eld) | 606 | struct hdmi_eld *eld, |
607 | int index) | ||
549 | { | 608 | { |
550 | return 0; | 609 | return 0; |
551 | } | 610 | } |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 95f24e4729f8..c9afc04adac8 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -26,6 +26,21 @@ | |||
26 | #include "hda_codec.h" | 26 | #include "hda_codec.h" |
27 | #include "hda_local.h" | 27 | #include "hda_local.h" |
28 | 28 | ||
29 | static char *bits_names(unsigned int bits, char *names[], int size) | ||
30 | { | ||
31 | int i, n; | ||
32 | static char buf[128]; | ||
33 | |||
34 | for (i = 0, n = 0; i < size; i++) { | ||
35 | if (bits & (1U<<i) && names[i]) | ||
36 | n += snprintf(buf + n, sizeof(buf) - n, " %s", | ||
37 | names[i]); | ||
38 | } | ||
39 | buf[n] = '\0'; | ||
40 | |||
41 | return buf; | ||
42 | } | ||
43 | |||
29 | static const char *get_wid_type_name(unsigned int wid_value) | 44 | static const char *get_wid_type_name(unsigned int wid_value) |
30 | { | 45 | { |
31 | static char *names[16] = { | 46 | static char *names[16] = { |
@@ -46,6 +61,41 @@ static const char *get_wid_type_name(unsigned int wid_value) | |||
46 | return "UNKNOWN Widget"; | 61 | return "UNKNOWN Widget"; |
47 | } | 62 | } |
48 | 63 | ||
64 | static void print_nid_mixers(struct snd_info_buffer *buffer, | ||
65 | struct hda_codec *codec, hda_nid_t nid) | ||
66 | { | ||
67 | int i; | ||
68 | struct hda_nid_item *items = codec->mixers.list; | ||
69 | struct snd_kcontrol *kctl; | ||
70 | for (i = 0; i < codec->mixers.used; i++) { | ||
71 | if (items[i].nid == nid) { | ||
72 | kctl = items[i].kctl; | ||
73 | snd_iprintf(buffer, | ||
74 | " Control: name=\"%s\", index=%i, device=%i\n", | ||
75 | kctl->id.name, kctl->id.index, kctl->id.device); | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | |||
80 | static void print_nid_pcms(struct snd_info_buffer *buffer, | ||
81 | struct hda_codec *codec, hda_nid_t nid) | ||
82 | { | ||
83 | int pcm, type; | ||
84 | struct hda_pcm *cpcm; | ||
85 | for (pcm = 0; pcm < codec->num_pcms; pcm++) { | ||
86 | cpcm = &codec->pcm_info[pcm]; | ||
87 | for (type = 0; type < 2; type++) { | ||
88 | if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL) | ||
89 | continue; | ||
90 | snd_iprintf(buffer, " Device: name=\"%s\", " | ||
91 | "type=\"%s\", device=%i\n", | ||
92 | cpcm->name, | ||
93 | snd_hda_pcm_type_name[cpcm->pcm_type], | ||
94 | cpcm->pcm->device); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
49 | static void print_amp_caps(struct snd_info_buffer *buffer, | 99 | static void print_amp_caps(struct snd_info_buffer *buffer, |
50 | struct hda_codec *codec, hda_nid_t nid, int dir) | 100 | struct hda_codec *codec, hda_nid_t nid, int dir) |
51 | { | 101 | { |
@@ -190,9 +240,14 @@ static void print_pin_caps(struct snd_info_buffer *buffer, | |||
190 | /* Realtek uses this bit as a different meaning */ | 240 | /* Realtek uses this bit as a different meaning */ |
191 | if ((codec->vendor_id >> 16) == 0x10ec) | 241 | if ((codec->vendor_id >> 16) == 0x10ec) |
192 | snd_iprintf(buffer, " R/L"); | 242 | snd_iprintf(buffer, " R/L"); |
193 | else | 243 | else { |
244 | if (caps & AC_PINCAP_HBR) | ||
245 | snd_iprintf(buffer, " HBR"); | ||
194 | snd_iprintf(buffer, " HDMI"); | 246 | snd_iprintf(buffer, " HDMI"); |
247 | } | ||
195 | } | 248 | } |
249 | if (caps & AC_PINCAP_DP) | ||
250 | snd_iprintf(buffer, " DP"); | ||
196 | if (caps & AC_PINCAP_TRIG_REQ) | 251 | if (caps & AC_PINCAP_TRIG_REQ) |
197 | snd_iprintf(buffer, " Trigger"); | 252 | snd_iprintf(buffer, " Trigger"); |
198 | if (caps & AC_PINCAP_IMP_SENSE) | 253 | if (caps & AC_PINCAP_IMP_SENSE) |
@@ -363,8 +418,24 @@ static const char *get_pwr_state(u32 state) | |||
363 | static void print_power_state(struct snd_info_buffer *buffer, | 418 | static void print_power_state(struct snd_info_buffer *buffer, |
364 | struct hda_codec *codec, hda_nid_t nid) | 419 | struct hda_codec *codec, hda_nid_t nid) |
365 | { | 420 | { |
421 | static char *names[] = { | ||
422 | [ilog2(AC_PWRST_D0SUP)] = "D0", | ||
423 | [ilog2(AC_PWRST_D1SUP)] = "D1", | ||
424 | [ilog2(AC_PWRST_D2SUP)] = "D2", | ||
425 | [ilog2(AC_PWRST_D3SUP)] = "D3", | ||
426 | [ilog2(AC_PWRST_D3COLDSUP)] = "D3cold", | ||
427 | [ilog2(AC_PWRST_S3D3COLDSUP)] = "S3D3cold", | ||
428 | [ilog2(AC_PWRST_CLKSTOP)] = "CLKSTOP", | ||
429 | [ilog2(AC_PWRST_EPSS)] = "EPSS", | ||
430 | }; | ||
431 | |||
432 | int sup = snd_hda_param_read(codec, nid, AC_PAR_POWER_STATE); | ||
366 | int pwr = snd_hda_codec_read(codec, nid, 0, | 433 | int pwr = snd_hda_codec_read(codec, nid, 0, |
367 | AC_VERB_GET_POWER_STATE, 0); | 434 | AC_VERB_GET_POWER_STATE, 0); |
435 | if (sup) | ||
436 | snd_iprintf(buffer, " Power states: %s\n", | ||
437 | bits_names(sup, names, ARRAY_SIZE(names))); | ||
438 | |||
368 | snd_iprintf(buffer, " Power: setting=%s, actual=%s\n", | 439 | snd_iprintf(buffer, " Power: setting=%s, actual=%s\n", |
369 | get_pwr_state(pwr & AC_PWRST_SETTING), | 440 | get_pwr_state(pwr & AC_PWRST_SETTING), |
370 | get_pwr_state((pwr & AC_PWRST_ACTUAL) >> | 441 | get_pwr_state((pwr & AC_PWRST_ACTUAL) >> |
@@ -457,6 +528,7 @@ static void print_gpio(struct snd_info_buffer *buffer, | |||
457 | (data & (1<<i)) ? 1 : 0, | 528 | (data & (1<<i)) ? 1 : 0, |
458 | (unsol & (1<<i)) ? 1 : 0); | 529 | (unsol & (1<<i)) ? 1 : 0); |
459 | /* FIXME: add GPO and GPI pin information */ | 530 | /* FIXME: add GPO and GPI pin information */ |
531 | print_nid_mixers(buffer, codec, nid); | ||
460 | } | 532 | } |
461 | 533 | ||
462 | static void print_codec_info(struct snd_info_entry *entry, | 534 | static void print_codec_info(struct snd_info_entry *entry, |
@@ -536,6 +608,9 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
536 | snd_iprintf(buffer, " CP"); | 608 | snd_iprintf(buffer, " CP"); |
537 | snd_iprintf(buffer, "\n"); | 609 | snd_iprintf(buffer, "\n"); |
538 | 610 | ||
611 | print_nid_mixers(buffer, codec, nid); | ||
612 | print_nid_pcms(buffer, codec, nid); | ||
613 | |||
539 | /* volume knob is a special widget that always have connection | 614 | /* volume knob is a special widget that always have connection |
540 | * list | 615 | * list |
541 | */ | 616 | */ |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 2d603f6aba63..1a36137e13ec 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -72,7 +72,8 @@ struct ad198x_spec { | |||
72 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 72 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
73 | 73 | ||
74 | unsigned int jack_present :1; | 74 | unsigned int jack_present :1; |
75 | unsigned int inv_jack_detect:1; | 75 | unsigned int inv_jack_detect:1; /* inverted jack-detection */ |
76 | unsigned int inv_eapd:1; /* inverted EAPD implementation */ | ||
76 | 77 | ||
77 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 78 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
78 | struct hda_loopback_check loopback; | 79 | struct hda_loopback_check loopback; |
@@ -156,15 +157,19 @@ static const char *ad_slave_sws[] = { | |||
156 | 157 | ||
157 | static void ad198x_free_kctls(struct hda_codec *codec); | 158 | static void ad198x_free_kctls(struct hda_codec *codec); |
158 | 159 | ||
160 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
159 | /* additional beep mixers; the actual parameters are overwritten at build */ | 161 | /* additional beep mixers; the actual parameters are overwritten at build */ |
160 | static struct snd_kcontrol_new ad_beep_mixer[] = { | 162 | static struct snd_kcontrol_new ad_beep_mixer[] = { |
161 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT), | 163 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT), |
162 | HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_OUTPUT), | 164 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT), |
163 | { } /* end */ | 165 | { } /* end */ |
164 | }; | 166 | }; |
165 | 167 | ||
166 | #define set_beep_amp(spec, nid, idx, dir) \ | 168 | #define set_beep_amp(spec, nid, idx, dir) \ |
167 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */ | 169 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */ |
170 | #else | ||
171 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ | ||
172 | #endif | ||
168 | 173 | ||
169 | static int ad198x_build_controls(struct hda_codec *codec) | 174 | static int ad198x_build_controls(struct hda_codec *codec) |
170 | { | 175 | { |
@@ -194,6 +199,7 @@ static int ad198x_build_controls(struct hda_codec *codec) | |||
194 | } | 199 | } |
195 | 200 | ||
196 | /* create beep controls if needed */ | 201 | /* create beep controls if needed */ |
202 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
197 | if (spec->beep_amp) { | 203 | if (spec->beep_amp) { |
198 | struct snd_kcontrol_new *knew; | 204 | struct snd_kcontrol_new *knew; |
199 | for (knew = ad_beep_mixer; knew->name; knew++) { | 205 | for (knew = ad_beep_mixer; knew->name; knew++) { |
@@ -202,11 +208,14 @@ static int ad198x_build_controls(struct hda_codec *codec) | |||
202 | if (!kctl) | 208 | if (!kctl) |
203 | return -ENOMEM; | 209 | return -ENOMEM; |
204 | kctl->private_value = spec->beep_amp; | 210 | kctl->private_value = spec->beep_amp; |
205 | err = snd_hda_ctl_add(codec, kctl); | 211 | err = snd_hda_ctl_add(codec, |
212 | get_amp_nid_(spec->beep_amp), | ||
213 | kctl); | ||
206 | if (err < 0) | 214 | if (err < 0) |
207 | return err; | 215 | return err; |
208 | } | 216 | } |
209 | } | 217 | } |
218 | #endif | ||
210 | 219 | ||
211 | /* if we have no master control, let's create it */ | 220 | /* if we have no master control, let's create it */ |
212 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | 221 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
@@ -450,7 +459,7 @@ static struct hda_codec_ops ad198x_patch_ops = { | |||
450 | 459 | ||
451 | /* | 460 | /* |
452 | * EAPD control | 461 | * EAPD control |
453 | * the private value = nid | (invert << 8) | 462 | * the private value = nid |
454 | */ | 463 | */ |
455 | #define ad198x_eapd_info snd_ctl_boolean_mono_info | 464 | #define ad198x_eapd_info snd_ctl_boolean_mono_info |
456 | 465 | ||
@@ -459,8 +468,7 @@ static int ad198x_eapd_get(struct snd_kcontrol *kcontrol, | |||
459 | { | 468 | { |
460 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 469 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
461 | struct ad198x_spec *spec = codec->spec; | 470 | struct ad198x_spec *spec = codec->spec; |
462 | int invert = (kcontrol->private_value >> 8) & 1; | 471 | if (spec->inv_eapd) |
463 | if (invert) | ||
464 | ucontrol->value.integer.value[0] = ! spec->cur_eapd; | 472 | ucontrol->value.integer.value[0] = ! spec->cur_eapd; |
465 | else | 473 | else |
466 | ucontrol->value.integer.value[0] = spec->cur_eapd; | 474 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
@@ -472,11 +480,10 @@ static int ad198x_eapd_put(struct snd_kcontrol *kcontrol, | |||
472 | { | 480 | { |
473 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 481 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
474 | struct ad198x_spec *spec = codec->spec; | 482 | struct ad198x_spec *spec = codec->spec; |
475 | int invert = (kcontrol->private_value >> 8) & 1; | ||
476 | hda_nid_t nid = kcontrol->private_value & 0xff; | 483 | hda_nid_t nid = kcontrol->private_value & 0xff; |
477 | unsigned int eapd; | 484 | unsigned int eapd; |
478 | eapd = !!ucontrol->value.integer.value[0]; | 485 | eapd = !!ucontrol->value.integer.value[0]; |
479 | if (invert) | 486 | if (spec->inv_eapd) |
480 | eapd = !eapd; | 487 | eapd = !eapd; |
481 | if (eapd == spec->cur_eapd) | 488 | if (eapd == spec->cur_eapd) |
482 | return 0; | 489 | return 0; |
@@ -697,7 +704,7 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { | |||
697 | .info = ad198x_eapd_info, | 704 | .info = ad198x_eapd_info, |
698 | .get = ad198x_eapd_get, | 705 | .get = ad198x_eapd_get, |
699 | .put = ad198x_eapd_put, | 706 | .put = ad198x_eapd_put, |
700 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ | 707 | .private_value = 0x1b, /* port-D */ |
701 | }, | 708 | }, |
702 | { } /* end */ | 709 | { } /* end */ |
703 | }; | 710 | }; |
@@ -712,10 +719,10 @@ static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = { | |||
712 | static void ad1986a_automic(struct hda_codec *codec) | 719 | static void ad1986a_automic(struct hda_codec *codec) |
713 | { | 720 | { |
714 | unsigned int present; | 721 | unsigned int present; |
715 | present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0); | 722 | present = snd_hda_jack_detect(codec, 0x1f); |
716 | /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */ | 723 | /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */ |
717 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL, | 724 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL, |
718 | (present & AC_PINSENSE_PRESENCE) ? 0 : 2); | 725 | present ? 0 : 2); |
719 | } | 726 | } |
720 | 727 | ||
721 | #define AD1986A_MIC_EVENT 0x36 | 728 | #define AD1986A_MIC_EVENT 0x36 |
@@ -754,10 +761,8 @@ static void ad1986a_update_hp(struct hda_codec *codec) | |||
754 | static void ad1986a_hp_automute(struct hda_codec *codec) | 761 | static void ad1986a_hp_automute(struct hda_codec *codec) |
755 | { | 762 | { |
756 | struct ad198x_spec *spec = codec->spec; | 763 | struct ad198x_spec *spec = codec->spec; |
757 | unsigned int present; | ||
758 | 764 | ||
759 | present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0); | 765 | spec->jack_present = snd_hda_jack_detect(codec, 0x1a); |
760 | spec->jack_present = !!(present & 0x80000000); | ||
761 | if (spec->inv_jack_detect) | 766 | if (spec->inv_jack_detect) |
762 | spec->jack_present = !spec->jack_present; | 767 | spec->jack_present = !spec->jack_present; |
763 | ad1986a_update_hp(codec); | 768 | ad1986a_update_hp(codec); |
@@ -1068,6 +1073,7 @@ static int patch_ad1986a(struct hda_codec *codec) | |||
1068 | spec->loopback.amplist = ad1986a_loopbacks; | 1073 | spec->loopback.amplist = ad1986a_loopbacks; |
1069 | #endif | 1074 | #endif |
1070 | spec->vmaster_nid = 0x1b; | 1075 | spec->vmaster_nid = 0x1b; |
1076 | spec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */ | ||
1071 | 1077 | ||
1072 | codec->patch_ops = ad198x_patch_ops; | 1078 | codec->patch_ops = ad198x_patch_ops; |
1073 | 1079 | ||
@@ -1547,8 +1553,7 @@ static void ad1981_hp_automute(struct hda_codec *codec) | |||
1547 | { | 1553 | { |
1548 | unsigned int present; | 1554 | unsigned int present; |
1549 | 1555 | ||
1550 | present = snd_hda_codec_read(codec, 0x06, 0, | 1556 | present = snd_hda_jack_detect(codec, 0x06); |
1551 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1552 | snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0, | 1557 | snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0, |
1553 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 1558 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
1554 | } | 1559 | } |
@@ -1568,8 +1573,7 @@ static void ad1981_hp_automic(struct hda_codec *codec) | |||
1568 | }; | 1573 | }; |
1569 | unsigned int present; | 1574 | unsigned int present; |
1570 | 1575 | ||
1571 | present = snd_hda_codec_read(codec, 0x08, 0, | 1576 | present = snd_hda_jack_detect(codec, 0x08); |
1572 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1573 | if (present) | 1577 | if (present) |
1574 | snd_hda_sequence_write(codec, mic_jack_on); | 1578 | snd_hda_sequence_write(codec, mic_jack_on); |
1575 | else | 1579 | else |
@@ -1785,6 +1789,14 @@ static int patch_ad1981(struct hda_codec *codec) | |||
1785 | 1789 | ||
1786 | codec->patch_ops.init = ad1981_hp_init; | 1790 | codec->patch_ops.init = ad1981_hp_init; |
1787 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; | 1791 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
1792 | /* set the upper-limit for mixer amp to 0dB for avoiding the | ||
1793 | * possible damage by overloading | ||
1794 | */ | ||
1795 | snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT, | ||
1796 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | ||
1797 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
1798 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
1799 | (1 << AC_AMPCAP_MUTE_SHIFT)); | ||
1788 | break; | 1800 | break; |
1789 | case AD1981_THINKPAD: | 1801 | case AD1981_THINKPAD: |
1790 | spec->mixers[0] = ad1981_thinkpad_mixers; | 1802 | spec->mixers[0] = ad1981_thinkpad_mixers; |
@@ -2120,7 +2132,7 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = { | |||
2120 | .info = ad198x_eapd_info, | 2132 | .info = ad198x_eapd_info, |
2121 | .get = ad198x_eapd_get, | 2133 | .get = ad198x_eapd_get, |
2122 | .put = ad198x_eapd_put, | 2134 | .put = ad198x_eapd_put, |
2123 | .private_value = 0x12 | (1 << 8), /* port-D, inversed */ | 2135 | .private_value = 0x12, /* port-D */ |
2124 | }, | 2136 | }, |
2125 | 2137 | ||
2126 | { } /* end */ | 2138 | { } /* end */ |
@@ -2524,7 +2536,7 @@ static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) | |||
2524 | { | 2536 | { |
2525 | if ((res >> 26) != AD1988_HP_EVENT) | 2537 | if ((res >> 26) != AD1988_HP_EVENT) |
2526 | return; | 2538 | return; |
2527 | if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) | 2539 | if (snd_hda_jack_detect(codec, 0x11)) |
2528 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); | 2540 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
2529 | else | 2541 | else |
2530 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); | 2542 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
@@ -2569,6 +2581,8 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name, | |||
2569 | knew->name = kstrdup(name, GFP_KERNEL); | 2581 | knew->name = kstrdup(name, GFP_KERNEL); |
2570 | if (! knew->name) | 2582 | if (! knew->name) |
2571 | return -ENOMEM; | 2583 | return -ENOMEM; |
2584 | if (get_amp_nid_(val)) | ||
2585 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | ||
2572 | knew->private_value = val; | 2586 | knew->private_value = val; |
2573 | return 0; | 2587 | return 0; |
2574 | } | 2588 | } |
@@ -3059,6 +3073,7 @@ static int patch_ad1988(struct hda_codec *codec) | |||
3059 | spec->input_mux = &ad1988_laptop_capture_source; | 3073 | spec->input_mux = &ad1988_laptop_capture_source; |
3060 | spec->num_mixers = 1; | 3074 | spec->num_mixers = 1; |
3061 | spec->mixers[0] = ad1988_laptop_mixers; | 3075 | spec->mixers[0] = ad1988_laptop_mixers; |
3076 | spec->inv_eapd = 1; /* inverted EAPD */ | ||
3062 | spec->num_init_verbs = 1; | 3077 | spec->num_init_verbs = 1; |
3063 | spec->init_verbs[0] = ad1988_laptop_init_verbs; | 3078 | spec->init_verbs[0] = ad1988_laptop_init_verbs; |
3064 | if (board_config == AD1988_LAPTOP_DIG) | 3079 | if (board_config == AD1988_LAPTOP_DIG) |
@@ -3768,8 +3783,7 @@ static void ad1884a_hp_automute(struct hda_codec *codec) | |||
3768 | { | 3783 | { |
3769 | unsigned int present; | 3784 | unsigned int present; |
3770 | 3785 | ||
3771 | present = snd_hda_codec_read(codec, 0x11, 0, | 3786 | present = snd_hda_jack_detect(codec, 0x11); |
3772 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
3773 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | 3787 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
3774 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 3788 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
3775 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, | 3789 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, |
@@ -3781,8 +3795,7 @@ static void ad1884a_hp_automic(struct hda_codec *codec) | |||
3781 | { | 3795 | { |
3782 | unsigned int present; | 3796 | unsigned int present; |
3783 | 3797 | ||
3784 | present = snd_hda_codec_read(codec, 0x14, 0, | 3798 | present = snd_hda_jack_detect(codec, 0x14); |
3785 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
3786 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, | 3799 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, |
3787 | present ? 0 : 1); | 3800 | present ? 0 : 1); |
3788 | } | 3801 | } |
@@ -3817,13 +3830,9 @@ static void ad1884a_laptop_automute(struct hda_codec *codec) | |||
3817 | { | 3830 | { |
3818 | unsigned int present; | 3831 | unsigned int present; |
3819 | 3832 | ||
3820 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0); | 3833 | present = snd_hda_jack_detect(codec, 0x11); |
3821 | present &= AC_PINSENSE_PRESENCE; | 3834 | if (!present) |
3822 | if (!present) { | 3835 | present = snd_hda_jack_detect(codec, 0x12); |
3823 | present = snd_hda_codec_read(codec, 0x12, 0, | ||
3824 | AC_VERB_GET_PIN_SENSE, 0); | ||
3825 | present &= AC_PINSENSE_PRESENCE; | ||
3826 | } | ||
3827 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | 3836 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
3828 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 3837 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
3829 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, | 3838 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, |
@@ -3835,11 +3844,9 @@ static void ad1884a_laptop_automic(struct hda_codec *codec) | |||
3835 | { | 3844 | { |
3836 | unsigned int idx; | 3845 | unsigned int idx; |
3837 | 3846 | ||
3838 | if (snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) & | 3847 | if (snd_hda_jack_detect(codec, 0x14)) |
3839 | AC_PINSENSE_PRESENCE) | ||
3840 | idx = 0; | 3848 | idx = 0; |
3841 | else if (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) & | 3849 | else if (snd_hda_jack_detect(codec, 0x1c)) |
3842 | AC_PINSENSE_PRESENCE) | ||
3843 | idx = 4; | 3850 | idx = 4; |
3844 | else | 3851 | else |
3845 | idx = 1; | 3852 | idx = 1; |
@@ -4008,8 +4015,7 @@ static void ad1984a_thinkpad_automute(struct hda_codec *codec) | |||
4008 | { | 4015 | { |
4009 | unsigned int present; | 4016 | unsigned int present; |
4010 | 4017 | ||
4011 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) | 4018 | present = snd_hda_jack_detect(codec, 0x11); |
4012 | & AC_PINSENSE_PRESENCE; | ||
4013 | snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0, | 4019 | snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0, |
4014 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 4020 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
4015 | } | 4021 | } |
@@ -4117,14 +4123,12 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = { | |||
4117 | /* switch to external mic if plugged */ | 4123 | /* switch to external mic if plugged */ |
4118 | static void ad1984a_touchsmart_automic(struct hda_codec *codec) | 4124 | static void ad1984a_touchsmart_automic(struct hda_codec *codec) |
4119 | { | 4125 | { |
4120 | if (snd_hda_codec_read(codec, 0x1c, 0, | 4126 | if (snd_hda_jack_detect(codec, 0x1c)) |
4121 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000) { | ||
4122 | snd_hda_codec_write(codec, 0x0c, 0, | 4127 | snd_hda_codec_write(codec, 0x0c, 0, |
4123 | AC_VERB_SET_CONNECT_SEL, 0x4); | 4128 | AC_VERB_SET_CONNECT_SEL, 0x4); |
4124 | } else { | 4129 | else |
4125 | snd_hda_codec_write(codec, 0x0c, 0, | 4130 | snd_hda_codec_write(codec, 0x0c, 0, |
4126 | AC_VERB_SET_CONNECT_SEL, 0x5); | 4131 | AC_VERB_SET_CONNECT_SEL, 0x5); |
4127 | } | ||
4128 | } | 4132 | } |
4129 | 4133 | ||
4130 | 4134 | ||
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index d08353d3bb7f..af478019088e 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c | |||
@@ -144,7 +144,7 @@ static int _add_switch(struct hda_codec *codec, hda_nid_t nid, const char *pfx, | |||
144 | struct snd_kcontrol_new knew = | 144 | struct snd_kcontrol_new knew = |
145 | HDA_CODEC_MUTE_MONO(namestr, nid, chan, 0, type); | 145 | HDA_CODEC_MUTE_MONO(namestr, nid, chan, 0, type); |
146 | sprintf(namestr, "%s %s Switch", pfx, dirstr[dir]); | 146 | sprintf(namestr, "%s %s Switch", pfx, dirstr[dir]); |
147 | return snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 147 | return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); |
148 | } | 148 | } |
149 | 149 | ||
150 | static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx, | 150 | static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx, |
@@ -155,7 +155,7 @@ static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx, | |||
155 | struct snd_kcontrol_new knew = | 155 | struct snd_kcontrol_new knew = |
156 | HDA_CODEC_VOLUME_MONO(namestr, nid, chan, 0, type); | 156 | HDA_CODEC_VOLUME_MONO(namestr, nid, chan, 0, type); |
157 | sprintf(namestr, "%s %s Volume", pfx, dirstr[dir]); | 157 | sprintf(namestr, "%s %s Volume", pfx, dirstr[dir]); |
158 | return snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | 158 | return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec)); |
159 | } | 159 | } |
160 | 160 | ||
161 | #define add_out_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 0) | 161 | #define add_out_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 0) |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 8ba306856d38..fe0423c39598 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 | }; |
@@ -500,7 +501,7 @@ static int add_mute(struct hda_codec *codec, const char *name, int index, | |||
500 | knew.private_value = pval; | 501 | knew.private_value = pval; |
501 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); | 502 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); |
502 | *kctlp = snd_ctl_new1(&knew, codec); | 503 | *kctlp = snd_ctl_new1(&knew, codec); |
503 | return snd_hda_ctl_add(codec, *kctlp); | 504 | return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); |
504 | } | 505 | } |
505 | 506 | ||
506 | static int add_volume(struct hda_codec *codec, const char *name, | 507 | static int add_volume(struct hda_codec *codec, const char *name, |
@@ -513,7 +514,7 @@ static int add_volume(struct hda_codec *codec, const char *name, | |||
513 | knew.private_value = pval; | 514 | knew.private_value = pval; |
514 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); | 515 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); |
515 | *kctlp = snd_ctl_new1(&knew, codec); | 516 | *kctlp = snd_ctl_new1(&knew, codec); |
516 | return snd_hda_ctl_add(codec, *kctlp); | 517 | return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); |
517 | } | 518 | } |
518 | 519 | ||
519 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) | 520 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) |
@@ -536,14 +537,14 @@ static int add_vmaster(struct hda_codec *codec, hda_nid_t dac) | |||
536 | 537 | ||
537 | spec->vmaster_sw = | 538 | spec->vmaster_sw = |
538 | snd_ctl_make_virtual_master("Master Playback Switch", NULL); | 539 | snd_ctl_make_virtual_master("Master Playback Switch", NULL); |
539 | err = snd_hda_ctl_add(codec, spec->vmaster_sw); | 540 | err = snd_hda_ctl_add(codec, dac, spec->vmaster_sw); |
540 | if (err < 0) | 541 | if (err < 0) |
541 | return err; | 542 | return err; |
542 | 543 | ||
543 | snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv); | 544 | snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv); |
544 | spec->vmaster_vol = | 545 | spec->vmaster_vol = |
545 | snd_ctl_make_virtual_master("Master Playback Volume", tlv); | 546 | snd_ctl_make_virtual_master("Master Playback Volume", tlv); |
546 | err = snd_hda_ctl_add(codec, spec->vmaster_vol); | 547 | err = snd_hda_ctl_add(codec, dac, spec->vmaster_vol); |
547 | if (err < 0) | 548 | if (err < 0) |
548 | return err; | 549 | return err; |
549 | return 0; | 550 | return 0; |
@@ -756,13 +757,13 @@ static int build_input(struct hda_codec *codec) | |||
756 | if (!kctl) | 757 | if (!kctl) |
757 | return -ENOMEM; | 758 | return -ENOMEM; |
758 | kctl->private_value = (long)spec->capture_bind[i]; | 759 | kctl->private_value = (long)spec->capture_bind[i]; |
759 | err = snd_hda_ctl_add(codec, kctl); | 760 | err = snd_hda_ctl_add(codec, 0, kctl); |
760 | if (err < 0) | 761 | if (err < 0) |
761 | return err; | 762 | return err; |
762 | } | 763 | } |
763 | 764 | ||
764 | if (spec->num_inputs > 1 && !spec->mic_detect) { | 765 | if (spec->num_inputs > 1 && !spec->mic_detect) { |
765 | err = snd_hda_ctl_add(codec, | 766 | err = snd_hda_ctl_add(codec, 0, |
766 | snd_ctl_new1(&cs_capture_source, codec)); | 767 | snd_ctl_new1(&cs_capture_source, codec)); |
767 | if (err < 0) | 768 | if (err < 0) |
768 | return err; | 769 | return err; |
@@ -807,7 +808,7 @@ static void cs_automute(struct hda_codec *codec) | |||
807 | { | 808 | { |
808 | struct cs_spec *spec = codec->spec; | 809 | struct cs_spec *spec = codec->spec; |
809 | struct auto_pin_cfg *cfg = &spec->autocfg; | 810 | struct auto_pin_cfg *cfg = &spec->autocfg; |
810 | unsigned int caps, present, hp_present; | 811 | unsigned int caps, hp_present; |
811 | hda_nid_t nid; | 812 | hda_nid_t nid; |
812 | int i; | 813 | int i; |
813 | 814 | ||
@@ -817,12 +818,7 @@ static void cs_automute(struct hda_codec *codec) | |||
817 | caps = snd_hda_query_pin_caps(codec, nid); | 818 | caps = snd_hda_query_pin_caps(codec, nid); |
818 | if (!(caps & AC_PINCAP_PRES_DETECT)) | 819 | if (!(caps & AC_PINCAP_PRES_DETECT)) |
819 | continue; | 820 | continue; |
820 | if (caps & AC_PINCAP_TRIG_REQ) | 821 | hp_present = snd_hda_jack_detect(codec, nid); |
821 | snd_hda_codec_read(codec, nid, 0, | ||
822 | AC_VERB_SET_PIN_SENSE, 0); | ||
823 | present = snd_hda_codec_read(codec, nid, 0, | ||
824 | AC_VERB_GET_PIN_SENSE, 0); | ||
825 | hp_present |= (present & AC_PINSENSE_PRESENCE) != 0; | ||
826 | if (hp_present) | 822 | if (hp_present) |
827 | break; | 823 | break; |
828 | } | 824 | } |
@@ -832,7 +828,8 @@ static void cs_automute(struct hda_codec *codec) | |||
832 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 828 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
833 | hp_present ? 0 : PIN_OUT); | 829 | hp_present ? 0 : PIN_OUT); |
834 | } | 830 | } |
835 | if (spec->board_config == CS420X_MBP55) { | 831 | if (spec->board_config == CS420X_MBP55 || |
832 | spec->board_config == CS420X_IMAC27) { | ||
836 | unsigned int gpio = hp_present ? 0x02 : 0x08; | 833 | unsigned int gpio = hp_present ? 0x02 : 0x08; |
837 | snd_hda_codec_write(codec, 0x01, 0, | 834 | snd_hda_codec_write(codec, 0x01, 0, |
838 | AC_VERB_SET_GPIO_DATA, gpio); | 835 | AC_VERB_SET_GPIO_DATA, gpio); |
@@ -844,15 +841,11 @@ static void cs_automic(struct hda_codec *codec) | |||
844 | struct cs_spec *spec = codec->spec; | 841 | struct cs_spec *spec = codec->spec; |
845 | struct auto_pin_cfg *cfg = &spec->autocfg; | 842 | struct auto_pin_cfg *cfg = &spec->autocfg; |
846 | hda_nid_t nid; | 843 | hda_nid_t nid; |
847 | unsigned int caps, present; | 844 | unsigned int present; |
848 | 845 | ||
849 | nid = cfg->input_pins[spec->automic_idx]; | 846 | nid = cfg->input_pins[spec->automic_idx]; |
850 | caps = snd_hda_query_pin_caps(codec, nid); | 847 | present = snd_hda_jack_detect(codec, nid); |
851 | if (caps & AC_PINCAP_TRIG_REQ) | 848 | if (present) |
852 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
853 | present = snd_hda_codec_read(codec, nid, 0, | ||
854 | AC_VERB_GET_PIN_SENSE, 0); | ||
855 | if (present & AC_PINSENSE_PRESENCE) | ||
856 | change_cur_input(codec, spec->automic_idx, 0); | 849 | change_cur_input(codec, spec->automic_idx, 0); |
857 | else { | 850 | else { |
858 | unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? | 851 | unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? |
@@ -947,7 +940,7 @@ static void init_input(struct hda_codec *codec) | |||
947 | coef |= 0x0500; /* DMIC2 enable 2 channels, disable GPIO1 */ | 940 | coef |= 0x0500; /* DMIC2 enable 2 channels, disable GPIO1 */ |
948 | if (is_active_pin(codec, CS_DMIC1_PIN_NID)) | 941 | if (is_active_pin(codec, CS_DMIC1_PIN_NID)) |
949 | coef |= 0x1800; /* DMIC1 enable 2 channels, disable GPIO0 | 942 | coef |= 0x1800; /* DMIC1 enable 2 channels, disable GPIO0 |
950 | * No effect if SPDIF_OUT2 is slected in | 943 | * No effect if SPDIF_OUT2 is selected in |
951 | * IDX_SPDIF_CTL. | 944 | * IDX_SPDIF_CTL. |
952 | */ | 945 | */ |
953 | cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); | 946 | cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); |
@@ -1078,12 +1071,14 @@ static int cs_parse_auto_config(struct hda_codec *codec) | |||
1078 | 1071 | ||
1079 | static const char *cs420x_models[CS420X_MODELS] = { | 1072 | static const char *cs420x_models[CS420X_MODELS] = { |
1080 | [CS420X_MBP55] = "mbp55", | 1073 | [CS420X_MBP55] = "mbp55", |
1074 | [CS420X_IMAC27] = "imac27", | ||
1081 | [CS420X_AUTO] = "auto", | 1075 | [CS420X_AUTO] = "auto", |
1082 | }; | 1076 | }; |
1083 | 1077 | ||
1084 | 1078 | ||
1085 | static struct snd_pci_quirk cs420x_cfg_tbl[] = { | 1079 | static struct snd_pci_quirk cs420x_cfg_tbl[] = { |
1086 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), | 1080 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), |
1081 | SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), | ||
1087 | {} /* terminator */ | 1082 | {} /* terminator */ |
1088 | }; | 1083 | }; |
1089 | 1084 | ||
@@ -1106,8 +1101,23 @@ static struct cs_pincfg mbp55_pincfgs[] = { | |||
1106 | {} /* terminator */ | 1101 | {} /* terminator */ |
1107 | }; | 1102 | }; |
1108 | 1103 | ||
1104 | static struct cs_pincfg imac27_pincfgs[] = { | ||
1105 | { 0x09, 0x012b4050 }, | ||
1106 | { 0x0a, 0x90100140 }, | ||
1107 | { 0x0b, 0x90100142 }, | ||
1108 | { 0x0c, 0x018b3020 }, | ||
1109 | { 0x0d, 0x90a00110 }, | ||
1110 | { 0x0e, 0x400000f0 }, | ||
1111 | { 0x0f, 0x01cbe030 }, | ||
1112 | { 0x10, 0x014be060 }, | ||
1113 | { 0x12, 0x01ab9070 }, | ||
1114 | { 0x15, 0x400000f0 }, | ||
1115 | {} /* terminator */ | ||
1116 | }; | ||
1117 | |||
1109 | static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { | 1118 | static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { |
1110 | [CS420X_MBP55] = mbp55_pincfgs, | 1119 | [CS420X_MBP55] = mbp55_pincfgs, |
1120 | [CS420X_IMAC27] = imac27_pincfgs, | ||
1111 | }; | 1121 | }; |
1112 | 1122 | ||
1113 | static void fix_pincfg(struct hda_codec *codec, int model) | 1123 | static void fix_pincfg(struct hda_codec *codec, int model) |
@@ -1137,6 +1147,7 @@ static int patch_cs420x(struct hda_codec *codec) | |||
1137 | fix_pincfg(codec, spec->board_config); | 1147 | fix_pincfg(codec, spec->board_config); |
1138 | 1148 | ||
1139 | switch (spec->board_config) { | 1149 | switch (spec->board_config) { |
1150 | case CS420X_IMAC27: | ||
1140 | case CS420X_MBP55: | 1151 | case CS420X_MBP55: |
1141 | /* GPIO1 = headphones */ | 1152 | /* GPIO1 = headphones */ |
1142 | /* GPIO3 = speakers */ | 1153 | /* GPIO3 = speakers */ |
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index 780e1a72114a..a45c1169762b 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
@@ -66,7 +66,7 @@ struct cmi_spec { | |||
66 | 66 | ||
67 | struct hda_pcm pcm_rec[2]; /* PCM information */ | 67 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
68 | 68 | ||
69 | /* pin deafault configuration */ | 69 | /* pin default configuration */ |
70 | hda_nid_t pin_nid[NUM_PINS]; | 70 | hda_nid_t pin_nid[NUM_PINS]; |
71 | unsigned int def_conf[NUM_PINS]; | 71 | unsigned int def_conf[NUM_PINS]; |
72 | unsigned int pin_def_confs; | 72 | unsigned int pin_def_confs; |
@@ -197,8 +197,8 @@ static struct snd_kcontrol_new cmi9880_basic_mixer[] = { | |||
197 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0, HDA_INPUT), | 197 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0, HDA_INPUT), |
198 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0, HDA_INPUT), | 198 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0, HDA_INPUT), |
199 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0, HDA_INPUT), | 199 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0, HDA_INPUT), |
200 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x23, 0, HDA_OUTPUT), | 200 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x23, 0, HDA_OUTPUT), |
201 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x23, 0, HDA_OUTPUT), | 201 | HDA_CODEC_MUTE("Beep Playback Switch", 0x23, 0, HDA_OUTPUT), |
202 | { } /* end */ | 202 | { } /* end */ |
203 | }; | 203 | }; |
204 | 204 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 3fbbc8c01e70..c578c28f368e 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 |
@@ -110,6 +111,8 @@ struct conexant_spec { | |||
110 | 111 | ||
111 | unsigned int dell_automute; | 112 | unsigned int dell_automute; |
112 | unsigned int port_d_mode; | 113 | unsigned int port_d_mode; |
114 | unsigned char ext_mic_bias; | ||
115 | unsigned int dell_vostro; | ||
113 | }; | 116 | }; |
114 | 117 | ||
115 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | 118 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
@@ -396,9 +399,7 @@ static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | |||
396 | for (i = 0; i < spec->jacks.used; i++) { | 399 | for (i = 0; i < spec->jacks.used; i++) { |
397 | if (jacks->nid == nid) { | 400 | if (jacks->nid == nid) { |
398 | unsigned int present; | 401 | unsigned int present; |
399 | present = snd_hda_codec_read(codec, nid, 0, | 402 | present = snd_hda_jack_detect(codec, nid); |
400 | AC_VERB_GET_PIN_SENSE, 0) & | ||
401 | AC_PINSENSE_PRESENCE; | ||
402 | 403 | ||
403 | present = (present) ? jacks->type : 0 ; | 404 | present = (present) ? jacks->type : 0 ; |
404 | 405 | ||
@@ -477,6 +478,7 @@ static void conexant_free(struct hda_codec *codec) | |||
477 | snd_array_free(&spec->jacks); | 478 | snd_array_free(&spec->jacks); |
478 | } | 479 | } |
479 | #endif | 480 | #endif |
481 | snd_hda_detach_beep_device(codec); | ||
480 | kfree(codec->spec); | 482 | kfree(codec->spec); |
481 | } | 483 | } |
482 | 484 | ||
@@ -749,8 +751,7 @@ static void cxt5045_hp_automic(struct hda_codec *codec) | |||
749 | }; | 751 | }; |
750 | unsigned int present; | 752 | unsigned int present; |
751 | 753 | ||
752 | present = snd_hda_codec_read(codec, 0x12, 0, | 754 | present = snd_hda_jack_detect(codec, 0x12); |
753 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
754 | if (present) | 755 | if (present) |
755 | snd_hda_sequence_write(codec, mic_jack_on); | 756 | snd_hda_sequence_write(codec, mic_jack_on); |
756 | else | 757 | else |
@@ -764,8 +765,7 @@ static void cxt5045_hp_automute(struct hda_codec *codec) | |||
764 | struct conexant_spec *spec = codec->spec; | 765 | struct conexant_spec *spec = codec->spec; |
765 | unsigned int bits; | 766 | unsigned int bits; |
766 | 767 | ||
767 | spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, | 768 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
768 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
769 | 769 | ||
770 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; | 770 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
771 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, | 771 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, |
@@ -1174,9 +1174,10 @@ static int patch_cxt5045(struct hda_codec *codec) | |||
1174 | 1174 | ||
1175 | switch (codec->subsystem_id >> 16) { | 1175 | switch (codec->subsystem_id >> 16) { |
1176 | case 0x103c: | 1176 | case 0x103c: |
1177 | /* HP laptop has a really bad sound over 0dB on NID 0x17. | 1177 | case 0x1734: |
1178 | * Fix max PCM level to 0 dB | 1178 | /* HP & Fujitsu-Siemens laptops have really bad sound over 0dB |
1179 | * (originall it has 0x2b steps with 0dB offset 0x14) | 1179 | * on NID 0x17. Fix max PCM level to 0 dB |
1180 | * (originally it has 0x2b steps with 0dB offset 0x14) | ||
1180 | */ | 1181 | */ |
1181 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, | 1182 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, |
1182 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | | 1183 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | |
@@ -1242,8 +1243,7 @@ static void cxt5047_hp_automute(struct hda_codec *codec) | |||
1242 | struct conexant_spec *spec = codec->spec; | 1243 | struct conexant_spec *spec = codec->spec; |
1243 | unsigned int bits; | 1244 | unsigned int bits; |
1244 | 1245 | ||
1245 | spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, | 1246 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
1246 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1247 | 1247 | ||
1248 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; | 1248 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
1249 | /* See the note in cxt5047_hp_master_sw_put */ | 1249 | /* See the note in cxt5047_hp_master_sw_put */ |
@@ -1266,8 +1266,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec) | |||
1266 | }; | 1266 | }; |
1267 | unsigned int present; | 1267 | unsigned int present; |
1268 | 1268 | ||
1269 | present = snd_hda_codec_read(codec, 0x15, 0, | 1269 | present = snd_hda_jack_detect(codec, 0x15); |
1270 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1271 | if (present) | 1270 | if (present) |
1272 | snd_hda_sequence_write(codec, mic_jack_on); | 1271 | snd_hda_sequence_write(codec, mic_jack_on); |
1273 | else | 1272 | else |
@@ -1414,16 +1413,7 @@ static struct snd_kcontrol_new cxt5047_test_mixer[] = { | |||
1414 | .get = conexant_mux_enum_get, | 1413 | .get = conexant_mux_enum_get, |
1415 | .put = conexant_mux_enum_put, | 1414 | .put = conexant_mux_enum_put, |
1416 | }, | 1415 | }, |
1417 | HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT), | 1416 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
1418 | HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT), | ||
1419 | HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT), | ||
1420 | HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT), | ||
1421 | HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT), | ||
1422 | HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT), | ||
1423 | HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT), | ||
1424 | HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT), | ||
1425 | HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT), | ||
1426 | HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT), | ||
1427 | 1417 | ||
1428 | { } /* end */ | 1418 | { } /* end */ |
1429 | }; | 1419 | }; |
@@ -1620,9 +1610,7 @@ static void cxt5051_portb_automic(struct hda_codec *codec) | |||
1620 | 1610 | ||
1621 | if (spec->no_auto_mic) | 1611 | if (spec->no_auto_mic) |
1622 | return; | 1612 | return; |
1623 | present = snd_hda_codec_read(codec, 0x17, 0, | 1613 | present = snd_hda_jack_detect(codec, 0x17); |
1624 | AC_VERB_GET_PIN_SENSE, 0) & | ||
1625 | AC_PINSENSE_PRESENCE; | ||
1626 | snd_hda_codec_write(codec, 0x14, 0, | 1614 | snd_hda_codec_write(codec, 0x14, 0, |
1627 | AC_VERB_SET_CONNECT_SEL, | 1615 | AC_VERB_SET_CONNECT_SEL, |
1628 | present ? 0x01 : 0x00); | 1616 | present ? 0x01 : 0x00); |
@@ -1637,9 +1625,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec) | |||
1637 | 1625 | ||
1638 | if (spec->no_auto_mic) | 1626 | if (spec->no_auto_mic) |
1639 | return; | 1627 | return; |
1640 | present = snd_hda_codec_read(codec, 0x18, 0, | 1628 | present = snd_hda_jack_detect(codec, 0x18); |
1641 | AC_VERB_GET_PIN_SENSE, 0) & | ||
1642 | AC_PINSENSE_PRESENCE; | ||
1643 | if (present) | 1629 | if (present) |
1644 | spec->cur_adc_idx = 1; | 1630 | spec->cur_adc_idx = 1; |
1645 | else | 1631 | else |
@@ -1660,9 +1646,7 @@ static void cxt5051_hp_automute(struct hda_codec *codec) | |||
1660 | { | 1646 | { |
1661 | struct conexant_spec *spec = codec->spec; | 1647 | struct conexant_spec *spec = codec->spec; |
1662 | 1648 | ||
1663 | spec->hp_present = snd_hda_codec_read(codec, 0x16, 0, | 1649 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
1664 | AC_VERB_GET_PIN_SENSE, 0) & | ||
1665 | AC_PINSENSE_PRESENCE; | ||
1666 | cxt5051_update_speaker(codec); | 1650 | cxt5051_update_speaker(codec); |
1667 | } | 1651 | } |
1668 | 1652 | ||
@@ -1927,6 +1911,11 @@ static hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; | |||
1927 | static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; | 1911 | static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; |
1928 | #define CXT5066_SPDIF_OUT 0x21 | 1912 | #define CXT5066_SPDIF_OUT 0x21 |
1929 | 1913 | ||
1914 | /* OLPC's microphone port is DC coupled for use with external sensors, | ||
1915 | * therefore we use a 50% mic bias in order to center the input signal with | ||
1916 | * the DC input range of the codec. */ | ||
1917 | #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 | ||
1918 | |||
1930 | static struct hda_channel_mode cxt5066_modes[1] = { | 1919 | static struct hda_channel_mode cxt5066_modes[1] = { |
1931 | { 2, NULL }, | 1920 | { 2, NULL }, |
1932 | }; | 1921 | }; |
@@ -1980,9 +1969,10 @@ static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
1980 | /* toggle input of built-in and mic jack appropriately */ | 1969 | /* toggle input of built-in and mic jack appropriately */ |
1981 | static void cxt5066_automic(struct hda_codec *codec) | 1970 | static void cxt5066_automic(struct hda_codec *codec) |
1982 | { | 1971 | { |
1983 | static struct hda_verb ext_mic_present[] = { | 1972 | struct conexant_spec *spec = codec->spec; |
1973 | struct hda_verb ext_mic_present[] = { | ||
1984 | /* enable external mic, port B */ | 1974 | /* enable external mic, port B */ |
1985 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 1975 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->ext_mic_bias}, |
1986 | 1976 | ||
1987 | /* switch to external mic input */ | 1977 | /* switch to external mic input */ |
1988 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | 1978 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
@@ -2004,8 +1994,47 @@ static void cxt5066_automic(struct hda_codec *codec) | |||
2004 | }; | 1994 | }; |
2005 | unsigned int present; | 1995 | unsigned int present; |
2006 | 1996 | ||
2007 | present = snd_hda_codec_read(codec, 0x1a, 0, | 1997 | present = snd_hda_jack_detect(codec, 0x1a); |
2008 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1998 | if (present) { |
1999 | snd_printdd("CXT5066: external microphone detected\n"); | ||
2000 | snd_hda_sequence_write(codec, ext_mic_present); | ||
2001 | } else { | ||
2002 | snd_printdd("CXT5066: external microphone absent\n"); | ||
2003 | snd_hda_sequence_write(codec, ext_mic_absent); | ||
2004 | } | ||
2005 | } | ||
2006 | |||
2007 | /* toggle input of built-in digital mic and mic jack appropriately */ | ||
2008 | static void cxt5066_vostro_automic(struct hda_codec *codec) | ||
2009 | { | ||
2010 | struct conexant_spec *spec = codec->spec; | ||
2011 | unsigned int present; | ||
2012 | |||
2013 | struct hda_verb ext_mic_present[] = { | ||
2014 | /* enable external mic, port B */ | ||
2015 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->ext_mic_bias}, | ||
2016 | |||
2017 | /* switch to external mic input */ | ||
2018 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | ||
2019 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | ||
2020 | |||
2021 | /* disable internal digital mic */ | ||
2022 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2023 | {} | ||
2024 | }; | ||
2025 | static struct hda_verb ext_mic_absent[] = { | ||
2026 | /* enable internal mic, port C */ | ||
2027 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
2028 | |||
2029 | /* switch to internal mic input */ | ||
2030 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, | ||
2031 | |||
2032 | /* disable external mic, port B */ | ||
2033 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2034 | {} | ||
2035 | }; | ||
2036 | |||
2037 | present = snd_hda_jack_detect(codec, 0x1a); | ||
2009 | if (present) { | 2038 | if (present) { |
2010 | snd_printdd("CXT5066: external microphone detected\n"); | 2039 | snd_printdd("CXT5066: external microphone detected\n"); |
2011 | snd_hda_sequence_write(codec, ext_mic_present); | 2040 | snd_hda_sequence_write(codec, ext_mic_present); |
@@ -2022,12 +2051,10 @@ static void cxt5066_hp_automute(struct hda_codec *codec) | |||
2022 | unsigned int portA, portD; | 2051 | unsigned int portA, portD; |
2023 | 2052 | ||
2024 | /* Port A */ | 2053 | /* Port A */ |
2025 | portA = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0) | 2054 | portA = snd_hda_jack_detect(codec, 0x19); |
2026 | & AC_PINSENSE_PRESENCE; | ||
2027 | 2055 | ||
2028 | /* Port D */ | 2056 | /* Port D */ |
2029 | portD = (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) | 2057 | portD = snd_hda_jack_detect(codec, 0x1c); |
2030 | & AC_PINSENSE_PRESENCE) << 1; | ||
2031 | 2058 | ||
2032 | spec->hp_present = !!(portA | portD); | 2059 | spec->hp_present = !!(portA | portD); |
2033 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", | 2060 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", |
@@ -2049,6 +2076,20 @@ static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) | |||
2049 | } | 2076 | } |
2050 | } | 2077 | } |
2051 | 2078 | ||
2079 | /* unsolicited event for jack sensing */ | ||
2080 | static void cxt5066_vostro_event(struct hda_codec *codec, unsigned int res) | ||
2081 | { | ||
2082 | snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res, res >> 26); | ||
2083 | switch (res >> 26) { | ||
2084 | case CONEXANT_HP_EVENT: | ||
2085 | cxt5066_hp_automute(codec); | ||
2086 | break; | ||
2087 | case CONEXANT_MIC_EVENT: | ||
2088 | cxt5066_vostro_automic(codec); | ||
2089 | break; | ||
2090 | } | ||
2091 | } | ||
2092 | |||
2052 | static const struct hda_input_mux cxt5066_analog_mic_boost = { | 2093 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
2053 | .num_items = 5, | 2094 | .num_items = 5, |
2054 | .items = { | 2095 | .items = { |
@@ -2071,9 +2112,12 @@ static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | |||
2071 | { | 2112 | { |
2072 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2113 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2073 | 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; | ||
2074 | 2118 | ||
2075 | val = snd_hda_codec_read(codec, 0x17, 0, | 2119 | val = snd_hda_codec_read(codec, nid, 0, |
2076 | AC_VERB_GET_AMP_GAIN_MUTE, AC_AMP_GET_OUTPUT); | 2120 | AC_VERB_GET_AMP_GAIN_MUTE, inout); |
2077 | 2121 | ||
2078 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; | 2122 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; |
2079 | return 0; | 2123 | return 0; |
@@ -2085,6 +2129,9 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
2085 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2129 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2086 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | 2130 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
2087 | 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; | ||
2088 | 2135 | ||
2089 | if (!imux->num_items) | 2136 | if (!imux->num_items) |
2090 | return 0; | 2137 | return 0; |
@@ -2092,9 +2139,9 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
2092 | if (idx >= imux->num_items) | 2139 | if (idx >= imux->num_items) |
2093 | idx = imux->num_items - 1; | 2140 | idx = imux->num_items - 1; |
2094 | 2141 | ||
2095 | snd_hda_codec_write_cache(codec, 0x17, 0, | 2142 | snd_hda_codec_write_cache(codec, nid, 0, |
2096 | AC_VERB_SET_AMP_GAIN_MUTE, | 2143 | AC_VERB_SET_AMP_GAIN_MUTE, |
2097 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | 2144 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | inout | |
2098 | imux->items[idx].index); | 2145 | imux->items[idx].index); |
2099 | 2146 | ||
2100 | return 1; | 2147 | return 1; |
@@ -2163,10 +2210,11 @@ static struct snd_kcontrol_new cxt5066_mixers[] = { | |||
2163 | 2210 | ||
2164 | { | 2211 | { |
2165 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2212 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2166 | .name = "Analog Mic Boost Capture Enum", | 2213 | .name = "Ext Mic Boost Capture Enum", |
2167 | .info = cxt5066_mic_boost_mux_enum_info, | 2214 | .info = cxt5066_mic_boost_mux_enum_info, |
2168 | .get = cxt5066_mic_boost_mux_enum_get, | 2215 | .get = cxt5066_mic_boost_mux_enum_get, |
2169 | .put = cxt5066_mic_boost_mux_enum_put, | 2216 | .put = cxt5066_mic_boost_mux_enum_put, |
2217 | .private_value = 0x17, | ||
2170 | }, | 2218 | }, |
2171 | 2219 | ||
2172 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | 2220 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), |
@@ -2174,6 +2222,19 @@ static struct snd_kcontrol_new cxt5066_mixers[] = { | |||
2174 | {} | 2222 | {} |
2175 | }; | 2223 | }; |
2176 | 2224 | ||
2225 | static struct snd_kcontrol_new cxt5066_vostro_mixers[] = { | ||
2226 | { | ||
2227 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2228 | .name = "Int Mic Boost Capture Enum", | ||
2229 | .info = cxt5066_mic_boost_mux_enum_info, | ||
2230 | .get = cxt5066_mic_boost_mux_enum_get, | ||
2231 | .put = cxt5066_mic_boost_mux_enum_put, | ||
2232 | .private_value = 0x23 | 0x100, | ||
2233 | }, | ||
2234 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), | ||
2235 | {} | ||
2236 | }; | ||
2237 | |||
2177 | static struct hda_verb cxt5066_init_verbs[] = { | 2238 | static struct hda_verb cxt5066_init_verbs[] = { |
2178 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ | 2239 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
2179 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | 2240 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
@@ -2235,7 +2296,7 @@ static struct hda_verb cxt5066_init_verbs_olpc[] = { | |||
2235 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | 2296 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
2236 | 2297 | ||
2237 | /* Port B: external microphone */ | 2298 | /* Port B: external microphone */ |
2238 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 2299 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, CXT5066_OLPC_EXT_MIC_BIAS}, |
2239 | 2300 | ||
2240 | /* Port C: internal microphone */ | 2301 | /* Port C: internal microphone */ |
2241 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 2302 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
@@ -2290,6 +2351,67 @@ static struct hda_verb cxt5066_init_verbs_olpc[] = { | |||
2290 | { } /* end */ | 2351 | { } /* end */ |
2291 | }; | 2352 | }; |
2292 | 2353 | ||
2354 | static struct hda_verb cxt5066_init_verbs_vostro[] = { | ||
2355 | /* Port A: headphones */ | ||
2356 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2357 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2358 | |||
2359 | /* Port B: external microphone */ | ||
2360 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2361 | |||
2362 | /* Port C: unused */ | ||
2363 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2364 | |||
2365 | /* Port D: unused */ | ||
2366 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2367 | |||
2368 | /* Port E: unused, but has primary EAPD */ | ||
2369 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2370 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
2371 | |||
2372 | /* Port F: unused */ | ||
2373 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2374 | |||
2375 | /* Port G: internal speakers */ | ||
2376 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2377 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2378 | |||
2379 | /* DAC1 */ | ||
2380 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2381 | |||
2382 | /* DAC2: unused */ | ||
2383 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
2384 | |||
2385 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2386 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2387 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2388 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2389 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2390 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2391 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2392 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2393 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2394 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2395 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2396 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2397 | |||
2398 | /* Digital microphone port */ | ||
2399 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
2400 | |||
2401 | /* Audio input selectors */ | ||
2402 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | ||
2403 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
2404 | |||
2405 | /* Disable SPDIF */ | ||
2406 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2407 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2408 | |||
2409 | /* enable unsolicited events for Port A and B */ | ||
2410 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | ||
2411 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | ||
2412 | { } /* end */ | ||
2413 | }; | ||
2414 | |||
2293 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { | 2415 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
2294 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 2416 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2295 | { } /* end */ | 2417 | { } /* end */ |
@@ -2298,11 +2420,16 @@ static struct hda_verb cxt5066_init_verbs_portd_lo[] = { | |||
2298 | /* initialize jack-sensing, too */ | 2420 | /* initialize jack-sensing, too */ |
2299 | static int cxt5066_init(struct hda_codec *codec) | 2421 | static int cxt5066_init(struct hda_codec *codec) |
2300 | { | 2422 | { |
2423 | struct conexant_spec *spec = codec->spec; | ||
2424 | |||
2301 | snd_printdd("CXT5066: init\n"); | 2425 | snd_printdd("CXT5066: init\n"); |
2302 | conexant_init(codec); | 2426 | conexant_init(codec); |
2303 | if (codec->patch_ops.unsol_event) { | 2427 | if (codec->patch_ops.unsol_event) { |
2304 | cxt5066_hp_automute(codec); | 2428 | cxt5066_hp_automute(codec); |
2305 | cxt5066_automic(codec); | 2429 | if (spec->dell_vostro) |
2430 | cxt5066_vostro_automic(codec); | ||
2431 | else | ||
2432 | cxt5066_automic(codec); | ||
2306 | } | 2433 | } |
2307 | return 0; | 2434 | return 0; |
2308 | } | 2435 | } |
@@ -2311,6 +2438,7 @@ enum { | |||
2311 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ | 2438 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ |
2312 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ | 2439 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
2313 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ | 2440 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ |
2441 | CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ | ||
2314 | CXT5066_MODELS | 2442 | CXT5066_MODELS |
2315 | }; | 2443 | }; |
2316 | 2444 | ||
@@ -2318,6 +2446,7 @@ static const char *cxt5066_models[CXT5066_MODELS] = { | |||
2318 | [CXT5066_LAPTOP] = "laptop", | 2446 | [CXT5066_LAPTOP] = "laptop", |
2319 | [CXT5066_DELL_LAPTOP] = "dell-laptop", | 2447 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
2320 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", | 2448 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", |
2449 | [CXT5066_DELL_VOSTO] = "dell-vostro" | ||
2321 | }; | 2450 | }; |
2322 | 2451 | ||
2323 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | 2452 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
@@ -2325,6 +2454,8 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | |||
2325 | CXT5066_LAPTOP), | 2454 | CXT5066_LAPTOP), |
2326 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", | 2455 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", |
2327 | CXT5066_DELL_LAPTOP), | 2456 | CXT5066_DELL_LAPTOP), |
2457 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), | ||
2458 | SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), | ||
2328 | {} | 2459 | {} |
2329 | }; | 2460 | }; |
2330 | 2461 | ||
@@ -2352,6 +2483,7 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2352 | spec->input_mux = &cxt5066_capture_source; | 2483 | spec->input_mux = &cxt5066_capture_source; |
2353 | 2484 | ||
2354 | spec->port_d_mode = PIN_HP; | 2485 | spec->port_d_mode = PIN_HP; |
2486 | spec->ext_mic_bias = PIN_VREF80; | ||
2355 | 2487 | ||
2356 | spec->num_init_verbs = 1; | 2488 | spec->num_init_verbs = 1; |
2357 | spec->init_verbs[0] = cxt5066_init_verbs; | 2489 | spec->init_verbs[0] = cxt5066_init_verbs; |
@@ -2383,6 +2515,23 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2383 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | 2515 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
2384 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | 2516 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
2385 | spec->port_d_mode = 0; | 2517 | spec->port_d_mode = 0; |
2518 | spec->ext_mic_bias = CXT5066_OLPC_EXT_MIC_BIAS; | ||
2519 | |||
2520 | /* no S/PDIF out */ | ||
2521 | spec->multiout.dig_out_nid = 0; | ||
2522 | |||
2523 | /* input source automatically selected */ | ||
2524 | spec->input_mux = NULL; | ||
2525 | break; | ||
2526 | case CXT5066_DELL_VOSTO: | ||
2527 | codec->patch_ops.unsol_event = cxt5066_vostro_event; | ||
2528 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; | ||
2529 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | ||
2530 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2531 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; | ||
2532 | spec->port_d_mode = 0; | ||
2533 | spec->dell_vostro = 1; | ||
2534 | snd_hda_attach_beep_device(codec, 0x13); | ||
2386 | 2535 | ||
2387 | /* no S/PDIF out */ | 2536 | /* no S/PDIF out */ |
2388 | spec->multiout.dig_out_nid = 0; | 2537 | spec->multiout.dig_out_nid = 0; |
@@ -2407,6 +2556,8 @@ static struct hda_codec_preset snd_hda_preset_conexant[] = { | |||
2407 | .patch = patch_cxt5051 }, | 2556 | .patch = patch_cxt5051 }, |
2408 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", | 2557 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
2409 | .patch = patch_cxt5066 }, | 2558 | .patch = patch_cxt5066 }, |
2559 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", | ||
2560 | .patch = patch_cxt5066 }, | ||
2410 | {} /* terminator */ | 2561 | {} /* terminator */ |
2411 | }; | 2562 | }; |
2412 | 2563 | ||
@@ -2414,6 +2565,7 @@ MODULE_ALIAS("snd-hda-codec-id:14f15045"); | |||
2414 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); | 2565 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); |
2415 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); | 2566 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); |
2416 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); | 2567 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
2568 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); | ||
2417 | 2569 | ||
2418 | MODULE_LICENSE("GPL"); | 2570 | MODULE_LICENSE("GPL"); |
2419 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | 2571 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index 01a18ed475ac..918f40378d52 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c | |||
@@ -33,15 +33,41 @@ | |||
33 | #include "hda_codec.h" | 33 | #include "hda_codec.h" |
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | 35 | ||
36 | static hda_nid_t cvt_nid; /* audio converter */ | 36 | /* |
37 | static hda_nid_t pin_nid; /* HDMI output pin */ | 37 | * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device |
38 | * could support two independent pipes, each of them can be connected to one or | ||
39 | * more ports (DVI, HDMI or DisplayPort). | ||
40 | * | ||
41 | * The HDA correspondence of pipes/ports are converter/pin nodes. | ||
42 | */ | ||
43 | #define INTEL_HDMI_CVTS 2 | ||
44 | #define INTEL_HDMI_PINS 3 | ||
38 | 45 | ||
39 | #define INTEL_HDMI_EVENT_TAG 0x08 | 46 | static char *intel_hdmi_pcm_names[INTEL_HDMI_CVTS] = { |
47 | "INTEL HDMI 0", | ||
48 | "INTEL HDMI 1", | ||
49 | }; | ||
40 | 50 | ||
41 | struct intel_hdmi_spec { | 51 | struct intel_hdmi_spec { |
42 | struct hda_multi_out multiout; | 52 | int num_cvts; |
43 | struct hda_pcm pcm_rec; | 53 | int num_pins; |
44 | struct hdmi_eld sink_eld; | 54 | hda_nid_t cvt[INTEL_HDMI_CVTS+1]; /* audio sources */ |
55 | hda_nid_t pin[INTEL_HDMI_PINS+1]; /* audio sinks */ | ||
56 | |||
57 | /* | ||
58 | * source connection for each pin | ||
59 | */ | ||
60 | hda_nid_t pin_cvt[INTEL_HDMI_PINS+1]; | ||
61 | |||
62 | /* | ||
63 | * HDMI sink attached to each pin | ||
64 | */ | ||
65 | struct hdmi_eld sink_eld[INTEL_HDMI_PINS]; | ||
66 | |||
67 | /* | ||
68 | * export one pcm per pipe | ||
69 | */ | ||
70 | struct hda_pcm pcm_rec[INTEL_HDMI_CVTS]; | ||
45 | }; | 71 | }; |
46 | 72 | ||
47 | struct hdmi_audio_infoframe { | 73 | struct hdmi_audio_infoframe { |
@@ -120,38 +146,78 @@ struct cea_channel_speaker_allocation { | |||
120 | }; | 146 | }; |
121 | 147 | ||
122 | /* | 148 | /* |
149 | * ALSA sequence is: | ||
150 | * | ||
151 | * surround40 surround41 surround50 surround51 surround71 | ||
152 | * ch0 front left = = = = | ||
153 | * ch1 front right = = = = | ||
154 | * ch2 rear left = = = = | ||
155 | * ch3 rear right = = = = | ||
156 | * ch4 LFE center center center | ||
157 | * ch5 LFE LFE | ||
158 | * ch6 side left | ||
159 | * ch7 side right | ||
160 | * | ||
161 | * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR} | ||
162 | */ | ||
163 | static int hdmi_channel_mapping[0x32][8] = { | ||
164 | /* stereo */ | ||
165 | [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
166 | /* 2.1 */ | ||
167 | [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
168 | /* Dolby Surround */ | ||
169 | [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
170 | /* surround40 */ | ||
171 | [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 }, | ||
172 | /* 4ch */ | ||
173 | [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, | ||
174 | /* surround41 */ | ||
175 | [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, | ||
176 | /* surround50 */ | ||
177 | [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, | ||
178 | /* surround51 */ | ||
179 | [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 }, | ||
180 | /* 7.1 */ | ||
181 | [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 }, | ||
182 | }; | ||
183 | |||
184 | /* | ||
123 | * This is an ordered list! | 185 | * This is an ordered list! |
124 | * | 186 | * |
125 | * The preceding ones have better chances to be selected by | 187 | * The preceding ones have better chances to be selected by |
126 | * hdmi_setup_channel_allocation(). | 188 | * hdmi_setup_channel_allocation(). |
127 | */ | 189 | */ |
128 | static struct cea_channel_speaker_allocation channel_allocations[] = { | 190 | static struct cea_channel_speaker_allocation channel_allocations[] = { |
129 | /* channel: 8 7 6 5 4 3 2 1 */ | 191 | /* channel: 7 6 5 4 3 2 1 0 */ |
130 | { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, | 192 | { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, |
131 | /* 2.1 */ | 193 | /* 2.1 */ |
132 | { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, | 194 | { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, |
133 | /* Dolby Surround */ | 195 | /* Dolby Surround */ |
134 | { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, | 196 | { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, |
197 | /* surround40 */ | ||
198 | { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, | ||
199 | /* surround41 */ | ||
200 | { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, | ||
201 | /* surround50 */ | ||
202 | { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, | ||
203 | /* surround51 */ | ||
204 | { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, | ||
205 | /* 6.1 */ | ||
206 | { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, | ||
207 | /* surround71 */ | ||
208 | { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, | ||
209 | |||
135 | { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, | 210 | { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, |
136 | { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, | 211 | { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, |
137 | { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, | 212 | { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, |
138 | { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, | 213 | { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, |
139 | { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, | 214 | { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, |
140 | { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, | ||
141 | { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, | ||
142 | { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, | ||
143 | /* 5.1 */ | ||
144 | { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, | ||
145 | { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, | 215 | { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, |
146 | { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, | 216 | { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, |
147 | { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, | 217 | { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, |
148 | /* 6.1 */ | ||
149 | { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, | ||
150 | { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, | 218 | { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, |
151 | { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, | 219 | { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, |
152 | { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, | 220 | { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, |
153 | /* 7.1 */ | ||
154 | { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, | ||
155 | { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, | 221 | { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, |
156 | { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, | 222 | { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, |
157 | { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, | 223 | { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, |
@@ -185,39 +251,195 @@ static struct cea_channel_speaker_allocation channel_allocations[] = { | |||
185 | }; | 251 | }; |
186 | 252 | ||
187 | /* | 253 | /* |
254 | * HDA/HDMI auto parsing | ||
255 | */ | ||
256 | |||
257 | static int hda_node_index(hda_nid_t *nids, hda_nid_t nid) | ||
258 | { | ||
259 | int i; | ||
260 | |||
261 | for (i = 0; nids[i]; i++) | ||
262 | if (nids[i] == nid) | ||
263 | return i; | ||
264 | |||
265 | snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid); | ||
266 | return -EINVAL; | ||
267 | } | ||
268 | |||
269 | static int intel_hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) | ||
270 | { | ||
271 | struct intel_hdmi_spec *spec = codec->spec; | ||
272 | hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; | ||
273 | int conn_len, curr; | ||
274 | int index; | ||
275 | |||
276 | if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { | ||
277 | snd_printk(KERN_WARNING | ||
278 | "HDMI: pin %d wcaps %#x " | ||
279 | "does not support connection list\n", | ||
280 | pin_nid, get_wcaps(codec, pin_nid)); | ||
281 | return -EINVAL; | ||
282 | } | ||
283 | |||
284 | conn_len = snd_hda_get_connections(codec, pin_nid, conn_list, | ||
285 | HDA_MAX_CONNECTIONS); | ||
286 | if (conn_len > 1) | ||
287 | curr = snd_hda_codec_read(codec, pin_nid, 0, | ||
288 | AC_VERB_GET_CONNECT_SEL, 0); | ||
289 | else | ||
290 | curr = 0; | ||
291 | |||
292 | index = hda_node_index(spec->pin, pin_nid); | ||
293 | if (index < 0) | ||
294 | return -EINVAL; | ||
295 | |||
296 | spec->pin_cvt[index] = conn_list[curr]; | ||
297 | |||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid, | ||
302 | struct hdmi_eld *eld) | ||
303 | { | ||
304 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) | ||
305 | snd_hdmi_show_eld(eld); | ||
306 | } | ||
307 | |||
308 | static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, | ||
309 | struct hdmi_eld *eld) | ||
310 | { | ||
311 | int present = snd_hda_pin_sense(codec, pin_nid); | ||
312 | |||
313 | eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); | ||
314 | eld->eld_valid = !!(present & AC_PINSENSE_ELDV); | ||
315 | |||
316 | if (present & AC_PINSENSE_ELDV) | ||
317 | hdmi_get_show_eld(codec, pin_nid, eld); | ||
318 | } | ||
319 | |||
320 | static int intel_hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) | ||
321 | { | ||
322 | struct intel_hdmi_spec *spec = codec->spec; | ||
323 | |||
324 | if (spec->num_pins >= INTEL_HDMI_PINS) { | ||
325 | snd_printk(KERN_WARNING | ||
326 | "HDMI: no space for pin %d \n", pin_nid); | ||
327 | return -EINVAL; | ||
328 | } | ||
329 | |||
330 | hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]); | ||
331 | |||
332 | spec->pin[spec->num_pins] = pin_nid; | ||
333 | spec->num_pins++; | ||
334 | |||
335 | /* | ||
336 | * It is assumed that converter nodes come first in the node list and | ||
337 | * hence have been registered and usable now. | ||
338 | */ | ||
339 | return intel_hdmi_read_pin_conn(codec, pin_nid); | ||
340 | } | ||
341 | |||
342 | static int intel_hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid) | ||
343 | { | ||
344 | struct intel_hdmi_spec *spec = codec->spec; | ||
345 | |||
346 | if (spec->num_cvts >= INTEL_HDMI_CVTS) { | ||
347 | snd_printk(KERN_WARNING | ||
348 | "HDMI: no space for converter %d \n", nid); | ||
349 | return -EINVAL; | ||
350 | } | ||
351 | |||
352 | spec->cvt[spec->num_cvts] = nid; | ||
353 | spec->num_cvts++; | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static int intel_hdmi_parse_codec(struct hda_codec *codec) | ||
359 | { | ||
360 | hda_nid_t nid; | ||
361 | int i, nodes; | ||
362 | |||
363 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); | ||
364 | if (!nid || nodes < 0) { | ||
365 | snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); | ||
366 | return -EINVAL; | ||
367 | } | ||
368 | |||
369 | for (i = 0; i < nodes; i++, nid++) { | ||
370 | unsigned int caps; | ||
371 | unsigned int type; | ||
372 | |||
373 | caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); | ||
374 | type = get_wcaps_type(caps); | ||
375 | |||
376 | if (!(caps & AC_WCAP_DIGITAL)) | ||
377 | continue; | ||
378 | |||
379 | switch (type) { | ||
380 | case AC_WID_AUD_OUT: | ||
381 | if (intel_hdmi_add_cvt(codec, nid) < 0) | ||
382 | return -EINVAL; | ||
383 | break; | ||
384 | case AC_WID_PIN: | ||
385 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
386 | if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) | ||
387 | continue; | ||
388 | if (intel_hdmi_add_pin(codec, nid) < 0) | ||
389 | return -EINVAL; | ||
390 | break; | ||
391 | } | ||
392 | } | ||
393 | |||
394 | /* | ||
395 | * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event | ||
396 | * can be lost and presence sense verb will become inaccurate if the | ||
397 | * HDA link is powered off at hot plug or hw initialization time. | ||
398 | */ | ||
399 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
400 | if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & | ||
401 | AC_PWRST_EPSS)) | ||
402 | codec->bus->power_keep_link_on = 1; | ||
403 | #endif | ||
404 | |||
405 | return 0; | ||
406 | } | ||
407 | |||
408 | /* | ||
188 | * HDMI routines | 409 | * HDMI routines |
189 | */ | 410 | */ |
190 | 411 | ||
191 | #ifdef BE_PARANOID | 412 | #ifdef BE_PARANOID |
192 | static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t nid, | 413 | static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, |
193 | int *packet_index, int *byte_index) | 414 | int *packet_index, int *byte_index) |
194 | { | 415 | { |
195 | int val; | 416 | int val; |
196 | 417 | ||
197 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_INDEX, 0); | 418 | val = snd_hda_codec_read(codec, pin_nid, 0, |
419 | AC_VERB_GET_HDMI_DIP_INDEX, 0); | ||
198 | 420 | ||
199 | *packet_index = val >> 5; | 421 | *packet_index = val >> 5; |
200 | *byte_index = val & 0x1f; | 422 | *byte_index = val & 0x1f; |
201 | } | 423 | } |
202 | #endif | 424 | #endif |
203 | 425 | ||
204 | static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t nid, | 426 | static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, |
205 | int packet_index, int byte_index) | 427 | int packet_index, int byte_index) |
206 | { | 428 | { |
207 | int val; | 429 | int val; |
208 | 430 | ||
209 | val = (packet_index << 5) | (byte_index & 0x1f); | 431 | val = (packet_index << 5) | (byte_index & 0x1f); |
210 | 432 | ||
211 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); | 433 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); |
212 | } | 434 | } |
213 | 435 | ||
214 | static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid, | 436 | static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, |
215 | unsigned char val) | 437 | unsigned char val) |
216 | { | 438 | { |
217 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); | 439 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); |
218 | } | 440 | } |
219 | 441 | ||
220 | static void hdmi_enable_output(struct hda_codec *codec) | 442 | static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid) |
221 | { | 443 | { |
222 | /* Unmute */ | 444 | /* Unmute */ |
223 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) | 445 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) |
@@ -231,7 +453,8 @@ static void hdmi_enable_output(struct hda_codec *codec) | |||
231 | /* | 453 | /* |
232 | * Enable Audio InfoFrame Transmission | 454 | * Enable Audio InfoFrame Transmission |
233 | */ | 455 | */ |
234 | static void hdmi_start_infoframe_trans(struct hda_codec *codec) | 456 | static void hdmi_start_infoframe_trans(struct hda_codec *codec, |
457 | hda_nid_t pin_nid) | ||
235 | { | 458 | { |
236 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | 459 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
237 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, | 460 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
@@ -241,59 +464,50 @@ static void hdmi_start_infoframe_trans(struct hda_codec *codec) | |||
241 | /* | 464 | /* |
242 | * Disable Audio InfoFrame Transmission | 465 | * Disable Audio InfoFrame Transmission |
243 | */ | 466 | */ |
244 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec) | 467 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec, |
468 | hda_nid_t pin_nid) | ||
245 | { | 469 | { |
246 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | 470 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
247 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, | 471 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
248 | AC_DIPXMIT_DISABLE); | 472 | AC_DIPXMIT_DISABLE); |
249 | } | 473 | } |
250 | 474 | ||
251 | static int hdmi_get_channel_count(struct hda_codec *codec) | 475 | static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid) |
252 | { | 476 | { |
253 | return 1 + snd_hda_codec_read(codec, cvt_nid, 0, | 477 | return 1 + snd_hda_codec_read(codec, nid, 0, |
254 | AC_VERB_GET_CVT_CHAN_COUNT, 0); | 478 | AC_VERB_GET_CVT_CHAN_COUNT, 0); |
255 | } | 479 | } |
256 | 480 | ||
257 | static void hdmi_set_channel_count(struct hda_codec *codec, int chs) | 481 | static void hdmi_set_channel_count(struct hda_codec *codec, |
482 | hda_nid_t nid, int chs) | ||
258 | { | 483 | { |
259 | snd_hda_codec_write(codec, cvt_nid, 0, | 484 | if (chs != hdmi_get_channel_count(codec, nid)) |
260 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | 485 | snd_hda_codec_write(codec, nid, 0, |
261 | 486 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | |
262 | if (chs != hdmi_get_channel_count(codec)) | ||
263 | snd_printd(KERN_INFO "HDMI channel count: expect %d, get %d\n", | ||
264 | chs, hdmi_get_channel_count(codec)); | ||
265 | } | 487 | } |
266 | 488 | ||
267 | static void hdmi_debug_channel_mapping(struct hda_codec *codec) | 489 | static void hdmi_debug_channel_mapping(struct hda_codec *codec, |
490 | hda_nid_t pin_nid) | ||
268 | { | 491 | { |
269 | #ifdef CONFIG_SND_DEBUG_VERBOSE | 492 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
270 | int i; | 493 | int i; |
271 | int slot; | 494 | int slot; |
272 | 495 | ||
273 | for (i = 0; i < 8; i++) { | 496 | for (i = 0; i < 8; i++) { |
274 | slot = snd_hda_codec_read(codec, cvt_nid, 0, | 497 | slot = snd_hda_codec_read(codec, pin_nid, 0, |
275 | AC_VERB_GET_HDMI_CHAN_SLOT, i); | 498 | AC_VERB_GET_HDMI_CHAN_SLOT, i); |
276 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", | 499 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", |
277 | slot >> 4, slot & 0x7); | 500 | slot >> 4, slot & 0xf); |
278 | } | 501 | } |
279 | #endif | 502 | #endif |
280 | } | 503 | } |
281 | 504 | ||
282 | static void hdmi_parse_eld(struct hda_codec *codec) | ||
283 | { | ||
284 | struct intel_hdmi_spec *spec = codec->spec; | ||
285 | struct hdmi_eld *eld = &spec->sink_eld; | ||
286 | |||
287 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) | ||
288 | snd_hdmi_show_eld(eld); | ||
289 | } | ||
290 | |||
291 | 505 | ||
292 | /* | 506 | /* |
293 | * Audio InfoFrame routines | 507 | * Audio InfoFrame routines |
294 | */ | 508 | */ |
295 | 509 | ||
296 | static void hdmi_debug_dip_size(struct hda_codec *codec) | 510 | static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) |
297 | { | 511 | { |
298 | #ifdef CONFIG_SND_DEBUG_VERBOSE | 512 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
299 | int i; | 513 | int i; |
@@ -310,7 +524,7 @@ static void hdmi_debug_dip_size(struct hda_codec *codec) | |||
310 | #endif | 524 | #endif |
311 | } | 525 | } |
312 | 526 | ||
313 | static void hdmi_clear_dip_buffers(struct hda_codec *codec) | 527 | static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) |
314 | { | 528 | { |
315 | #ifdef BE_PARANOID | 529 | #ifdef BE_PARANOID |
316 | int i, j; | 530 | int i, j; |
@@ -339,23 +553,35 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec) | |||
339 | #endif | 553 | #endif |
340 | } | 554 | } |
341 | 555 | ||
342 | static void hdmi_fill_audio_infoframe(struct hda_codec *codec, | 556 | static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) |
343 | struct hdmi_audio_infoframe *ai) | ||
344 | { | 557 | { |
345 | u8 *params = (u8 *)ai; | 558 | u8 *bytes = (u8 *)ai; |
346 | u8 sum = 0; | 559 | u8 sum = 0; |
347 | int i; | 560 | int i; |
348 | 561 | ||
349 | hdmi_debug_dip_size(codec); | 562 | ai->checksum = 0; |
350 | hdmi_clear_dip_buffers(codec); /* be paranoid */ | 563 | |
564 | for (i = 0; i < sizeof(*ai); i++) | ||
565 | sum += bytes[i]; | ||
351 | 566 | ||
352 | for (i = 0; i < sizeof(ai); i++) | ||
353 | sum += params[i]; | ||
354 | ai->checksum = - sum; | 567 | ai->checksum = - sum; |
568 | } | ||
569 | |||
570 | static void hdmi_fill_audio_infoframe(struct hda_codec *codec, | ||
571 | hda_nid_t pin_nid, | ||
572 | struct hdmi_audio_infoframe *ai) | ||
573 | { | ||
574 | u8 *bytes = (u8 *)ai; | ||
575 | int i; | ||
576 | |||
577 | hdmi_debug_dip_size(codec, pin_nid); | ||
578 | hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ | ||
579 | |||
580 | hdmi_checksum_audio_infoframe(ai); | ||
355 | 581 | ||
356 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | 582 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
357 | for (i = 0; i < sizeof(ai); i++) | 583 | for (i = 0; i < sizeof(*ai); i++) |
358 | hdmi_write_dip_byte(codec, pin_nid, params[i]); | 584 | hdmi_write_dip_byte(codec, pin_nid, bytes[i]); |
359 | } | 585 | } |
360 | 586 | ||
361 | /* | 587 | /* |
@@ -386,11 +612,11 @@ static void init_channel_allocations(void) | |||
386 | * | 612 | * |
387 | * TODO: it could select the wrong CA from multiple candidates. | 613 | * TODO: it could select the wrong CA from multiple candidates. |
388 | */ | 614 | */ |
389 | static int hdmi_setup_channel_allocation(struct hda_codec *codec, | 615 | static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, |
390 | struct hdmi_audio_infoframe *ai) | 616 | struct hdmi_audio_infoframe *ai) |
391 | { | 617 | { |
392 | struct intel_hdmi_spec *spec = codec->spec; | 618 | struct intel_hdmi_spec *spec = codec->spec; |
393 | struct hdmi_eld *eld = &spec->sink_eld; | 619 | struct hdmi_eld *eld; |
394 | int i; | 620 | int i; |
395 | int spk_mask = 0; | 621 | int spk_mask = 0; |
396 | int channels = 1 + (ai->CC02_CT47 & 0x7); | 622 | int channels = 1 + (ai->CC02_CT47 & 0x7); |
@@ -402,6 +628,11 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec, | |||
402 | if (channels <= 2) | 628 | if (channels <= 2) |
403 | return 0; | 629 | return 0; |
404 | 630 | ||
631 | i = hda_node_index(spec->pin_cvt, nid); | ||
632 | if (i < 0) | ||
633 | return 0; | ||
634 | eld = &spec->sink_eld[i]; | ||
635 | |||
405 | /* | 636 | /* |
406 | * HDMI sink's ELD info cannot always be retrieved for now, e.g. | 637 | * HDMI sink's ELD info cannot always be retrieved for now, e.g. |
407 | * in console or for audio devices. Assume the highest speakers | 638 | * in console or for audio devices. Assume the highest speakers |
@@ -440,30 +671,61 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec, | |||
440 | } | 671 | } |
441 | 672 | ||
442 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, | 673 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, |
443 | struct hdmi_audio_infoframe *ai) | 674 | hda_nid_t pin_nid, |
675 | struct hdmi_audio_infoframe *ai) | ||
444 | { | 676 | { |
445 | int i; | 677 | int i; |
678 | int ca = ai->CA; | ||
679 | int err; | ||
446 | 680 | ||
447 | if (!ai->CA) | 681 | if (hdmi_channel_mapping[ca][1] == 0) { |
448 | return; | 682 | for (i = 0; i < channel_allocations[ca].channels; i++) |
449 | 683 | hdmi_channel_mapping[ca][i] = i | (i << 4); | |
450 | /* | 684 | for (; i < 8; i++) |
451 | * TODO: adjust channel mapping if necessary | 685 | hdmi_channel_mapping[ca][i] = 0xf | (i << 4); |
452 | * ALSA sequence is front/surr/clfe/side? | 686 | } |
453 | */ | ||
454 | 687 | ||
455 | for (i = 0; i < 8; i++) | 688 | for (i = 0; i < 8; i++) { |
456 | snd_hda_codec_write(codec, cvt_nid, 0, | 689 | err = snd_hda_codec_write(codec, pin_nid, 0, |
457 | AC_VERB_SET_HDMI_CHAN_SLOT, | 690 | AC_VERB_SET_HDMI_CHAN_SLOT, |
458 | (i << 4) | i); | 691 | hdmi_channel_mapping[ca][i]); |
692 | if (err) { | ||
693 | snd_printdd(KERN_INFO "HDMI: channel mapping failed\n"); | ||
694 | break; | ||
695 | } | ||
696 | } | ||
459 | 697 | ||
460 | hdmi_debug_channel_mapping(codec); | 698 | hdmi_debug_channel_mapping(codec, pin_nid); |
461 | } | 699 | } |
462 | 700 | ||
701 | static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, | ||
702 | struct hdmi_audio_infoframe *ai) | ||
703 | { | ||
704 | u8 *bytes = (u8 *)ai; | ||
705 | u8 val; | ||
706 | int i; | ||
707 | |||
708 | if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) | ||
709 | != AC_DIPXMIT_BEST) | ||
710 | return false; | ||
711 | |||
712 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
713 | for (i = 0; i < sizeof(*ai); i++) { | ||
714 | val = snd_hda_codec_read(codec, pin_nid, 0, | ||
715 | AC_VERB_GET_HDMI_DIP_DATA, 0); | ||
716 | if (val != bytes[i]) | ||
717 | return false; | ||
718 | } | ||
719 | |||
720 | return true; | ||
721 | } | ||
463 | 722 | ||
464 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, | 723 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, |
465 | struct snd_pcm_substream *substream) | 724 | struct snd_pcm_substream *substream) |
466 | { | 725 | { |
726 | struct intel_hdmi_spec *spec = codec->spec; | ||
727 | hda_nid_t pin_nid; | ||
728 | int i; | ||
467 | struct hdmi_audio_infoframe ai = { | 729 | struct hdmi_audio_infoframe ai = { |
468 | .type = 0x84, | 730 | .type = 0x84, |
469 | .ver = 0x01, | 731 | .ver = 0x01, |
@@ -471,11 +733,22 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, | |||
471 | .CC02_CT47 = substream->runtime->channels - 1, | 733 | .CC02_CT47 = substream->runtime->channels - 1, |
472 | }; | 734 | }; |
473 | 735 | ||
474 | hdmi_setup_channel_allocation(codec, &ai); | 736 | hdmi_setup_channel_allocation(codec, nid, &ai); |
475 | hdmi_setup_channel_mapping(codec, &ai); | ||
476 | 737 | ||
477 | hdmi_fill_audio_infoframe(codec, &ai); | 738 | for (i = 0; i < spec->num_pins; i++) { |
478 | hdmi_start_infoframe_trans(codec); | 739 | if (spec->pin_cvt[i] != nid) |
740 | continue; | ||
741 | if (!spec->sink_eld[i].monitor_present) | ||
742 | continue; | ||
743 | |||
744 | pin_nid = spec->pin[i]; | ||
745 | if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { | ||
746 | hdmi_setup_channel_mapping(codec, pin_nid, &ai); | ||
747 | hdmi_stop_infoframe_trans(codec, pin_nid); | ||
748 | hdmi_fill_audio_infoframe(codec, pin_nid, &ai); | ||
749 | hdmi_start_infoframe_trans(codec, pin_nid); | ||
750 | } | ||
751 | } | ||
479 | } | 752 | } |
480 | 753 | ||
481 | 754 | ||
@@ -485,27 +758,39 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, | |||
485 | 758 | ||
486 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) | 759 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) |
487 | { | 760 | { |
761 | struct intel_hdmi_spec *spec = codec->spec; | ||
762 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
488 | int pind = !!(res & AC_UNSOL_RES_PD); | 763 | int pind = !!(res & AC_UNSOL_RES_PD); |
489 | int eldv = !!(res & AC_UNSOL_RES_ELDV); | 764 | int eldv = !!(res & AC_UNSOL_RES_ELDV); |
765 | int index; | ||
490 | 766 | ||
491 | printk(KERN_INFO | 767 | printk(KERN_INFO |
492 | "HDMI hot plug event: Presence_Detect=%d ELD_Valid=%d\n", | 768 | "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n", |
493 | pind, eldv); | 769 | tag, pind, eldv); |
770 | |||
771 | index = hda_node_index(spec->pin, tag); | ||
772 | if (index < 0) | ||
773 | return; | ||
774 | |||
775 | spec->sink_eld[index].monitor_present = pind; | ||
776 | spec->sink_eld[index].eld_valid = eldv; | ||
494 | 777 | ||
495 | if (pind && eldv) { | 778 | if (pind && eldv) { |
496 | hdmi_parse_eld(codec); | 779 | hdmi_get_show_eld(codec, spec->pin[index], &spec->sink_eld[index]); |
497 | /* TODO: do real things about ELD */ | 780 | /* TODO: do real things about ELD */ |
498 | } | 781 | } |
499 | } | 782 | } |
500 | 783 | ||
501 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) | 784 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) |
502 | { | 785 | { |
786 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
503 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; | 787 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; |
504 | int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); | 788 | int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); |
505 | int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); | 789 | int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); |
506 | 790 | ||
507 | printk(KERN_INFO | 791 | printk(KERN_INFO |
508 | "HDMI content protection event: SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", | 792 | "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", |
793 | tag, | ||
509 | subtag, | 794 | subtag, |
510 | cp_state, | 795 | cp_state, |
511 | cp_ready); | 796 | cp_ready); |
@@ -520,10 +805,11 @@ static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) | |||
520 | 805 | ||
521 | static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res) | 806 | static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res) |
522 | { | 807 | { |
808 | struct intel_hdmi_spec *spec = codec->spec; | ||
523 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | 809 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; |
524 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; | 810 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; |
525 | 811 | ||
526 | if (tag != INTEL_HDMI_EVENT_TAG) { | 812 | if (hda_node_index(spec->pin, tag) < 0) { |
527 | snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); | 813 | snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); |
528 | return; | 814 | return; |
529 | } | 815 | } |
@@ -538,24 +824,29 @@ static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res) | |||
538 | * Callbacks | 824 | * Callbacks |
539 | */ | 825 | */ |
540 | 826 | ||
541 | static int intel_hdmi_playback_pcm_open(struct hda_pcm_stream *hinfo, | 827 | static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, |
542 | struct hda_codec *codec, | 828 | u32 stream_tag, int format) |
543 | struct snd_pcm_substream *substream) | ||
544 | { | 829 | { |
545 | struct intel_hdmi_spec *spec = codec->spec; | 830 | int tag; |
546 | 831 | int fmt; | |
547 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | ||
548 | } | ||
549 | 832 | ||
550 | static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo, | 833 | tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; |
551 | struct hda_codec *codec, | 834 | fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); |
552 | struct snd_pcm_substream *substream) | ||
553 | { | ||
554 | struct intel_hdmi_spec *spec = codec->spec; | ||
555 | 835 | ||
556 | hdmi_stop_infoframe_trans(codec); | 836 | snd_printdd("hdmi_setup_stream: " |
837 | "NID=0x%x, %sstream=0x%x, %sformat=0x%x\n", | ||
838 | nid, | ||
839 | tag == stream_tag ? "" : "new-", | ||
840 | stream_tag, | ||
841 | fmt == format ? "" : "new-", | ||
842 | format); | ||
557 | 843 | ||
558 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | 844 | if (tag != stream_tag) |
845 | snd_hda_codec_write(codec, nid, 0, | ||
846 | AC_VERB_SET_CHANNEL_STREAMID, stream_tag << 4); | ||
847 | if (fmt != format) | ||
848 | snd_hda_codec_write(codec, nid, 0, | ||
849 | AC_VERB_SET_STREAM_FORMAT, format); | ||
559 | } | 850 | } |
560 | 851 | ||
561 | static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 852 | static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
@@ -564,43 +855,53 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
564 | unsigned int format, | 855 | unsigned int format, |
565 | struct snd_pcm_substream *substream) | 856 | struct snd_pcm_substream *substream) |
566 | { | 857 | { |
567 | struct intel_hdmi_spec *spec = codec->spec; | 858 | hdmi_set_channel_count(codec, hinfo->nid, |
568 | 859 | substream->runtime->channels); | |
569 | snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, | ||
570 | format, substream); | ||
571 | 860 | ||
572 | hdmi_set_channel_count(codec, substream->runtime->channels); | 861 | hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); |
573 | 862 | ||
574 | hdmi_setup_audio_infoframe(codec, substream); | 863 | hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); |
864 | return 0; | ||
865 | } | ||
575 | 866 | ||
867 | static int intel_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
868 | struct hda_codec *codec, | ||
869 | struct snd_pcm_substream *substream) | ||
870 | { | ||
576 | return 0; | 871 | return 0; |
577 | } | 872 | } |
578 | 873 | ||
579 | static struct hda_pcm_stream intel_hdmi_pcm_playback = { | 874 | static struct hda_pcm_stream intel_hdmi_pcm_playback = { |
580 | .substreams = 1, | 875 | .substreams = 1, |
581 | .channels_min = 2, | 876 | .channels_min = 2, |
582 | .channels_max = 8, | ||
583 | .ops = { | 877 | .ops = { |
584 | .open = intel_hdmi_playback_pcm_open, | 878 | .prepare = intel_hdmi_playback_pcm_prepare, |
585 | .close = intel_hdmi_playback_pcm_close, | 879 | .cleanup = intel_hdmi_playback_pcm_cleanup, |
586 | .prepare = intel_hdmi_playback_pcm_prepare | ||
587 | }, | 880 | }, |
588 | }; | 881 | }; |
589 | 882 | ||
590 | static int intel_hdmi_build_pcms(struct hda_codec *codec) | 883 | static int intel_hdmi_build_pcms(struct hda_codec *codec) |
591 | { | 884 | { |
592 | struct intel_hdmi_spec *spec = codec->spec; | 885 | struct intel_hdmi_spec *spec = codec->spec; |
593 | struct hda_pcm *info = &spec->pcm_rec; | 886 | struct hda_pcm *info = spec->pcm_rec; |
887 | int i; | ||
594 | 888 | ||
595 | codec->num_pcms = 1; | 889 | codec->num_pcms = spec->num_cvts; |
596 | codec->pcm_info = info; | 890 | codec->pcm_info = info; |
597 | 891 | ||
598 | /* NID to query formats and rates and setup streams */ | 892 | for (i = 0; i < codec->num_pcms; i++, info++) { |
599 | intel_hdmi_pcm_playback.nid = cvt_nid; | 893 | unsigned int chans; |
894 | |||
895 | chans = get_wcaps(codec, spec->cvt[i]); | ||
896 | chans = get_wcaps_channels(chans); | ||
600 | 897 | ||
601 | info->name = "INTEL HDMI"; | 898 | info->name = intel_hdmi_pcm_names[i]; |
602 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 899 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
603 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = intel_hdmi_pcm_playback; | 900 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
901 | intel_hdmi_pcm_playback; | ||
902 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; | ||
903 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; | ||
904 | } | ||
604 | 905 | ||
605 | return 0; | 906 | return 0; |
606 | } | 907 | } |
@@ -609,29 +910,39 @@ static int intel_hdmi_build_controls(struct hda_codec *codec) | |||
609 | { | 910 | { |
610 | struct intel_hdmi_spec *spec = codec->spec; | 911 | struct intel_hdmi_spec *spec = codec->spec; |
611 | int err; | 912 | int err; |
913 | int i; | ||
612 | 914 | ||
613 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | 915 | for (i = 0; i < codec->num_pcms; i++) { |
614 | if (err < 0) | 916 | err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]); |
615 | return err; | 917 | if (err < 0) |
918 | return err; | ||
919 | } | ||
616 | 920 | ||
617 | return 0; | 921 | return 0; |
618 | } | 922 | } |
619 | 923 | ||
620 | static int intel_hdmi_init(struct hda_codec *codec) | 924 | static int intel_hdmi_init(struct hda_codec *codec) |
621 | { | 925 | { |
622 | hdmi_enable_output(codec); | 926 | struct intel_hdmi_spec *spec = codec->spec; |
927 | int i; | ||
623 | 928 | ||
624 | snd_hda_codec_write(codec, pin_nid, 0, | 929 | for (i = 0; spec->pin[i]; i++) { |
625 | AC_VERB_SET_UNSOLICITED_ENABLE, | 930 | hdmi_enable_output(codec, spec->pin[i]); |
626 | AC_USRSP_EN | INTEL_HDMI_EVENT_TAG); | 931 | snd_hda_codec_write(codec, spec->pin[i], 0, |
932 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
933 | AC_USRSP_EN | spec->pin[i]); | ||
934 | } | ||
627 | return 0; | 935 | return 0; |
628 | } | 936 | } |
629 | 937 | ||
630 | static void intel_hdmi_free(struct hda_codec *codec) | 938 | static void intel_hdmi_free(struct hda_codec *codec) |
631 | { | 939 | { |
632 | struct intel_hdmi_spec *spec = codec->spec; | 940 | struct intel_hdmi_spec *spec = codec->spec; |
941 | int i; | ||
942 | |||
943 | for (i = 0; i < spec->num_pins; i++) | ||
944 | snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); | ||
633 | 945 | ||
634 | snd_hda_eld_proc_free(codec, &spec->sink_eld); | ||
635 | kfree(spec); | 946 | kfree(spec); |
636 | } | 947 | } |
637 | 948 | ||
@@ -643,49 +954,38 @@ static struct hda_codec_ops intel_hdmi_patch_ops = { | |||
643 | .unsol_event = intel_hdmi_unsol_event, | 954 | .unsol_event = intel_hdmi_unsol_event, |
644 | }; | 955 | }; |
645 | 956 | ||
646 | static int do_patch_intel_hdmi(struct hda_codec *codec) | 957 | static int patch_intel_hdmi(struct hda_codec *codec) |
647 | { | 958 | { |
648 | struct intel_hdmi_spec *spec; | 959 | struct intel_hdmi_spec *spec; |
960 | int i; | ||
649 | 961 | ||
650 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 962 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
651 | if (spec == NULL) | 963 | if (spec == NULL) |
652 | return -ENOMEM; | 964 | return -ENOMEM; |
653 | 965 | ||
654 | spec->multiout.num_dacs = 0; /* no analog */ | ||
655 | spec->multiout.max_channels = 8; | ||
656 | spec->multiout.dig_out_nid = cvt_nid; | ||
657 | |||
658 | codec->spec = spec; | 966 | codec->spec = spec; |
967 | if (intel_hdmi_parse_codec(codec) < 0) { | ||
968 | codec->spec = NULL; | ||
969 | kfree(spec); | ||
970 | return -EINVAL; | ||
971 | } | ||
659 | codec->patch_ops = intel_hdmi_patch_ops; | 972 | codec->patch_ops = intel_hdmi_patch_ops; |
660 | 973 | ||
661 | snd_hda_eld_proc_new(codec, &spec->sink_eld); | 974 | for (i = 0; i < spec->num_pins; i++) |
975 | snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); | ||
662 | 976 | ||
663 | init_channel_allocations(); | 977 | init_channel_allocations(); |
664 | 978 | ||
665 | return 0; | 979 | return 0; |
666 | } | 980 | } |
667 | 981 | ||
668 | static int patch_intel_hdmi(struct hda_codec *codec) | ||
669 | { | ||
670 | cvt_nid = 0x02; | ||
671 | pin_nid = 0x03; | ||
672 | return do_patch_intel_hdmi(codec); | ||
673 | } | ||
674 | |||
675 | static int patch_intel_hdmi_ibexpeak(struct hda_codec *codec) | ||
676 | { | ||
677 | cvt_nid = 0x02; | ||
678 | pin_nid = 0x04; | ||
679 | return do_patch_intel_hdmi(codec); | ||
680 | } | ||
681 | |||
682 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { | 982 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { |
683 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, | 983 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, |
684 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, | 984 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, |
685 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, | 985 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, |
686 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, | 986 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, |
687 | { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi }, | 987 | { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi }, |
688 | { .id = 0x80860054, .name = "Q57 DEVIBX", .patch = patch_intel_hdmi_ibexpeak }, | 988 | { .id = 0x80860054, .name = "Q57 DEVIBX", .patch = patch_intel_hdmi }, |
689 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, | 989 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, |
690 | {} /* terminator */ | 990 | {} /* terminator */ |
691 | }; | 991 | }; |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index 9fb60276f5c9..6afdab09bab7 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -397,6 +397,7 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) | |||
397 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | 397 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { |
398 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 398 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
399 | { .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 399 | { .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
400 | { .id = 0x10de0005, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
400 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 401 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
401 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, | 402 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, |
402 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, | 403 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
@@ -406,6 +407,7 @@ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | |||
406 | 407 | ||
407 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); | 408 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); |
408 | MODULE_ALIAS("snd-hda-codec-id:10de0003"); | 409 | MODULE_ALIAS("snd-hda-codec-id:10de0003"); |
410 | MODULE_ALIAS("snd-hda-codec-id:10de0005"); | ||
409 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); | 411 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); |
410 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); | 412 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); |
411 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); | 413 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ff20048504b6..c7465053d6bb 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, |
@@ -208,6 +210,7 @@ enum { | |||
208 | ALC885_MBP3, | 210 | ALC885_MBP3, |
209 | ALC885_MB5, | 211 | ALC885_MB5, |
210 | ALC885_IMAC24, | 212 | ALC885_IMAC24, |
213 | ALC885_IMAC91, | ||
211 | ALC883_3ST_2ch_DIG, | 214 | ALC883_3ST_2ch_DIG, |
212 | ALC883_3ST_6ch_DIG, | 215 | ALC883_3ST_6ch_DIG, |
213 | ALC883_3ST_6ch, | 216 | ALC883_3ST_6ch, |
@@ -334,6 +337,9 @@ struct alc_spec { | |||
334 | /* hooks */ | 337 | /* hooks */ |
335 | void (*init_hook)(struct hda_codec *codec); | 338 | void (*init_hook)(struct hda_codec *codec); |
336 | 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 | ||
337 | 343 | ||
338 | /* for pin sensing */ | 344 | /* for pin sensing */ |
339 | unsigned int sense_updated: 1; | 345 | unsigned int sense_updated: 1; |
@@ -385,6 +391,7 @@ struct alc_config_preset { | |||
385 | void (*init_hook)(struct hda_codec *); | 391 | void (*init_hook)(struct hda_codec *); |
386 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 392 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
387 | struct hda_amp_list *loopbacks; | 393 | struct hda_amp_list *loopbacks; |
394 | void (*power_hook)(struct hda_codec *codec, int power); | ||
388 | #endif | 395 | #endif |
389 | }; | 396 | }; |
390 | 397 | ||
@@ -897,6 +904,7 @@ static void setup_preset(struct hda_codec *codec, | |||
897 | spec->unsol_event = preset->unsol_event; | 904 | spec->unsol_event = preset->unsol_event; |
898 | spec->init_hook = preset->init_hook; | 905 | spec->init_hook = preset->init_hook; |
899 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 906 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
907 | spec->power_hook = preset->power_hook; | ||
900 | spec->loopback.amplist = preset->loopbacks; | 908 | spec->loopback.amplist = preset->loopbacks; |
901 | #endif | 909 | #endif |
902 | 910 | ||
@@ -961,18 +969,12 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
961 | static void alc_automute_pin(struct hda_codec *codec) | 969 | static void alc_automute_pin(struct hda_codec *codec) |
962 | { | 970 | { |
963 | struct alc_spec *spec = codec->spec; | 971 | struct alc_spec *spec = codec->spec; |
964 | unsigned int present, pincap; | ||
965 | unsigned int nid = spec->autocfg.hp_pins[0]; | 972 | unsigned int nid = spec->autocfg.hp_pins[0]; |
966 | int i; | 973 | int i; |
967 | 974 | ||
968 | if (!nid) | 975 | if (!nid) |
969 | return; | 976 | return; |
970 | pincap = snd_hda_query_pin_caps(codec, nid); | 977 | spec->jack_present = snd_hda_jack_detect(codec, nid); |
971 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
972 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
973 | present = snd_hda_codec_read(codec, nid, 0, | ||
974 | AC_VERB_GET_PIN_SENSE, 0); | ||
975 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
976 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { | 978 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { |
977 | nid = spec->autocfg.speaker_pins[i]; | 979 | nid = spec->autocfg.speaker_pins[i]; |
978 | if (!nid) | 980 | if (!nid) |
@@ -1012,9 +1014,7 @@ static void alc_mic_automute(struct hda_codec *codec) | |||
1012 | 1014 | ||
1013 | cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; | 1015 | cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; |
1014 | 1016 | ||
1015 | present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0, | 1017 | present = snd_hda_jack_detect(codec, spec->ext_mic.pin); |
1016 | AC_VERB_GET_PIN_SENSE, 0); | ||
1017 | present &= AC_PINSENSE_PRESENCE; | ||
1018 | if (present) { | 1018 | if (present) { |
1019 | alive = &spec->ext_mic; | 1019 | alive = &spec->ext_mic; |
1020 | dead = &spec->int_mic; | 1020 | dead = &spec->int_mic; |
@@ -1402,6 +1402,17 @@ static void alc_pick_fixup(struct hda_codec *codec, | |||
1402 | add_verb(codec->spec, fix->verbs); | 1402 | add_verb(codec->spec, fix->verbs); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | static int alc_read_coef_idx(struct hda_codec *codec, | ||
1406 | unsigned int coef_idx) | ||
1407 | { | ||
1408 | unsigned int val; | ||
1409 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, | ||
1410 | coef_idx); | ||
1411 | val = snd_hda_codec_read(codec, 0x20, 0, | ||
1412 | AC_VERB_GET_PROC_COEF, 0); | ||
1413 | return val; | ||
1414 | } | ||
1415 | |||
1405 | /* | 1416 | /* |
1406 | * ALC888 | 1417 | * ALC888 |
1407 | */ | 1418 | */ |
@@ -1513,7 +1524,7 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |||
1513 | static void alc_automute_amp(struct hda_codec *codec) | 1524 | static void alc_automute_amp(struct hda_codec *codec) |
1514 | { | 1525 | { |
1515 | struct alc_spec *spec = codec->spec; | 1526 | struct alc_spec *spec = codec->spec; |
1516 | unsigned int val, mute, pincap; | 1527 | unsigned int mute; |
1517 | hda_nid_t nid; | 1528 | hda_nid_t nid; |
1518 | int i; | 1529 | int i; |
1519 | 1530 | ||
@@ -1522,13 +1533,7 @@ static void alc_automute_amp(struct hda_codec *codec) | |||
1522 | nid = spec->autocfg.hp_pins[i]; | 1533 | nid = spec->autocfg.hp_pins[i]; |
1523 | if (!nid) | 1534 | if (!nid) |
1524 | break; | 1535 | break; |
1525 | pincap = snd_hda_query_pin_caps(codec, nid); | 1536 | if (snd_hda_jack_detect(codec, nid)) { |
1526 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
1527 | snd_hda_codec_read(codec, nid, 0, | ||
1528 | AC_VERB_SET_PIN_SENSE, 0); | ||
1529 | val = snd_hda_codec_read(codec, nid, 0, | ||
1530 | AC_VERB_GET_PIN_SENSE, 0); | ||
1531 | if (val & AC_PINSENSE_PRESENCE) { | ||
1532 | spec->jack_present = 1; | 1537 | spec->jack_present = 1; |
1533 | break; | 1538 | break; |
1534 | } | 1539 | } |
@@ -1665,9 +1670,6 @@ static struct hda_verb alc889_acer_aspire_8930g_verbs[] = { | |||
1665 | /* some bit here disables the other DACs. Init=0x4900 */ | 1670 | /* some bit here disables the other DACs. Init=0x4900 */ |
1666 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, | 1671 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, |
1667 | {0x20, AC_VERB_SET_PROC_COEF, 0x0000}, | 1672 | {0x20, AC_VERB_SET_PROC_COEF, 0x0000}, |
1668 | /* Enable amplifiers */ | ||
1669 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
1670 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
1671 | /* DMIC fix | 1673 | /* DMIC fix |
1672 | * This laptop has a stereo digital microphone. The mics are only 1cm apart | 1674 | * This laptop has a stereo digital microphone. The mics are only 1cm apart |
1673 | * which makes the stereo useless. However, either the mic or the ALC889 | 1675 | * which makes the stereo useless. However, either the mic or the ALC889 |
@@ -1780,12 +1782,33 @@ static struct snd_kcontrol_new alc888_base_mixer[] = { | |||
1780 | { } /* end */ | 1782 | { } /* end */ |
1781 | }; | 1783 | }; |
1782 | 1784 | ||
1785 | static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = { | ||
1786 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
1787 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
1788 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
1789 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
1790 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | ||
1791 | HDA_OUTPUT), | ||
1792 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
1793 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
1794 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
1795 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
1796 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
1797 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
1798 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
1799 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
1800 | { } /* end */ | ||
1801 | }; | ||
1802 | |||
1803 | |||
1783 | static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) | 1804 | static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) |
1784 | { | 1805 | { |
1785 | struct alc_spec *spec = codec->spec; | 1806 | struct alc_spec *spec = codec->spec; |
1786 | 1807 | ||
1787 | spec->autocfg.hp_pins[0] = 0x15; | 1808 | spec->autocfg.hp_pins[0] = 0x15; |
1788 | spec->autocfg.speaker_pins[0] = 0x14; | 1809 | spec->autocfg.speaker_pins[0] = 0x14; |
1810 | spec->autocfg.speaker_pins[1] = 0x16; | ||
1811 | spec->autocfg.speaker_pins[2] = 0x17; | ||
1789 | } | 1812 | } |
1790 | 1813 | ||
1791 | static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) | 1814 | static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) |
@@ -1808,6 +1831,16 @@ static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) | |||
1808 | spec->autocfg.speaker_pins[2] = 0x1b; | 1831 | spec->autocfg.speaker_pins[2] = 0x1b; |
1809 | } | 1832 | } |
1810 | 1833 | ||
1834 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
1835 | static void alc889_power_eapd(struct hda_codec *codec, int power) | ||
1836 | { | ||
1837 | snd_hda_codec_write(codec, 0x14, 0, | ||
1838 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1839 | snd_hda_codec_write(codec, 0x15, 0, | ||
1840 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1841 | } | ||
1842 | #endif | ||
1843 | |||
1811 | /* | 1844 | /* |
1812 | * ALC880 3-stack model | 1845 | * ALC880 3-stack model |
1813 | * | 1846 | * |
@@ -2401,6 +2434,8 @@ static const char *alc_slave_sws[] = { | |||
2401 | "Speaker Playback Switch", | 2434 | "Speaker Playback Switch", |
2402 | "Mono Playback Switch", | 2435 | "Mono Playback Switch", |
2403 | "IEC958 Playback Switch", | 2436 | "IEC958 Playback Switch", |
2437 | "Line-Out Playback Switch", | ||
2438 | "PCM Playback Switch", | ||
2404 | NULL, | 2439 | NULL, |
2405 | }; | 2440 | }; |
2406 | 2441 | ||
@@ -2410,12 +2445,14 @@ static const char *alc_slave_sws[] = { | |||
2410 | 2445 | ||
2411 | static void alc_free_kctls(struct hda_codec *codec); | 2446 | static void alc_free_kctls(struct hda_codec *codec); |
2412 | 2447 | ||
2448 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2413 | /* additional beep mixers; the actual parameters are overwritten at build */ | 2449 | /* additional beep mixers; the actual parameters are overwritten at build */ |
2414 | static struct snd_kcontrol_new alc_beep_mixer[] = { | 2450 | static struct snd_kcontrol_new alc_beep_mixer[] = { |
2415 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), | 2451 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
2416 | HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT), | 2452 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
2417 | { } /* end */ | 2453 | { } /* end */ |
2418 | }; | 2454 | }; |
2455 | #endif | ||
2419 | 2456 | ||
2420 | static int alc_build_controls(struct hda_codec *codec) | 2457 | static int alc_build_controls(struct hda_codec *codec) |
2421 | { | 2458 | { |
@@ -2452,6 +2489,7 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2452 | return err; | 2489 | return err; |
2453 | } | 2490 | } |
2454 | 2491 | ||
2492 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
2455 | /* create beep controls if needed */ | 2493 | /* create beep controls if needed */ |
2456 | if (spec->beep_amp) { | 2494 | if (spec->beep_amp) { |
2457 | struct snd_kcontrol_new *knew; | 2495 | struct snd_kcontrol_new *knew; |
@@ -2461,11 +2499,13 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2461 | if (!kctl) | 2499 | if (!kctl) |
2462 | return -ENOMEM; | 2500 | return -ENOMEM; |
2463 | kctl->private_value = spec->beep_amp; | 2501 | kctl->private_value = spec->beep_amp; |
2464 | err = snd_hda_ctl_add(codec, kctl); | 2502 | err = snd_hda_ctl_add(codec, |
2503 | get_amp_nid_(spec->beep_amp), kctl); | ||
2465 | if (err < 0) | 2504 | if (err < 0) |
2466 | return err; | 2505 | return err; |
2467 | } | 2506 | } |
2468 | } | 2507 | } |
2508 | #endif | ||
2469 | 2509 | ||
2470 | /* if we have no master control, let's create it */ | 2510 | /* if we have no master control, let's create it */ |
2471 | if (!spec->no_analog && | 2511 | if (!spec->no_analog && |
@@ -2779,8 +2819,7 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |||
2779 | unsigned int present; | 2819 | unsigned int present; |
2780 | unsigned char bits; | 2820 | unsigned char bits; |
2781 | 2821 | ||
2782 | present = snd_hda_codec_read(codec, 0x18, 0, | 2822 | present = snd_hda_jack_detect(codec, 0x18); |
2783 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2784 | bits = present ? HDA_AMP_MUTE : 0; | 2823 | bits = present ? HDA_AMP_MUTE : 0; |
2785 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 2824 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
2786 | } | 2825 | } |
@@ -3480,7 +3519,7 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
3480 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), | 3519 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
3481 | "%s Analog", codec->chip_name); | 3520 | "%s Analog", codec->chip_name); |
3482 | info->name = spec->stream_name_analog; | 3521 | info->name = spec->stream_name_analog; |
3483 | 3522 | ||
3484 | if (spec->stream_analog_playback) { | 3523 | if (spec->stream_analog_playback) { |
3485 | if (snd_BUG_ON(!spec->multiout.dac_nids)) | 3524 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
3486 | return -EINVAL; | 3525 | return -EINVAL; |
@@ -3595,12 +3634,29 @@ static void alc_free(struct hda_codec *codec) | |||
3595 | snd_hda_detach_beep_device(codec); | 3634 | snd_hda_detach_beep_device(codec); |
3596 | } | 3635 | } |
3597 | 3636 | ||
3637 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3638 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) | ||
3639 | { | ||
3640 | struct alc_spec *spec = codec->spec; | ||
3641 | if (spec && spec->power_hook) | ||
3642 | spec->power_hook(codec, 0); | ||
3643 | return 0; | ||
3644 | } | ||
3645 | #endif | ||
3646 | |||
3598 | #ifdef SND_HDA_NEEDS_RESUME | 3647 | #ifdef SND_HDA_NEEDS_RESUME |
3599 | static int alc_resume(struct hda_codec *codec) | 3648 | static int alc_resume(struct hda_codec *codec) |
3600 | { | 3649 | { |
3650 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3651 | struct alc_spec *spec = codec->spec; | ||
3652 | #endif | ||
3601 | codec->patch_ops.init(codec); | 3653 | codec->patch_ops.init(codec); |
3602 | snd_hda_codec_resume_amp(codec); | 3654 | snd_hda_codec_resume_amp(codec); |
3603 | snd_hda_codec_resume_cache(codec); | 3655 | snd_hda_codec_resume_cache(codec); |
3656 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3657 | if (spec && spec->power_hook) | ||
3658 | spec->power_hook(codec, 1); | ||
3659 | #endif | ||
3604 | return 0; | 3660 | return 0; |
3605 | } | 3661 | } |
3606 | #endif | 3662 | #endif |
@@ -3617,6 +3673,7 @@ static struct hda_codec_ops alc_patch_ops = { | |||
3617 | .resume = alc_resume, | 3673 | .resume = alc_resume, |
3618 | #endif | 3674 | #endif |
3619 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3675 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3676 | .suspend = alc_suspend, | ||
3620 | .check_power_status = alc_check_power_status, | 3677 | .check_power_status = alc_check_power_status, |
3621 | #endif | 3678 | #endif |
3622 | }; | 3679 | }; |
@@ -4322,10 +4379,26 @@ static int add_control(struct alc_spec *spec, int type, const char *name, | |||
4322 | knew->name = kstrdup(name, GFP_KERNEL); | 4379 | knew->name = kstrdup(name, GFP_KERNEL); |
4323 | if (!knew->name) | 4380 | if (!knew->name) |
4324 | return -ENOMEM; | 4381 | return -ENOMEM; |
4382 | if (get_amp_nid_(val)) | ||
4383 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | ||
4325 | knew->private_value = val; | 4384 | knew->private_value = val; |
4326 | return 0; | 4385 | return 0; |
4327 | } | 4386 | } |
4328 | 4387 | ||
4388 | static int add_control_with_pfx(struct alc_spec *spec, int type, | ||
4389 | const char *pfx, const char *dir, | ||
4390 | const char *sfx, unsigned long val) | ||
4391 | { | ||
4392 | char name[32]; | ||
4393 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); | ||
4394 | return add_control(spec, type, name, val); | ||
4395 | } | ||
4396 | |||
4397 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ | ||
4398 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val) | ||
4399 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ | ||
4400 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val) | ||
4401 | |||
4329 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | 4402 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) |
4330 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | 4403 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
4331 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | 4404 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
@@ -4379,7 +4452,6 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, | |||
4379 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | 4452 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
4380 | const struct auto_pin_cfg *cfg) | 4453 | const struct auto_pin_cfg *cfg) |
4381 | { | 4454 | { |
4382 | char name[32]; | ||
4383 | static const char *chname[4] = { | 4455 | static const char *chname[4] = { |
4384 | "Front", "Surround", NULL /*CLFE*/, "Side" | 4456 | "Front", "Surround", NULL /*CLFE*/, "Side" |
4385 | }; | 4457 | }; |
@@ -4392,26 +4464,26 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4392 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | 4464 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); |
4393 | if (i == 2) { | 4465 | if (i == 2) { |
4394 | /* Center/LFE */ | 4466 | /* Center/LFE */ |
4395 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 4467 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
4396 | "Center Playback Volume", | 4468 | "Center", |
4397 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | 4469 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
4398 | HDA_OUTPUT)); | 4470 | HDA_OUTPUT)); |
4399 | if (err < 0) | 4471 | if (err < 0) |
4400 | return err; | 4472 | return err; |
4401 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 4473 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
4402 | "LFE Playback Volume", | 4474 | "LFE", |
4403 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | 4475 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
4404 | HDA_OUTPUT)); | 4476 | HDA_OUTPUT)); |
4405 | if (err < 0) | 4477 | if (err < 0) |
4406 | return err; | 4478 | return err; |
4407 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 4479 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
4408 | "Center Playback Switch", | 4480 | "Center", |
4409 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | 4481 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
4410 | HDA_INPUT)); | 4482 | HDA_INPUT)); |
4411 | if (err < 0) | 4483 | if (err < 0) |
4412 | return err; | 4484 | return err; |
4413 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 4485 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
4414 | "LFE Playback Switch", | 4486 | "LFE", |
4415 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | 4487 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
4416 | HDA_INPUT)); | 4488 | HDA_INPUT)); |
4417 | if (err < 0) | 4489 | if (err < 0) |
@@ -4423,14 +4495,12 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4423 | pfx = "Speaker"; | 4495 | pfx = "Speaker"; |
4424 | else | 4496 | else |
4425 | pfx = chname[i]; | 4497 | pfx = chname[i]; |
4426 | sprintf(name, "%s Playback Volume", pfx); | 4498 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
4427 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4428 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 4499 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
4429 | HDA_OUTPUT)); | 4500 | HDA_OUTPUT)); |
4430 | if (err < 0) | 4501 | if (err < 0) |
4431 | return err; | 4502 | return err; |
4432 | sprintf(name, "%s Playback Switch", pfx); | 4503 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
4433 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
4434 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | 4504 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
4435 | HDA_INPUT)); | 4505 | HDA_INPUT)); |
4436 | if (err < 0) | 4506 | if (err < 0) |
@@ -4446,7 +4516,6 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
4446 | { | 4516 | { |
4447 | hda_nid_t nid; | 4517 | hda_nid_t nid; |
4448 | int err; | 4518 | int err; |
4449 | char name[32]; | ||
4450 | 4519 | ||
4451 | if (!pin) | 4520 | if (!pin) |
4452 | return 0; | 4521 | return 0; |
@@ -4460,21 +4529,18 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
4460 | spec->multiout.extra_out_nid[0] = nid; | 4529 | spec->multiout.extra_out_nid[0] = nid; |
4461 | /* control HP volume/switch on the output mixer amp */ | 4530 | /* control HP volume/switch on the output mixer amp */ |
4462 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | 4531 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); |
4463 | sprintf(name, "%s Playback Volume", pfx); | 4532 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
4464 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4465 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 4533 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
4466 | if (err < 0) | 4534 | if (err < 0) |
4467 | return err; | 4535 | return err; |
4468 | sprintf(name, "%s Playback Switch", pfx); | 4536 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
4469 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
4470 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | 4537 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
4471 | if (err < 0) | 4538 | if (err < 0) |
4472 | return err; | 4539 | return err; |
4473 | } else if (alc880_is_multi_pin(pin)) { | 4540 | } else if (alc880_is_multi_pin(pin)) { |
4474 | /* set manual connection */ | 4541 | /* set manual connection */ |
4475 | /* we have only a switch on HP-out PIN */ | 4542 | /* we have only a switch on HP-out PIN */ |
4476 | sprintf(name, "%s Playback Switch", pfx); | 4543 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
4477 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
4478 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 4544 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
4479 | if (err < 0) | 4545 | if (err < 0) |
4480 | return err; | 4546 | return err; |
@@ -4487,16 +4553,13 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, | |||
4487 | const char *ctlname, | 4553 | const char *ctlname, |
4488 | int idx, hda_nid_t mix_nid) | 4554 | int idx, hda_nid_t mix_nid) |
4489 | { | 4555 | { |
4490 | char name[32]; | ||
4491 | int err; | 4556 | int err; |
4492 | 4557 | ||
4493 | sprintf(name, "%s Playback Volume", ctlname); | 4558 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, |
4494 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4495 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 4559 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
4496 | if (err < 0) | 4560 | if (err < 0) |
4497 | return err; | 4561 | return err; |
4498 | sprintf(name, "%s Playback Switch", ctlname); | 4562 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
4499 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
4500 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 4563 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
4501 | if (err < 0) | 4564 | if (err < 0) |
4502 | return err; | 4565 | return err; |
@@ -4684,9 +4747,9 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4684 | spec->multiout.dig_out_nid = dig_nid; | 4747 | spec->multiout.dig_out_nid = dig_nid; |
4685 | else { | 4748 | else { |
4686 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; | 4749 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
4687 | spec->slave_dig_outs[i - 1] = dig_nid; | 4750 | if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
4688 | if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1) | ||
4689 | break; | 4751 | break; |
4752 | spec->slave_dig_outs[i - 1] = dig_nid; | ||
4690 | } | 4753 | } |
4691 | } | 4754 | } |
4692 | if (spec->autocfg.dig_in_pin) | 4755 | if (spec->autocfg.dig_in_pin) |
@@ -4773,8 +4836,12 @@ static void set_capture_mixer(struct hda_codec *codec) | |||
4773 | } | 4836 | } |
4774 | } | 4837 | } |
4775 | 4838 | ||
4839 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | ||
4776 | #define set_beep_amp(spec, nid, idx, dir) \ | 4840 | #define set_beep_amp(spec, nid, idx, dir) \ |
4777 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) | 4841 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
4842 | #else | ||
4843 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ | ||
4844 | #endif | ||
4778 | 4845 | ||
4779 | /* | 4846 | /* |
4780 | * OK, here we have finally the patch for ALC880 | 4847 | * OK, here we have finally the patch for ALC880 |
@@ -5087,11 +5154,8 @@ static struct hda_verb alc260_hp_unsol_verbs[] = { | |||
5087 | static void alc260_hp_automute(struct hda_codec *codec) | 5154 | static void alc260_hp_automute(struct hda_codec *codec) |
5088 | { | 5155 | { |
5089 | struct alc_spec *spec = codec->spec; | 5156 | struct alc_spec *spec = codec->spec; |
5090 | unsigned int present; | ||
5091 | 5157 | ||
5092 | present = snd_hda_codec_read(codec, 0x10, 0, | 5158 | spec->jack_present = snd_hda_jack_detect(codec, 0x10); |
5093 | AC_VERB_GET_PIN_SENSE, 0); | ||
5094 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
5095 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | 5159 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); |
5096 | } | 5160 | } |
5097 | 5161 | ||
@@ -5156,11 +5220,8 @@ static struct hda_verb alc260_hp_3013_unsol_verbs[] = { | |||
5156 | static void alc260_hp_3013_automute(struct hda_codec *codec) | 5220 | static void alc260_hp_3013_automute(struct hda_codec *codec) |
5157 | { | 5221 | { |
5158 | struct alc_spec *spec = codec->spec; | 5222 | struct alc_spec *spec = codec->spec; |
5159 | unsigned int present; | ||
5160 | 5223 | ||
5161 | present = snd_hda_codec_read(codec, 0x15, 0, | 5224 | spec->jack_present = snd_hda_jack_detect(codec, 0x15); |
5162 | AC_VERB_GET_PIN_SENSE, 0); | ||
5163 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
5164 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); | 5225 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); |
5165 | } | 5226 | } |
5166 | 5227 | ||
@@ -5173,12 +5234,8 @@ static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |||
5173 | 5234 | ||
5174 | static void alc260_hp_3012_automute(struct hda_codec *codec) | 5235 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
5175 | { | 5236 | { |
5176 | unsigned int present, bits; | 5237 | unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT; |
5177 | |||
5178 | present = snd_hda_codec_read(codec, 0x10, 0, | ||
5179 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | ||
5180 | 5238 | ||
5181 | bits = present ? 0 : PIN_OUT; | ||
5182 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 5239 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
5183 | bits); | 5240 | bits); |
5184 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 5241 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
@@ -5748,8 +5805,7 @@ static void alc260_replacer_672v_automute(struct hda_codec *codec) | |||
5748 | unsigned int present; | 5805 | unsigned int present; |
5749 | 5806 | ||
5750 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | 5807 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ |
5751 | present = snd_hda_codec_read(codec, 0x0f, 0, | 5808 | present = snd_hda_jack_detect(codec, 0x0f); |
5752 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
5753 | if (present) { | 5809 | if (present) { |
5754 | snd_hda_codec_write_cache(codec, 0x01, 0, | 5810 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5755 | AC_VERB_SET_GPIO_DATA, 1); | 5811 | AC_VERB_SET_GPIO_DATA, 1); |
@@ -5989,7 +6045,6 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, | |||
5989 | { | 6045 | { |
5990 | hda_nid_t nid_vol; | 6046 | hda_nid_t nid_vol; |
5991 | unsigned long vol_val, sw_val; | 6047 | unsigned long vol_val, sw_val; |
5992 | char name[32]; | ||
5993 | int err; | 6048 | int err; |
5994 | 6049 | ||
5995 | if (nid >= 0x0f && nid < 0x11) { | 6050 | if (nid >= 0x0f && nid < 0x11) { |
@@ -6009,14 +6064,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, | |||
6009 | 6064 | ||
6010 | if (!(*vol_bits & (1 << nid_vol))) { | 6065 | if (!(*vol_bits & (1 << nid_vol))) { |
6011 | /* first control for the volume widget */ | 6066 | /* first control for the volume widget */ |
6012 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | 6067 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val); |
6013 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | ||
6014 | if (err < 0) | 6068 | if (err < 0) |
6015 | return err; | 6069 | return err; |
6016 | *vol_bits |= (1 << nid_vol); | 6070 | *vol_bits |= (1 << nid_vol); |
6017 | } | 6071 | } |
6018 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | 6072 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val); |
6019 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); | ||
6020 | if (err < 0) | 6073 | if (err < 0) |
6021 | return err; | 6074 | return err; |
6022 | return 1; | 6075 | return 1; |
@@ -6246,10 +6299,11 @@ static const char *alc260_models[ALC260_MODEL_LAST] = { | |||
6246 | 6299 | ||
6247 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | 6300 | static struct snd_pci_quirk alc260_cfg_tbl[] = { |
6248 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), | 6301 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
6302 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL), | ||
6249 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), | 6303 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
6250 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100), | 6304 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100), |
6251 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), | 6305 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
6252 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), | 6306 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */ |
6253 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), | 6307 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
6254 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), | 6308 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
6255 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), | 6309 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), |
@@ -6619,7 +6673,7 @@ static struct hda_input_mux alc889A_mb31_capture_source = { | |||
6619 | /* Front Mic (0x01) unused */ | 6673 | /* Front Mic (0x01) unused */ |
6620 | { "Line", 0x2 }, | 6674 | { "Line", 0x2 }, |
6621 | /* Line 2 (0x03) unused */ | 6675 | /* Line 2 (0x03) unused */ |
6622 | /* CD (0x04) unsused? */ | 6676 | /* CD (0x04) unused? */ |
6623 | }, | 6677 | }, |
6624 | }; | 6678 | }; |
6625 | 6679 | ||
@@ -7051,6 +7105,20 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = { | |||
7051 | { } /* end */ | 7105 | { } /* end */ |
7052 | }; | 7106 | }; |
7053 | 7107 | ||
7108 | static struct snd_kcontrol_new alc885_imac91_mixer[] = { | ||
7109 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | ||
7110 | HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT), | ||
7111 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | ||
7112 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | ||
7113 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
7114 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
7115 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), | ||
7116 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | ||
7117 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), | ||
7118 | { } /* end */ | ||
7119 | }; | ||
7120 | |||
7121 | |||
7054 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { | 7122 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
7055 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7123 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7056 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | 7124 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
@@ -7336,8 +7404,8 @@ static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |||
7336 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | 7404 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7337 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | 7405 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), |
7338 | /* FIXME: this looks suspicious... | 7406 | /* FIXME: this looks suspicious... |
7339 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | 7407 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7340 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | 7408 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT), |
7341 | */ | 7409 | */ |
7342 | { } /* end */ | 7410 | { } /* end */ |
7343 | }; | 7411 | }; |
@@ -7506,6 +7574,66 @@ static struct hda_verb alc885_mbp3_init_verbs[] = { | |||
7506 | { } | 7574 | { } |
7507 | }; | 7575 | }; |
7508 | 7576 | ||
7577 | /* iMac 9,1 */ | ||
7578 | static struct hda_verb alc885_imac91_init_verbs[] = { | ||
7579 | /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */ | ||
7580 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7581 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7582 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7583 | /* Rear mixer */ | ||
7584 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7585 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7586 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7587 | /* HP Pin: output 0 (0x0c) */ | ||
7588 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
7589 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7590 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7591 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
7592 | /* Internal Speakers: output 0 (0x0d) */ | ||
7593 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7594 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7595 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7596 | /* Mic (rear) pin: input vref at 80% */ | ||
7597 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
7598 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7599 | /* Front Mic pin: input vref at 80% */ | ||
7600 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
7601 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7602 | /* Line In pin: use output 1 when in LineOut mode */ | ||
7603 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
7604 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7605 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
7606 | |||
7607 | /* FIXME: use matrix-type input source selection */ | ||
7608 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | ||
7609 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
7610 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7611 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7612 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7613 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7614 | /* Input mixer2 */ | ||
7615 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7616 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7617 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7618 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7619 | /* Input mixer3 */ | ||
7620 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7621 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7622 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7623 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7624 | /* ADC1: mute amp left and right */ | ||
7625 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7626 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7627 | /* ADC2: mute amp left and right */ | ||
7628 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7629 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7630 | /* ADC3: mute amp left and right */ | ||
7631 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7632 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7633 | |||
7634 | { } | ||
7635 | }; | ||
7636 | |||
7509 | /* iMac 24 mixer. */ | 7637 | /* iMac 24 mixer. */ |
7510 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | 7638 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { |
7511 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | 7639 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
@@ -7552,6 +7680,26 @@ static void alc885_mbp3_setup(struct hda_codec *codec) | |||
7552 | spec->autocfg.speaker_pins[0] = 0x14; | 7680 | spec->autocfg.speaker_pins[0] = 0x14; |
7553 | } | 7681 | } |
7554 | 7682 | ||
7683 | static void alc885_imac91_automute(struct hda_codec *codec) | ||
7684 | { | ||
7685 | unsigned int present; | ||
7686 | |||
7687 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
7688 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
7689 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
7690 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7691 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
7692 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7693 | |||
7694 | } | ||
7695 | |||
7696 | static void alc885_imac91_unsol_event(struct hda_codec *codec, | ||
7697 | unsigned int res) | ||
7698 | { | ||
7699 | /* Headphone insertion or removal. */ | ||
7700 | if ((res >> 26) == ALC880_HP_EVENT) | ||
7701 | alc885_imac91_automute(codec); | ||
7702 | } | ||
7555 | 7703 | ||
7556 | static struct hda_verb alc882_targa_verbs[] = { | 7704 | static struct hda_verb alc882_targa_verbs[] = { |
7557 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7705 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
@@ -8184,12 +8332,8 @@ static void alc883_mitac_setup(struct hda_codec *codec) | |||
8184 | /* | 8332 | /* |
8185 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | 8333 | static void alc883_mitac_mic_automute(struct hda_codec *codec) |
8186 | { | 8334 | { |
8187 | unsigned int present; | 8335 | unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0; |
8188 | unsigned char bits; | ||
8189 | 8336 | ||
8190 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
8191 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8192 | bits = present ? HDA_AMP_MUTE : 0; | ||
8193 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 8337 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
8194 | } | 8338 | } |
8195 | */ | 8339 | */ |
@@ -8411,10 +8555,8 @@ static struct hda_channel_mode alc888_3st_hp_modes[3] = { | |||
8411 | /* toggle front-jack and RCA according to the hp-jack state */ | 8555 | /* toggle front-jack and RCA according to the hp-jack state */ |
8412 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | 8556 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) |
8413 | { | 8557 | { |
8414 | unsigned int present; | 8558 | unsigned int present = snd_hda_jack_detect(codec, 0x1b); |
8415 | 8559 | ||
8416 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8417 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8418 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8560 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8419 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8561 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8420 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8562 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
@@ -8424,10 +8566,8 @@ static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |||
8424 | /* toggle RCA according to the front-jack state */ | 8566 | /* toggle RCA according to the front-jack state */ |
8425 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | 8567 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) |
8426 | { | 8568 | { |
8427 | unsigned int present; | 8569 | unsigned int present = snd_hda_jack_detect(codec, 0x14); |
8428 | 8570 | ||
8429 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8430 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8431 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8571 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8432 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8572 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8433 | } | 8573 | } |
@@ -8468,8 +8608,7 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8468 | { | 8608 | { |
8469 | unsigned int present; | 8609 | unsigned int present; |
8470 | 8610 | ||
8471 | present = snd_hda_codec_read(codec, 0x18, 0, | 8611 | present = snd_hda_jack_detect(codec, 0x18); |
8472 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8473 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | 8612 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, |
8474 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8613 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8475 | } | 8614 | } |
@@ -8520,24 +8659,16 @@ static void alc883_haier_w66_setup(struct hda_codec *codec) | |||
8520 | 8659 | ||
8521 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | 8660 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
8522 | { | 8661 | { |
8523 | unsigned int present; | 8662 | int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0; |
8524 | unsigned char bits; | ||
8525 | 8663 | ||
8526 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
8527 | & AC_PINSENSE_PRESENCE; | ||
8528 | bits = present ? HDA_AMP_MUTE : 0; | ||
8529 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8664 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8530 | HDA_AMP_MUTE, bits); | 8665 | HDA_AMP_MUTE, bits); |
8531 | } | 8666 | } |
8532 | 8667 | ||
8533 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | 8668 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) |
8534 | { | 8669 | { |
8535 | unsigned int present; | 8670 | int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0; |
8536 | unsigned char bits; | ||
8537 | 8671 | ||
8538 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8539 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8540 | bits = present ? HDA_AMP_MUTE : 0; | ||
8541 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8672 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8542 | HDA_AMP_MUTE, bits); | 8673 | HDA_AMP_MUTE, bits); |
8543 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8674 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
@@ -8688,8 +8819,7 @@ static void alc889A_mb31_automute(struct hda_codec *codec) | |||
8688 | /* Mute only in 2ch or 4ch mode */ | 8819 | /* Mute only in 2ch or 4ch mode */ |
8689 | if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0) | 8820 | if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0) |
8690 | == 0x00) { | 8821 | == 0x00) { |
8691 | present = snd_hda_codec_read(codec, 0x15, 0, | 8822 | present = snd_hda_jack_detect(codec, 0x15); |
8692 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | ||
8693 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8823 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8694 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8824 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8695 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | 8825 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, |
@@ -8737,6 +8867,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = { | |||
8737 | [ALC885_MB5] = "mb5", | 8867 | [ALC885_MB5] = "mb5", |
8738 | [ALC885_MBP3] = "mbp3", | 8868 | [ALC885_MBP3] = "mbp3", |
8739 | [ALC885_IMAC24] = "imac24", | 8869 | [ALC885_IMAC24] = "imac24", |
8870 | [ALC885_IMAC91] = "imac91", | ||
8740 | [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig", | 8871 | [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig", |
8741 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | 8872 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", |
8742 | [ALC883_3ST_6ch] = "3stack-6ch", | 8873 | [ALC883_3ST_6ch] = "3stack-6ch", |
@@ -8839,7 +8970,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = { | |||
8839 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), | 8970 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
8840 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), | 8971 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
8841 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ | 8972 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
8842 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), | 8973 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO), |
8843 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | 8974 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), |
8844 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), | 8975 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
8845 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), | 8976 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
@@ -8910,11 +9041,13 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { | |||
8910 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), | 9041 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), |
8911 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), | 9042 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), |
8912 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), | 9043 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), |
9044 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91), | ||
8913 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), | 9045 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), |
8914 | /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently | 9046 | /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2, |
8915 | * no perfect solution yet | 9047 | * so apparently no perfect solution yet |
8916 | */ | 9048 | */ |
8917 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5), | 9049 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5), |
9050 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5), | ||
8918 | {} /* terminator */ | 9051 | {} /* terminator */ |
8919 | }; | 9052 | }; |
8920 | 9053 | ||
@@ -9020,6 +9153,20 @@ static struct alc_config_preset alc882_presets[] = { | |||
9020 | .setup = alc885_imac24_setup, | 9153 | .setup = alc885_imac24_setup, |
9021 | .init_hook = alc885_imac24_init_hook, | 9154 | .init_hook = alc885_imac24_init_hook, |
9022 | }, | 9155 | }, |
9156 | [ALC885_IMAC91] = { | ||
9157 | .mixers = { alc885_imac91_mixer, alc882_chmode_mixer }, | ||
9158 | .init_verbs = { alc885_imac91_init_verbs, | ||
9159 | alc880_gpio1_init_verbs }, | ||
9160 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9161 | .dac_nids = alc882_dac_nids, | ||
9162 | .channel_mode = alc885_mbp_4ch_modes, | ||
9163 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes), | ||
9164 | .input_mux = &alc882_capture_source, | ||
9165 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9166 | .dig_in_nid = ALC882_DIGIN_NID, | ||
9167 | .unsol_event = alc885_imac91_unsol_event, | ||
9168 | .init_hook = alc885_imac91_automute, | ||
9169 | }, | ||
9023 | [ALC882_TARGA] = { | 9170 | [ALC882_TARGA] = { |
9024 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, | 9171 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, |
9025 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | 9172 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, |
@@ -9186,6 +9333,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9186 | .dac_nids = alc883_dac_nids, | 9333 | .dac_nids = alc883_dac_nids, |
9187 | .adc_nids = alc883_adc_nids_alt, | 9334 | .adc_nids = alc883_adc_nids_alt, |
9188 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | 9335 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), |
9336 | .capsrc_nids = alc883_capsrc_nids, | ||
9189 | .dig_out_nid = ALC883_DIGOUT_NID, | 9337 | .dig_out_nid = ALC883_DIGOUT_NID, |
9190 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9338 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9191 | .channel_mode = alc883_3ST_2ch_modes, | 9339 | .channel_mode = alc883_3ST_2ch_modes, |
@@ -9282,10 +9430,11 @@ static struct alc_config_preset alc882_presets[] = { | |||
9282 | .init_hook = alc_automute_amp, | 9430 | .init_hook = alc_automute_amp, |
9283 | }, | 9431 | }, |
9284 | [ALC888_ACER_ASPIRE_8930G] = { | 9432 | [ALC888_ACER_ASPIRE_8930G] = { |
9285 | .mixers = { alc888_base_mixer, | 9433 | .mixers = { alc889_acer_aspire_8930g_mixer, |
9286 | alc883_chmode_mixer }, | 9434 | alc883_chmode_mixer }, |
9287 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | 9435 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, |
9288 | alc889_acer_aspire_8930g_verbs }, | 9436 | alc889_acer_aspire_8930g_verbs, |
9437 | alc889_eapd_verbs}, | ||
9289 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | 9438 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
9290 | .dac_nids = alc883_dac_nids, | 9439 | .dac_nids = alc883_dac_nids, |
9291 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | 9440 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), |
@@ -9302,6 +9451,9 @@ static struct alc_config_preset alc882_presets[] = { | |||
9302 | .unsol_event = alc_automute_amp_unsol_event, | 9451 | .unsol_event = alc_automute_amp_unsol_event, |
9303 | .setup = alc889_acer_aspire_8930g_setup, | 9452 | .setup = alc889_acer_aspire_8930g_setup, |
9304 | .init_hook = alc_automute_amp, | 9453 | .init_hook = alc_automute_amp, |
9454 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
9455 | .power_hook = alc889_power_eapd, | ||
9456 | #endif | ||
9305 | }, | 9457 | }, |
9306 | [ALC888_ACER_ASPIRE_7730G] = { | 9458 | [ALC888_ACER_ASPIRE_7730G] = { |
9307 | .mixers = { alc883_3ST_6ch_mixer, | 9459 | .mixers = { alc883_3ST_6ch_mixer, |
@@ -9332,6 +9484,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9332 | .dac_nids = alc883_dac_nids, | 9484 | .dac_nids = alc883_dac_nids, |
9333 | .adc_nids = alc883_adc_nids_alt, | 9485 | .adc_nids = alc883_adc_nids_alt, |
9334 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | 9486 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), |
9487 | .capsrc_nids = alc883_capsrc_nids, | ||
9335 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | 9488 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
9336 | .channel_mode = alc883_sixstack_modes, | 9489 | .channel_mode = alc883_sixstack_modes, |
9337 | .input_mux = &alc883_capture_source, | 9490 | .input_mux = &alc883_capture_source, |
@@ -9393,6 +9546,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9393 | .dac_nids = alc883_dac_nids, | 9546 | .dac_nids = alc883_dac_nids, |
9394 | .adc_nids = alc883_adc_nids_alt, | 9547 | .adc_nids = alc883_adc_nids_alt, |
9395 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | 9548 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), |
9549 | .capsrc_nids = alc883_capsrc_nids, | ||
9396 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9550 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9397 | .channel_mode = alc883_3ST_2ch_modes, | 9551 | .channel_mode = alc883_3ST_2ch_modes, |
9398 | .input_mux = &alc883_lenovo_101e_capture_source, | 9552 | .input_mux = &alc883_lenovo_101e_capture_source, |
@@ -9572,6 +9726,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9572 | alc880_gpio1_init_verbs }, | 9726 | alc880_gpio1_init_verbs }, |
9573 | .adc_nids = alc883_adc_nids, | 9727 | .adc_nids = alc883_adc_nids, |
9574 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | 9728 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
9729 | .capsrc_nids = alc883_capsrc_nids, | ||
9575 | .dac_nids = alc883_dac_nids, | 9730 | .dac_nids = alc883_dac_nids, |
9576 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | 9731 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
9577 | .channel_mode = alc889A_mb31_6ch_modes, | 9732 | .channel_mode = alc889A_mb31_6ch_modes, |
@@ -9813,9 +9968,9 @@ static int alc882_parse_auto_config(struct hda_codec *codec) | |||
9813 | spec->multiout.dig_out_nid = dig_nid; | 9968 | spec->multiout.dig_out_nid = dig_nid; |
9814 | else { | 9969 | else { |
9815 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; | 9970 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
9816 | spec->slave_dig_outs[i - 1] = dig_nid; | 9971 | if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
9817 | if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1) | ||
9818 | break; | 9972 | break; |
9973 | spec->slave_dig_outs[i - 1] = dig_nid; | ||
9819 | } | 9974 | } |
9820 | } | 9975 | } |
9821 | if (spec->autocfg.dig_in_pin) | 9976 | if (spec->autocfg.dig_in_pin) |
@@ -9926,10 +10081,12 @@ static int patch_alc882(struct hda_codec *codec) | |||
9926 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ | 10081 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ |
9927 | 10082 | ||
9928 | if (!spec->adc_nids && spec->input_mux) { | 10083 | if (!spec->adc_nids && spec->input_mux) { |
9929 | int i; | 10084 | int i, j; |
9930 | spec->num_adc_nids = 0; | 10085 | spec->num_adc_nids = 0; |
9931 | for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) { | 10086 | for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) { |
10087 | const struct hda_input_mux *imux = spec->input_mux; | ||
9932 | hda_nid_t cap; | 10088 | hda_nid_t cap; |
10089 | hda_nid_t items[16]; | ||
9933 | hda_nid_t nid = alc882_adc_nids[i]; | 10090 | hda_nid_t nid = alc882_adc_nids[i]; |
9934 | unsigned int wcap = get_wcaps(codec, nid); | 10091 | unsigned int wcap = get_wcaps(codec, nid); |
9935 | /* get type */ | 10092 | /* get type */ |
@@ -9940,6 +10097,15 @@ static int patch_alc882(struct hda_codec *codec) | |||
9940 | err = snd_hda_get_connections(codec, nid, &cap, 1); | 10097 | err = snd_hda_get_connections(codec, nid, &cap, 1); |
9941 | if (err < 0) | 10098 | if (err < 0) |
9942 | continue; | 10099 | continue; |
10100 | err = snd_hda_get_connections(codec, cap, items, | ||
10101 | ARRAY_SIZE(items)); | ||
10102 | if (err < 0) | ||
10103 | continue; | ||
10104 | for (j = 0; j < imux->num_items; j++) | ||
10105 | if (imux->items[j].index >= err) | ||
10106 | break; | ||
10107 | if (j < imux->num_items) | ||
10108 | continue; | ||
9943 | spec->private_capsrc_nids[spec->num_adc_nids] = cap; | 10109 | spec->private_capsrc_nids[spec->num_adc_nids] = cap; |
9944 | spec->num_adc_nids++; | 10110 | spec->num_adc_nids++; |
9945 | } | 10111 | } |
@@ -10031,10 +10197,8 @@ static void alc262_hp_master_update(struct hda_codec *codec) | |||
10031 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | 10197 | static void alc262_hp_bpc_automute(struct hda_codec *codec) |
10032 | { | 10198 | { |
10033 | struct alc_spec *spec = codec->spec; | 10199 | struct alc_spec *spec = codec->spec; |
10034 | unsigned int presence; | 10200 | |
10035 | presence = snd_hda_codec_read(codec, 0x1b, 0, | 10201 | spec->jack_present = snd_hda_jack_detect(codec, 0x1b); |
10036 | AC_VERB_GET_PIN_SENSE, 0); | ||
10037 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | ||
10038 | alc262_hp_master_update(codec); | 10202 | alc262_hp_master_update(codec); |
10039 | } | 10203 | } |
10040 | 10204 | ||
@@ -10048,10 +10212,8 @@ static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |||
10048 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | 10212 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) |
10049 | { | 10213 | { |
10050 | struct alc_spec *spec = codec->spec; | 10214 | struct alc_spec *spec = codec->spec; |
10051 | unsigned int presence; | 10215 | |
10052 | presence = snd_hda_codec_read(codec, 0x15, 0, | 10216 | spec->jack_present = snd_hda_jack_detect(codec, 0x15); |
10053 | AC_VERB_GET_PIN_SENSE, 0); | ||
10054 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | ||
10055 | alc262_hp_master_update(codec); | 10217 | alc262_hp_master_update(codec); |
10056 | } | 10218 | } |
10057 | 10219 | ||
@@ -10285,13 +10447,8 @@ static void alc262_hippo_automute(struct hda_codec *codec) | |||
10285 | { | 10447 | { |
10286 | struct alc_spec *spec = codec->spec; | 10448 | struct alc_spec *spec = codec->spec; |
10287 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | 10449 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; |
10288 | unsigned int present; | ||
10289 | 10450 | ||
10290 | /* need to execute and sync at first */ | 10451 | spec->jack_present = snd_hda_jack_detect(codec, hp_nid); |
10291 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10292 | present = snd_hda_codec_read(codec, hp_nid, 0, | ||
10293 | AC_VERB_GET_PIN_SENSE, 0); | ||
10294 | spec->jack_present = (present & 0x80000000) != 0; | ||
10295 | alc262_hippo_master_update(codec); | 10452 | alc262_hippo_master_update(codec); |
10296 | } | 10453 | } |
10297 | 10454 | ||
@@ -10580,6 +10737,13 @@ static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { | |||
10580 | {} | 10737 | {} |
10581 | }; | 10738 | }; |
10582 | 10739 | ||
10740 | static struct hda_verb alc262_lenovo_3000_init_verbs[] = { | ||
10741 | /* Front Mic pin: input vref at 50% */ | ||
10742 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | ||
10743 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
10744 | {} | ||
10745 | }; | ||
10746 | |||
10583 | static struct hda_input_mux alc262_fujitsu_capture_source = { | 10747 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
10584 | .num_items = 3, | 10748 | .num_items = 3, |
10585 | .items = { | 10749 | .items = { |
@@ -10617,21 +10781,8 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |||
10617 | unsigned int mute; | 10781 | unsigned int mute; |
10618 | 10782 | ||
10619 | if (force || !spec->sense_updated) { | 10783 | if (force || !spec->sense_updated) { |
10620 | unsigned int present; | 10784 | spec->jack_present = snd_hda_jack_detect(codec, 0x14) || |
10621 | /* need to execute and sync at first */ | 10785 | snd_hda_jack_detect(codec, 0x1b); |
10622 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10623 | /* check laptop HP jack */ | ||
10624 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
10625 | AC_VERB_GET_PIN_SENSE, 0); | ||
10626 | /* need to execute and sync at first */ | ||
10627 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10628 | /* check docking HP jack */ | ||
10629 | present |= snd_hda_codec_read(codec, 0x1b, 0, | ||
10630 | AC_VERB_GET_PIN_SENSE, 0); | ||
10631 | if (present & AC_PINSENSE_PRESENCE) | ||
10632 | spec->jack_present = 1; | ||
10633 | else | ||
10634 | spec->jack_present = 0; | ||
10635 | spec->sense_updated = 1; | 10786 | spec->sense_updated = 1; |
10636 | } | 10787 | } |
10637 | /* unmute internal speaker only if both HPs are unplugged and | 10788 | /* unmute internal speaker only if both HPs are unplugged and |
@@ -10676,12 +10827,7 @@ static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |||
10676 | unsigned int mute; | 10827 | unsigned int mute; |
10677 | 10828 | ||
10678 | if (force || !spec->sense_updated) { | 10829 | if (force || !spec->sense_updated) { |
10679 | unsigned int present_int_hp; | 10830 | spec->jack_present = snd_hda_jack_detect(codec, 0x1b); |
10680 | /* need to execute and sync at first */ | ||
10681 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10682 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | ||
10683 | AC_VERB_GET_PIN_SENSE, 0); | ||
10684 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | ||
10685 | spec->sense_updated = 1; | 10831 | spec->sense_updated = 1; |
10686 | } | 10832 | } |
10687 | if (spec->jack_present) { | 10833 | if (spec->jack_present) { |
@@ -10873,12 +11019,7 @@ static void alc262_ultra_automute(struct hda_codec *codec) | |||
10873 | mute = 0; | 11019 | mute = 0; |
10874 | /* auto-mute only when HP is used as HP */ | 11020 | /* auto-mute only when HP is used as HP */ |
10875 | if (!spec->cur_mux[0]) { | 11021 | if (!spec->cur_mux[0]) { |
10876 | unsigned int present; | 11022 | spec->jack_present = snd_hda_jack_detect(codec, 0x15); |
10877 | /* need to execute and sync at first */ | ||
10878 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10879 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
10880 | AC_VERB_GET_PIN_SENSE, 0); | ||
10881 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
10882 | if (spec->jack_present) | 11023 | if (spec->jack_present) |
10883 | mute = HDA_AMP_MUTE; | 11024 | mute = HDA_AMP_MUTE; |
10884 | } | 11025 | } |
@@ -10955,7 +11096,6 @@ static int alc262_check_volbit(hda_nid_t nid) | |||
10955 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | 11096 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, |
10956 | const char *pfx, int *vbits) | 11097 | const char *pfx, int *vbits) |
10957 | { | 11098 | { |
10958 | char name[32]; | ||
10959 | unsigned long val; | 11099 | unsigned long val; |
10960 | int vbit; | 11100 | int vbit; |
10961 | 11101 | ||
@@ -10965,28 +11105,25 @@ static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | |||
10965 | if (*vbits & vbit) /* a volume control for this mixer already there */ | 11105 | if (*vbits & vbit) /* a volume control for this mixer already there */ |
10966 | return 0; | 11106 | return 0; |
10967 | *vbits |= vbit; | 11107 | *vbits |= vbit; |
10968 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | ||
10969 | if (vbit == 2) | 11108 | if (vbit == 2) |
10970 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | 11109 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); |
10971 | else | 11110 | else |
10972 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | 11111 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); |
10973 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, val); | 11112 | return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val); |
10974 | } | 11113 | } |
10975 | 11114 | ||
10976 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | 11115 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, |
10977 | const char *pfx) | 11116 | const char *pfx) |
10978 | { | 11117 | { |
10979 | char name[32]; | ||
10980 | unsigned long val; | 11118 | unsigned long val; |
10981 | 11119 | ||
10982 | if (!nid) | 11120 | if (!nid) |
10983 | return 0; | 11121 | return 0; |
10984 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
10985 | if (nid == 0x16) | 11122 | if (nid == 0x16) |
10986 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | 11123 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); |
10987 | else | 11124 | else |
10988 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | 11125 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
10989 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val); | 11126 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val); |
10990 | } | 11127 | } |
10991 | 11128 | ||
10992 | /* add playback controls from the parsed DAC table */ | 11129 | /* add playback controls from the parsed DAC table */ |
@@ -11460,8 +11597,12 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = { | |||
11460 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), | 11597 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
11461 | SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */ | 11598 | SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */ |
11462 | SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06), | 11599 | SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06), |
11600 | SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO), | ||
11601 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO), | ||
11602 | #if 0 /* disable the quirk since model=auto works better in recent versions */ | ||
11463 | SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO", | 11603 | SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO", |
11464 | ALC262_SONY_ASSAMD), | 11604 | ALC262_SONY_ASSAMD), |
11605 | #endif | ||
11465 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", | 11606 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
11466 | ALC262_TOSHIBA_RX1), | 11607 | ALC262_TOSHIBA_RX1), |
11467 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), | 11608 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
@@ -11645,7 +11786,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11645 | [ALC262_LENOVO_3000] = { | 11786 | [ALC262_LENOVO_3000] = { |
11646 | .mixers = { alc262_lenovo_3000_mixer }, | 11787 | .mixers = { alc262_lenovo_3000_mixer }, |
11647 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | 11788 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
11648 | alc262_lenovo_3000_unsol_verbs }, | 11789 | alc262_lenovo_3000_unsol_verbs, |
11790 | alc262_lenovo_3000_init_verbs }, | ||
11649 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11791 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
11650 | .dac_nids = alc262_dac_nids, | 11792 | .dac_nids = alc262_dac_nids, |
11651 | .hp_nid = 0x03, | 11793 | .hp_nid = 0x03, |
@@ -11920,10 +12062,7 @@ static void alc268_acer_automute(struct hda_codec *codec, int force) | |||
11920 | unsigned int mute; | 12062 | unsigned int mute; |
11921 | 12063 | ||
11922 | if (force || !spec->sense_updated) { | 12064 | if (force || !spec->sense_updated) { |
11923 | unsigned int present; | 12065 | spec->jack_present = snd_hda_jack_detect(codec, 0x14); |
11924 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
11925 | AC_VERB_GET_PIN_SENSE, 0); | ||
11926 | spec->jack_present = (present & 0x80000000) != 0; | ||
11927 | spec->sense_updated = 1; | 12066 | spec->sense_updated = 1; |
11928 | } | 12067 | } |
11929 | if (spec->jack_present) | 12068 | if (spec->jack_present) |
@@ -12042,8 +12181,7 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |||
12042 | unsigned int present; | 12181 | unsigned int present; |
12043 | unsigned char bits; | 12182 | unsigned char bits; |
12044 | 12183 | ||
12045 | present = snd_hda_codec_read(codec, 0x15, 0, | 12184 | present = snd_hda_jack_detect(codec, 0x15); |
12046 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
12047 | bits = present ? AMP_IN_MUTE(0) : 0; | 12185 | bits = present ? AMP_IN_MUTE(0) : 0; |
12048 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | 12186 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, |
12049 | AMP_IN_MUTE(0), bits); | 12187 | AMP_IN_MUTE(0), bits); |
@@ -12324,11 +12462,9 @@ static struct snd_kcontrol_new alc268_test_mixer[] = { | |||
12324 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | 12462 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, |
12325 | const char *ctlname, int idx) | 12463 | const char *ctlname, int idx) |
12326 | { | 12464 | { |
12327 | char name[32]; | ||
12328 | hda_nid_t dac; | 12465 | hda_nid_t dac; |
12329 | int err; | 12466 | int err; |
12330 | 12467 | ||
12331 | sprintf(name, "%s Playback Volume", ctlname); | ||
12332 | switch (nid) { | 12468 | switch (nid) { |
12333 | case 0x14: | 12469 | case 0x14: |
12334 | case 0x16: | 12470 | case 0x16: |
@@ -12342,7 +12478,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12342 | } | 12478 | } |
12343 | if (spec->multiout.dac_nids[0] != dac && | 12479 | if (spec->multiout.dac_nids[0] != dac && |
12344 | spec->multiout.dac_nids[1] != dac) { | 12480 | spec->multiout.dac_nids[1] != dac) { |
12345 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12481 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, |
12346 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, | 12482 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, |
12347 | HDA_OUTPUT)); | 12483 | HDA_OUTPUT)); |
12348 | if (err < 0) | 12484 | if (err < 0) |
@@ -12350,12 +12486,11 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12350 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; | 12486 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
12351 | } | 12487 | } |
12352 | 12488 | ||
12353 | sprintf(name, "%s Playback Switch", ctlname); | ||
12354 | if (nid != 0x16) | 12489 | if (nid != 0x16) |
12355 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12490 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
12356 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | 12491 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); |
12357 | else /* mono */ | 12492 | else /* mono */ |
12358 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12493 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
12359 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); | 12494 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); |
12360 | if (err < 0) | 12495 | if (err < 0) |
12361 | return err; | 12496 | return err; |
@@ -12385,8 +12520,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12385 | 12520 | ||
12386 | nid = cfg->speaker_pins[0]; | 12521 | nid = cfg->speaker_pins[0]; |
12387 | if (nid == 0x1d) { | 12522 | if (nid == 0x1d) { |
12388 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 12523 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker", |
12389 | "Speaker Playback Volume", | ||
12390 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | 12524 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
12391 | if (err < 0) | 12525 | if (err < 0) |
12392 | return err; | 12526 | return err; |
@@ -12404,8 +12538,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12404 | 12538 | ||
12405 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | 12539 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; |
12406 | if (nid == 0x16) { | 12540 | if (nid == 0x16) { |
12407 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 12541 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono", |
12408 | "Mono Playback Switch", | ||
12409 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); | 12542 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); |
12410 | if (err < 0) | 12543 | if (err < 0) |
12411 | return err; | 12544 | return err; |
@@ -12791,7 +12924,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
12791 | int board_config; | 12924 | int board_config; |
12792 | int i, has_beep, err; | 12925 | int i, has_beep, err; |
12793 | 12926 | ||
12794 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 12927 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
12795 | if (spec == NULL) | 12928 | if (spec == NULL) |
12796 | return -ENOMEM; | 12929 | return -ENOMEM; |
12797 | 12930 | ||
@@ -13031,8 +13164,7 @@ static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |||
13031 | unsigned int present; | 13164 | unsigned int present; |
13032 | unsigned char bits; | 13165 | unsigned char bits; |
13033 | 13166 | ||
13034 | present = snd_hda_codec_read(codec, 0x15, 0, | 13167 | present = snd_hda_jack_detect(codec, 0x15); |
13035 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13036 | bits = present ? AMP_IN_MUTE(0) : 0; | 13168 | bits = present ? AMP_IN_MUTE(0) : 0; |
13037 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 13169 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
13038 | AMP_IN_MUTE(0), bits); | 13170 | AMP_IN_MUTE(0), bits); |
@@ -13057,12 +13189,10 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |||
13057 | unsigned char bits; | 13189 | unsigned char bits; |
13058 | 13190 | ||
13059 | /* Check laptop headphone socket */ | 13191 | /* Check laptop headphone socket */ |
13060 | present = snd_hda_codec_read(codec, 0x15, 0, | 13192 | present = snd_hda_jack_detect(codec, 0x15); |
13061 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13062 | 13193 | ||
13063 | /* Check port replicator headphone socket */ | 13194 | /* Check port replicator headphone socket */ |
13064 | present |= snd_hda_codec_read(codec, 0x1a, 0, | 13195 | present |= snd_hda_jack_detect(codec, 0x1a); |
13065 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13066 | 13196 | ||
13067 | bits = present ? AMP_IN_MUTE(0) : 0; | 13197 | bits = present ? AMP_IN_MUTE(0) : 0; |
13068 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 13198 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
@@ -13086,11 +13216,8 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) | |||
13086 | unsigned int present_laptop; | 13216 | unsigned int present_laptop; |
13087 | unsigned int present_dock; | 13217 | unsigned int present_dock; |
13088 | 13218 | ||
13089 | present_laptop = snd_hda_codec_read(codec, 0x18, 0, | 13219 | present_laptop = snd_hda_jack_detect(codec, 0x18); |
13090 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 13220 | present_dock = snd_hda_jack_detect(codec, 0x1b); |
13091 | |||
13092 | present_dock = snd_hda_codec_read(codec, 0x1b, 0, | ||
13093 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13094 | 13221 | ||
13095 | /* Laptop mic port overrides dock mic port, design decision */ | 13222 | /* Laptop mic port overrides dock mic port, design decision */ |
13096 | if (present_dock) | 13223 | if (present_dock) |
@@ -13172,11 +13299,12 @@ static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |||
13172 | /* toggle speaker-output according to the hp-jack state */ | 13299 | /* toggle speaker-output according to the hp-jack state */ |
13173 | static void alc269_speaker_automute(struct hda_codec *codec) | 13300 | static void alc269_speaker_automute(struct hda_codec *codec) |
13174 | { | 13301 | { |
13302 | struct alc_spec *spec = codec->spec; | ||
13303 | unsigned int nid = spec->autocfg.hp_pins[0]; | ||
13175 | unsigned int present; | 13304 | unsigned int present; |
13176 | unsigned char bits; | 13305 | unsigned char bits; |
13177 | 13306 | ||
13178 | present = snd_hda_codec_read(codec, 0x15, 0, | 13307 | present = snd_hda_jack_detect(codec, nid); |
13179 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13180 | bits = present ? AMP_IN_MUTE(0) : 0; | 13308 | bits = present ? AMP_IN_MUTE(0) : 0; |
13181 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 13309 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
13182 | AMP_IN_MUTE(0), bits); | 13310 | AMP_IN_MUTE(0), bits); |
@@ -13401,8 +13529,8 @@ static void alc269_auto_init(struct hda_codec *codec) | |||
13401 | static const char *alc269_models[ALC269_MODEL_LAST] = { | 13529 | static const char *alc269_models[ALC269_MODEL_LAST] = { |
13402 | [ALC269_BASIC] = "basic", | 13530 | [ALC269_BASIC] = "basic", |
13403 | [ALC269_QUANTA_FL1] = "quanta", | 13531 | [ALC269_QUANTA_FL1] = "quanta", |
13404 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | 13532 | [ALC269_ASUS_AMIC] = "asus-amic", |
13405 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901", | 13533 | [ALC269_ASUS_DMIC] = "asus-dmic", |
13406 | [ALC269_FUJITSU] = "fujitsu", | 13534 | [ALC269_FUJITSU] = "fujitsu", |
13407 | [ALC269_LIFEBOOK] = "lifebook", | 13535 | [ALC269_LIFEBOOK] = "lifebook", |
13408 | [ALC269_AUTO] = "auto", | 13536 | [ALC269_AUTO] = "auto", |
@@ -13411,18 +13539,41 @@ static const char *alc269_models[ALC269_MODEL_LAST] = { | |||
13411 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | 13539 | static struct snd_pci_quirk alc269_cfg_tbl[] = { |
13412 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), | 13540 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
13413 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", | 13541 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
13414 | ALC269_ASUS_EEEPC_P703), | 13542 | ALC269_ASUS_AMIC), |
13415 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703), | 13543 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC), |
13416 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703), | 13544 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC), |
13417 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703), | 13545 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC), |
13418 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703), | 13546 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC), |
13419 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703), | 13547 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC), |
13420 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703), | 13548 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC), |
13549 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC), | ||
13550 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC), | ||
13551 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC), | ||
13552 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC), | ||
13553 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC), | ||
13554 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC), | ||
13555 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC), | ||
13556 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC), | ||
13557 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC), | ||
13558 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC), | ||
13559 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC), | ||
13560 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC), | ||
13561 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC), | ||
13562 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC), | ||
13563 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC), | ||
13564 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC), | ||
13565 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC), | ||
13566 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC), | ||
13567 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC), | ||
13568 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC), | ||
13569 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC), | ||
13570 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC), | ||
13421 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | 13571 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", |
13422 | ALC269_ASUS_EEEPC_P901), | 13572 | ALC269_ASUS_DMIC), |
13423 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", | 13573 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
13424 | ALC269_ASUS_EEEPC_P901), | 13574 | ALC269_ASUS_DMIC), |
13425 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901), | 13575 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC), |
13576 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC), | ||
13426 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), | 13577 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), |
13427 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), | 13578 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), |
13428 | {} | 13579 | {} |
@@ -13452,7 +13603,7 @@ static struct alc_config_preset alc269_presets[] = { | |||
13452 | .setup = alc269_quanta_fl1_setup, | 13603 | .setup = alc269_quanta_fl1_setup, |
13453 | .init_hook = alc269_quanta_fl1_init_hook, | 13604 | .init_hook = alc269_quanta_fl1_init_hook, |
13454 | }, | 13605 | }, |
13455 | [ALC269_ASUS_EEEPC_P703] = { | 13606 | [ALC269_ASUS_AMIC] = { |
13456 | .mixers = { alc269_eeepc_mixer }, | 13607 | .mixers = { alc269_eeepc_mixer }, |
13457 | .cap_mixer = alc269_epc_capture_mixer, | 13608 | .cap_mixer = alc269_epc_capture_mixer, |
13458 | .init_verbs = { alc269_init_verbs, | 13609 | .init_verbs = { alc269_init_verbs, |
@@ -13466,7 +13617,7 @@ static struct alc_config_preset alc269_presets[] = { | |||
13466 | .setup = alc269_eeepc_amic_setup, | 13617 | .setup = alc269_eeepc_amic_setup, |
13467 | .init_hook = alc269_eeepc_inithook, | 13618 | .init_hook = alc269_eeepc_inithook, |
13468 | }, | 13619 | }, |
13469 | [ALC269_ASUS_EEEPC_P901] = { | 13620 | [ALC269_ASUS_DMIC] = { |
13470 | .mixers = { alc269_eeepc_mixer }, | 13621 | .mixers = { alc269_eeepc_mixer }, |
13471 | .cap_mixer = alc269_epc_capture_mixer, | 13622 | .cap_mixer = alc269_epc_capture_mixer, |
13472 | .init_verbs = { alc269_init_verbs, | 13623 | .init_verbs = { alc269_init_verbs, |
@@ -13522,6 +13673,15 @@ static int patch_alc269(struct hda_codec *codec) | |||
13522 | 13673 | ||
13523 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 13674 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
13524 | 13675 | ||
13676 | if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ | ||
13677 | kfree(codec->chip_name); | ||
13678 | codec->chip_name = kstrdup("ALC259", GFP_KERNEL); | ||
13679 | if (!codec->chip_name) { | ||
13680 | alc_free(codec); | ||
13681 | return -ENOMEM; | ||
13682 | } | ||
13683 | } | ||
13684 | |||
13525 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, | 13685 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
13526 | alc269_models, | 13686 | alc269_models, |
13527 | alc269_cfg_tbl); | 13687 | alc269_cfg_tbl); |
@@ -14154,10 +14314,8 @@ static struct hda_verb alc861_toshiba_init_verbs[] = { | |||
14154 | /* toggle speaker-output according to the hp-jack state */ | 14314 | /* toggle speaker-output according to the hp-jack state */ |
14155 | static void alc861_toshiba_automute(struct hda_codec *codec) | 14315 | static void alc861_toshiba_automute(struct hda_codec *codec) |
14156 | { | 14316 | { |
14157 | unsigned int present; | 14317 | unsigned int present = snd_hda_jack_detect(codec, 0x0f); |
14158 | 14318 | ||
14159 | present = snd_hda_codec_read(codec, 0x0f, 0, | ||
14160 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
14161 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, | 14319 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
14162 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 14320 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
14163 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | 14321 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, |
@@ -14257,9 +14415,7 @@ static int alc861_auto_fill_dac_nids(struct hda_codec *codec, | |||
14257 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, | 14415 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, |
14258 | hda_nid_t nid, unsigned int chs) | 14416 | hda_nid_t nid, unsigned int chs) |
14259 | { | 14417 | { |
14260 | char name[32]; | 14418 | return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, |
14261 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
14262 | return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name, | ||
14263 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 14419 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
14264 | } | 14420 | } |
14265 | 14421 | ||
@@ -14624,6 +14780,27 @@ static struct alc_config_preset alc861_presets[] = { | |||
14624 | }, | 14780 | }, |
14625 | }; | 14781 | }; |
14626 | 14782 | ||
14783 | /* Pin config fixes */ | ||
14784 | enum { | ||
14785 | PINFIX_FSC_AMILO_PI1505, | ||
14786 | }; | ||
14787 | |||
14788 | static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = { | ||
14789 | { 0x0b, 0x0221101f }, /* HP */ | ||
14790 | { 0x0f, 0x90170310 }, /* speaker */ | ||
14791 | { } | ||
14792 | }; | ||
14793 | |||
14794 | static const struct alc_fixup alc861_fixups[] = { | ||
14795 | [PINFIX_FSC_AMILO_PI1505] = { | ||
14796 | .pins = alc861_fsc_amilo_pi1505_pinfix | ||
14797 | }, | ||
14798 | }; | ||
14799 | |||
14800 | static struct snd_pci_quirk alc861_fixup_tbl[] = { | ||
14801 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505), | ||
14802 | {} | ||
14803 | }; | ||
14627 | 14804 | ||
14628 | static int patch_alc861(struct hda_codec *codec) | 14805 | static int patch_alc861(struct hda_codec *codec) |
14629 | { | 14806 | { |
@@ -14647,6 +14824,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
14647 | board_config = ALC861_AUTO; | 14824 | board_config = ALC861_AUTO; |
14648 | } | 14825 | } |
14649 | 14826 | ||
14827 | alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups); | ||
14828 | |||
14650 | if (board_config == ALC861_AUTO) { | 14829 | if (board_config == ALC861_AUTO) { |
14651 | /* automatic parse from the BIOS config */ | 14830 | /* automatic parse from the BIOS config */ |
14652 | err = alc861_parse_auto_config(codec); | 14831 | err = alc861_parse_auto_config(codec); |
@@ -15064,9 +15243,9 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |||
15064 | unsigned int present; | 15243 | unsigned int present; |
15065 | unsigned char bits; | 15244 | unsigned char bits; |
15066 | 15245 | ||
15067 | present = snd_hda_codec_read(codec, 0x18, 0, | 15246 | present = snd_hda_jack_detect(codec, 0x18); |
15068 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
15069 | bits = present ? HDA_AMP_MUTE : 0; | 15247 | bits = present ? HDA_AMP_MUTE : 0; |
15248 | |||
15070 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | 15249 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, |
15071 | HDA_AMP_MUTE, bits); | 15250 | HDA_AMP_MUTE, bits); |
15072 | } | 15251 | } |
@@ -15383,7 +15562,6 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |||
15383 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | 15562 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, |
15384 | const struct auto_pin_cfg *cfg) | 15563 | const struct auto_pin_cfg *cfg) |
15385 | { | 15564 | { |
15386 | char name[32]; | ||
15387 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | 15565 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; |
15388 | hda_nid_t nid_v, nid_s; | 15566 | hda_nid_t nid_v, nid_s; |
15389 | int i, err; | 15567 | int i, err; |
@@ -15400,26 +15578,26 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15400 | 15578 | ||
15401 | if (i == 2) { | 15579 | if (i == 2) { |
15402 | /* Center/LFE */ | 15580 | /* Center/LFE */ |
15403 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 15581 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
15404 | "Center Playback Volume", | 15582 | "Center", |
15405 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | 15583 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, |
15406 | HDA_OUTPUT)); | 15584 | HDA_OUTPUT)); |
15407 | if (err < 0) | 15585 | if (err < 0) |
15408 | return err; | 15586 | return err; |
15409 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 15587 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
15410 | "LFE Playback Volume", | 15588 | "LFE", |
15411 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | 15589 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, |
15412 | HDA_OUTPUT)); | 15590 | HDA_OUTPUT)); |
15413 | if (err < 0) | 15591 | if (err < 0) |
15414 | return err; | 15592 | return err; |
15415 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 15593 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
15416 | "Center Playback Switch", | 15594 | "Center", |
15417 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | 15595 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, |
15418 | HDA_INPUT)); | 15596 | HDA_INPUT)); |
15419 | if (err < 0) | 15597 | if (err < 0) |
15420 | return err; | 15598 | return err; |
15421 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 15599 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
15422 | "LFE Playback Switch", | 15600 | "LFE", |
15423 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | 15601 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, |
15424 | HDA_INPUT)); | 15602 | HDA_INPUT)); |
15425 | if (err < 0) | 15603 | if (err < 0) |
@@ -15434,8 +15612,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15434 | pfx = "PCM"; | 15612 | pfx = "PCM"; |
15435 | } else | 15613 | } else |
15436 | pfx = chname[i]; | 15614 | pfx = chname[i]; |
15437 | sprintf(name, "%s Playback Volume", pfx); | 15615 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
15438 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
15439 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | 15616 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, |
15440 | HDA_OUTPUT)); | 15617 | HDA_OUTPUT)); |
15441 | if (err < 0) | 15618 | if (err < 0) |
@@ -15443,8 +15620,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15443 | if (cfg->line_outs == 1 && | 15620 | if (cfg->line_outs == 1 && |
15444 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | 15621 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
15445 | pfx = "Speaker"; | 15622 | pfx = "Speaker"; |
15446 | sprintf(name, "%s Playback Switch", pfx); | 15623 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
15447 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
15448 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, | 15624 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
15449 | HDA_INPUT)); | 15625 | HDA_INPUT)); |
15450 | if (err < 0) | 15626 | if (err < 0) |
@@ -15462,7 +15638,6 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |||
15462 | { | 15638 | { |
15463 | hda_nid_t nid_v, nid_s; | 15639 | hda_nid_t nid_v, nid_s; |
15464 | int err; | 15640 | int err; |
15465 | char name[32]; | ||
15466 | 15641 | ||
15467 | if (!pin) | 15642 | if (!pin) |
15468 | return 0; | 15643 | return 0; |
@@ -15480,21 +15655,18 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |||
15480 | nid_s = alc861vd_idx_to_mixer_switch( | 15655 | nid_s = alc861vd_idx_to_mixer_switch( |
15481 | alc880_fixed_pin_idx(pin)); | 15656 | alc880_fixed_pin_idx(pin)); |
15482 | 15657 | ||
15483 | sprintf(name, "%s Playback Volume", pfx); | 15658 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
15484 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
15485 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | 15659 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); |
15486 | if (err < 0) | 15660 | if (err < 0) |
15487 | return err; | 15661 | return err; |
15488 | sprintf(name, "%s Playback Switch", pfx); | 15662 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
15489 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
15490 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | 15663 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); |
15491 | if (err < 0) | 15664 | if (err < 0) |
15492 | return err; | 15665 | return err; |
15493 | } else if (alc880_is_multi_pin(pin)) { | 15666 | } else if (alc880_is_multi_pin(pin)) { |
15494 | /* set manual connection */ | 15667 | /* set manual connection */ |
15495 | /* we have only a switch on HP-out PIN */ | 15668 | /* we have only a switch on HP-out PIN */ |
15496 | sprintf(name, "%s Playback Switch", pfx); | 15669 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
15497 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
15498 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 15670 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
15499 | if (err < 0) | 15671 | if (err < 0) |
15500 | return err; | 15672 | return err; |
@@ -16080,6 +16252,52 @@ static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |||
16080 | { } /* end */ | 16252 | { } /* end */ |
16081 | }; | 16253 | }; |
16082 | 16254 | ||
16255 | static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = { | ||
16256 | .ops = &snd_hda_bind_sw, | ||
16257 | .values = { | ||
16258 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | ||
16259 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | ||
16260 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
16261 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | ||
16262 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
16263 | 0 | ||
16264 | }, | ||
16265 | }; | ||
16266 | |||
16267 | static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = { | ||
16268 | .ops = &snd_hda_bind_sw, | ||
16269 | .values = { | ||
16270 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | ||
16271 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
16272 | 0 | ||
16273 | }, | ||
16274 | }; | ||
16275 | |||
16276 | static struct snd_kcontrol_new alc663_mode7_mixer[] = { | ||
16277 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch), | ||
16278 | HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol), | ||
16279 | HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch), | ||
16280 | HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
16281 | HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
16282 | HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
16283 | HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
16284 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
16285 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
16286 | { } /* end */ | ||
16287 | }; | ||
16288 | |||
16289 | static struct snd_kcontrol_new alc663_mode8_mixer[] = { | ||
16290 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch), | ||
16291 | HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol), | ||
16292 | HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch), | ||
16293 | HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
16294 | HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
16295 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
16296 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
16297 | { } /* end */ | ||
16298 | }; | ||
16299 | |||
16300 | |||
16083 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { | 16301 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
16084 | { | 16302 | { |
16085 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 16303 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -16367,6 +16585,45 @@ static struct hda_verb alc272_dell_init_verbs[] = { | |||
16367 | {} | 16585 | {} |
16368 | }; | 16586 | }; |
16369 | 16587 | ||
16588 | static struct hda_verb alc663_mode7_init_verbs[] = { | ||
16589 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16590 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16591 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16592 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16593 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16594 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16595 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
16596 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16597 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16598 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | ||
16599 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
16600 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | ||
16601 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | ||
16602 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16603 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16604 | {} | ||
16605 | }; | ||
16606 | |||
16607 | static struct hda_verb alc663_mode8_init_verbs[] = { | ||
16608 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16609 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16610 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16611 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
16612 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16613 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16614 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16615 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16616 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
16617 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16618 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | ||
16619 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
16620 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | ||
16621 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16622 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | ||
16623 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
16624 | {} | ||
16625 | }; | ||
16626 | |||
16370 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { | 16627 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
16371 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | 16628 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), |
16372 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | 16629 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), |
@@ -16384,9 +16641,9 @@ static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |||
16384 | unsigned int present; | 16641 | unsigned int present; |
16385 | unsigned char bits; | 16642 | unsigned char bits; |
16386 | 16643 | ||
16387 | present = snd_hda_codec_read(codec, 0x14, 0, | 16644 | present = snd_hda_jack_detect(codec, 0x14); |
16388 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
16389 | bits = present ? HDA_AMP_MUTE : 0; | 16645 | bits = present ? HDA_AMP_MUTE : 0; |
16646 | |||
16390 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 16647 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
16391 | HDA_AMP_MUTE, bits); | 16648 | HDA_AMP_MUTE, bits); |
16392 | } | 16649 | } |
@@ -16396,9 +16653,9 @@ static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |||
16396 | unsigned int present; | 16653 | unsigned int present; |
16397 | unsigned char bits; | 16654 | unsigned char bits; |
16398 | 16655 | ||
16399 | present = snd_hda_codec_read(codec, 0x1b, 0, | 16656 | present = snd_hda_jack_detect(codec, 0x1b); |
16400 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
16401 | bits = present ? HDA_AMP_MUTE : 0; | 16657 | bits = present ? HDA_AMP_MUTE : 0; |
16658 | |||
16402 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 16659 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
16403 | HDA_AMP_MUTE, bits); | 16660 | HDA_AMP_MUTE, bits); |
16404 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 16661 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
@@ -16457,9 +16714,7 @@ static void alc663_m51va_speaker_automute(struct hda_codec *codec) | |||
16457 | unsigned int present; | 16714 | unsigned int present; |
16458 | unsigned char bits; | 16715 | unsigned char bits; |
16459 | 16716 | ||
16460 | present = snd_hda_codec_read(codec, 0x21, 0, | 16717 | present = snd_hda_jack_detect(codec, 0x21); |
16461 | AC_VERB_GET_PIN_SENSE, 0) | ||
16462 | & AC_PINSENSE_PRESENCE; | ||
16463 | bits = present ? HDA_AMP_MUTE : 0; | 16718 | bits = present ? HDA_AMP_MUTE : 0; |
16464 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16719 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
16465 | AMP_IN_MUTE(0), bits); | 16720 | AMP_IN_MUTE(0), bits); |
@@ -16472,9 +16727,7 @@ static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |||
16472 | unsigned int present; | 16727 | unsigned int present; |
16473 | unsigned char bits; | 16728 | unsigned char bits; |
16474 | 16729 | ||
16475 | present = snd_hda_codec_read(codec, 0x21, 0, | 16730 | present = snd_hda_jack_detect(codec, 0x21); |
16476 | AC_VERB_GET_PIN_SENSE, 0) | ||
16477 | & AC_PINSENSE_PRESENCE; | ||
16478 | bits = present ? HDA_AMP_MUTE : 0; | 16731 | bits = present ? HDA_AMP_MUTE : 0; |
16479 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16732 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
16480 | AMP_IN_MUTE(0), bits); | 16733 | AMP_IN_MUTE(0), bits); |
@@ -16491,9 +16744,7 @@ static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |||
16491 | unsigned int present; | 16744 | unsigned int present; |
16492 | unsigned char bits; | 16745 | unsigned char bits; |
16493 | 16746 | ||
16494 | present = snd_hda_codec_read(codec, 0x15, 0, | 16747 | present = snd_hda_jack_detect(codec, 0x15); |
16495 | AC_VERB_GET_PIN_SENSE, 0) | ||
16496 | & AC_PINSENSE_PRESENCE; | ||
16497 | bits = present ? HDA_AMP_MUTE : 0; | 16748 | bits = present ? HDA_AMP_MUTE : 0; |
16498 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16749 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
16499 | AMP_IN_MUTE(0), bits); | 16750 | AMP_IN_MUTE(0), bits); |
@@ -16510,9 +16761,7 @@ static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |||
16510 | unsigned int present; | 16761 | unsigned int present; |
16511 | unsigned char bits; | 16762 | unsigned char bits; |
16512 | 16763 | ||
16513 | present = snd_hda_codec_read(codec, 0x1b, 0, | 16764 | present = snd_hda_jack_detect(codec, 0x1b); |
16514 | AC_VERB_GET_PIN_SENSE, 0) | ||
16515 | & AC_PINSENSE_PRESENCE; | ||
16516 | bits = present ? 0 : PIN_OUT; | 16765 | bits = present ? 0 : PIN_OUT; |
16517 | snd_hda_codec_write(codec, 0x14, 0, | 16766 | snd_hda_codec_write(codec, 0x14, 0, |
16518 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | 16767 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); |
@@ -16522,12 +16771,8 @@ static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |||
16522 | { | 16771 | { |
16523 | unsigned int present1, present2; | 16772 | unsigned int present1, present2; |
16524 | 16773 | ||
16525 | present1 = snd_hda_codec_read(codec, 0x21, 0, | 16774 | present1 = snd_hda_jack_detect(codec, 0x21); |
16526 | AC_VERB_GET_PIN_SENSE, 0) | 16775 | present2 = snd_hda_jack_detect(codec, 0x15); |
16527 | & AC_PINSENSE_PRESENCE; | ||
16528 | present2 = snd_hda_codec_read(codec, 0x15, 0, | ||
16529 | AC_VERB_GET_PIN_SENSE, 0) | ||
16530 | & AC_PINSENSE_PRESENCE; | ||
16531 | 16776 | ||
16532 | if (present1 || present2) { | 16777 | if (present1 || present2) { |
16533 | snd_hda_codec_write_cache(codec, 0x14, 0, | 16778 | snd_hda_codec_write_cache(codec, 0x14, 0, |
@@ -16542,12 +16787,8 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |||
16542 | { | 16787 | { |
16543 | unsigned int present1, present2; | 16788 | unsigned int present1, present2; |
16544 | 16789 | ||
16545 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | 16790 | present1 = snd_hda_jack_detect(codec, 0x1b); |
16546 | AC_VERB_GET_PIN_SENSE, 0) | 16791 | present2 = snd_hda_jack_detect(codec, 0x15); |
16547 | & AC_PINSENSE_PRESENCE; | ||
16548 | present2 = snd_hda_codec_read(codec, 0x15, 0, | ||
16549 | AC_VERB_GET_PIN_SENSE, 0) | ||
16550 | & AC_PINSENSE_PRESENCE; | ||
16551 | 16792 | ||
16552 | if (present1 || present2) { | 16793 | if (present1 || present2) { |
16553 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | 16794 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
@@ -16562,6 +16803,54 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |||
16562 | } | 16803 | } |
16563 | } | 16804 | } |
16564 | 16805 | ||
16806 | static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec) | ||
16807 | { | ||
16808 | unsigned int present1, present2; | ||
16809 | |||
16810 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | ||
16811 | AC_VERB_GET_PIN_SENSE, 0) | ||
16812 | & AC_PINSENSE_PRESENCE; | ||
16813 | present2 = snd_hda_codec_read(codec, 0x21, 0, | ||
16814 | AC_VERB_GET_PIN_SENSE, 0) | ||
16815 | & AC_PINSENSE_PRESENCE; | ||
16816 | |||
16817 | if (present1 || present2) { | ||
16818 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16819 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16820 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16821 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16822 | } else { | ||
16823 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16824 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16825 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16826 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16827 | } | ||
16828 | } | ||
16829 | |||
16830 | static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec) | ||
16831 | { | ||
16832 | unsigned int present1, present2; | ||
16833 | |||
16834 | present1 = snd_hda_codec_read(codec, 0x21, 0, | ||
16835 | AC_VERB_GET_PIN_SENSE, 0) | ||
16836 | & AC_PINSENSE_PRESENCE; | ||
16837 | present2 = snd_hda_codec_read(codec, 0x15, 0, | ||
16838 | AC_VERB_GET_PIN_SENSE, 0) | ||
16839 | & AC_PINSENSE_PRESENCE; | ||
16840 | |||
16841 | if (present1 || present2) { | ||
16842 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16843 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16844 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16845 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
16846 | } else { | ||
16847 | snd_hda_codec_write_cache(codec, 0x14, 0, | ||
16848 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16849 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
16850 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
16851 | } | ||
16852 | } | ||
16853 | |||
16565 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | 16854 | static void alc663_m51va_unsol_event(struct hda_codec *codec, |
16566 | unsigned int res) | 16855 | unsigned int res) |
16567 | { | 16856 | { |
@@ -16581,7 +16870,7 @@ static void alc663_m51va_setup(struct hda_codec *codec) | |||
16581 | spec->ext_mic.pin = 0x18; | 16870 | spec->ext_mic.pin = 0x18; |
16582 | spec->ext_mic.mux_idx = 0; | 16871 | spec->ext_mic.mux_idx = 0; |
16583 | spec->int_mic.pin = 0x12; | 16872 | spec->int_mic.pin = 0x12; |
16584 | spec->int_mic.mux_idx = 1; | 16873 | spec->int_mic.mux_idx = 9; |
16585 | spec->auto_mic = 1; | 16874 | spec->auto_mic = 1; |
16586 | } | 16875 | } |
16587 | 16876 | ||
@@ -16593,7 +16882,17 @@ static void alc663_m51va_inithook(struct hda_codec *codec) | |||
16593 | 16882 | ||
16594 | /* ***************** Mode1 ******************************/ | 16883 | /* ***************** Mode1 ******************************/ |
16595 | #define alc663_mode1_unsol_event alc663_m51va_unsol_event | 16884 | #define alc663_mode1_unsol_event alc663_m51va_unsol_event |
16596 | #define alc663_mode1_setup alc663_m51va_setup | 16885 | |
16886 | static void alc663_mode1_setup(struct hda_codec *codec) | ||
16887 | { | ||
16888 | struct alc_spec *spec = codec->spec; | ||
16889 | spec->ext_mic.pin = 0x18; | ||
16890 | spec->ext_mic.mux_idx = 0; | ||
16891 | spec->int_mic.pin = 0x19; | ||
16892 | spec->int_mic.mux_idx = 1; | ||
16893 | spec->auto_mic = 1; | ||
16894 | } | ||
16895 | |||
16597 | #define alc663_mode1_inithook alc663_m51va_inithook | 16896 | #define alc663_mode1_inithook alc663_m51va_inithook |
16598 | 16897 | ||
16599 | /* ***************** Mode2 ******************************/ | 16898 | /* ***************** Mode2 ******************************/ |
@@ -16610,7 +16909,7 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec, | |||
16610 | } | 16909 | } |
16611 | } | 16910 | } |
16612 | 16911 | ||
16613 | #define alc662_mode2_setup alc663_m51va_setup | 16912 | #define alc662_mode2_setup alc663_mode1_setup |
16614 | 16913 | ||
16615 | static void alc662_mode2_inithook(struct hda_codec *codec) | 16914 | static void alc662_mode2_inithook(struct hda_codec *codec) |
16616 | { | 16915 | { |
@@ -16631,7 +16930,7 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec, | |||
16631 | } | 16930 | } |
16632 | } | 16931 | } |
16633 | 16932 | ||
16634 | #define alc663_mode3_setup alc663_m51va_setup | 16933 | #define alc663_mode3_setup alc663_mode1_setup |
16635 | 16934 | ||
16636 | static void alc663_mode3_inithook(struct hda_codec *codec) | 16935 | static void alc663_mode3_inithook(struct hda_codec *codec) |
16637 | { | 16936 | { |
@@ -16652,7 +16951,7 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec, | |||
16652 | } | 16951 | } |
16653 | } | 16952 | } |
16654 | 16953 | ||
16655 | #define alc663_mode4_setup alc663_m51va_setup | 16954 | #define alc663_mode4_setup alc663_mode1_setup |
16656 | 16955 | ||
16657 | static void alc663_mode4_inithook(struct hda_codec *codec) | 16956 | static void alc663_mode4_inithook(struct hda_codec *codec) |
16658 | { | 16957 | { |
@@ -16673,7 +16972,7 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec, | |||
16673 | } | 16972 | } |
16674 | } | 16973 | } |
16675 | 16974 | ||
16676 | #define alc663_mode5_setup alc663_m51va_setup | 16975 | #define alc663_mode5_setup alc663_mode1_setup |
16677 | 16976 | ||
16678 | static void alc663_mode5_inithook(struct hda_codec *codec) | 16977 | static void alc663_mode5_inithook(struct hda_codec *codec) |
16679 | { | 16978 | { |
@@ -16694,7 +16993,7 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec, | |||
16694 | } | 16993 | } |
16695 | } | 16994 | } |
16696 | 16995 | ||
16697 | #define alc663_mode6_setup alc663_m51va_setup | 16996 | #define alc663_mode6_setup alc663_mode1_setup |
16698 | 16997 | ||
16699 | static void alc663_mode6_inithook(struct hda_codec *codec) | 16998 | static void alc663_mode6_inithook(struct hda_codec *codec) |
16700 | { | 16999 | { |
@@ -16702,14 +17001,56 @@ static void alc663_mode6_inithook(struct hda_codec *codec) | |||
16702 | alc_mic_automute(codec); | 17001 | alc_mic_automute(codec); |
16703 | } | 17002 | } |
16704 | 17003 | ||
17004 | /* ***************** Mode7 ******************************/ | ||
17005 | static void alc663_mode7_unsol_event(struct hda_codec *codec, | ||
17006 | unsigned int res) | ||
17007 | { | ||
17008 | switch (res >> 26) { | ||
17009 | case ALC880_HP_EVENT: | ||
17010 | alc663_two_hp_m7_speaker_automute(codec); | ||
17011 | break; | ||
17012 | case ALC880_MIC_EVENT: | ||
17013 | alc_mic_automute(codec); | ||
17014 | break; | ||
17015 | } | ||
17016 | } | ||
17017 | |||
17018 | #define alc663_mode7_setup alc663_mode1_setup | ||
17019 | |||
17020 | static void alc663_mode7_inithook(struct hda_codec *codec) | ||
17021 | { | ||
17022 | alc663_two_hp_m7_speaker_automute(codec); | ||
17023 | alc_mic_automute(codec); | ||
17024 | } | ||
17025 | |||
17026 | /* ***************** Mode8 ******************************/ | ||
17027 | static void alc663_mode8_unsol_event(struct hda_codec *codec, | ||
17028 | unsigned int res) | ||
17029 | { | ||
17030 | switch (res >> 26) { | ||
17031 | case ALC880_HP_EVENT: | ||
17032 | alc663_two_hp_m8_speaker_automute(codec); | ||
17033 | break; | ||
17034 | case ALC880_MIC_EVENT: | ||
17035 | alc_mic_automute(codec); | ||
17036 | break; | ||
17037 | } | ||
17038 | } | ||
17039 | |||
17040 | #define alc663_mode8_setup alc663_m51va_setup | ||
17041 | |||
17042 | static void alc663_mode8_inithook(struct hda_codec *codec) | ||
17043 | { | ||
17044 | alc663_two_hp_m8_speaker_automute(codec); | ||
17045 | alc_mic_automute(codec); | ||
17046 | } | ||
17047 | |||
16705 | static void alc663_g71v_hp_automute(struct hda_codec *codec) | 17048 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
16706 | { | 17049 | { |
16707 | unsigned int present; | 17050 | unsigned int present; |
16708 | unsigned char bits; | 17051 | unsigned char bits; |
16709 | 17052 | ||
16710 | present = snd_hda_codec_read(codec, 0x21, 0, | 17053 | present = snd_hda_jack_detect(codec, 0x21); |
16711 | AC_VERB_GET_PIN_SENSE, 0) | ||
16712 | & AC_PINSENSE_PRESENCE; | ||
16713 | bits = present ? HDA_AMP_MUTE : 0; | 17054 | bits = present ? HDA_AMP_MUTE : 0; |
16714 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 17055 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
16715 | HDA_AMP_MUTE, bits); | 17056 | HDA_AMP_MUTE, bits); |
@@ -16722,9 +17063,7 @@ static void alc663_g71v_front_automute(struct hda_codec *codec) | |||
16722 | unsigned int present; | 17063 | unsigned int present; |
16723 | unsigned char bits; | 17064 | unsigned char bits; |
16724 | 17065 | ||
16725 | present = snd_hda_codec_read(codec, 0x15, 0, | 17066 | present = snd_hda_jack_detect(codec, 0x15); |
16726 | AC_VERB_GET_PIN_SENSE, 0) | ||
16727 | & AC_PINSENSE_PRESENCE; | ||
16728 | bits = present ? HDA_AMP_MUTE : 0; | 17067 | bits = present ? HDA_AMP_MUTE : 0; |
16729 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 17068 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
16730 | HDA_AMP_MUTE, bits); | 17069 | HDA_AMP_MUTE, bits); |
@@ -16840,6 +17179,8 @@ static const char *alc662_models[ALC662_MODEL_LAST] = { | |||
16840 | [ALC663_ASUS_MODE4] = "asus-mode4", | 17179 | [ALC663_ASUS_MODE4] = "asus-mode4", |
16841 | [ALC663_ASUS_MODE5] = "asus-mode5", | 17180 | [ALC663_ASUS_MODE5] = "asus-mode5", |
16842 | [ALC663_ASUS_MODE6] = "asus-mode6", | 17181 | [ALC663_ASUS_MODE6] = "asus-mode6", |
17182 | [ALC663_ASUS_MODE7] = "asus-mode7", | ||
17183 | [ALC663_ASUS_MODE8] = "asus-mode8", | ||
16843 | [ALC272_DELL] = "dell", | 17184 | [ALC272_DELL] = "dell", |
16844 | [ALC272_DELL_ZM1] = "dell-zm1", | 17185 | [ALC272_DELL_ZM1] = "dell-zm1", |
16845 | [ALC272_SAMSUNG_NC10] = "samsung-nc10", | 17186 | [ALC272_SAMSUNG_NC10] = "samsung-nc10", |
@@ -16856,12 +17197,22 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
16856 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | 17197 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), |
16857 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | 17198 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), |
16858 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), | 17199 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), |
17200 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1), | ||
17201 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1), | ||
16859 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), | 17202 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), |
17203 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7), | ||
17204 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7), | ||
17205 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8), | ||
17206 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3), | ||
17207 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1), | ||
16860 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), | 17208 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), |
17209 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2), | ||
17210 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1), | ||
16861 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | 17211 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), |
16862 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | 17212 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), |
16863 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | 17213 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), |
16864 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | 17214 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), |
17215 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1), | ||
16865 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3), | 17216 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3), |
16866 | SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA), | 17217 | SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA), |
16867 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2), | 17218 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2), |
@@ -16911,6 +17262,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
16911 | ALC662_3ST_6ch_DIG), | 17262 | ALC662_3ST_6ch_DIG), |
16912 | SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x", | 17263 | SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x", |
16913 | ALC663_ASUS_H13), | 17264 | ALC663_ASUS_H13), |
17265 | SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG), | ||
16914 | {} | 17266 | {} |
16915 | }; | 17267 | }; |
16916 | 17268 | ||
@@ -17144,6 +17496,36 @@ static struct alc_config_preset alc662_presets[] = { | |||
17144 | .setup = alc663_mode6_setup, | 17496 | .setup = alc663_mode6_setup, |
17145 | .init_hook = alc663_mode6_inithook, | 17497 | .init_hook = alc663_mode6_inithook, |
17146 | }, | 17498 | }, |
17499 | [ALC663_ASUS_MODE7] = { | ||
17500 | .mixers = { alc663_mode7_mixer }, | ||
17501 | .cap_mixer = alc662_auto_capture_mixer, | ||
17502 | .init_verbs = { alc662_init_verbs, | ||
17503 | alc663_mode7_init_verbs }, | ||
17504 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | ||
17505 | .hp_nid = 0x03, | ||
17506 | .dac_nids = alc662_dac_nids, | ||
17507 | .dig_out_nid = ALC662_DIGOUT_NID, | ||
17508 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | ||
17509 | .channel_mode = alc662_3ST_2ch_modes, | ||
17510 | .unsol_event = alc663_mode7_unsol_event, | ||
17511 | .setup = alc663_mode7_setup, | ||
17512 | .init_hook = alc663_mode7_inithook, | ||
17513 | }, | ||
17514 | [ALC663_ASUS_MODE8] = { | ||
17515 | .mixers = { alc663_mode8_mixer }, | ||
17516 | .cap_mixer = alc662_auto_capture_mixer, | ||
17517 | .init_verbs = { alc662_init_verbs, | ||
17518 | alc663_mode8_init_verbs }, | ||
17519 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | ||
17520 | .hp_nid = 0x03, | ||
17521 | .dac_nids = alc662_dac_nids, | ||
17522 | .dig_out_nid = ALC662_DIGOUT_NID, | ||
17523 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | ||
17524 | .channel_mode = alc662_3ST_2ch_modes, | ||
17525 | .unsol_event = alc663_mode8_unsol_event, | ||
17526 | .setup = alc663_mode8_setup, | ||
17527 | .init_hook = alc663_mode8_inithook, | ||
17528 | }, | ||
17147 | [ALC272_DELL] = { | 17529 | [ALC272_DELL] = { |
17148 | .mixers = { alc663_m51va_mixer }, | 17530 | .mixers = { alc663_m51va_mixer }, |
17149 | .cap_mixer = alc272_auto_capture_mixer, | 17531 | .cap_mixer = alc272_auto_capture_mixer, |
@@ -17261,21 +17643,17 @@ static int alc662_auto_fill_dac_nids(struct hda_codec *codec, | |||
17261 | return 0; | 17643 | return 0; |
17262 | } | 17644 | } |
17263 | 17645 | ||
17264 | static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, | 17646 | static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, |
17265 | hda_nid_t nid, unsigned int chs) | 17647 | hda_nid_t nid, unsigned int chs) |
17266 | { | 17648 | { |
17267 | char name[32]; | 17649 | return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
17268 | sprintf(name, "%s Playback Volume", pfx); | ||
17269 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
17270 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 17650 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
17271 | } | 17651 | } |
17272 | 17652 | ||
17273 | static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, | 17653 | static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, |
17274 | hda_nid_t nid, unsigned int chs) | 17654 | hda_nid_t nid, unsigned int chs) |
17275 | { | 17655 | { |
17276 | char name[32]; | 17656 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
17277 | sprintf(name, "%s Playback Switch", pfx); | ||
17278 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
17279 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); | 17657 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); |
17280 | } | 17658 | } |
17281 | 17659 | ||
@@ -17353,13 +17731,11 @@ static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, | |||
17353 | return 0; | 17731 | return 0; |
17354 | nid = alc662_look_for_dac(codec, pin); | 17732 | nid = alc662_look_for_dac(codec, pin); |
17355 | if (!nid) { | 17733 | if (!nid) { |
17356 | char name[32]; | ||
17357 | /* the corresponding DAC is already occupied */ | 17734 | /* the corresponding DAC is already occupied */ |
17358 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) | 17735 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
17359 | return 0; /* no way */ | 17736 | return 0; /* no way */ |
17360 | /* create a switch only */ | 17737 | /* create a switch only */ |
17361 | sprintf(name, "%s Playback Switch", pfx); | 17738 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
17362 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
17363 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 17739 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
17364 | } | 17740 | } |
17365 | 17741 | ||
@@ -17535,6 +17911,15 @@ static int patch_alc662(struct hda_codec *codec) | |||
17535 | 17911 | ||
17536 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 17912 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
17537 | 17913 | ||
17914 | if (alc_read_coef_idx(codec, 0)==0x8020){ | ||
17915 | kfree(codec->chip_name); | ||
17916 | codec->chip_name = kstrdup("ALC661", GFP_KERNEL); | ||
17917 | if (!codec->chip_name) { | ||
17918 | alc_free(codec); | ||
17919 | return -ENOMEM; | ||
17920 | } | ||
17921 | } | ||
17922 | |||
17538 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | 17923 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
17539 | alc662_models, | 17924 | alc662_models, |
17540 | alc662_cfg_tbl); | 17925 | alc662_cfg_tbl); |
@@ -17601,6 +17986,20 @@ static int patch_alc662(struct hda_codec *codec) | |||
17601 | return 0; | 17986 | return 0; |
17602 | } | 17987 | } |
17603 | 17988 | ||
17989 | static int patch_alc888(struct hda_codec *codec) | ||
17990 | { | ||
17991 | if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){ | ||
17992 | kfree(codec->chip_name); | ||
17993 | codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL); | ||
17994 | if (!codec->chip_name) { | ||
17995 | alc_free(codec); | ||
17996 | return -ENOMEM; | ||
17997 | } | ||
17998 | return patch_alc662(codec); | ||
17999 | } | ||
18000 | return patch_alc882(codec); | ||
18001 | } | ||
18002 | |||
17604 | /* | 18003 | /* |
17605 | * patch entries | 18004 | * patch entries |
17606 | */ | 18005 | */ |
@@ -17610,7 +18009,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
17610 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, | 18009 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
17611 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, | 18010 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
17612 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, | 18011 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
18012 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, | ||
17613 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, | 18013 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
18014 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, | ||
17614 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", | 18015 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
17615 | .patch = patch_alc861 }, | 18016 | .patch = patch_alc861 }, |
17616 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, | 18017 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
@@ -17632,8 +18033,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
17632 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, | 18033 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
17633 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", | 18034 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
17634 | .patch = patch_alc882 }, | 18035 | .patch = patch_alc882 }, |
17635 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, | 18036 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 }, |
17636 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, | 18037 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
18038 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, | ||
17637 | {} /* terminator */ | 18039 | {} /* terminator */ |
17638 | }; | 18040 | }; |
17639 | 18041 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 66c0876bf734..eeda7beeb57a 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
31 | #include <linux/dmi.h> | ||
31 | #include <sound/core.h> | 32 | #include <sound/core.h> |
32 | #include <sound/asoundef.h> | 33 | #include <sound/asoundef.h> |
33 | #include <sound/jack.h> | 34 | #include <sound/jack.h> |
@@ -92,6 +93,7 @@ enum { | |||
92 | STAC_92HD83XXX_REF, | 93 | STAC_92HD83XXX_REF, |
93 | STAC_92HD83XXX_PWR_REF, | 94 | STAC_92HD83XXX_PWR_REF, |
94 | STAC_DELL_S14, | 95 | STAC_DELL_S14, |
96 | STAC_92HD83XXX_HP, | ||
95 | STAC_92HD83XXX_MODELS | 97 | STAC_92HD83XXX_MODELS |
96 | }; | 98 | }; |
97 | 99 | ||
@@ -207,6 +209,7 @@ struct sigmatel_spec { | |||
207 | unsigned int gpio_data; | 209 | unsigned int gpio_data; |
208 | unsigned int gpio_mute; | 210 | unsigned int gpio_mute; |
209 | unsigned int gpio_led; | 211 | unsigned int gpio_led; |
212 | unsigned int gpio_led_polarity; | ||
210 | 213 | ||
211 | /* stream */ | 214 | /* stream */ |
212 | unsigned int stream_delay; | 215 | unsigned int stream_delay; |
@@ -1084,7 +1087,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) | |||
1084 | if (!spec->auto_mic && spec->num_dmuxes > 0 && | 1087 | if (!spec->auto_mic && spec->num_dmuxes > 0 && |
1085 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { | 1088 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { |
1086 | stac_dmux_mixer.count = spec->num_dmuxes; | 1089 | stac_dmux_mixer.count = spec->num_dmuxes; |
1087 | err = snd_hda_ctl_add(codec, | 1090 | err = snd_hda_ctl_add(codec, 0, |
1088 | snd_ctl_new1(&stac_dmux_mixer, codec)); | 1091 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
1089 | if (err < 0) | 1092 | if (err < 0) |
1090 | return err; | 1093 | return err; |
@@ -1100,7 +1103,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) | |||
1100 | spec->spdif_mute = 1; | 1103 | spec->spdif_mute = 1; |
1101 | } | 1104 | } |
1102 | stac_smux_mixer.count = spec->num_smuxes; | 1105 | stac_smux_mixer.count = spec->num_smuxes; |
1103 | err = snd_hda_ctl_add(codec, | 1106 | err = snd_hda_ctl_add(codec, 0, |
1104 | snd_ctl_new1(&stac_smux_mixer, codec)); | 1107 | snd_ctl_new1(&stac_smux_mixer, codec)); |
1105 | if (err < 0) | 1108 | if (err < 0) |
1106 | return err; | 1109 | return err; |
@@ -1536,6 +1539,13 @@ static unsigned int alienware_m17x_pin_configs[13] = { | |||
1536 | 0x904601b0, | 1539 | 0x904601b0, |
1537 | }; | 1540 | }; |
1538 | 1541 | ||
1542 | static unsigned int intel_dg45id_pin_configs[14] = { | ||
1543 | 0x02214230, 0x02A19240, 0x01013214, 0x01014210, | ||
1544 | 0x01A19250, 0x01011212, 0x01016211, 0x40f000f0, | ||
1545 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x014510A0, | ||
1546 | 0x074510B0, 0x40f000f0 | ||
1547 | }; | ||
1548 | |||
1539 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | 1549 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
1540 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, | 1550 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
1541 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, | 1551 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
@@ -1543,6 +1553,7 @@ static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | |||
1543 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, | 1553 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
1544 | [STAC_DELL_EQ] = dell_m6_pin_configs, | 1554 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
1545 | [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs, | 1555 | [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs, |
1556 | [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs, | ||
1546 | }; | 1557 | }; |
1547 | 1558 | ||
1548 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { | 1559 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
@@ -1589,6 +1600,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |||
1589 | "Dell Studio 17", STAC_DELL_M6_DMIC), | 1600 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
1590 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, | 1601 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, |
1591 | "Dell Studio 1555", STAC_DELL_M6_DMIC), | 1602 | "Dell Studio 1555", STAC_DELL_M6_DMIC), |
1603 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd, | ||
1604 | "Dell Studio 1557", STAC_DELL_M6_DMIC), | ||
1592 | {} /* terminator */ | 1605 | {} /* terminator */ |
1593 | }; | 1606 | }; |
1594 | 1607 | ||
@@ -1621,6 +1634,7 @@ static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { | |||
1621 | [STAC_92HD83XXX_REF] = "ref", | 1634 | [STAC_92HD83XXX_REF] = "ref", |
1622 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", | 1635 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
1623 | [STAC_DELL_S14] = "dell-s14", | 1636 | [STAC_DELL_S14] = "dell-s14", |
1637 | [STAC_92HD83XXX_HP] = "hp", | ||
1624 | }; | 1638 | }; |
1625 | 1639 | ||
1626 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { | 1640 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
@@ -1631,6 +1645,8 @@ static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { | |||
1631 | "DFI LanParty", STAC_92HD83XXX_REF), | 1645 | "DFI LanParty", STAC_92HD83XXX_REF), |
1632 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, | 1646 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
1633 | "unknown Dell", STAC_DELL_S14), | 1647 | "unknown Dell", STAC_DELL_S14), |
1648 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600, | ||
1649 | "HP", STAC_92HD83XXX_HP), | ||
1634 | {} /* terminator */ | 1650 | {} /* terminator */ |
1635 | }; | 1651 | }; |
1636 | 1652 | ||
@@ -1693,6 +1709,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |||
1693 | "DFI LanParty", STAC_92HD71BXX_REF), | 1709 | "DFI LanParty", STAC_92HD71BXX_REF), |
1694 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, | 1710 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
1695 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), | 1711 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
1712 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720, | ||
1713 | "HP", STAC_HP_DV5), | ||
1696 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, | 1714 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
1697 | "HP", STAC_HP_DV5), | 1715 | "HP", STAC_HP_DV5), |
1698 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, | 1716 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
@@ -2086,6 +2104,7 @@ static unsigned int ref9205_pin_configs[12] = { | |||
2086 | 10280204 | 2104 | 10280204 |
2087 | 1028021F | 2105 | 1028021F |
2088 | 10280228 (Dell Vostro 1500) | 2106 | 10280228 (Dell Vostro 1500) |
2107 | 10280229 (Dell Vostro 1700) | ||
2089 | */ | 2108 | */ |
2090 | static unsigned int dell_9205_m42_pin_configs[12] = { | 2109 | static unsigned int dell_9205_m42_pin_configs[12] = { |
2091 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, | 2110 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
@@ -2171,6 +2190,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = { | |||
2171 | "Dell Inspiron", STAC_9205_DELL_M44), | 2190 | "Dell Inspiron", STAC_9205_DELL_M44), |
2172 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, | 2191 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
2173 | "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), | ||
2174 | /* Gateway */ | 2195 | /* Gateway */ |
2175 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), | 2196 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
2176 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), | 2197 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
@@ -2643,6 +2664,7 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, | |||
2643 | enum { | 2664 | enum { |
2644 | STAC_CTL_WIDGET_VOL, | 2665 | STAC_CTL_WIDGET_VOL, |
2645 | STAC_CTL_WIDGET_MUTE, | 2666 | STAC_CTL_WIDGET_MUTE, |
2667 | STAC_CTL_WIDGET_MUTE_BEEP, | ||
2646 | STAC_CTL_WIDGET_MONO_MUX, | 2668 | STAC_CTL_WIDGET_MONO_MUX, |
2647 | STAC_CTL_WIDGET_HP_SWITCH, | 2669 | STAC_CTL_WIDGET_HP_SWITCH, |
2648 | STAC_CTL_WIDGET_IO_SWITCH, | 2670 | STAC_CTL_WIDGET_IO_SWITCH, |
@@ -2653,6 +2675,7 @@ enum { | |||
2653 | static struct snd_kcontrol_new stac92xx_control_templates[] = { | 2675 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
2654 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), | 2676 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2655 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | 2677 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
2678 | HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0), | ||
2656 | STAC_MONO_MUX, | 2679 | STAC_MONO_MUX, |
2657 | STAC_CODEC_HP_SWITCH(NULL), | 2680 | STAC_CODEC_HP_SWITCH(NULL), |
2658 | STAC_CODEC_IO_SWITCH(NULL, 0), | 2681 | STAC_CODEC_IO_SWITCH(NULL, 0), |
@@ -2664,7 +2687,8 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = { | |||
2664 | static struct snd_kcontrol_new * | 2687 | static struct snd_kcontrol_new * |
2665 | stac_control_new(struct sigmatel_spec *spec, | 2688 | stac_control_new(struct sigmatel_spec *spec, |
2666 | struct snd_kcontrol_new *ktemp, | 2689 | struct snd_kcontrol_new *ktemp, |
2667 | const char *name) | 2690 | const char *name, |
2691 | hda_nid_t nid) | ||
2668 | { | 2692 | { |
2669 | struct snd_kcontrol_new *knew; | 2693 | struct snd_kcontrol_new *knew; |
2670 | 2694 | ||
@@ -2680,6 +2704,8 @@ stac_control_new(struct sigmatel_spec *spec, | |||
2680 | spec->kctls.alloced--; | 2704 | spec->kctls.alloced--; |
2681 | return NULL; | 2705 | return NULL; |
2682 | } | 2706 | } |
2707 | if (nid) | ||
2708 | knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; | ||
2683 | return knew; | 2709 | return knew; |
2684 | } | 2710 | } |
2685 | 2711 | ||
@@ -2688,7 +2714,8 @@ static int stac92xx_add_control_temp(struct sigmatel_spec *spec, | |||
2688 | int idx, const char *name, | 2714 | int idx, const char *name, |
2689 | unsigned long val) | 2715 | unsigned long val) |
2690 | { | 2716 | { |
2691 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); | 2717 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, |
2718 | get_amp_nid_(val)); | ||
2692 | if (!knew) | 2719 | if (!knew) |
2693 | return -ENOMEM; | 2720 | return -ENOMEM; |
2694 | knew->index = idx; | 2721 | knew->index = idx; |
@@ -2759,7 +2786,7 @@ static int stac92xx_add_input_source(struct sigmatel_spec *spec) | |||
2759 | if (!spec->num_adcs || imux->num_items <= 1) | 2786 | if (!spec->num_adcs || imux->num_items <= 1) |
2760 | return 0; /* no need for input source control */ | 2787 | return 0; /* no need for input source control */ |
2761 | knew = stac_control_new(spec, &stac_input_src_temp, | 2788 | knew = stac_control_new(spec, &stac_input_src_temp, |
2762 | stac_input_src_temp.name); | 2789 | stac_input_src_temp.name, 0); |
2763 | if (!knew) | 2790 | if (!knew) |
2764 | return -ENOMEM; | 2791 | return -ENOMEM; |
2765 | knew->count = spec->num_adcs; | 2792 | knew->count = spec->num_adcs; |
@@ -3216,12 +3243,15 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | |||
3216 | { | 3243 | { |
3217 | struct sigmatel_spec *spec = codec->spec; | 3244 | struct sigmatel_spec *spec = codec->spec; |
3218 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 3245 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
3219 | int err; | 3246 | int err, type = STAC_CTL_WIDGET_MUTE_BEEP; |
3247 | |||
3248 | if (spec->anabeep_nid == nid) | ||
3249 | type = STAC_CTL_WIDGET_MUTE; | ||
3220 | 3250 | ||
3221 | /* check for mute support for the the amp */ | 3251 | /* check for mute support for the the amp */ |
3222 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { | 3252 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
3223 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, | 3253 | err = stac92xx_add_control(spec, type, |
3224 | "PC Beep Playback Switch", | 3254 | "Beep Playback Switch", |
3225 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | 3255 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
3226 | if (err < 0) | 3256 | if (err < 0) |
3227 | return err; | 3257 | return err; |
@@ -3230,7 +3260,7 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | |||
3230 | /* check to see if there is volume support for the amp */ | 3260 | /* check to see if there is volume support for the amp */ |
3231 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { | 3261 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
3232 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, | 3262 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
3233 | "PC Beep Playback Volume", | 3263 | "Beep Playback Volume", |
3234 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | 3264 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
3235 | if (err < 0) | 3265 | if (err < 0) |
3236 | return err; | 3266 | return err; |
@@ -3253,12 +3283,7 @@ static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, | |||
3253 | struct snd_ctl_elem_value *ucontrol) | 3283 | struct snd_ctl_elem_value *ucontrol) |
3254 | { | 3284 | { |
3255 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 3285 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
3256 | int enabled = !!ucontrol->value.integer.value[0]; | 3286 | return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]); |
3257 | if (codec->beep->enabled != enabled) { | ||
3258 | codec->beep->enabled = enabled; | ||
3259 | return 1; | ||
3260 | } | ||
3261 | return 0; | ||
3262 | } | 3287 | } |
3263 | 3288 | ||
3264 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { | 3289 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
@@ -3271,7 +3296,7 @@ static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { | |||
3271 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) | 3296 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
3272 | { | 3297 | { |
3273 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, | 3298 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
3274 | 0, "PC Beep Playback Switch", 0); | 3299 | 0, "Beep Playback Switch", 0); |
3275 | } | 3300 | } |
3276 | #endif | 3301 | #endif |
3277 | 3302 | ||
@@ -3626,6 +3651,26 @@ static void stac92xx_auto_init_hp_out(struct hda_codec *codec) | |||
3626 | } | 3651 | } |
3627 | } | 3652 | } |
3628 | 3653 | ||
3654 | static int is_dual_headphones(struct hda_codec *codec) | ||
3655 | { | ||
3656 | struct sigmatel_spec *spec = codec->spec; | ||
3657 | int i, valid_hps; | ||
3658 | |||
3659 | if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT || | ||
3660 | spec->autocfg.hp_outs <= 1) | ||
3661 | return 0; | ||
3662 | valid_hps = 0; | ||
3663 | for (i = 0; i < spec->autocfg.hp_outs; i++) { | ||
3664 | hda_nid_t nid = spec->autocfg.hp_pins[i]; | ||
3665 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid); | ||
3666 | if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE) | ||
3667 | continue; | ||
3668 | valid_hps++; | ||
3669 | } | ||
3670 | return (valid_hps > 1); | ||
3671 | } | ||
3672 | |||
3673 | |||
3629 | static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) | 3674 | static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) |
3630 | { | 3675 | { |
3631 | struct sigmatel_spec *spec = codec->spec; | 3676 | struct sigmatel_spec *spec = codec->spec; |
@@ -3642,8 +3687,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3642 | /* If we have no real line-out pin and multiple hp-outs, HPs should | 3687 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
3643 | * be set up as multi-channel outputs. | 3688 | * be set up as multi-channel outputs. |
3644 | */ | 3689 | */ |
3645 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && | 3690 | if (is_dual_headphones(codec)) { |
3646 | spec->autocfg.hp_outs > 1) { | ||
3647 | /* Copy hp_outs to line_outs, backup line_outs in | 3691 | /* Copy hp_outs to line_outs, backup line_outs in |
3648 | * speaker_outs so that the following routines can handle | 3692 | * speaker_outs so that the following routines can handle |
3649 | * HP pins as primary outputs. | 3693 | * HP pins as primary outputs. |
@@ -3738,15 +3782,16 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3738 | err = snd_hda_attach_beep_device(codec, nid); | 3782 | err = snd_hda_attach_beep_device(codec, nid); |
3739 | if (err < 0) | 3783 | if (err < 0) |
3740 | return err; | 3784 | return err; |
3741 | /* IDT/STAC codecs have linear beep tone parameter */ | 3785 | if (codec->beep) { |
3742 | codec->beep->linear_tone = 1; | 3786 | /* IDT/STAC codecs have linear beep tone parameter */ |
3743 | /* if no beep switch is available, make its own one */ | 3787 | codec->beep->linear_tone = 1; |
3744 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 3788 | /* if no beep switch is available, make its own one */ |
3745 | if (codec->beep && | 3789 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
3746 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { | 3790 | if (!(caps & AC_AMPCAP_MUTE)) { |
3747 | err = stac92xx_beep_switch_ctl(codec); | 3791 | err = stac92xx_beep_switch_ctl(codec); |
3748 | if (err < 0) | 3792 | if (err < 0) |
3749 | return err; | 3793 | return err; |
3794 | } | ||
3750 | } | 3795 | } |
3751 | } | 3796 | } |
3752 | #endif | 3797 | #endif |
@@ -4324,6 +4369,28 @@ static void stac92xx_free_kctls(struct hda_codec *codec) | |||
4324 | snd_array_free(&spec->kctls); | 4369 | snd_array_free(&spec->kctls); |
4325 | } | 4370 | } |
4326 | 4371 | ||
4372 | static void stac92xx_shutup(struct hda_codec *codec) | ||
4373 | { | ||
4374 | struct sigmatel_spec *spec = codec->spec; | ||
4375 | int i; | ||
4376 | hda_nid_t nid; | ||
4377 | |||
4378 | /* reset each pin before powering down DAC/ADC to avoid click noise */ | ||
4379 | nid = codec->start_nid; | ||
4380 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
4381 | unsigned int wcaps = get_wcaps(codec, nid); | ||
4382 | unsigned int wid_type = get_wcaps_type(wcaps); | ||
4383 | if (wid_type == AC_WID_PIN) | ||
4384 | snd_hda_codec_read(codec, nid, 0, | ||
4385 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
4386 | } | ||
4387 | |||
4388 | if (spec->eapd_mask) | ||
4389 | stac_gpio_set(codec, spec->gpio_mask, | ||
4390 | spec->gpio_dir, spec->gpio_data & | ||
4391 | ~spec->eapd_mask); | ||
4392 | } | ||
4393 | |||
4327 | static void stac92xx_free(struct hda_codec *codec) | 4394 | static void stac92xx_free(struct hda_codec *codec) |
4328 | { | 4395 | { |
4329 | struct sigmatel_spec *spec = codec->spec; | 4396 | struct sigmatel_spec *spec = codec->spec; |
@@ -4331,6 +4398,7 @@ static void stac92xx_free(struct hda_codec *codec) | |||
4331 | if (! spec) | 4398 | if (! spec) |
4332 | return; | 4399 | return; |
4333 | 4400 | ||
4401 | stac92xx_shutup(codec); | ||
4334 | stac92xx_free_jacks(codec); | 4402 | stac92xx_free_jacks(codec); |
4335 | snd_array_free(&spec->events); | 4403 | snd_array_free(&spec->events); |
4336 | 4404 | ||
@@ -4381,12 +4449,16 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4381 | pin_ctl & ~flag); | 4449 | pin_ctl & ~flag); |
4382 | } | 4450 | } |
4383 | 4451 | ||
4384 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) | 4452 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
4385 | { | 4453 | { |
4386 | if (!nid) | 4454 | if (!nid) |
4387 | return 0; | 4455 | return 0; |
4388 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) | 4456 | /* NOTE: we can't use snd_hda_jack_detect() here because STAC/IDT |
4389 | & (1 << 31)) | 4457 | * codecs behave wrongly when SET_PIN_SENSE is triggered, although |
4458 | * the pincap gives TRIG_REQ bit. | ||
4459 | */ | ||
4460 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0) & | ||
4461 | AC_PINSENSE_PRESENCE) | ||
4390 | return 1; | 4462 | return 1; |
4391 | return 0; | 4463 | return 0; |
4392 | } | 4464 | } |
@@ -4665,6 +4737,82 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4665 | } | 4737 | } |
4666 | } | 4738 | } |
4667 | 4739 | ||
4740 | /* | ||
4741 | * This method searches for the mute LED GPIO configuration | ||
4742 | * provided as OEM string in SMBIOS. The format of that string | ||
4743 | * is HP_Mute_LED_P_G or HP_Mute_LED_P | ||
4744 | * where P can be 0 or 1 and defines mute LED GPIO control state (low/high) | ||
4745 | * that corresponds to the NOT muted state of the master volume | ||
4746 | * and G is the index of the GPIO to use as the mute LED control (0..9) | ||
4747 | * If _G portion is missing it is assigned based on the codec ID | ||
4748 | * | ||
4749 | * So, HP B-series like systems may have HP_Mute_LED_0 (current models) | ||
4750 | * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings | ||
4751 | */ | ||
4752 | static int find_mute_led_gpio(struct hda_codec *codec) | ||
4753 | { | ||
4754 | struct sigmatel_spec *spec = codec->spec; | ||
4755 | const struct dmi_device *dev = NULL; | ||
4756 | |||
4757 | if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) { | ||
4758 | while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, | ||
4759 | NULL, dev))) { | ||
4760 | if (sscanf(dev->name, "HP_Mute_LED_%d_%d", | ||
4761 | &spec->gpio_led_polarity, | ||
4762 | &spec->gpio_led) == 2) { | ||
4763 | spec->gpio_led = 1 << spec->gpio_led; | ||
4764 | return 1; | ||
4765 | } | ||
4766 | if (sscanf(dev->name, "HP_Mute_LED_%d", | ||
4767 | &spec->gpio_led_polarity) == 1) { | ||
4768 | switch (codec->vendor_id) { | ||
4769 | case 0x111d7608: | ||
4770 | /* GPIO 0 */ | ||
4771 | spec->gpio_led = 0x01; | ||
4772 | return 1; | ||
4773 | case 0x111d7600: | ||
4774 | case 0x111d7601: | ||
4775 | case 0x111d7602: | ||
4776 | case 0x111d7603: | ||
4777 | /* GPIO 3 */ | ||
4778 | spec->gpio_led = 0x08; | ||
4779 | return 1; | ||
4780 | } | ||
4781 | } | ||
4782 | } | ||
4783 | } | ||
4784 | return 0; | ||
4785 | } | ||
4786 | |||
4787 | static int hp_blike_system(u32 subsystem_id) | ||
4788 | { | ||
4789 | switch (subsystem_id) { | ||
4790 | case 0x103c1520: | ||
4791 | case 0x103c1521: | ||
4792 | case 0x103c1523: | ||
4793 | case 0x103c1524: | ||
4794 | case 0x103c1525: | ||
4795 | case 0x103c1722: | ||
4796 | case 0x103c1723: | ||
4797 | case 0x103c1724: | ||
4798 | case 0x103c1725: | ||
4799 | case 0x103c1726: | ||
4800 | case 0x103c1727: | ||
4801 | case 0x103c1728: | ||
4802 | case 0x103c1729: | ||
4803 | case 0x103c172a: | ||
4804 | case 0x103c172b: | ||
4805 | case 0x103c307e: | ||
4806 | case 0x103c307f: | ||
4807 | case 0x103c3080: | ||
4808 | case 0x103c3081: | ||
4809 | case 0x103c7007: | ||
4810 | case 0x103c7008: | ||
4811 | return 1; | ||
4812 | } | ||
4813 | return 0; | ||
4814 | } | ||
4815 | |||
4668 | #ifdef CONFIG_PROC_FS | 4816 | #ifdef CONFIG_PROC_FS |
4669 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, | 4817 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
4670 | struct hda_codec *codec, hda_nid_t nid) | 4818 | struct hda_codec *codec, hda_nid_t nid) |
@@ -4754,6 +4902,11 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec, | |||
4754 | else | 4902 | else |
4755 | spec->gpio_data |= spec->gpio_led; /* white */ | 4903 | spec->gpio_data |= spec->gpio_led; /* white */ |
4756 | 4904 | ||
4905 | if (!spec->gpio_led_polarity) { | ||
4906 | /* LED state is inverted on these systems */ | ||
4907 | spec->gpio_data ^= spec->gpio_led; | ||
4908 | } | ||
4909 | |||
4757 | stac_gpio_set(codec, spec->gpio_mask, | 4910 | stac_gpio_set(codec, spec->gpio_mask, |
4758 | spec->gpio_dir, | 4911 | spec->gpio_dir, |
4759 | spec->gpio_data); | 4912 | spec->gpio_data); |
@@ -4761,28 +4914,28 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec, | |||
4761 | 4914 | ||
4762 | return 0; | 4915 | return 0; |
4763 | } | 4916 | } |
4764 | #endif | ||
4765 | 4917 | ||
4766 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | 4918 | static int idt92hd83xxx_hp_check_power_status(struct hda_codec *codec, |
4919 | hda_nid_t nid) | ||
4767 | { | 4920 | { |
4768 | struct sigmatel_spec *spec = codec->spec; | 4921 | struct sigmatel_spec *spec = codec->spec; |
4769 | int i; | ||
4770 | hda_nid_t nid; | ||
4771 | 4922 | ||
4772 | /* reset each pin before powering down DAC/ADC to avoid click noise */ | 4923 | if (nid != 0x13) |
4773 | nid = codec->start_nid; | 4924 | return 0; |
4774 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 4925 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & HDA_AMP_MUTE) |
4775 | unsigned int wcaps = get_wcaps(codec, nid); | 4926 | spec->gpio_data |= spec->gpio_led; /* mute LED on */ |
4776 | unsigned int wid_type = get_wcaps_type(wcaps); | 4927 | else |
4777 | if (wid_type == AC_WID_PIN) | 4928 | spec->gpio_data &= ~spec->gpio_led; /* mute LED off */ |
4778 | snd_hda_codec_read(codec, nid, 0, | 4929 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); |
4779 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
4780 | } | ||
4781 | 4930 | ||
4782 | if (spec->eapd_mask) | 4931 | return 0; |
4783 | stac_gpio_set(codec, spec->gpio_mask, | 4932 | } |
4784 | spec->gpio_dir, spec->gpio_data & | 4933 | |
4785 | ~spec->eapd_mask); | 4934 | #endif |
4935 | |||
4936 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | ||
4937 | { | ||
4938 | stac92xx_shutup(codec); | ||
4786 | return 0; | 4939 | return 0; |
4787 | } | 4940 | } |
4788 | #endif | 4941 | #endif |
@@ -4797,6 +4950,7 @@ static struct hda_codec_ops stac92xx_patch_ops = { | |||
4797 | .suspend = stac92xx_suspend, | 4950 | .suspend = stac92xx_suspend, |
4798 | .resume = stac92xx_resume, | 4951 | .resume = stac92xx_resume, |
4799 | #endif | 4952 | #endif |
4953 | .reboot_notify = stac92xx_shutup, | ||
4800 | }; | 4954 | }; |
4801 | 4955 | ||
4802 | static int patch_stac9200(struct hda_codec *codec) | 4956 | static int patch_stac9200(struct hda_codec *codec) |
@@ -5142,6 +5296,22 @@ again: | |||
5142 | break; | 5296 | break; |
5143 | } | 5297 | } |
5144 | 5298 | ||
5299 | codec->patch_ops = stac92xx_patch_ops; | ||
5300 | |||
5301 | if (spec->board_config == STAC_92HD83XXX_HP) | ||
5302 | spec->gpio_led = 0x01; | ||
5303 | |||
5304 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5305 | if (spec->gpio_led) { | ||
5306 | spec->gpio_mask |= spec->gpio_led; | ||
5307 | spec->gpio_dir |= spec->gpio_led; | ||
5308 | spec->gpio_data |= spec->gpio_led; | ||
5309 | /* register check_power_status callback. */ | ||
5310 | codec->patch_ops.check_power_status = | ||
5311 | idt92hd83xxx_hp_check_power_status; | ||
5312 | } | ||
5313 | #endif | ||
5314 | |||
5145 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); | 5315 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
5146 | if (!err) { | 5316 | if (!err) { |
5147 | if (spec->board_config < 0) { | 5317 | if (spec->board_config < 0) { |
@@ -5177,8 +5347,6 @@ again: | |||
5177 | snd_hda_codec_write_cache(codec, nid, 0, | 5347 | snd_hda_codec_write_cache(codec, nid, 0, |
5178 | AC_VERB_SET_CONNECT_SEL, num_dacs); | 5348 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
5179 | 5349 | ||
5180 | codec->patch_ops = stac92xx_patch_ops; | ||
5181 | |||
5182 | codec->proc_widget_hook = stac92hd_proc_hook; | 5350 | codec->proc_widget_hook = stac92hd_proc_hook; |
5183 | 5351 | ||
5184 | return 0; | 5352 | return 0; |
@@ -5243,6 +5411,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5243 | { | 5411 | { |
5244 | struct sigmatel_spec *spec; | 5412 | struct sigmatel_spec *spec; |
5245 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; | 5413 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
5414 | unsigned int pin_cfg; | ||
5246 | int err = 0; | 5415 | int err = 0; |
5247 | 5416 | ||
5248 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5417 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
@@ -5426,6 +5595,29 @@ again: | |||
5426 | break; | 5595 | break; |
5427 | } | 5596 | } |
5428 | 5597 | ||
5598 | if (hp_blike_system(codec->subsystem_id)) { | ||
5599 | pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f); | ||
5600 | if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT || | ||
5601 | get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER || | ||
5602 | get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) { | ||
5603 | /* It was changed in the BIOS to just satisfy MS DTM. | ||
5604 | * Lets turn it back into slaved HP | ||
5605 | */ | ||
5606 | pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) | ||
5607 | | (AC_JACK_HP_OUT << | ||
5608 | AC_DEFCFG_DEVICE_SHIFT); | ||
5609 | pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC | ||
5610 | | AC_DEFCFG_SEQUENCE))) | ||
5611 | | 0x1f; | ||
5612 | snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg); | ||
5613 | } | ||
5614 | } | ||
5615 | |||
5616 | if (find_mute_led_gpio(codec)) | ||
5617 | snd_printd("mute LED gpio %d polarity %d\n", | ||
5618 | spec->gpio_led, | ||
5619 | spec->gpio_led_polarity); | ||
5620 | |||
5429 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 5621 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5430 | if (spec->gpio_led) { | 5622 | if (spec->gpio_led) { |
5431 | spec->gpio_mask |= spec->gpio_led; | 5623 | spec->gpio_mask |= spec->gpio_led; |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index ee89db90c9b6..b70e26ad263f 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | 2 | * Universal Interface for Intel High Definition Audio Codec |
3 | * | 3 | * |
4 | * HD audio interface patch for VIA VT1702/VT1708/VT1709 codec | 4 | * HD audio interface patch for VIA VT17xx/VT18xx/VT20xx codec |
5 | * | 5 | * |
6 | * Copyright (c) 2006-2008 Lydia Wang <lydiawang@viatech.com> | 6 | * (C) 2006-2009 VIA Technology, Inc. |
7 | * Takashi Iwai <tiwai@suse.de> | 7 | * (C) 2006-2008 Takashi Iwai <tiwai@suse.de> |
8 | * | 8 | * |
9 | * This driver is free software; you can redistribute it and/or modify | 9 | * This driver is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -22,21 +22,27 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */ | 24 | /* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */ |
25 | /* */ | 25 | /* */ |
26 | /* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */ | 26 | /* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */ |
27 | /* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */ | 27 | /* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */ |
28 | /* 2006-08-02 Lydia Wang Add support to VT1709 codec */ | 28 | /* 2006-08-02 Lydia Wang Add support to VT1709 codec */ |
29 | /* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */ | 29 | /* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */ |
30 | /* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */ | 30 | /* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */ |
31 | /* 2007-09-17 Lydia Wang Add VT1708B codec support */ | 31 | /* 2007-09-17 Lydia Wang Add VT1708B codec support */ |
32 | /* 2007-11-14 Lydia Wang Add VT1708A codec HP and CD pin connect config */ | 32 | /* 2007-11-14 Lydia Wang Add VT1708A codec HP and CD pin connect config */ |
33 | /* 2008-02-03 Lydia Wang Fix Rear channels and Back channels inverse issue */ | 33 | /* 2008-02-03 Lydia Wang Fix Rear channels and Back channels inverse issue */ |
34 | /* 2008-03-06 Lydia Wang Add VT1702 codec and VT1708S codec support */ | 34 | /* 2008-03-06 Lydia Wang Add VT1702 codec and VT1708S codec support */ |
35 | /* 2008-04-09 Lydia Wang Add mute front speaker when HP plugin */ | 35 | /* 2008-04-09 Lydia Wang Add mute front speaker when HP plugin */ |
36 | /* 2008-04-09 Lydia Wang Add Independent HP feature */ | 36 | /* 2008-04-09 Lydia Wang Add Independent HP feature */ |
37 | /* 2008-05-28 Lydia Wang Add second S/PDIF Out support for VT1702 */ | 37 | /* 2008-05-28 Lydia Wang Add second S/PDIF Out support for VT1702 */ |
38 | /* 2008-09-15 Logan Li Add VT1708S Mic Boost workaround/backdoor */ | 38 | /* 2008-09-15 Logan Li Add VT1708S Mic Boost workaround/backdoor */ |
39 | /* */ | 39 | /* 2009-02-16 Logan Li Add support for VT1718S */ |
40 | /* 2009-03-13 Logan Li Add support for VT1716S */ | ||
41 | /* 2009-04-14 Lydai Wang Add support for VT1828S and VT2020 */ | ||
42 | /* 2009-07-08 Lydia Wang Add support for VT2002P */ | ||
43 | /* 2009-07-21 Lydia Wang Add support for VT1812 */ | ||
44 | /* 2009-09-19 Lydia Wang Add support for VT1818S */ | ||
45 | /* */ | ||
40 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 46 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
41 | 47 | ||
42 | 48 | ||
@@ -76,14 +82,6 @@ | |||
76 | #define VT1702_HP_NID 0x17 | 82 | #define VT1702_HP_NID 0x17 |
77 | #define VT1702_DIGOUT_NID 0x11 | 83 | #define VT1702_DIGOUT_NID 0x11 |
78 | 84 | ||
79 | #define IS_VT1708_VENDORID(x) ((x) >= 0x11061708 && (x) <= 0x1106170b) | ||
80 | #define IS_VT1709_10CH_VENDORID(x) ((x) >= 0x1106e710 && (x) <= 0x1106e713) | ||
81 | #define IS_VT1709_6CH_VENDORID(x) ((x) >= 0x1106e714 && (x) <= 0x1106e717) | ||
82 | #define IS_VT1708B_8CH_VENDORID(x) ((x) >= 0x1106e720 && (x) <= 0x1106e723) | ||
83 | #define IS_VT1708B_4CH_VENDORID(x) ((x) >= 0x1106e724 && (x) <= 0x1106e727) | ||
84 | #define IS_VT1708S_VENDORID(x) ((x) >= 0x11060397 && (x) <= 0x11067397) | ||
85 | #define IS_VT1702_VENDORID(x) ((x) >= 0x11060398 && (x) <= 0x11067398) | ||
86 | |||
87 | enum VIA_HDA_CODEC { | 85 | enum VIA_HDA_CODEC { |
88 | UNKNOWN = -1, | 86 | UNKNOWN = -1, |
89 | VT1708, | 87 | VT1708, |
@@ -92,12 +90,76 @@ enum VIA_HDA_CODEC { | |||
92 | VT1708B_8CH, | 90 | VT1708B_8CH, |
93 | VT1708B_4CH, | 91 | VT1708B_4CH, |
94 | VT1708S, | 92 | VT1708S, |
93 | VT1708BCE, | ||
95 | VT1702, | 94 | VT1702, |
95 | VT1718S, | ||
96 | VT1716S, | ||
97 | VT2002P, | ||
98 | VT1812, | ||
96 | CODEC_TYPES, | 99 | CODEC_TYPES, |
97 | }; | 100 | }; |
98 | 101 | ||
99 | static enum VIA_HDA_CODEC get_codec_type(u32 vendor_id) | 102 | struct via_spec { |
103 | /* codec parameterization */ | ||
104 | struct snd_kcontrol_new *mixers[6]; | ||
105 | unsigned int num_mixers; | ||
106 | |||
107 | struct hda_verb *init_verbs[5]; | ||
108 | unsigned int num_iverbs; | ||
109 | |||
110 | char *stream_name_analog; | ||
111 | struct hda_pcm_stream *stream_analog_playback; | ||
112 | struct hda_pcm_stream *stream_analog_capture; | ||
113 | |||
114 | char *stream_name_digital; | ||
115 | struct hda_pcm_stream *stream_digital_playback; | ||
116 | struct hda_pcm_stream *stream_digital_capture; | ||
117 | |||
118 | /* playback */ | ||
119 | struct hda_multi_out multiout; | ||
120 | hda_nid_t slave_dig_outs[2]; | ||
121 | |||
122 | /* capture */ | ||
123 | unsigned int num_adc_nids; | ||
124 | hda_nid_t *adc_nids; | ||
125 | hda_nid_t mux_nids[3]; | ||
126 | hda_nid_t dig_in_nid; | ||
127 | hda_nid_t dig_in_pin; | ||
128 | |||
129 | /* capture source */ | ||
130 | const struct hda_input_mux *input_mux; | ||
131 | unsigned int cur_mux[3]; | ||
132 | |||
133 | /* PCM information */ | ||
134 | struct hda_pcm pcm_rec[3]; | ||
135 | |||
136 | /* dynamic controls, init_verbs and input_mux */ | ||
137 | struct auto_pin_cfg autocfg; | ||
138 | struct snd_array kctls; | ||
139 | struct hda_input_mux private_imux[2]; | ||
140 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | ||
141 | |||
142 | /* HP mode source */ | ||
143 | const struct hda_input_mux *hp_mux; | ||
144 | unsigned int hp_independent_mode; | ||
145 | unsigned int hp_independent_mode_index; | ||
146 | unsigned int smart51_enabled; | ||
147 | unsigned int dmic_enabled; | ||
148 | enum VIA_HDA_CODEC codec_type; | ||
149 | |||
150 | /* work to check hp jack state */ | ||
151 | struct hda_codec *codec; | ||
152 | struct delayed_work vt1708_hp_work; | ||
153 | int vt1708_jack_detectect; | ||
154 | int vt1708_hp_present; | ||
155 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
156 | struct hda_loopback_check loopback; | ||
157 | #endif | ||
158 | }; | ||
159 | |||
160 | static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) | ||
100 | { | 161 | { |
162 | u32 vendor_id = codec->vendor_id; | ||
101 | u16 ven_id = vendor_id >> 16; | 163 | u16 ven_id = vendor_id >> 16; |
102 | u16 dev_id = vendor_id & 0xffff; | 164 | u16 dev_id = vendor_id & 0xffff; |
103 | enum VIA_HDA_CODEC codec_type; | 165 | enum VIA_HDA_CODEC codec_type; |
@@ -111,9 +173,11 @@ static enum VIA_HDA_CODEC get_codec_type(u32 vendor_id) | |||
111 | codec_type = VT1709_10CH; | 173 | codec_type = VT1709_10CH; |
112 | else if (dev_id >= 0xe714 && dev_id <= 0xe717) | 174 | else if (dev_id >= 0xe714 && dev_id <= 0xe717) |
113 | codec_type = VT1709_6CH; | 175 | codec_type = VT1709_6CH; |
114 | else if (dev_id >= 0xe720 && dev_id <= 0xe723) | 176 | else if (dev_id >= 0xe720 && dev_id <= 0xe723) { |
115 | codec_type = VT1708B_8CH; | 177 | codec_type = VT1708B_8CH; |
116 | else if (dev_id >= 0xe724 && dev_id <= 0xe727) | 178 | if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7) |
179 | codec_type = VT1708BCE; | ||
180 | } else if (dev_id >= 0xe724 && dev_id <= 0xe727) | ||
117 | codec_type = VT1708B_4CH; | 181 | codec_type = VT1708B_4CH; |
118 | else if ((dev_id & 0xfff) == 0x397 | 182 | else if ((dev_id & 0xfff) == 0x397 |
119 | && (dev_id >> 12) < 8) | 183 | && (dev_id >> 12) < 8) |
@@ -121,6 +185,19 @@ static enum VIA_HDA_CODEC get_codec_type(u32 vendor_id) | |||
121 | else if ((dev_id & 0xfff) == 0x398 | 185 | else if ((dev_id & 0xfff) == 0x398 |
122 | && (dev_id >> 12) < 8) | 186 | && (dev_id >> 12) < 8) |
123 | codec_type = VT1702; | 187 | codec_type = VT1702; |
188 | else if ((dev_id & 0xfff) == 0x428 | ||
189 | && (dev_id >> 12) < 8) | ||
190 | codec_type = VT1718S; | ||
191 | else if (dev_id == 0x0433 || dev_id == 0xa721) | ||
192 | codec_type = VT1716S; | ||
193 | else if (dev_id == 0x0441 || dev_id == 0x4441) | ||
194 | codec_type = VT1718S; | ||
195 | else if (dev_id == 0x0438 || dev_id == 0x4438) | ||
196 | codec_type = VT2002P; | ||
197 | else if (dev_id == 0x0448) | ||
198 | codec_type = VT1812; | ||
199 | else if (dev_id == 0x0440) | ||
200 | codec_type = VT1708S; | ||
124 | else | 201 | else |
125 | codec_type = UNKNOWN; | 202 | codec_type = UNKNOWN; |
126 | return codec_type; | 203 | return codec_type; |
@@ -128,10 +205,16 @@ static enum VIA_HDA_CODEC get_codec_type(u32 vendor_id) | |||
128 | 205 | ||
129 | #define VIA_HP_EVENT 0x01 | 206 | #define VIA_HP_EVENT 0x01 |
130 | #define VIA_GPIO_EVENT 0x02 | 207 | #define VIA_GPIO_EVENT 0x02 |
208 | #define VIA_JACK_EVENT 0x04 | ||
209 | #define VIA_MONO_EVENT 0x08 | ||
210 | #define VIA_SPEAKER_EVENT 0x10 | ||
211 | #define VIA_BIND_HP_EVENT 0x20 | ||
131 | 212 | ||
132 | enum { | 213 | enum { |
133 | VIA_CTL_WIDGET_VOL, | 214 | VIA_CTL_WIDGET_VOL, |
134 | VIA_CTL_WIDGET_MUTE, | 215 | VIA_CTL_WIDGET_MUTE, |
216 | VIA_CTL_WIDGET_ANALOG_MUTE, | ||
217 | VIA_CTL_WIDGET_BIND_PIN_MUTE, | ||
135 | }; | 218 | }; |
136 | 219 | ||
137 | enum { | 220 | enum { |
@@ -141,99 +224,162 @@ enum { | |||
141 | AUTO_SEQ_SIDE | 224 | AUTO_SEQ_SIDE |
142 | }; | 225 | }; |
143 | 226 | ||
144 | /* Some VT1708S based boards gets the micboost setting wrong, so we have | 227 | static void analog_low_current_mode(struct hda_codec *codec, int stream_idle); |
145 | * to apply some brute-force and re-write the TLV's by software. */ | 228 | static void set_jack_power_state(struct hda_codec *codec); |
146 | static int mic_boost_tlv(struct snd_kcontrol *kcontrol, int op_flag, | 229 | static int is_aa_path_mute(struct hda_codec *codec); |
147 | unsigned int size, unsigned int __user *_tlv) | 230 | |
231 | static void vt1708_start_hp_work(struct via_spec *spec) | ||
148 | { | 232 | { |
149 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 233 | if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) |
150 | hda_nid_t nid = get_amp_nid(kcontrol); | 234 | return; |
235 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, | ||
236 | !spec->vt1708_jack_detectect); | ||
237 | if (!delayed_work_pending(&spec->vt1708_hp_work)) | ||
238 | schedule_delayed_work(&spec->vt1708_hp_work, | ||
239 | msecs_to_jiffies(100)); | ||
240 | } | ||
151 | 241 | ||
152 | if (get_codec_type(codec->vendor_id) == VT1708S | 242 | static void vt1708_stop_hp_work(struct via_spec *spec) |
153 | && (nid == 0x1a || nid == 0x1e)) { | 243 | { |
154 | if (size < 4 * sizeof(unsigned int)) | 244 | if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) |
155 | return -ENOMEM; | 245 | return; |
156 | if (put_user(1, _tlv)) /* SNDRV_CTL_TLVT_DB_SCALE */ | 246 | if (snd_hda_get_bool_hint(spec->codec, "analog_loopback_hp_detect") == 1 |
157 | return -EFAULT; | 247 | && !is_aa_path_mute(spec->codec)) |
158 | if (put_user(2 * sizeof(unsigned int), _tlv + 1)) | 248 | return; |
159 | return -EFAULT; | 249 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, |
160 | if (put_user(0, _tlv + 2)) /* offset = 0 */ | 250 | !spec->vt1708_jack_detectect); |
161 | return -EFAULT; | 251 | cancel_delayed_work(&spec->vt1708_hp_work); |
162 | if (put_user(1000, _tlv + 3)) /* step size = 10 dB */ | 252 | flush_scheduled_work(); |
163 | return -EFAULT; | ||
164 | } | ||
165 | return 0; | ||
166 | } | 253 | } |
167 | 254 | ||
168 | static int mic_boost_volume_info(struct snd_kcontrol *kcontrol, | 255 | |
169 | struct snd_ctl_elem_info *uinfo) | 256 | static int analog_input_switch_put(struct snd_kcontrol *kcontrol, |
257 | struct snd_ctl_elem_value *ucontrol) | ||
170 | { | 258 | { |
259 | int change = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); | ||
171 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 260 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
172 | hda_nid_t nid = get_amp_nid(kcontrol); | ||
173 | 261 | ||
174 | if (get_codec_type(codec->vendor_id) == VT1708S | 262 | set_jack_power_state(codec); |
175 | && (nid == 0x1a || nid == 0x1e)) { | 263 | analog_low_current_mode(snd_kcontrol_chip(kcontrol), -1); |
176 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 264 | if (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1) { |
177 | uinfo->count = 2; | 265 | if (is_aa_path_mute(codec)) |
178 | uinfo->value.integer.min = 0; | 266 | vt1708_start_hp_work(codec->spec); |
179 | uinfo->value.integer.max = 3; | 267 | else |
268 | vt1708_stop_hp_work(codec->spec); | ||
180 | } | 269 | } |
181 | return 0; | 270 | return change; |
182 | } | 271 | } |
183 | 272 | ||
184 | static struct snd_kcontrol_new vt1708_control_templates[] = { | 273 | /* modify .put = snd_hda_mixer_amp_switch_put */ |
185 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), | 274 | #define ANALOG_INPUT_MUTE \ |
186 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | 275 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
187 | }; | 276 | .name = NULL, \ |
188 | 277 | .index = 0, \ | |
189 | 278 | .info = snd_hda_mixer_amp_switch_info, \ | |
190 | struct via_spec { | 279 | .get = snd_hda_mixer_amp_switch_get, \ |
191 | /* codec parameterization */ | 280 | .put = analog_input_switch_put, \ |
192 | struct snd_kcontrol_new *mixers[3]; | 281 | .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } |
193 | unsigned int num_mixers; | ||
194 | 282 | ||
195 | struct hda_verb *init_verbs[5]; | 283 | static void via_hp_bind_automute(struct hda_codec *codec); |
196 | unsigned int num_iverbs; | ||
197 | 284 | ||
198 | char *stream_name_analog; | 285 | static int bind_pin_switch_put(struct snd_kcontrol *kcontrol, |
199 | struct hda_pcm_stream *stream_analog_playback; | 286 | struct snd_ctl_elem_value *ucontrol) |
200 | struct hda_pcm_stream *stream_analog_capture; | 287 | { |
201 | 288 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
202 | char *stream_name_digital; | 289 | struct via_spec *spec = codec->spec; |
203 | struct hda_pcm_stream *stream_digital_playback; | 290 | int i; |
204 | struct hda_pcm_stream *stream_digital_capture; | 291 | int change = 0; |
205 | |||
206 | /* playback */ | ||
207 | struct hda_multi_out multiout; | ||
208 | hda_nid_t slave_dig_outs[2]; | ||
209 | |||
210 | /* capture */ | ||
211 | unsigned int num_adc_nids; | ||
212 | hda_nid_t *adc_nids; | ||
213 | hda_nid_t mux_nids[3]; | ||
214 | hda_nid_t dig_in_nid; | ||
215 | hda_nid_t dig_in_pin; | ||
216 | 292 | ||
217 | /* capture source */ | 293 | long *valp = ucontrol->value.integer.value; |
218 | const struct hda_input_mux *input_mux; | 294 | int lmute, rmute; |
219 | unsigned int cur_mux[3]; | 295 | if (strstr(kcontrol->id.name, "Switch") == NULL) { |
296 | snd_printd("Invalid control!\n"); | ||
297 | return change; | ||
298 | } | ||
299 | change = snd_hda_mixer_amp_switch_put(kcontrol, | ||
300 | ucontrol); | ||
301 | /* Get mute value */ | ||
302 | lmute = *valp ? 0 : HDA_AMP_MUTE; | ||
303 | valp++; | ||
304 | rmute = *valp ? 0 : HDA_AMP_MUTE; | ||
305 | |||
306 | /* Set hp pins */ | ||
307 | if (!spec->hp_independent_mode) { | ||
308 | for (i = 0; i < spec->autocfg.hp_outs; i++) { | ||
309 | snd_hda_codec_amp_update( | ||
310 | codec, spec->autocfg.hp_pins[i], | ||
311 | 0, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
312 | lmute); | ||
313 | snd_hda_codec_amp_update( | ||
314 | codec, spec->autocfg.hp_pins[i], | ||
315 | 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
316 | rmute); | ||
317 | } | ||
318 | } | ||
220 | 319 | ||
221 | /* PCM information */ | 320 | if (!lmute && !rmute) { |
222 | struct hda_pcm pcm_rec[3]; | 321 | /* Line Outs */ |
322 | for (i = 0; i < spec->autocfg.line_outs; i++) | ||
323 | snd_hda_codec_amp_stereo( | ||
324 | codec, spec->autocfg.line_out_pins[i], | ||
325 | HDA_OUTPUT, 0, HDA_AMP_MUTE, 0); | ||
326 | /* Speakers */ | ||
327 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | ||
328 | snd_hda_codec_amp_stereo( | ||
329 | codec, spec->autocfg.speaker_pins[i], | ||
330 | HDA_OUTPUT, 0, HDA_AMP_MUTE, 0); | ||
331 | /* unmute */ | ||
332 | via_hp_bind_automute(codec); | ||
223 | 333 | ||
224 | /* dynamic controls, init_verbs and input_mux */ | 334 | } else { |
225 | struct auto_pin_cfg autocfg; | 335 | if (lmute) { |
226 | struct snd_array kctls; | 336 | /* Mute all left channels */ |
227 | struct hda_input_mux private_imux[2]; | 337 | for (i = 1; i < spec->autocfg.line_outs; i++) |
228 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 338 | snd_hda_codec_amp_update( |
339 | codec, | ||
340 | spec->autocfg.line_out_pins[i], | ||
341 | 0, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
342 | lmute); | ||
343 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | ||
344 | snd_hda_codec_amp_update( | ||
345 | codec, | ||
346 | spec->autocfg.speaker_pins[i], | ||
347 | 0, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
348 | lmute); | ||
349 | } | ||
350 | if (rmute) { | ||
351 | /* mute all right channels */ | ||
352 | for (i = 1; i < spec->autocfg.line_outs; i++) | ||
353 | snd_hda_codec_amp_update( | ||
354 | codec, | ||
355 | spec->autocfg.line_out_pins[i], | ||
356 | 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
357 | rmute); | ||
358 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | ||
359 | snd_hda_codec_amp_update( | ||
360 | codec, | ||
361 | spec->autocfg.speaker_pins[i], | ||
362 | 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
363 | rmute); | ||
364 | } | ||
365 | } | ||
366 | return change; | ||
367 | } | ||
229 | 368 | ||
230 | /* HP mode source */ | 369 | #define BIND_PIN_MUTE \ |
231 | const struct hda_input_mux *hp_mux; | 370 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
232 | unsigned int hp_independent_mode; | 371 | .name = NULL, \ |
372 | .index = 0, \ | ||
373 | .info = snd_hda_mixer_amp_switch_info, \ | ||
374 | .get = snd_hda_mixer_amp_switch_get, \ | ||
375 | .put = bind_pin_switch_put, \ | ||
376 | .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } | ||
233 | 377 | ||
234 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 378 | static struct snd_kcontrol_new via_control_templates[] = { |
235 | struct hda_loopback_check loopback; | 379 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
236 | #endif | 380 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
381 | ANALOG_INPUT_MUTE, | ||
382 | BIND_PIN_MUTE, | ||
237 | }; | 383 | }; |
238 | 384 | ||
239 | static hda_nid_t vt1708_adc_nids[2] = { | 385 | static hda_nid_t vt1708_adc_nids[2] = { |
@@ -261,6 +407,27 @@ static hda_nid_t vt1702_adc_nids[3] = { | |||
261 | 0x12, 0x20, 0x1F | 407 | 0x12, 0x20, 0x1F |
262 | }; | 408 | }; |
263 | 409 | ||
410 | static hda_nid_t vt1718S_adc_nids[2] = { | ||
411 | /* ADC1-2 */ | ||
412 | 0x10, 0x11 | ||
413 | }; | ||
414 | |||
415 | static hda_nid_t vt1716S_adc_nids[2] = { | ||
416 | /* ADC1-2 */ | ||
417 | 0x13, 0x14 | ||
418 | }; | ||
419 | |||
420 | static hda_nid_t vt2002P_adc_nids[2] = { | ||
421 | /* ADC1-2 */ | ||
422 | 0x10, 0x11 | ||
423 | }; | ||
424 | |||
425 | static hda_nid_t vt1812_adc_nids[2] = { | ||
426 | /* ADC1-2 */ | ||
427 | 0x10, 0x11 | ||
428 | }; | ||
429 | |||
430 | |||
264 | /* add dynamic controls */ | 431 | /* add dynamic controls */ |
265 | static int via_add_control(struct via_spec *spec, int type, const char *name, | 432 | static int via_add_control(struct via_spec *spec, int type, const char *name, |
266 | unsigned long val) | 433 | unsigned long val) |
@@ -271,10 +438,12 @@ static int via_add_control(struct via_spec *spec, int type, const char *name, | |||
271 | knew = snd_array_new(&spec->kctls); | 438 | knew = snd_array_new(&spec->kctls); |
272 | if (!knew) | 439 | if (!knew) |
273 | return -ENOMEM; | 440 | return -ENOMEM; |
274 | *knew = vt1708_control_templates[type]; | 441 | *knew = via_control_templates[type]; |
275 | knew->name = kstrdup(name, GFP_KERNEL); | 442 | knew->name = kstrdup(name, GFP_KERNEL); |
276 | if (!knew->name) | 443 | if (!knew->name) |
277 | return -ENOMEM; | 444 | return -ENOMEM; |
445 | if (get_amp_nid_(val)) | ||
446 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | ||
278 | knew->private_value = val; | 447 | knew->private_value = val; |
279 | return 0; | 448 | return 0; |
280 | } | 449 | } |
@@ -293,8 +462,8 @@ static void via_free_kctls(struct hda_codec *codec) | |||
293 | } | 462 | } |
294 | 463 | ||
295 | /* create input playback/capture controls for the given pin */ | 464 | /* create input playback/capture controls for the given pin */ |
296 | static int via_new_analog_input(struct via_spec *spec, hda_nid_t pin, | 465 | static int via_new_analog_input(struct via_spec *spec, const char *ctlname, |
297 | const char *ctlname, int idx, int mix_nid) | 466 | int idx, int mix_nid) |
298 | { | 467 | { |
299 | char name[32]; | 468 | char name[32]; |
300 | int err; | 469 | int err; |
@@ -305,7 +474,7 @@ static int via_new_analog_input(struct via_spec *spec, hda_nid_t pin, | |||
305 | if (err < 0) | 474 | if (err < 0) |
306 | return err; | 475 | return err; |
307 | sprintf(name, "%s Playback Switch", ctlname); | 476 | sprintf(name, "%s Playback Switch", ctlname); |
308 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, | 477 | err = via_add_control(spec, VIA_CTL_WIDGET_ANALOG_MUTE, name, |
309 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 478 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
310 | if (err < 0) | 479 | if (err < 0) |
311 | return err; | 480 | return err; |
@@ -322,7 +491,7 @@ static void via_auto_set_output_and_unmute(struct hda_codec *codec, | |||
322 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 491 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
323 | AMP_OUT_UNMUTE); | 492 | AMP_OUT_UNMUTE); |
324 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) | 493 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
325 | snd_hda_codec_write(codec, nid, 0, | 494 | snd_hda_codec_write(codec, nid, 0, |
326 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | 495 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); |
327 | } | 496 | } |
328 | 497 | ||
@@ -343,10 +512,13 @@ static void via_auto_init_hp_out(struct hda_codec *codec) | |||
343 | { | 512 | { |
344 | struct via_spec *spec = codec->spec; | 513 | struct via_spec *spec = codec->spec; |
345 | hda_nid_t pin; | 514 | hda_nid_t pin; |
515 | int i; | ||
346 | 516 | ||
347 | pin = spec->autocfg.hp_pins[0]; | 517 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
348 | if (pin) /* connect to front */ | 518 | pin = spec->autocfg.hp_pins[i]; |
349 | via_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | 519 | if (pin) /* connect to front */ |
520 | via_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | ||
521 | } | ||
350 | } | 522 | } |
351 | 523 | ||
352 | static void via_auto_init_analog_input(struct hda_codec *codec) | 524 | static void via_auto_init_analog_input(struct hda_codec *codec) |
@@ -364,6 +536,502 @@ static void via_auto_init_analog_input(struct hda_codec *codec) | |||
364 | 536 | ||
365 | } | 537 | } |
366 | } | 538 | } |
539 | |||
540 | static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin); | ||
541 | |||
542 | static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid, | ||
543 | unsigned int *affected_parm) | ||
544 | { | ||
545 | unsigned parm; | ||
546 | unsigned def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
547 | unsigned no_presence = (def_conf & AC_DEFCFG_MISC) | ||
548 | >> AC_DEFCFG_MISC_SHIFT | ||
549 | & AC_DEFCFG_MISC_NO_PRESENCE; /* do not support pin sense */ | ||
550 | unsigned present = snd_hda_jack_detect(codec, nid); | ||
551 | struct via_spec *spec = codec->spec; | ||
552 | if ((spec->smart51_enabled && is_smart51_pins(spec, nid)) | ||
553 | || ((no_presence || present) | ||
554 | && get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)) { | ||
555 | *affected_parm = AC_PWRST_D0; /* if it's connected */ | ||
556 | parm = AC_PWRST_D0; | ||
557 | } else | ||
558 | parm = AC_PWRST_D3; | ||
559 | |||
560 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, parm); | ||
561 | } | ||
562 | |||
563 | static void set_jack_power_state(struct hda_codec *codec) | ||
564 | { | ||
565 | struct via_spec *spec = codec->spec; | ||
566 | int imux_is_smixer; | ||
567 | unsigned int parm; | ||
568 | |||
569 | if (spec->codec_type == VT1702) { | ||
570 | imux_is_smixer = snd_hda_codec_read( | ||
571 | codec, 0x13, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 3; | ||
572 | /* inputs */ | ||
573 | /* PW 1/2/5 (14h/15h/18h) */ | ||
574 | parm = AC_PWRST_D3; | ||
575 | set_pin_power_state(codec, 0x14, &parm); | ||
576 | set_pin_power_state(codec, 0x15, &parm); | ||
577 | set_pin_power_state(codec, 0x18, &parm); | ||
578 | if (imux_is_smixer) | ||
579 | parm = AC_PWRST_D0; /* SW0 = stereo mixer (idx 3) */ | ||
580 | /* SW0 (13h), AIW 0/1/2 (12h/1fh/20h) */ | ||
581 | snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, | ||
582 | parm); | ||
583 | snd_hda_codec_write(codec, 0x12, 0, AC_VERB_SET_POWER_STATE, | ||
584 | parm); | ||
585 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, | ||
586 | parm); | ||
587 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_POWER_STATE, | ||
588 | parm); | ||
589 | |||
590 | /* outputs */ | ||
591 | /* PW 3/4 (16h/17h) */ | ||
592 | parm = AC_PWRST_D3; | ||
593 | set_pin_power_state(codec, 0x16, &parm); | ||
594 | set_pin_power_state(codec, 0x17, &parm); | ||
595 | /* MW0 (1ah), AOW 0/1 (10h/1dh) */ | ||
596 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_POWER_STATE, | ||
597 | imux_is_smixer ? AC_PWRST_D0 : parm); | ||
598 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, | ||
599 | parm); | ||
600 | snd_hda_codec_write(codec, 0x1d, 0, AC_VERB_SET_POWER_STATE, | ||
601 | parm); | ||
602 | } else if (spec->codec_type == VT1708B_8CH | ||
603 | || spec->codec_type == VT1708B_4CH | ||
604 | || spec->codec_type == VT1708S) { | ||
605 | /* SW0 (17h) = stereo mixer */ | ||
606 | int is_8ch = spec->codec_type != VT1708B_4CH; | ||
607 | imux_is_smixer = snd_hda_codec_read( | ||
608 | codec, 0x17, 0, AC_VERB_GET_CONNECT_SEL, 0x00) | ||
609 | == ((spec->codec_type == VT1708S) ? 5 : 0); | ||
610 | /* inputs */ | ||
611 | /* PW 1/2/5 (1ah/1bh/1eh) */ | ||
612 | parm = AC_PWRST_D3; | ||
613 | set_pin_power_state(codec, 0x1a, &parm); | ||
614 | set_pin_power_state(codec, 0x1b, &parm); | ||
615 | set_pin_power_state(codec, 0x1e, &parm); | ||
616 | if (imux_is_smixer) | ||
617 | parm = AC_PWRST_D0; | ||
618 | /* SW0 (17h), AIW 0/1 (13h/14h) */ | ||
619 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_POWER_STATE, | ||
620 | parm); | ||
621 | snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, | ||
622 | parm); | ||
623 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_POWER_STATE, | ||
624 | parm); | ||
625 | |||
626 | /* outputs */ | ||
627 | /* PW0 (19h), SW1 (18h), AOW1 (11h) */ | ||
628 | parm = AC_PWRST_D3; | ||
629 | set_pin_power_state(codec, 0x19, &parm); | ||
630 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, | ||
631 | parm); | ||
632 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, | ||
633 | parm); | ||
634 | |||
635 | /* PW6 (22h), SW2 (26h), AOW2 (24h) */ | ||
636 | if (is_8ch) { | ||
637 | parm = AC_PWRST_D3; | ||
638 | set_pin_power_state(codec, 0x22, &parm); | ||
639 | snd_hda_codec_write(codec, 0x26, 0, | ||
640 | AC_VERB_SET_POWER_STATE, parm); | ||
641 | snd_hda_codec_write(codec, 0x24, 0, | ||
642 | AC_VERB_SET_POWER_STATE, parm); | ||
643 | } | ||
644 | |||
645 | /* PW 3/4/7 (1ch/1dh/23h) */ | ||
646 | parm = AC_PWRST_D3; | ||
647 | /* force to D0 for internal Speaker */ | ||
648 | set_pin_power_state(codec, 0x1c, &parm); | ||
649 | set_pin_power_state(codec, 0x1d, &parm); | ||
650 | if (is_8ch) | ||
651 | set_pin_power_state(codec, 0x23, &parm); | ||
652 | /* MW0 (16h), Sw3 (27h), AOW 0/3 (10h/25h) */ | ||
653 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_POWER_STATE, | ||
654 | imux_is_smixer ? AC_PWRST_D0 : parm); | ||
655 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, | ||
656 | parm); | ||
657 | if (is_8ch) { | ||
658 | snd_hda_codec_write(codec, 0x25, 0, | ||
659 | AC_VERB_SET_POWER_STATE, parm); | ||
660 | snd_hda_codec_write(codec, 0x27, 0, | ||
661 | AC_VERB_SET_POWER_STATE, parm); | ||
662 | } | ||
663 | } else if (spec->codec_type == VT1718S) { | ||
664 | /* MUX6 (1eh) = stereo mixer */ | ||
665 | imux_is_smixer = snd_hda_codec_read( | ||
666 | codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5; | ||
667 | /* inputs */ | ||
668 | /* PW 5/6/7 (29h/2ah/2bh) */ | ||
669 | parm = AC_PWRST_D3; | ||
670 | set_pin_power_state(codec, 0x29, &parm); | ||
671 | set_pin_power_state(codec, 0x2a, &parm); | ||
672 | set_pin_power_state(codec, 0x2b, &parm); | ||
673 | if (imux_is_smixer) | ||
674 | parm = AC_PWRST_D0; | ||
675 | /* MUX6/7 (1eh/1fh), AIW 0/1 (10h/11h) */ | ||
676 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, | ||
677 | parm); | ||
678 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, | ||
679 | parm); | ||
680 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, | ||
681 | parm); | ||
682 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, | ||
683 | parm); | ||
684 | |||
685 | /* outputs */ | ||
686 | /* PW3 (27h), MW2 (1ah), AOW3 (bh) */ | ||
687 | parm = AC_PWRST_D3; | ||
688 | set_pin_power_state(codec, 0x27, &parm); | ||
689 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_POWER_STATE, | ||
690 | parm); | ||
691 | snd_hda_codec_write(codec, 0xb, 0, AC_VERB_SET_POWER_STATE, | ||
692 | parm); | ||
693 | |||
694 | /* PW2 (26h), AOW2 (ah) */ | ||
695 | parm = AC_PWRST_D3; | ||
696 | set_pin_power_state(codec, 0x26, &parm); | ||
697 | snd_hda_codec_write(codec, 0xa, 0, AC_VERB_SET_POWER_STATE, | ||
698 | parm); | ||
699 | |||
700 | /* PW0/1 (24h/25h) */ | ||
701 | parm = AC_PWRST_D3; | ||
702 | set_pin_power_state(codec, 0x24, &parm); | ||
703 | set_pin_power_state(codec, 0x25, &parm); | ||
704 | if (!spec->hp_independent_mode) /* check for redirected HP */ | ||
705 | set_pin_power_state(codec, 0x28, &parm); | ||
706 | snd_hda_codec_write(codec, 0x8, 0, AC_VERB_SET_POWER_STATE, | ||
707 | parm); | ||
708 | snd_hda_codec_write(codec, 0x9, 0, AC_VERB_SET_POWER_STATE, | ||
709 | parm); | ||
710 | /* MW9 (21h), Mw2 (1ah), AOW0 (8h) */ | ||
711 | snd_hda_codec_write(codec, 0x21, 0, AC_VERB_SET_POWER_STATE, | ||
712 | imux_is_smixer ? AC_PWRST_D0 : parm); | ||
713 | if (spec->hp_independent_mode) { | ||
714 | /* PW4 (28h), MW3 (1bh), MUX1(34h), AOW4 (ch) */ | ||
715 | parm = AC_PWRST_D3; | ||
716 | set_pin_power_state(codec, 0x28, &parm); | ||
717 | snd_hda_codec_write(codec, 0x1b, 0, | ||
718 | AC_VERB_SET_POWER_STATE, parm); | ||
719 | snd_hda_codec_write(codec, 0x34, 0, | ||
720 | AC_VERB_SET_POWER_STATE, parm); | ||
721 | snd_hda_codec_write(codec, 0xc, 0, | ||
722 | AC_VERB_SET_POWER_STATE, parm); | ||
723 | } | ||
724 | } else if (spec->codec_type == VT1716S) { | ||
725 | unsigned int mono_out, present; | ||
726 | /* SW0 (17h) = stereo mixer */ | ||
727 | imux_is_smixer = snd_hda_codec_read( | ||
728 | codec, 0x17, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5; | ||
729 | /* inputs */ | ||
730 | /* PW 1/2/5 (1ah/1bh/1eh) */ | ||
731 | parm = AC_PWRST_D3; | ||
732 | set_pin_power_state(codec, 0x1a, &parm); | ||
733 | set_pin_power_state(codec, 0x1b, &parm); | ||
734 | set_pin_power_state(codec, 0x1e, &parm); | ||
735 | if (imux_is_smixer) | ||
736 | parm = AC_PWRST_D0; | ||
737 | /* SW0 (17h), AIW0(13h) */ | ||
738 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_POWER_STATE, | ||
739 | parm); | ||
740 | snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, | ||
741 | parm); | ||
742 | |||
743 | parm = AC_PWRST_D3; | ||
744 | set_pin_power_state(codec, 0x1e, &parm); | ||
745 | /* PW11 (22h) */ | ||
746 | if (spec->dmic_enabled) | ||
747 | set_pin_power_state(codec, 0x22, &parm); | ||
748 | else | ||
749 | snd_hda_codec_write( | ||
750 | codec, 0x22, 0, | ||
751 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
752 | |||
753 | /* SW2(26h), AIW1(14h) */ | ||
754 | snd_hda_codec_write(codec, 0x26, 0, AC_VERB_SET_POWER_STATE, | ||
755 | parm); | ||
756 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_POWER_STATE, | ||
757 | parm); | ||
758 | |||
759 | /* outputs */ | ||
760 | /* PW0 (19h), SW1 (18h), AOW1 (11h) */ | ||
761 | parm = AC_PWRST_D3; | ||
762 | set_pin_power_state(codec, 0x19, &parm); | ||
763 | /* Smart 5.1 PW2(1bh) */ | ||
764 | if (spec->smart51_enabled) | ||
765 | set_pin_power_state(codec, 0x1b, &parm); | ||
766 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, | ||
767 | parm); | ||
768 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, | ||
769 | parm); | ||
770 | |||
771 | /* PW7 (23h), SW3 (27h), AOW3 (25h) */ | ||
772 | parm = AC_PWRST_D3; | ||
773 | set_pin_power_state(codec, 0x23, &parm); | ||
774 | /* Smart 5.1 PW1(1ah) */ | ||
775 | if (spec->smart51_enabled) | ||
776 | set_pin_power_state(codec, 0x1a, &parm); | ||
777 | snd_hda_codec_write(codec, 0x27, 0, AC_VERB_SET_POWER_STATE, | ||
778 | parm); | ||
779 | |||
780 | /* Smart 5.1 PW5(1eh) */ | ||
781 | if (spec->smart51_enabled) | ||
782 | set_pin_power_state(codec, 0x1e, &parm); | ||
783 | snd_hda_codec_write(codec, 0x25, 0, AC_VERB_SET_POWER_STATE, | ||
784 | parm); | ||
785 | |||
786 | /* Mono out */ | ||
787 | /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/ | ||
788 | present = snd_hda_jack_detect(codec, 0x1c); | ||
789 | if (present) | ||
790 | mono_out = 0; | ||
791 | else { | ||
792 | present = snd_hda_jack_detect(codec, 0x1d); | ||
793 | if (!spec->hp_independent_mode && present) | ||
794 | mono_out = 0; | ||
795 | else | ||
796 | mono_out = 1; | ||
797 | } | ||
798 | parm = mono_out ? AC_PWRST_D0 : AC_PWRST_D3; | ||
799 | snd_hda_codec_write(codec, 0x28, 0, AC_VERB_SET_POWER_STATE, | ||
800 | parm); | ||
801 | snd_hda_codec_write(codec, 0x29, 0, AC_VERB_SET_POWER_STATE, | ||
802 | parm); | ||
803 | snd_hda_codec_write(codec, 0x2a, 0, AC_VERB_SET_POWER_STATE, | ||
804 | parm); | ||
805 | |||
806 | /* PW 3/4 (1ch/1dh) */ | ||
807 | parm = AC_PWRST_D3; | ||
808 | set_pin_power_state(codec, 0x1c, &parm); | ||
809 | set_pin_power_state(codec, 0x1d, &parm); | ||
810 | /* HP Independent Mode, power on AOW3 */ | ||
811 | if (spec->hp_independent_mode) | ||
812 | snd_hda_codec_write(codec, 0x25, 0, | ||
813 | AC_VERB_SET_POWER_STATE, parm); | ||
814 | |||
815 | /* force to D0 for internal Speaker */ | ||
816 | /* MW0 (16h), AOW0 (10h) */ | ||
817 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_POWER_STATE, | ||
818 | imux_is_smixer ? AC_PWRST_D0 : parm); | ||
819 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, | ||
820 | mono_out ? AC_PWRST_D0 : parm); | ||
821 | } else if (spec->codec_type == VT2002P) { | ||
822 | unsigned int present; | ||
823 | /* MUX9 (1eh) = stereo mixer */ | ||
824 | imux_is_smixer = snd_hda_codec_read( | ||
825 | codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 3; | ||
826 | /* inputs */ | ||
827 | /* PW 5/6/7 (29h/2ah/2bh) */ | ||
828 | parm = AC_PWRST_D3; | ||
829 | set_pin_power_state(codec, 0x29, &parm); | ||
830 | set_pin_power_state(codec, 0x2a, &parm); | ||
831 | set_pin_power_state(codec, 0x2b, &parm); | ||
832 | if (imux_is_smixer) | ||
833 | parm = AC_PWRST_D0; | ||
834 | /* MUX9/10 (1eh/1fh), AIW 0/1 (10h/11h) */ | ||
835 | snd_hda_codec_write(codec, 0x1e, 0, | ||
836 | AC_VERB_SET_POWER_STATE, parm); | ||
837 | snd_hda_codec_write(codec, 0x1f, 0, | ||
838 | AC_VERB_SET_POWER_STATE, parm); | ||
839 | snd_hda_codec_write(codec, 0x10, 0, | ||
840 | AC_VERB_SET_POWER_STATE, parm); | ||
841 | snd_hda_codec_write(codec, 0x11, 0, | ||
842 | AC_VERB_SET_POWER_STATE, parm); | ||
843 | |||
844 | /* outputs */ | ||
845 | /* AOW0 (8h)*/ | ||
846 | snd_hda_codec_write(codec, 0x8, 0, | ||
847 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
848 | |||
849 | /* PW4 (26h), MW4 (1ch), MUX4(37h) */ | ||
850 | parm = AC_PWRST_D3; | ||
851 | set_pin_power_state(codec, 0x26, &parm); | ||
852 | snd_hda_codec_write(codec, 0x1c, 0, | ||
853 | AC_VERB_SET_POWER_STATE, parm); | ||
854 | snd_hda_codec_write(codec, 0x37, | ||
855 | 0, AC_VERB_SET_POWER_STATE, parm); | ||
856 | |||
857 | /* PW1 (25h), MW1 (19h), MUX1(35h), AOW1 (9h) */ | ||
858 | parm = AC_PWRST_D3; | ||
859 | set_pin_power_state(codec, 0x25, &parm); | ||
860 | snd_hda_codec_write(codec, 0x19, 0, | ||
861 | AC_VERB_SET_POWER_STATE, parm); | ||
862 | snd_hda_codec_write(codec, 0x35, 0, | ||
863 | AC_VERB_SET_POWER_STATE, parm); | ||
864 | if (spec->hp_independent_mode) { | ||
865 | snd_hda_codec_write(codec, 0x9, 0, | ||
866 | AC_VERB_SET_POWER_STATE, parm); | ||
867 | } | ||
868 | |||
869 | /* Class-D */ | ||
870 | /* PW0 (24h), MW0(18h), MUX0(34h) */ | ||
871 | present = snd_hda_jack_detect(codec, 0x25); | ||
872 | parm = AC_PWRST_D3; | ||
873 | set_pin_power_state(codec, 0x24, &parm); | ||
874 | if (present) { | ||
875 | snd_hda_codec_write( | ||
876 | codec, 0x18, 0, | ||
877 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
878 | snd_hda_codec_write( | ||
879 | codec, 0x34, 0, | ||
880 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
881 | } else { | ||
882 | snd_hda_codec_write( | ||
883 | codec, 0x18, 0, | ||
884 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
885 | snd_hda_codec_write( | ||
886 | codec, 0x34, 0, | ||
887 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
888 | } | ||
889 | |||
890 | /* Mono Out */ | ||
891 | /* PW15 (31h), MW8(17h), MUX8(3bh) */ | ||
892 | present = snd_hda_jack_detect(codec, 0x26); | ||
893 | parm = AC_PWRST_D3; | ||
894 | set_pin_power_state(codec, 0x31, &parm); | ||
895 | if (present) { | ||
896 | snd_hda_codec_write( | ||
897 | codec, 0x17, 0, | ||
898 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
899 | snd_hda_codec_write( | ||
900 | codec, 0x3b, 0, | ||
901 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
902 | } else { | ||
903 | snd_hda_codec_write( | ||
904 | codec, 0x17, 0, | ||
905 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
906 | snd_hda_codec_write( | ||
907 | codec, 0x3b, 0, | ||
908 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
909 | } | ||
910 | |||
911 | /* MW9 (21h) */ | ||
912 | if (imux_is_smixer || !is_aa_path_mute(codec)) | ||
913 | snd_hda_codec_write( | ||
914 | codec, 0x21, 0, | ||
915 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
916 | else | ||
917 | snd_hda_codec_write( | ||
918 | codec, 0x21, 0, | ||
919 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
920 | } else if (spec->codec_type == VT1812) { | ||
921 | unsigned int present; | ||
922 | /* MUX10 (1eh) = stereo mixer */ | ||
923 | imux_is_smixer = snd_hda_codec_read( | ||
924 | codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5; | ||
925 | /* inputs */ | ||
926 | /* PW 5/6/7 (29h/2ah/2bh) */ | ||
927 | parm = AC_PWRST_D3; | ||
928 | set_pin_power_state(codec, 0x29, &parm); | ||
929 | set_pin_power_state(codec, 0x2a, &parm); | ||
930 | set_pin_power_state(codec, 0x2b, &parm); | ||
931 | if (imux_is_smixer) | ||
932 | parm = AC_PWRST_D0; | ||
933 | /* MUX10/11 (1eh/1fh), AIW 0/1 (10h/11h) */ | ||
934 | snd_hda_codec_write(codec, 0x1e, 0, | ||
935 | AC_VERB_SET_POWER_STATE, parm); | ||
936 | snd_hda_codec_write(codec, 0x1f, 0, | ||
937 | AC_VERB_SET_POWER_STATE, parm); | ||
938 | snd_hda_codec_write(codec, 0x10, 0, | ||
939 | AC_VERB_SET_POWER_STATE, parm); | ||
940 | snd_hda_codec_write(codec, 0x11, 0, | ||
941 | AC_VERB_SET_POWER_STATE, parm); | ||
942 | |||
943 | /* outputs */ | ||
944 | /* AOW0 (8h)*/ | ||
945 | snd_hda_codec_write(codec, 0x8, 0, | ||
946 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
947 | |||
948 | /* PW4 (28h), MW4 (18h), MUX4(38h) */ | ||
949 | parm = AC_PWRST_D3; | ||
950 | set_pin_power_state(codec, 0x28, &parm); | ||
951 | snd_hda_codec_write(codec, 0x18, 0, | ||
952 | AC_VERB_SET_POWER_STATE, parm); | ||
953 | snd_hda_codec_write(codec, 0x38, 0, | ||
954 | AC_VERB_SET_POWER_STATE, parm); | ||
955 | |||
956 | /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */ | ||
957 | parm = AC_PWRST_D3; | ||
958 | set_pin_power_state(codec, 0x25, &parm); | ||
959 | snd_hda_codec_write(codec, 0x15, 0, | ||
960 | AC_VERB_SET_POWER_STATE, parm); | ||
961 | snd_hda_codec_write(codec, 0x35, 0, | ||
962 | AC_VERB_SET_POWER_STATE, parm); | ||
963 | if (spec->hp_independent_mode) { | ||
964 | snd_hda_codec_write(codec, 0x9, 0, | ||
965 | AC_VERB_SET_POWER_STATE, parm); | ||
966 | } | ||
967 | |||
968 | /* Internal Speaker */ | ||
969 | /* PW0 (24h), MW0(14h), MUX0(34h) */ | ||
970 | present = snd_hda_jack_detect(codec, 0x25); | ||
971 | parm = AC_PWRST_D3; | ||
972 | set_pin_power_state(codec, 0x24, &parm); | ||
973 | if (present) { | ||
974 | snd_hda_codec_write(codec, 0x14, 0, | ||
975 | AC_VERB_SET_POWER_STATE, | ||
976 | AC_PWRST_D3); | ||
977 | snd_hda_codec_write(codec, 0x34, 0, | ||
978 | AC_VERB_SET_POWER_STATE, | ||
979 | AC_PWRST_D3); | ||
980 | } else { | ||
981 | snd_hda_codec_write(codec, 0x14, 0, | ||
982 | AC_VERB_SET_POWER_STATE, | ||
983 | AC_PWRST_D0); | ||
984 | snd_hda_codec_write(codec, 0x34, 0, | ||
985 | AC_VERB_SET_POWER_STATE, | ||
986 | AC_PWRST_D0); | ||
987 | } | ||
988 | /* Mono Out */ | ||
989 | /* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */ | ||
990 | present = snd_hda_jack_detect(codec, 0x28); | ||
991 | parm = AC_PWRST_D3; | ||
992 | set_pin_power_state(codec, 0x31, &parm); | ||
993 | if (present) { | ||
994 | snd_hda_codec_write(codec, 0x1c, 0, | ||
995 | AC_VERB_SET_POWER_STATE, | ||
996 | AC_PWRST_D3); | ||
997 | snd_hda_codec_write(codec, 0x3c, 0, | ||
998 | AC_VERB_SET_POWER_STATE, | ||
999 | AC_PWRST_D3); | ||
1000 | snd_hda_codec_write(codec, 0x3e, 0, | ||
1001 | AC_VERB_SET_POWER_STATE, | ||
1002 | AC_PWRST_D3); | ||
1003 | } else { | ||
1004 | snd_hda_codec_write(codec, 0x1c, 0, | ||
1005 | AC_VERB_SET_POWER_STATE, | ||
1006 | AC_PWRST_D0); | ||
1007 | snd_hda_codec_write(codec, 0x3c, 0, | ||
1008 | AC_VERB_SET_POWER_STATE, | ||
1009 | AC_PWRST_D0); | ||
1010 | snd_hda_codec_write(codec, 0x3e, 0, | ||
1011 | AC_VERB_SET_POWER_STATE, | ||
1012 | AC_PWRST_D0); | ||
1013 | } | ||
1014 | |||
1015 | /* PW15 (33h), MW15 (1dh), MUX15(3dh) */ | ||
1016 | parm = AC_PWRST_D3; | ||
1017 | set_pin_power_state(codec, 0x33, &parm); | ||
1018 | snd_hda_codec_write(codec, 0x1d, 0, | ||
1019 | AC_VERB_SET_POWER_STATE, parm); | ||
1020 | snd_hda_codec_write(codec, 0x3d, 0, | ||
1021 | AC_VERB_SET_POWER_STATE, parm); | ||
1022 | |||
1023 | /* MW9 (21h) */ | ||
1024 | if (imux_is_smixer || !is_aa_path_mute(codec)) | ||
1025 | snd_hda_codec_write( | ||
1026 | codec, 0x21, 0, | ||
1027 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
1028 | else | ||
1029 | snd_hda_codec_write( | ||
1030 | codec, 0x21, 0, | ||
1031 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | ||
1032 | } | ||
1033 | } | ||
1034 | |||
367 | /* | 1035 | /* |
368 | * input MUX handling | 1036 | * input MUX handling |
369 | */ | 1037 | */ |
@@ -395,6 +1063,14 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
395 | 1063 | ||
396 | if (!spec->mux_nids[adc_idx]) | 1064 | if (!spec->mux_nids[adc_idx]) |
397 | return -EINVAL; | 1065 | return -EINVAL; |
1066 | /* switch to D0 beofre change index */ | ||
1067 | if (snd_hda_codec_read(codec, spec->mux_nids[adc_idx], 0, | ||
1068 | AC_VERB_GET_POWER_STATE, 0x00) != AC_PWRST_D0) | ||
1069 | snd_hda_codec_write(codec, spec->mux_nids[adc_idx], 0, | ||
1070 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | ||
1071 | /* update jack power state */ | ||
1072 | set_jack_power_state(codec); | ||
1073 | |||
398 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | 1074 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
399 | spec->mux_nids[adc_idx], | 1075 | spec->mux_nids[adc_idx], |
400 | &spec->cur_mux[adc_idx]); | 1076 | &spec->cur_mux[adc_idx]); |
@@ -413,16 +1089,74 @@ static int via_independent_hp_get(struct snd_kcontrol *kcontrol, | |||
413 | { | 1089 | { |
414 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 1090 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
415 | struct via_spec *spec = codec->spec; | 1091 | struct via_spec *spec = codec->spec; |
416 | hda_nid_t nid = spec->autocfg.hp_pins[0]; | 1092 | hda_nid_t nid; |
417 | unsigned int pinsel = snd_hda_codec_read(codec, nid, 0, | 1093 | unsigned int pinsel; |
418 | AC_VERB_GET_CONNECT_SEL, | 1094 | |
419 | 0x00); | 1095 | switch (spec->codec_type) { |
420 | 1096 | case VT1718S: | |
1097 | nid = 0x34; | ||
1098 | break; | ||
1099 | case VT2002P: | ||
1100 | nid = 0x35; | ||
1101 | break; | ||
1102 | case VT1812: | ||
1103 | nid = 0x3d; | ||
1104 | break; | ||
1105 | default: | ||
1106 | nid = spec->autocfg.hp_pins[0]; | ||
1107 | break; | ||
1108 | } | ||
1109 | /* use !! to translate conn sel 2 for VT1718S */ | ||
1110 | pinsel = !!snd_hda_codec_read(codec, nid, 0, | ||
1111 | AC_VERB_GET_CONNECT_SEL, | ||
1112 | 0x00); | ||
421 | ucontrol->value.enumerated.item[0] = pinsel; | 1113 | ucontrol->value.enumerated.item[0] = pinsel; |
422 | 1114 | ||
423 | return 0; | 1115 | return 0; |
424 | } | 1116 | } |
425 | 1117 | ||
1118 | static void activate_ctl(struct hda_codec *codec, const char *name, int active) | ||
1119 | { | ||
1120 | struct snd_kcontrol *ctl = snd_hda_find_mixer_ctl(codec, name); | ||
1121 | if (ctl) { | ||
1122 | ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; | ||
1123 | ctl->vd[0].access |= active | ||
1124 | ? 0 : SNDRV_CTL_ELEM_ACCESS_INACTIVE; | ||
1125 | snd_ctl_notify(codec->bus->card, | ||
1126 | SNDRV_CTL_EVENT_MASK_VALUE, &ctl->id); | ||
1127 | } | ||
1128 | } | ||
1129 | |||
1130 | static int update_side_mute_status(struct hda_codec *codec) | ||
1131 | { | ||
1132 | /* mute side channel */ | ||
1133 | struct via_spec *spec = codec->spec; | ||
1134 | unsigned int parm = spec->hp_independent_mode | ||
1135 | ? AMP_OUT_MUTE : AMP_OUT_UNMUTE; | ||
1136 | hda_nid_t sw3; | ||
1137 | |||
1138 | switch (spec->codec_type) { | ||
1139 | case VT1708: | ||
1140 | sw3 = 0x1b; | ||
1141 | break; | ||
1142 | case VT1709_10CH: | ||
1143 | sw3 = 0x29; | ||
1144 | break; | ||
1145 | case VT1708B_8CH: | ||
1146 | case VT1708S: | ||
1147 | sw3 = 0x27; | ||
1148 | break; | ||
1149 | default: | ||
1150 | sw3 = 0; | ||
1151 | break; | ||
1152 | } | ||
1153 | |||
1154 | if (sw3) | ||
1155 | snd_hda_codec_write(codec, sw3, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
1156 | parm); | ||
1157 | return 0; | ||
1158 | } | ||
1159 | |||
426 | static int via_independent_hp_put(struct snd_kcontrol *kcontrol, | 1160 | static int via_independent_hp_put(struct snd_kcontrol *kcontrol, |
427 | struct snd_ctl_elem_value *ucontrol) | 1161 | struct snd_ctl_elem_value *ucontrol) |
428 | { | 1162 | { |
@@ -430,47 +1164,46 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol, | |||
430 | struct via_spec *spec = codec->spec; | 1164 | struct via_spec *spec = codec->spec; |
431 | hda_nid_t nid = spec->autocfg.hp_pins[0]; | 1165 | hda_nid_t nid = spec->autocfg.hp_pins[0]; |
432 | unsigned int pinsel = ucontrol->value.enumerated.item[0]; | 1166 | unsigned int pinsel = ucontrol->value.enumerated.item[0]; |
433 | unsigned int con_nid = snd_hda_codec_read(codec, nid, 0, | 1167 | /* Get Independent Mode index of headphone pin widget */ |
434 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | 1168 | spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel |
435 | 1169 | ? 1 : 0; | |
436 | if (con_nid == spec->multiout.hp_nid) { | 1170 | |
437 | if (pinsel == 0) { | 1171 | switch (spec->codec_type) { |
438 | if (!spec->hp_independent_mode) { | 1172 | case VT1718S: |
439 | if (spec->multiout.num_dacs > 1) | 1173 | nid = 0x34; |
440 | spec->multiout.num_dacs -= 1; | 1174 | pinsel = pinsel ? 2 : 0; /* indep HP use AOW4 (index 2) */ |
441 | spec->hp_independent_mode = 1; | 1175 | spec->multiout.num_dacs = 4; |
442 | } | 1176 | break; |
443 | } else if (pinsel == 1) { | 1177 | case VT2002P: |
444 | if (spec->hp_independent_mode) { | 1178 | nid = 0x35; |
445 | if (spec->multiout.num_dacs > 1) | 1179 | break; |
446 | spec->multiout.num_dacs += 1; | 1180 | case VT1812: |
447 | spec->hp_independent_mode = 0; | 1181 | nid = 0x3d; |
448 | } | 1182 | break; |
449 | } | 1183 | default: |
450 | } else { | 1184 | nid = spec->autocfg.hp_pins[0]; |
451 | if (pinsel == 0) { | 1185 | break; |
452 | if (spec->hp_independent_mode) { | 1186 | } |
453 | if (spec->multiout.num_dacs > 1) | 1187 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); |
454 | spec->multiout.num_dacs += 1; | 1188 | |
455 | spec->hp_independent_mode = 0; | 1189 | if (spec->multiout.hp_nid && spec->multiout.hp_nid |
456 | } | 1190 | != spec->multiout.dac_nids[HDA_FRONT]) |
457 | } else if (pinsel == 1) { | 1191 | snd_hda_codec_setup_stream(codec, spec->multiout.hp_nid, |
458 | if (!spec->hp_independent_mode) { | 1192 | 0, 0, 0); |
459 | if (spec->multiout.num_dacs > 1) | 1193 | |
460 | spec->multiout.num_dacs -= 1; | 1194 | update_side_mute_status(codec); |
461 | spec->hp_independent_mode = 1; | 1195 | /* update HP volume/swtich active state */ |
462 | } | 1196 | if (spec->codec_type == VT1708S |
463 | } | 1197 | || spec->codec_type == VT1702 |
1198 | || spec->codec_type == VT1718S | ||
1199 | || spec->codec_type == VT1716S | ||
1200 | || spec->codec_type == VT2002P | ||
1201 | || spec->codec_type == VT1812) { | ||
1202 | activate_ctl(codec, "Headphone Playback Volume", | ||
1203 | spec->hp_independent_mode); | ||
1204 | activate_ctl(codec, "Headphone Playback Switch", | ||
1205 | spec->hp_independent_mode); | ||
464 | } | 1206 | } |
465 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, | ||
466 | pinsel); | ||
467 | |||
468 | if (spec->multiout.hp_nid && | ||
469 | spec->multiout.hp_nid != spec->multiout.dac_nids[HDA_FRONT]) | ||
470 | snd_hda_codec_setup_stream(codec, | ||
471 | spec->multiout.hp_nid, | ||
472 | 0, 0, 0); | ||
473 | |||
474 | return 0; | 1207 | return 0; |
475 | } | 1208 | } |
476 | 1209 | ||
@@ -486,6 +1219,175 @@ static struct snd_kcontrol_new via_hp_mixer[] = { | |||
486 | { } /* end */ | 1219 | { } /* end */ |
487 | }; | 1220 | }; |
488 | 1221 | ||
1222 | static void notify_aa_path_ctls(struct hda_codec *codec) | ||
1223 | { | ||
1224 | int i; | ||
1225 | struct snd_ctl_elem_id id; | ||
1226 | const char *labels[] = {"Mic", "Front Mic", "Line"}; | ||
1227 | |||
1228 | memset(&id, 0, sizeof(id)); | ||
1229 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
1230 | for (i = 0; i < ARRAY_SIZE(labels); i++) { | ||
1231 | sprintf(id.name, "%s Playback Volume", labels[i]); | ||
1232 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
1233 | &id); | ||
1234 | } | ||
1235 | } | ||
1236 | |||
1237 | static void mute_aa_path(struct hda_codec *codec, int mute) | ||
1238 | { | ||
1239 | struct via_spec *spec = codec->spec; | ||
1240 | hda_nid_t nid_mixer; | ||
1241 | int start_idx; | ||
1242 | int end_idx; | ||
1243 | int i; | ||
1244 | /* get nid of MW0 and start & end index */ | ||
1245 | switch (spec->codec_type) { | ||
1246 | case VT1708: | ||
1247 | nid_mixer = 0x17; | ||
1248 | start_idx = 2; | ||
1249 | end_idx = 4; | ||
1250 | break; | ||
1251 | case VT1709_10CH: | ||
1252 | case VT1709_6CH: | ||
1253 | nid_mixer = 0x18; | ||
1254 | start_idx = 2; | ||
1255 | end_idx = 4; | ||
1256 | break; | ||
1257 | case VT1708B_8CH: | ||
1258 | case VT1708B_4CH: | ||
1259 | case VT1708S: | ||
1260 | case VT1716S: | ||
1261 | nid_mixer = 0x16; | ||
1262 | start_idx = 2; | ||
1263 | end_idx = 4; | ||
1264 | break; | ||
1265 | default: | ||
1266 | return; | ||
1267 | } | ||
1268 | /* check AA path's mute status */ | ||
1269 | for (i = start_idx; i <= end_idx; i++) { | ||
1270 | int val = mute ? HDA_AMP_MUTE : HDA_AMP_UNMUTE; | ||
1271 | snd_hda_codec_amp_stereo(codec, nid_mixer, HDA_INPUT, i, | ||
1272 | HDA_AMP_MUTE, val); | ||
1273 | } | ||
1274 | } | ||
1275 | static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin) | ||
1276 | { | ||
1277 | int res = 0; | ||
1278 | int index; | ||
1279 | for (index = AUTO_PIN_MIC; index < AUTO_PIN_FRONT_LINE; index++) { | ||
1280 | if (pin == spec->autocfg.input_pins[index]) { | ||
1281 | res = 1; | ||
1282 | break; | ||
1283 | } | ||
1284 | } | ||
1285 | return res; | ||
1286 | } | ||
1287 | |||
1288 | static int via_smart51_info(struct snd_kcontrol *kcontrol, | ||
1289 | struct snd_ctl_elem_info *uinfo) | ||
1290 | { | ||
1291 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1292 | uinfo->count = 1; | ||
1293 | uinfo->value.integer.min = 0; | ||
1294 | uinfo->value.integer.max = 1; | ||
1295 | return 0; | ||
1296 | } | ||
1297 | |||
1298 | static int via_smart51_get(struct snd_kcontrol *kcontrol, | ||
1299 | struct snd_ctl_elem_value *ucontrol) | ||
1300 | { | ||
1301 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1302 | struct via_spec *spec = codec->spec; | ||
1303 | int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; | ||
1304 | int on = 1; | ||
1305 | int i; | ||
1306 | |||
1307 | for (i = 0; i < ARRAY_SIZE(index); i++) { | ||
1308 | hda_nid_t nid = spec->autocfg.input_pins[index[i]]; | ||
1309 | if (nid) { | ||
1310 | int ctl = | ||
1311 | snd_hda_codec_read(codec, nid, 0, | ||
1312 | AC_VERB_GET_PIN_WIDGET_CONTROL, | ||
1313 | 0); | ||
1314 | if (i == AUTO_PIN_FRONT_MIC | ||
1315 | && spec->hp_independent_mode | ||
1316 | && spec->codec_type != VT1718S) | ||
1317 | continue; /* ignore FMic for independent HP */ | ||
1318 | if (ctl & AC_PINCTL_IN_EN | ||
1319 | && !(ctl & AC_PINCTL_OUT_EN)) | ||
1320 | on = 0; | ||
1321 | } | ||
1322 | } | ||
1323 | *ucontrol->value.integer.value = on; | ||
1324 | return 0; | ||
1325 | } | ||
1326 | |||
1327 | static int via_smart51_put(struct snd_kcontrol *kcontrol, | ||
1328 | struct snd_ctl_elem_value *ucontrol) | ||
1329 | { | ||
1330 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1331 | struct via_spec *spec = codec->spec; | ||
1332 | int out_in = *ucontrol->value.integer.value | ||
1333 | ? AC_PINCTL_OUT_EN : AC_PINCTL_IN_EN; | ||
1334 | int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; | ||
1335 | int i; | ||
1336 | |||
1337 | for (i = 0; i < ARRAY_SIZE(index); i++) { | ||
1338 | hda_nid_t nid = spec->autocfg.input_pins[index[i]]; | ||
1339 | if (i == AUTO_PIN_FRONT_MIC | ||
1340 | && spec->hp_independent_mode | ||
1341 | && spec->codec_type != VT1718S) | ||
1342 | continue; /* don't retask FMic for independent HP */ | ||
1343 | if (nid) { | ||
1344 | unsigned int parm = snd_hda_codec_read( | ||
1345 | codec, nid, 0, | ||
1346 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
1347 | parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | ||
1348 | parm |= out_in; | ||
1349 | snd_hda_codec_write(codec, nid, 0, | ||
1350 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1351 | parm); | ||
1352 | if (out_in == AC_PINCTL_OUT_EN) { | ||
1353 | mute_aa_path(codec, 1); | ||
1354 | notify_aa_path_ctls(codec); | ||
1355 | } | ||
1356 | if (spec->codec_type == VT1718S) | ||
1357 | snd_hda_codec_amp_stereo( | ||
1358 | codec, nid, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
1359 | HDA_AMP_UNMUTE); | ||
1360 | } | ||
1361 | if (i == AUTO_PIN_FRONT_MIC) { | ||
1362 | if (spec->codec_type == VT1708S | ||
1363 | || spec->codec_type == VT1716S) { | ||
1364 | /* input = index 1 (AOW3) */ | ||
1365 | snd_hda_codec_write( | ||
1366 | codec, nid, 0, | ||
1367 | AC_VERB_SET_CONNECT_SEL, 1); | ||
1368 | snd_hda_codec_amp_stereo( | ||
1369 | codec, nid, HDA_OUTPUT, | ||
1370 | 0, HDA_AMP_MUTE, HDA_AMP_UNMUTE); | ||
1371 | } | ||
1372 | } | ||
1373 | } | ||
1374 | spec->smart51_enabled = *ucontrol->value.integer.value; | ||
1375 | set_jack_power_state(codec); | ||
1376 | return 1; | ||
1377 | } | ||
1378 | |||
1379 | static struct snd_kcontrol_new via_smart51_mixer[] = { | ||
1380 | { | ||
1381 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1382 | .name = "Smart 5.1", | ||
1383 | .count = 1, | ||
1384 | .info = via_smart51_info, | ||
1385 | .get = via_smart51_get, | ||
1386 | .put = via_smart51_put, | ||
1387 | }, | ||
1388 | {} /* end */ | ||
1389 | }; | ||
1390 | |||
489 | /* capture mixer elements */ | 1391 | /* capture mixer elements */ |
490 | static struct snd_kcontrol_new vt1708_capture_mixer[] = { | 1392 | static struct snd_kcontrol_new vt1708_capture_mixer[] = { |
491 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT), | 1393 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT), |
@@ -506,6 +1408,112 @@ static struct snd_kcontrol_new vt1708_capture_mixer[] = { | |||
506 | }, | 1408 | }, |
507 | { } /* end */ | 1409 | { } /* end */ |
508 | }; | 1410 | }; |
1411 | |||
1412 | /* check AA path's mute statue */ | ||
1413 | static int is_aa_path_mute(struct hda_codec *codec) | ||
1414 | { | ||
1415 | int mute = 1; | ||
1416 | hda_nid_t nid_mixer; | ||
1417 | int start_idx; | ||
1418 | int end_idx; | ||
1419 | int i; | ||
1420 | struct via_spec *spec = codec->spec; | ||
1421 | /* get nid of MW0 and start & end index */ | ||
1422 | switch (spec->codec_type) { | ||
1423 | case VT1708B_8CH: | ||
1424 | case VT1708B_4CH: | ||
1425 | case VT1708S: | ||
1426 | case VT1716S: | ||
1427 | nid_mixer = 0x16; | ||
1428 | start_idx = 2; | ||
1429 | end_idx = 4; | ||
1430 | break; | ||
1431 | case VT1702: | ||
1432 | nid_mixer = 0x1a; | ||
1433 | start_idx = 1; | ||
1434 | end_idx = 3; | ||
1435 | break; | ||
1436 | case VT1718S: | ||
1437 | nid_mixer = 0x21; | ||
1438 | start_idx = 1; | ||
1439 | end_idx = 3; | ||
1440 | break; | ||
1441 | case VT2002P: | ||
1442 | case VT1812: | ||
1443 | nid_mixer = 0x21; | ||
1444 | start_idx = 0; | ||
1445 | end_idx = 2; | ||
1446 | break; | ||
1447 | default: | ||
1448 | return 0; | ||
1449 | } | ||
1450 | /* check AA path's mute status */ | ||
1451 | for (i = start_idx; i <= end_idx; i++) { | ||
1452 | unsigned int con_list = snd_hda_codec_read( | ||
1453 | codec, nid_mixer, 0, AC_VERB_GET_CONNECT_LIST, i/4*4); | ||
1454 | int shift = 8 * (i % 4); | ||
1455 | hda_nid_t nid_pin = (con_list & (0xff << shift)) >> shift; | ||
1456 | unsigned int defconf = snd_hda_codec_get_pincfg(codec, nid_pin); | ||
1457 | if (get_defcfg_connect(defconf) == AC_JACK_PORT_COMPLEX) { | ||
1458 | /* check mute status while the pin is connected */ | ||
1459 | int mute_l = snd_hda_codec_amp_read(codec, nid_mixer, 0, | ||
1460 | HDA_INPUT, i) >> 7; | ||
1461 | int mute_r = snd_hda_codec_amp_read(codec, nid_mixer, 1, | ||
1462 | HDA_INPUT, i) >> 7; | ||
1463 | if (!mute_l || !mute_r) { | ||
1464 | mute = 0; | ||
1465 | break; | ||
1466 | } | ||
1467 | } | ||
1468 | } | ||
1469 | return mute; | ||
1470 | } | ||
1471 | |||
1472 | /* enter/exit analog low-current mode */ | ||
1473 | static void analog_low_current_mode(struct hda_codec *codec, int stream_idle) | ||
1474 | { | ||
1475 | struct via_spec *spec = codec->spec; | ||
1476 | static int saved_stream_idle = 1; /* saved stream idle status */ | ||
1477 | int enable = is_aa_path_mute(codec); | ||
1478 | unsigned int verb = 0; | ||
1479 | unsigned int parm = 0; | ||
1480 | |||
1481 | if (stream_idle == -1) /* stream status did not change */ | ||
1482 | enable = enable && saved_stream_idle; | ||
1483 | else { | ||
1484 | enable = enable && stream_idle; | ||
1485 | saved_stream_idle = stream_idle; | ||
1486 | } | ||
1487 | |||
1488 | /* decide low current mode's verb & parameter */ | ||
1489 | switch (spec->codec_type) { | ||
1490 | case VT1708B_8CH: | ||
1491 | case VT1708B_4CH: | ||
1492 | verb = 0xf70; | ||
1493 | parm = enable ? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */ | ||
1494 | break; | ||
1495 | case VT1708S: | ||
1496 | case VT1718S: | ||
1497 | case VT1716S: | ||
1498 | verb = 0xf73; | ||
1499 | parm = enable ? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */ | ||
1500 | break; | ||
1501 | case VT1702: | ||
1502 | verb = 0xf73; | ||
1503 | parm = enable ? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */ | ||
1504 | break; | ||
1505 | case VT2002P: | ||
1506 | case VT1812: | ||
1507 | verb = 0xf93; | ||
1508 | parm = enable ? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */ | ||
1509 | break; | ||
1510 | default: | ||
1511 | return; /* other codecs are not supported */ | ||
1512 | } | ||
1513 | /* send verb */ | ||
1514 | snd_hda_codec_write(codec, codec->afg, 0, verb, parm); | ||
1515 | } | ||
1516 | |||
509 | /* | 1517 | /* |
510 | * generic initialization of ADC, input mixers and output mixers | 1518 | * generic initialization of ADC, input mixers and output mixers |
511 | */ | 1519 | */ |
@@ -534,9 +1542,9 @@ static struct hda_verb vt1708_volume_init_verbs[] = { | |||
534 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 1542 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
535 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 1543 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
536 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 1544 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
537 | 1545 | ||
538 | /* Setup default input to PW4 */ | 1546 | /* Setup default input MW0 to PW4 */ |
539 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x1}, | 1547 | {0x20, AC_VERB_SET_CONNECT_SEL, 0}, |
540 | /* PW9 Output enable */ | 1548 | /* PW9 Output enable */ |
541 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 1549 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
542 | { } | 1550 | { } |
@@ -547,30 +1555,13 @@ static int via_playback_pcm_open(struct hda_pcm_stream *hinfo, | |||
547 | struct snd_pcm_substream *substream) | 1555 | struct snd_pcm_substream *substream) |
548 | { | 1556 | { |
549 | struct via_spec *spec = codec->spec; | 1557 | struct via_spec *spec = codec->spec; |
1558 | int idle = substream->pstr->substream_opened == 1 | ||
1559 | && substream->ref_count == 0; | ||
1560 | analog_low_current_mode(codec, idle); | ||
550 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, | 1561 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
551 | hinfo); | 1562 | hinfo); |
552 | } | 1563 | } |
553 | 1564 | ||
554 | static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
555 | struct hda_codec *codec, | ||
556 | unsigned int stream_tag, | ||
557 | unsigned int format, | ||
558 | struct snd_pcm_substream *substream) | ||
559 | { | ||
560 | struct via_spec *spec = codec->spec; | ||
561 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | ||
562 | stream_tag, format, substream); | ||
563 | } | ||
564 | |||
565 | static int via_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
566 | struct hda_codec *codec, | ||
567 | struct snd_pcm_substream *substream) | ||
568 | { | ||
569 | struct via_spec *spec = codec->spec; | ||
570 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | ||
571 | } | ||
572 | |||
573 | |||
574 | static void playback_multi_pcm_prep_0(struct hda_codec *codec, | 1565 | static void playback_multi_pcm_prep_0(struct hda_codec *codec, |
575 | unsigned int stream_tag, | 1566 | unsigned int stream_tag, |
576 | unsigned int format, | 1567 | unsigned int format, |
@@ -615,8 +1606,8 @@ static void playback_multi_pcm_prep_0(struct hda_codec *codec, | |||
615 | snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, | 1606 | snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, |
616 | 0, format); | 1607 | 0, format); |
617 | 1608 | ||
618 | if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT] && | 1609 | if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT] |
619 | !spec->hp_independent_mode) | 1610 | && !spec->hp_independent_mode) |
620 | /* headphone out will just decode front left/right (stereo) */ | 1611 | /* headphone out will just decode front left/right (stereo) */ |
621 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, | 1612 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, |
622 | 0, format); | 1613 | 0, format); |
@@ -658,7 +1649,7 @@ static int via_playback_multi_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
658 | snd_hda_codec_setup_stream(codec, mout->hp_nid, | 1649 | snd_hda_codec_setup_stream(codec, mout->hp_nid, |
659 | stream_tag, 0, format); | 1650 | stream_tag, 0, format); |
660 | } | 1651 | } |
661 | 1652 | vt1708_start_hp_work(spec); | |
662 | return 0; | 1653 | return 0; |
663 | } | 1654 | } |
664 | 1655 | ||
@@ -698,7 +1689,7 @@ static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream *hinfo, | |||
698 | snd_hda_codec_setup_stream(codec, mout->hp_nid, | 1689 | snd_hda_codec_setup_stream(codec, mout->hp_nid, |
699 | 0, 0, 0); | 1690 | 0, 0, 0); |
700 | } | 1691 | } |
701 | 1692 | vt1708_stop_hp_work(spec); | |
702 | return 0; | 1693 | return 0; |
703 | } | 1694 | } |
704 | 1695 | ||
@@ -779,7 +1770,7 @@ static struct hda_pcm_stream vt1708_pcm_analog_playback = { | |||
779 | }; | 1770 | }; |
780 | 1771 | ||
781 | static struct hda_pcm_stream vt1708_pcm_analog_s16_playback = { | 1772 | static struct hda_pcm_stream vt1708_pcm_analog_s16_playback = { |
782 | .substreams = 1, | 1773 | .substreams = 2, |
783 | .channels_min = 2, | 1774 | .channels_min = 2, |
784 | .channels_max = 8, | 1775 | .channels_max = 8, |
785 | .nid = 0x10, /* NID to query formats and rates */ | 1776 | .nid = 0x10, /* NID to query formats and rates */ |
@@ -790,8 +1781,8 @@ static struct hda_pcm_stream vt1708_pcm_analog_s16_playback = { | |||
790 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 1781 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
791 | .ops = { | 1782 | .ops = { |
792 | .open = via_playback_pcm_open, | 1783 | .open = via_playback_pcm_open, |
793 | .prepare = via_playback_pcm_prepare, | 1784 | .prepare = via_playback_multi_pcm_prepare, |
794 | .cleanup = via_playback_pcm_cleanup | 1785 | .cleanup = via_playback_multi_pcm_cleanup |
795 | }, | 1786 | }, |
796 | }; | 1787 | }; |
797 | 1788 | ||
@@ -853,6 +1844,11 @@ static int via_build_controls(struct hda_codec *codec) | |||
853 | if (err < 0) | 1844 | if (err < 0) |
854 | return err; | 1845 | return err; |
855 | } | 1846 | } |
1847 | |||
1848 | /* init power states */ | ||
1849 | set_jack_power_state(codec); | ||
1850 | analog_low_current_mode(codec, 1); | ||
1851 | |||
856 | via_free_kctls(codec); /* no longer needed */ | 1852 | via_free_kctls(codec); /* no longer needed */ |
857 | return 0; | 1853 | return 0; |
858 | } | 1854 | } |
@@ -866,8 +1862,10 @@ static int via_build_pcms(struct hda_codec *codec) | |||
866 | codec->pcm_info = info; | 1862 | codec->pcm_info = info; |
867 | 1863 | ||
868 | info->name = spec->stream_name_analog; | 1864 | info->name = spec->stream_name_analog; |
869 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | 1865 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
870 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | 1866 | *(spec->stream_analog_playback); |
1867 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | ||
1868 | spec->multiout.dac_nids[0]; | ||
871 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | 1869 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
872 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | 1870 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
873 | 1871 | ||
@@ -904,20 +1902,58 @@ static void via_free(struct hda_codec *codec) | |||
904 | return; | 1902 | return; |
905 | 1903 | ||
906 | via_free_kctls(codec); | 1904 | via_free_kctls(codec); |
1905 | vt1708_stop_hp_work(spec); | ||
907 | kfree(codec->spec); | 1906 | kfree(codec->spec); |
908 | } | 1907 | } |
909 | 1908 | ||
910 | /* mute internal speaker if HP is plugged */ | 1909 | /* mute internal speaker if HP is plugged */ |
911 | static void via_hp_automute(struct hda_codec *codec) | 1910 | static void via_hp_automute(struct hda_codec *codec) |
912 | { | 1911 | { |
913 | unsigned int present; | 1912 | unsigned int present = 0; |
914 | struct via_spec *spec = codec->spec; | 1913 | struct via_spec *spec = codec->spec; |
915 | 1914 | ||
916 | present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0, | 1915 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
917 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1916 | |
918 | snd_hda_codec_amp_stereo(codec, spec->autocfg.line_out_pins[0], | 1917 | if (!spec->hp_independent_mode) { |
919 | HDA_OUTPUT, 0, HDA_AMP_MUTE, | 1918 | struct snd_ctl_elem_id id; |
920 | present ? HDA_AMP_MUTE : 0); | 1919 | /* auto mute */ |
1920 | snd_hda_codec_amp_stereo( | ||
1921 | codec, spec->autocfg.line_out_pins[0], HDA_OUTPUT, 0, | ||
1922 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
1923 | /* notify change */ | ||
1924 | memset(&id, 0, sizeof(id)); | ||
1925 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
1926 | strcpy(id.name, "Front Playback Switch"); | ||
1927 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
1928 | &id); | ||
1929 | } | ||
1930 | } | ||
1931 | |||
1932 | /* mute mono out if HP or Line out is plugged */ | ||
1933 | static void via_mono_automute(struct hda_codec *codec) | ||
1934 | { | ||
1935 | unsigned int hp_present, lineout_present; | ||
1936 | struct via_spec *spec = codec->spec; | ||
1937 | |||
1938 | if (spec->codec_type != VT1716S) | ||
1939 | return; | ||
1940 | |||
1941 | lineout_present = snd_hda_jack_detect(codec, | ||
1942 | spec->autocfg.line_out_pins[0]); | ||
1943 | |||
1944 | /* Mute Mono Out if Line Out is plugged */ | ||
1945 | if (lineout_present) { | ||
1946 | snd_hda_codec_amp_stereo( | ||
1947 | codec, 0x2A, HDA_OUTPUT, 0, HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
1948 | return; | ||
1949 | } | ||
1950 | |||
1951 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); | ||
1952 | |||
1953 | if (!spec->hp_independent_mode) | ||
1954 | snd_hda_codec_amp_stereo( | ||
1955 | codec, 0x2A, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
1956 | hp_present ? HDA_AMP_MUTE : 0); | ||
921 | } | 1957 | } |
922 | 1958 | ||
923 | static void via_gpio_control(struct hda_codec *codec) | 1959 | static void via_gpio_control(struct hda_codec *codec) |
@@ -968,15 +2004,83 @@ static void via_gpio_control(struct hda_codec *codec) | |||
968 | } | 2004 | } |
969 | } | 2005 | } |
970 | 2006 | ||
2007 | /* mute Internal-Speaker if HP is plugged */ | ||
2008 | static void via_speaker_automute(struct hda_codec *codec) | ||
2009 | { | ||
2010 | unsigned int hp_present; | ||
2011 | struct via_spec *spec = codec->spec; | ||
2012 | |||
2013 | if (spec->codec_type != VT2002P && spec->codec_type != VT1812) | ||
2014 | return; | ||
2015 | |||
2016 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); | ||
2017 | |||
2018 | if (!spec->hp_independent_mode) { | ||
2019 | struct snd_ctl_elem_id id; | ||
2020 | snd_hda_codec_amp_stereo( | ||
2021 | codec, spec->autocfg.speaker_pins[0], HDA_OUTPUT, 0, | ||
2022 | HDA_AMP_MUTE, hp_present ? HDA_AMP_MUTE : 0); | ||
2023 | /* notify change */ | ||
2024 | memset(&id, 0, sizeof(id)); | ||
2025 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
2026 | strcpy(id.name, "Speaker Playback Switch"); | ||
2027 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
2028 | &id); | ||
2029 | } | ||
2030 | } | ||
2031 | |||
2032 | /* mute line-out and internal speaker if HP is plugged */ | ||
2033 | static void via_hp_bind_automute(struct hda_codec *codec) | ||
2034 | { | ||
2035 | /* use long instead of int below just to avoid an internal compiler | ||
2036 | * error with gcc 4.0.x | ||
2037 | */ | ||
2038 | unsigned long hp_present, present = 0; | ||
2039 | struct via_spec *spec = codec->spec; | ||
2040 | int i; | ||
2041 | |||
2042 | if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0]) | ||
2043 | return; | ||
2044 | |||
2045 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); | ||
2046 | |||
2047 | present = snd_hda_jack_detect(codec, spec->autocfg.line_out_pins[0]); | ||
2048 | |||
2049 | if (!spec->hp_independent_mode) { | ||
2050 | /* Mute Line-Outs */ | ||
2051 | for (i = 0; i < spec->autocfg.line_outs; i++) | ||
2052 | snd_hda_codec_amp_stereo( | ||
2053 | codec, spec->autocfg.line_out_pins[i], | ||
2054 | HDA_OUTPUT, 0, | ||
2055 | HDA_AMP_MUTE, hp_present ? HDA_AMP_MUTE : 0); | ||
2056 | if (hp_present) | ||
2057 | present = hp_present; | ||
2058 | } | ||
2059 | /* Speakers */ | ||
2060 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | ||
2061 | snd_hda_codec_amp_stereo( | ||
2062 | codec, spec->autocfg.speaker_pins[i], HDA_OUTPUT, 0, | ||
2063 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
2064 | } | ||
2065 | |||
2066 | |||
971 | /* unsolicited event for jack sensing */ | 2067 | /* unsolicited event for jack sensing */ |
972 | static void via_unsol_event(struct hda_codec *codec, | 2068 | static void via_unsol_event(struct hda_codec *codec, |
973 | unsigned int res) | 2069 | unsigned int res) |
974 | { | 2070 | { |
975 | res >>= 26; | 2071 | res >>= 26; |
976 | if (res == VIA_HP_EVENT) | 2072 | if (res & VIA_HP_EVENT) |
977 | via_hp_automute(codec); | 2073 | via_hp_automute(codec); |
978 | else if (res == VIA_GPIO_EVENT) | 2074 | if (res & VIA_GPIO_EVENT) |
979 | via_gpio_control(codec); | 2075 | via_gpio_control(codec); |
2076 | if (res & VIA_JACK_EVENT) | ||
2077 | set_jack_power_state(codec); | ||
2078 | if (res & VIA_MONO_EVENT) | ||
2079 | via_mono_automute(codec); | ||
2080 | if (res & VIA_SPEAKER_EVENT) | ||
2081 | via_speaker_automute(codec); | ||
2082 | if (res & VIA_BIND_HP_EVENT) | ||
2083 | via_hp_bind_automute(codec); | ||
980 | } | 2084 | } |
981 | 2085 | ||
982 | static int via_init(struct hda_codec *codec) | 2086 | static int via_init(struct hda_codec *codec) |
@@ -986,6 +2090,10 @@ static int via_init(struct hda_codec *codec) | |||
986 | for (i = 0; i < spec->num_iverbs; i++) | 2090 | for (i = 0; i < spec->num_iverbs; i++) |
987 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | 2091 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
988 | 2092 | ||
2093 | spec->codec_type = get_codec_type(codec); | ||
2094 | if (spec->codec_type == VT1708BCE) | ||
2095 | spec->codec_type = VT1708S; /* VT1708BCE & VT1708S are almost | ||
2096 | same */ | ||
989 | /* Lydia Add for EAPD enable */ | 2097 | /* Lydia Add for EAPD enable */ |
990 | if (!spec->dig_in_nid) { /* No Digital In connection */ | 2098 | if (!spec->dig_in_nid) { /* No Digital In connection */ |
991 | if (spec->dig_in_pin) { | 2099 | if (spec->dig_in_pin) { |
@@ -1003,8 +2111,17 @@ static int via_init(struct hda_codec *codec) | |||
1003 | if (spec->slave_dig_outs[0]) | 2111 | if (spec->slave_dig_outs[0]) |
1004 | codec->slave_dig_outs = spec->slave_dig_outs; | 2112 | codec->slave_dig_outs = spec->slave_dig_outs; |
1005 | 2113 | ||
1006 | return 0; | 2114 | return 0; |
2115 | } | ||
2116 | |||
2117 | #ifdef SND_HDA_NEEDS_RESUME | ||
2118 | static int via_suspend(struct hda_codec *codec, pm_message_t state) | ||
2119 | { | ||
2120 | struct via_spec *spec = codec->spec; | ||
2121 | vt1708_stop_hp_work(spec); | ||
2122 | return 0; | ||
1007 | } | 2123 | } |
2124 | #endif | ||
1008 | 2125 | ||
1009 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2126 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
1010 | static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) | 2127 | static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
@@ -1021,6 +2138,9 @@ static struct hda_codec_ops via_patch_ops = { | |||
1021 | .build_pcms = via_build_pcms, | 2138 | .build_pcms = via_build_pcms, |
1022 | .init = via_init, | 2139 | .init = via_init, |
1023 | .free = via_free, | 2140 | .free = via_free, |
2141 | #ifdef SND_HDA_NEEDS_RESUME | ||
2142 | .suspend = via_suspend, | ||
2143 | #endif | ||
1024 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2144 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
1025 | .check_power_status = via_check_power_status, | 2145 | .check_power_status = via_check_power_status, |
1026 | #endif | 2146 | #endif |
@@ -1036,8 +2156,8 @@ static int vt1708_auto_fill_dac_nids(struct via_spec *spec, | |||
1036 | spec->multiout.num_dacs = cfg->line_outs; | 2156 | spec->multiout.num_dacs = cfg->line_outs; |
1037 | 2157 | ||
1038 | spec->multiout.dac_nids = spec->private_dac_nids; | 2158 | spec->multiout.dac_nids = spec->private_dac_nids; |
1039 | 2159 | ||
1040 | for(i = 0; i < 4; i++) { | 2160 | for (i = 0; i < 4; i++) { |
1041 | nid = cfg->line_out_pins[i]; | 2161 | nid = cfg->line_out_pins[i]; |
1042 | if (nid) { | 2162 | if (nid) { |
1043 | /* config dac list */ | 2163 | /* config dac list */ |
@@ -1067,7 +2187,7 @@ static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec, | |||
1067 | { | 2187 | { |
1068 | char name[32]; | 2188 | char name[32]; |
1069 | static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; | 2189 | static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; |
1070 | hda_nid_t nid, nid_vol = 0; | 2190 | hda_nid_t nid, nid_vol, nid_vols[] = {0x17, 0x19, 0x1a, 0x1b}; |
1071 | int i, err; | 2191 | int i, err; |
1072 | 2192 | ||
1073 | for (i = 0; i <= AUTO_SEQ_SIDE; i++) { | 2193 | for (i = 0; i <= AUTO_SEQ_SIDE; i++) { |
@@ -1075,9 +2195,8 @@ static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec, | |||
1075 | 2195 | ||
1076 | if (!nid) | 2196 | if (!nid) |
1077 | continue; | 2197 | continue; |
1078 | 2198 | ||
1079 | if (i != AUTO_SEQ_FRONT) | 2199 | nid_vol = nid_vols[i]; |
1080 | nid_vol = 0x18 + i; | ||
1081 | 2200 | ||
1082 | if (i == AUTO_SEQ_CENLFE) { | 2201 | if (i == AUTO_SEQ_CENLFE) { |
1083 | /* Center/LFE */ | 2202 | /* Center/LFE */ |
@@ -1105,21 +2224,21 @@ static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec, | |||
1105 | HDA_OUTPUT)); | 2224 | HDA_OUTPUT)); |
1106 | if (err < 0) | 2225 | if (err < 0) |
1107 | return err; | 2226 | return err; |
1108 | } else if (i == AUTO_SEQ_FRONT){ | 2227 | } else if (i == AUTO_SEQ_FRONT) { |
1109 | /* add control to mixer index 0 */ | 2228 | /* add control to mixer index 0 */ |
1110 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 2229 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
1111 | "Master Front Playback Volume", | 2230 | "Master Front Playback Volume", |
1112 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, | 2231 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1113 | HDA_INPUT)); | 2232 | HDA_INPUT)); |
1114 | if (err < 0) | 2233 | if (err < 0) |
1115 | return err; | 2234 | return err; |
1116 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | 2235 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, |
1117 | "Master Front Playback Switch", | 2236 | "Master Front Playback Switch", |
1118 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, | 2237 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1119 | HDA_INPUT)); | 2238 | HDA_INPUT)); |
1120 | if (err < 0) | 2239 | if (err < 0) |
1121 | return err; | 2240 | return err; |
1122 | 2241 | ||
1123 | /* add control to PW3 */ | 2242 | /* add control to PW3 */ |
1124 | sprintf(name, "%s Playback Volume", chname[i]); | 2243 | sprintf(name, "%s Playback Volume", chname[i]); |
1125 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, | 2244 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, |
@@ -1178,6 +2297,7 @@ static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
1178 | return 0; | 2297 | return 0; |
1179 | 2298 | ||
1180 | spec->multiout.hp_nid = VT1708_HP_NID; /* AOW3 */ | 2299 | spec->multiout.hp_nid = VT1708_HP_NID; /* AOW3 */ |
2300 | spec->hp_independent_mode_index = 1; | ||
1181 | 2301 | ||
1182 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 2302 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
1183 | "Headphone Playback Volume", | 2303 | "Headphone Playback Volume", |
@@ -1218,7 +2338,7 @@ static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, | |||
1218 | case 0x1d: /* Mic */ | 2338 | case 0x1d: /* Mic */ |
1219 | idx = 2; | 2339 | idx = 2; |
1220 | break; | 2340 | break; |
1221 | 2341 | ||
1222 | case 0x1e: /* Line In */ | 2342 | case 0x1e: /* Line In */ |
1223 | idx = 3; | 2343 | idx = 3; |
1224 | break; | 2344 | break; |
@@ -1231,8 +2351,7 @@ static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, | |||
1231 | idx = 1; | 2351 | idx = 1; |
1232 | break; | 2352 | break; |
1233 | } | 2353 | } |
1234 | err = via_new_analog_input(spec, cfg->input_pins[i], labels[i], | 2354 | err = via_new_analog_input(spec, labels[i], idx, 0x17); |
1235 | idx, 0x17); | ||
1236 | if (err < 0) | 2355 | if (err < 0) |
1237 | return err; | 2356 | return err; |
1238 | imux->items[imux->num_items].label = labels[i]; | 2357 | imux->items[imux->num_items].label = labels[i]; |
@@ -1260,16 +2379,60 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) | |||
1260 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | 2379 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
1261 | seqassoc = (unsigned char) get_defcfg_association(def_conf); | 2380 | seqassoc = (unsigned char) get_defcfg_association(def_conf); |
1262 | seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); | 2381 | seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); |
1263 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) { | 2382 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE |
1264 | if (seqassoc == 0xff) { | 2383 | && (seqassoc == 0xf0 || seqassoc == 0xff)) { |
1265 | def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); | 2384 | def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); |
1266 | snd_hda_codec_set_pincfg(codec, nid, def_conf); | 2385 | snd_hda_codec_set_pincfg(codec, nid, def_conf); |
1267 | } | ||
1268 | } | 2386 | } |
1269 | 2387 | ||
1270 | return; | 2388 | return; |
1271 | } | 2389 | } |
1272 | 2390 | ||
2391 | static int vt1708_jack_detectect_get(struct snd_kcontrol *kcontrol, | ||
2392 | struct snd_ctl_elem_value *ucontrol) | ||
2393 | { | ||
2394 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2395 | struct via_spec *spec = codec->spec; | ||
2396 | |||
2397 | if (spec->codec_type != VT1708) | ||
2398 | return 0; | ||
2399 | spec->vt1708_jack_detectect = | ||
2400 | !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1); | ||
2401 | ucontrol->value.integer.value[0] = spec->vt1708_jack_detectect; | ||
2402 | return 0; | ||
2403 | } | ||
2404 | |||
2405 | static int vt1708_jack_detectect_put(struct snd_kcontrol *kcontrol, | ||
2406 | struct snd_ctl_elem_value *ucontrol) | ||
2407 | { | ||
2408 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2409 | struct via_spec *spec = codec->spec; | ||
2410 | int change; | ||
2411 | |||
2412 | if (spec->codec_type != VT1708) | ||
2413 | return 0; | ||
2414 | spec->vt1708_jack_detectect = ucontrol->value.integer.value[0]; | ||
2415 | change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) | ||
2416 | == !spec->vt1708_jack_detectect; | ||
2417 | if (spec->vt1708_jack_detectect) { | ||
2418 | mute_aa_path(codec, 1); | ||
2419 | notify_aa_path_ctls(codec); | ||
2420 | } | ||
2421 | return change; | ||
2422 | } | ||
2423 | |||
2424 | static struct snd_kcontrol_new vt1708_jack_detectect[] = { | ||
2425 | { | ||
2426 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2427 | .name = "Jack Detect", | ||
2428 | .count = 1, | ||
2429 | .info = snd_ctl_boolean_mono_info, | ||
2430 | .get = vt1708_jack_detectect_get, | ||
2431 | .put = vt1708_jack_detectect_put, | ||
2432 | }, | ||
2433 | {} /* end */ | ||
2434 | }; | ||
2435 | |||
1273 | static int vt1708_parse_auto_config(struct hda_codec *codec) | 2436 | static int vt1708_parse_auto_config(struct hda_codec *codec) |
1274 | { | 2437 | { |
1275 | struct via_spec *spec = codec->spec; | 2438 | struct via_spec *spec = codec->spec; |
@@ -1297,6 +2460,10 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) | |||
1297 | err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); | 2460 | err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); |
1298 | if (err < 0) | 2461 | if (err < 0) |
1299 | return err; | 2462 | return err; |
2463 | /* add jack detect on/off control */ | ||
2464 | err = snd_hda_add_new_ctls(codec, vt1708_jack_detectect); | ||
2465 | if (err < 0) | ||
2466 | return err; | ||
1300 | 2467 | ||
1301 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | 2468 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
1302 | 2469 | ||
@@ -1316,19 +2483,44 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) | |||
1316 | if (spec->hp_mux) | 2483 | if (spec->hp_mux) |
1317 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 2484 | spec->mixers[spec->num_mixers++] = via_hp_mixer; |
1318 | 2485 | ||
2486 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | ||
1319 | return 1; | 2487 | return 1; |
1320 | } | 2488 | } |
1321 | 2489 | ||
1322 | /* init callback for auto-configuration model -- overriding the default init */ | 2490 | /* init callback for auto-configuration model -- overriding the default init */ |
1323 | static int via_auto_init(struct hda_codec *codec) | 2491 | static int via_auto_init(struct hda_codec *codec) |
1324 | { | 2492 | { |
2493 | struct via_spec *spec = codec->spec; | ||
2494 | |||
1325 | via_init(codec); | 2495 | via_init(codec); |
1326 | via_auto_init_multi_out(codec); | 2496 | via_auto_init_multi_out(codec); |
1327 | via_auto_init_hp_out(codec); | 2497 | via_auto_init_hp_out(codec); |
1328 | via_auto_init_analog_input(codec); | 2498 | via_auto_init_analog_input(codec); |
2499 | if (spec->codec_type == VT2002P || spec->codec_type == VT1812) { | ||
2500 | via_hp_bind_automute(codec); | ||
2501 | } else { | ||
2502 | via_hp_automute(codec); | ||
2503 | via_speaker_automute(codec); | ||
2504 | } | ||
2505 | |||
1329 | return 0; | 2506 | return 0; |
1330 | } | 2507 | } |
1331 | 2508 | ||
2509 | static void vt1708_update_hp_jack_state(struct work_struct *work) | ||
2510 | { | ||
2511 | struct via_spec *spec = container_of(work, struct via_spec, | ||
2512 | vt1708_hp_work.work); | ||
2513 | if (spec->codec_type != VT1708) | ||
2514 | return; | ||
2515 | /* if jack state toggled */ | ||
2516 | if (spec->vt1708_hp_present | ||
2517 | != snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) { | ||
2518 | spec->vt1708_hp_present ^= 1; | ||
2519 | via_hp_automute(spec->codec); | ||
2520 | } | ||
2521 | vt1708_start_hp_work(spec); | ||
2522 | } | ||
2523 | |||
1332 | static int get_mux_nids(struct hda_codec *codec) | 2524 | static int get_mux_nids(struct hda_codec *codec) |
1333 | { | 2525 | { |
1334 | struct via_spec *spec = codec->spec; | 2526 | struct via_spec *spec = codec->spec; |
@@ -1378,7 +2570,7 @@ static int patch_vt1708(struct hda_codec *codec) | |||
1378 | "from BIOS. Using genenic mode...\n"); | 2570 | "from BIOS. Using genenic mode...\n"); |
1379 | } | 2571 | } |
1380 | 2572 | ||
1381 | 2573 | ||
1382 | spec->stream_name_analog = "VT1708 Analog"; | 2574 | spec->stream_name_analog = "VT1708 Analog"; |
1383 | spec->stream_analog_playback = &vt1708_pcm_analog_playback; | 2575 | spec->stream_analog_playback = &vt1708_pcm_analog_playback; |
1384 | /* disable 32bit format on VT1708 */ | 2576 | /* disable 32bit format on VT1708 */ |
@@ -1390,7 +2582,7 @@ static int patch_vt1708(struct hda_codec *codec) | |||
1390 | spec->stream_digital_playback = &vt1708_pcm_digital_playback; | 2582 | spec->stream_digital_playback = &vt1708_pcm_digital_playback; |
1391 | spec->stream_digital_capture = &vt1708_pcm_digital_capture; | 2583 | spec->stream_digital_capture = &vt1708_pcm_digital_capture; |
1392 | 2584 | ||
1393 | 2585 | ||
1394 | if (!spec->adc_nids && spec->input_mux) { | 2586 | if (!spec->adc_nids && spec->input_mux) { |
1395 | spec->adc_nids = vt1708_adc_nids; | 2587 | spec->adc_nids = vt1708_adc_nids; |
1396 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); | 2588 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); |
@@ -1405,7 +2597,8 @@ static int patch_vt1708(struct hda_codec *codec) | |||
1405 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2597 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
1406 | spec->loopback.amplist = vt1708_loopbacks; | 2598 | spec->loopback.amplist = vt1708_loopbacks; |
1407 | #endif | 2599 | #endif |
1408 | 2600 | spec->codec = codec; | |
2601 | INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state); | ||
1409 | return 0; | 2602 | return 0; |
1410 | } | 2603 | } |
1411 | 2604 | ||
@@ -1433,7 +2626,8 @@ static struct snd_kcontrol_new vt1709_capture_mixer[] = { | |||
1433 | }; | 2626 | }; |
1434 | 2627 | ||
1435 | static struct hda_verb vt1709_uniwill_init_verbs[] = { | 2628 | static struct hda_verb vt1709_uniwill_init_verbs[] = { |
1436 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_HP_EVENT}, | 2629 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, |
2630 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, | ||
1437 | { } | 2631 | { } |
1438 | }; | 2632 | }; |
1439 | 2633 | ||
@@ -1473,8 +2667,8 @@ static struct hda_verb vt1709_10ch_volume_init_verbs[] = { | |||
1473 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 2667 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1474 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 2668 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1475 | 2669 | ||
1476 | /* Set input of PW4 as AOW4 */ | 2670 | /* Set input of PW4 as MW0 */ |
1477 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x1}, | 2671 | {0x20, AC_VERB_SET_CONNECT_SEL, 0}, |
1478 | /* PW9 Output enable */ | 2672 | /* PW9 Output enable */ |
1479 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2673 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
1480 | { } | 2674 | { } |
@@ -1487,8 +2681,8 @@ static struct hda_pcm_stream vt1709_10ch_pcm_analog_playback = { | |||
1487 | .nid = 0x10, /* NID to query formats and rates */ | 2681 | .nid = 0x10, /* NID to query formats and rates */ |
1488 | .ops = { | 2682 | .ops = { |
1489 | .open = via_playback_pcm_open, | 2683 | .open = via_playback_pcm_open, |
1490 | .prepare = via_playback_pcm_prepare, | 2684 | .prepare = via_playback_multi_pcm_prepare, |
1491 | .cleanup = via_playback_pcm_cleanup | 2685 | .cleanup = via_playback_multi_pcm_cleanup, |
1492 | }, | 2686 | }, |
1493 | }; | 2687 | }; |
1494 | 2688 | ||
@@ -1499,8 +2693,8 @@ static struct hda_pcm_stream vt1709_6ch_pcm_analog_playback = { | |||
1499 | .nid = 0x10, /* NID to query formats and rates */ | 2693 | .nid = 0x10, /* NID to query formats and rates */ |
1500 | .ops = { | 2694 | .ops = { |
1501 | .open = via_playback_pcm_open, | 2695 | .open = via_playback_pcm_open, |
1502 | .prepare = via_playback_pcm_prepare, | 2696 | .prepare = via_playback_multi_pcm_prepare, |
1503 | .cleanup = via_playback_pcm_cleanup | 2697 | .cleanup = via_playback_multi_pcm_cleanup, |
1504 | }, | 2698 | }, |
1505 | }; | 2699 | }; |
1506 | 2700 | ||
@@ -1575,11 +2769,11 @@ static int vt1709_auto_fill_dac_nids(struct via_spec *spec, | |||
1575 | spec->multiout.dac_nids[cfg->line_outs] = 0x28; /* AOW4 */ | 2769 | spec->multiout.dac_nids[cfg->line_outs] = 0x28; /* AOW4 */ |
1576 | 2770 | ||
1577 | } else if (cfg->line_outs == 3) { /* 6 channels */ | 2771 | } else if (cfg->line_outs == 3) { /* 6 channels */ |
1578 | for(i = 0; i < cfg->line_outs; i++) { | 2772 | for (i = 0; i < cfg->line_outs; i++) { |
1579 | nid = cfg->line_out_pins[i]; | 2773 | nid = cfg->line_out_pins[i]; |
1580 | if (nid) { | 2774 | if (nid) { |
1581 | /* config dac list */ | 2775 | /* config dac list */ |
1582 | switch(i) { | 2776 | switch (i) { |
1583 | case AUTO_SEQ_FRONT: | 2777 | case AUTO_SEQ_FRONT: |
1584 | /* AOW0 */ | 2778 | /* AOW0 */ |
1585 | spec->multiout.dac_nids[i] = 0x10; | 2779 | spec->multiout.dac_nids[i] = 0x10; |
@@ -1608,56 +2802,58 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, | |||
1608 | { | 2802 | { |
1609 | char name[32]; | 2803 | char name[32]; |
1610 | static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; | 2804 | static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; |
1611 | hda_nid_t nid = 0; | 2805 | hda_nid_t nid, nid_vol, nid_vols[] = {0x18, 0x1a, 0x1b, 0x29}; |
1612 | int i, err; | 2806 | int i, err; |
1613 | 2807 | ||
1614 | for (i = 0; i <= AUTO_SEQ_SIDE; i++) { | 2808 | for (i = 0; i <= AUTO_SEQ_SIDE; i++) { |
1615 | nid = cfg->line_out_pins[i]; | 2809 | nid = cfg->line_out_pins[i]; |
1616 | 2810 | ||
1617 | if (!nid) | 2811 | if (!nid) |
1618 | continue; | 2812 | continue; |
1619 | 2813 | ||
2814 | nid_vol = nid_vols[i]; | ||
2815 | |||
1620 | if (i == AUTO_SEQ_CENLFE) { | 2816 | if (i == AUTO_SEQ_CENLFE) { |
1621 | /* Center/LFE */ | 2817 | /* Center/LFE */ |
1622 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 2818 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
1623 | "Center Playback Volume", | 2819 | "Center Playback Volume", |
1624 | HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, | 2820 | HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, |
1625 | HDA_OUTPUT)); | 2821 | HDA_OUTPUT)); |
1626 | if (err < 0) | 2822 | if (err < 0) |
1627 | return err; | 2823 | return err; |
1628 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 2824 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
1629 | "LFE Playback Volume", | 2825 | "LFE Playback Volume", |
1630 | HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, | 2826 | HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, |
1631 | HDA_OUTPUT)); | 2827 | HDA_OUTPUT)); |
1632 | if (err < 0) | 2828 | if (err < 0) |
1633 | return err; | 2829 | return err; |
1634 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | 2830 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, |
1635 | "Center Playback Switch", | 2831 | "Center Playback Switch", |
1636 | HDA_COMPOSE_AMP_VAL(0x1b, 1, 0, | 2832 | HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, |
1637 | HDA_OUTPUT)); | 2833 | HDA_OUTPUT)); |
1638 | if (err < 0) | 2834 | if (err < 0) |
1639 | return err; | 2835 | return err; |
1640 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | 2836 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, |
1641 | "LFE Playback Switch", | 2837 | "LFE Playback Switch", |
1642 | HDA_COMPOSE_AMP_VAL(0x1b, 2, 0, | 2838 | HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, |
1643 | HDA_OUTPUT)); | 2839 | HDA_OUTPUT)); |
1644 | if (err < 0) | 2840 | if (err < 0) |
1645 | return err; | 2841 | return err; |
1646 | } else if (i == AUTO_SEQ_FRONT){ | 2842 | } else if (i == AUTO_SEQ_FRONT) { |
1647 | /* add control to mixer index 0 */ | 2843 | /* ADD control to mixer index 0 */ |
1648 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 2844 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
1649 | "Master Front Playback Volume", | 2845 | "Master Front Playback Volume", |
1650 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, | 2846 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1651 | HDA_INPUT)); | 2847 | HDA_INPUT)); |
1652 | if (err < 0) | 2848 | if (err < 0) |
1653 | return err; | 2849 | return err; |
1654 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | 2850 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, |
1655 | "Master Front Playback Switch", | 2851 | "Master Front Playback Switch", |
1656 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, | 2852 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1657 | HDA_INPUT)); | 2853 | HDA_INPUT)); |
1658 | if (err < 0) | 2854 | if (err < 0) |
1659 | return err; | 2855 | return err; |
1660 | 2856 | ||
1661 | /* add control to PW3 */ | 2857 | /* add control to PW3 */ |
1662 | sprintf(name, "%s Playback Volume", chname[i]); | 2858 | sprintf(name, "%s Playback Volume", chname[i]); |
1663 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, | 2859 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, |
@@ -1674,26 +2870,26 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, | |||
1674 | } else if (i == AUTO_SEQ_SURROUND) { | 2870 | } else if (i == AUTO_SEQ_SURROUND) { |
1675 | sprintf(name, "%s Playback Volume", chname[i]); | 2871 | sprintf(name, "%s Playback Volume", chname[i]); |
1676 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, | 2872 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, |
1677 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, | 2873 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1678 | HDA_OUTPUT)); | 2874 | HDA_OUTPUT)); |
1679 | if (err < 0) | 2875 | if (err < 0) |
1680 | return err; | 2876 | return err; |
1681 | sprintf(name, "%s Playback Switch", chname[i]); | 2877 | sprintf(name, "%s Playback Switch", chname[i]); |
1682 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, | 2878 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, |
1683 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, | 2879 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1684 | HDA_OUTPUT)); | 2880 | HDA_OUTPUT)); |
1685 | if (err < 0) | 2881 | if (err < 0) |
1686 | return err; | 2882 | return err; |
1687 | } else if (i == AUTO_SEQ_SIDE) { | 2883 | } else if (i == AUTO_SEQ_SIDE) { |
1688 | sprintf(name, "%s Playback Volume", chname[i]); | 2884 | sprintf(name, "%s Playback Volume", chname[i]); |
1689 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, | 2885 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, |
1690 | HDA_COMPOSE_AMP_VAL(0x29, 3, 0, | 2886 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1691 | HDA_OUTPUT)); | 2887 | HDA_OUTPUT)); |
1692 | if (err < 0) | 2888 | if (err < 0) |
1693 | return err; | 2889 | return err; |
1694 | sprintf(name, "%s Playback Switch", chname[i]); | 2890 | sprintf(name, "%s Playback Switch", chname[i]); |
1695 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, | 2891 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, |
1696 | HDA_COMPOSE_AMP_VAL(0x29, 3, 0, | 2892 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, |
1697 | HDA_OUTPUT)); | 2893 | HDA_OUTPUT)); |
1698 | if (err < 0) | 2894 | if (err < 0) |
1699 | return err; | 2895 | return err; |
@@ -1714,6 +2910,7 @@ static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
1714 | spec->multiout.hp_nid = VT1709_HP_DAC_NID; | 2910 | spec->multiout.hp_nid = VT1709_HP_DAC_NID; |
1715 | else if (spec->multiout.num_dacs == 3) /* 6 channels */ | 2911 | else if (spec->multiout.num_dacs == 3) /* 6 channels */ |
1716 | spec->multiout.hp_nid = 0; | 2912 | spec->multiout.hp_nid = 0; |
2913 | spec->hp_independent_mode_index = 1; | ||
1717 | 2914 | ||
1718 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 2915 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
1719 | "Headphone Playback Volume", | 2916 | "Headphone Playback Volume", |
@@ -1752,7 +2949,7 @@ static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, | |||
1752 | case 0x1d: /* Mic */ | 2949 | case 0x1d: /* Mic */ |
1753 | idx = 2; | 2950 | idx = 2; |
1754 | break; | 2951 | break; |
1755 | 2952 | ||
1756 | case 0x1e: /* Line In */ | 2953 | case 0x1e: /* Line In */ |
1757 | idx = 3; | 2954 | idx = 3; |
1758 | break; | 2955 | break; |
@@ -1765,8 +2962,7 @@ static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, | |||
1765 | idx = 1; | 2962 | idx = 1; |
1766 | break; | 2963 | break; |
1767 | } | 2964 | } |
1768 | err = via_new_analog_input(spec, cfg->input_pins[i], labels[i], | 2965 | err = via_new_analog_input(spec, labels[i], idx, 0x18); |
1769 | idx, 0x18); | ||
1770 | if (err < 0) | 2966 | if (err < 0) |
1771 | return err; | 2967 | return err; |
1772 | imux->items[imux->num_items].label = labels[i]; | 2968 | imux->items[imux->num_items].label = labels[i]; |
@@ -1816,6 +3012,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec) | |||
1816 | if (spec->hp_mux) | 3012 | if (spec->hp_mux) |
1817 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 3013 | spec->mixers[spec->num_mixers++] = via_hp_mixer; |
1818 | 3014 | ||
3015 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | ||
1819 | return 1; | 3016 | return 1; |
1820 | } | 3017 | } |
1821 | 3018 | ||
@@ -1861,7 +3058,7 @@ static int patch_vt1709_10ch(struct hda_codec *codec) | |||
1861 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; | 3058 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; |
1862 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; | 3059 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; |
1863 | 3060 | ||
1864 | 3061 | ||
1865 | if (!spec->adc_nids && spec->input_mux) { | 3062 | if (!spec->adc_nids && spec->input_mux) { |
1866 | spec->adc_nids = vt1709_adc_nids; | 3063 | spec->adc_nids = vt1709_adc_nids; |
1867 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); | 3064 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); |
@@ -1955,7 +3152,7 @@ static int patch_vt1709_6ch(struct hda_codec *codec) | |||
1955 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; | 3152 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; |
1956 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; | 3153 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; |
1957 | 3154 | ||
1958 | 3155 | ||
1959 | if (!spec->adc_nids && spec->input_mux) { | 3156 | if (!spec->adc_nids && spec->input_mux) { |
1960 | spec->adc_nids = vt1709_adc_nids; | 3157 | spec->adc_nids = vt1709_adc_nids; |
1961 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); | 3158 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); |
@@ -2024,7 +3221,7 @@ static struct hda_verb vt1708B_8ch_volume_init_verbs[] = { | |||
2024 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 3221 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2025 | 3222 | ||
2026 | /* Setup default input to PW4 */ | 3223 | /* Setup default input to PW4 */ |
2027 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, | 3224 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0}, |
2028 | /* PW9 Output enable */ | 3225 | /* PW9 Output enable */ |
2029 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 3226 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
2030 | /* PW10 Input enable */ | 3227 | /* PW10 Input enable */ |
@@ -2068,10 +3265,29 @@ static struct hda_verb vt1708B_4ch_volume_init_verbs[] = { | |||
2068 | }; | 3265 | }; |
2069 | 3266 | ||
2070 | static struct hda_verb vt1708B_uniwill_init_verbs[] = { | 3267 | static struct hda_verb vt1708B_uniwill_init_verbs[] = { |
2071 | {0x1D, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_HP_EVENT}, | 3268 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, |
3269 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, | ||
3270 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3271 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3272 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3273 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3274 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3275 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3276 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
2072 | { } | 3277 | { } |
2073 | }; | 3278 | }; |
2074 | 3279 | ||
3280 | static int via_pcm_open_close(struct hda_pcm_stream *hinfo, | ||
3281 | struct hda_codec *codec, | ||
3282 | struct snd_pcm_substream *substream) | ||
3283 | { | ||
3284 | int idle = substream->pstr->substream_opened == 1 | ||
3285 | && substream->ref_count == 0; | ||
3286 | |||
3287 | analog_low_current_mode(codec, idle); | ||
3288 | return 0; | ||
3289 | } | ||
3290 | |||
2075 | static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = { | 3291 | static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = { |
2076 | .substreams = 2, | 3292 | .substreams = 2, |
2077 | .channels_min = 2, | 3293 | .channels_min = 2, |
@@ -2080,7 +3296,8 @@ static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = { | |||
2080 | .ops = { | 3296 | .ops = { |
2081 | .open = via_playback_pcm_open, | 3297 | .open = via_playback_pcm_open, |
2082 | .prepare = via_playback_multi_pcm_prepare, | 3298 | .prepare = via_playback_multi_pcm_prepare, |
2083 | .cleanup = via_playback_multi_pcm_cleanup | 3299 | .cleanup = via_playback_multi_pcm_cleanup, |
3300 | .close = via_pcm_open_close | ||
2084 | }, | 3301 | }, |
2085 | }; | 3302 | }; |
2086 | 3303 | ||
@@ -2102,8 +3319,10 @@ static struct hda_pcm_stream vt1708B_pcm_analog_capture = { | |||
2102 | .channels_max = 2, | 3319 | .channels_max = 2, |
2103 | .nid = 0x13, /* NID to query formats and rates */ | 3320 | .nid = 0x13, /* NID to query formats and rates */ |
2104 | .ops = { | 3321 | .ops = { |
3322 | .open = via_pcm_open_close, | ||
2105 | .prepare = via_capture_pcm_prepare, | 3323 | .prepare = via_capture_pcm_prepare, |
2106 | .cleanup = via_capture_pcm_cleanup | 3324 | .cleanup = via_capture_pcm_cleanup, |
3325 | .close = via_pcm_open_close | ||
2107 | }, | 3326 | }, |
2108 | }; | 3327 | }; |
2109 | 3328 | ||
@@ -2260,6 +3479,7 @@ static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
2260 | return 0; | 3479 | return 0; |
2261 | 3480 | ||
2262 | spec->multiout.hp_nid = VT1708B_HP_NID; /* AOW3 */ | 3481 | spec->multiout.hp_nid = VT1708B_HP_NID; /* AOW3 */ |
3482 | spec->hp_independent_mode_index = 1; | ||
2263 | 3483 | ||
2264 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 3484 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
2265 | "Headphone Playback Volume", | 3485 | "Headphone Playback Volume", |
@@ -2313,8 +3533,7 @@ static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec, | |||
2313 | idx = 1; | 3533 | idx = 1; |
2314 | break; | 3534 | break; |
2315 | } | 3535 | } |
2316 | err = via_new_analog_input(spec, cfg->input_pins[i], labels[i], | 3536 | err = via_new_analog_input(spec, labels[i], idx, 0x16); |
2317 | idx, 0x16); | ||
2318 | if (err < 0) | 3537 | if (err < 0) |
2319 | return err; | 3538 | return err; |
2320 | imux->items[imux->num_items].label = labels[i]; | 3539 | imux->items[imux->num_items].label = labels[i]; |
@@ -2364,6 +3583,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec) | |||
2364 | if (spec->hp_mux) | 3583 | if (spec->hp_mux) |
2365 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 3584 | spec->mixers[spec->num_mixers++] = via_hp_mixer; |
2366 | 3585 | ||
3586 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | ||
2367 | return 1; | 3587 | return 1; |
2368 | } | 3588 | } |
2369 | 3589 | ||
@@ -2376,12 +3596,14 @@ static struct hda_amp_list vt1708B_loopbacks[] = { | |||
2376 | { } /* end */ | 3596 | { } /* end */ |
2377 | }; | 3597 | }; |
2378 | #endif | 3598 | #endif |
2379 | 3599 | static int patch_vt1708S(struct hda_codec *codec); | |
2380 | static int patch_vt1708B_8ch(struct hda_codec *codec) | 3600 | static int patch_vt1708B_8ch(struct hda_codec *codec) |
2381 | { | 3601 | { |
2382 | struct via_spec *spec; | 3602 | struct via_spec *spec; |
2383 | int err; | 3603 | int err; |
2384 | 3604 | ||
3605 | if (get_codec_type(codec) == VT1708BCE) | ||
3606 | return patch_vt1708S(codec); | ||
2385 | /* create a codec specific record */ | 3607 | /* create a codec specific record */ |
2386 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3608 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
2387 | if (spec == NULL) | 3609 | if (spec == NULL) |
@@ -2483,29 +3705,15 @@ static int patch_vt1708B_4ch(struct hda_codec *codec) | |||
2483 | 3705 | ||
2484 | /* Patch for VT1708S */ | 3706 | /* Patch for VT1708S */ |
2485 | 3707 | ||
2486 | /* VT1708S software backdoor based override for buggy hardware micboost | ||
2487 | * setting */ | ||
2488 | #define MIC_BOOST_VOLUME(xname, nid) { \ | ||
2489 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
2490 | .name = xname, \ | ||
2491 | .index = 0, \ | ||
2492 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
2493 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | ||
2494 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | ||
2495 | .info = mic_boost_volume_info, \ | ||
2496 | .get = snd_hda_mixer_amp_volume_get, \ | ||
2497 | .put = snd_hda_mixer_amp_volume_put, \ | ||
2498 | .tlv = { .c = mic_boost_tlv }, \ | ||
2499 | .private_value = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT) } | ||
2500 | |||
2501 | /* capture mixer elements */ | 3708 | /* capture mixer elements */ |
2502 | static struct snd_kcontrol_new vt1708S_capture_mixer[] = { | 3709 | static struct snd_kcontrol_new vt1708S_capture_mixer[] = { |
2503 | HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT), | 3710 | HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT), |
2504 | HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT), | 3711 | HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT), |
2505 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT), | 3712 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT), |
2506 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT), | 3713 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT), |
2507 | MIC_BOOST_VOLUME("Mic Boost Capture Volume", 0x1A), | 3714 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT), |
2508 | MIC_BOOST_VOLUME("Front Mic Boost Capture Volume", 0x1E), | 3715 | HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0, |
3716 | HDA_INPUT), | ||
2509 | { | 3717 | { |
2510 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 3718 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2511 | /* The multiple "Capture Source" controls confuse alsamixer | 3719 | /* The multiple "Capture Source" controls confuse alsamixer |
@@ -2542,11 +3750,21 @@ static struct hda_verb vt1708S_volume_init_verbs[] = { | |||
2542 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 3750 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
2543 | /* Enable Mic Boost Volume backdoor */ | 3751 | /* Enable Mic Boost Volume backdoor */ |
2544 | {0x1, 0xf98, 0x1}, | 3752 | {0x1, 0xf98, 0x1}, |
3753 | /* don't bybass mixer */ | ||
3754 | {0x1, 0xf88, 0xc0}, | ||
2545 | { } | 3755 | { } |
2546 | }; | 3756 | }; |
2547 | 3757 | ||
2548 | static struct hda_verb vt1708S_uniwill_init_verbs[] = { | 3758 | static struct hda_verb vt1708S_uniwill_init_verbs[] = { |
2549 | {0x1D, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_HP_EVENT}, | 3759 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, |
3760 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, | ||
3761 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3762 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3763 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3764 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3765 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3766 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
3767 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
2550 | { } | 3768 | { } |
2551 | }; | 3769 | }; |
2552 | 3770 | ||
@@ -2557,8 +3775,9 @@ static struct hda_pcm_stream vt1708S_pcm_analog_playback = { | |||
2557 | .nid = 0x10, /* NID to query formats and rates */ | 3775 | .nid = 0x10, /* NID to query formats and rates */ |
2558 | .ops = { | 3776 | .ops = { |
2559 | .open = via_playback_pcm_open, | 3777 | .open = via_playback_pcm_open, |
2560 | .prepare = via_playback_pcm_prepare, | 3778 | .prepare = via_playback_multi_pcm_prepare, |
2561 | .cleanup = via_playback_pcm_cleanup | 3779 | .cleanup = via_playback_multi_pcm_cleanup, |
3780 | .close = via_pcm_open_close | ||
2562 | }, | 3781 | }, |
2563 | }; | 3782 | }; |
2564 | 3783 | ||
@@ -2568,8 +3787,10 @@ static struct hda_pcm_stream vt1708S_pcm_analog_capture = { | |||
2568 | .channels_max = 2, | 3787 | .channels_max = 2, |
2569 | .nid = 0x13, /* NID to query formats and rates */ | 3788 | .nid = 0x13, /* NID to query formats and rates */ |
2570 | .ops = { | 3789 | .ops = { |
3790 | .open = via_pcm_open_close, | ||
2571 | .prepare = via_capture_pcm_prepare, | 3791 | .prepare = via_capture_pcm_prepare, |
2572 | .cleanup = via_capture_pcm_cleanup | 3792 | .cleanup = via_capture_pcm_cleanup, |
3793 | .close = via_pcm_open_close | ||
2573 | }, | 3794 | }, |
2574 | }; | 3795 | }; |
2575 | 3796 | ||
@@ -2726,6 +3947,7 @@ static int vt1708S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
2726 | return 0; | 3947 | return 0; |
2727 | 3948 | ||
2728 | spec->multiout.hp_nid = VT1708S_HP_NID; /* AOW3 */ | 3949 | spec->multiout.hp_nid = VT1708S_HP_NID; /* AOW3 */ |
3950 | spec->hp_independent_mode_index = 1; | ||
2729 | 3951 | ||
2730 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 3952 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
2731 | "Headphone Playback Volume", | 3953 | "Headphone Playback Volume", |
@@ -2780,8 +4002,7 @@ static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, | |||
2780 | idx = 1; | 4002 | idx = 1; |
2781 | break; | 4003 | break; |
2782 | } | 4004 | } |
2783 | err = via_new_analog_input(spec, cfg->input_pins[i], labels[i], | 4005 | err = via_new_analog_input(spec, labels[i], idx, 0x16); |
2784 | idx, 0x16); | ||
2785 | if (err < 0) | 4006 | if (err < 0) |
2786 | return err; | 4007 | return err; |
2787 | imux->items[imux->num_items].label = labels[i]; | 4008 | imux->items[imux->num_items].label = labels[i]; |
@@ -2852,6 +4073,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec) | |||
2852 | if (spec->hp_mux) | 4073 | if (spec->hp_mux) |
2853 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 4074 | spec->mixers[spec->num_mixers++] = via_hp_mixer; |
2854 | 4075 | ||
4076 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | ||
2855 | return 1; | 4077 | return 1; |
2856 | } | 4078 | } |
2857 | 4079 | ||
@@ -2865,6 +4087,16 @@ static struct hda_amp_list vt1708S_loopbacks[] = { | |||
2865 | }; | 4087 | }; |
2866 | #endif | 4088 | #endif |
2867 | 4089 | ||
4090 | static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, | ||
4091 | int offset, int num_steps, int step_size) | ||
4092 | { | ||
4093 | snd_hda_override_amp_caps(codec, pin, HDA_INPUT, | ||
4094 | (offset << AC_AMPCAP_OFFSET_SHIFT) | | ||
4095 | (num_steps << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
4096 | (step_size << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
4097 | (0 << AC_AMPCAP_MUTE_SHIFT)); | ||
4098 | } | ||
4099 | |||
2868 | static int patch_vt1708S(struct hda_codec *codec) | 4100 | static int patch_vt1708S(struct hda_codec *codec) |
2869 | { | 4101 | { |
2870 | struct via_spec *spec; | 4102 | struct via_spec *spec; |
@@ -2890,17 +4122,25 @@ static int patch_vt1708S(struct hda_codec *codec) | |||
2890 | spec->init_verbs[spec->num_iverbs++] = vt1708S_volume_init_verbs; | 4122 | spec->init_verbs[spec->num_iverbs++] = vt1708S_volume_init_verbs; |
2891 | spec->init_verbs[spec->num_iverbs++] = vt1708S_uniwill_init_verbs; | 4123 | spec->init_verbs[spec->num_iverbs++] = vt1708S_uniwill_init_verbs; |
2892 | 4124 | ||
2893 | spec->stream_name_analog = "VT1708S Analog"; | 4125 | if (codec->vendor_id == 0x11060440) |
4126 | spec->stream_name_analog = "VT1818S Analog"; | ||
4127 | else | ||
4128 | spec->stream_name_analog = "VT1708S Analog"; | ||
2894 | spec->stream_analog_playback = &vt1708S_pcm_analog_playback; | 4129 | spec->stream_analog_playback = &vt1708S_pcm_analog_playback; |
2895 | spec->stream_analog_capture = &vt1708S_pcm_analog_capture; | 4130 | spec->stream_analog_capture = &vt1708S_pcm_analog_capture; |
2896 | 4131 | ||
2897 | spec->stream_name_digital = "VT1708S Digital"; | 4132 | if (codec->vendor_id == 0x11060440) |
4133 | spec->stream_name_digital = "VT1818S Digital"; | ||
4134 | else | ||
4135 | spec->stream_name_digital = "VT1708S Digital"; | ||
2898 | spec->stream_digital_playback = &vt1708S_pcm_digital_playback; | 4136 | spec->stream_digital_playback = &vt1708S_pcm_digital_playback; |
2899 | 4137 | ||
2900 | if (!spec->adc_nids && spec->input_mux) { | 4138 | if (!spec->adc_nids && spec->input_mux) { |
2901 | spec->adc_nids = vt1708S_adc_nids; | 4139 | spec->adc_nids = vt1708S_adc_nids; |
2902 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); | 4140 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); |
2903 | get_mux_nids(codec); | 4141 | get_mux_nids(codec); |
4142 | override_mic_boost(codec, 0x1a, 0, 3, 40); | ||
4143 | override_mic_boost(codec, 0x1e, 0, 3, 40); | ||
2904 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; | 4144 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; |
2905 | spec->num_mixers++; | 4145 | spec->num_mixers++; |
2906 | } | 4146 | } |
@@ -2913,6 +4153,16 @@ static int patch_vt1708S(struct hda_codec *codec) | |||
2913 | spec->loopback.amplist = vt1708S_loopbacks; | 4153 | spec->loopback.amplist = vt1708S_loopbacks; |
2914 | #endif | 4154 | #endif |
2915 | 4155 | ||
4156 | /* correct names for VT1708BCE */ | ||
4157 | if (get_codec_type(codec) == VT1708BCE) { | ||
4158 | kfree(codec->chip_name); | ||
4159 | codec->chip_name = kstrdup("VT1708BCE", GFP_KERNEL); | ||
4160 | snprintf(codec->bus->card->mixername, | ||
4161 | sizeof(codec->bus->card->mixername), | ||
4162 | "%s %s", codec->vendor_name, codec->chip_name); | ||
4163 | spec->stream_name_analog = "VT1708BCE Analog"; | ||
4164 | spec->stream_name_digital = "VT1708BCE Digital"; | ||
4165 | } | ||
2916 | return 0; | 4166 | return 0; |
2917 | } | 4167 | } |
2918 | 4168 | ||
@@ -2967,12 +4217,20 @@ static struct hda_verb vt1702_volume_init_verbs[] = { | |||
2967 | /* PW6 PW7 Output enable */ | 4217 | /* PW6 PW7 Output enable */ |
2968 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 4218 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
2969 | {0x1C, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 4219 | {0x1C, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
4220 | /* mixer enable */ | ||
4221 | {0x1, 0xF88, 0x3}, | ||
4222 | /* GPIO 0~2 */ | ||
4223 | {0x1, 0xF82, 0x3F}, | ||
2970 | { } | 4224 | { } |
2971 | }; | 4225 | }; |
2972 | 4226 | ||
2973 | static struct hda_verb vt1702_uniwill_init_verbs[] = { | 4227 | static struct hda_verb vt1702_uniwill_init_verbs[] = { |
2974 | {0x01, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_GPIO_EVENT}, | 4228 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, |
2975 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_HP_EVENT}, | 4229 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
4230 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4231 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4232 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4233 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
2976 | { } | 4234 | { } |
2977 | }; | 4235 | }; |
2978 | 4236 | ||
@@ -2984,7 +4242,8 @@ static struct hda_pcm_stream vt1702_pcm_analog_playback = { | |||
2984 | .ops = { | 4242 | .ops = { |
2985 | .open = via_playback_pcm_open, | 4243 | .open = via_playback_pcm_open, |
2986 | .prepare = via_playback_multi_pcm_prepare, | 4244 | .prepare = via_playback_multi_pcm_prepare, |
2987 | .cleanup = via_playback_multi_pcm_cleanup | 4245 | .cleanup = via_playback_multi_pcm_cleanup, |
4246 | .close = via_pcm_open_close | ||
2988 | }, | 4247 | }, |
2989 | }; | 4248 | }; |
2990 | 4249 | ||
@@ -2994,8 +4253,10 @@ static struct hda_pcm_stream vt1702_pcm_analog_capture = { | |||
2994 | .channels_max = 2, | 4253 | .channels_max = 2, |
2995 | .nid = 0x12, /* NID to query formats and rates */ | 4254 | .nid = 0x12, /* NID to query formats and rates */ |
2996 | .ops = { | 4255 | .ops = { |
4256 | .open = via_pcm_open_close, | ||
2997 | .prepare = via_capture_pcm_prepare, | 4257 | .prepare = via_capture_pcm_prepare, |
2998 | .cleanup = via_capture_pcm_cleanup | 4258 | .cleanup = via_capture_pcm_cleanup, |
4259 | .close = via_pcm_open_close | ||
2999 | }, | 4260 | }, |
3000 | }; | 4261 | }; |
3001 | 4262 | ||
@@ -3065,12 +4326,13 @@ static int vt1702_auto_create_line_out_ctls(struct via_spec *spec, | |||
3065 | 4326 | ||
3066 | static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | 4327 | static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) |
3067 | { | 4328 | { |
3068 | int err; | 4329 | int err, i; |
3069 | 4330 | struct hda_input_mux *imux; | |
4331 | static const char *texts[] = { "ON", "OFF", NULL}; | ||
3070 | if (!pin) | 4332 | if (!pin) |
3071 | return 0; | 4333 | return 0; |
3072 | |||
3073 | spec->multiout.hp_nid = 0x1D; | 4334 | spec->multiout.hp_nid = 0x1D; |
4335 | spec->hp_independent_mode_index = 0; | ||
3074 | 4336 | ||
3075 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | 4337 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
3076 | "Headphone Playback Volume", | 4338 | "Headphone Playback Volume", |
@@ -3084,8 +4346,18 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
3084 | if (err < 0) | 4346 | if (err < 0) |
3085 | return err; | 4347 | return err; |
3086 | 4348 | ||
3087 | create_hp_imux(spec); | 4349 | imux = &spec->private_imux[1]; |
3088 | 4350 | ||
4351 | /* for hp mode select */ | ||
4352 | i = 0; | ||
4353 | while (texts[i] != NULL) { | ||
4354 | imux->items[imux->num_items].label = texts[i]; | ||
4355 | imux->items[imux->num_items].index = i; | ||
4356 | imux->num_items++; | ||
4357 | i++; | ||
4358 | } | ||
4359 | |||
4360 | spec->hp_mux = &spec->private_imux[1]; | ||
3089 | return 0; | 4361 | return 0; |
3090 | } | 4362 | } |
3091 | 4363 | ||
@@ -3121,8 +4393,7 @@ static int vt1702_auto_create_analog_input_ctls(struct via_spec *spec, | |||
3121 | idx = 3; | 4393 | idx = 3; |
3122 | break; | 4394 | break; |
3123 | } | 4395 | } |
3124 | err = via_new_analog_input(spec, cfg->input_pins[i], | 4396 | err = via_new_analog_input(spec, labels[i], idx, 0x1A); |
3125 | labels[i], idx, 0x1A); | ||
3126 | if (err < 0) | 4397 | if (err < 0) |
3127 | return err; | 4398 | return err; |
3128 | imux->items[imux->num_items].label = labels[i]; | 4399 | imux->items[imux->num_items].label = labels[i]; |
@@ -3152,6 +4423,12 @@ static int vt1702_parse_auto_config(struct hda_codec *codec) | |||
3152 | err = vt1702_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | 4423 | err = vt1702_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); |
3153 | if (err < 0) | 4424 | if (err < 0) |
3154 | return err; | 4425 | return err; |
4426 | /* limit AA path volume to 0 dB */ | ||
4427 | snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT, | ||
4428 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | ||
4429 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
4430 | (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
4431 | (1 << AC_AMPCAP_MUTE_SHIFT)); | ||
3155 | err = vt1702_auto_create_analog_input_ctls(spec, &spec->autocfg); | 4432 | err = vt1702_auto_create_analog_input_ctls(spec, &spec->autocfg); |
3156 | if (err < 0) | 4433 | if (err < 0) |
3157 | return err; | 4434 | return err; |
@@ -3185,8 +4462,6 @@ static int patch_vt1702(struct hda_codec *codec) | |||
3185 | { | 4462 | { |
3186 | struct via_spec *spec; | 4463 | struct via_spec *spec; |
3187 | int err; | 4464 | int err; |
3188 | unsigned int response; | ||
3189 | unsigned char control; | ||
3190 | 4465 | ||
3191 | /* create a codec specific record */ | 4466 | /* create a codec specific record */ |
3192 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4467 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
@@ -3231,17 +4506,1638 @@ static int patch_vt1702(struct hda_codec *codec) | |||
3231 | spec->loopback.amplist = vt1702_loopbacks; | 4506 | spec->loopback.amplist = vt1702_loopbacks; |
3232 | #endif | 4507 | #endif |
3233 | 4508 | ||
3234 | /* Open backdoor */ | 4509 | return 0; |
3235 | response = snd_hda_codec_read(codec, codec->afg, 0, 0xF8C, 0); | 4510 | } |
3236 | control = (unsigned char)(response & 0xff); | 4511 | |
3237 | control |= 0x3; | 4512 | /* Patch for VT1718S */ |
3238 | snd_hda_codec_write(codec, codec->afg, 0, 0xF88, control); | 4513 | |
4514 | /* capture mixer elements */ | ||
4515 | static struct snd_kcontrol_new vt1718S_capture_mixer[] = { | ||
4516 | HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT), | ||
4517 | HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT), | ||
4518 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT), | ||
4519 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT), | ||
4520 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT), | ||
4521 | HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x29, 0x0, | ||
4522 | HDA_INPUT), | ||
4523 | { | ||
4524 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
4525 | /* The multiple "Capture Source" controls confuse alsamixer | ||
4526 | * So call somewhat different.. | ||
4527 | */ | ||
4528 | .name = "Input Source", | ||
4529 | .count = 2, | ||
4530 | .info = via_mux_enum_info, | ||
4531 | .get = via_mux_enum_get, | ||
4532 | .put = via_mux_enum_put, | ||
4533 | }, | ||
4534 | { } /* end */ | ||
4535 | }; | ||
4536 | |||
4537 | static struct hda_verb vt1718S_volume_init_verbs[] = { | ||
4538 | /* | ||
4539 | * Unmute ADC0-1 and set the default input to mic-in | ||
4540 | */ | ||
4541 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4542 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4543 | |||
4544 | |||
4545 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
4546 | * mixer widget | ||
4547 | */ | ||
4548 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ | ||
4549 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
4550 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
4551 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
4552 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
4553 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | ||
4554 | |||
4555 | /* Setup default input of Front HP to MW9 */ | ||
4556 | {0x28, AC_VERB_SET_CONNECT_SEL, 0x1}, | ||
4557 | /* PW9 PW10 Output enable */ | ||
4558 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, | ||
4559 | {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, | ||
4560 | /* PW11 Input enable */ | ||
4561 | {0x2f, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_IN_EN}, | ||
4562 | /* Enable Boost Volume backdoor */ | ||
4563 | {0x1, 0xf88, 0x8}, | ||
4564 | /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */ | ||
4565 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4566 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4567 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4568 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4569 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4570 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
4571 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
4572 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
4573 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
4574 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
4575 | /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */ | ||
4576 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x2}, | ||
4577 | {0x35, AC_VERB_SET_CONNECT_SEL, 0x1}, | ||
4578 | /* Unmute MW4's index 0 */ | ||
4579 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
4580 | { } | ||
4581 | }; | ||
4582 | |||
4583 | |||
4584 | static struct hda_verb vt1718S_uniwill_init_verbs[] = { | ||
4585 | {0x28, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
4586 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, | ||
4587 | {0x24, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4588 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4589 | {0x26, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4590 | {0x27, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4591 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4592 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4593 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
4594 | { } | ||
4595 | }; | ||
4596 | |||
4597 | static struct hda_pcm_stream vt1718S_pcm_analog_playback = { | ||
4598 | .substreams = 2, | ||
4599 | .channels_min = 2, | ||
4600 | .channels_max = 10, | ||
4601 | .nid = 0x8, /* NID to query formats and rates */ | ||
4602 | .ops = { | ||
4603 | .open = via_playback_pcm_open, | ||
4604 | .prepare = via_playback_multi_pcm_prepare, | ||
4605 | .cleanup = via_playback_multi_pcm_cleanup, | ||
4606 | .close = via_pcm_open_close, | ||
4607 | }, | ||
4608 | }; | ||
4609 | |||
4610 | static struct hda_pcm_stream vt1718S_pcm_analog_capture = { | ||
4611 | .substreams = 2, | ||
4612 | .channels_min = 2, | ||
4613 | .channels_max = 2, | ||
4614 | .nid = 0x10, /* NID to query formats and rates */ | ||
4615 | .ops = { | ||
4616 | .open = via_pcm_open_close, | ||
4617 | .prepare = via_capture_pcm_prepare, | ||
4618 | .cleanup = via_capture_pcm_cleanup, | ||
4619 | .close = via_pcm_open_close, | ||
4620 | }, | ||
4621 | }; | ||
4622 | |||
4623 | static struct hda_pcm_stream vt1718S_pcm_digital_playback = { | ||
4624 | .substreams = 2, | ||
4625 | .channels_min = 2, | ||
4626 | .channels_max = 2, | ||
4627 | /* NID is set in via_build_pcms */ | ||
4628 | .ops = { | ||
4629 | .open = via_dig_playback_pcm_open, | ||
4630 | .close = via_dig_playback_pcm_close, | ||
4631 | .prepare = via_dig_playback_pcm_prepare, | ||
4632 | .cleanup = via_dig_playback_pcm_cleanup | ||
4633 | }, | ||
4634 | }; | ||
4635 | |||
4636 | static struct hda_pcm_stream vt1718S_pcm_digital_capture = { | ||
4637 | .substreams = 1, | ||
4638 | .channels_min = 2, | ||
4639 | .channels_max = 2, | ||
4640 | }; | ||
4641 | |||
4642 | /* fill in the dac_nids table from the parsed pin configuration */ | ||
4643 | static int vt1718S_auto_fill_dac_nids(struct via_spec *spec, | ||
4644 | const struct auto_pin_cfg *cfg) | ||
4645 | { | ||
4646 | int i; | ||
4647 | hda_nid_t nid; | ||
4648 | |||
4649 | spec->multiout.num_dacs = cfg->line_outs; | ||
4650 | |||
4651 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
4652 | |||
4653 | for (i = 0; i < 4; i++) { | ||
4654 | nid = cfg->line_out_pins[i]; | ||
4655 | if (nid) { | ||
4656 | /* config dac list */ | ||
4657 | switch (i) { | ||
4658 | case AUTO_SEQ_FRONT: | ||
4659 | spec->multiout.dac_nids[i] = 0x8; | ||
4660 | break; | ||
4661 | case AUTO_SEQ_CENLFE: | ||
4662 | spec->multiout.dac_nids[i] = 0xa; | ||
4663 | break; | ||
4664 | case AUTO_SEQ_SURROUND: | ||
4665 | spec->multiout.dac_nids[i] = 0x9; | ||
4666 | break; | ||
4667 | case AUTO_SEQ_SIDE: | ||
4668 | spec->multiout.dac_nids[i] = 0xb; | ||
4669 | break; | ||
4670 | } | ||
4671 | } | ||
4672 | } | ||
4673 | |||
4674 | return 0; | ||
4675 | } | ||
4676 | |||
4677 | /* add playback controls from the parsed DAC table */ | ||
4678 | static int vt1718S_auto_create_multi_out_ctls(struct via_spec *spec, | ||
4679 | const struct auto_pin_cfg *cfg) | ||
4680 | { | ||
4681 | char name[32]; | ||
4682 | static const char *chname[4] = { "Front", "Surround", "C/LFE", "Side" }; | ||
4683 | hda_nid_t nid_vols[] = {0x8, 0x9, 0xa, 0xb}; | ||
4684 | hda_nid_t nid_mutes[] = {0x24, 0x25, 0x26, 0x27}; | ||
4685 | hda_nid_t nid, nid_vol, nid_mute = 0; | ||
4686 | int i, err; | ||
4687 | |||
4688 | for (i = 0; i <= AUTO_SEQ_SIDE; i++) { | ||
4689 | nid = cfg->line_out_pins[i]; | ||
4690 | |||
4691 | if (!nid) | ||
4692 | continue; | ||
4693 | nid_vol = nid_vols[i]; | ||
4694 | nid_mute = nid_mutes[i]; | ||
4695 | |||
4696 | if (i == AUTO_SEQ_CENLFE) { | ||
4697 | /* Center/LFE */ | ||
4698 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
4699 | "Center Playback Volume", | ||
4700 | HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, | ||
4701 | HDA_OUTPUT)); | ||
4702 | if (err < 0) | ||
4703 | return err; | ||
4704 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
4705 | "LFE Playback Volume", | ||
4706 | HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, | ||
4707 | HDA_OUTPUT)); | ||
4708 | if (err < 0) | ||
4709 | return err; | ||
4710 | err = via_add_control( | ||
4711 | spec, VIA_CTL_WIDGET_MUTE, | ||
4712 | "Center Playback Switch", | ||
4713 | HDA_COMPOSE_AMP_VAL(nid_mute, 1, 0, | ||
4714 | HDA_OUTPUT)); | ||
4715 | if (err < 0) | ||
4716 | return err; | ||
4717 | err = via_add_control( | ||
4718 | spec, VIA_CTL_WIDGET_MUTE, | ||
4719 | "LFE Playback Switch", | ||
4720 | HDA_COMPOSE_AMP_VAL(nid_mute, 2, 0, | ||
4721 | HDA_OUTPUT)); | ||
4722 | if (err < 0) | ||
4723 | return err; | ||
4724 | } else if (i == AUTO_SEQ_FRONT) { | ||
4725 | /* Front */ | ||
4726 | sprintf(name, "%s Playback Volume", chname[i]); | ||
4727 | err = via_add_control( | ||
4728 | spec, VIA_CTL_WIDGET_VOL, name, | ||
4729 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); | ||
4730 | if (err < 0) | ||
4731 | return err; | ||
4732 | sprintf(name, "%s Playback Switch", chname[i]); | ||
4733 | err = via_add_control( | ||
4734 | spec, VIA_CTL_WIDGET_MUTE, name, | ||
4735 | HDA_COMPOSE_AMP_VAL(nid_mute, 3, 0, | ||
4736 | HDA_OUTPUT)); | ||
4737 | if (err < 0) | ||
4738 | return err; | ||
4739 | } else { | ||
4740 | sprintf(name, "%s Playback Volume", chname[i]); | ||
4741 | err = via_add_control( | ||
4742 | spec, VIA_CTL_WIDGET_VOL, name, | ||
4743 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); | ||
4744 | if (err < 0) | ||
4745 | return err; | ||
4746 | sprintf(name, "%s Playback Switch", chname[i]); | ||
4747 | err = via_add_control( | ||
4748 | spec, VIA_CTL_WIDGET_MUTE, name, | ||
4749 | HDA_COMPOSE_AMP_VAL(nid_mute, 3, 0, | ||
4750 | HDA_OUTPUT)); | ||
4751 | if (err < 0) | ||
4752 | return err; | ||
4753 | } | ||
4754 | } | ||
4755 | return 0; | ||
4756 | } | ||
4757 | |||
4758 | static int vt1718S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | ||
4759 | { | ||
4760 | int err; | ||
4761 | |||
4762 | if (!pin) | ||
4763 | return 0; | ||
4764 | |||
4765 | spec->multiout.hp_nid = 0xc; /* AOW4 */ | ||
4766 | spec->hp_independent_mode_index = 1; | ||
4767 | |||
4768 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
4769 | "Headphone Playback Volume", | ||
4770 | HDA_COMPOSE_AMP_VAL(0xc, 3, 0, HDA_OUTPUT)); | ||
4771 | if (err < 0) | ||
4772 | return err; | ||
4773 | |||
4774 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | ||
4775 | "Headphone Playback Switch", | ||
4776 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | ||
4777 | if (err < 0) | ||
4778 | return err; | ||
4779 | |||
4780 | create_hp_imux(spec); | ||
4781 | return 0; | ||
4782 | } | ||
4783 | |||
4784 | /* create playback/capture controls for input pins */ | ||
4785 | static int vt1718S_auto_create_analog_input_ctls(struct via_spec *spec, | ||
4786 | const struct auto_pin_cfg *cfg) | ||
4787 | { | ||
4788 | static char *labels[] = { | ||
4789 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL | ||
4790 | }; | ||
4791 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
4792 | int i, err, idx = 0; | ||
4793 | |||
4794 | /* for internal loopback recording select */ | ||
4795 | imux->items[imux->num_items].label = "Stereo Mixer"; | ||
4796 | imux->items[imux->num_items].index = 5; | ||
4797 | imux->num_items++; | ||
4798 | |||
4799 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
4800 | if (!cfg->input_pins[i]) | ||
4801 | continue; | ||
4802 | |||
4803 | switch (cfg->input_pins[i]) { | ||
4804 | case 0x2b: /* Mic */ | ||
4805 | idx = 1; | ||
4806 | break; | ||
4807 | |||
4808 | case 0x2a: /* Line In */ | ||
4809 | idx = 2; | ||
4810 | break; | ||
4811 | |||
4812 | case 0x29: /* Front Mic */ | ||
4813 | idx = 3; | ||
4814 | break; | ||
4815 | |||
4816 | case 0x2c: /* CD */ | ||
4817 | idx = 0; | ||
4818 | break; | ||
4819 | } | ||
4820 | err = via_new_analog_input(spec, labels[i], idx, 0x21); | ||
4821 | if (err < 0) | ||
4822 | return err; | ||
4823 | imux->items[imux->num_items].label = labels[i]; | ||
4824 | imux->items[imux->num_items].index = idx; | ||
4825 | imux->num_items++; | ||
4826 | } | ||
4827 | return 0; | ||
4828 | } | ||
4829 | |||
4830 | static int vt1718S_parse_auto_config(struct hda_codec *codec) | ||
4831 | { | ||
4832 | struct via_spec *spec = codec->spec; | ||
4833 | int err; | ||
4834 | |||
4835 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
4836 | |||
4837 | if (err < 0) | ||
4838 | return err; | ||
4839 | err = vt1718S_auto_fill_dac_nids(spec, &spec->autocfg); | ||
4840 | if (err < 0) | ||
4841 | return err; | ||
4842 | if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0]) | ||
4843 | return 0; /* can't find valid BIOS pin config */ | ||
4844 | |||
4845 | err = vt1718S_auto_create_multi_out_ctls(spec, &spec->autocfg); | ||
4846 | if (err < 0) | ||
4847 | return err; | ||
4848 | err = vt1718S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | ||
4849 | if (err < 0) | ||
4850 | return err; | ||
4851 | err = vt1718S_auto_create_analog_input_ctls(spec, &spec->autocfg); | ||
4852 | if (err < 0) | ||
4853 | return err; | ||
4854 | |||
4855 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | ||
4856 | |||
4857 | fill_dig_outs(codec); | ||
4858 | |||
4859 | if (spec->autocfg.dig_in_pin && codec->vendor_id == 0x11060428) | ||
4860 | spec->dig_in_nid = 0x13; | ||
4861 | |||
4862 | if (spec->kctls.list) | ||
4863 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | ||
4864 | |||
4865 | spec->input_mux = &spec->private_imux[0]; | ||
4866 | |||
4867 | if (spec->hp_mux) | ||
4868 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | ||
4869 | |||
4870 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | ||
4871 | |||
4872 | return 1; | ||
4873 | } | ||
4874 | |||
4875 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
4876 | static struct hda_amp_list vt1718S_loopbacks[] = { | ||
4877 | { 0x21, HDA_INPUT, 1 }, | ||
4878 | { 0x21, HDA_INPUT, 2 }, | ||
4879 | { 0x21, HDA_INPUT, 3 }, | ||
4880 | { 0x21, HDA_INPUT, 4 }, | ||
4881 | { } /* end */ | ||
4882 | }; | ||
4883 | #endif | ||
4884 | |||
4885 | static int patch_vt1718S(struct hda_codec *codec) | ||
4886 | { | ||
4887 | struct via_spec *spec; | ||
4888 | int err; | ||
3239 | 4889 | ||
3240 | /* Enable GPIO 0&1 for volume&mute control */ | 4890 | /* create a codec specific record */ |
3241 | /* Enable GPIO 2 for DMIC-DATA */ | 4891 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
3242 | response = snd_hda_codec_read(codec, codec->afg, 0, 0xF84, 0); | 4892 | if (spec == NULL) |
3243 | control = (unsigned char)((response >> 16) & 0x3f); | 4893 | return -ENOMEM; |
3244 | snd_hda_codec_write(codec, codec->afg, 0, 0xF82, control); | 4894 | |
4895 | codec->spec = spec; | ||
4896 | |||
4897 | /* automatic parse from the BIOS config */ | ||
4898 | err = vt1718S_parse_auto_config(codec); | ||
4899 | if (err < 0) { | ||
4900 | via_free(codec); | ||
4901 | return err; | ||
4902 | } else if (!err) { | ||
4903 | printk(KERN_INFO "hda_codec: Cannot set up configuration " | ||
4904 | "from BIOS. Using genenic mode...\n"); | ||
4905 | } | ||
4906 | |||
4907 | spec->init_verbs[spec->num_iverbs++] = vt1718S_volume_init_verbs; | ||
4908 | spec->init_verbs[spec->num_iverbs++] = vt1718S_uniwill_init_verbs; | ||
4909 | |||
4910 | if (codec->vendor_id == 0x11060441) | ||
4911 | spec->stream_name_analog = "VT2020 Analog"; | ||
4912 | else if (codec->vendor_id == 0x11064441) | ||
4913 | spec->stream_name_analog = "VT1828S Analog"; | ||
4914 | else | ||
4915 | spec->stream_name_analog = "VT1718S Analog"; | ||
4916 | spec->stream_analog_playback = &vt1718S_pcm_analog_playback; | ||
4917 | spec->stream_analog_capture = &vt1718S_pcm_analog_capture; | ||
4918 | |||
4919 | if (codec->vendor_id == 0x11060441) | ||
4920 | spec->stream_name_digital = "VT2020 Digital"; | ||
4921 | else if (codec->vendor_id == 0x11064441) | ||
4922 | spec->stream_name_digital = "VT1828S Digital"; | ||
4923 | else | ||
4924 | spec->stream_name_digital = "VT1718S Digital"; | ||
4925 | spec->stream_digital_playback = &vt1718S_pcm_digital_playback; | ||
4926 | if (codec->vendor_id == 0x11060428 || codec->vendor_id == 0x11060441) | ||
4927 | spec->stream_digital_capture = &vt1718S_pcm_digital_capture; | ||
4928 | |||
4929 | if (!spec->adc_nids && spec->input_mux) { | ||
4930 | spec->adc_nids = vt1718S_adc_nids; | ||
4931 | spec->num_adc_nids = ARRAY_SIZE(vt1718S_adc_nids); | ||
4932 | get_mux_nids(codec); | ||
4933 | override_mic_boost(codec, 0x2b, 0, 3, 40); | ||
4934 | override_mic_boost(codec, 0x29, 0, 3, 40); | ||
4935 | spec->mixers[spec->num_mixers] = vt1718S_capture_mixer; | ||
4936 | spec->num_mixers++; | ||
4937 | } | ||
4938 | |||
4939 | codec->patch_ops = via_patch_ops; | ||
4940 | |||
4941 | codec->patch_ops.init = via_auto_init; | ||
4942 | codec->patch_ops.unsol_event = via_unsol_event; | ||
4943 | |||
4944 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
4945 | spec->loopback.amplist = vt1718S_loopbacks; | ||
4946 | #endif | ||
4947 | |||
4948 | return 0; | ||
4949 | } | ||
4950 | |||
4951 | /* Patch for VT1716S */ | ||
4952 | |||
4953 | static int vt1716s_dmic_info(struct snd_kcontrol *kcontrol, | ||
4954 | struct snd_ctl_elem_info *uinfo) | ||
4955 | { | ||
4956 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
4957 | uinfo->count = 1; | ||
4958 | uinfo->value.integer.min = 0; | ||
4959 | uinfo->value.integer.max = 1; | ||
4960 | return 0; | ||
4961 | } | ||
4962 | |||
4963 | static int vt1716s_dmic_get(struct snd_kcontrol *kcontrol, | ||
4964 | struct snd_ctl_elem_value *ucontrol) | ||
4965 | { | ||
4966 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
4967 | int index = 0; | ||
4968 | |||
4969 | index = snd_hda_codec_read(codec, 0x26, 0, | ||
4970 | AC_VERB_GET_CONNECT_SEL, 0); | ||
4971 | if (index != -1) | ||
4972 | *ucontrol->value.integer.value = index; | ||
4973 | |||
4974 | return 0; | ||
4975 | } | ||
4976 | |||
4977 | static int vt1716s_dmic_put(struct snd_kcontrol *kcontrol, | ||
4978 | struct snd_ctl_elem_value *ucontrol) | ||
4979 | { | ||
4980 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
4981 | struct via_spec *spec = codec->spec; | ||
4982 | int index = *ucontrol->value.integer.value; | ||
4983 | |||
4984 | snd_hda_codec_write(codec, 0x26, 0, | ||
4985 | AC_VERB_SET_CONNECT_SEL, index); | ||
4986 | spec->dmic_enabled = index; | ||
4987 | set_jack_power_state(codec); | ||
4988 | |||
4989 | return 1; | ||
4990 | } | ||
4991 | |||
4992 | /* capture mixer elements */ | ||
4993 | static struct snd_kcontrol_new vt1716S_capture_mixer[] = { | ||
4994 | HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT), | ||
4995 | HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT), | ||
4996 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT), | ||
4997 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT), | ||
4998 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT), | ||
4999 | HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0, | ||
5000 | HDA_INPUT), | ||
5001 | { | ||
5002 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
5003 | .name = "Input Source", | ||
5004 | .count = 1, | ||
5005 | .info = via_mux_enum_info, | ||
5006 | .get = via_mux_enum_get, | ||
5007 | .put = via_mux_enum_put, | ||
5008 | }, | ||
5009 | { } /* end */ | ||
5010 | }; | ||
5011 | |||
5012 | static struct snd_kcontrol_new vt1716s_dmic_mixer[] = { | ||
5013 | HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT), | ||
5014 | { | ||
5015 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
5016 | .name = "Digital Mic Capture Switch", | ||
5017 | .count = 1, | ||
5018 | .info = vt1716s_dmic_info, | ||
5019 | .get = vt1716s_dmic_get, | ||
5020 | .put = vt1716s_dmic_put, | ||
5021 | }, | ||
5022 | {} /* end */ | ||
5023 | }; | ||
5024 | |||
5025 | |||
5026 | /* mono-out mixer elements */ | ||
5027 | static struct snd_kcontrol_new vt1716S_mono_out_mixer[] = { | ||
5028 | HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT), | ||
5029 | { } /* end */ | ||
5030 | }; | ||
5031 | |||
5032 | static struct hda_verb vt1716S_volume_init_verbs[] = { | ||
5033 | /* | ||
5034 | * Unmute ADC0-1 and set the default input to mic-in | ||
5035 | */ | ||
5036 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5037 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5038 | |||
5039 | |||
5040 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
5041 | * mixer widget | ||
5042 | */ | ||
5043 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ | ||
5044 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
5045 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
5046 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
5047 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
5048 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
5049 | |||
5050 | /* MUX Indices: Stereo Mixer = 5 */ | ||
5051 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x5}, | ||
5052 | |||
5053 | /* Setup default input of PW4 to MW0 */ | ||
5054 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
5055 | |||
5056 | /* Setup default input of SW1 as MW0 */ | ||
5057 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x1}, | ||
5058 | |||
5059 | /* Setup default input of SW4 as AOW0 */ | ||
5060 | {0x28, AC_VERB_SET_CONNECT_SEL, 0x1}, | ||
5061 | |||
5062 | /* PW9 PW10 Output enable */ | ||
5063 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | ||
5064 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | ||
5065 | |||
5066 | /* Unmute SW1, PW12 */ | ||
5067 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5068 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
5069 | /* PW12 Output enable */ | ||
5070 | {0x2a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | ||
5071 | /* Enable Boost Volume backdoor */ | ||
5072 | {0x1, 0xf8a, 0x80}, | ||
5073 | /* don't bybass mixer */ | ||
5074 | {0x1, 0xf88, 0xc0}, | ||
5075 | /* Enable mono output */ | ||
5076 | {0x1, 0xf90, 0x08}, | ||
5077 | { } | ||
5078 | }; | ||
5079 | |||
5080 | |||
5081 | static struct hda_verb vt1716S_uniwill_init_verbs[] = { | ||
5082 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
5083 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, | ||
5084 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5085 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5086 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5087 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
5088 | AC_USRSP_EN | VIA_MONO_EVENT | VIA_JACK_EVENT}, | ||
5089 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5090 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5091 | { } | ||
5092 | }; | ||
5093 | |||
5094 | static struct hda_pcm_stream vt1716S_pcm_analog_playback = { | ||
5095 | .substreams = 2, | ||
5096 | .channels_min = 2, | ||
5097 | .channels_max = 6, | ||
5098 | .nid = 0x10, /* NID to query formats and rates */ | ||
5099 | .ops = { | ||
5100 | .open = via_playback_pcm_open, | ||
5101 | .prepare = via_playback_multi_pcm_prepare, | ||
5102 | .cleanup = via_playback_multi_pcm_cleanup, | ||
5103 | .close = via_pcm_open_close, | ||
5104 | }, | ||
5105 | }; | ||
5106 | |||
5107 | static struct hda_pcm_stream vt1716S_pcm_analog_capture = { | ||
5108 | .substreams = 2, | ||
5109 | .channels_min = 2, | ||
5110 | .channels_max = 2, | ||
5111 | .nid = 0x13, /* NID to query formats and rates */ | ||
5112 | .ops = { | ||
5113 | .open = via_pcm_open_close, | ||
5114 | .prepare = via_capture_pcm_prepare, | ||
5115 | .cleanup = via_capture_pcm_cleanup, | ||
5116 | .close = via_pcm_open_close, | ||
5117 | }, | ||
5118 | }; | ||
5119 | |||
5120 | static struct hda_pcm_stream vt1716S_pcm_digital_playback = { | ||
5121 | .substreams = 2, | ||
5122 | .channels_min = 2, | ||
5123 | .channels_max = 2, | ||
5124 | /* NID is set in via_build_pcms */ | ||
5125 | .ops = { | ||
5126 | .open = via_dig_playback_pcm_open, | ||
5127 | .close = via_dig_playback_pcm_close, | ||
5128 | .prepare = via_dig_playback_pcm_prepare, | ||
5129 | .cleanup = via_dig_playback_pcm_cleanup | ||
5130 | }, | ||
5131 | }; | ||
5132 | |||
5133 | /* fill in the dac_nids table from the parsed pin configuration */ | ||
5134 | static int vt1716S_auto_fill_dac_nids(struct via_spec *spec, | ||
5135 | const struct auto_pin_cfg *cfg) | ||
5136 | { int i; | ||
5137 | hda_nid_t nid; | ||
5138 | |||
5139 | spec->multiout.num_dacs = cfg->line_outs; | ||
5140 | |||
5141 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
5142 | |||
5143 | for (i = 0; i < 3; i++) { | ||
5144 | nid = cfg->line_out_pins[i]; | ||
5145 | if (nid) { | ||
5146 | /* config dac list */ | ||
5147 | switch (i) { | ||
5148 | case AUTO_SEQ_FRONT: | ||
5149 | spec->multiout.dac_nids[i] = 0x10; | ||
5150 | break; | ||
5151 | case AUTO_SEQ_CENLFE: | ||
5152 | spec->multiout.dac_nids[i] = 0x25; | ||
5153 | break; | ||
5154 | case AUTO_SEQ_SURROUND: | ||
5155 | spec->multiout.dac_nids[i] = 0x11; | ||
5156 | break; | ||
5157 | } | ||
5158 | } | ||
5159 | } | ||
5160 | |||
5161 | return 0; | ||
5162 | } | ||
5163 | |||
5164 | /* add playback controls from the parsed DAC table */ | ||
5165 | static int vt1716S_auto_create_multi_out_ctls(struct via_spec *spec, | ||
5166 | const struct auto_pin_cfg *cfg) | ||
5167 | { | ||
5168 | char name[32]; | ||
5169 | static const char *chname[3] = { "Front", "Surround", "C/LFE" }; | ||
5170 | hda_nid_t nid_vols[] = {0x10, 0x11, 0x25}; | ||
5171 | hda_nid_t nid_mutes[] = {0x1C, 0x18, 0x27}; | ||
5172 | hda_nid_t nid, nid_vol, nid_mute; | ||
5173 | int i, err; | ||
5174 | |||
5175 | for (i = 0; i <= AUTO_SEQ_CENLFE; i++) { | ||
5176 | nid = cfg->line_out_pins[i]; | ||
5177 | |||
5178 | if (!nid) | ||
5179 | continue; | ||
5180 | |||
5181 | nid_vol = nid_vols[i]; | ||
5182 | nid_mute = nid_mutes[i]; | ||
5183 | |||
5184 | if (i == AUTO_SEQ_CENLFE) { | ||
5185 | err = via_add_control( | ||
5186 | spec, VIA_CTL_WIDGET_VOL, | ||
5187 | "Center Playback Volume", | ||
5188 | HDA_COMPOSE_AMP_VAL(nid_vol, 1, 0, HDA_OUTPUT)); | ||
5189 | if (err < 0) | ||
5190 | return err; | ||
5191 | err = via_add_control( | ||
5192 | spec, VIA_CTL_WIDGET_VOL, | ||
5193 | "LFE Playback Volume", | ||
5194 | HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT)); | ||
5195 | if (err < 0) | ||
5196 | return err; | ||
5197 | err = via_add_control( | ||
5198 | spec, VIA_CTL_WIDGET_MUTE, | ||
5199 | "Center Playback Switch", | ||
5200 | HDA_COMPOSE_AMP_VAL(nid_mute, 1, 0, | ||
5201 | HDA_OUTPUT)); | ||
5202 | if (err < 0) | ||
5203 | return err; | ||
5204 | err = via_add_control( | ||
5205 | spec, VIA_CTL_WIDGET_MUTE, | ||
5206 | "LFE Playback Switch", | ||
5207 | HDA_COMPOSE_AMP_VAL(nid_mute, 2, 0, | ||
5208 | HDA_OUTPUT)); | ||
5209 | if (err < 0) | ||
5210 | return err; | ||
5211 | } else if (i == AUTO_SEQ_FRONT) { | ||
5212 | |||
5213 | err = via_add_control( | ||
5214 | spec, VIA_CTL_WIDGET_VOL, | ||
5215 | "Master Front Playback Volume", | ||
5216 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_INPUT)); | ||
5217 | if (err < 0) | ||
5218 | return err; | ||
5219 | err = via_add_control( | ||
5220 | spec, VIA_CTL_WIDGET_MUTE, | ||
5221 | "Master Front Playback Switch", | ||
5222 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_INPUT)); | ||
5223 | if (err < 0) | ||
5224 | return err; | ||
5225 | |||
5226 | sprintf(name, "%s Playback Volume", chname[i]); | ||
5227 | err = via_add_control( | ||
5228 | spec, VIA_CTL_WIDGET_VOL, name, | ||
5229 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); | ||
5230 | if (err < 0) | ||
5231 | return err; | ||
5232 | sprintf(name, "%s Playback Switch", chname[i]); | ||
5233 | err = via_add_control( | ||
5234 | spec, VIA_CTL_WIDGET_MUTE, name, | ||
5235 | HDA_COMPOSE_AMP_VAL(nid_mute, 3, 0, | ||
5236 | HDA_OUTPUT)); | ||
5237 | if (err < 0) | ||
5238 | return err; | ||
5239 | } else { | ||
5240 | sprintf(name, "%s Playback Volume", chname[i]); | ||
5241 | err = via_add_control( | ||
5242 | spec, VIA_CTL_WIDGET_VOL, name, | ||
5243 | HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT)); | ||
5244 | if (err < 0) | ||
5245 | return err; | ||
5246 | sprintf(name, "%s Playback Switch", chname[i]); | ||
5247 | err = via_add_control( | ||
5248 | spec, VIA_CTL_WIDGET_MUTE, name, | ||
5249 | HDA_COMPOSE_AMP_VAL(nid_mute, 3, 0, | ||
5250 | HDA_OUTPUT)); | ||
5251 | if (err < 0) | ||
5252 | return err; | ||
5253 | } | ||
5254 | } | ||
5255 | return 0; | ||
5256 | } | ||
5257 | |||
5258 | static int vt1716S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | ||
5259 | { | ||
5260 | int err; | ||
5261 | |||
5262 | if (!pin) | ||
5263 | return 0; | ||
5264 | |||
5265 | spec->multiout.hp_nid = 0x25; /* AOW3 */ | ||
5266 | spec->hp_independent_mode_index = 1; | ||
5267 | |||
5268 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
5269 | "Headphone Playback Volume", | ||
5270 | HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT)); | ||
5271 | if (err < 0) | ||
5272 | return err; | ||
5273 | |||
5274 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | ||
5275 | "Headphone Playback Switch", | ||
5276 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | ||
5277 | if (err < 0) | ||
5278 | return err; | ||
5279 | |||
5280 | create_hp_imux(spec); | ||
5281 | return 0; | ||
5282 | } | ||
5283 | |||
5284 | /* create playback/capture controls for input pins */ | ||
5285 | static int vt1716S_auto_create_analog_input_ctls(struct via_spec *spec, | ||
5286 | const struct auto_pin_cfg *cfg) | ||
5287 | { | ||
5288 | static char *labels[] = { | ||
5289 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL | ||
5290 | }; | ||
5291 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
5292 | int i, err, idx = 0; | ||
5293 | |||
5294 | /* for internal loopback recording select */ | ||
5295 | imux->items[imux->num_items].label = "Stereo Mixer"; | ||
5296 | imux->items[imux->num_items].index = 5; | ||
5297 | imux->num_items++; | ||
5298 | |||
5299 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
5300 | if (!cfg->input_pins[i]) | ||
5301 | continue; | ||
5302 | |||
5303 | switch (cfg->input_pins[i]) { | ||
5304 | case 0x1a: /* Mic */ | ||
5305 | idx = 2; | ||
5306 | break; | ||
5307 | |||
5308 | case 0x1b: /* Line In */ | ||
5309 | idx = 3; | ||
5310 | break; | ||
5311 | |||
5312 | case 0x1e: /* Front Mic */ | ||
5313 | idx = 4; | ||
5314 | break; | ||
5315 | |||
5316 | case 0x1f: /* CD */ | ||
5317 | idx = 1; | ||
5318 | break; | ||
5319 | } | ||
5320 | err = via_new_analog_input(spec, labels[i], idx, 0x16); | ||
5321 | if (err < 0) | ||
5322 | return err; | ||
5323 | imux->items[imux->num_items].label = labels[i]; | ||
5324 | imux->items[imux->num_items].index = idx-1; | ||
5325 | imux->num_items++; | ||
5326 | } | ||
5327 | return 0; | ||
5328 | } | ||
5329 | |||
5330 | static int vt1716S_parse_auto_config(struct hda_codec *codec) | ||
5331 | { | ||
5332 | struct via_spec *spec = codec->spec; | ||
5333 | int err; | ||
5334 | |||
5335 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
5336 | if (err < 0) | ||
5337 | return err; | ||
5338 | err = vt1716S_auto_fill_dac_nids(spec, &spec->autocfg); | ||
5339 | if (err < 0) | ||
5340 | return err; | ||
5341 | if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0]) | ||
5342 | return 0; /* can't find valid BIOS pin config */ | ||
5343 | |||
5344 | err = vt1716S_auto_create_multi_out_ctls(spec, &spec->autocfg); | ||
5345 | if (err < 0) | ||
5346 | return err; | ||
5347 | err = vt1716S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | ||
5348 | if (err < 0) | ||
5349 | return err; | ||
5350 | err = vt1716S_auto_create_analog_input_ctls(spec, &spec->autocfg); | ||
5351 | if (err < 0) | ||
5352 | return err; | ||
5353 | |||
5354 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | ||
5355 | |||
5356 | fill_dig_outs(codec); | ||
5357 | |||
5358 | if (spec->kctls.list) | ||
5359 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | ||
5360 | |||
5361 | spec->input_mux = &spec->private_imux[0]; | ||
5362 | |||
5363 | if (spec->hp_mux) | ||
5364 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | ||
5365 | |||
5366 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | ||
5367 | |||
5368 | return 1; | ||
5369 | } | ||
5370 | |||
5371 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5372 | static struct hda_amp_list vt1716S_loopbacks[] = { | ||
5373 | { 0x16, HDA_INPUT, 1 }, | ||
5374 | { 0x16, HDA_INPUT, 2 }, | ||
5375 | { 0x16, HDA_INPUT, 3 }, | ||
5376 | { 0x16, HDA_INPUT, 4 }, | ||
5377 | { } /* end */ | ||
5378 | }; | ||
5379 | #endif | ||
5380 | |||
5381 | static int patch_vt1716S(struct hda_codec *codec) | ||
5382 | { | ||
5383 | struct via_spec *spec; | ||
5384 | int err; | ||
5385 | |||
5386 | /* create a codec specific record */ | ||
5387 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
5388 | if (spec == NULL) | ||
5389 | return -ENOMEM; | ||
5390 | |||
5391 | codec->spec = spec; | ||
5392 | |||
5393 | /* automatic parse from the BIOS config */ | ||
5394 | err = vt1716S_parse_auto_config(codec); | ||
5395 | if (err < 0) { | ||
5396 | via_free(codec); | ||
5397 | return err; | ||
5398 | } else if (!err) { | ||
5399 | printk(KERN_INFO "hda_codec: Cannot set up configuration " | ||
5400 | "from BIOS. Using genenic mode...\n"); | ||
5401 | } | ||
5402 | |||
5403 | spec->init_verbs[spec->num_iverbs++] = vt1716S_volume_init_verbs; | ||
5404 | spec->init_verbs[spec->num_iverbs++] = vt1716S_uniwill_init_verbs; | ||
5405 | |||
5406 | spec->stream_name_analog = "VT1716S Analog"; | ||
5407 | spec->stream_analog_playback = &vt1716S_pcm_analog_playback; | ||
5408 | spec->stream_analog_capture = &vt1716S_pcm_analog_capture; | ||
5409 | |||
5410 | spec->stream_name_digital = "VT1716S Digital"; | ||
5411 | spec->stream_digital_playback = &vt1716S_pcm_digital_playback; | ||
5412 | |||
5413 | if (!spec->adc_nids && spec->input_mux) { | ||
5414 | spec->adc_nids = vt1716S_adc_nids; | ||
5415 | spec->num_adc_nids = ARRAY_SIZE(vt1716S_adc_nids); | ||
5416 | get_mux_nids(codec); | ||
5417 | override_mic_boost(codec, 0x1a, 0, 3, 40); | ||
5418 | override_mic_boost(codec, 0x1e, 0, 3, 40); | ||
5419 | spec->mixers[spec->num_mixers] = vt1716S_capture_mixer; | ||
5420 | spec->num_mixers++; | ||
5421 | } | ||
5422 | |||
5423 | spec->mixers[spec->num_mixers] = vt1716s_dmic_mixer; | ||
5424 | spec->num_mixers++; | ||
5425 | |||
5426 | spec->mixers[spec->num_mixers++] = vt1716S_mono_out_mixer; | ||
5427 | |||
5428 | codec->patch_ops = via_patch_ops; | ||
5429 | |||
5430 | codec->patch_ops.init = via_auto_init; | ||
5431 | codec->patch_ops.unsol_event = via_unsol_event; | ||
5432 | |||
5433 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5434 | spec->loopback.amplist = vt1716S_loopbacks; | ||
5435 | #endif | ||
5436 | |||
5437 | return 0; | ||
5438 | } | ||
5439 | |||
5440 | /* for vt2002P */ | ||
5441 | |||
5442 | /* capture mixer elements */ | ||
5443 | static struct snd_kcontrol_new vt2002P_capture_mixer[] = { | ||
5444 | HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT), | ||
5445 | HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT), | ||
5446 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT), | ||
5447 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT), | ||
5448 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT), | ||
5449 | HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x29, 0x0, | ||
5450 | HDA_INPUT), | ||
5451 | { | ||
5452 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
5453 | /* The multiple "Capture Source" controls confuse alsamixer | ||
5454 | * So call somewhat different.. | ||
5455 | */ | ||
5456 | /* .name = "Capture Source", */ | ||
5457 | .name = "Input Source", | ||
5458 | .count = 2, | ||
5459 | .info = via_mux_enum_info, | ||
5460 | .get = via_mux_enum_get, | ||
5461 | .put = via_mux_enum_put, | ||
5462 | }, | ||
5463 | { } /* end */ | ||
5464 | }; | ||
5465 | |||
5466 | static struct hda_verb vt2002P_volume_init_verbs[] = { | ||
5467 | /* | ||
5468 | * Unmute ADC0-1 and set the default input to mic-in | ||
5469 | */ | ||
5470 | {0x8, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5471 | {0x9, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5472 | |||
5473 | |||
5474 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
5475 | * mixer widget | ||
5476 | */ | ||
5477 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ | ||
5478 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
5479 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
5480 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
5481 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
5482 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
5483 | |||
5484 | /* MUX Indices: Mic = 0 */ | ||
5485 | {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5486 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5487 | |||
5488 | /* PW9 Output enable */ | ||
5489 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, | ||
5490 | |||
5491 | /* Enable Boost Volume backdoor */ | ||
5492 | {0x1, 0xfb9, 0x24}, | ||
5493 | |||
5494 | /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */ | ||
5495 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5496 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5497 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5498 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5499 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5500 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5501 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5502 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5503 | |||
5504 | /* set MUX0/1/4/8 = 0 (AOW0) */ | ||
5505 | {0x34, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5506 | {0x35, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5507 | {0x37, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5508 | {0x3b, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5509 | |||
5510 | /* set PW0 index=0 (MW0) */ | ||
5511 | {0x24, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5512 | |||
5513 | /* Enable AOW0 to MW9 */ | ||
5514 | {0x1, 0xfb8, 0x88}, | ||
5515 | { } | ||
5516 | }; | ||
5517 | |||
5518 | |||
5519 | static struct hda_verb vt2002P_uniwill_init_verbs[] = { | ||
5520 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
5521 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, | ||
5522 | {0x26, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
5523 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, | ||
5524 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5525 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5526 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5527 | { } | ||
5528 | }; | ||
5529 | |||
5530 | static struct hda_pcm_stream vt2002P_pcm_analog_playback = { | ||
5531 | .substreams = 2, | ||
5532 | .channels_min = 2, | ||
5533 | .channels_max = 2, | ||
5534 | .nid = 0x8, /* NID to query formats and rates */ | ||
5535 | .ops = { | ||
5536 | .open = via_playback_pcm_open, | ||
5537 | .prepare = via_playback_multi_pcm_prepare, | ||
5538 | .cleanup = via_playback_multi_pcm_cleanup, | ||
5539 | .close = via_pcm_open_close, | ||
5540 | }, | ||
5541 | }; | ||
5542 | |||
5543 | static struct hda_pcm_stream vt2002P_pcm_analog_capture = { | ||
5544 | .substreams = 2, | ||
5545 | .channels_min = 2, | ||
5546 | .channels_max = 2, | ||
5547 | .nid = 0x10, /* NID to query formats and rates */ | ||
5548 | .ops = { | ||
5549 | .open = via_pcm_open_close, | ||
5550 | .prepare = via_capture_pcm_prepare, | ||
5551 | .cleanup = via_capture_pcm_cleanup, | ||
5552 | .close = via_pcm_open_close, | ||
5553 | }, | ||
5554 | }; | ||
5555 | |||
5556 | static struct hda_pcm_stream vt2002P_pcm_digital_playback = { | ||
5557 | .substreams = 1, | ||
5558 | .channels_min = 2, | ||
5559 | .channels_max = 2, | ||
5560 | /* NID is set in via_build_pcms */ | ||
5561 | .ops = { | ||
5562 | .open = via_dig_playback_pcm_open, | ||
5563 | .close = via_dig_playback_pcm_close, | ||
5564 | .prepare = via_dig_playback_pcm_prepare, | ||
5565 | .cleanup = via_dig_playback_pcm_cleanup | ||
5566 | }, | ||
5567 | }; | ||
5568 | |||
5569 | /* fill in the dac_nids table from the parsed pin configuration */ | ||
5570 | static int vt2002P_auto_fill_dac_nids(struct via_spec *spec, | ||
5571 | const struct auto_pin_cfg *cfg) | ||
5572 | { | ||
5573 | spec->multiout.num_dacs = 1; | ||
5574 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
5575 | if (cfg->line_out_pins[0]) | ||
5576 | spec->multiout.dac_nids[0] = 0x8; | ||
5577 | return 0; | ||
5578 | } | ||
5579 | |||
5580 | /* add playback controls from the parsed DAC table */ | ||
5581 | static int vt2002P_auto_create_multi_out_ctls(struct via_spec *spec, | ||
5582 | const struct auto_pin_cfg *cfg) | ||
5583 | { | ||
5584 | int err; | ||
5585 | |||
5586 | if (!cfg->line_out_pins[0]) | ||
5587 | return -1; | ||
5588 | |||
5589 | |||
5590 | /* Line-Out: PortE */ | ||
5591 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
5592 | "Master Front Playback Volume", | ||
5593 | HDA_COMPOSE_AMP_VAL(0x8, 3, 0, HDA_OUTPUT)); | ||
5594 | if (err < 0) | ||
5595 | return err; | ||
5596 | err = via_add_control(spec, VIA_CTL_WIDGET_BIND_PIN_MUTE, | ||
5597 | "Master Front Playback Switch", | ||
5598 | HDA_COMPOSE_AMP_VAL(0x26, 3, 0, HDA_OUTPUT)); | ||
5599 | if (err < 0) | ||
5600 | return err; | ||
5601 | |||
5602 | return 0; | ||
5603 | } | ||
5604 | |||
5605 | static int vt2002P_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | ||
5606 | { | ||
5607 | int err; | ||
5608 | |||
5609 | if (!pin) | ||
5610 | return 0; | ||
5611 | |||
5612 | spec->multiout.hp_nid = 0x9; | ||
5613 | spec->hp_independent_mode_index = 1; | ||
5614 | |||
5615 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
5616 | "Headphone Playback Volume", | ||
5617 | HDA_COMPOSE_AMP_VAL( | ||
5618 | spec->multiout.hp_nid, 3, 0, HDA_OUTPUT)); | ||
5619 | if (err < 0) | ||
5620 | return err; | ||
5621 | |||
5622 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | ||
5623 | "Headphone Playback Switch", | ||
5624 | HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT)); | ||
5625 | if (err < 0) | ||
5626 | return err; | ||
5627 | |||
5628 | create_hp_imux(spec); | ||
5629 | return 0; | ||
5630 | } | ||
5631 | |||
5632 | /* create playback/capture controls for input pins */ | ||
5633 | static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, | ||
5634 | const struct auto_pin_cfg *cfg) | ||
5635 | { | ||
5636 | static char *labels[] = { | ||
5637 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL | ||
5638 | }; | ||
5639 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
5640 | int i, err, idx = 0; | ||
5641 | |||
5642 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
5643 | if (!cfg->input_pins[i]) | ||
5644 | continue; | ||
5645 | |||
5646 | switch (cfg->input_pins[i]) { | ||
5647 | case 0x2b: /* Mic */ | ||
5648 | idx = 0; | ||
5649 | break; | ||
5650 | |||
5651 | case 0x2a: /* Line In */ | ||
5652 | idx = 1; | ||
5653 | break; | ||
5654 | |||
5655 | case 0x29: /* Front Mic */ | ||
5656 | idx = 2; | ||
5657 | break; | ||
5658 | } | ||
5659 | err = via_new_analog_input(spec, labels[i], idx, 0x21); | ||
5660 | if (err < 0) | ||
5661 | return err; | ||
5662 | imux->items[imux->num_items].label = labels[i]; | ||
5663 | imux->items[imux->num_items].index = idx; | ||
5664 | imux->num_items++; | ||
5665 | } | ||
5666 | |||
5667 | /* build volume/mute control of loopback */ | ||
5668 | err = via_new_analog_input(spec, "Stereo Mixer", 3, 0x21); | ||
5669 | if (err < 0) | ||
5670 | return err; | ||
5671 | |||
5672 | /* for internal loopback recording select */ | ||
5673 | imux->items[imux->num_items].label = "Stereo Mixer"; | ||
5674 | imux->items[imux->num_items].index = 3; | ||
5675 | imux->num_items++; | ||
5676 | |||
5677 | /* for digital mic select */ | ||
5678 | imux->items[imux->num_items].label = "Digital Mic"; | ||
5679 | imux->items[imux->num_items].index = 4; | ||
5680 | imux->num_items++; | ||
5681 | |||
5682 | return 0; | ||
5683 | } | ||
5684 | |||
5685 | static int vt2002P_parse_auto_config(struct hda_codec *codec) | ||
5686 | { | ||
5687 | struct via_spec *spec = codec->spec; | ||
5688 | int err; | ||
5689 | |||
5690 | |||
5691 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
5692 | if (err < 0) | ||
5693 | return err; | ||
5694 | |||
5695 | err = vt2002P_auto_fill_dac_nids(spec, &spec->autocfg); | ||
5696 | if (err < 0) | ||
5697 | return err; | ||
5698 | |||
5699 | if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0]) | ||
5700 | return 0; /* can't find valid BIOS pin config */ | ||
5701 | |||
5702 | err = vt2002P_auto_create_multi_out_ctls(spec, &spec->autocfg); | ||
5703 | if (err < 0) | ||
5704 | return err; | ||
5705 | err = vt2002P_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | ||
5706 | if (err < 0) | ||
5707 | return err; | ||
5708 | err = vt2002P_auto_create_analog_input_ctls(spec, &spec->autocfg); | ||
5709 | if (err < 0) | ||
5710 | return err; | ||
5711 | |||
5712 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | ||
5713 | |||
5714 | fill_dig_outs(codec); | ||
5715 | |||
5716 | if (spec->kctls.list) | ||
5717 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | ||
5718 | |||
5719 | spec->input_mux = &spec->private_imux[0]; | ||
5720 | |||
5721 | if (spec->hp_mux) | ||
5722 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | ||
5723 | |||
5724 | return 1; | ||
5725 | } | ||
5726 | |||
5727 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5728 | static struct hda_amp_list vt2002P_loopbacks[] = { | ||
5729 | { 0x21, HDA_INPUT, 0 }, | ||
5730 | { 0x21, HDA_INPUT, 1 }, | ||
5731 | { 0x21, HDA_INPUT, 2 }, | ||
5732 | { } /* end */ | ||
5733 | }; | ||
5734 | #endif | ||
5735 | |||
5736 | |||
5737 | /* patch for vt2002P */ | ||
5738 | static int patch_vt2002P(struct hda_codec *codec) | ||
5739 | { | ||
5740 | struct via_spec *spec; | ||
5741 | int err; | ||
5742 | |||
5743 | /* create a codec specific record */ | ||
5744 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
5745 | if (spec == NULL) | ||
5746 | return -ENOMEM; | ||
5747 | |||
5748 | codec->spec = spec; | ||
5749 | |||
5750 | /* automatic parse from the BIOS config */ | ||
5751 | err = vt2002P_parse_auto_config(codec); | ||
5752 | if (err < 0) { | ||
5753 | via_free(codec); | ||
5754 | return err; | ||
5755 | } else if (!err) { | ||
5756 | printk(KERN_INFO "hda_codec: Cannot set up configuration " | ||
5757 | "from BIOS. Using genenic mode...\n"); | ||
5758 | } | ||
5759 | |||
5760 | spec->init_verbs[spec->num_iverbs++] = vt2002P_volume_init_verbs; | ||
5761 | spec->init_verbs[spec->num_iverbs++] = vt2002P_uniwill_init_verbs; | ||
5762 | |||
5763 | spec->stream_name_analog = "VT2002P Analog"; | ||
5764 | spec->stream_analog_playback = &vt2002P_pcm_analog_playback; | ||
5765 | spec->stream_analog_capture = &vt2002P_pcm_analog_capture; | ||
5766 | |||
5767 | spec->stream_name_digital = "VT2002P Digital"; | ||
5768 | spec->stream_digital_playback = &vt2002P_pcm_digital_playback; | ||
5769 | |||
5770 | if (!spec->adc_nids && spec->input_mux) { | ||
5771 | spec->adc_nids = vt2002P_adc_nids; | ||
5772 | spec->num_adc_nids = ARRAY_SIZE(vt2002P_adc_nids); | ||
5773 | get_mux_nids(codec); | ||
5774 | override_mic_boost(codec, 0x2b, 0, 3, 40); | ||
5775 | override_mic_boost(codec, 0x29, 0, 3, 40); | ||
5776 | spec->mixers[spec->num_mixers] = vt2002P_capture_mixer; | ||
5777 | spec->num_mixers++; | ||
5778 | } | ||
5779 | |||
5780 | codec->patch_ops = via_patch_ops; | ||
5781 | |||
5782 | codec->patch_ops.init = via_auto_init; | ||
5783 | codec->patch_ops.unsol_event = via_unsol_event; | ||
5784 | |||
5785 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5786 | spec->loopback.amplist = vt2002P_loopbacks; | ||
5787 | #endif | ||
5788 | |||
5789 | return 0; | ||
5790 | } | ||
5791 | |||
5792 | /* for vt1812 */ | ||
5793 | |||
5794 | /* capture mixer elements */ | ||
5795 | static struct snd_kcontrol_new vt1812_capture_mixer[] = { | ||
5796 | HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT), | ||
5797 | HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT), | ||
5798 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT), | ||
5799 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT), | ||
5800 | HDA_CODEC_MUTE("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT), | ||
5801 | HDA_CODEC_MUTE("Front Mic Boost Capture Volume", 0x29, 0x0, | ||
5802 | HDA_INPUT), | ||
5803 | { | ||
5804 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
5805 | /* The multiple "Capture Source" controls confuse alsamixer | ||
5806 | * So call somewhat different.. | ||
5807 | */ | ||
5808 | .name = "Input Source", | ||
5809 | .count = 2, | ||
5810 | .info = via_mux_enum_info, | ||
5811 | .get = via_mux_enum_get, | ||
5812 | .put = via_mux_enum_put, | ||
5813 | }, | ||
5814 | { } /* end */ | ||
5815 | }; | ||
5816 | |||
5817 | static struct hda_verb vt1812_volume_init_verbs[] = { | ||
5818 | /* | ||
5819 | * Unmute ADC0-1 and set the default input to mic-in | ||
5820 | */ | ||
5821 | {0x8, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5822 | {0x9, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5823 | |||
5824 | |||
5825 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
5826 | * mixer widget | ||
5827 | */ | ||
5828 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ | ||
5829 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
5830 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
5831 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
5832 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
5833 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
5834 | |||
5835 | /* MUX Indices: Mic = 0 */ | ||
5836 | {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5837 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5838 | |||
5839 | /* PW9 Output enable */ | ||
5840 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, | ||
5841 | |||
5842 | /* Enable Boost Volume backdoor */ | ||
5843 | {0x1, 0xfb9, 0x24}, | ||
5844 | |||
5845 | /* MW0/1/4/13/15: un-mute index 0 (MUXx), un-mute index 1 (MW9) */ | ||
5846 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5847 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5848 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5849 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5850 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
5851 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5852 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5853 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5854 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5855 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
5856 | |||
5857 | /* set MUX0/1/4/13/15 = 0 (AOW0) */ | ||
5858 | {0x34, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5859 | {0x35, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5860 | {0x38, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5861 | {0x3c, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5862 | {0x3d, AC_VERB_SET_CONNECT_SEL, 0}, | ||
5863 | |||
5864 | /* Enable AOW0 to MW9 */ | ||
5865 | {0x1, 0xfb8, 0xa8}, | ||
5866 | { } | ||
5867 | }; | ||
5868 | |||
5869 | |||
5870 | static struct hda_verb vt1812_uniwill_init_verbs[] = { | ||
5871 | {0x33, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
5872 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, | ||
5873 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT }, | ||
5874 | {0x28, AC_VERB_SET_UNSOLICITED_ENABLE, | ||
5875 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, | ||
5876 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5877 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5878 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, | ||
5879 | { } | ||
5880 | }; | ||
5881 | |||
5882 | static struct hda_pcm_stream vt1812_pcm_analog_playback = { | ||
5883 | .substreams = 2, | ||
5884 | .channels_min = 2, | ||
5885 | .channels_max = 2, | ||
5886 | .nid = 0x8, /* NID to query formats and rates */ | ||
5887 | .ops = { | ||
5888 | .open = via_playback_pcm_open, | ||
5889 | .prepare = via_playback_multi_pcm_prepare, | ||
5890 | .cleanup = via_playback_multi_pcm_cleanup, | ||
5891 | .close = via_pcm_open_close, | ||
5892 | }, | ||
5893 | }; | ||
5894 | |||
5895 | static struct hda_pcm_stream vt1812_pcm_analog_capture = { | ||
5896 | .substreams = 2, | ||
5897 | .channels_min = 2, | ||
5898 | .channels_max = 2, | ||
5899 | .nid = 0x10, /* NID to query formats and rates */ | ||
5900 | .ops = { | ||
5901 | .open = via_pcm_open_close, | ||
5902 | .prepare = via_capture_pcm_prepare, | ||
5903 | .cleanup = via_capture_pcm_cleanup, | ||
5904 | .close = via_pcm_open_close, | ||
5905 | }, | ||
5906 | }; | ||
5907 | |||
5908 | static struct hda_pcm_stream vt1812_pcm_digital_playback = { | ||
5909 | .substreams = 1, | ||
5910 | .channels_min = 2, | ||
5911 | .channels_max = 2, | ||
5912 | /* NID is set in via_build_pcms */ | ||
5913 | .ops = { | ||
5914 | .open = via_dig_playback_pcm_open, | ||
5915 | .close = via_dig_playback_pcm_close, | ||
5916 | .prepare = via_dig_playback_pcm_prepare, | ||
5917 | .cleanup = via_dig_playback_pcm_cleanup | ||
5918 | }, | ||
5919 | }; | ||
5920 | /* fill in the dac_nids table from the parsed pin configuration */ | ||
5921 | static int vt1812_auto_fill_dac_nids(struct via_spec *spec, | ||
5922 | const struct auto_pin_cfg *cfg) | ||
5923 | { | ||
5924 | spec->multiout.num_dacs = 1; | ||
5925 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
5926 | if (cfg->line_out_pins[0]) | ||
5927 | spec->multiout.dac_nids[0] = 0x8; | ||
5928 | return 0; | ||
5929 | } | ||
5930 | |||
5931 | |||
5932 | /* add playback controls from the parsed DAC table */ | ||
5933 | static int vt1812_auto_create_multi_out_ctls(struct via_spec *spec, | ||
5934 | const struct auto_pin_cfg *cfg) | ||
5935 | { | ||
5936 | int err; | ||
5937 | |||
5938 | if (!cfg->line_out_pins[0]) | ||
5939 | return -1; | ||
5940 | |||
5941 | /* Line-Out: PortE */ | ||
5942 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
5943 | "Master Front Playback Volume", | ||
5944 | HDA_COMPOSE_AMP_VAL(0x8, 3, 0, HDA_OUTPUT)); | ||
5945 | if (err < 0) | ||
5946 | return err; | ||
5947 | err = via_add_control(spec, VIA_CTL_WIDGET_BIND_PIN_MUTE, | ||
5948 | "Master Front Playback Switch", | ||
5949 | HDA_COMPOSE_AMP_VAL(0x28, 3, 0, HDA_OUTPUT)); | ||
5950 | if (err < 0) | ||
5951 | return err; | ||
5952 | |||
5953 | return 0; | ||
5954 | } | ||
5955 | |||
5956 | static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | ||
5957 | { | ||
5958 | int err; | ||
5959 | |||
5960 | if (!pin) | ||
5961 | return 0; | ||
5962 | |||
5963 | spec->multiout.hp_nid = 0x9; | ||
5964 | spec->hp_independent_mode_index = 1; | ||
5965 | |||
5966 | |||
5967 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, | ||
5968 | "Headphone Playback Volume", | ||
5969 | HDA_COMPOSE_AMP_VAL( | ||
5970 | spec->multiout.hp_nid, 3, 0, HDA_OUTPUT)); | ||
5971 | if (err < 0) | ||
5972 | return err; | ||
5973 | |||
5974 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, | ||
5975 | "Headphone Playback Switch", | ||
5976 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | ||
5977 | if (err < 0) | ||
5978 | return err; | ||
5979 | |||
5980 | create_hp_imux(spec); | ||
5981 | return 0; | ||
5982 | } | ||
5983 | |||
5984 | /* create playback/capture controls for input pins */ | ||
5985 | static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, | ||
5986 | const struct auto_pin_cfg *cfg) | ||
5987 | { | ||
5988 | static char *labels[] = { | ||
5989 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL | ||
5990 | }; | ||
5991 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
5992 | int i, err, idx = 0; | ||
5993 | |||
5994 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
5995 | if (!cfg->input_pins[i]) | ||
5996 | continue; | ||
5997 | |||
5998 | switch (cfg->input_pins[i]) { | ||
5999 | case 0x2b: /* Mic */ | ||
6000 | idx = 0; | ||
6001 | break; | ||
6002 | |||
6003 | case 0x2a: /* Line In */ | ||
6004 | idx = 1; | ||
6005 | break; | ||
6006 | |||
6007 | case 0x29: /* Front Mic */ | ||
6008 | idx = 2; | ||
6009 | break; | ||
6010 | } | ||
6011 | err = via_new_analog_input(spec, labels[i], idx, 0x21); | ||
6012 | if (err < 0) | ||
6013 | return err; | ||
6014 | imux->items[imux->num_items].label = labels[i]; | ||
6015 | imux->items[imux->num_items].index = idx; | ||
6016 | imux->num_items++; | ||
6017 | } | ||
6018 | /* build volume/mute control of loopback */ | ||
6019 | err = via_new_analog_input(spec, "Stereo Mixer", 5, 0x21); | ||
6020 | if (err < 0) | ||
6021 | return err; | ||
6022 | |||
6023 | /* for internal loopback recording select */ | ||
6024 | imux->items[imux->num_items].label = "Stereo Mixer"; | ||
6025 | imux->items[imux->num_items].index = 5; | ||
6026 | imux->num_items++; | ||
6027 | |||
6028 | /* for digital mic select */ | ||
6029 | imux->items[imux->num_items].label = "Digital Mic"; | ||
6030 | imux->items[imux->num_items].index = 6; | ||
6031 | imux->num_items++; | ||
6032 | |||
6033 | return 0; | ||
6034 | } | ||
6035 | |||
6036 | static int vt1812_parse_auto_config(struct hda_codec *codec) | ||
6037 | { | ||
6038 | struct via_spec *spec = codec->spec; | ||
6039 | int err; | ||
6040 | |||
6041 | |||
6042 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
6043 | if (err < 0) | ||
6044 | return err; | ||
6045 | fill_dig_outs(codec); | ||
6046 | err = vt1812_auto_fill_dac_nids(spec, &spec->autocfg); | ||
6047 | if (err < 0) | ||
6048 | return err; | ||
6049 | |||
6050 | if (!spec->autocfg.line_outs && !spec->autocfg.hp_outs) | ||
6051 | return 0; /* can't find valid BIOS pin config */ | ||
6052 | |||
6053 | err = vt1812_auto_create_multi_out_ctls(spec, &spec->autocfg); | ||
6054 | if (err < 0) | ||
6055 | return err; | ||
6056 | err = vt1812_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | ||
6057 | if (err < 0) | ||
6058 | return err; | ||
6059 | err = vt1812_auto_create_analog_input_ctls(spec, &spec->autocfg); | ||
6060 | if (err < 0) | ||
6061 | return err; | ||
6062 | |||
6063 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | ||
6064 | |||
6065 | fill_dig_outs(codec); | ||
6066 | |||
6067 | if (spec->kctls.list) | ||
6068 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | ||
6069 | |||
6070 | spec->input_mux = &spec->private_imux[0]; | ||
6071 | |||
6072 | if (spec->hp_mux) | ||
6073 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | ||
6074 | |||
6075 | return 1; | ||
6076 | } | ||
6077 | |||
6078 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
6079 | static struct hda_amp_list vt1812_loopbacks[] = { | ||
6080 | { 0x21, HDA_INPUT, 0 }, | ||
6081 | { 0x21, HDA_INPUT, 1 }, | ||
6082 | { 0x21, HDA_INPUT, 2 }, | ||
6083 | { } /* end */ | ||
6084 | }; | ||
6085 | #endif | ||
6086 | |||
6087 | |||
6088 | /* patch for vt1812 */ | ||
6089 | static int patch_vt1812(struct hda_codec *codec) | ||
6090 | { | ||
6091 | struct via_spec *spec; | ||
6092 | int err; | ||
6093 | |||
6094 | /* create a codec specific record */ | ||
6095 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
6096 | if (spec == NULL) | ||
6097 | return -ENOMEM; | ||
6098 | |||
6099 | codec->spec = spec; | ||
6100 | |||
6101 | /* automatic parse from the BIOS config */ | ||
6102 | err = vt1812_parse_auto_config(codec); | ||
6103 | if (err < 0) { | ||
6104 | via_free(codec); | ||
6105 | return err; | ||
6106 | } else if (!err) { | ||
6107 | printk(KERN_INFO "hda_codec: Cannot set up configuration " | ||
6108 | "from BIOS. Using genenic mode...\n"); | ||
6109 | } | ||
6110 | |||
6111 | |||
6112 | spec->init_verbs[spec->num_iverbs++] = vt1812_volume_init_verbs; | ||
6113 | spec->init_verbs[spec->num_iverbs++] = vt1812_uniwill_init_verbs; | ||
6114 | |||
6115 | spec->stream_name_analog = "VT1812 Analog"; | ||
6116 | spec->stream_analog_playback = &vt1812_pcm_analog_playback; | ||
6117 | spec->stream_analog_capture = &vt1812_pcm_analog_capture; | ||
6118 | |||
6119 | spec->stream_name_digital = "VT1812 Digital"; | ||
6120 | spec->stream_digital_playback = &vt1812_pcm_digital_playback; | ||
6121 | |||
6122 | |||
6123 | if (!spec->adc_nids && spec->input_mux) { | ||
6124 | spec->adc_nids = vt1812_adc_nids; | ||
6125 | spec->num_adc_nids = ARRAY_SIZE(vt1812_adc_nids); | ||
6126 | get_mux_nids(codec); | ||
6127 | override_mic_boost(codec, 0x2b, 0, 3, 40); | ||
6128 | override_mic_boost(codec, 0x29, 0, 3, 40); | ||
6129 | spec->mixers[spec->num_mixers] = vt1812_capture_mixer; | ||
6130 | spec->num_mixers++; | ||
6131 | } | ||
6132 | |||
6133 | codec->patch_ops = via_patch_ops; | ||
6134 | |||
6135 | codec->patch_ops.init = via_auto_init; | ||
6136 | codec->patch_ops.unsol_event = via_unsol_event; | ||
6137 | |||
6138 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
6139 | spec->loopback.amplist = vt1812_loopbacks; | ||
6140 | #endif | ||
3245 | 6141 | ||
3246 | return 0; | 6142 | return 0; |
3247 | } | 6143 | } |
@@ -3318,6 +6214,23 @@ static struct hda_codec_preset snd_hda_preset_via[] = { | |||
3318 | .patch = patch_vt1702}, | 6214 | .patch = patch_vt1702}, |
3319 | { .id = 0x11067398, .name = "VT1702", | 6215 | { .id = 0x11067398, .name = "VT1702", |
3320 | .patch = patch_vt1702}, | 6216 | .patch = patch_vt1702}, |
6217 | { .id = 0x11060428, .name = "VT1718S", | ||
6218 | .patch = patch_vt1718S}, | ||
6219 | { .id = 0x11064428, .name = "VT1718S", | ||
6220 | .patch = patch_vt1718S}, | ||
6221 | { .id = 0x11060441, .name = "VT2020", | ||
6222 | .patch = patch_vt1718S}, | ||
6223 | { .id = 0x11064441, .name = "VT1828S", | ||
6224 | .patch = patch_vt1718S}, | ||
6225 | { .id = 0x11060433, .name = "VT1716S", | ||
6226 | .patch = patch_vt1716S}, | ||
6227 | { .id = 0x1106a721, .name = "VT1716S", | ||
6228 | .patch = patch_vt1716S}, | ||
6229 | { .id = 0x11060438, .name = "VT2002P", .patch = patch_vt2002P}, | ||
6230 | { .id = 0x11064438, .name = "VT2002P", .patch = patch_vt2002P}, | ||
6231 | { .id = 0x11060448, .name = "VT1812", .patch = patch_vt1812}, | ||
6232 | { .id = 0x11060440, .name = "VT1818S", | ||
6233 | .patch = patch_vt1708S}, | ||
3321 | {} /* terminator */ | 6234 | {} /* terminator */ |
3322 | }; | 6235 | }; |
3323 | 6236 | ||
diff --git a/sound/pci/ice1712/Makefile b/sound/pci/ice1712/Makefile index 536eae2ccf94..f7ce33f00ea5 100644 --- a/sound/pci/ice1712/Makefile +++ b/sound/pci/ice1712/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | snd-ice17xx-ak4xxx-objs := ak4xxx.o | 6 | snd-ice17xx-ak4xxx-objs := ak4xxx.o |
7 | snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o | 7 | snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o |
8 | snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o prodigy_hifi.o juli.o phase.o wtm.o se.o maya44.o | 8 | snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o prodigy_hifi.o juli.o phase.o wtm.o se.o maya44.o quartet.o |
9 | 9 | ||
10 | # Toplevel Module Dependency | 10 | # Toplevel Module Dependency |
11 | obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o | 11 | obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o |
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 110d16e52733..765d7bd4c3d4 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c | |||
@@ -689,32 +689,14 @@ static int aureon_ac97_mmute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
689 | return change; | 689 | return change; |
690 | } | 690 | } |
691 | 691 | ||
692 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); | 692 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -10000, 100, 1); |
693 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); | 693 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); |
694 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0); | 694 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0); |
695 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0); | 695 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0); |
696 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0); | 696 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0); |
697 | 697 | ||
698 | /* | 698 | #define WM_VOL_MAX 100 |
699 | * Logarithmic volume values for WM8770 | 699 | #define WM_VOL_CNT 101 /* 0dB .. -100dB */ |
700 | * Computed as 20 * Log10(255 / x) | ||
701 | */ | ||
702 | static const unsigned char wm_vol[256] = { | ||
703 | 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23, | ||
704 | 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, | ||
705 | 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, | ||
706 | 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, | ||
707 | 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, | ||
708 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, | ||
709 | 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||
710 | 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, | ||
711 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
712 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
713 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
714 | 0, 0 | ||
715 | }; | ||
716 | |||
717 | #define WM_VOL_MAX (sizeof(wm_vol) - 1) | ||
718 | #define WM_VOL_MUTE 0x8000 | 700 | #define WM_VOL_MUTE 0x8000 |
719 | 701 | ||
720 | static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) | 702 | static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) |
@@ -724,7 +706,8 @@ static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned sho | |||
724 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) | 706 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) |
725 | nvol = 0; | 707 | nvol = 0; |
726 | else | 708 | else |
727 | nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX]; | 709 | nvol = ((vol % WM_VOL_CNT) * (master % WM_VOL_CNT)) / |
710 | WM_VOL_MAX; | ||
728 | 711 | ||
729 | wm_put(ice, index, nvol); | 712 | wm_put(ice, index, nvol); |
730 | wm_put_nocache(ice, index, 0x180 | nvol); | 713 | wm_put_nocache(ice, index, 0x180 | nvol); |
@@ -820,7 +803,7 @@ static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info * | |||
820 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 803 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
821 | uinfo->count = voices; | 804 | uinfo->count = voices; |
822 | uinfo->value.integer.min = 0; /* mute (-101dB) */ | 805 | uinfo->value.integer.min = 0; /* mute (-101dB) */ |
823 | uinfo->value.integer.max = 0x7F; /* 0dB */ | 806 | uinfo->value.integer.max = WM_VOL_MAX; /* 0dB */ |
824 | return 0; | 807 | return 0; |
825 | } | 808 | } |
826 | 809 | ||
@@ -850,7 +833,7 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value * | |||
850 | snd_ice1712_save_gpio_status(ice); | 833 | snd_ice1712_save_gpio_status(ice); |
851 | for (i = 0; i < voices; i++) { | 834 | for (i = 0; i < voices; i++) { |
852 | unsigned int vol = ucontrol->value.integer.value[i]; | 835 | unsigned int vol = ucontrol->value.integer.value[i]; |
853 | if (vol > 0x7f) | 836 | if (vol > WM_VOL_MAX) |
854 | continue; | 837 | continue; |
855 | vol |= spec->vol[ofs+i]; | 838 | vol |= spec->vol[ofs+i]; |
856 | if (vol != spec->vol[ofs+i]) { | 839 | if (vol != spec->vol[ofs+i]) { |
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index d74033a2cfbe..c7cff6f8168a 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c | |||
@@ -298,6 +298,16 @@ static void snd_ice1712_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data) | |||
298 | inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ | 298 | inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ |
299 | } | 299 | } |
300 | 300 | ||
301 | static unsigned int snd_ice1712_get_gpio_dir(struct snd_ice1712 *ice) | ||
302 | { | ||
303 | return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DIRECTION); | ||
304 | } | ||
305 | |||
306 | static unsigned int snd_ice1712_get_gpio_mask(struct snd_ice1712 *ice) | ||
307 | { | ||
308 | return snd_ice1712_read(ice, ICE1712_IREG_GPIO_WRITE_MASK); | ||
309 | } | ||
310 | |||
301 | static void snd_ice1712_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) | 311 | static void snd_ice1712_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) |
302 | { | 312 | { |
303 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, data); | 313 | snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, data); |
@@ -2557,7 +2567,9 @@ static int __devinit snd_ice1712_create(struct snd_card *card, | |||
2557 | mutex_init(&ice->i2c_mutex); | 2567 | mutex_init(&ice->i2c_mutex); |
2558 | mutex_init(&ice->open_mutex); | 2568 | mutex_init(&ice->open_mutex); |
2559 | ice->gpio.set_mask = snd_ice1712_set_gpio_mask; | 2569 | ice->gpio.set_mask = snd_ice1712_set_gpio_mask; |
2570 | ice->gpio.get_mask = snd_ice1712_get_gpio_mask; | ||
2560 | ice->gpio.set_dir = snd_ice1712_set_gpio_dir; | 2571 | ice->gpio.set_dir = snd_ice1712_set_gpio_dir; |
2572 | ice->gpio.get_dir = snd_ice1712_get_gpio_dir; | ||
2561 | ice->gpio.set_data = snd_ice1712_set_gpio_data; | 2573 | ice->gpio.set_data = snd_ice1712_set_gpio_data; |
2562 | ice->gpio.get_data = snd_ice1712_get_gpio_data; | 2574 | ice->gpio.get_data = snd_ice1712_get_gpio_data; |
2563 | 2575 | ||
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index 9da2dae64c5b..0da778a69ef8 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h | |||
@@ -359,7 +359,9 @@ struct snd_ice1712 { | |||
359 | unsigned int saved[2]; /* for ewx_i2c */ | 359 | unsigned int saved[2]; /* for ewx_i2c */ |
360 | /* operators */ | 360 | /* operators */ |
361 | void (*set_mask)(struct snd_ice1712 *ice, unsigned int data); | 361 | void (*set_mask)(struct snd_ice1712 *ice, unsigned int data); |
362 | unsigned int (*get_mask)(struct snd_ice1712 *ice); | ||
362 | void (*set_dir)(struct snd_ice1712 *ice, unsigned int data); | 363 | void (*set_dir)(struct snd_ice1712 *ice, unsigned int data); |
364 | unsigned int (*get_dir)(struct snd_ice1712 *ice); | ||
363 | void (*set_data)(struct snd_ice1712 *ice, unsigned int data); | 365 | void (*set_data)(struct snd_ice1712 *ice, unsigned int data); |
364 | unsigned int (*get_data)(struct snd_ice1712 *ice); | 366 | unsigned int (*get_data)(struct snd_ice1712 *ice); |
365 | /* misc operators - move to another place? */ | 367 | /* misc operators - move to another place? */ |
@@ -377,13 +379,16 @@ struct snd_ice1712 { | |||
377 | unsigned int (*get_rate)(struct snd_ice1712 *ice); | 379 | unsigned int (*get_rate)(struct snd_ice1712 *ice); |
378 | void (*set_rate)(struct snd_ice1712 *ice, unsigned int rate); | 380 | void (*set_rate)(struct snd_ice1712 *ice, unsigned int rate); |
379 | unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); | 381 | unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); |
380 | void (*set_spdif_clock)(struct snd_ice1712 *ice); | 382 | int (*set_spdif_clock)(struct snd_ice1712 *ice, int type); |
381 | 383 | int (*get_spdif_master_type)(struct snd_ice1712 *ice); | |
384 | char **ext_clock_names; | ||
385 | int ext_clock_count; | ||
386 | void (*pro_open)(struct snd_ice1712 *, struct snd_pcm_substream *); | ||
382 | #ifdef CONFIG_PM | 387 | #ifdef CONFIG_PM |
383 | int (*pm_suspend)(struct snd_ice1712 *); | 388 | int (*pm_suspend)(struct snd_ice1712 *); |
384 | int (*pm_resume)(struct snd_ice1712 *); | 389 | int (*pm_resume)(struct snd_ice1712 *); |
385 | int pm_suspend_enabled:1; | 390 | unsigned int pm_suspend_enabled:1; |
386 | int pm_saved_is_spdif_master:1; | 391 | unsigned int pm_saved_is_spdif_master:1; |
387 | unsigned int pm_saved_spdif_ctrl; | 392 | unsigned int pm_saved_spdif_ctrl; |
388 | unsigned char pm_saved_spdif_cfg; | 393 | unsigned char pm_saved_spdif_cfg; |
389 | unsigned int pm_saved_route; | 394 | unsigned int pm_saved_route; |
@@ -399,6 +404,11 @@ static inline void snd_ice1712_gpio_set_dir(struct snd_ice1712 *ice, unsigned in | |||
399 | ice->gpio.set_dir(ice, bits); | 404 | ice->gpio.set_dir(ice, bits); |
400 | } | 405 | } |
401 | 406 | ||
407 | static inline unsigned int snd_ice1712_gpio_get_dir(struct snd_ice1712 *ice) | ||
408 | { | ||
409 | return ice->gpio.get_dir(ice); | ||
410 | } | ||
411 | |||
402 | static inline void snd_ice1712_gpio_set_mask(struct snd_ice1712 *ice, unsigned int bits) | 412 | static inline void snd_ice1712_gpio_set_mask(struct snd_ice1712 *ice, unsigned int bits) |
403 | { | 413 | { |
404 | ice->gpio.set_mask(ice, bits); | 414 | ice->gpio.set_mask(ice, bits); |
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 10fc92c05574..ae29073eea93 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include "phase.h" | 53 | #include "phase.h" |
54 | #include "wtm.h" | 54 | #include "wtm.h" |
55 | #include "se.h" | 55 | #include "se.h" |
56 | #include "quartet.h" | ||
56 | 57 | ||
57 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); | 58 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); |
58 | MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)"); | 59 | MODULE_DESCRIPTION("VIA ICEnsemble ICE1724/1720 (Envy24HT/PT)"); |
@@ -70,6 +71,7 @@ MODULE_SUPPORTED_DEVICE("{" | |||
70 | PHASE_DEVICE_DESC | 71 | PHASE_DEVICE_DESC |
71 | WTM_DEVICE_DESC | 72 | WTM_DEVICE_DESC |
72 | SE_DEVICE_DESC | 73 | SE_DEVICE_DESC |
74 | QTET_DEVICE_DESC | ||
73 | "{VIA,VT1720}," | 75 | "{VIA,VT1720}," |
74 | "{VIA,VT1724}," | 76 | "{VIA,VT1724}," |
75 | "{ICEnsemble,Generic ICE1724}," | 77 | "{ICEnsemble,Generic ICE1724}," |
@@ -104,6 +106,8 @@ static int PRO_RATE_LOCKED; | |||
104 | static int PRO_RATE_RESET = 1; | 106 | static int PRO_RATE_RESET = 1; |
105 | static unsigned int PRO_RATE_DEFAULT = 44100; | 107 | static unsigned int PRO_RATE_DEFAULT = 44100; |
106 | 108 | ||
109 | static char *ext_clock_names[1] = { "IEC958 In" }; | ||
110 | |||
107 | /* | 111 | /* |
108 | * Basic I/O | 112 | * Basic I/O |
109 | */ | 113 | */ |
@@ -118,9 +122,12 @@ static inline int stdclock_is_spdif_master(struct snd_ice1712 *ice) | |||
118 | return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0; | 122 | return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0; |
119 | } | 123 | } |
120 | 124 | ||
125 | /* | ||
126 | * locking rate makes sense only for internal clock mode | ||
127 | */ | ||
121 | static inline int is_pro_rate_locked(struct snd_ice1712 *ice) | 128 | static inline int is_pro_rate_locked(struct snd_ice1712 *ice) |
122 | { | 129 | { |
123 | return ice->is_spdif_master(ice) || PRO_RATE_LOCKED; | 130 | return (!ice->is_spdif_master(ice)) && PRO_RATE_LOCKED; |
124 | } | 131 | } |
125 | 132 | ||
126 | /* | 133 | /* |
@@ -196,6 +203,12 @@ static void snd_vt1724_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data) | |||
196 | inw(ICEREG1724(ice, GPIO_DIRECTION)); /* dummy read for pci-posting */ | 203 | inw(ICEREG1724(ice, GPIO_DIRECTION)); /* dummy read for pci-posting */ |
197 | } | 204 | } |
198 | 205 | ||
206 | /* get gpio direction 0 = read, 1 = write */ | ||
207 | static unsigned int snd_vt1724_get_gpio_dir(struct snd_ice1712 *ice) | ||
208 | { | ||
209 | return inl(ICEREG1724(ice, GPIO_DIRECTION)); | ||
210 | } | ||
211 | |||
199 | /* set the gpio mask (0 = writable) */ | 212 | /* set the gpio mask (0 = writable) */ |
200 | static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) | 213 | static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) |
201 | { | 214 | { |
@@ -205,6 +218,17 @@ static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) | |||
205 | inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */ | 218 | inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */ |
206 | } | 219 | } |
207 | 220 | ||
221 | static unsigned int snd_vt1724_get_gpio_mask(struct snd_ice1712 *ice) | ||
222 | { | ||
223 | unsigned int mask; | ||
224 | if (!ice->vt1720) | ||
225 | mask = (unsigned int)inb(ICEREG1724(ice, GPIO_WRITE_MASK_22)); | ||
226 | else | ||
227 | mask = 0; | ||
228 | mask = (mask << 16) | inw(ICEREG1724(ice, GPIO_WRITE_MASK)); | ||
229 | return mask; | ||
230 | } | ||
231 | |||
208 | static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data) | 232 | static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data) |
209 | { | 233 | { |
210 | outw(data, ICEREG1724(ice, GPIO_DATA)); | 234 | outw(data, ICEREG1724(ice, GPIO_DATA)); |
@@ -651,16 +675,22 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, | |||
651 | return ((rate == ice->cur_rate) && !force) ? 0 : -EBUSY; | 675 | return ((rate == ice->cur_rate) && !force) ? 0 : -EBUSY; |
652 | } | 676 | } |
653 | if (!force && is_pro_rate_locked(ice)) { | 677 | if (!force && is_pro_rate_locked(ice)) { |
678 | /* comparing required and current rate - makes sense for | ||
679 | * internal clock only */ | ||
654 | spin_unlock_irqrestore(&ice->reg_lock, flags); | 680 | spin_unlock_irqrestore(&ice->reg_lock, flags); |
655 | return (rate == ice->cur_rate) ? 0 : -EBUSY; | 681 | return (rate == ice->cur_rate) ? 0 : -EBUSY; |
656 | } | 682 | } |
657 | 683 | ||
658 | old_rate = ice->get_rate(ice); | 684 | if (force || !ice->is_spdif_master(ice)) { |
659 | if (force || (old_rate != rate)) | 685 | /* force means the rate was switched by ucontrol, otherwise |
660 | ice->set_rate(ice, rate); | 686 | * setting clock rate for internal clock mode */ |
661 | else if (rate == ice->cur_rate) { | 687 | old_rate = ice->get_rate(ice); |
662 | spin_unlock_irqrestore(&ice->reg_lock, flags); | 688 | if (force || (old_rate != rate)) |
663 | return 0; | 689 | ice->set_rate(ice, rate); |
690 | else if (rate == ice->cur_rate) { | ||
691 | spin_unlock_irqrestore(&ice->reg_lock, flags); | ||
692 | return 0; | ||
693 | } | ||
664 | } | 694 | } |
665 | 695 | ||
666 | ice->cur_rate = rate; | 696 | ice->cur_rate = rate; |
@@ -1016,6 +1046,8 @@ static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream) | |||
1016 | VT1724_BUFFER_ALIGN); | 1046 | VT1724_BUFFER_ALIGN); |
1017 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, | 1047 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, |
1018 | VT1724_BUFFER_ALIGN); | 1048 | VT1724_BUFFER_ALIGN); |
1049 | if (ice->pro_open) | ||
1050 | ice->pro_open(ice, substream); | ||
1019 | return 0; | 1051 | return 0; |
1020 | } | 1052 | } |
1021 | 1053 | ||
@@ -1034,6 +1066,8 @@ static int snd_vt1724_capture_pro_open(struct snd_pcm_substream *substream) | |||
1034 | VT1724_BUFFER_ALIGN); | 1066 | VT1724_BUFFER_ALIGN); |
1035 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, | 1067 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, |
1036 | VT1724_BUFFER_ALIGN); | 1068 | VT1724_BUFFER_ALIGN); |
1069 | if (ice->pro_open) | ||
1070 | ice->pro_open(ice, substream); | ||
1037 | return 0; | 1071 | return 0; |
1038 | } | 1072 | } |
1039 | 1073 | ||
@@ -1787,15 +1821,21 @@ static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol, | |||
1787 | struct snd_ctl_elem_info *uinfo) | 1821 | struct snd_ctl_elem_info *uinfo) |
1788 | { | 1822 | { |
1789 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1823 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1790 | 1824 | int hw_rates_count = ice->hw_rates->count; | |
1791 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1825 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
1792 | uinfo->count = 1; | 1826 | uinfo->count = 1; |
1793 | uinfo->value.enumerated.items = ice->hw_rates->count + 1; | 1827 | |
1828 | uinfo->value.enumerated.items = hw_rates_count + ice->ext_clock_count; | ||
1829 | /* upper limit - keep at top */ | ||
1794 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | 1830 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
1795 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | 1831 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
1796 | if (uinfo->value.enumerated.item == uinfo->value.enumerated.items - 1) | 1832 | if (uinfo->value.enumerated.item >= hw_rates_count) |
1797 | strcpy(uinfo->value.enumerated.name, "IEC958 Input"); | 1833 | /* ext_clock items */ |
1834 | strcpy(uinfo->value.enumerated.name, | ||
1835 | ice->ext_clock_names[ | ||
1836 | uinfo->value.enumerated.item - hw_rates_count]); | ||
1798 | else | 1837 | else |
1838 | /* int clock items */ | ||
1799 | sprintf(uinfo->value.enumerated.name, "%d", | 1839 | sprintf(uinfo->value.enumerated.name, "%d", |
1800 | ice->hw_rates->list[uinfo->value.enumerated.item]); | 1840 | ice->hw_rates->list[uinfo->value.enumerated.item]); |
1801 | return 0; | 1841 | return 0; |
@@ -1809,7 +1849,8 @@ static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol, | |||
1809 | 1849 | ||
1810 | spin_lock_irq(&ice->reg_lock); | 1850 | spin_lock_irq(&ice->reg_lock); |
1811 | if (ice->is_spdif_master(ice)) { | 1851 | if (ice->is_spdif_master(ice)) { |
1812 | ucontrol->value.enumerated.item[0] = ice->hw_rates->count; | 1852 | ucontrol->value.enumerated.item[0] = ice->hw_rates->count + |
1853 | ice->get_spdif_master_type(ice); | ||
1813 | } else { | 1854 | } else { |
1814 | rate = ice->get_rate(ice); | 1855 | rate = ice->get_rate(ice); |
1815 | ucontrol->value.enumerated.item[0] = 0; | 1856 | ucontrol->value.enumerated.item[0] = 0; |
@@ -1824,8 +1865,14 @@ static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol, | |||
1824 | return 0; | 1865 | return 0; |
1825 | } | 1866 | } |
1826 | 1867 | ||
1868 | static int stdclock_get_spdif_master_type(struct snd_ice1712 *ice) | ||
1869 | { | ||
1870 | /* standard external clock - only single type - SPDIF IN */ | ||
1871 | return 0; | ||
1872 | } | ||
1873 | |||
1827 | /* setting clock to external - SPDIF */ | 1874 | /* setting clock to external - SPDIF */ |
1828 | static void stdclock_set_spdif_clock(struct snd_ice1712 *ice) | 1875 | static int stdclock_set_spdif_clock(struct snd_ice1712 *ice, int type) |
1829 | { | 1876 | { |
1830 | unsigned char oval; | 1877 | unsigned char oval; |
1831 | unsigned char i2s_oval; | 1878 | unsigned char i2s_oval; |
@@ -1834,27 +1881,30 @@ static void stdclock_set_spdif_clock(struct snd_ice1712 *ice) | |||
1834 | /* setting 256fs */ | 1881 | /* setting 256fs */ |
1835 | i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT)); | 1882 | i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT)); |
1836 | outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X, ICEMT1724(ice, I2S_FORMAT)); | 1883 | outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X, ICEMT1724(ice, I2S_FORMAT)); |
1884 | return 0; | ||
1837 | } | 1885 | } |
1838 | 1886 | ||
1887 | |||
1839 | static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol, | 1888 | static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol, |
1840 | struct snd_ctl_elem_value *ucontrol) | 1889 | struct snd_ctl_elem_value *ucontrol) |
1841 | { | 1890 | { |
1842 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 1891 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
1843 | unsigned int old_rate, new_rate; | 1892 | unsigned int old_rate, new_rate; |
1844 | unsigned int item = ucontrol->value.enumerated.item[0]; | 1893 | unsigned int item = ucontrol->value.enumerated.item[0]; |
1845 | unsigned int spdif = ice->hw_rates->count; | 1894 | unsigned int first_ext_clock = ice->hw_rates->count; |
1846 | 1895 | ||
1847 | if (item > spdif) | 1896 | if (item > first_ext_clock + ice->ext_clock_count - 1) |
1848 | return -EINVAL; | 1897 | return -EINVAL; |
1849 | 1898 | ||
1899 | /* if rate = 0 => external clock */ | ||
1850 | spin_lock_irq(&ice->reg_lock); | 1900 | spin_lock_irq(&ice->reg_lock); |
1851 | if (ice->is_spdif_master(ice)) | 1901 | if (ice->is_spdif_master(ice)) |
1852 | old_rate = 0; | 1902 | old_rate = 0; |
1853 | else | 1903 | else |
1854 | old_rate = ice->get_rate(ice); | 1904 | old_rate = ice->get_rate(ice); |
1855 | if (item == spdif) { | 1905 | if (item >= first_ext_clock) { |
1856 | /* switching to external clock via SPDIF */ | 1906 | /* switching to external clock */ |
1857 | ice->set_spdif_clock(ice); | 1907 | ice->set_spdif_clock(ice, item - first_ext_clock); |
1858 | new_rate = 0; | 1908 | new_rate = 0; |
1859 | } else { | 1909 | } else { |
1860 | /* internal on-card clock */ | 1910 | /* internal on-card clock */ |
@@ -1866,7 +1916,7 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol, | |||
1866 | } | 1916 | } |
1867 | spin_unlock_irq(&ice->reg_lock); | 1917 | spin_unlock_irq(&ice->reg_lock); |
1868 | 1918 | ||
1869 | /* the first reset to the SPDIF master mode? */ | 1919 | /* the first switch to the ext. clock mode? */ |
1870 | if (old_rate != new_rate && !new_rate) { | 1920 | if (old_rate != new_rate && !new_rate) { |
1871 | /* notify akm chips as well */ | 1921 | /* notify akm chips as well */ |
1872 | unsigned int i; | 1922 | unsigned int i; |
@@ -2136,6 +2186,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = { | |||
2136 | snd_vt1724_phase_cards, | 2186 | snd_vt1724_phase_cards, |
2137 | snd_vt1724_wtm_cards, | 2187 | snd_vt1724_wtm_cards, |
2138 | snd_vt1724_se_cards, | 2188 | snd_vt1724_se_cards, |
2189 | snd_vt1724_qtet_cards, | ||
2139 | NULL, | 2190 | NULL, |
2140 | }; | 2191 | }; |
2141 | 2192 | ||
@@ -2434,7 +2485,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card, | |||
2434 | mutex_init(&ice->open_mutex); | 2485 | mutex_init(&ice->open_mutex); |
2435 | mutex_init(&ice->i2c_mutex); | 2486 | mutex_init(&ice->i2c_mutex); |
2436 | ice->gpio.set_mask = snd_vt1724_set_gpio_mask; | 2487 | ice->gpio.set_mask = snd_vt1724_set_gpio_mask; |
2488 | ice->gpio.get_mask = snd_vt1724_get_gpio_mask; | ||
2437 | ice->gpio.set_dir = snd_vt1724_set_gpio_dir; | 2489 | ice->gpio.set_dir = snd_vt1724_set_gpio_dir; |
2490 | ice->gpio.get_dir = snd_vt1724_get_gpio_dir; | ||
2438 | ice->gpio.set_data = snd_vt1724_set_gpio_data; | 2491 | ice->gpio.set_data = snd_vt1724_set_gpio_data; |
2439 | ice->gpio.get_data = snd_vt1724_get_gpio_data; | 2492 | ice->gpio.get_data = snd_vt1724_get_gpio_data; |
2440 | ice->card = card; | 2493 | ice->card = card; |
@@ -2522,6 +2575,9 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci, | |||
2522 | return err; | 2575 | return err; |
2523 | } | 2576 | } |
2524 | 2577 | ||
2578 | /* field init before calling chip_init */ | ||
2579 | ice->ext_clock_count = 0; | ||
2580 | |||
2525 | for (tbl = card_tables; *tbl; tbl++) { | 2581 | for (tbl = card_tables; *tbl; tbl++) { |
2526 | for (c = *tbl; c->subvendor; c++) { | 2582 | for (c = *tbl; c->subvendor; c++) { |
2527 | if (c->subvendor == ice->eeprom.subvendor) { | 2583 | if (c->subvendor == ice->eeprom.subvendor) { |
@@ -2560,6 +2616,13 @@ __found: | |||
2560 | ice->set_mclk = stdclock_set_mclk; | 2616 | ice->set_mclk = stdclock_set_mclk; |
2561 | if (!ice->set_spdif_clock) | 2617 | if (!ice->set_spdif_clock) |
2562 | ice->set_spdif_clock = stdclock_set_spdif_clock; | 2618 | ice->set_spdif_clock = stdclock_set_spdif_clock; |
2619 | if (!ice->get_spdif_master_type) | ||
2620 | ice->get_spdif_master_type = stdclock_get_spdif_master_type; | ||
2621 | if (!ice->ext_clock_names) | ||
2622 | ice->ext_clock_names = ext_clock_names; | ||
2623 | if (!ice->ext_clock_count) | ||
2624 | ice->ext_clock_count = ARRAY_SIZE(ext_clock_names); | ||
2625 | |||
2563 | if (!ice->hw_rates) | 2626 | if (!ice->hw_rates) |
2564 | set_std_hw_rates(ice); | 2627 | set_std_hw_rates(ice); |
2565 | 2628 | ||
@@ -2719,7 +2782,7 @@ static int snd_vt1724_resume(struct pci_dev *pci) | |||
2719 | 2782 | ||
2720 | if (ice->pm_saved_is_spdif_master) { | 2783 | if (ice->pm_saved_is_spdif_master) { |
2721 | /* switching to external clock via SPDIF */ | 2784 | /* switching to external clock via SPDIF */ |
2722 | ice->set_spdif_clock(ice); | 2785 | ice->set_spdif_clock(ice, 0); |
2723 | } else { | 2786 | } else { |
2724 | /* internal on-card clock */ | 2787 | /* internal on-card clock */ |
2725 | snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); | 2788 | snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); |
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index fd948bfd9aef..98bc3b7681b5 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c | |||
@@ -380,7 +380,7 @@ static struct snd_kcontrol_new juli_mute_controls[] __devinitdata = { | |||
380 | * inputs) are fed from Xilinx. | 380 | * inputs) are fed from Xilinx. |
381 | * | 381 | * |
382 | * I even checked traces on board and coded a support in driver for | 382 | * I even checked traces on board and coded a support in driver for |
383 | * an alternative possiblity - the unused I2S ICE output channels | 383 | * an alternative possibility - the unused I2S ICE output channels |
384 | * switched to HW-IN/SPDIF-IN and providing the monitoring signal to | 384 | * switched to HW-IN/SPDIF-IN and providing the monitoring signal to |
385 | * the DAC - to no avail. The I2S outputs seem to be unconnected. | 385 | * the DAC - to no avail. The I2S outputs seem to be unconnected. |
386 | * | 386 | * |
@@ -412,25 +412,6 @@ static struct snd_kcontrol_new juli_mute_controls[] __devinitdata = { | |||
412 | }, | 412 | }, |
413 | }; | 413 | }; |
414 | 414 | ||
415 | |||
416 | static void ak4358_proc_regs_read(struct snd_info_entry *entry, | ||
417 | struct snd_info_buffer *buffer) | ||
418 | { | ||
419 | struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; | ||
420 | int reg, val; | ||
421 | for (reg = 0; reg <= 0xf; reg++) { | ||
422 | val = snd_akm4xxx_get(ice->akm, 0, reg); | ||
423 | snd_iprintf(buffer, "0x%02x = 0x%02x\n", reg, val); | ||
424 | } | ||
425 | } | ||
426 | |||
427 | static void ak4358_proc_init(struct snd_ice1712 *ice) | ||
428 | { | ||
429 | struct snd_info_entry *entry; | ||
430 | if (!snd_card_proc_new(ice->card, "ak4358_codec", &entry)) | ||
431 | snd_info_set_text_ops(entry, ice, ak4358_proc_regs_read); | ||
432 | } | ||
433 | |||
434 | static char *slave_vols[] __devinitdata = { | 415 | static char *slave_vols[] __devinitdata = { |
435 | PCM_VOLUME, | 416 | PCM_VOLUME, |
436 | MONITOR_AN_IN_VOLUME, | 417 | MONITOR_AN_IN_VOLUME, |
@@ -496,14 +477,37 @@ static int __devinit juli_add_controls(struct snd_ice1712 *ice) | |||
496 | /* only capture SPDIF over AK4114 */ | 477 | /* only capture SPDIF over AK4114 */ |
497 | err = snd_ak4114_build(spec->ak4114, NULL, | 478 | err = snd_ak4114_build(spec->ak4114, NULL, |
498 | ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); | 479 | ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); |
499 | |||
500 | ak4358_proc_init(ice); | ||
501 | if (err < 0) | 480 | if (err < 0) |
502 | return err; | 481 | return err; |
503 | return 0; | 482 | return 0; |
504 | } | 483 | } |
505 | 484 | ||
506 | /* | 485 | /* |
486 | * suspend/resume | ||
487 | * */ | ||
488 | |||
489 | #ifdef CONFIG_PM | ||
490 | static int juli_resume(struct snd_ice1712 *ice) | ||
491 | { | ||
492 | struct snd_akm4xxx *ak = ice->akm; | ||
493 | struct juli_spec *spec = ice->spec; | ||
494 | /* akm4358 un-reset, un-mute */ | ||
495 | snd_akm4xxx_reset(ak, 0); | ||
496 | /* reinit ak4114 */ | ||
497 | snd_ak4114_reinit(spec->ak4114); | ||
498 | return 0; | ||
499 | } | ||
500 | |||
501 | static int juli_suspend(struct snd_ice1712 *ice) | ||
502 | { | ||
503 | struct snd_akm4xxx *ak = ice->akm; | ||
504 | /* akm4358 reset and soft-mute */ | ||
505 | snd_akm4xxx_reset(ak, 1); | ||
506 | return 0; | ||
507 | } | ||
508 | #endif | ||
509 | |||
510 | /* | ||
507 | * initialize the chip | 511 | * initialize the chip |
508 | */ | 512 | */ |
509 | 513 | ||
@@ -550,13 +554,14 @@ static inline unsigned char juli_set_mclk(struct snd_ice1712 *ice, | |||
550 | } | 554 | } |
551 | 555 | ||
552 | /* setting clock to external - SPDIF */ | 556 | /* setting clock to external - SPDIF */ |
553 | static void juli_set_spdif_clock(struct snd_ice1712 *ice) | 557 | static int juli_set_spdif_clock(struct snd_ice1712 *ice, int type) |
554 | { | 558 | { |
555 | unsigned int old; | 559 | unsigned int old; |
556 | old = ice->gpio.get_data(ice); | 560 | old = ice->gpio.get_data(ice); |
557 | /* external clock (= 0), multiply 1x, 48kHz */ | 561 | /* external clock (= 0), multiply 1x, 48kHz */ |
558 | ice->gpio.set_data(ice, (old & ~GPIO_RATE_MASK) | GPIO_MULTI_1X | | 562 | ice->gpio.set_data(ice, (old & ~GPIO_RATE_MASK) | GPIO_MULTI_1X | |
559 | GPIO_FREQ_48KHZ); | 563 | GPIO_FREQ_48KHZ); |
564 | return 0; | ||
560 | } | 565 | } |
561 | 566 | ||
562 | /* Called when ak4114 detects change in the input SPDIF stream */ | 567 | /* Called when ak4114 detects change in the input SPDIF stream */ |
@@ -646,6 +651,13 @@ static int __devinit juli_init(struct snd_ice1712 *ice) | |||
646 | ice->set_spdif_clock = juli_set_spdif_clock; | 651 | ice->set_spdif_clock = juli_set_spdif_clock; |
647 | 652 | ||
648 | ice->spdif.ops.open = juli_spdif_in_open; | 653 | ice->spdif.ops.open = juli_spdif_in_open; |
654 | |||
655 | #ifdef CONFIG_PM | ||
656 | ice->pm_resume = juli_resume; | ||
657 | ice->pm_suspend = juli_suspend; | ||
658 | ice->pm_suspend_enabled = 1; | ||
659 | #endif | ||
660 | |||
649 | return 0; | 661 | return 0; |
650 | } | 662 | } |
651 | 663 | ||
diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index c75515f5be6f..6a9fee3ee78f 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c | |||
@@ -1100,7 +1100,7 @@ static void ak4396_init(struct snd_ice1712 *ice) | |||
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | #ifdef CONFIG_PM | 1102 | #ifdef CONFIG_PM |
1103 | static int __devinit prodigy_hd2_resume(struct snd_ice1712 *ice) | 1103 | static int prodigy_hd2_resume(struct snd_ice1712 *ice) |
1104 | { | 1104 | { |
1105 | /* initialize ak4396 codec and restore previous mixer volumes */ | 1105 | /* initialize ak4396 codec and restore previous mixer volumes */ |
1106 | struct prodigy_hifi_spec *spec = ice->spec; | 1106 | struct prodigy_hifi_spec *spec = ice->spec; |
diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c new file mode 100644 index 000000000000..1948632787e6 --- /dev/null +++ b/sound/pci/ice1712/quartet.c | |||
@@ -0,0 +1,1130 @@ | |||
1 | /* | ||
2 | * ALSA driver for ICEnsemble VT1724 (Envy24HT) | ||
3 | * | ||
4 | * Lowlevel functions for Infrasonic Quartet | ||
5 | * | ||
6 | * Copyright (c) 2009 Pavel Hofman <pavel.hofman@ivitera.com> | ||
7 | * | ||
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 | |||
25 | #include <asm/io.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <sound/core.h> | ||
31 | #include <sound/tlv.h> | ||
32 | #include <sound/info.h> | ||
33 | |||
34 | #include "ice1712.h" | ||
35 | #include "envy24ht.h" | ||
36 | #include <sound/ak4113.h> | ||
37 | #include "quartet.h" | ||
38 | |||
39 | struct qtet_spec { | ||
40 | struct ak4113 *ak4113; | ||
41 | unsigned int scr; /* system control register */ | ||
42 | unsigned int mcr; /* monitoring control register */ | ||
43 | unsigned int cpld; /* cpld register */ | ||
44 | }; | ||
45 | |||
46 | struct qtet_kcontrol_private { | ||
47 | unsigned int bit; | ||
48 | void (*set_register)(struct snd_ice1712 *ice, unsigned int val); | ||
49 | unsigned int (*get_register)(struct snd_ice1712 *ice); | ||
50 | unsigned char *texts[2]; | ||
51 | }; | ||
52 | |||
53 | enum { | ||
54 | IN12_SEL = 0, | ||
55 | IN34_SEL, | ||
56 | AIN34_SEL, | ||
57 | COAX_OUT, | ||
58 | IN12_MON12, | ||
59 | IN12_MON34, | ||
60 | IN34_MON12, | ||
61 | IN34_MON34, | ||
62 | OUT12_MON34, | ||
63 | OUT34_MON12, | ||
64 | }; | ||
65 | |||
66 | static char *ext_clock_names[3] = {"IEC958 In", "Word Clock 1xFS", | ||
67 | "Word Clock 256xFS"}; | ||
68 | |||
69 | /* chip address on I2C bus */ | ||
70 | #define AK4113_ADDR 0x26 /* S/PDIF receiver */ | ||
71 | |||
72 | /* chip address on SPI bus */ | ||
73 | #define AK4620_ADDR 0x02 /* ADC/DAC */ | ||
74 | |||
75 | |||
76 | /* | ||
77 | * GPIO pins | ||
78 | */ | ||
79 | |||
80 | /* GPIO0 - O - DATA0, def. 0 */ | ||
81 | #define GPIO_D0 (1<<0) | ||
82 | /* GPIO1 - I/O - DATA1, Jack Detect Input0 (0:present, 1:missing), def. 1 */ | ||
83 | #define GPIO_D1_JACKDTC0 (1<<1) | ||
84 | /* GPIO2 - I/O - DATA2, Jack Detect Input1 (0:present, 1:missing), def. 1 */ | ||
85 | #define GPIO_D2_JACKDTC1 (1<<2) | ||
86 | /* GPIO3 - I/O - DATA3, def. 1 */ | ||
87 | #define GPIO_D3 (1<<3) | ||
88 | /* GPIO4 - I/O - DATA4, SPI CDTO, def. 1 */ | ||
89 | #define GPIO_D4_SPI_CDTO (1<<4) | ||
90 | /* GPIO5 - I/O - DATA5, SPI CCLK, def. 1 */ | ||
91 | #define GPIO_D5_SPI_CCLK (1<<5) | ||
92 | /* GPIO6 - I/O - DATA6, Cable Detect Input (0:detected, 1:not detected */ | ||
93 | #define GPIO_D6_CD (1<<6) | ||
94 | /* GPIO7 - I/O - DATA7, Device Detect Input (0:detected, 1:not detected */ | ||
95 | #define GPIO_D7_DD (1<<7) | ||
96 | /* GPIO8 - O - CPLD Chip Select, def. 1 */ | ||
97 | #define GPIO_CPLD_CSN (1<<8) | ||
98 | /* GPIO9 - O - CPLD register read/write (0:write, 1:read), def. 0 */ | ||
99 | #define GPIO_CPLD_RW (1<<9) | ||
100 | /* GPIO10 - O - SPI Chip Select for CODEC#0, def. 1 */ | ||
101 | #define GPIO_SPI_CSN0 (1<<10) | ||
102 | /* GPIO11 - O - SPI Chip Select for CODEC#1, def. 1 */ | ||
103 | #define GPIO_SPI_CSN1 (1<<11) | ||
104 | /* GPIO12 - O - Ex. Register Output Enable (0:enable, 1:disable), def. 1, | ||
105 | * init 0 */ | ||
106 | #define GPIO_EX_GPIOE (1<<12) | ||
107 | /* GPIO13 - O - Ex. Register0 Chip Select for System Control Register, | ||
108 | * def. 1 */ | ||
109 | #define GPIO_SCR (1<<13) | ||
110 | /* GPIO14 - O - Ex. Register1 Chip Select for Monitor Control Register, | ||
111 | * def. 1 */ | ||
112 | #define GPIO_MCR (1<<14) | ||
113 | |||
114 | #define GPIO_SPI_ALL (GPIO_D4_SPI_CDTO | GPIO_D5_SPI_CCLK |\ | ||
115 | GPIO_SPI_CSN0 | GPIO_SPI_CSN1) | ||
116 | |||
117 | #define GPIO_DATA_MASK (GPIO_D0 | GPIO_D1_JACKDTC0 | \ | ||
118 | GPIO_D2_JACKDTC1 | GPIO_D3 | \ | ||
119 | GPIO_D4_SPI_CDTO | GPIO_D5_SPI_CCLK | \ | ||
120 | GPIO_D6_CD | GPIO_D7_DD) | ||
121 | |||
122 | /* System Control Register GPIO_SCR data bits */ | ||
123 | /* Mic/Line select relay (0:line, 1:mic) */ | ||
124 | #define SCR_RELAY GPIO_D0 | ||
125 | /* Phantom power drive control (0:5V, 1:48V) */ | ||
126 | #define SCR_PHP_V GPIO_D1_JACKDTC0 | ||
127 | /* H/W mute control (0:Normal, 1:Mute) */ | ||
128 | #define SCR_MUTE GPIO_D2_JACKDTC1 | ||
129 | /* Phantom power control (0:Phantom on, 1:off) */ | ||
130 | #define SCR_PHP GPIO_D3 | ||
131 | /* Analog input 1/2 Source Select */ | ||
132 | #define SCR_AIN12_SEL0 GPIO_D4_SPI_CDTO | ||
133 | #define SCR_AIN12_SEL1 GPIO_D5_SPI_CCLK | ||
134 | /* Analog input 3/4 Source Select (0:line, 1:hi-z) */ | ||
135 | #define SCR_AIN34_SEL GPIO_D6_CD | ||
136 | /* Codec Power Down (0:power down, 1:normal) */ | ||
137 | #define SCR_CODEC_PDN GPIO_D7_DD | ||
138 | |||
139 | #define SCR_AIN12_LINE (0) | ||
140 | #define SCR_AIN12_MIC (SCR_AIN12_SEL0) | ||
141 | #define SCR_AIN12_LOWCUT (SCR_AIN12_SEL1 | SCR_AIN12_SEL0) | ||
142 | |||
143 | /* Monitor Control Register GPIO_MCR data bits */ | ||
144 | /* Input 1/2 to Monitor 1/2 (0:off, 1:on) */ | ||
145 | #define MCR_IN12_MON12 GPIO_D0 | ||
146 | /* Input 1/2 to Monitor 3/4 (0:off, 1:on) */ | ||
147 | #define MCR_IN12_MON34 GPIO_D1_JACKDTC0 | ||
148 | /* Input 3/4 to Monitor 1/2 (0:off, 1:on) */ | ||
149 | #define MCR_IN34_MON12 GPIO_D2_JACKDTC1 | ||
150 | /* Input 3/4 to Monitor 3/4 (0:off, 1:on) */ | ||
151 | #define MCR_IN34_MON34 GPIO_D3 | ||
152 | /* Output to Monitor 1/2 (0:off, 1:on) */ | ||
153 | #define MCR_OUT34_MON12 GPIO_D4_SPI_CDTO | ||
154 | /* Output to Monitor 3/4 (0:off, 1:on) */ | ||
155 | #define MCR_OUT12_MON34 GPIO_D5_SPI_CCLK | ||
156 | |||
157 | /* CPLD Register DATA bits */ | ||
158 | /* Clock Rate Select */ | ||
159 | #define CPLD_CKS0 GPIO_D0 | ||
160 | #define CPLD_CKS1 GPIO_D1_JACKDTC0 | ||
161 | #define CPLD_CKS2 GPIO_D2_JACKDTC1 | ||
162 | /* Sync Source Select (0:Internal, 1:External) */ | ||
163 | #define CPLD_SYNC_SEL GPIO_D3 | ||
164 | /* Word Clock FS Select (0:FS, 1:256FS) */ | ||
165 | #define CPLD_WORD_SEL GPIO_D4_SPI_CDTO | ||
166 | /* Coaxial Output Source (IS-Link) (0:SPDIF, 1:I2S) */ | ||
167 | #define CPLD_COAX_OUT GPIO_D5_SPI_CCLK | ||
168 | /* Input 1/2 Source Select (0:Analog12, 1:An34) */ | ||
169 | #define CPLD_IN12_SEL GPIO_D6_CD | ||
170 | /* Input 3/4 Source Select (0:Analog34, 1:Digital In) */ | ||
171 | #define CPLD_IN34_SEL GPIO_D7_DD | ||
172 | |||
173 | /* internal clock (CPLD_SYNC_SEL = 0) options */ | ||
174 | #define CPLD_CKS_44100HZ (0) | ||
175 | #define CPLD_CKS_48000HZ (CPLD_CKS0) | ||
176 | #define CPLD_CKS_88200HZ (CPLD_CKS1) | ||
177 | #define CPLD_CKS_96000HZ (CPLD_CKS1 | CPLD_CKS0) | ||
178 | #define CPLD_CKS_176400HZ (CPLD_CKS2) | ||
179 | #define CPLD_CKS_192000HZ (CPLD_CKS2 | CPLD_CKS0) | ||
180 | |||
181 | #define CPLD_CKS_MASK (CPLD_CKS0 | CPLD_CKS1 | CPLD_CKS2) | ||
182 | |||
183 | /* external clock (CPLD_SYNC_SEL = 1) options */ | ||
184 | /* external clock - SPDIF */ | ||
185 | #define CPLD_EXT_SPDIF (0 | CPLD_SYNC_SEL) | ||
186 | /* external clock - WordClock 1xfs */ | ||
187 | #define CPLD_EXT_WORDCLOCK_1FS (CPLD_CKS1 | CPLD_SYNC_SEL) | ||
188 | /* external clock - WordClock 256xfs */ | ||
189 | #define CPLD_EXT_WORDCLOCK_256FS (CPLD_CKS1 | CPLD_WORD_SEL |\ | ||
190 | CPLD_SYNC_SEL) | ||
191 | |||
192 | #define EXT_SPDIF_TYPE 0 | ||
193 | #define EXT_WORDCLOCK_1FS_TYPE 1 | ||
194 | #define EXT_WORDCLOCK_256FS_TYPE 2 | ||
195 | |||
196 | #define AK4620_DFS0 (1<<0) | ||
197 | #define AK4620_DFS1 (1<<1) | ||
198 | #define AK4620_CKS0 (1<<2) | ||
199 | #define AK4620_CKS1 (1<<3) | ||
200 | /* Clock and Format Control register */ | ||
201 | #define AK4620_DFS_REG 0x02 | ||
202 | |||
203 | /* Deem and Volume Control register */ | ||
204 | #define AK4620_DEEMVOL_REG 0x03 | ||
205 | #define AK4620_SMUTE (1<<7) | ||
206 | |||
207 | /* | ||
208 | * Conversion from int value to its binary form. Used for debugging. | ||
209 | * The output buffer must be allocated prior to calling the function. | ||
210 | */ | ||
211 | static char *get_binary(char *buffer, int value) | ||
212 | { | ||
213 | int i, j, pos; | ||
214 | pos = 0; | ||
215 | for (i = 0; i < 4; ++i) { | ||
216 | for (j = 0; j < 8; ++j) { | ||
217 | if (value & (1 << (31-(i*8 + j)))) | ||
218 | buffer[pos] = '1'; | ||
219 | else | ||
220 | buffer[pos] = '0'; | ||
221 | pos++; | ||
222 | } | ||
223 | if (i < 3) { | ||
224 | buffer[pos] = ' '; | ||
225 | pos++; | ||
226 | } | ||
227 | } | ||
228 | buffer[pos] = '\0'; | ||
229 | return buffer; | ||
230 | } | ||
231 | |||
232 | /* | ||
233 | * Initial setup of the conversion array GPIO <-> rate | ||
234 | */ | ||
235 | static unsigned int qtet_rates[] = { | ||
236 | 44100, 48000, 88200, | ||
237 | 96000, 176400, 192000, | ||
238 | }; | ||
239 | |||
240 | static unsigned int cks_vals[] = { | ||
241 | CPLD_CKS_44100HZ, CPLD_CKS_48000HZ, CPLD_CKS_88200HZ, | ||
242 | CPLD_CKS_96000HZ, CPLD_CKS_176400HZ, CPLD_CKS_192000HZ, | ||
243 | }; | ||
244 | |||
245 | static struct snd_pcm_hw_constraint_list qtet_rates_info = { | ||
246 | .count = ARRAY_SIZE(qtet_rates), | ||
247 | .list = qtet_rates, | ||
248 | .mask = 0, | ||
249 | }; | ||
250 | |||
251 | static void qtet_ak4113_write(void *private_data, unsigned char reg, | ||
252 | unsigned char val) | ||
253 | { | ||
254 | snd_vt1724_write_i2c((struct snd_ice1712 *)private_data, AK4113_ADDR, | ||
255 | reg, val); | ||
256 | } | ||
257 | |||
258 | static unsigned char qtet_ak4113_read(void *private_data, unsigned char reg) | ||
259 | { | ||
260 | return snd_vt1724_read_i2c((struct snd_ice1712 *)private_data, | ||
261 | AK4113_ADDR, reg); | ||
262 | } | ||
263 | |||
264 | |||
265 | /* | ||
266 | * AK4620 section | ||
267 | */ | ||
268 | |||
269 | /* | ||
270 | * Write data to addr register of ak4620 | ||
271 | */ | ||
272 | static void qtet_akm_write(struct snd_akm4xxx *ak, int chip, | ||
273 | unsigned char addr, unsigned char data) | ||
274 | { | ||
275 | unsigned int tmp, orig_dir; | ||
276 | int idx; | ||
277 | unsigned int addrdata; | ||
278 | struct snd_ice1712 *ice = ak->private_data[0]; | ||
279 | |||
280 | if (snd_BUG_ON(chip < 0 || chip >= 4)) | ||
281 | return; | ||
282 | /*printk(KERN_DEBUG "Writing to AK4620: chip=%d, addr=0x%x, | ||
283 | data=0x%x\n", chip, addr, data);*/ | ||
284 | orig_dir = ice->gpio.get_dir(ice); | ||
285 | ice->gpio.set_dir(ice, orig_dir | GPIO_SPI_ALL); | ||
286 | /* set mask - only SPI bits */ | ||
287 | ice->gpio.set_mask(ice, ~GPIO_SPI_ALL); | ||
288 | |||
289 | tmp = ice->gpio.get_data(ice); | ||
290 | /* high all */ | ||
291 | tmp |= GPIO_SPI_ALL; | ||
292 | ice->gpio.set_data(ice, tmp); | ||
293 | udelay(100); | ||
294 | /* drop chip select */ | ||
295 | if (chip) | ||
296 | /* CODEC 1 */ | ||
297 | tmp &= ~GPIO_SPI_CSN1; | ||
298 | else | ||
299 | tmp &= ~GPIO_SPI_CSN0; | ||
300 | ice->gpio.set_data(ice, tmp); | ||
301 | udelay(100); | ||
302 | |||
303 | /* build I2C address + data byte */ | ||
304 | addrdata = (AK4620_ADDR << 6) | 0x20 | (addr & 0x1f); | ||
305 | addrdata = (addrdata << 8) | data; | ||
306 | for (idx = 15; idx >= 0; idx--) { | ||
307 | /* drop clock */ | ||
308 | tmp &= ~GPIO_D5_SPI_CCLK; | ||
309 | ice->gpio.set_data(ice, tmp); | ||
310 | udelay(100); | ||
311 | /* set data */ | ||
312 | if (addrdata & (1 << idx)) | ||
313 | tmp |= GPIO_D4_SPI_CDTO; | ||
314 | else | ||
315 | tmp &= ~GPIO_D4_SPI_CDTO; | ||
316 | ice->gpio.set_data(ice, tmp); | ||
317 | udelay(100); | ||
318 | /* raise clock */ | ||
319 | tmp |= GPIO_D5_SPI_CCLK; | ||
320 | ice->gpio.set_data(ice, tmp); | ||
321 | udelay(100); | ||
322 | } | ||
323 | /* all back to 1 */ | ||
324 | tmp |= GPIO_SPI_ALL; | ||
325 | ice->gpio.set_data(ice, tmp); | ||
326 | udelay(100); | ||
327 | |||
328 | /* return all gpios to non-writable */ | ||
329 | ice->gpio.set_mask(ice, 0xffffff); | ||
330 | /* restore GPIOs direction */ | ||
331 | ice->gpio.set_dir(ice, orig_dir); | ||
332 | } | ||
333 | |||
334 | static void qtet_akm_set_regs(struct snd_akm4xxx *ak, unsigned char addr, | ||
335 | unsigned char mask, unsigned char value) | ||
336 | { | ||
337 | unsigned char tmp; | ||
338 | int chip; | ||
339 | for (chip = 0; chip < ak->num_chips; chip++) { | ||
340 | tmp = snd_akm4xxx_get(ak, chip, addr); | ||
341 | /* clear the bits */ | ||
342 | tmp &= ~mask; | ||
343 | /* set the new bits */ | ||
344 | tmp |= value; | ||
345 | snd_akm4xxx_write(ak, chip, addr, tmp); | ||
346 | } | ||
347 | } | ||
348 | |||
349 | /* | ||
350 | * change the rate of AK4620 | ||
351 | */ | ||
352 | static void qtet_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) | ||
353 | { | ||
354 | unsigned char ak4620_dfs; | ||
355 | |||
356 | if (rate == 0) /* no hint - S/PDIF input is master or the new spdif | ||
357 | input rate undetected, simply return */ | ||
358 | return; | ||
359 | |||
360 | /* adjust DFS on codecs - see datasheet */ | ||
361 | if (rate > 108000) | ||
362 | ak4620_dfs = AK4620_DFS1 | AK4620_CKS1; | ||
363 | else if (rate > 54000) | ||
364 | ak4620_dfs = AK4620_DFS0 | AK4620_CKS0; | ||
365 | else | ||
366 | ak4620_dfs = 0; | ||
367 | |||
368 | /* set new value */ | ||
369 | qtet_akm_set_regs(ak, AK4620_DFS_REG, AK4620_DFS0 | AK4620_DFS1 | | ||
370 | AK4620_CKS0 | AK4620_CKS1, ak4620_dfs); | ||
371 | } | ||
372 | |||
373 | #define AK_CONTROL(xname, xch) { .name = xname, .num_channels = xch } | ||
374 | |||
375 | #define PCM_12_PLAYBACK_VOLUME "PCM 1/2 Playback Volume" | ||
376 | #define PCM_34_PLAYBACK_VOLUME "PCM 3/4 Playback Volume" | ||
377 | #define PCM_12_CAPTURE_VOLUME "PCM 1/2 Capture Volume" | ||
378 | #define PCM_34_CAPTURE_VOLUME "PCM 3/4 Capture Volume" | ||
379 | |||
380 | static const struct snd_akm4xxx_dac_channel qtet_dac[] = { | ||
381 | AK_CONTROL(PCM_12_PLAYBACK_VOLUME, 2), | ||
382 | AK_CONTROL(PCM_34_PLAYBACK_VOLUME, 2), | ||
383 | }; | ||
384 | |||
385 | static const struct snd_akm4xxx_adc_channel qtet_adc[] = { | ||
386 | AK_CONTROL(PCM_12_CAPTURE_VOLUME, 2), | ||
387 | AK_CONTROL(PCM_34_CAPTURE_VOLUME, 2), | ||
388 | }; | ||
389 | |||
390 | static struct snd_akm4xxx akm_qtet_dac __devinitdata = { | ||
391 | .type = SND_AK4620, | ||
392 | .num_dacs = 4, /* DAC1 - Output 12 | ||
393 | */ | ||
394 | .num_adcs = 4, /* ADC1 - Input 12 | ||
395 | */ | ||
396 | .ops = { | ||
397 | .write = qtet_akm_write, | ||
398 | .set_rate_val = qtet_akm_set_rate_val, | ||
399 | }, | ||
400 | .dac_info = qtet_dac, | ||
401 | .adc_info = qtet_adc, | ||
402 | }; | ||
403 | |||
404 | /* Communication routines with the CPLD */ | ||
405 | |||
406 | |||
407 | /* Writes data to external register reg, both reg and data are | ||
408 | * GPIO representations */ | ||
409 | static void reg_write(struct snd_ice1712 *ice, unsigned int reg, | ||
410 | unsigned int data) | ||
411 | { | ||
412 | unsigned int tmp; | ||
413 | |||
414 | mutex_lock(&ice->gpio_mutex); | ||
415 | /* set direction of used GPIOs*/ | ||
416 | /* all outputs */ | ||
417 | tmp = 0x00ffff; | ||
418 | ice->gpio.set_dir(ice, tmp); | ||
419 | /* mask - writable bits */ | ||
420 | ice->gpio.set_mask(ice, ~(tmp)); | ||
421 | /* write the data */ | ||
422 | tmp = ice->gpio.get_data(ice); | ||
423 | tmp &= ~GPIO_DATA_MASK; | ||
424 | tmp |= data; | ||
425 | ice->gpio.set_data(ice, tmp); | ||
426 | udelay(100); | ||
427 | /* drop output enable */ | ||
428 | tmp &= ~GPIO_EX_GPIOE; | ||
429 | ice->gpio.set_data(ice, tmp); | ||
430 | udelay(100); | ||
431 | /* drop the register gpio */ | ||
432 | tmp &= ~reg; | ||
433 | ice->gpio.set_data(ice, tmp); | ||
434 | udelay(100); | ||
435 | /* raise the register GPIO */ | ||
436 | tmp |= reg; | ||
437 | ice->gpio.set_data(ice, tmp); | ||
438 | udelay(100); | ||
439 | |||
440 | /* raise all data gpios */ | ||
441 | tmp |= GPIO_DATA_MASK; | ||
442 | ice->gpio.set_data(ice, tmp); | ||
443 | /* mask - immutable bits */ | ||
444 | ice->gpio.set_mask(ice, 0xffffff); | ||
445 | /* outputs only 8-15 */ | ||
446 | ice->gpio.set_dir(ice, 0x00ff00); | ||
447 | mutex_unlock(&ice->gpio_mutex); | ||
448 | } | ||
449 | |||
450 | static unsigned int get_scr(struct snd_ice1712 *ice) | ||
451 | { | ||
452 | struct qtet_spec *spec = ice->spec; | ||
453 | return spec->scr; | ||
454 | } | ||
455 | |||
456 | static unsigned int get_mcr(struct snd_ice1712 *ice) | ||
457 | { | ||
458 | struct qtet_spec *spec = ice->spec; | ||
459 | return spec->mcr; | ||
460 | } | ||
461 | |||
462 | static unsigned int get_cpld(struct snd_ice1712 *ice) | ||
463 | { | ||
464 | struct qtet_spec *spec = ice->spec; | ||
465 | return spec->cpld; | ||
466 | } | ||
467 | |||
468 | static void set_scr(struct snd_ice1712 *ice, unsigned int val) | ||
469 | { | ||
470 | struct qtet_spec *spec = ice->spec; | ||
471 | reg_write(ice, GPIO_SCR, val); | ||
472 | spec->scr = val; | ||
473 | } | ||
474 | |||
475 | static void set_mcr(struct snd_ice1712 *ice, unsigned int val) | ||
476 | { | ||
477 | struct qtet_spec *spec = ice->spec; | ||
478 | reg_write(ice, GPIO_MCR, val); | ||
479 | spec->mcr = val; | ||
480 | } | ||
481 | |||
482 | static void set_cpld(struct snd_ice1712 *ice, unsigned int val) | ||
483 | { | ||
484 | struct qtet_spec *spec = ice->spec; | ||
485 | reg_write(ice, GPIO_CPLD_CSN, val); | ||
486 | spec->cpld = val; | ||
487 | } | ||
488 | #ifdef CONFIG_PROC_FS | ||
489 | static void proc_regs_read(struct snd_info_entry *entry, | ||
490 | struct snd_info_buffer *buffer) | ||
491 | { | ||
492 | struct snd_ice1712 *ice = entry->private_data; | ||
493 | char bin_buffer[36]; | ||
494 | |||
495 | snd_iprintf(buffer, "SCR: %s\n", get_binary(bin_buffer, | ||
496 | get_scr(ice))); | ||
497 | snd_iprintf(buffer, "MCR: %s\n", get_binary(bin_buffer, | ||
498 | get_mcr(ice))); | ||
499 | snd_iprintf(buffer, "CPLD: %s\n", get_binary(bin_buffer, | ||
500 | get_cpld(ice))); | ||
501 | } | ||
502 | |||
503 | static void proc_init(struct snd_ice1712 *ice) | ||
504 | { | ||
505 | struct snd_info_entry *entry; | ||
506 | if (!snd_card_proc_new(ice->card, "quartet", &entry)) | ||
507 | snd_info_set_text_ops(entry, ice, proc_regs_read); | ||
508 | } | ||
509 | #else /* !CONFIG_PROC_FS */ | ||
510 | static void proc_init(struct snd_ice1712 *ice) {} | ||
511 | #endif | ||
512 | |||
513 | static int qtet_mute_get(struct snd_kcontrol *kcontrol, | ||
514 | struct snd_ctl_elem_value *ucontrol) | ||
515 | { | ||
516 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
517 | unsigned int val; | ||
518 | val = get_scr(ice) & SCR_MUTE; | ||
519 | ucontrol->value.integer.value[0] = (val) ? 0 : 1; | ||
520 | return 0; | ||
521 | } | ||
522 | |||
523 | static int qtet_mute_put(struct snd_kcontrol *kcontrol, | ||
524 | struct snd_ctl_elem_value *ucontrol) | ||
525 | { | ||
526 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
527 | unsigned int old, new, smute; | ||
528 | old = get_scr(ice) & SCR_MUTE; | ||
529 | if (ucontrol->value.integer.value[0]) { | ||
530 | /* unmute */ | ||
531 | new = 0; | ||
532 | /* un-smuting DAC */ | ||
533 | smute = 0; | ||
534 | } else { | ||
535 | /* mute */ | ||
536 | new = SCR_MUTE; | ||
537 | /* smuting DAC */ | ||
538 | smute = AK4620_SMUTE; | ||
539 | } | ||
540 | if (old != new) { | ||
541 | struct snd_akm4xxx *ak = ice->akm; | ||
542 | set_scr(ice, (get_scr(ice) & ~SCR_MUTE) | new); | ||
543 | /* set smute */ | ||
544 | qtet_akm_set_regs(ak, AK4620_DEEMVOL_REG, AK4620_SMUTE, smute); | ||
545 | return 1; | ||
546 | } | ||
547 | /* no change */ | ||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | static int qtet_ain12_enum_info(struct snd_kcontrol *kcontrol, | ||
552 | struct snd_ctl_elem_info *uinfo) | ||
553 | { | ||
554 | static char *texts[3] = {"Line In 1/2", "Mic", "Mic + Low-cut"}; | ||
555 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
556 | uinfo->count = 1; | ||
557 | uinfo->value.enumerated.items = ARRAY_SIZE(texts); | ||
558 | |||
559 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
560 | uinfo->value.enumerated.item = | ||
561 | uinfo->value.enumerated.items - 1; | ||
562 | strcpy(uinfo->value.enumerated.name, | ||
563 | texts[uinfo->value.enumerated.item]); | ||
564 | |||
565 | return 0; | ||
566 | } | ||
567 | |||
568 | static int qtet_ain12_sw_get(struct snd_kcontrol *kcontrol, | ||
569 | struct snd_ctl_elem_value *ucontrol) | ||
570 | { | ||
571 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
572 | unsigned int val, result; | ||
573 | val = get_scr(ice) & (SCR_AIN12_SEL1 | SCR_AIN12_SEL0); | ||
574 | switch (val) { | ||
575 | case SCR_AIN12_LINE: | ||
576 | result = 0; | ||
577 | break; | ||
578 | case SCR_AIN12_MIC: | ||
579 | result = 1; | ||
580 | break; | ||
581 | case SCR_AIN12_LOWCUT: | ||
582 | result = 2; | ||
583 | break; | ||
584 | default: | ||
585 | /* BUG - no other combinations allowed */ | ||
586 | snd_BUG(); | ||
587 | result = 0; | ||
588 | } | ||
589 | ucontrol->value.integer.value[0] = result; | ||
590 | return 0; | ||
591 | } | ||
592 | |||
593 | static int qtet_ain12_sw_put(struct snd_kcontrol *kcontrol, | ||
594 | struct snd_ctl_elem_value *ucontrol) | ||
595 | { | ||
596 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
597 | unsigned int old, new, tmp, masked_old; | ||
598 | old = new = get_scr(ice); | ||
599 | masked_old = old & (SCR_AIN12_SEL1 | SCR_AIN12_SEL0); | ||
600 | tmp = ucontrol->value.integer.value[0]; | ||
601 | if (tmp == 2) | ||
602 | tmp = 3; /* binary 10 is not supported */ | ||
603 | tmp <<= 4; /* shifting to SCR_AIN12_SEL0 */ | ||
604 | if (tmp != masked_old) { | ||
605 | /* change requested */ | ||
606 | switch (tmp) { | ||
607 | case SCR_AIN12_LINE: | ||
608 | new = old & ~(SCR_AIN12_SEL1 | SCR_AIN12_SEL0); | ||
609 | set_scr(ice, new); | ||
610 | /* turn off relay */ | ||
611 | new &= ~SCR_RELAY; | ||
612 | set_scr(ice, new); | ||
613 | break; | ||
614 | case SCR_AIN12_MIC: | ||
615 | /* turn on relay */ | ||
616 | new = old | SCR_RELAY; | ||
617 | set_scr(ice, new); | ||
618 | new = (new & ~SCR_AIN12_SEL1) | SCR_AIN12_SEL0; | ||
619 | set_scr(ice, new); | ||
620 | break; | ||
621 | case SCR_AIN12_LOWCUT: | ||
622 | /* turn on relay */ | ||
623 | new = old | SCR_RELAY; | ||
624 | set_scr(ice, new); | ||
625 | new |= SCR_AIN12_SEL1 | SCR_AIN12_SEL0; | ||
626 | set_scr(ice, new); | ||
627 | break; | ||
628 | default: | ||
629 | snd_BUG(); | ||
630 | } | ||
631 | return 1; | ||
632 | } | ||
633 | /* no change */ | ||
634 | return 0; | ||
635 | } | ||
636 | |||
637 | static int qtet_php_get(struct snd_kcontrol *kcontrol, | ||
638 | struct snd_ctl_elem_value *ucontrol) | ||
639 | { | ||
640 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
641 | unsigned int val; | ||
642 | /* if phantom voltage =48V, phantom on */ | ||
643 | val = get_scr(ice) & SCR_PHP_V; | ||
644 | ucontrol->value.integer.value[0] = val ? 1 : 0; | ||
645 | return 0; | ||
646 | } | ||
647 | |||
648 | static int qtet_php_put(struct snd_kcontrol *kcontrol, | ||
649 | struct snd_ctl_elem_value *ucontrol) | ||
650 | { | ||
651 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
652 | unsigned int old, new; | ||
653 | old = new = get_scr(ice); | ||
654 | if (ucontrol->value.integer.value[0] /* phantom on requested */ | ||
655 | && (~old & SCR_PHP_V)) /* 0 = voltage 5V */ { | ||
656 | /* is off, turn on */ | ||
657 | /* turn voltage on first, = 1 */ | ||
658 | new = old | SCR_PHP_V; | ||
659 | set_scr(ice, new); | ||
660 | /* turn phantom on, = 0 */ | ||
661 | new &= ~SCR_PHP; | ||
662 | set_scr(ice, new); | ||
663 | } else if (!ucontrol->value.integer.value[0] && (old & SCR_PHP_V)) { | ||
664 | /* phantom off requested and 1 = voltage 48V */ | ||
665 | /* is on, turn off */ | ||
666 | /* turn voltage off first, = 0 */ | ||
667 | new = old & ~SCR_PHP_V; | ||
668 | set_scr(ice, new); | ||
669 | /* turn phantom off, = 1 */ | ||
670 | new |= SCR_PHP; | ||
671 | set_scr(ice, new); | ||
672 | } | ||
673 | if (old != new) | ||
674 | return 1; | ||
675 | /* no change */ | ||
676 | return 0; | ||
677 | } | ||
678 | |||
679 | #define PRIV_SW(xid, xbit, xreg) [xid] = {.bit = xbit,\ | ||
680 | .set_register = set_##xreg,\ | ||
681 | .get_register = get_##xreg, } | ||
682 | |||
683 | |||
684 | #define PRIV_ENUM2(xid, xbit, xreg, xtext1, xtext2) [xid] = {.bit = xbit,\ | ||
685 | .set_register = set_##xreg,\ | ||
686 | .get_register = get_##xreg,\ | ||
687 | .texts = {xtext1, xtext2} } | ||
688 | |||
689 | static struct qtet_kcontrol_private qtet_privates[] = { | ||
690 | PRIV_ENUM2(IN12_SEL, CPLD_IN12_SEL, cpld, "An In 1/2", "An In 3/4"), | ||
691 | PRIV_ENUM2(IN34_SEL, CPLD_IN34_SEL, cpld, "An In 3/4", "IEC958 In"), | ||
692 | PRIV_ENUM2(AIN34_SEL, SCR_AIN34_SEL, scr, "Line In 3/4", "Hi-Z"), | ||
693 | PRIV_ENUM2(COAX_OUT, CPLD_COAX_OUT, cpld, "IEC958", "I2S"), | ||
694 | PRIV_SW(IN12_MON12, MCR_IN12_MON12, mcr), | ||
695 | PRIV_SW(IN12_MON34, MCR_IN12_MON34, mcr), | ||
696 | PRIV_SW(IN34_MON12, MCR_IN34_MON12, mcr), | ||
697 | PRIV_SW(IN34_MON34, MCR_IN34_MON34, mcr), | ||
698 | PRIV_SW(OUT12_MON34, MCR_OUT12_MON34, mcr), | ||
699 | PRIV_SW(OUT34_MON12, MCR_OUT34_MON12, mcr), | ||
700 | }; | ||
701 | |||
702 | static int qtet_enum_info(struct snd_kcontrol *kcontrol, | ||
703 | struct snd_ctl_elem_info *uinfo) | ||
704 | { | ||
705 | struct qtet_kcontrol_private private = | ||
706 | qtet_privates[kcontrol->private_value]; | ||
707 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
708 | uinfo->count = 1; | ||
709 | uinfo->value.enumerated.items = ARRAY_SIZE(private.texts); | ||
710 | |||
711 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
712 | uinfo->value.enumerated.item = | ||
713 | uinfo->value.enumerated.items - 1; | ||
714 | strcpy(uinfo->value.enumerated.name, | ||
715 | private.texts[uinfo->value.enumerated.item]); | ||
716 | |||
717 | return 0; | ||
718 | } | ||
719 | |||
720 | static int qtet_sw_get(struct snd_kcontrol *kcontrol, | ||
721 | struct snd_ctl_elem_value *ucontrol) | ||
722 | { | ||
723 | struct qtet_kcontrol_private private = | ||
724 | qtet_privates[kcontrol->private_value]; | ||
725 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
726 | ucontrol->value.integer.value[0] = | ||
727 | (private.get_register(ice) & private.bit) ? 1 : 0; | ||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | static int qtet_sw_put(struct snd_kcontrol *kcontrol, | ||
732 | struct snd_ctl_elem_value *ucontrol) | ||
733 | { | ||
734 | struct qtet_kcontrol_private private = | ||
735 | qtet_privates[kcontrol->private_value]; | ||
736 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | ||
737 | unsigned int old, new; | ||
738 | old = private.get_register(ice); | ||
739 | if (ucontrol->value.integer.value[0]) | ||
740 | new = old | private.bit; | ||
741 | else | ||
742 | new = old & ~private.bit; | ||
743 | if (old != new) { | ||
744 | private.set_register(ice, new); | ||
745 | return 1; | ||
746 | } | ||
747 | /* no change */ | ||
748 | return 0; | ||
749 | } | ||
750 | |||
751 | #define qtet_sw_info snd_ctl_boolean_mono_info | ||
752 | |||
753 | #define QTET_CONTROL(xname, xtype, xpriv) \ | ||
754 | {.iface = SNDRV_CTL_ELEM_IFACE_MIXER,\ | ||
755 | .name = xname,\ | ||
756 | .info = qtet_##xtype##_info,\ | ||
757 | .get = qtet_sw_get,\ | ||
758 | .put = qtet_sw_put,\ | ||
759 | .private_value = xpriv } | ||
760 | |||
761 | static struct snd_kcontrol_new qtet_controls[] __devinitdata = { | ||
762 | { | ||
763 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
764 | .name = "Master Playback Switch", | ||
765 | .info = qtet_sw_info, | ||
766 | .get = qtet_mute_get, | ||
767 | .put = qtet_mute_put, | ||
768 | .private_value = 0 | ||
769 | }, | ||
770 | { | ||
771 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
772 | .name = "Phantom Power", | ||
773 | .info = qtet_sw_info, | ||
774 | .get = qtet_php_get, | ||
775 | .put = qtet_php_put, | ||
776 | .private_value = 0 | ||
777 | }, | ||
778 | { | ||
779 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
780 | .name = "Analog In 1/2 Capture Switch", | ||
781 | .info = qtet_ain12_enum_info, | ||
782 | .get = qtet_ain12_sw_get, | ||
783 | .put = qtet_ain12_sw_put, | ||
784 | .private_value = 0 | ||
785 | }, | ||
786 | QTET_CONTROL("Analog In 3/4 Capture Switch", enum, AIN34_SEL), | ||
787 | QTET_CONTROL("PCM In 1/2 Capture Switch", enum, IN12_SEL), | ||
788 | QTET_CONTROL("PCM In 3/4 Capture Switch", enum, IN34_SEL), | ||
789 | QTET_CONTROL("Coax Output Source", enum, COAX_OUT), | ||
790 | QTET_CONTROL("Analog In 1/2 to Monitor 1/2", sw, IN12_MON12), | ||
791 | QTET_CONTROL("Analog In 1/2 to Monitor 3/4", sw, IN12_MON34), | ||
792 | QTET_CONTROL("Analog In 3/4 to Monitor 1/2", sw, IN34_MON12), | ||
793 | QTET_CONTROL("Analog In 3/4 to Monitor 3/4", sw, IN34_MON34), | ||
794 | QTET_CONTROL("Output 1/2 to Monitor 3/4", sw, OUT12_MON34), | ||
795 | QTET_CONTROL("Output 3/4 to Monitor 1/2", sw, OUT34_MON12), | ||
796 | }; | ||
797 | |||
798 | static char *slave_vols[] __devinitdata = { | ||
799 | PCM_12_PLAYBACK_VOLUME, | ||
800 | PCM_34_PLAYBACK_VOLUME, | ||
801 | NULL | ||
802 | }; | ||
803 | |||
804 | static __devinitdata | ||
805 | DECLARE_TLV_DB_SCALE(qtet_master_db_scale, -6350, 50, 1); | ||
806 | |||
807 | static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card, | ||
808 | const char *name) | ||
809 | { | ||
810 | struct snd_ctl_elem_id sid; | ||
811 | memset(&sid, 0, sizeof(sid)); | ||
812 | /* FIXME: strcpy is bad. */ | ||
813 | strcpy(sid.name, name); | ||
814 | sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
815 | return snd_ctl_find_id(card, &sid); | ||
816 | } | ||
817 | |||
818 | static void __devinit add_slaves(struct snd_card *card, | ||
819 | struct snd_kcontrol *master, char **list) | ||
820 | { | ||
821 | for (; *list; list++) { | ||
822 | struct snd_kcontrol *slave = ctl_find(card, *list); | ||
823 | if (slave) | ||
824 | snd_ctl_add_slave(master, slave); | ||
825 | } | ||
826 | } | ||
827 | |||
828 | static int __devinit qtet_add_controls(struct snd_ice1712 *ice) | ||
829 | { | ||
830 | struct qtet_spec *spec = ice->spec; | ||
831 | int err, i; | ||
832 | struct snd_kcontrol *vmaster; | ||
833 | err = snd_ice1712_akm4xxx_build_controls(ice); | ||
834 | if (err < 0) | ||
835 | return err; | ||
836 | for (i = 0; i < ARRAY_SIZE(qtet_controls); i++) { | ||
837 | err = snd_ctl_add(ice->card, | ||
838 | snd_ctl_new1(&qtet_controls[i], ice)); | ||
839 | if (err < 0) | ||
840 | return err; | ||
841 | } | ||
842 | |||
843 | /* Create virtual master control */ | ||
844 | vmaster = snd_ctl_make_virtual_master("Master Playback Volume", | ||
845 | qtet_master_db_scale); | ||
846 | if (!vmaster) | ||
847 | return -ENOMEM; | ||
848 | add_slaves(ice->card, vmaster, slave_vols); | ||
849 | err = snd_ctl_add(ice->card, vmaster); | ||
850 | if (err < 0) | ||
851 | return err; | ||
852 | /* only capture SPDIF over AK4113 */ | ||
853 | err = snd_ak4113_build(spec->ak4113, | ||
854 | ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); | ||
855 | if (err < 0) | ||
856 | return err; | ||
857 | return 0; | ||
858 | } | ||
859 | |||
860 | static inline int qtet_is_spdif_master(struct snd_ice1712 *ice) | ||
861 | { | ||
862 | /* CPLD_SYNC_SEL: 0 = internal, 1 = external (i.e. spdif master) */ | ||
863 | return (get_cpld(ice) & CPLD_SYNC_SEL) ? 1 : 0; | ||
864 | } | ||
865 | |||
866 | static unsigned int qtet_get_rate(struct snd_ice1712 *ice) | ||
867 | { | ||
868 | int i; | ||
869 | unsigned char result; | ||
870 | |||
871 | result = get_cpld(ice) & CPLD_CKS_MASK; | ||
872 | for (i = 0; i < ARRAY_SIZE(cks_vals); i++) | ||
873 | if (cks_vals[i] == result) | ||
874 | return qtet_rates[i]; | ||
875 | return 0; | ||
876 | } | ||
877 | |||
878 | static int get_cks_val(int rate) | ||
879 | { | ||
880 | int i; | ||
881 | for (i = 0; i < ARRAY_SIZE(qtet_rates); i++) | ||
882 | if (qtet_rates[i] == rate) | ||
883 | return cks_vals[i]; | ||
884 | return 0; | ||
885 | } | ||
886 | |||
887 | /* setting new rate */ | ||
888 | static void qtet_set_rate(struct snd_ice1712 *ice, unsigned int rate) | ||
889 | { | ||
890 | unsigned int new; | ||
891 | unsigned char val; | ||
892 | /* switching ice1724 to external clock - supplied by ext. circuits */ | ||
893 | val = inb(ICEMT1724(ice, RATE)); | ||
894 | outb(val | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); | ||
895 | |||
896 | new = (get_cpld(ice) & ~CPLD_CKS_MASK) | get_cks_val(rate); | ||
897 | /* switch to internal clock, drop CPLD_SYNC_SEL */ | ||
898 | new &= ~CPLD_SYNC_SEL; | ||
899 | /* printk(KERN_DEBUG "QT - set_rate: old %x, new %x\n", | ||
900 | get_cpld(ice), new); */ | ||
901 | set_cpld(ice, new); | ||
902 | } | ||
903 | |||
904 | static inline unsigned char qtet_set_mclk(struct snd_ice1712 *ice, | ||
905 | unsigned int rate) | ||
906 | { | ||
907 | /* no change in master clock */ | ||
908 | return 0; | ||
909 | } | ||
910 | |||
911 | /* setting clock to external - SPDIF */ | ||
912 | static int qtet_set_spdif_clock(struct snd_ice1712 *ice, int type) | ||
913 | { | ||
914 | unsigned int old, new; | ||
915 | |||
916 | old = new = get_cpld(ice); | ||
917 | new &= ~(CPLD_CKS_MASK | CPLD_WORD_SEL); | ||
918 | switch (type) { | ||
919 | case EXT_SPDIF_TYPE: | ||
920 | new |= CPLD_EXT_SPDIF; | ||
921 | break; | ||
922 | case EXT_WORDCLOCK_1FS_TYPE: | ||
923 | new |= CPLD_EXT_WORDCLOCK_1FS; | ||
924 | break; | ||
925 | case EXT_WORDCLOCK_256FS_TYPE: | ||
926 | new |= CPLD_EXT_WORDCLOCK_256FS; | ||
927 | break; | ||
928 | default: | ||
929 | snd_BUG(); | ||
930 | } | ||
931 | if (old != new) { | ||
932 | set_cpld(ice, new); | ||
933 | /* changed */ | ||
934 | return 1; | ||
935 | } | ||
936 | return 0; | ||
937 | } | ||
938 | |||
939 | static int qtet_get_spdif_master_type(struct snd_ice1712 *ice) | ||
940 | { | ||
941 | unsigned int val; | ||
942 | int result; | ||
943 | val = get_cpld(ice); | ||
944 | /* checking only rate/clock-related bits */ | ||
945 | val &= (CPLD_CKS_MASK | CPLD_WORD_SEL | CPLD_SYNC_SEL); | ||
946 | if (!(val & CPLD_SYNC_SEL)) { | ||
947 | /* switched to internal clock, is not any external type */ | ||
948 | result = -1; | ||
949 | } else { | ||
950 | switch (val) { | ||
951 | case (CPLD_EXT_SPDIF): | ||
952 | result = EXT_SPDIF_TYPE; | ||
953 | break; | ||
954 | case (CPLD_EXT_WORDCLOCK_1FS): | ||
955 | result = EXT_WORDCLOCK_1FS_TYPE; | ||
956 | break; | ||
957 | case (CPLD_EXT_WORDCLOCK_256FS): | ||
958 | result = EXT_WORDCLOCK_256FS_TYPE; | ||
959 | break; | ||
960 | default: | ||
961 | /* undefined combination of external clock setup */ | ||
962 | snd_BUG(); | ||
963 | result = 0; | ||
964 | } | ||
965 | } | ||
966 | return result; | ||
967 | } | ||
968 | |||
969 | /* Called when ak4113 detects change in the input SPDIF stream */ | ||
970 | static void qtet_ak4113_change(struct ak4113 *ak4113, unsigned char c0, | ||
971 | unsigned char c1) | ||
972 | { | ||
973 | struct snd_ice1712 *ice = ak4113->change_callback_private; | ||
974 | int rate; | ||
975 | if ((qtet_get_spdif_master_type(ice) == EXT_SPDIF_TYPE) && | ||
976 | c1) { | ||
977 | /* only for SPDIF master mode, rate was changed */ | ||
978 | rate = snd_ak4113_external_rate(ak4113); | ||
979 | /* printk(KERN_DEBUG "ak4113 - input rate changed to %d\n", | ||
980 | rate); */ | ||
981 | qtet_akm_set_rate_val(ice->akm, rate); | ||
982 | } | ||
983 | } | ||
984 | |||
985 | /* | ||
986 | * If clock slaved to SPDIF-IN, setting runtime rate | ||
987 | * to the detected external rate | ||
988 | */ | ||
989 | static void qtet_spdif_in_open(struct snd_ice1712 *ice, | ||
990 | struct snd_pcm_substream *substream) | ||
991 | { | ||
992 | struct qtet_spec *spec = ice->spec; | ||
993 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
994 | int rate; | ||
995 | |||
996 | if (qtet_get_spdif_master_type(ice) != EXT_SPDIF_TYPE) | ||
997 | /* not external SPDIF, no rate limitation */ | ||
998 | return; | ||
999 | /* only external SPDIF can detect incoming sample rate */ | ||
1000 | rate = snd_ak4113_external_rate(spec->ak4113); | ||
1001 | if (rate >= runtime->hw.rate_min && rate <= runtime->hw.rate_max) { | ||
1002 | runtime->hw.rate_min = rate; | ||
1003 | runtime->hw.rate_max = rate; | ||
1004 | } | ||
1005 | } | ||
1006 | |||
1007 | /* | ||
1008 | * initialize the chip | ||
1009 | */ | ||
1010 | static int __devinit qtet_init(struct snd_ice1712 *ice) | ||
1011 | { | ||
1012 | static const unsigned char ak4113_init_vals[] = { | ||
1013 | /* AK4113_REG_PWRDN */ AK4113_RST | AK4113_PWN | | ||
1014 | AK4113_OCKS0 | AK4113_OCKS1, | ||
1015 | /* AK4113_REQ_FORMAT */ AK4113_DIF_I24I2S | AK4113_VTX | | ||
1016 | AK4113_DEM_OFF | AK4113_DEAU, | ||
1017 | /* AK4113_REG_IO0 */ AK4113_OPS2 | AK4113_TXE | | ||
1018 | AK4113_XTL_24_576M, | ||
1019 | /* AK4113_REG_IO1 */ AK4113_EFH_1024LRCLK | AK4113_IPS(0), | ||
1020 | /* AK4113_REG_INT0_MASK */ 0, | ||
1021 | /* AK4113_REG_INT1_MASK */ 0, | ||
1022 | /* AK4113_REG_DATDTS */ 0, | ||
1023 | }; | ||
1024 | int err; | ||
1025 | struct qtet_spec *spec; | ||
1026 | struct snd_akm4xxx *ak; | ||
1027 | unsigned char val; | ||
1028 | |||
1029 | /* switching ice1724 to external clock - supplied by ext. circuits */ | ||
1030 | val = inb(ICEMT1724(ice, RATE)); | ||
1031 | outb(val | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); | ||
1032 | |||
1033 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
1034 | if (!spec) | ||
1035 | return -ENOMEM; | ||
1036 | /* qtet is clocked by Xilinx array */ | ||
1037 | ice->hw_rates = &qtet_rates_info; | ||
1038 | ice->is_spdif_master = qtet_is_spdif_master; | ||
1039 | ice->get_rate = qtet_get_rate; | ||
1040 | ice->set_rate = qtet_set_rate; | ||
1041 | ice->set_mclk = qtet_set_mclk; | ||
1042 | ice->set_spdif_clock = qtet_set_spdif_clock; | ||
1043 | ice->get_spdif_master_type = qtet_get_spdif_master_type; | ||
1044 | ice->ext_clock_names = ext_clock_names; | ||
1045 | ice->ext_clock_count = ARRAY_SIZE(ext_clock_names); | ||
1046 | /* since Qtet can detect correct SPDIF-in rate, all streams can be | ||
1047 | * limited to this specific rate */ | ||
1048 | ice->spdif.ops.open = ice->pro_open = qtet_spdif_in_open; | ||
1049 | ice->spec = spec; | ||
1050 | |||
1051 | /* Mute Off */ | ||
1052 | /* SCR Initialize*/ | ||
1053 | /* keep codec power down first */ | ||
1054 | set_scr(ice, SCR_PHP); | ||
1055 | udelay(1); | ||
1056 | /* codec power up */ | ||
1057 | set_scr(ice, SCR_PHP | SCR_CODEC_PDN); | ||
1058 | |||
1059 | /* MCR Initialize */ | ||
1060 | set_mcr(ice, 0); | ||
1061 | |||
1062 | /* CPLD Initialize */ | ||
1063 | set_cpld(ice, 0); | ||
1064 | |||
1065 | |||
1066 | ice->num_total_dacs = 2; | ||
1067 | ice->num_total_adcs = 2; | ||
1068 | |||
1069 | ice->akm = kcalloc(2, sizeof(struct snd_akm4xxx), GFP_KERNEL); | ||
1070 | ak = ice->akm; | ||
1071 | if (!ak) | ||
1072 | return -ENOMEM; | ||
1073 | /* only one codec with two chips */ | ||
1074 | ice->akm_codecs = 1; | ||
1075 | err = snd_ice1712_akm4xxx_init(ak, &akm_qtet_dac, NULL, ice); | ||
1076 | if (err < 0) | ||
1077 | return err; | ||
1078 | err = snd_ak4113_create(ice->card, | ||
1079 | qtet_ak4113_read, | ||
1080 | qtet_ak4113_write, | ||
1081 | ak4113_init_vals, | ||
1082 | ice, &spec->ak4113); | ||
1083 | if (err < 0) | ||
1084 | return err; | ||
1085 | /* callback for codecs rate setting */ | ||
1086 | spec->ak4113->change_callback = qtet_ak4113_change; | ||
1087 | spec->ak4113->change_callback_private = ice; | ||
1088 | /* AK41143 in Quartet can detect external rate correctly | ||
1089 | * (i.e. check_flags = 0) */ | ||
1090 | spec->ak4113->check_flags = 0; | ||
1091 | |||
1092 | proc_init(ice); | ||
1093 | |||
1094 | qtet_set_rate(ice, 44100); | ||
1095 | return 0; | ||
1096 | } | ||
1097 | |||
1098 | static unsigned char qtet_eeprom[] __devinitdata = { | ||
1099 | [ICE_EEP2_SYSCONF] = 0x28, /* clock 256(24MHz), mpu401, 1xADC, | ||
1100 | 1xDACs, SPDIF in */ | ||
1101 | [ICE_EEP2_ACLINK] = 0x80, /* I2S */ | ||
1102 | [ICE_EEP2_I2S] = 0x78, /* 96k, 24bit, 192k */ | ||
1103 | [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, in, out-ext */ | ||
1104 | [ICE_EEP2_GPIO_DIR] = 0x00, /* 0-7 inputs, switched to output | ||
1105 | only during output operations */ | ||
1106 | [ICE_EEP2_GPIO_DIR1] = 0xff, /* 8-15 outputs */ | ||
1107 | [ICE_EEP2_GPIO_DIR2] = 0x00, | ||
1108 | [ICE_EEP2_GPIO_MASK] = 0xff, /* changed only for OUT operations */ | ||
1109 | [ICE_EEP2_GPIO_MASK1] = 0x00, | ||
1110 | [ICE_EEP2_GPIO_MASK2] = 0xff, | ||
1111 | |||
1112 | [ICE_EEP2_GPIO_STATE] = 0x00, /* inputs */ | ||
1113 | [ICE_EEP2_GPIO_STATE1] = 0x7d, /* all 1, but GPIO_CPLD_RW | ||
1114 | and GPIO15 always zero */ | ||
1115 | [ICE_EEP2_GPIO_STATE2] = 0x00, /* inputs */ | ||
1116 | }; | ||
1117 | |||
1118 | /* entry point */ | ||
1119 | struct snd_ice1712_card_info snd_vt1724_qtet_cards[] __devinitdata = { | ||
1120 | { | ||
1121 | .subvendor = VT1724_SUBDEVICE_QTET, | ||
1122 | .name = "Infrasonic Quartet", | ||
1123 | .model = "quartet", | ||
1124 | .chip_init = qtet_init, | ||
1125 | .build_controls = qtet_add_controls, | ||
1126 | .eeprom_size = sizeof(qtet_eeprom), | ||
1127 | .eeprom_data = qtet_eeprom, | ||
1128 | }, | ||
1129 | { } /* terminator */ | ||
1130 | }; | ||
diff --git a/sound/pci/ice1712/quartet.h b/sound/pci/ice1712/quartet.h new file mode 100644 index 000000000000..80809b72439a --- /dev/null +++ b/sound/pci/ice1712/quartet.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __SOUND_QTET_H | ||
2 | #define __SOUND_QTET_H | ||
3 | |||
4 | #define QTET_DEVICE_DESC "{Infrasonic,Quartet}," | ||
5 | |||
6 | #define VT1724_SUBDEVICE_QTET 0x30305349 /* Infrasonic Quartet */ | ||
7 | |||
8 | extern struct snd_ice1712_card_info snd_vt1724_qtet_cards[]; | ||
9 | |||
10 | #endif /* __SOUND_QTET_H */ | ||
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 754867ed4785..b990143636f1 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -1950,6 +1950,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { | |||
1950 | }, | 1950 | }, |
1951 | { | 1951 | { |
1952 | .subvendor = 0x104d, | 1952 | .subvendor = 0x104d, |
1953 | .subdevice = 0x8144, | ||
1954 | .name = "Sony", | ||
1955 | .type = AC97_TUNE_INV_EAPD | ||
1956 | }, | ||
1957 | { | ||
1958 | .subvendor = 0x104d, | ||
1953 | .subdevice = 0x8197, | 1959 | .subdevice = 0x8197, |
1954 | .name = "Sony S1XP", | 1960 | .name = "Sony S1XP", |
1955 | .type = AC97_TUNE_INV_EAPD | 1961 | .type = AC97_TUNE_INV_EAPD |
@@ -2057,6 +2063,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { | |||
2057 | .type = AC97_TUNE_HP_ONLY | 2063 | .type = AC97_TUNE_HP_ONLY |
2058 | }, | 2064 | }, |
2059 | { | 2065 | { |
2066 | .subvendor = 0x161f, | ||
2067 | .subdevice = 0x203a, | ||
2068 | .name = "Gateway 4525GZ", /* AD1981B */ | ||
2069 | .type = AC97_TUNE_INV_EAPD | ||
2070 | }, | ||
2071 | { | ||
2060 | .subvendor = 0x1734, | 2072 | .subvendor = 0x1734, |
2061 | .subdevice = 0x0088, | 2073 | .subdevice = 0x0088, |
2062 | .name = "Fujitsu-Siemens D1522", /* AD1981 */ | 2074 | .name = "Fujitsu-Siemens D1522", /* AD1981 */ |
diff --git a/sound/pci/oxygen/Makefile b/sound/pci/oxygen/Makefile index 4ba07d42fd1d..389941cf6100 100644 --- a/sound/pci/oxygen/Makefile +++ b/sound/pci/oxygen/Makefile | |||
@@ -1,7 +1,8 @@ | |||
1 | snd-oxygen-lib-objs := oxygen_io.o oxygen_lib.o oxygen_mixer.o oxygen_pcm.o | 1 | snd-oxygen-lib-objs := oxygen_io.o oxygen_lib.o oxygen_mixer.o oxygen_pcm.o |
2 | snd-hifier-objs := hifier.o | 2 | snd-hifier-objs := hifier.o |
3 | snd-oxygen-objs := oxygen.o | 3 | snd-oxygen-objs := oxygen.o |
4 | snd-virtuoso-objs := virtuoso.o | 4 | snd-virtuoso-objs := virtuoso.o xonar_lib.o \ |
5 | xonar_pcm179x.o xonar_cs43xx.o xonar_hdmi.o | ||
5 | 6 | ||
6 | obj-$(CONFIG_SND_OXYGEN_LIB) += snd-oxygen-lib.o | 7 | obj-$(CONFIG_SND_OXYGEN_LIB) += snd-oxygen-lib.o |
7 | obj-$(CONFIG_SND_HIFIER) += snd-hifier.o | 8 | obj-$(CONFIG_SND_HIFIER) += snd-hifier.o |
diff --git a/sound/pci/oxygen/cs2000.h b/sound/pci/oxygen/cs2000.h new file mode 100644 index 000000000000..c3501bdb5edc --- /dev/null +++ b/sound/pci/oxygen/cs2000.h | |||
@@ -0,0 +1,83 @@ | |||
1 | #ifndef CS2000_H_INCLUDED | ||
2 | #define CS2000_H_INCLUDED | ||
3 | |||
4 | #define CS2000_DEV_ID 0x01 | ||
5 | #define CS2000_DEV_CTRL 0x02 | ||
6 | #define CS2000_DEV_CFG_1 0x03 | ||
7 | #define CS2000_DEV_CFG_2 0x04 | ||
8 | #define CS2000_GLOBAL_CFG 0x05 | ||
9 | #define CS2000_RATIO_0 0x06 /* 32 bits, big endian */ | ||
10 | #define CS2000_RATIO_1 0x0a | ||
11 | #define CS2000_RATIO_2 0x0e | ||
12 | #define CS2000_RATIO_3 0x12 | ||
13 | #define CS2000_FUN_CFG_1 0x16 | ||
14 | #define CS2000_FUN_CFG_2 0x17 | ||
15 | #define CS2000_FUN_CFG_3 0x1e | ||
16 | |||
17 | /* DEV_ID */ | ||
18 | #define CS2000_DEVICE_MASK 0xf8 | ||
19 | #define CS2000_REVISION_MASK 0x07 | ||
20 | |||
21 | /* DEV_CTRL */ | ||
22 | #define CS2000_UNLOCK 0x80 | ||
23 | #define CS2000_AUX_OUT_DIS 0x02 | ||
24 | #define CS2000_CLK_OUT_DIS 0x01 | ||
25 | |||
26 | /* DEV_CFG_1 */ | ||
27 | #define CS2000_R_MOD_SEL_MASK 0xe0 | ||
28 | #define CS2000_R_MOD_SEL_1 0x00 | ||
29 | #define CS2000_R_MOD_SEL_2 0x20 | ||
30 | #define CS2000_R_MOD_SEL_4 0x40 | ||
31 | #define CS2000_R_MOD_SEL_8 0x60 | ||
32 | #define CS2000_R_MOD_SEL_1_2 0x80 | ||
33 | #define CS2000_R_MOD_SEL_1_4 0xa0 | ||
34 | #define CS2000_R_MOD_SEL_1_8 0xc0 | ||
35 | #define CS2000_R_MOD_SEL_1_16 0xe0 | ||
36 | #define CS2000_R_SEL_MASK 0x18 | ||
37 | #define CS2000_R_SEL_SHIFT 3 | ||
38 | #define CS2000_AUX_OUT_SRC_MASK 0x06 | ||
39 | #define CS2000_AUX_OUT_SRC_REF_CLK 0x00 | ||
40 | #define CS2000_AUX_OUT_SRC_CLK_IN 0x02 | ||
41 | #define CS2000_AUX_OUT_SRC_CLK_OUT 0x04 | ||
42 | #define CS2000_AUX_OUT_SRC_PLL_LOCK 0x06 | ||
43 | #define CS2000_EN_DEV_CFG_1 0x01 | ||
44 | |||
45 | /* DEV_CFG_2 */ | ||
46 | #define CS2000_LOCK_CLK_MASK 0x06 | ||
47 | #define CS2000_LOCK_CLK_SHIFT 1 | ||
48 | #define CS2000_FRAC_N_SRC_MASK 0x01 | ||
49 | #define CS2000_FRAC_N_SRC_STATIC 0x00 | ||
50 | #define CS2000_FRAC_N_SRC_DYNAMIC 0x01 | ||
51 | |||
52 | /* GLOBAL_CFG */ | ||
53 | #define CS2000_FREEZE 0x08 | ||
54 | #define CS2000_EN_DEV_CFG_2 0x01 | ||
55 | |||
56 | /* FUN_CFG_1 */ | ||
57 | #define CS2000_CLK_SKIP_EN 0x80 | ||
58 | #define CS2000_AUX_LOCK_CFG_MASK 0x40 | ||
59 | #define CS2000_AUX_LOCK_CFG_PP_HIGH 0x00 | ||
60 | #define CS2000_AUX_LOCK_CFG_OD_LOW 0x40 | ||
61 | #define CS2000_REF_CLK_DIV_MASK 0x18 | ||
62 | #define CS2000_REF_CLK_DIV_4 0x00 | ||
63 | #define CS2000_REF_CLK_DIV_2 0x08 | ||
64 | #define CS2000_REF_CLK_DIV_1 0x10 | ||
65 | |||
66 | /* FUN_CFG_2 */ | ||
67 | #define CS2000_CLK_OUT_UNL 0x10 | ||
68 | #define CS2000_L_F_RATIO_CFG_MASK 0x08 | ||
69 | #define CS2000_L_F_RATIO_CFG_20_12 0x00 | ||
70 | #define CS2000_L_F_RATIO_CFG_12_20 0x08 | ||
71 | |||
72 | /* FUN_CFG_3 */ | ||
73 | #define CS2000_CLK_IN_BW_MASK 0x70 | ||
74 | #define CS2000_CLK_IN_BW_1 0x00 | ||
75 | #define CS2000_CLK_IN_BW_2 0x10 | ||
76 | #define CS2000_CLK_IN_BW_4 0x20 | ||
77 | #define CS2000_CLK_IN_BW_8 0x30 | ||
78 | #define CS2000_CLK_IN_BW_16 0x40 | ||
79 | #define CS2000_CLK_IN_BW_32 0x50 | ||
80 | #define CS2000_CLK_IN_BW_64 0x60 | ||
81 | #define CS2000_CLK_IN_BW_128 0x70 | ||
82 | |||
83 | #endif | ||
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c index 84ef13183419..e3c229b63311 100644 --- a/sound/pci/oxygen/hifier.c +++ b/sound/pci/oxygen/hifier.c | |||
@@ -17,6 +17,12 @@ | |||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* | ||
21 | * CMI8788: | ||
22 | * | ||
23 | * SPI 0 -> AK4396 | ||
24 | */ | ||
25 | |||
20 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
21 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
22 | #include <sound/control.h> | 28 | #include <sound/control.h> |
@@ -51,23 +57,28 @@ static struct pci_device_id hifier_ids[] __devinitdata = { | |||
51 | MODULE_DEVICE_TABLE(pci, hifier_ids); | 57 | MODULE_DEVICE_TABLE(pci, hifier_ids); |
52 | 58 | ||
53 | struct hifier_data { | 59 | struct hifier_data { |
54 | u8 ak4396_ctl2; | 60 | u8 ak4396_regs[5]; |
55 | }; | 61 | }; |
56 | 62 | ||
57 | static void ak4396_write(struct oxygen *chip, u8 reg, u8 value) | 63 | static void ak4396_write(struct oxygen *chip, u8 reg, u8 value) |
58 | { | 64 | { |
65 | struct hifier_data *data = chip->model_data; | ||
66 | |||
59 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | | 67 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
60 | OXYGEN_SPI_DATA_LENGTH_2 | | 68 | OXYGEN_SPI_DATA_LENGTH_2 | |
61 | OXYGEN_SPI_CLOCK_160 | | 69 | OXYGEN_SPI_CLOCK_160 | |
62 | (0 << OXYGEN_SPI_CODEC_SHIFT) | | 70 | (0 << OXYGEN_SPI_CODEC_SHIFT) | |
63 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, | 71 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, |
64 | AK4396_WRITE | (reg << 8) | value); | 72 | AK4396_WRITE | (reg << 8) | value); |
73 | data->ak4396_regs[reg] = value; | ||
65 | } | 74 | } |
66 | 75 | ||
67 | static void update_ak4396_volume(struct oxygen *chip) | 76 | static void ak4396_write_cached(struct oxygen *chip, u8 reg, u8 value) |
68 | { | 77 | { |
69 | ak4396_write(chip, AK4396_LCH_ATT, chip->dac_volume[0]); | 78 | struct hifier_data *data = chip->model_data; |
70 | ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]); | 79 | |
80 | if (value != data->ak4396_regs[reg]) | ||
81 | ak4396_write(chip, reg, value); | ||
71 | } | 82 | } |
72 | 83 | ||
73 | static void hifier_registers_init(struct oxygen *chip) | 84 | static void hifier_registers_init(struct oxygen *chip) |
@@ -75,16 +86,19 @@ static void hifier_registers_init(struct oxygen *chip) | |||
75 | struct hifier_data *data = chip->model_data; | 86 | struct hifier_data *data = chip->model_data; |
76 | 87 | ||
77 | ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); | 88 | ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
78 | ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2); | 89 | ak4396_write(chip, AK4396_CONTROL_2, |
90 | data->ak4396_regs[AK4396_CONTROL_2]); | ||
79 | ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM); | 91 | ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM); |
80 | update_ak4396_volume(chip); | 92 | ak4396_write(chip, AK4396_LCH_ATT, chip->dac_volume[0]); |
93 | ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]); | ||
81 | } | 94 | } |
82 | 95 | ||
83 | static void hifier_init(struct oxygen *chip) | 96 | static void hifier_init(struct oxygen *chip) |
84 | { | 97 | { |
85 | struct hifier_data *data = chip->model_data; | 98 | struct hifier_data *data = chip->model_data; |
86 | 99 | ||
87 | data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL; | 100 | data->ak4396_regs[AK4396_CONTROL_2] = |
101 | AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL; | ||
88 | hifier_registers_init(chip); | 102 | hifier_registers_init(chip); |
89 | 103 | ||
90 | snd_component_add(chip->card, "AK4396"); | 104 | snd_component_add(chip->card, "AK4396"); |
@@ -106,20 +120,29 @@ static void set_ak4396_params(struct oxygen *chip, | |||
106 | struct hifier_data *data = chip->model_data; | 120 | struct hifier_data *data = chip->model_data; |
107 | u8 value; | 121 | u8 value; |
108 | 122 | ||
109 | value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; | 123 | value = data->ak4396_regs[AK4396_CONTROL_2] & ~AK4396_DFS_MASK; |
110 | if (params_rate(params) <= 54000) | 124 | if (params_rate(params) <= 54000) |
111 | value |= AK4396_DFS_NORMAL; | 125 | value |= AK4396_DFS_NORMAL; |
112 | else if (params_rate(params) <= 108000) | 126 | else if (params_rate(params) <= 108000) |
113 | value |= AK4396_DFS_DOUBLE; | 127 | value |= AK4396_DFS_DOUBLE; |
114 | else | 128 | else |
115 | value |= AK4396_DFS_QUAD; | 129 | value |= AK4396_DFS_QUAD; |
116 | data->ak4396_ctl2 = value; | ||
117 | 130 | ||
118 | msleep(1); /* wait for the new MCLK to become stable */ | 131 | msleep(1); /* wait for the new MCLK to become stable */ |
119 | 132 | ||
120 | ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB); | 133 | if (value != data->ak4396_regs[AK4396_CONTROL_2]) { |
121 | ak4396_write(chip, AK4396_CONTROL_2, value); | 134 | ak4396_write(chip, AK4396_CONTROL_1, |
122 | ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); | 135 | AK4396_DIF_24_MSB); |
136 | ak4396_write(chip, AK4396_CONTROL_2, value); | ||
137 | ak4396_write(chip, AK4396_CONTROL_1, | ||
138 | AK4396_DIF_24_MSB | AK4396_RSTN); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | static void update_ak4396_volume(struct oxygen *chip) | ||
143 | { | ||
144 | ak4396_write_cached(chip, AK4396_LCH_ATT, chip->dac_volume[0]); | ||
145 | ak4396_write_cached(chip, AK4396_RCH_ATT, chip->dac_volume[1]); | ||
123 | } | 146 | } |
124 | 147 | ||
125 | static void update_ak4396_mute(struct oxygen *chip) | 148 | static void update_ak4396_mute(struct oxygen *chip) |
@@ -127,11 +150,10 @@ static void update_ak4396_mute(struct oxygen *chip) | |||
127 | struct hifier_data *data = chip->model_data; | 150 | struct hifier_data *data = chip->model_data; |
128 | u8 value; | 151 | u8 value; |
129 | 152 | ||
130 | value = data->ak4396_ctl2 & ~AK4396_SMUTE; | 153 | value = data->ak4396_regs[AK4396_CONTROL_2] & ~AK4396_SMUTE; |
131 | if (chip->dac_mute) | 154 | if (chip->dac_mute) |
132 | value |= AK4396_SMUTE; | 155 | value |= AK4396_SMUTE; |
133 | data->ak4396_ctl2 = value; | 156 | ak4396_write_cached(chip, AK4396_CONTROL_2, value); |
134 | ak4396_write(chip, AK4396_CONTROL_2, value); | ||
135 | } | 157 | } |
136 | 158 | ||
137 | static void set_cs5340_params(struct oxygen *chip, | 159 | static void set_cs5340_params(struct oxygen *chip, |
@@ -141,21 +163,14 @@ static void set_cs5340_params(struct oxygen *chip, | |||
141 | 163 | ||
142 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); | 164 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
143 | 165 | ||
144 | static int hifier_control_filter(struct snd_kcontrol_new *template) | ||
145 | { | ||
146 | if (!strcmp(template->name, "Stereo Upmixing")) | ||
147 | return 1; /* stereo only - we don't need upmixing */ | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static const struct oxygen_model model_hifier = { | 166 | static const struct oxygen_model model_hifier = { |
152 | .shortname = "C-Media CMI8787", | 167 | .shortname = "C-Media CMI8787", |
153 | .longname = "C-Media Oxygen HD Audio", | 168 | .longname = "C-Media Oxygen HD Audio", |
154 | .chip = "CMI8788", | 169 | .chip = "CMI8788", |
155 | .init = hifier_init, | 170 | .init = hifier_init, |
156 | .control_filter = hifier_control_filter, | ||
157 | .cleanup = hifier_cleanup, | 171 | .cleanup = hifier_cleanup, |
158 | .resume = hifier_resume, | 172 | .resume = hifier_resume, |
173 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
159 | .set_dac_params = set_ak4396_params, | 174 | .set_dac_params = set_ak4396_params, |
160 | .set_adc_params = set_cs5340_params, | 175 | .set_adc_params = set_cs5340_params, |
161 | .update_dac_volume = update_ak4396_volume, | 176 | .update_dac_volume = update_ak4396_volume, |
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index 72db4c39007f..acbedebcffd9 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -18,6 +18,8 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * CMI8788: | ||
22 | * | ||
21 | * SPI 0 -> 1st AK4396 (front) | 23 | * SPI 0 -> 1st AK4396 (front) |
22 | * SPI 1 -> 2nd AK4396 (surround) | 24 | * SPI 1 -> 2nd AK4396 (surround) |
23 | * SPI 2 -> 3rd AK4396 (center/LFE) | 25 | * SPI 2 -> 3rd AK4396 (center/LFE) |
@@ -27,6 +29,10 @@ | |||
27 | * GPIO 0 -> DFS0 of AK5385 | 29 | * GPIO 0 -> DFS0 of AK5385 |
28 | * GPIO 1 -> DFS1 of AK5385 | 30 | * GPIO 1 -> DFS1 of AK5385 |
29 | * GPIO 8 -> enable headphone amplifier on HT-Omega models | 31 | * GPIO 8 -> enable headphone amplifier on HT-Omega models |
32 | * | ||
33 | * CM9780: | ||
34 | * | ||
35 | * GPO 0 -> route line-in (0) or AC97 output (1) to ADC input | ||
30 | */ | 36 | */ |
31 | 37 | ||
32 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
@@ -91,8 +97,8 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids); | |||
91 | #define GPIO_CLARO_HP 0x0100 | 97 | #define GPIO_CLARO_HP 0x0100 |
92 | 98 | ||
93 | struct generic_data { | 99 | struct generic_data { |
94 | u8 ak4396_ctl2; | 100 | u8 ak4396_regs[4][5]; |
95 | u16 saved_wm8785_registers[2]; | 101 | u16 wm8785_regs[3]; |
96 | }; | 102 | }; |
97 | 103 | ||
98 | static void ak4396_write(struct oxygen *chip, unsigned int codec, | 104 | static void ak4396_write(struct oxygen *chip, unsigned int codec, |
@@ -102,12 +108,24 @@ static void ak4396_write(struct oxygen *chip, unsigned int codec, | |||
102 | static const u8 codec_spi_map[4] = { | 108 | static const u8 codec_spi_map[4] = { |
103 | 0, 1, 2, 4 | 109 | 0, 1, 2, 4 |
104 | }; | 110 | }; |
111 | struct generic_data *data = chip->model_data; | ||
112 | |||
105 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | | 113 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
106 | OXYGEN_SPI_DATA_LENGTH_2 | | 114 | OXYGEN_SPI_DATA_LENGTH_2 | |
107 | OXYGEN_SPI_CLOCK_160 | | 115 | OXYGEN_SPI_CLOCK_160 | |
108 | (codec_spi_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | | 116 | (codec_spi_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | |
109 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, | 117 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, |
110 | AK4396_WRITE | (reg << 8) | value); | 118 | AK4396_WRITE | (reg << 8) | value); |
119 | data->ak4396_regs[codec][reg] = value; | ||
120 | } | ||
121 | |||
122 | static void ak4396_write_cached(struct oxygen *chip, unsigned int codec, | ||
123 | u8 reg, u8 value) | ||
124 | { | ||
125 | struct generic_data *data = chip->model_data; | ||
126 | |||
127 | if (value != data->ak4396_regs[codec][reg]) | ||
128 | ak4396_write(chip, codec, reg, value); | ||
111 | } | 129 | } |
112 | 130 | ||
113 | static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) | 131 | static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) |
@@ -120,20 +138,8 @@ static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) | |||
120 | (3 << OXYGEN_SPI_CODEC_SHIFT) | | 138 | (3 << OXYGEN_SPI_CODEC_SHIFT) | |
121 | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, | 139 | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, |
122 | (reg << 9) | value); | 140 | (reg << 9) | value); |
123 | if (reg < ARRAY_SIZE(data->saved_wm8785_registers)) | 141 | if (reg < ARRAY_SIZE(data->wm8785_regs)) |
124 | data->saved_wm8785_registers[reg] = value; | 142 | data->wm8785_regs[reg] = value; |
125 | } | ||
126 | |||
127 | static void update_ak4396_volume(struct oxygen *chip) | ||
128 | { | ||
129 | unsigned int i; | ||
130 | |||
131 | for (i = 0; i < 4; ++i) { | ||
132 | ak4396_write(chip, i, | ||
133 | AK4396_LCH_ATT, chip->dac_volume[i * 2]); | ||
134 | ak4396_write(chip, i, | ||
135 | AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]); | ||
136 | } | ||
137 | } | 143 | } |
138 | 144 | ||
139 | static void ak4396_registers_init(struct oxygen *chip) | 145 | static void ak4396_registers_init(struct oxygen *chip) |
@@ -142,21 +148,25 @@ static void ak4396_registers_init(struct oxygen *chip) | |||
142 | unsigned int i; | 148 | unsigned int i; |
143 | 149 | ||
144 | for (i = 0; i < 4; ++i) { | 150 | for (i = 0; i < 4; ++i) { |
145 | ak4396_write(chip, i, | 151 | ak4396_write(chip, i, AK4396_CONTROL_1, |
146 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); | 152 | AK4396_DIF_24_MSB | AK4396_RSTN); |
147 | ak4396_write(chip, i, | 153 | ak4396_write(chip, i, AK4396_CONTROL_2, |
148 | AK4396_CONTROL_2, data->ak4396_ctl2); | 154 | data->ak4396_regs[0][AK4396_CONTROL_2]); |
149 | ak4396_write(chip, i, | 155 | ak4396_write(chip, i, AK4396_CONTROL_3, |
150 | AK4396_CONTROL_3, AK4396_PCM); | 156 | AK4396_PCM); |
157 | ak4396_write(chip, i, AK4396_LCH_ATT, | ||
158 | chip->dac_volume[i * 2]); | ||
159 | ak4396_write(chip, i, AK4396_RCH_ATT, | ||
160 | chip->dac_volume[i * 2 + 1]); | ||
151 | } | 161 | } |
152 | update_ak4396_volume(chip); | ||
153 | } | 162 | } |
154 | 163 | ||
155 | static void ak4396_init(struct oxygen *chip) | 164 | static void ak4396_init(struct oxygen *chip) |
156 | { | 165 | { |
157 | struct generic_data *data = chip->model_data; | 166 | struct generic_data *data = chip->model_data; |
158 | 167 | ||
159 | data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL; | 168 | data->ak4396_regs[0][AK4396_CONTROL_2] = |
169 | AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL; | ||
160 | ak4396_registers_init(chip); | 170 | ak4396_registers_init(chip); |
161 | snd_component_add(chip->card, "AK4396"); | 171 | snd_component_add(chip->card, "AK4396"); |
162 | } | 172 | } |
@@ -173,17 +183,17 @@ static void wm8785_registers_init(struct oxygen *chip) | |||
173 | struct generic_data *data = chip->model_data; | 183 | struct generic_data *data = chip->model_data; |
174 | 184 | ||
175 | wm8785_write(chip, WM8785_R7, 0); | 185 | wm8785_write(chip, WM8785_R7, 0); |
176 | wm8785_write(chip, WM8785_R0, data->saved_wm8785_registers[0]); | 186 | wm8785_write(chip, WM8785_R0, data->wm8785_regs[0]); |
177 | wm8785_write(chip, WM8785_R1, data->saved_wm8785_registers[1]); | 187 | wm8785_write(chip, WM8785_R2, data->wm8785_regs[2]); |
178 | } | 188 | } |
179 | 189 | ||
180 | static void wm8785_init(struct oxygen *chip) | 190 | static void wm8785_init(struct oxygen *chip) |
181 | { | 191 | { |
182 | struct generic_data *data = chip->model_data; | 192 | struct generic_data *data = chip->model_data; |
183 | 193 | ||
184 | data->saved_wm8785_registers[0] = WM8785_MCR_SLAVE | | 194 | data->wm8785_regs[0] = |
185 | WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST; | 195 | WM8785_MCR_SLAVE | WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST; |
186 | data->saved_wm8785_registers[1] = WM8785_WL_24; | 196 | data->wm8785_regs[2] = WM8785_HPFR | WM8785_HPFL; |
187 | wm8785_registers_init(chip); | 197 | wm8785_registers_init(chip); |
188 | snd_component_add(chip->card, "WM8785"); | 198 | snd_component_add(chip->card, "WM8785"); |
189 | } | 199 | } |
@@ -264,24 +274,36 @@ static void set_ak4396_params(struct oxygen *chip, | |||
264 | unsigned int i; | 274 | unsigned int i; |
265 | u8 value; | 275 | u8 value; |
266 | 276 | ||
267 | value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; | 277 | value = data->ak4396_regs[0][AK4396_CONTROL_2] & ~AK4396_DFS_MASK; |
268 | if (params_rate(params) <= 54000) | 278 | if (params_rate(params) <= 54000) |
269 | value |= AK4396_DFS_NORMAL; | 279 | value |= AK4396_DFS_NORMAL; |
270 | else if (params_rate(params) <= 108000) | 280 | else if (params_rate(params) <= 108000) |
271 | value |= AK4396_DFS_DOUBLE; | 281 | value |= AK4396_DFS_DOUBLE; |
272 | else | 282 | else |
273 | value |= AK4396_DFS_QUAD; | 283 | value |= AK4396_DFS_QUAD; |
274 | data->ak4396_ctl2 = value; | ||
275 | 284 | ||
276 | msleep(1); /* wait for the new MCLK to become stable */ | 285 | msleep(1); /* wait for the new MCLK to become stable */ |
277 | 286 | ||
287 | if (value != data->ak4396_regs[0][AK4396_CONTROL_2]) { | ||
288 | for (i = 0; i < 4; ++i) { | ||
289 | ak4396_write(chip, i, AK4396_CONTROL_1, | ||
290 | AK4396_DIF_24_MSB); | ||
291 | ak4396_write(chip, i, AK4396_CONTROL_2, value); | ||
292 | ak4396_write(chip, i, AK4396_CONTROL_1, | ||
293 | AK4396_DIF_24_MSB | AK4396_RSTN); | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | |||
298 | static void update_ak4396_volume(struct oxygen *chip) | ||
299 | { | ||
300 | unsigned int i; | ||
301 | |||
278 | for (i = 0; i < 4; ++i) { | 302 | for (i = 0; i < 4; ++i) { |
279 | ak4396_write(chip, i, | 303 | ak4396_write_cached(chip, i, AK4396_LCH_ATT, |
280 | AK4396_CONTROL_1, AK4396_DIF_24_MSB); | 304 | chip->dac_volume[i * 2]); |
281 | ak4396_write(chip, i, | 305 | ak4396_write_cached(chip, i, AK4396_RCH_ATT, |
282 | AK4396_CONTROL_2, value); | 306 | chip->dac_volume[i * 2 + 1]); |
283 | ak4396_write(chip, i, | ||
284 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); | ||
285 | } | 307 | } |
286 | } | 308 | } |
287 | 309 | ||
@@ -291,21 +313,19 @@ static void update_ak4396_mute(struct oxygen *chip) | |||
291 | unsigned int i; | 313 | unsigned int i; |
292 | u8 value; | 314 | u8 value; |
293 | 315 | ||
294 | value = data->ak4396_ctl2 & ~AK4396_SMUTE; | 316 | value = data->ak4396_regs[0][AK4396_CONTROL_2] & ~AK4396_SMUTE; |
295 | if (chip->dac_mute) | 317 | if (chip->dac_mute) |
296 | value |= AK4396_SMUTE; | 318 | value |= AK4396_SMUTE; |
297 | data->ak4396_ctl2 = value; | ||
298 | for (i = 0; i < 4; ++i) | 319 | for (i = 0; i < 4; ++i) |
299 | ak4396_write(chip, i, AK4396_CONTROL_2, value); | 320 | ak4396_write_cached(chip, i, AK4396_CONTROL_2, value); |
300 | } | 321 | } |
301 | 322 | ||
302 | static void set_wm8785_params(struct oxygen *chip, | 323 | static void set_wm8785_params(struct oxygen *chip, |
303 | struct snd_pcm_hw_params *params) | 324 | struct snd_pcm_hw_params *params) |
304 | { | 325 | { |
326 | struct generic_data *data = chip->model_data; | ||
305 | unsigned int value; | 327 | unsigned int value; |
306 | 328 | ||
307 | wm8785_write(chip, WM8785_R7, 0); | ||
308 | |||
309 | value = WM8785_MCR_SLAVE | WM8785_FORMAT_LJUST; | 329 | value = WM8785_MCR_SLAVE | WM8785_FORMAT_LJUST; |
310 | if (params_rate(params) <= 48000) | 330 | if (params_rate(params) <= 48000) |
311 | value |= WM8785_OSR_SINGLE; | 331 | value |= WM8785_OSR_SINGLE; |
@@ -313,13 +333,11 @@ static void set_wm8785_params(struct oxygen *chip, | |||
313 | value |= WM8785_OSR_DOUBLE; | 333 | value |= WM8785_OSR_DOUBLE; |
314 | else | 334 | else |
315 | value |= WM8785_OSR_QUAD; | 335 | value |= WM8785_OSR_QUAD; |
316 | wm8785_write(chip, WM8785_R0, value); | 336 | if (value != data->wm8785_regs[0]) { |
317 | 337 | wm8785_write(chip, WM8785_R7, 0); | |
318 | if (snd_pcm_format_width(params_format(params)) <= 16) | 338 | wm8785_write(chip, WM8785_R0, value); |
319 | value = WM8785_WL_16; | 339 | wm8785_write(chip, WM8785_R2, data->wm8785_regs[2]); |
320 | else | 340 | } |
321 | value = WM8785_WL_24; | ||
322 | wm8785_write(chip, WM8785_R1, value); | ||
323 | } | 341 | } |
324 | 342 | ||
325 | static void set_ak5385_params(struct oxygen *chip, | 343 | static void set_ak5385_params(struct oxygen *chip, |
@@ -337,6 +355,134 @@ static void set_ak5385_params(struct oxygen *chip, | |||
337 | value, GPIO_AK5385_DFS_MASK); | 355 | value, GPIO_AK5385_DFS_MASK); |
338 | } | 356 | } |
339 | 357 | ||
358 | static int rolloff_info(struct snd_kcontrol *ctl, | ||
359 | struct snd_ctl_elem_info *info) | ||
360 | { | ||
361 | static const char *const names[2] = { | ||
362 | "Sharp Roll-off", "Slow Roll-off" | ||
363 | }; | ||
364 | |||
365 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
366 | info->count = 1; | ||
367 | info->value.enumerated.items = 2; | ||
368 | if (info->value.enumerated.item >= 2) | ||
369 | info->value.enumerated.item = 1; | ||
370 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | static int rolloff_get(struct snd_kcontrol *ctl, | ||
375 | struct snd_ctl_elem_value *value) | ||
376 | { | ||
377 | struct oxygen *chip = ctl->private_data; | ||
378 | struct generic_data *data = chip->model_data; | ||
379 | |||
380 | value->value.enumerated.item[0] = | ||
381 | (data->ak4396_regs[0][AK4396_CONTROL_2] & AK4396_SLOW) != 0; | ||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | static int rolloff_put(struct snd_kcontrol *ctl, | ||
386 | struct snd_ctl_elem_value *value) | ||
387 | { | ||
388 | struct oxygen *chip = ctl->private_data; | ||
389 | struct generic_data *data = chip->model_data; | ||
390 | unsigned int i; | ||
391 | int changed; | ||
392 | u8 reg; | ||
393 | |||
394 | mutex_lock(&chip->mutex); | ||
395 | reg = data->ak4396_regs[0][AK4396_CONTROL_2]; | ||
396 | if (value->value.enumerated.item[0]) | ||
397 | reg |= AK4396_SLOW; | ||
398 | else | ||
399 | reg &= ~AK4396_SLOW; | ||
400 | changed = reg != data->ak4396_regs[0][AK4396_CONTROL_2]; | ||
401 | if (changed) { | ||
402 | for (i = 0; i < 4; ++i) | ||
403 | ak4396_write(chip, i, AK4396_CONTROL_2, reg); | ||
404 | } | ||
405 | mutex_unlock(&chip->mutex); | ||
406 | return changed; | ||
407 | } | ||
408 | |||
409 | static const struct snd_kcontrol_new rolloff_control = { | ||
410 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
411 | .name = "DAC Filter Playback Enum", | ||
412 | .info = rolloff_info, | ||
413 | .get = rolloff_get, | ||
414 | .put = rolloff_put, | ||
415 | }; | ||
416 | |||
417 | static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | ||
418 | { | ||
419 | static const char *const names[2] = { | ||
420 | "None", "High-pass Filter" | ||
421 | }; | ||
422 | |||
423 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
424 | info->count = 1; | ||
425 | info->value.enumerated.items = 2; | ||
426 | if (info->value.enumerated.item >= 2) | ||
427 | info->value.enumerated.item = 1; | ||
428 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
429 | return 0; | ||
430 | } | ||
431 | |||
432 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | ||
433 | { | ||
434 | struct oxygen *chip = ctl->private_data; | ||
435 | struct generic_data *data = chip->model_data; | ||
436 | |||
437 | value->value.enumerated.item[0] = | ||
438 | (data->wm8785_regs[WM8785_R2] & WM8785_HPFR) != 0; | ||
439 | return 0; | ||
440 | } | ||
441 | |||
442 | static int hpf_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | ||
443 | { | ||
444 | struct oxygen *chip = ctl->private_data; | ||
445 | struct generic_data *data = chip->model_data; | ||
446 | unsigned int reg; | ||
447 | int changed; | ||
448 | |||
449 | mutex_lock(&chip->mutex); | ||
450 | reg = data->wm8785_regs[WM8785_R2] & ~(WM8785_HPFR | WM8785_HPFL); | ||
451 | if (value->value.enumerated.item[0]) | ||
452 | reg |= WM8785_HPFR | WM8785_HPFL; | ||
453 | changed = reg != data->wm8785_regs[WM8785_R2]; | ||
454 | if (changed) | ||
455 | wm8785_write(chip, WM8785_R2, reg); | ||
456 | mutex_unlock(&chip->mutex); | ||
457 | return changed; | ||
458 | } | ||
459 | |||
460 | static const struct snd_kcontrol_new hpf_control = { | ||
461 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
462 | .name = "ADC Filter Capture Enum", | ||
463 | .info = hpf_info, | ||
464 | .get = hpf_get, | ||
465 | .put = hpf_put, | ||
466 | }; | ||
467 | |||
468 | static int generic_mixer_init(struct oxygen *chip) | ||
469 | { | ||
470 | return snd_ctl_add(chip->card, snd_ctl_new1(&rolloff_control, chip)); | ||
471 | } | ||
472 | |||
473 | static int generic_wm8785_mixer_init(struct oxygen *chip) | ||
474 | { | ||
475 | int err; | ||
476 | |||
477 | err = generic_mixer_init(chip); | ||
478 | if (err < 0) | ||
479 | return err; | ||
480 | err = snd_ctl_add(chip->card, snd_ctl_new1(&hpf_control, chip)); | ||
481 | if (err < 0) | ||
482 | return err; | ||
483 | return 0; | ||
484 | } | ||
485 | |||
340 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); | 486 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
341 | 487 | ||
342 | static const struct oxygen_model model_generic = { | 488 | static const struct oxygen_model model_generic = { |
@@ -344,8 +490,10 @@ static const struct oxygen_model model_generic = { | |||
344 | .longname = "C-Media Oxygen HD Audio", | 490 | .longname = "C-Media Oxygen HD Audio", |
345 | .chip = "CMI8788", | 491 | .chip = "CMI8788", |
346 | .init = generic_init, | 492 | .init = generic_init, |
493 | .mixer_init = generic_wm8785_mixer_init, | ||
347 | .cleanup = generic_cleanup, | 494 | .cleanup = generic_cleanup, |
348 | .resume = generic_resume, | 495 | .resume = generic_resume, |
496 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
349 | .set_dac_params = set_ak4396_params, | 497 | .set_dac_params = set_ak4396_params, |
350 | .set_adc_params = set_wm8785_params, | 498 | .set_adc_params = set_wm8785_params, |
351 | .update_dac_volume = update_ak4396_volume, | 499 | .update_dac_volume = update_ak4396_volume, |
@@ -374,6 +522,7 @@ static int __devinit get_oxygen_model(struct oxygen *chip, | |||
374 | switch (id->driver_data) { | 522 | switch (id->driver_data) { |
375 | case MODEL_MERIDIAN: | 523 | case MODEL_MERIDIAN: |
376 | chip->model.init = meridian_init; | 524 | chip->model.init = meridian_init; |
525 | chip->model.mixer_init = generic_mixer_init; | ||
377 | chip->model.resume = meridian_resume; | 526 | chip->model.resume = meridian_resume; |
378 | chip->model.set_adc_params = set_ak5385_params; | 527 | chip->model.set_adc_params = set_ak5385_params; |
379 | chip->model.device_config = PLAYBACK_0_TO_I2S | | 528 | chip->model.device_config = PLAYBACK_0_TO_I2S | |
@@ -389,6 +538,7 @@ static int __devinit get_oxygen_model(struct oxygen *chip, | |||
389 | break; | 538 | break; |
390 | case MODEL_CLARO_HALO: | 539 | case MODEL_CLARO_HALO: |
391 | chip->model.init = claro_halo_init; | 540 | chip->model.init = claro_halo_init; |
541 | chip->model.mixer_init = generic_mixer_init; | ||
392 | chip->model.cleanup = claro_cleanup; | 542 | chip->model.cleanup = claro_cleanup; |
393 | chip->model.suspend = claro_suspend; | 543 | chip->model.suspend = claro_suspend; |
394 | chip->model.resume = claro_resume; | 544 | chip->model.resume = claro_resume; |
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index bd615dbffadb..6147216af744 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h | |||
@@ -78,12 +78,15 @@ struct oxygen_model { | |||
78 | void (*resume)(struct oxygen *chip); | 78 | void (*resume)(struct oxygen *chip); |
79 | void (*pcm_hardware_filter)(unsigned int channel, | 79 | void (*pcm_hardware_filter)(unsigned int channel, |
80 | struct snd_pcm_hardware *hardware); | 80 | struct snd_pcm_hardware *hardware); |
81 | unsigned int (*get_i2s_mclk)(struct oxygen *chip, unsigned int channel, | ||
82 | struct snd_pcm_hw_params *hw_params); | ||
81 | void (*set_dac_params)(struct oxygen *chip, | 83 | void (*set_dac_params)(struct oxygen *chip, |
82 | struct snd_pcm_hw_params *params); | 84 | struct snd_pcm_hw_params *params); |
83 | void (*set_adc_params)(struct oxygen *chip, | 85 | void (*set_adc_params)(struct oxygen *chip, |
84 | struct snd_pcm_hw_params *params); | 86 | struct snd_pcm_hw_params *params); |
85 | void (*update_dac_volume)(struct oxygen *chip); | 87 | void (*update_dac_volume)(struct oxygen *chip); |
86 | void (*update_dac_mute)(struct oxygen *chip); | 88 | void (*update_dac_mute)(struct oxygen *chip); |
89 | void (*update_center_lfe_mix)(struct oxygen *chip, bool mixed); | ||
87 | void (*gpio_changed)(struct oxygen *chip); | 90 | void (*gpio_changed)(struct oxygen *chip); |
88 | void (*uart_input)(struct oxygen *chip); | 91 | void (*uart_input)(struct oxygen *chip); |
89 | void (*ac97_switch)(struct oxygen *chip, | 92 | void (*ac97_switch)(struct oxygen *chip, |
@@ -162,6 +165,8 @@ void oxygen_update_spdif_source(struct oxygen *chip); | |||
162 | /* oxygen_pcm.c */ | 165 | /* oxygen_pcm.c */ |
163 | 166 | ||
164 | int oxygen_pcm_init(struct oxygen *chip); | 167 | int oxygen_pcm_init(struct oxygen *chip); |
168 | unsigned int oxygen_default_i2s_mclk(struct oxygen *chip, unsigned int channel, | ||
169 | struct snd_pcm_hw_params *hw_params); | ||
165 | 170 | ||
166 | /* oxygen_io.c */ | 171 | /* oxygen_io.c */ |
167 | 172 | ||
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index 9a8936e20744..9c5e6450eebb 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c | |||
@@ -278,7 +278,11 @@ oxygen_search_pci_id(struct oxygen *chip, const struct pci_device_id ids[]) | |||
278 | static void oxygen_restore_eeprom(struct oxygen *chip, | 278 | static void oxygen_restore_eeprom(struct oxygen *chip, |
279 | const struct pci_device_id *id) | 279 | const struct pci_device_id *id) |
280 | { | 280 | { |
281 | if (oxygen_read_eeprom(chip, 0) != OXYGEN_EEPROM_ID) { | 281 | u16 eeprom_id; |
282 | |||
283 | eeprom_id = oxygen_read_eeprom(chip, 0); | ||
284 | if (eeprom_id != OXYGEN_EEPROM_ID && | ||
285 | (eeprom_id != 0xffff || id->subdevice != 0x8788)) { | ||
282 | /* | 286 | /* |
283 | * This function gets called only when a known card model has | 287 | * This function gets called only when a known card model has |
284 | * been detected, i.e., we know there is a valid subsystem | 288 | * been detected, i.e., we know there is a valid subsystem |
@@ -303,6 +307,28 @@ static void oxygen_restore_eeprom(struct oxygen *chip, | |||
303 | } | 307 | } |
304 | } | 308 | } |
305 | 309 | ||
310 | static void pci_bridge_magic(void) | ||
311 | { | ||
312 | struct pci_dev *pci = NULL; | ||
313 | u32 tmp; | ||
314 | |||
315 | for (;;) { | ||
316 | /* If there is any Pericom PI7C9X110 PCI-E/PCI bridge ... */ | ||
317 | pci = pci_get_device(0x12d8, 0xe110, pci); | ||
318 | if (!pci) | ||
319 | break; | ||
320 | /* | ||
321 | * ... configure its secondary internal arbiter to park to | ||
322 | * the secondary port, instead of to the last master. | ||
323 | */ | ||
324 | if (!pci_read_config_dword(pci, 0x40, &tmp)) { | ||
325 | tmp |= 1; | ||
326 | pci_write_config_dword(pci, 0x40, tmp); | ||
327 | } | ||
328 | /* Why? Try asking C-Media. */ | ||
329 | } | ||
330 | } | ||
331 | |||
306 | static void oxygen_init(struct oxygen *chip) | 332 | static void oxygen_init(struct oxygen *chip) |
307 | { | 333 | { |
308 | unsigned int i; | 334 | unsigned int i; |
@@ -581,6 +607,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
581 | snd_card_set_dev(card, &pci->dev); | 607 | snd_card_set_dev(card, &pci->dev); |
582 | card->private_free = oxygen_card_free; | 608 | card->private_free = oxygen_card_free; |
583 | 609 | ||
610 | pci_bridge_magic(); | ||
584 | oxygen_init(chip); | 611 | oxygen_init(chip); |
585 | chip->model.init(chip); | 612 | chip->model.init(chip); |
586 | 613 | ||
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 5401c547c4e3..f375b8a27862 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c | |||
@@ -99,11 +99,15 @@ static int dac_mute_put(struct snd_kcontrol *ctl, | |||
99 | 99 | ||
100 | static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | 100 | static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) |
101 | { | 101 | { |
102 | static const char *const names[3] = { | 102 | static const char *const names[5] = { |
103 | "Front", "Front+Surround", "Front+Surround+Back" | 103 | "Front", |
104 | "Front+Surround", | ||
105 | "Front+Surround+Back", | ||
106 | "Front+Surround+Center/LFE", | ||
107 | "Front+Surround+Center/LFE+Back", | ||
104 | }; | 108 | }; |
105 | struct oxygen *chip = ctl->private_data; | 109 | struct oxygen *chip = ctl->private_data; |
106 | unsigned int count = 2 + (chip->model.dac_channels == 8); | 110 | unsigned int count = chip->model.update_center_lfe_mix ? 5 : 3; |
107 | 111 | ||
108 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 112 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
109 | info->count = 1; | 113 | info->count = 1; |
@@ -127,7 +131,7 @@ static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | |||
127 | void oxygen_update_dac_routing(struct oxygen *chip) | 131 | void oxygen_update_dac_routing(struct oxygen *chip) |
128 | { | 132 | { |
129 | /* DAC 0: front, DAC 1: surround, DAC 2: center/LFE, DAC 3: back */ | 133 | /* DAC 0: front, DAC 1: surround, DAC 2: center/LFE, DAC 3: back */ |
130 | static const unsigned int reg_values[3] = { | 134 | static const unsigned int reg_values[5] = { |
131 | /* stereo -> front */ | 135 | /* stereo -> front */ |
132 | (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | | 136 | (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | |
133 | (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) | | 137 | (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) | |
@@ -143,6 +147,16 @@ void oxygen_update_dac_routing(struct oxygen *chip) | |||
143 | (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) | | 147 | (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) | |
144 | (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) | | 148 | (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) | |
145 | (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT), | 149 | (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT), |
150 | /* stereo -> front+surround+center/LFE */ | ||
151 | (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | | ||
152 | (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) | | ||
153 | (0 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) | | ||
154 | (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT), | ||
155 | /* stereo -> front+surround+center/LFE+back */ | ||
156 | (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | | ||
157 | (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) | | ||
158 | (0 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) | | ||
159 | (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT), | ||
146 | }; | 160 | }; |
147 | u8 channels; | 161 | u8 channels; |
148 | unsigned int reg_value; | 162 | unsigned int reg_value; |
@@ -167,22 +181,23 @@ void oxygen_update_dac_routing(struct oxygen *chip) | |||
167 | OXYGEN_PLAY_DAC1_SOURCE_MASK | | 181 | OXYGEN_PLAY_DAC1_SOURCE_MASK | |
168 | OXYGEN_PLAY_DAC2_SOURCE_MASK | | 182 | OXYGEN_PLAY_DAC2_SOURCE_MASK | |
169 | OXYGEN_PLAY_DAC3_SOURCE_MASK); | 183 | OXYGEN_PLAY_DAC3_SOURCE_MASK); |
184 | if (chip->model.update_center_lfe_mix) | ||
185 | chip->model.update_center_lfe_mix(chip, chip->dac_routing > 2); | ||
170 | } | 186 | } |
171 | 187 | ||
172 | static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 188 | static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |
173 | { | 189 | { |
174 | struct oxygen *chip = ctl->private_data; | 190 | struct oxygen *chip = ctl->private_data; |
175 | unsigned int count = 2 + (chip->model.dac_channels == 8); | 191 | unsigned int count = chip->model.update_center_lfe_mix ? 5 : 3; |
176 | int changed; | 192 | int changed; |
177 | 193 | ||
194 | if (value->value.enumerated.item[0] >= count) | ||
195 | return -EINVAL; | ||
178 | mutex_lock(&chip->mutex); | 196 | mutex_lock(&chip->mutex); |
179 | changed = value->value.enumerated.item[0] != chip->dac_routing; | 197 | changed = value->value.enumerated.item[0] != chip->dac_routing; |
180 | if (changed) { | 198 | if (changed) { |
181 | chip->dac_routing = min(value->value.enumerated.item[0], | 199 | chip->dac_routing = value->value.enumerated.item[0]; |
182 | count - 1); | ||
183 | spin_lock_irq(&chip->reg_lock); | ||
184 | oxygen_update_dac_routing(chip); | 200 | oxygen_update_dac_routing(chip); |
185 | spin_unlock_irq(&chip->reg_lock); | ||
186 | } | 201 | } |
187 | mutex_unlock(&chip->mutex); | 202 | mutex_unlock(&chip->mutex); |
188 | return changed; | 203 | return changed; |
@@ -790,7 +805,7 @@ static const struct { | |||
790 | .controls = { | 805 | .controls = { |
791 | { | 806 | { |
792 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 807 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
793 | .name = "Analog Input Monitor Switch", | 808 | .name = "Analog Input Monitor Playback Switch", |
794 | .info = snd_ctl_boolean_mono_info, | 809 | .info = snd_ctl_boolean_mono_info, |
795 | .get = monitor_get, | 810 | .get = monitor_get, |
796 | .put = monitor_put, | 811 | .put = monitor_put, |
@@ -798,7 +813,7 @@ static const struct { | |||
798 | }, | 813 | }, |
799 | { | 814 | { |
800 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 815 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
801 | .name = "Analog Input Monitor Volume", | 816 | .name = "Analog Input Monitor Playback Volume", |
802 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 817 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
803 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | 818 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, |
804 | .info = monitor_volume_info, | 819 | .info = monitor_volume_info, |
@@ -815,7 +830,7 @@ static const struct { | |||
815 | .controls = { | 830 | .controls = { |
816 | { | 831 | { |
817 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 832 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
818 | .name = "Analog Input Monitor Switch", | 833 | .name = "Analog Input Monitor Playback Switch", |
819 | .info = snd_ctl_boolean_mono_info, | 834 | .info = snd_ctl_boolean_mono_info, |
820 | .get = monitor_get, | 835 | .get = monitor_get, |
821 | .put = monitor_put, | 836 | .put = monitor_put, |
@@ -823,7 +838,7 @@ static const struct { | |||
823 | }, | 838 | }, |
824 | { | 839 | { |
825 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 840 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
826 | .name = "Analog Input Monitor Volume", | 841 | .name = "Analog Input Monitor Playback Volume", |
827 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 842 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
828 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | 843 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, |
829 | .info = monitor_volume_info, | 844 | .info = monitor_volume_info, |
@@ -840,7 +855,7 @@ static const struct { | |||
840 | .controls = { | 855 | .controls = { |
841 | { | 856 | { |
842 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 857 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
843 | .name = "Analog Input Monitor Switch", | 858 | .name = "Analog Input Monitor Playback Switch", |
844 | .index = 1, | 859 | .index = 1, |
845 | .info = snd_ctl_boolean_mono_info, | 860 | .info = snd_ctl_boolean_mono_info, |
846 | .get = monitor_get, | 861 | .get = monitor_get, |
@@ -849,7 +864,7 @@ static const struct { | |||
849 | }, | 864 | }, |
850 | { | 865 | { |
851 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 866 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
852 | .name = "Analog Input Monitor Volume", | 867 | .name = "Analog Input Monitor Playback Volume", |
853 | .index = 1, | 868 | .index = 1, |
854 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 869 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
855 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | 870 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, |
@@ -867,7 +882,7 @@ static const struct { | |||
867 | .controls = { | 882 | .controls = { |
868 | { | 883 | { |
869 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 884 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
870 | .name = "Digital Input Monitor Switch", | 885 | .name = "Digital Input Monitor Playback Switch", |
871 | .info = snd_ctl_boolean_mono_info, | 886 | .info = snd_ctl_boolean_mono_info, |
872 | .get = monitor_get, | 887 | .get = monitor_get, |
873 | .put = monitor_put, | 888 | .put = monitor_put, |
@@ -875,7 +890,7 @@ static const struct { | |||
875 | }, | 890 | }, |
876 | { | 891 | { |
877 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 892 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
878 | .name = "Digital Input Monitor Volume", | 893 | .name = "Digital Input Monitor Playback Volume", |
879 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 894 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
880 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | 895 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, |
881 | .info = monitor_volume_info, | 896 | .info = monitor_volume_info, |
@@ -954,6 +969,9 @@ static int add_controls(struct oxygen *chip, | |||
954 | if (err == 1) | 969 | if (err == 1) |
955 | continue; | 970 | continue; |
956 | } | 971 | } |
972 | if (!strcmp(template.name, "Stereo Upmixing") && | ||
973 | chip->model.dac_channels == 2) | ||
974 | continue; | ||
957 | if (!strcmp(template.name, "Master Playback Volume") && | 975 | if (!strcmp(template.name, "Master Playback Volume") && |
958 | chip->model.dac_tlv) { | 976 | chip->model.dac_tlv) { |
959 | template.tlv.p = chip->model.dac_tlv; | 977 | template.tlv.p = chip->model.dac_tlv; |
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index ef2345d82b86..9dff6954c397 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -271,13 +271,16 @@ static unsigned int oxygen_rate(struct snd_pcm_hw_params *hw_params) | |||
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | static unsigned int oxygen_i2s_mclk(struct snd_pcm_hw_params *hw_params) | 274 | unsigned int oxygen_default_i2s_mclk(struct oxygen *chip, |
275 | unsigned int channel, | ||
276 | struct snd_pcm_hw_params *hw_params) | ||
275 | { | 277 | { |
276 | if (params_rate(hw_params) <= 96000) | 278 | if (params_rate(hw_params) <= 96000) |
277 | return OXYGEN_I2S_MCLK_256; | 279 | return OXYGEN_I2S_MCLK_256; |
278 | else | 280 | else |
279 | return OXYGEN_I2S_MCLK_128; | 281 | return OXYGEN_I2S_MCLK_128; |
280 | } | 282 | } |
283 | EXPORT_SYMBOL(oxygen_default_i2s_mclk); | ||
281 | 284 | ||
282 | static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params) | 285 | static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params) |
283 | { | 286 | { |
@@ -354,7 +357,7 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, | |||
354 | OXYGEN_REC_FORMAT_A_MASK); | 357 | OXYGEN_REC_FORMAT_A_MASK); |
355 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, | 358 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, |
356 | oxygen_rate(hw_params) | | 359 | oxygen_rate(hw_params) | |
357 | oxygen_i2s_mclk(hw_params) | | 360 | chip->model.get_i2s_mclk(chip, PCM_A, hw_params) | |
358 | chip->model.adc_i2s_format | | 361 | chip->model.adc_i2s_format | |
359 | oxygen_i2s_bits(hw_params), | 362 | oxygen_i2s_bits(hw_params), |
360 | OXYGEN_I2S_RATE_MASK | | 363 | OXYGEN_I2S_RATE_MASK | |
@@ -390,7 +393,8 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, | |||
390 | if (!is_ac97) | 393 | if (!is_ac97) |
391 | oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, | 394 | oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, |
392 | oxygen_rate(hw_params) | | 395 | oxygen_rate(hw_params) | |
393 | oxygen_i2s_mclk(hw_params) | | 396 | chip->model.get_i2s_mclk(chip, PCM_B, |
397 | hw_params) | | ||
394 | chip->model.adc_i2s_format | | 398 | chip->model.adc_i2s_format | |
395 | oxygen_i2s_bits(hw_params), | 399 | oxygen_i2s_bits(hw_params), |
396 | OXYGEN_I2S_RATE_MASK | | 400 | OXYGEN_I2S_RATE_MASK | |
@@ -435,6 +439,7 @@ static int oxygen_spdif_hw_params(struct snd_pcm_substream *substream, | |||
435 | if (err < 0) | 439 | if (err < 0) |
436 | return err; | 440 | return err; |
437 | 441 | ||
442 | mutex_lock(&chip->mutex); | ||
438 | spin_lock_irq(&chip->reg_lock); | 443 | spin_lock_irq(&chip->reg_lock); |
439 | oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, | 444 | oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, |
440 | OXYGEN_SPDIF_OUT_ENABLE); | 445 | OXYGEN_SPDIF_OUT_ENABLE); |
@@ -446,6 +451,7 @@ static int oxygen_spdif_hw_params(struct snd_pcm_substream *substream, | |||
446 | OXYGEN_SPDIF_OUT_RATE_MASK); | 451 | OXYGEN_SPDIF_OUT_RATE_MASK); |
447 | oxygen_update_spdif_source(chip); | 452 | oxygen_update_spdif_source(chip); |
448 | spin_unlock_irq(&chip->reg_lock); | 453 | spin_unlock_irq(&chip->reg_lock); |
454 | mutex_unlock(&chip->mutex); | ||
449 | return 0; | 455 | return 0; |
450 | } | 456 | } |
451 | 457 | ||
@@ -459,6 +465,7 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
459 | if (err < 0) | 465 | if (err < 0) |
460 | return err; | 466 | return err; |
461 | 467 | ||
468 | mutex_lock(&chip->mutex); | ||
462 | spin_lock_irq(&chip->reg_lock); | 469 | spin_lock_irq(&chip->reg_lock); |
463 | oxygen_write8_masked(chip, OXYGEN_PLAY_CHANNELS, | 470 | oxygen_write8_masked(chip, OXYGEN_PLAY_CHANNELS, |
464 | oxygen_play_channels(hw_params), | 471 | oxygen_play_channels(hw_params), |
@@ -469,18 +476,18 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | 476 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, |
470 | oxygen_rate(hw_params) | | 477 | oxygen_rate(hw_params) | |
471 | chip->model.dac_i2s_format | | 478 | chip->model.dac_i2s_format | |
472 | oxygen_i2s_mclk(hw_params) | | 479 | chip->model.get_i2s_mclk(chip, PCM_MULTICH, |
480 | hw_params) | | ||
473 | oxygen_i2s_bits(hw_params), | 481 | oxygen_i2s_bits(hw_params), |
474 | OXYGEN_I2S_RATE_MASK | | 482 | OXYGEN_I2S_RATE_MASK | |
475 | OXYGEN_I2S_FORMAT_MASK | | 483 | OXYGEN_I2S_FORMAT_MASK | |
476 | OXYGEN_I2S_MCLK_MASK | | 484 | OXYGEN_I2S_MCLK_MASK | |
477 | OXYGEN_I2S_BITS_MASK); | 485 | OXYGEN_I2S_BITS_MASK); |
478 | oxygen_update_dac_routing(chip); | ||
479 | oxygen_update_spdif_source(chip); | 486 | oxygen_update_spdif_source(chip); |
480 | spin_unlock_irq(&chip->reg_lock); | 487 | spin_unlock_irq(&chip->reg_lock); |
481 | 488 | ||
482 | mutex_lock(&chip->mutex); | ||
483 | chip->model.set_dac_params(chip, hw_params); | 489 | chip->model.set_dac_params(chip, hw_params); |
490 | oxygen_update_dac_routing(chip); | ||
484 | mutex_unlock(&chip->mutex); | 491 | mutex_unlock(&chip->mutex); |
485 | return 0; | 492 | return 0; |
486 | } | 493 | } |
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 6ebcb6bdd712..6accaf9580b2 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c | |||
@@ -17,145 +17,12 @@ | |||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* | ||
21 | * Xonar D2/D2X | ||
22 | * ------------ | ||
23 | * | ||
24 | * CMI8788: | ||
25 | * | ||
26 | * SPI 0 -> 1st PCM1796 (front) | ||
27 | * SPI 1 -> 2nd PCM1796 (surround) | ||
28 | * SPI 2 -> 3rd PCM1796 (center/LFE) | ||
29 | * SPI 4 -> 4th PCM1796 (back) | ||
30 | * | ||
31 | * GPIO 2 -> M0 of CS5381 | ||
32 | * GPIO 3 -> M1 of CS5381 | ||
33 | * GPIO 5 <- external power present (D2X only) | ||
34 | * GPIO 7 -> ALT | ||
35 | * GPIO 8 -> enable output to speakers | ||
36 | */ | ||
37 | |||
38 | /* | ||
39 | * Xonar D1/DX | ||
40 | * ----------- | ||
41 | * | ||
42 | * CMI8788: | ||
43 | * | ||
44 | * I²C <-> CS4398 (front) | ||
45 | * <-> CS4362A (surround, center/LFE, back) | ||
46 | * | ||
47 | * GPI 0 <- external power present (DX only) | ||
48 | * | ||
49 | * GPIO 0 -> enable output to speakers | ||
50 | * GPIO 1 -> enable front panel I/O | ||
51 | * GPIO 2 -> M0 of CS5361 | ||
52 | * GPIO 3 -> M1 of CS5361 | ||
53 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
54 | * | ||
55 | * CS4398: | ||
56 | * | ||
57 | * AD0 <- 1 | ||
58 | * AD1 <- 1 | ||
59 | * | ||
60 | * CS4362A: | ||
61 | * | ||
62 | * AD0 <- 0 | ||
63 | */ | ||
64 | |||
65 | /* | ||
66 | * Xonar HDAV1.3 (Deluxe) | ||
67 | * ---------------------- | ||
68 | * | ||
69 | * CMI8788: | ||
70 | * | ||
71 | * I²C <-> PCM1796 (front) | ||
72 | * | ||
73 | * GPI 0 <- external power present | ||
74 | * | ||
75 | * GPIO 0 -> enable output to speakers | ||
76 | * GPIO 2 -> M0 of CS5381 | ||
77 | * GPIO 3 -> M1 of CS5381 | ||
78 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
79 | * | ||
80 | * TXD -> HDMI controller | ||
81 | * RXD <- HDMI controller | ||
82 | * | ||
83 | * PCM1796 front: AD1,0 <- 0,0 | ||
84 | * | ||
85 | * no daughterboard | ||
86 | * ---------------- | ||
87 | * | ||
88 | * GPIO 4 <- 1 | ||
89 | * | ||
90 | * H6 daughterboard | ||
91 | * ---------------- | ||
92 | * | ||
93 | * GPIO 4 <- 0 | ||
94 | * GPIO 5 <- 0 | ||
95 | * | ||
96 | * I²C <-> PCM1796 (surround) | ||
97 | * <-> PCM1796 (center/LFE) | ||
98 | * <-> PCM1796 (back) | ||
99 | * | ||
100 | * PCM1796 surround: AD1,0 <- 0,1 | ||
101 | * PCM1796 center/LFE: AD1,0 <- 1,0 | ||
102 | * PCM1796 back: AD1,0 <- 1,1 | ||
103 | * | ||
104 | * unknown daughterboard | ||
105 | * --------------------- | ||
106 | * | ||
107 | * GPIO 4 <- 0 | ||
108 | * GPIO 5 <- 1 | ||
109 | * | ||
110 | * I²C <-> CS4362A (surround, center/LFE, back) | ||
111 | * | ||
112 | * CS4362A: AD0 <- 0 | ||
113 | */ | ||
114 | |||
115 | /* | ||
116 | * Xonar Essence ST (Deluxe)/STX | ||
117 | * ----------------------------- | ||
118 | * | ||
119 | * CMI8788: | ||
120 | * | ||
121 | * I²C <-> PCM1792A | ||
122 | * | ||
123 | * GPI 0 <- external power present | ||
124 | * | ||
125 | * GPIO 0 -> enable output to speakers | ||
126 | * GPIO 1 -> route HP to front panel (0) or rear jack (1) | ||
127 | * GPIO 2 -> M0 of CS5381 | ||
128 | * GPIO 3 -> M1 of CS5381 | ||
129 | * GPIO 7 -> route output to speaker jacks (0) or HP (1) | ||
130 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
131 | * | ||
132 | * PCM1792A: | ||
133 | * | ||
134 | * AD0 <- 0 | ||
135 | * | ||
136 | * H6 daughterboard | ||
137 | * ---------------- | ||
138 | * | ||
139 | * GPIO 4 <- 0 | ||
140 | * GPIO 5 <- 0 | ||
141 | */ | ||
142 | |||
143 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
144 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
145 | #include <linux/mutex.h> | ||
146 | #include <sound/ac97_codec.h> | ||
147 | #include <sound/asoundef.h> | ||
148 | #include <sound/control.h> | ||
149 | #include <sound/core.h> | 22 | #include <sound/core.h> |
150 | #include <sound/initval.h> | 23 | #include <sound/initval.h> |
151 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
152 | #include <sound/pcm_params.h> | 25 | #include "xonar.h" |
153 | #include <sound/tlv.h> | ||
154 | #include "oxygen.h" | ||
155 | #include "cm9780.h" | ||
156 | #include "pcm1796.h" | ||
157 | #include "cs4398.h" | ||
158 | #include "cs4362a.h" | ||
159 | 26 | ||
160 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | 27 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
161 | MODULE_DESCRIPTION("Asus AVx00 driver"); | 28 | MODULE_DESCRIPTION("Asus AVx00 driver"); |
@@ -173,972 +40,28 @@ MODULE_PARM_DESC(id, "ID string"); | |||
173 | module_param_array(enable, bool, NULL, 0444); | 40 | module_param_array(enable, bool, NULL, 0444); |
174 | MODULE_PARM_DESC(enable, "enable card"); | 41 | MODULE_PARM_DESC(enable, "enable card"); |
175 | 42 | ||
176 | enum { | ||
177 | MODEL_D2, | ||
178 | MODEL_D2X, | ||
179 | MODEL_D1, | ||
180 | MODEL_DX, | ||
181 | MODEL_HDAV, /* without daughterboard */ | ||
182 | MODEL_HDAV_H6, /* with H6 daughterboard */ | ||
183 | MODEL_ST, | ||
184 | MODEL_ST_H6, | ||
185 | MODEL_STX, | ||
186 | }; | ||
187 | |||
188 | static struct pci_device_id xonar_ids[] __devinitdata = { | 43 | static struct pci_device_id xonar_ids[] __devinitdata = { |
189 | { OXYGEN_PCI_SUBID(0x1043, 0x8269), .driver_data = MODEL_D2 }, | 44 | { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, |
190 | { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX }, | 45 | { OXYGEN_PCI_SUBID(0x1043, 0x8275) }, |
191 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X }, | 46 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, |
192 | { OXYGEN_PCI_SUBID(0x1043, 0x8314), .driver_data = MODEL_HDAV }, | 47 | { OXYGEN_PCI_SUBID(0x1043, 0x8314) }, |
193 | { OXYGEN_PCI_SUBID(0x1043, 0x8327), .driver_data = MODEL_DX }, | 48 | { OXYGEN_PCI_SUBID(0x1043, 0x8327) }, |
194 | { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 }, | 49 | { OXYGEN_PCI_SUBID(0x1043, 0x834f) }, |
195 | { OXYGEN_PCI_SUBID(0x1043, 0x835c), .driver_data = MODEL_STX }, | 50 | { OXYGEN_PCI_SUBID(0x1043, 0x835c) }, |
196 | { OXYGEN_PCI_SUBID(0x1043, 0x835d), .driver_data = MODEL_ST }, | 51 | { OXYGEN_PCI_SUBID(0x1043, 0x835d) }, |
197 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, | 52 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, |
198 | { } | 53 | { } |
199 | }; | 54 | }; |
200 | MODULE_DEVICE_TABLE(pci, xonar_ids); | 55 | MODULE_DEVICE_TABLE(pci, xonar_ids); |
201 | 56 | ||
202 | |||
203 | #define GPIO_CS53x1_M_MASK 0x000c | ||
204 | #define GPIO_CS53x1_M_SINGLE 0x0000 | ||
205 | #define GPIO_CS53x1_M_DOUBLE 0x0004 | ||
206 | #define GPIO_CS53x1_M_QUAD 0x0008 | ||
207 | |||
208 | #define GPIO_D2X_EXT_POWER 0x0020 | ||
209 | #define GPIO_D2_ALT 0x0080 | ||
210 | #define GPIO_D2_OUTPUT_ENABLE 0x0100 | ||
211 | |||
212 | #define GPI_DX_EXT_POWER 0x01 | ||
213 | #define GPIO_DX_OUTPUT_ENABLE 0x0001 | ||
214 | #define GPIO_DX_FRONT_PANEL 0x0002 | ||
215 | #define GPIO_DX_INPUT_ROUTE 0x0100 | ||
216 | |||
217 | #define GPIO_DB_MASK 0x0030 | ||
218 | #define GPIO_DB_H6 0x0000 | ||
219 | #define GPIO_DB_XX 0x0020 | ||
220 | |||
221 | #define GPIO_ST_HP_REAR 0x0002 | ||
222 | #define GPIO_ST_HP 0x0080 | ||
223 | |||
224 | #define I2C_DEVICE_PCM1796(i) (0x98 + ((i) << 1)) /* 10011, ADx=i, /W=0 */ | ||
225 | #define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */ | ||
226 | #define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */ | ||
227 | |||
228 | struct xonar_data { | ||
229 | unsigned int anti_pop_delay; | ||
230 | unsigned int dacs; | ||
231 | u16 output_enable_bit; | ||
232 | u8 ext_power_reg; | ||
233 | u8 ext_power_int_reg; | ||
234 | u8 ext_power_bit; | ||
235 | u8 has_power; | ||
236 | u8 pcm1796_oversampling; | ||
237 | u8 cs4398_fm; | ||
238 | u8 cs4362a_fm; | ||
239 | u8 hdmi_params[5]; | ||
240 | }; | ||
241 | |||
242 | static void xonar_gpio_changed(struct oxygen *chip); | ||
243 | |||
244 | static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec, | ||
245 | u8 reg, u8 value) | ||
246 | { | ||
247 | /* maps ALSA channel pair number to SPI output */ | ||
248 | static const u8 codec_map[4] = { | ||
249 | 0, 1, 2, 4 | ||
250 | }; | ||
251 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | | ||
252 | OXYGEN_SPI_DATA_LENGTH_2 | | ||
253 | OXYGEN_SPI_CLOCK_160 | | ||
254 | (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | | ||
255 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, | ||
256 | (reg << 8) | value); | ||
257 | } | ||
258 | |||
259 | static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec, | ||
260 | u8 reg, u8 value) | ||
261 | { | ||
262 | oxygen_write_i2c(chip, I2C_DEVICE_PCM1796(codec), reg, value); | ||
263 | } | ||
264 | |||
265 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, | ||
266 | u8 reg, u8 value) | ||
267 | { | ||
268 | if ((chip->model.function_flags & OXYGEN_FUNCTION_2WIRE_SPI_MASK) == | ||
269 | OXYGEN_FUNCTION_SPI) | ||
270 | pcm1796_write_spi(chip, codec, reg, value); | ||
271 | else | ||
272 | pcm1796_write_i2c(chip, codec, reg, value); | ||
273 | } | ||
274 | |||
275 | static void cs4398_write(struct oxygen *chip, u8 reg, u8 value) | ||
276 | { | ||
277 | oxygen_write_i2c(chip, I2C_DEVICE_CS4398, reg, value); | ||
278 | } | ||
279 | |||
280 | static void cs4362a_write(struct oxygen *chip, u8 reg, u8 value) | ||
281 | { | ||
282 | oxygen_write_i2c(chip, I2C_DEVICE_CS4362A, reg, value); | ||
283 | } | ||
284 | |||
285 | static void hdmi_write_command(struct oxygen *chip, u8 command, | ||
286 | unsigned int count, const u8 *params) | ||
287 | { | ||
288 | unsigned int i; | ||
289 | u8 checksum; | ||
290 | |||
291 | oxygen_write_uart(chip, 0xfb); | ||
292 | oxygen_write_uart(chip, 0xef); | ||
293 | oxygen_write_uart(chip, command); | ||
294 | oxygen_write_uart(chip, count); | ||
295 | for (i = 0; i < count; ++i) | ||
296 | oxygen_write_uart(chip, params[i]); | ||
297 | checksum = 0xfb + 0xef + command + count; | ||
298 | for (i = 0; i < count; ++i) | ||
299 | checksum += params[i]; | ||
300 | oxygen_write_uart(chip, checksum); | ||
301 | } | ||
302 | |||
303 | static void xonar_enable_output(struct oxygen *chip) | ||
304 | { | ||
305 | struct xonar_data *data = chip->model_data; | ||
306 | |||
307 | msleep(data->anti_pop_delay); | ||
308 | oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); | ||
309 | } | ||
310 | |||
311 | static void xonar_common_init(struct oxygen *chip) | ||
312 | { | ||
313 | struct xonar_data *data = chip->model_data; | ||
314 | |||
315 | if (data->ext_power_reg) { | ||
316 | oxygen_set_bits8(chip, data->ext_power_int_reg, | ||
317 | data->ext_power_bit); | ||
318 | chip->interrupt_mask |= OXYGEN_INT_GPIO; | ||
319 | chip->model.gpio_changed = xonar_gpio_changed; | ||
320 | data->has_power = !!(oxygen_read8(chip, data->ext_power_reg) | ||
321 | & data->ext_power_bit); | ||
322 | } | ||
323 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, | ||
324 | GPIO_CS53x1_M_MASK | data->output_enable_bit); | ||
325 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
326 | GPIO_CS53x1_M_SINGLE, GPIO_CS53x1_M_MASK); | ||
327 | oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); | ||
328 | xonar_enable_output(chip); | ||
329 | } | ||
330 | |||
331 | static void update_pcm1796_volume(struct oxygen *chip) | ||
332 | { | ||
333 | struct xonar_data *data = chip->model_data; | ||
334 | unsigned int i; | ||
335 | |||
336 | for (i = 0; i < data->dacs; ++i) { | ||
337 | pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]); | ||
338 | pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | static void update_pcm1796_mute(struct oxygen *chip) | ||
343 | { | ||
344 | struct xonar_data *data = chip->model_data; | ||
345 | unsigned int i; | ||
346 | u8 value; | ||
347 | |||
348 | value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; | ||
349 | if (chip->dac_mute) | ||
350 | value |= PCM1796_MUTE; | ||
351 | for (i = 0; i < data->dacs; ++i) | ||
352 | pcm1796_write(chip, i, 18, value); | ||
353 | } | ||
354 | |||
355 | static void pcm1796_init(struct oxygen *chip) | ||
356 | { | ||
357 | struct xonar_data *data = chip->model_data; | ||
358 | unsigned int i; | ||
359 | |||
360 | for (i = 0; i < data->dacs; ++i) { | ||
361 | pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); | ||
362 | pcm1796_write(chip, i, 20, data->pcm1796_oversampling); | ||
363 | pcm1796_write(chip, i, 21, 0); | ||
364 | } | ||
365 | update_pcm1796_mute(chip); /* set ATLD before ATL/ATR */ | ||
366 | update_pcm1796_volume(chip); | ||
367 | } | ||
368 | |||
369 | static void xonar_d2_init(struct oxygen *chip) | ||
370 | { | ||
371 | struct xonar_data *data = chip->model_data; | ||
372 | |||
373 | data->anti_pop_delay = 300; | ||
374 | data->dacs = 4; | ||
375 | data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE; | ||
376 | data->pcm1796_oversampling = PCM1796_OS_64; | ||
377 | |||
378 | pcm1796_init(chip); | ||
379 | |||
380 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT); | ||
381 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT); | ||
382 | |||
383 | xonar_common_init(chip); | ||
384 | |||
385 | snd_component_add(chip->card, "PCM1796"); | ||
386 | snd_component_add(chip->card, "CS5381"); | ||
387 | } | ||
388 | |||
389 | static void xonar_d2x_init(struct oxygen *chip) | ||
390 | { | ||
391 | struct xonar_data *data = chip->model_data; | ||
392 | |||
393 | data->ext_power_reg = OXYGEN_GPIO_DATA; | ||
394 | data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK; | ||
395 | data->ext_power_bit = GPIO_D2X_EXT_POWER; | ||
396 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER); | ||
397 | |||
398 | xonar_d2_init(chip); | ||
399 | } | ||
400 | |||
401 | static void update_cs4362a_volumes(struct oxygen *chip) | ||
402 | { | ||
403 | u8 mute; | ||
404 | |||
405 | mute = chip->dac_mute ? CS4362A_MUTE : 0; | ||
406 | cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute); | ||
407 | cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute); | ||
408 | cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute); | ||
409 | cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute); | ||
410 | cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute); | ||
411 | cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute); | ||
412 | } | ||
413 | |||
414 | static void update_cs43xx_volume(struct oxygen *chip) | ||
415 | { | ||
416 | cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2); | ||
417 | cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2); | ||
418 | update_cs4362a_volumes(chip); | ||
419 | } | ||
420 | |||
421 | static void update_cs43xx_mute(struct oxygen *chip) | ||
422 | { | ||
423 | u8 reg; | ||
424 | |||
425 | reg = CS4398_MUTEP_LOW | CS4398_PAMUTE; | ||
426 | if (chip->dac_mute) | ||
427 | reg |= CS4398_MUTE_B | CS4398_MUTE_A; | ||
428 | cs4398_write(chip, 4, reg); | ||
429 | update_cs4362a_volumes(chip); | ||
430 | } | ||
431 | |||
432 | static void cs43xx_init(struct oxygen *chip) | ||
433 | { | ||
434 | struct xonar_data *data = chip->model_data; | ||
435 | |||
436 | /* set CPEN (control port mode) and power down */ | ||
437 | cs4398_write(chip, 8, CS4398_CPEN | CS4398_PDN); | ||
438 | cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); | ||
439 | /* configure */ | ||
440 | cs4398_write(chip, 2, data->cs4398_fm); | ||
441 | cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L); | ||
442 | cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP | | ||
443 | CS4398_ZERO_CROSS | CS4398_SOFT_RAMP); | ||
444 | cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST); | ||
445 | cs4362a_write(chip, 0x03, CS4362A_MUTEC_6 | CS4362A_AMUTE | | ||
446 | CS4362A_RMP_UP | CS4362A_ZERO_CROSS | CS4362A_SOFT_RAMP); | ||
447 | cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE); | ||
448 | cs4362a_write(chip, 0x05, 0); | ||
449 | cs4362a_write(chip, 0x06, data->cs4362a_fm); | ||
450 | cs4362a_write(chip, 0x09, data->cs4362a_fm); | ||
451 | cs4362a_write(chip, 0x0c, data->cs4362a_fm); | ||
452 | update_cs43xx_volume(chip); | ||
453 | update_cs43xx_mute(chip); | ||
454 | /* clear power down */ | ||
455 | cs4398_write(chip, 8, CS4398_CPEN); | ||
456 | cs4362a_write(chip, 0x01, CS4362A_CPEN); | ||
457 | } | ||
458 | |||
459 | static void xonar_d1_init(struct oxygen *chip) | ||
460 | { | ||
461 | struct xonar_data *data = chip->model_data; | ||
462 | |||
463 | data->anti_pop_delay = 800; | ||
464 | data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; | ||
465 | data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST; | ||
466 | data->cs4362a_fm = CS4362A_FM_SINGLE | | ||
467 | CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; | ||
468 | |||
469 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
470 | OXYGEN_2WIRE_LENGTH_8 | | ||
471 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
472 | OXYGEN_2WIRE_SPEED_FAST); | ||
473 | |||
474 | cs43xx_init(chip); | ||
475 | |||
476 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, | ||
477 | GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE); | ||
478 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, | ||
479 | GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE); | ||
480 | |||
481 | xonar_common_init(chip); | ||
482 | |||
483 | snd_component_add(chip->card, "CS4398"); | ||
484 | snd_component_add(chip->card, "CS4362A"); | ||
485 | snd_component_add(chip->card, "CS5361"); | ||
486 | } | ||
487 | |||
488 | static void xonar_dx_init(struct oxygen *chip) | ||
489 | { | ||
490 | struct xonar_data *data = chip->model_data; | ||
491 | |||
492 | data->ext_power_reg = OXYGEN_GPI_DATA; | ||
493 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
494 | data->ext_power_bit = GPI_DX_EXT_POWER; | ||
495 | |||
496 | xonar_d1_init(chip); | ||
497 | } | ||
498 | |||
499 | static void xonar_hdav_init(struct oxygen *chip) | ||
500 | { | ||
501 | struct xonar_data *data = chip->model_data; | ||
502 | u8 param; | ||
503 | |||
504 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
505 | OXYGEN_2WIRE_LENGTH_8 | | ||
506 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
507 | OXYGEN_2WIRE_SPEED_FAST); | ||
508 | |||
509 | data->anti_pop_delay = 100; | ||
510 | data->dacs = chip->model.private_data == MODEL_HDAV_H6 ? 4 : 1; | ||
511 | data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; | ||
512 | data->ext_power_reg = OXYGEN_GPI_DATA; | ||
513 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
514 | data->ext_power_bit = GPI_DX_EXT_POWER; | ||
515 | data->pcm1796_oversampling = PCM1796_OS_64; | ||
516 | |||
517 | pcm1796_init(chip); | ||
518 | |||
519 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DX_INPUT_ROUTE); | ||
520 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_DX_INPUT_ROUTE); | ||
521 | |||
522 | oxygen_reset_uart(chip); | ||
523 | param = 0; | ||
524 | hdmi_write_command(chip, 0x61, 1, ¶m); | ||
525 | param = 1; | ||
526 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
527 | data->hdmi_params[1] = IEC958_AES3_CON_FS_48000; | ||
528 | data->hdmi_params[4] = 1; | ||
529 | hdmi_write_command(chip, 0x54, 5, data->hdmi_params); | ||
530 | |||
531 | xonar_common_init(chip); | ||
532 | |||
533 | snd_component_add(chip->card, "PCM1796"); | ||
534 | snd_component_add(chip->card, "CS5381"); | ||
535 | } | ||
536 | |||
537 | static void xonar_st_init(struct oxygen *chip) | ||
538 | { | ||
539 | struct xonar_data *data = chip->model_data; | ||
540 | |||
541 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
542 | OXYGEN_2WIRE_LENGTH_8 | | ||
543 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
544 | OXYGEN_2WIRE_SPEED_FAST); | ||
545 | |||
546 | if (chip->model.private_data == MODEL_ST_H6) | ||
547 | chip->model.dac_channels = 8; | ||
548 | data->anti_pop_delay = 100; | ||
549 | data->dacs = chip->model.private_data == MODEL_ST_H6 ? 4 : 1; | ||
550 | data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; | ||
551 | data->pcm1796_oversampling = PCM1796_OS_64; | ||
552 | |||
553 | pcm1796_init(chip); | ||
554 | |||
555 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, | ||
556 | GPIO_DX_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP); | ||
557 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, | ||
558 | GPIO_DX_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP); | ||
559 | |||
560 | xonar_common_init(chip); | ||
561 | |||
562 | snd_component_add(chip->card, "PCM1792A"); | ||
563 | snd_component_add(chip->card, "CS5381"); | ||
564 | } | ||
565 | |||
566 | static void xonar_stx_init(struct oxygen *chip) | ||
567 | { | ||
568 | struct xonar_data *data = chip->model_data; | ||
569 | |||
570 | data->ext_power_reg = OXYGEN_GPI_DATA; | ||
571 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
572 | data->ext_power_bit = GPI_DX_EXT_POWER; | ||
573 | |||
574 | xonar_st_init(chip); | ||
575 | } | ||
576 | |||
577 | static void xonar_disable_output(struct oxygen *chip) | ||
578 | { | ||
579 | struct xonar_data *data = chip->model_data; | ||
580 | |||
581 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); | ||
582 | } | ||
583 | |||
584 | static void xonar_d2_cleanup(struct oxygen *chip) | ||
585 | { | ||
586 | xonar_disable_output(chip); | ||
587 | } | ||
588 | |||
589 | static void xonar_d1_cleanup(struct oxygen *chip) | ||
590 | { | ||
591 | xonar_disable_output(chip); | ||
592 | cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); | ||
593 | oxygen_clear_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); | ||
594 | } | ||
595 | |||
596 | static void xonar_hdav_cleanup(struct oxygen *chip) | ||
597 | { | ||
598 | u8 param = 0; | ||
599 | |||
600 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
601 | xonar_disable_output(chip); | ||
602 | } | ||
603 | |||
604 | static void xonar_st_cleanup(struct oxygen *chip) | ||
605 | { | ||
606 | xonar_disable_output(chip); | ||
607 | } | ||
608 | |||
609 | static void xonar_d2_suspend(struct oxygen *chip) | ||
610 | { | ||
611 | xonar_d2_cleanup(chip); | ||
612 | } | ||
613 | |||
614 | static void xonar_d1_suspend(struct oxygen *chip) | ||
615 | { | ||
616 | xonar_d1_cleanup(chip); | ||
617 | } | ||
618 | |||
619 | static void xonar_hdav_suspend(struct oxygen *chip) | ||
620 | { | ||
621 | xonar_hdav_cleanup(chip); | ||
622 | msleep(2); | ||
623 | } | ||
624 | |||
625 | static void xonar_st_suspend(struct oxygen *chip) | ||
626 | { | ||
627 | xonar_st_cleanup(chip); | ||
628 | } | ||
629 | |||
630 | static void xonar_d2_resume(struct oxygen *chip) | ||
631 | { | ||
632 | pcm1796_init(chip); | ||
633 | xonar_enable_output(chip); | ||
634 | } | ||
635 | |||
636 | static void xonar_d1_resume(struct oxygen *chip) | ||
637 | { | ||
638 | oxygen_set_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); | ||
639 | msleep(1); | ||
640 | cs43xx_init(chip); | ||
641 | xonar_enable_output(chip); | ||
642 | } | ||
643 | |||
644 | static void xonar_hdav_resume(struct oxygen *chip) | ||
645 | { | ||
646 | struct xonar_data *data = chip->model_data; | ||
647 | u8 param; | ||
648 | |||
649 | oxygen_reset_uart(chip); | ||
650 | param = 0; | ||
651 | hdmi_write_command(chip, 0x61, 1, ¶m); | ||
652 | param = 1; | ||
653 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
654 | hdmi_write_command(chip, 0x54, 5, data->hdmi_params); | ||
655 | pcm1796_init(chip); | ||
656 | xonar_enable_output(chip); | ||
657 | } | ||
658 | |||
659 | static void xonar_st_resume(struct oxygen *chip) | ||
660 | { | ||
661 | pcm1796_init(chip); | ||
662 | xonar_enable_output(chip); | ||
663 | } | ||
664 | |||
665 | static void xonar_hdav_pcm_hardware_filter(unsigned int channel, | ||
666 | struct snd_pcm_hardware *hardware) | ||
667 | { | ||
668 | if (channel == PCM_MULTICH) { | ||
669 | hardware->rates = SNDRV_PCM_RATE_44100 | | ||
670 | SNDRV_PCM_RATE_48000 | | ||
671 | SNDRV_PCM_RATE_96000 | | ||
672 | SNDRV_PCM_RATE_192000; | ||
673 | hardware->rate_min = 44100; | ||
674 | } | ||
675 | } | ||
676 | |||
677 | static void set_pcm1796_params(struct oxygen *chip, | ||
678 | struct snd_pcm_hw_params *params) | ||
679 | { | ||
680 | struct xonar_data *data = chip->model_data; | ||
681 | unsigned int i; | ||
682 | |||
683 | data->pcm1796_oversampling = | ||
684 | params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; | ||
685 | for (i = 0; i < data->dacs; ++i) | ||
686 | pcm1796_write(chip, i, 20, data->pcm1796_oversampling); | ||
687 | } | ||
688 | |||
689 | static void set_cs53x1_params(struct oxygen *chip, | ||
690 | struct snd_pcm_hw_params *params) | ||
691 | { | ||
692 | unsigned int value; | ||
693 | |||
694 | if (params_rate(params) <= 54000) | ||
695 | value = GPIO_CS53x1_M_SINGLE; | ||
696 | else if (params_rate(params) <= 108000) | ||
697 | value = GPIO_CS53x1_M_DOUBLE; | ||
698 | else | ||
699 | value = GPIO_CS53x1_M_QUAD; | ||
700 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
701 | value, GPIO_CS53x1_M_MASK); | ||
702 | } | ||
703 | |||
704 | static void set_cs43xx_params(struct oxygen *chip, | ||
705 | struct snd_pcm_hw_params *params) | ||
706 | { | ||
707 | struct xonar_data *data = chip->model_data; | ||
708 | |||
709 | data->cs4398_fm = CS4398_DEM_NONE | CS4398_DIF_LJUST; | ||
710 | data->cs4362a_fm = CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; | ||
711 | if (params_rate(params) <= 50000) { | ||
712 | data->cs4398_fm |= CS4398_FM_SINGLE; | ||
713 | data->cs4362a_fm |= CS4362A_FM_SINGLE; | ||
714 | } else if (params_rate(params) <= 100000) { | ||
715 | data->cs4398_fm |= CS4398_FM_DOUBLE; | ||
716 | data->cs4362a_fm |= CS4362A_FM_DOUBLE; | ||
717 | } else { | ||
718 | data->cs4398_fm |= CS4398_FM_QUAD; | ||
719 | data->cs4362a_fm |= CS4362A_FM_QUAD; | ||
720 | } | ||
721 | cs4398_write(chip, 2, data->cs4398_fm); | ||
722 | cs4362a_write(chip, 0x06, data->cs4362a_fm); | ||
723 | cs4362a_write(chip, 0x09, data->cs4362a_fm); | ||
724 | cs4362a_write(chip, 0x0c, data->cs4362a_fm); | ||
725 | } | ||
726 | |||
727 | static void set_hdmi_params(struct oxygen *chip, | ||
728 | struct snd_pcm_hw_params *params) | ||
729 | { | ||
730 | struct xonar_data *data = chip->model_data; | ||
731 | |||
732 | data->hdmi_params[0] = 0; /* 1 = non-audio */ | ||
733 | switch (params_rate(params)) { | ||
734 | case 44100: | ||
735 | data->hdmi_params[1] = IEC958_AES3_CON_FS_44100; | ||
736 | break; | ||
737 | case 48000: | ||
738 | data->hdmi_params[1] = IEC958_AES3_CON_FS_48000; | ||
739 | break; | ||
740 | default: /* 96000 */ | ||
741 | data->hdmi_params[1] = IEC958_AES3_CON_FS_96000; | ||
742 | break; | ||
743 | case 192000: | ||
744 | data->hdmi_params[1] = IEC958_AES3_CON_FS_192000; | ||
745 | break; | ||
746 | } | ||
747 | data->hdmi_params[2] = params_channels(params) / 2 - 1; | ||
748 | if (params_format(params) == SNDRV_PCM_FORMAT_S16_LE) | ||
749 | data->hdmi_params[3] = 0; | ||
750 | else | ||
751 | data->hdmi_params[3] = 0xc0; | ||
752 | data->hdmi_params[4] = 1; /* ? */ | ||
753 | hdmi_write_command(chip, 0x54, 5, data->hdmi_params); | ||
754 | } | ||
755 | |||
756 | static void set_hdav_params(struct oxygen *chip, | ||
757 | struct snd_pcm_hw_params *params) | ||
758 | { | ||
759 | set_pcm1796_params(chip, params); | ||
760 | set_hdmi_params(chip, params); | ||
761 | } | ||
762 | |||
763 | static void xonar_gpio_changed(struct oxygen *chip) | ||
764 | { | ||
765 | struct xonar_data *data = chip->model_data; | ||
766 | u8 has_power; | ||
767 | |||
768 | has_power = !!(oxygen_read8(chip, data->ext_power_reg) | ||
769 | & data->ext_power_bit); | ||
770 | if (has_power != data->has_power) { | ||
771 | data->has_power = has_power; | ||
772 | if (has_power) { | ||
773 | snd_printk(KERN_NOTICE "power restored\n"); | ||
774 | } else { | ||
775 | snd_printk(KERN_CRIT | ||
776 | "Hey! Don't unplug the power cable!\n"); | ||
777 | /* TODO: stop PCMs */ | ||
778 | } | ||
779 | } | ||
780 | } | ||
781 | |||
782 | static void xonar_hdav_uart_input(struct oxygen *chip) | ||
783 | { | ||
784 | if (chip->uart_input_count >= 2 && | ||
785 | chip->uart_input[chip->uart_input_count - 2] == 'O' && | ||
786 | chip->uart_input[chip->uart_input_count - 1] == 'K') { | ||
787 | printk(KERN_DEBUG "message from Xonar HDAV HDMI chip received:\n"); | ||
788 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, | ||
789 | chip->uart_input, chip->uart_input_count); | ||
790 | chip->uart_input_count = 0; | ||
791 | } | ||
792 | } | ||
793 | |||
794 | static int gpio_bit_switch_get(struct snd_kcontrol *ctl, | ||
795 | struct snd_ctl_elem_value *value) | ||
796 | { | ||
797 | struct oxygen *chip = ctl->private_data; | ||
798 | u16 bit = ctl->private_value; | ||
799 | |||
800 | value->value.integer.value[0] = | ||
801 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & bit); | ||
802 | return 0; | ||
803 | } | ||
804 | |||
805 | static int gpio_bit_switch_put(struct snd_kcontrol *ctl, | ||
806 | struct snd_ctl_elem_value *value) | ||
807 | { | ||
808 | struct oxygen *chip = ctl->private_data; | ||
809 | u16 bit = ctl->private_value; | ||
810 | u16 old_bits, new_bits; | ||
811 | int changed; | ||
812 | |||
813 | spin_lock_irq(&chip->reg_lock); | ||
814 | old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
815 | if (value->value.integer.value[0]) | ||
816 | new_bits = old_bits | bit; | ||
817 | else | ||
818 | new_bits = old_bits & ~bit; | ||
819 | changed = new_bits != old_bits; | ||
820 | if (changed) | ||
821 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); | ||
822 | spin_unlock_irq(&chip->reg_lock); | ||
823 | return changed; | ||
824 | } | ||
825 | |||
826 | static const struct snd_kcontrol_new alt_switch = { | ||
827 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
828 | .name = "Analog Loopback Switch", | ||
829 | .info = snd_ctl_boolean_mono_info, | ||
830 | .get = gpio_bit_switch_get, | ||
831 | .put = gpio_bit_switch_put, | ||
832 | .private_value = GPIO_D2_ALT, | ||
833 | }; | ||
834 | |||
835 | static const struct snd_kcontrol_new front_panel_switch = { | ||
836 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
837 | .name = "Front Panel Switch", | ||
838 | .info = snd_ctl_boolean_mono_info, | ||
839 | .get = gpio_bit_switch_get, | ||
840 | .put = gpio_bit_switch_put, | ||
841 | .private_value = GPIO_DX_FRONT_PANEL, | ||
842 | }; | ||
843 | |||
844 | static int st_output_switch_info(struct snd_kcontrol *ctl, | ||
845 | struct snd_ctl_elem_info *info) | ||
846 | { | ||
847 | static const char *const names[3] = { | ||
848 | "Speakers", "Headphones", "FP Headphones" | ||
849 | }; | ||
850 | |||
851 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
852 | info->count = 1; | ||
853 | info->value.enumerated.items = 3; | ||
854 | if (info->value.enumerated.item >= 3) | ||
855 | info->value.enumerated.item = 2; | ||
856 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
857 | return 0; | ||
858 | } | ||
859 | |||
860 | static int st_output_switch_get(struct snd_kcontrol *ctl, | ||
861 | struct snd_ctl_elem_value *value) | ||
862 | { | ||
863 | struct oxygen *chip = ctl->private_data; | ||
864 | u16 gpio; | ||
865 | |||
866 | gpio = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
867 | if (!(gpio & GPIO_ST_HP)) | ||
868 | value->value.enumerated.item[0] = 0; | ||
869 | else if (gpio & GPIO_ST_HP_REAR) | ||
870 | value->value.enumerated.item[0] = 1; | ||
871 | else | ||
872 | value->value.enumerated.item[0] = 2; | ||
873 | return 0; | ||
874 | } | ||
875 | |||
876 | |||
877 | static int st_output_switch_put(struct snd_kcontrol *ctl, | ||
878 | struct snd_ctl_elem_value *value) | ||
879 | { | ||
880 | struct oxygen *chip = ctl->private_data; | ||
881 | u16 gpio_old, gpio; | ||
882 | |||
883 | mutex_lock(&chip->mutex); | ||
884 | gpio_old = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
885 | gpio = gpio_old; | ||
886 | switch (value->value.enumerated.item[0]) { | ||
887 | case 0: | ||
888 | gpio &= ~(GPIO_ST_HP | GPIO_ST_HP_REAR); | ||
889 | break; | ||
890 | case 1: | ||
891 | gpio |= GPIO_ST_HP | GPIO_ST_HP_REAR; | ||
892 | break; | ||
893 | case 2: | ||
894 | gpio = (gpio | GPIO_ST_HP) & ~GPIO_ST_HP_REAR; | ||
895 | break; | ||
896 | } | ||
897 | oxygen_write16(chip, OXYGEN_GPIO_DATA, gpio); | ||
898 | mutex_unlock(&chip->mutex); | ||
899 | return gpio != gpio_old; | ||
900 | } | ||
901 | |||
902 | static const struct snd_kcontrol_new st_output_switch = { | ||
903 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
904 | .name = "Analog Output", | ||
905 | .info = st_output_switch_info, | ||
906 | .get = st_output_switch_get, | ||
907 | .put = st_output_switch_put, | ||
908 | }; | ||
909 | |||
910 | static void xonar_line_mic_ac97_switch(struct oxygen *chip, | ||
911 | unsigned int reg, unsigned int mute) | ||
912 | { | ||
913 | if (reg == AC97_LINE) { | ||
914 | spin_lock_irq(&chip->reg_lock); | ||
915 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
916 | mute ? GPIO_DX_INPUT_ROUTE : 0, | ||
917 | GPIO_DX_INPUT_ROUTE); | ||
918 | spin_unlock_irq(&chip->reg_lock); | ||
919 | } | ||
920 | } | ||
921 | |||
922 | static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -6000, 50, 0); | ||
923 | static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -6000, 100, 0); | ||
924 | |||
925 | static int xonar_d2_control_filter(struct snd_kcontrol_new *template) | ||
926 | { | ||
927 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
928 | /* CD in is actually connected to the video in pin */ | ||
929 | template->private_value ^= AC97_CD ^ AC97_VIDEO; | ||
930 | return 0; | ||
931 | } | ||
932 | |||
933 | static int xonar_d1_control_filter(struct snd_kcontrol_new *template) | ||
934 | { | ||
935 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
936 | return 1; /* no CD input */ | ||
937 | return 0; | ||
938 | } | ||
939 | |||
940 | static int xonar_st_control_filter(struct snd_kcontrol_new *template) | ||
941 | { | ||
942 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
943 | return 1; /* no CD input */ | ||
944 | if (!strcmp(template->name, "Stereo Upmixing")) | ||
945 | return 1; /* stereo only - we don't need upmixing */ | ||
946 | return 0; | ||
947 | } | ||
948 | |||
949 | static int xonar_d2_mixer_init(struct oxygen *chip) | ||
950 | { | ||
951 | return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); | ||
952 | } | ||
953 | |||
954 | static int xonar_d1_mixer_init(struct oxygen *chip) | ||
955 | { | ||
956 | return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip)); | ||
957 | } | ||
958 | |||
959 | static int xonar_st_mixer_init(struct oxygen *chip) | ||
960 | { | ||
961 | return snd_ctl_add(chip->card, snd_ctl_new1(&st_output_switch, chip)); | ||
962 | } | ||
963 | |||
964 | static const struct oxygen_model model_xonar_d2 = { | ||
965 | .longname = "Asus Virtuoso 200", | ||
966 | .chip = "AV200", | ||
967 | .init = xonar_d2_init, | ||
968 | .control_filter = xonar_d2_control_filter, | ||
969 | .mixer_init = xonar_d2_mixer_init, | ||
970 | .cleanup = xonar_d2_cleanup, | ||
971 | .suspend = xonar_d2_suspend, | ||
972 | .resume = xonar_d2_resume, | ||
973 | .set_dac_params = set_pcm1796_params, | ||
974 | .set_adc_params = set_cs53x1_params, | ||
975 | .update_dac_volume = update_pcm1796_volume, | ||
976 | .update_dac_mute = update_pcm1796_mute, | ||
977 | .dac_tlv = pcm1796_db_scale, | ||
978 | .model_data_size = sizeof(struct xonar_data), | ||
979 | .device_config = PLAYBACK_0_TO_I2S | | ||
980 | PLAYBACK_1_TO_SPDIF | | ||
981 | CAPTURE_0_FROM_I2S_2 | | ||
982 | CAPTURE_1_FROM_SPDIF | | ||
983 | MIDI_OUTPUT | | ||
984 | MIDI_INPUT, | ||
985 | .dac_channels = 8, | ||
986 | .dac_volume_min = 255 - 2*60, | ||
987 | .dac_volume_max = 255, | ||
988 | .misc_flags = OXYGEN_MISC_MIDI, | ||
989 | .function_flags = OXYGEN_FUNCTION_SPI | | ||
990 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | ||
991 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
992 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
993 | }; | ||
994 | |||
995 | static const struct oxygen_model model_xonar_d1 = { | ||
996 | .longname = "Asus Virtuoso 100", | ||
997 | .chip = "AV200", | ||
998 | .init = xonar_d1_init, | ||
999 | .control_filter = xonar_d1_control_filter, | ||
1000 | .mixer_init = xonar_d1_mixer_init, | ||
1001 | .cleanup = xonar_d1_cleanup, | ||
1002 | .suspend = xonar_d1_suspend, | ||
1003 | .resume = xonar_d1_resume, | ||
1004 | .set_dac_params = set_cs43xx_params, | ||
1005 | .set_adc_params = set_cs53x1_params, | ||
1006 | .update_dac_volume = update_cs43xx_volume, | ||
1007 | .update_dac_mute = update_cs43xx_mute, | ||
1008 | .ac97_switch = xonar_line_mic_ac97_switch, | ||
1009 | .dac_tlv = cs4362a_db_scale, | ||
1010 | .model_data_size = sizeof(struct xonar_data), | ||
1011 | .device_config = PLAYBACK_0_TO_I2S | | ||
1012 | PLAYBACK_1_TO_SPDIF | | ||
1013 | CAPTURE_0_FROM_I2S_2, | ||
1014 | .dac_channels = 8, | ||
1015 | .dac_volume_min = 127 - 60, | ||
1016 | .dac_volume_max = 127, | ||
1017 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
1018 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1019 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1020 | }; | ||
1021 | |||
1022 | static const struct oxygen_model model_xonar_hdav = { | ||
1023 | .longname = "Asus Virtuoso 200", | ||
1024 | .chip = "AV200", | ||
1025 | .init = xonar_hdav_init, | ||
1026 | .cleanup = xonar_hdav_cleanup, | ||
1027 | .suspend = xonar_hdav_suspend, | ||
1028 | .resume = xonar_hdav_resume, | ||
1029 | .pcm_hardware_filter = xonar_hdav_pcm_hardware_filter, | ||
1030 | .set_dac_params = set_hdav_params, | ||
1031 | .set_adc_params = set_cs53x1_params, | ||
1032 | .update_dac_volume = update_pcm1796_volume, | ||
1033 | .update_dac_mute = update_pcm1796_mute, | ||
1034 | .uart_input = xonar_hdav_uart_input, | ||
1035 | .ac97_switch = xonar_line_mic_ac97_switch, | ||
1036 | .dac_tlv = pcm1796_db_scale, | ||
1037 | .model_data_size = sizeof(struct xonar_data), | ||
1038 | .device_config = PLAYBACK_0_TO_I2S | | ||
1039 | PLAYBACK_1_TO_SPDIF | | ||
1040 | CAPTURE_0_FROM_I2S_2 | | ||
1041 | CAPTURE_1_FROM_SPDIF, | ||
1042 | .dac_channels = 8, | ||
1043 | .dac_volume_min = 255 - 2*60, | ||
1044 | .dac_volume_max = 255, | ||
1045 | .misc_flags = OXYGEN_MISC_MIDI, | ||
1046 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
1047 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1048 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1049 | }; | ||
1050 | |||
1051 | static const struct oxygen_model model_xonar_st = { | ||
1052 | .longname = "Asus Virtuoso 100", | ||
1053 | .chip = "AV200", | ||
1054 | .init = xonar_st_init, | ||
1055 | .control_filter = xonar_st_control_filter, | ||
1056 | .mixer_init = xonar_st_mixer_init, | ||
1057 | .cleanup = xonar_st_cleanup, | ||
1058 | .suspend = xonar_st_suspend, | ||
1059 | .resume = xonar_st_resume, | ||
1060 | .set_dac_params = set_pcm1796_params, | ||
1061 | .set_adc_params = set_cs53x1_params, | ||
1062 | .update_dac_volume = update_pcm1796_volume, | ||
1063 | .update_dac_mute = update_pcm1796_mute, | ||
1064 | .ac97_switch = xonar_line_mic_ac97_switch, | ||
1065 | .dac_tlv = pcm1796_db_scale, | ||
1066 | .model_data_size = sizeof(struct xonar_data), | ||
1067 | .device_config = PLAYBACK_0_TO_I2S | | ||
1068 | PLAYBACK_1_TO_SPDIF | | ||
1069 | CAPTURE_0_FROM_I2S_2, | ||
1070 | .dac_channels = 2, | ||
1071 | .dac_volume_min = 255 - 2*60, | ||
1072 | .dac_volume_max = 255, | ||
1073 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
1074 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1075 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1076 | }; | ||
1077 | |||
1078 | static int __devinit get_xonar_model(struct oxygen *chip, | 57 | static int __devinit get_xonar_model(struct oxygen *chip, |
1079 | const struct pci_device_id *id) | 58 | const struct pci_device_id *id) |
1080 | { | 59 | { |
1081 | static const struct oxygen_model *const models[] = { | 60 | if (get_xonar_pcm179x_model(chip, id) >= 0) |
1082 | [MODEL_D1] = &model_xonar_d1, | 61 | return 0; |
1083 | [MODEL_DX] = &model_xonar_d1, | 62 | if (get_xonar_cs43xx_model(chip, id) >= 0) |
1084 | [MODEL_D2] = &model_xonar_d2, | 63 | return 0; |
1085 | [MODEL_D2X] = &model_xonar_d2, | 64 | return -EINVAL; |
1086 | [MODEL_HDAV] = &model_xonar_hdav, | ||
1087 | [MODEL_ST] = &model_xonar_st, | ||
1088 | [MODEL_STX] = &model_xonar_st, | ||
1089 | }; | ||
1090 | static const char *const names[] = { | ||
1091 | [MODEL_D1] = "Xonar D1", | ||
1092 | [MODEL_DX] = "Xonar DX", | ||
1093 | [MODEL_D2] = "Xonar D2", | ||
1094 | [MODEL_D2X] = "Xonar D2X", | ||
1095 | [MODEL_HDAV] = "Xonar HDAV1.3", | ||
1096 | [MODEL_HDAV_H6] = "Xonar HDAV1.3+H6", | ||
1097 | [MODEL_ST] = "Xonar Essence ST", | ||
1098 | [MODEL_ST_H6] = "Xonar Essence ST+H6", | ||
1099 | [MODEL_STX] = "Xonar Essence STX", | ||
1100 | }; | ||
1101 | unsigned int model = id->driver_data; | ||
1102 | |||
1103 | if (model >= ARRAY_SIZE(models) || !models[model]) | ||
1104 | return -EINVAL; | ||
1105 | chip->model = *models[model]; | ||
1106 | |||
1107 | switch (model) { | ||
1108 | case MODEL_D2X: | ||
1109 | chip->model.init = xonar_d2x_init; | ||
1110 | break; | ||
1111 | case MODEL_DX: | ||
1112 | chip->model.init = xonar_dx_init; | ||
1113 | break; | ||
1114 | case MODEL_HDAV: | ||
1115 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); | ||
1116 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { | ||
1117 | case GPIO_DB_H6: | ||
1118 | model = MODEL_HDAV_H6; | ||
1119 | break; | ||
1120 | case GPIO_DB_XX: | ||
1121 | snd_printk(KERN_ERR "unknown daughterboard\n"); | ||
1122 | return -ENODEV; | ||
1123 | } | ||
1124 | break; | ||
1125 | case MODEL_ST: | ||
1126 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); | ||
1127 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { | ||
1128 | case GPIO_DB_H6: | ||
1129 | model = MODEL_ST_H6; | ||
1130 | break; | ||
1131 | } | ||
1132 | break; | ||
1133 | case MODEL_STX: | ||
1134 | chip->model.init = xonar_stx_init; | ||
1135 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); | ||
1136 | break; | ||
1137 | } | ||
1138 | |||
1139 | chip->model.shortname = names[model]; | ||
1140 | chip->model.private_data = model; | ||
1141 | return 0; | ||
1142 | } | 65 | } |
1143 | 66 | ||
1144 | static int __devinit xonar_probe(struct pci_dev *pci, | 67 | static int __devinit xonar_probe(struct pci_dev *pci, |
diff --git a/sound/pci/oxygen/xonar.h b/sound/pci/oxygen/xonar.h new file mode 100644 index 000000000000..89b3ed814d64 --- /dev/null +++ b/sound/pci/oxygen/xonar.h | |||
@@ -0,0 +1,50 @@ | |||
1 | #ifndef XONAR_H_INCLUDED | ||
2 | #define XONAR_H_INCLUDED | ||
3 | |||
4 | #include "oxygen.h" | ||
5 | |||
6 | struct xonar_generic { | ||
7 | unsigned int anti_pop_delay; | ||
8 | u16 output_enable_bit; | ||
9 | u8 ext_power_reg; | ||
10 | u8 ext_power_int_reg; | ||
11 | u8 ext_power_bit; | ||
12 | u8 has_power; | ||
13 | }; | ||
14 | |||
15 | struct xonar_hdmi { | ||
16 | u8 params[5]; | ||
17 | }; | ||
18 | |||
19 | /* generic helper functions */ | ||
20 | |||
21 | void xonar_enable_output(struct oxygen *chip); | ||
22 | void xonar_disable_output(struct oxygen *chip); | ||
23 | void xonar_init_ext_power(struct oxygen *chip); | ||
24 | void xonar_init_cs53x1(struct oxygen *chip); | ||
25 | void xonar_set_cs53x1_params(struct oxygen *chip, | ||
26 | struct snd_pcm_hw_params *params); | ||
27 | int xonar_gpio_bit_switch_get(struct snd_kcontrol *ctl, | ||
28 | struct snd_ctl_elem_value *value); | ||
29 | int xonar_gpio_bit_switch_put(struct snd_kcontrol *ctl, | ||
30 | struct snd_ctl_elem_value *value); | ||
31 | |||
32 | /* model-specific card drivers */ | ||
33 | |||
34 | int get_xonar_pcm179x_model(struct oxygen *chip, | ||
35 | const struct pci_device_id *id); | ||
36 | int get_xonar_cs43xx_model(struct oxygen *chip, | ||
37 | const struct pci_device_id *id); | ||
38 | |||
39 | /* HDMI helper functions */ | ||
40 | |||
41 | void xonar_hdmi_init(struct oxygen *chip, struct xonar_hdmi *data); | ||
42 | void xonar_hdmi_cleanup(struct oxygen *chip); | ||
43 | void xonar_hdmi_resume(struct oxygen *chip, struct xonar_hdmi *hdmi); | ||
44 | void xonar_hdmi_pcm_hardware_filter(unsigned int channel, | ||
45 | struct snd_pcm_hardware *hardware); | ||
46 | void xonar_set_hdmi_params(struct oxygen *chip, struct xonar_hdmi *hdmi, | ||
47 | struct snd_pcm_hw_params *params); | ||
48 | void xonar_hdmi_uart_input(struct oxygen *chip); | ||
49 | |||
50 | #endif | ||
diff --git a/sound/pci/oxygen/xonar_cs43xx.c b/sound/pci/oxygen/xonar_cs43xx.c new file mode 100644 index 000000000000..16c226bfcd2b --- /dev/null +++ b/sound/pci/oxygen/xonar_cs43xx.c | |||
@@ -0,0 +1,434 @@ | |||
1 | /* | ||
2 | * card driver for models with CS4398/CS4362A DACs (Xonar D1/DX) | ||
3 | * | ||
4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
5 | * | ||
6 | * | ||
7 | * This driver is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, version 2. | ||
9 | * | ||
10 | * This driver is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this driver; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /* | ||
20 | * Xonar D1/DX | ||
21 | * ----------- | ||
22 | * | ||
23 | * CMI8788: | ||
24 | * | ||
25 | * I²C <-> CS4398 (front) | ||
26 | * <-> CS4362A (surround, center/LFE, back) | ||
27 | * | ||
28 | * GPI 0 <- external power present (DX only) | ||
29 | * | ||
30 | * GPIO 0 -> enable output to speakers | ||
31 | * GPIO 1 -> enable front panel I/O | ||
32 | * GPIO 2 -> M0 of CS5361 | ||
33 | * GPIO 3 -> M1 of CS5361 | ||
34 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
35 | * | ||
36 | * CS4398: | ||
37 | * | ||
38 | * AD0 <- 1 | ||
39 | * AD1 <- 1 | ||
40 | * | ||
41 | * CS4362A: | ||
42 | * | ||
43 | * AD0 <- 0 | ||
44 | * | ||
45 | * CM9780: | ||
46 | * | ||
47 | * GPO 0 -> route line-in (0) or AC97 output (1) to CS5361 input | ||
48 | */ | ||
49 | |||
50 | #include <linux/pci.h> | ||
51 | #include <linux/delay.h> | ||
52 | #include <sound/ac97_codec.h> | ||
53 | #include <sound/control.h> | ||
54 | #include <sound/core.h> | ||
55 | #include <sound/pcm.h> | ||
56 | #include <sound/pcm_params.h> | ||
57 | #include <sound/tlv.h> | ||
58 | #include "xonar.h" | ||
59 | #include "cs4398.h" | ||
60 | #include "cs4362a.h" | ||
61 | |||
62 | #define GPI_EXT_POWER 0x01 | ||
63 | #define GPIO_D1_OUTPUT_ENABLE 0x0001 | ||
64 | #define GPIO_D1_FRONT_PANEL 0x0002 | ||
65 | #define GPIO_D1_INPUT_ROUTE 0x0100 | ||
66 | |||
67 | #define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */ | ||
68 | #define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */ | ||
69 | |||
70 | struct xonar_cs43xx { | ||
71 | struct xonar_generic generic; | ||
72 | u8 cs4398_regs[8]; | ||
73 | u8 cs4362a_regs[15]; | ||
74 | }; | ||
75 | |||
76 | static void cs4398_write(struct oxygen *chip, u8 reg, u8 value) | ||
77 | { | ||
78 | struct xonar_cs43xx *data = chip->model_data; | ||
79 | |||
80 | oxygen_write_i2c(chip, I2C_DEVICE_CS4398, reg, value); | ||
81 | if (reg < ARRAY_SIZE(data->cs4398_regs)) | ||
82 | data->cs4398_regs[reg] = value; | ||
83 | } | ||
84 | |||
85 | static void cs4398_write_cached(struct oxygen *chip, u8 reg, u8 value) | ||
86 | { | ||
87 | struct xonar_cs43xx *data = chip->model_data; | ||
88 | |||
89 | if (value != data->cs4398_regs[reg]) | ||
90 | cs4398_write(chip, reg, value); | ||
91 | } | ||
92 | |||
93 | static void cs4362a_write(struct oxygen *chip, u8 reg, u8 value) | ||
94 | { | ||
95 | struct xonar_cs43xx *data = chip->model_data; | ||
96 | |||
97 | oxygen_write_i2c(chip, I2C_DEVICE_CS4362A, reg, value); | ||
98 | if (reg < ARRAY_SIZE(data->cs4362a_regs)) | ||
99 | data->cs4362a_regs[reg] = value; | ||
100 | } | ||
101 | |||
102 | static void cs4362a_write_cached(struct oxygen *chip, u8 reg, u8 value) | ||
103 | { | ||
104 | struct xonar_cs43xx *data = chip->model_data; | ||
105 | |||
106 | if (value != data->cs4362a_regs[reg]) | ||
107 | cs4362a_write(chip, reg, value); | ||
108 | } | ||
109 | |||
110 | static void cs43xx_registers_init(struct oxygen *chip) | ||
111 | { | ||
112 | struct xonar_cs43xx *data = chip->model_data; | ||
113 | unsigned int i; | ||
114 | |||
115 | /* set CPEN (control port mode) and power down */ | ||
116 | cs4398_write(chip, 8, CS4398_CPEN | CS4398_PDN); | ||
117 | cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); | ||
118 | /* configure */ | ||
119 | cs4398_write(chip, 2, data->cs4398_regs[2]); | ||
120 | cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L); | ||
121 | cs4398_write(chip, 4, data->cs4398_regs[4]); | ||
122 | cs4398_write(chip, 5, data->cs4398_regs[5]); | ||
123 | cs4398_write(chip, 6, data->cs4398_regs[6]); | ||
124 | cs4398_write(chip, 7, data->cs4398_regs[7]); | ||
125 | cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST); | ||
126 | cs4362a_write(chip, 0x03, CS4362A_MUTEC_6 | CS4362A_AMUTE | | ||
127 | CS4362A_RMP_UP | CS4362A_ZERO_CROSS | CS4362A_SOFT_RAMP); | ||
128 | cs4362a_write(chip, 0x04, data->cs4362a_regs[0x04]); | ||
129 | cs4362a_write(chip, 0x05, 0); | ||
130 | for (i = 6; i <= 14; ++i) | ||
131 | cs4362a_write(chip, i, data->cs4362a_regs[i]); | ||
132 | /* clear power down */ | ||
133 | cs4398_write(chip, 8, CS4398_CPEN); | ||
134 | cs4362a_write(chip, 0x01, CS4362A_CPEN); | ||
135 | } | ||
136 | |||
137 | static void xonar_d1_init(struct oxygen *chip) | ||
138 | { | ||
139 | struct xonar_cs43xx *data = chip->model_data; | ||
140 | |||
141 | data->generic.anti_pop_delay = 800; | ||
142 | data->generic.output_enable_bit = GPIO_D1_OUTPUT_ENABLE; | ||
143 | data->cs4398_regs[2] = | ||
144 | CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST; | ||
145 | data->cs4398_regs[4] = CS4398_MUTEP_LOW | | ||
146 | CS4398_MUTE_B | CS4398_MUTE_A | CS4398_PAMUTE; | ||
147 | data->cs4398_regs[5] = 60 * 2; | ||
148 | data->cs4398_regs[6] = 60 * 2; | ||
149 | data->cs4398_regs[7] = CS4398_RMP_DN | CS4398_RMP_UP | | ||
150 | CS4398_ZERO_CROSS | CS4398_SOFT_RAMP; | ||
151 | data->cs4362a_regs[4] = CS4362A_RMP_DN | CS4362A_DEM_NONE; | ||
152 | data->cs4362a_regs[6] = CS4362A_FM_SINGLE | | ||
153 | CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; | ||
154 | data->cs4362a_regs[7] = 60 | CS4362A_MUTE; | ||
155 | data->cs4362a_regs[8] = 60 | CS4362A_MUTE; | ||
156 | data->cs4362a_regs[9] = data->cs4362a_regs[6]; | ||
157 | data->cs4362a_regs[10] = 60 | CS4362A_MUTE; | ||
158 | data->cs4362a_regs[11] = 60 | CS4362A_MUTE; | ||
159 | data->cs4362a_regs[12] = data->cs4362a_regs[6]; | ||
160 | data->cs4362a_regs[13] = 60 | CS4362A_MUTE; | ||
161 | data->cs4362a_regs[14] = 60 | CS4362A_MUTE; | ||
162 | |||
163 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
164 | OXYGEN_2WIRE_LENGTH_8 | | ||
165 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
166 | OXYGEN_2WIRE_SPEED_FAST); | ||
167 | |||
168 | cs43xx_registers_init(chip); | ||
169 | |||
170 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, | ||
171 | GPIO_D1_FRONT_PANEL | GPIO_D1_INPUT_ROUTE); | ||
172 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, | ||
173 | GPIO_D1_FRONT_PANEL | GPIO_D1_INPUT_ROUTE); | ||
174 | |||
175 | xonar_init_cs53x1(chip); | ||
176 | xonar_enable_output(chip); | ||
177 | |||
178 | snd_component_add(chip->card, "CS4398"); | ||
179 | snd_component_add(chip->card, "CS4362A"); | ||
180 | snd_component_add(chip->card, "CS5361"); | ||
181 | } | ||
182 | |||
183 | static void xonar_dx_init(struct oxygen *chip) | ||
184 | { | ||
185 | struct xonar_cs43xx *data = chip->model_data; | ||
186 | |||
187 | data->generic.ext_power_reg = OXYGEN_GPI_DATA; | ||
188 | data->generic.ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
189 | data->generic.ext_power_bit = GPI_EXT_POWER; | ||
190 | xonar_init_ext_power(chip); | ||
191 | xonar_d1_init(chip); | ||
192 | } | ||
193 | |||
194 | static void xonar_d1_cleanup(struct oxygen *chip) | ||
195 | { | ||
196 | xonar_disable_output(chip); | ||
197 | cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); | ||
198 | oxygen_clear_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); | ||
199 | } | ||
200 | |||
201 | static void xonar_d1_suspend(struct oxygen *chip) | ||
202 | { | ||
203 | xonar_d1_cleanup(chip); | ||
204 | } | ||
205 | |||
206 | static void xonar_d1_resume(struct oxygen *chip) | ||
207 | { | ||
208 | oxygen_set_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); | ||
209 | msleep(1); | ||
210 | cs43xx_registers_init(chip); | ||
211 | xonar_enable_output(chip); | ||
212 | } | ||
213 | |||
214 | static void set_cs43xx_params(struct oxygen *chip, | ||
215 | struct snd_pcm_hw_params *params) | ||
216 | { | ||
217 | struct xonar_cs43xx *data = chip->model_data; | ||
218 | u8 cs4398_fm, cs4362a_fm; | ||
219 | |||
220 | if (params_rate(params) <= 50000) { | ||
221 | cs4398_fm = CS4398_FM_SINGLE; | ||
222 | cs4362a_fm = CS4362A_FM_SINGLE; | ||
223 | } else if (params_rate(params) <= 100000) { | ||
224 | cs4398_fm = CS4398_FM_DOUBLE; | ||
225 | cs4362a_fm = CS4362A_FM_DOUBLE; | ||
226 | } else { | ||
227 | cs4398_fm = CS4398_FM_QUAD; | ||
228 | cs4362a_fm = CS4362A_FM_QUAD; | ||
229 | } | ||
230 | cs4398_fm |= CS4398_DEM_NONE | CS4398_DIF_LJUST; | ||
231 | cs4398_write_cached(chip, 2, cs4398_fm); | ||
232 | cs4362a_fm |= data->cs4362a_regs[6] & ~CS4362A_FM_MASK; | ||
233 | cs4362a_write_cached(chip, 6, cs4362a_fm); | ||
234 | cs4362a_write_cached(chip, 12, cs4362a_fm); | ||
235 | cs4362a_fm &= CS4362A_FM_MASK; | ||
236 | cs4362a_fm |= data->cs4362a_regs[9] & ~CS4362A_FM_MASK; | ||
237 | cs4362a_write_cached(chip, 9, cs4362a_fm); | ||
238 | } | ||
239 | |||
240 | static void update_cs4362a_volumes(struct oxygen *chip) | ||
241 | { | ||
242 | unsigned int i; | ||
243 | u8 mute; | ||
244 | |||
245 | mute = chip->dac_mute ? CS4362A_MUTE : 0; | ||
246 | for (i = 0; i < 6; ++i) | ||
247 | cs4362a_write_cached(chip, 7 + i + i / 2, | ||
248 | (127 - chip->dac_volume[2 + i]) | mute); | ||
249 | } | ||
250 | |||
251 | static void update_cs43xx_volume(struct oxygen *chip) | ||
252 | { | ||
253 | cs4398_write_cached(chip, 5, (127 - chip->dac_volume[0]) * 2); | ||
254 | cs4398_write_cached(chip, 6, (127 - chip->dac_volume[1]) * 2); | ||
255 | update_cs4362a_volumes(chip); | ||
256 | } | ||
257 | |||
258 | static void update_cs43xx_mute(struct oxygen *chip) | ||
259 | { | ||
260 | u8 reg; | ||
261 | |||
262 | reg = CS4398_MUTEP_LOW | CS4398_PAMUTE; | ||
263 | if (chip->dac_mute) | ||
264 | reg |= CS4398_MUTE_B | CS4398_MUTE_A; | ||
265 | cs4398_write_cached(chip, 4, reg); | ||
266 | update_cs4362a_volumes(chip); | ||
267 | } | ||
268 | |||
269 | static void update_cs43xx_center_lfe_mix(struct oxygen *chip, bool mixed) | ||
270 | { | ||
271 | struct xonar_cs43xx *data = chip->model_data; | ||
272 | u8 reg; | ||
273 | |||
274 | reg = data->cs4362a_regs[9] & ~CS4362A_ATAPI_MASK; | ||
275 | if (mixed) | ||
276 | reg |= CS4362A_ATAPI_B_LR | CS4362A_ATAPI_A_LR; | ||
277 | else | ||
278 | reg |= CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; | ||
279 | cs4362a_write_cached(chip, 9, reg); | ||
280 | } | ||
281 | |||
282 | static const struct snd_kcontrol_new front_panel_switch = { | ||
283 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
284 | .name = "Front Panel Switch", | ||
285 | .info = snd_ctl_boolean_mono_info, | ||
286 | .get = xonar_gpio_bit_switch_get, | ||
287 | .put = xonar_gpio_bit_switch_put, | ||
288 | .private_value = GPIO_D1_FRONT_PANEL, | ||
289 | }; | ||
290 | |||
291 | static int rolloff_info(struct snd_kcontrol *ctl, | ||
292 | struct snd_ctl_elem_info *info) | ||
293 | { | ||
294 | static const char *const names[2] = { | ||
295 | "Fast Roll-off", "Slow Roll-off" | ||
296 | }; | ||
297 | |||
298 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
299 | info->count = 1; | ||
300 | info->value.enumerated.items = 2; | ||
301 | if (info->value.enumerated.item >= 2) | ||
302 | info->value.enumerated.item = 1; | ||
303 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static int rolloff_get(struct snd_kcontrol *ctl, | ||
308 | struct snd_ctl_elem_value *value) | ||
309 | { | ||
310 | struct oxygen *chip = ctl->private_data; | ||
311 | struct xonar_cs43xx *data = chip->model_data; | ||
312 | |||
313 | value->value.enumerated.item[0] = | ||
314 | (data->cs4398_regs[7] & CS4398_FILT_SEL) != 0; | ||
315 | return 0; | ||
316 | } | ||
317 | |||
318 | static int rolloff_put(struct snd_kcontrol *ctl, | ||
319 | struct snd_ctl_elem_value *value) | ||
320 | { | ||
321 | struct oxygen *chip = ctl->private_data; | ||
322 | struct xonar_cs43xx *data = chip->model_data; | ||
323 | int changed; | ||
324 | u8 reg; | ||
325 | |||
326 | mutex_lock(&chip->mutex); | ||
327 | reg = data->cs4398_regs[7]; | ||
328 | if (value->value.enumerated.item[0]) | ||
329 | reg |= CS4398_FILT_SEL; | ||
330 | else | ||
331 | reg &= ~CS4398_FILT_SEL; | ||
332 | changed = reg != data->cs4398_regs[7]; | ||
333 | if (changed) { | ||
334 | cs4398_write(chip, 7, reg); | ||
335 | if (reg & CS4398_FILT_SEL) | ||
336 | reg = data->cs4362a_regs[0x04] | CS4362A_FILT_SEL; | ||
337 | else | ||
338 | reg = data->cs4362a_regs[0x04] & ~CS4362A_FILT_SEL; | ||
339 | cs4362a_write(chip, 0x04, reg); | ||
340 | } | ||
341 | mutex_unlock(&chip->mutex); | ||
342 | return changed; | ||
343 | } | ||
344 | |||
345 | static const struct snd_kcontrol_new rolloff_control = { | ||
346 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
347 | .name = "DAC Filter Playback Enum", | ||
348 | .info = rolloff_info, | ||
349 | .get = rolloff_get, | ||
350 | .put = rolloff_put, | ||
351 | }; | ||
352 | |||
353 | static void xonar_d1_line_mic_ac97_switch(struct oxygen *chip, | ||
354 | unsigned int reg, unsigned int mute) | ||
355 | { | ||
356 | if (reg == AC97_LINE) { | ||
357 | spin_lock_irq(&chip->reg_lock); | ||
358 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
359 | mute ? GPIO_D1_INPUT_ROUTE : 0, | ||
360 | GPIO_D1_INPUT_ROUTE); | ||
361 | spin_unlock_irq(&chip->reg_lock); | ||
362 | } | ||
363 | } | ||
364 | |||
365 | static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -6000, 100, 0); | ||
366 | |||
367 | static int xonar_d1_control_filter(struct snd_kcontrol_new *template) | ||
368 | { | ||
369 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
370 | return 1; /* no CD input */ | ||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | static int xonar_d1_mixer_init(struct oxygen *chip) | ||
375 | { | ||
376 | int err; | ||
377 | |||
378 | err = snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip)); | ||
379 | if (err < 0) | ||
380 | return err; | ||
381 | err = snd_ctl_add(chip->card, snd_ctl_new1(&rolloff_control, chip)); | ||
382 | if (err < 0) | ||
383 | return err; | ||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static const struct oxygen_model model_xonar_d1 = { | ||
388 | .longname = "Asus Virtuoso 100", | ||
389 | .chip = "AV200", | ||
390 | .init = xonar_d1_init, | ||
391 | .control_filter = xonar_d1_control_filter, | ||
392 | .mixer_init = xonar_d1_mixer_init, | ||
393 | .cleanup = xonar_d1_cleanup, | ||
394 | .suspend = xonar_d1_suspend, | ||
395 | .resume = xonar_d1_resume, | ||
396 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
397 | .set_dac_params = set_cs43xx_params, | ||
398 | .set_adc_params = xonar_set_cs53x1_params, | ||
399 | .update_dac_volume = update_cs43xx_volume, | ||
400 | .update_dac_mute = update_cs43xx_mute, | ||
401 | .update_center_lfe_mix = update_cs43xx_center_lfe_mix, | ||
402 | .ac97_switch = xonar_d1_line_mic_ac97_switch, | ||
403 | .dac_tlv = cs4362a_db_scale, | ||
404 | .model_data_size = sizeof(struct xonar_cs43xx), | ||
405 | .device_config = PLAYBACK_0_TO_I2S | | ||
406 | PLAYBACK_1_TO_SPDIF | | ||
407 | CAPTURE_0_FROM_I2S_2, | ||
408 | .dac_channels = 8, | ||
409 | .dac_volume_min = 127 - 60, | ||
410 | .dac_volume_max = 127, | ||
411 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
412 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
413 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
414 | }; | ||
415 | |||
416 | int __devinit get_xonar_cs43xx_model(struct oxygen *chip, | ||
417 | const struct pci_device_id *id) | ||
418 | { | ||
419 | switch (id->subdevice) { | ||
420 | case 0x834f: | ||
421 | chip->model = model_xonar_d1; | ||
422 | chip->model.shortname = "Xonar D1"; | ||
423 | break; | ||
424 | case 0x8275: | ||
425 | case 0x8327: | ||
426 | chip->model = model_xonar_d1; | ||
427 | chip->model.shortname = "Xonar DX"; | ||
428 | chip->model.init = xonar_dx_init; | ||
429 | break; | ||
430 | default: | ||
431 | return -EINVAL; | ||
432 | } | ||
433 | return 0; | ||
434 | } | ||
diff --git a/sound/pci/oxygen/xonar_hdmi.c b/sound/pci/oxygen/xonar_hdmi.c new file mode 100644 index 000000000000..b12db1f1cea9 --- /dev/null +++ b/sound/pci/oxygen/xonar_hdmi.c | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * helper functions for HDMI models (Xonar HDAV1.3) | ||
3 | * | ||
4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
5 | * | ||
6 | * | ||
7 | * This driver is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, version 2. | ||
9 | * | ||
10 | * This driver is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this driver; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <linux/pci.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <sound/asoundef.h> | ||
22 | #include <sound/control.h> | ||
23 | #include <sound/core.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/pcm_params.h> | ||
26 | #include <sound/tlv.h> | ||
27 | #include "xonar.h" | ||
28 | |||
29 | static void hdmi_write_command(struct oxygen *chip, u8 command, | ||
30 | unsigned int count, const u8 *params) | ||
31 | { | ||
32 | unsigned int i; | ||
33 | u8 checksum; | ||
34 | |||
35 | oxygen_write_uart(chip, 0xfb); | ||
36 | oxygen_write_uart(chip, 0xef); | ||
37 | oxygen_write_uart(chip, command); | ||
38 | oxygen_write_uart(chip, count); | ||
39 | for (i = 0; i < count; ++i) | ||
40 | oxygen_write_uart(chip, params[i]); | ||
41 | checksum = 0xfb + 0xef + command + count; | ||
42 | for (i = 0; i < count; ++i) | ||
43 | checksum += params[i]; | ||
44 | oxygen_write_uart(chip, checksum); | ||
45 | } | ||
46 | |||
47 | static void xonar_hdmi_init_commands(struct oxygen *chip, | ||
48 | struct xonar_hdmi *hdmi) | ||
49 | { | ||
50 | u8 param; | ||
51 | |||
52 | oxygen_reset_uart(chip); | ||
53 | param = 0; | ||
54 | hdmi_write_command(chip, 0x61, 1, ¶m); | ||
55 | param = 1; | ||
56 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
57 | hdmi_write_command(chip, 0x54, 5, hdmi->params); | ||
58 | } | ||
59 | |||
60 | void xonar_hdmi_init(struct oxygen *chip, struct xonar_hdmi *hdmi) | ||
61 | { | ||
62 | hdmi->params[1] = IEC958_AES3_CON_FS_48000; | ||
63 | hdmi->params[4] = 1; | ||
64 | xonar_hdmi_init_commands(chip, hdmi); | ||
65 | } | ||
66 | |||
67 | void xonar_hdmi_cleanup(struct oxygen *chip) | ||
68 | { | ||
69 | u8 param = 0; | ||
70 | |||
71 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
72 | } | ||
73 | |||
74 | void xonar_hdmi_resume(struct oxygen *chip, struct xonar_hdmi *hdmi) | ||
75 | { | ||
76 | xonar_hdmi_init_commands(chip, hdmi); | ||
77 | } | ||
78 | |||
79 | void xonar_hdmi_pcm_hardware_filter(unsigned int channel, | ||
80 | struct snd_pcm_hardware *hardware) | ||
81 | { | ||
82 | if (channel == PCM_MULTICH) { | ||
83 | hardware->rates = SNDRV_PCM_RATE_44100 | | ||
84 | SNDRV_PCM_RATE_48000 | | ||
85 | SNDRV_PCM_RATE_96000 | | ||
86 | SNDRV_PCM_RATE_192000; | ||
87 | hardware->rate_min = 44100; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void xonar_set_hdmi_params(struct oxygen *chip, struct xonar_hdmi *hdmi, | ||
92 | struct snd_pcm_hw_params *params) | ||
93 | { | ||
94 | hdmi->params[0] = 0; /* 1 = non-audio */ | ||
95 | switch (params_rate(params)) { | ||
96 | case 44100: | ||
97 | hdmi->params[1] = IEC958_AES3_CON_FS_44100; | ||
98 | break; | ||
99 | case 48000: | ||
100 | hdmi->params[1] = IEC958_AES3_CON_FS_48000; | ||
101 | break; | ||
102 | default: /* 96000 */ | ||
103 | hdmi->params[1] = IEC958_AES3_CON_FS_96000; | ||
104 | break; | ||
105 | case 192000: | ||
106 | hdmi->params[1] = IEC958_AES3_CON_FS_192000; | ||
107 | break; | ||
108 | } | ||
109 | hdmi->params[2] = params_channels(params) / 2 - 1; | ||
110 | if (params_format(params) == SNDRV_PCM_FORMAT_S16_LE) | ||
111 | hdmi->params[3] = 0; | ||
112 | else | ||
113 | hdmi->params[3] = 0xc0; | ||
114 | hdmi->params[4] = 1; /* ? */ | ||
115 | hdmi_write_command(chip, 0x54, 5, hdmi->params); | ||
116 | } | ||
117 | |||
118 | void xonar_hdmi_uart_input(struct oxygen *chip) | ||
119 | { | ||
120 | if (chip->uart_input_count >= 2 && | ||
121 | chip->uart_input[chip->uart_input_count - 2] == 'O' && | ||
122 | chip->uart_input[chip->uart_input_count - 1] == 'K') { | ||
123 | printk(KERN_DEBUG "message from HDMI chip received:\n"); | ||
124 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, | ||
125 | chip->uart_input, chip->uart_input_count); | ||
126 | chip->uart_input_count = 0; | ||
127 | } | ||
128 | } | ||
diff --git a/sound/pci/oxygen/xonar_lib.c b/sound/pci/oxygen/xonar_lib.c new file mode 100644 index 000000000000..b3ff71316653 --- /dev/null +++ b/sound/pci/oxygen/xonar_lib.c | |||
@@ -0,0 +1,132 @@ | |||
1 | /* | ||
2 | * helper functions for Asus Xonar cards | ||
3 | * | ||
4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
5 | * | ||
6 | * | ||
7 | * This driver is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, version 2. | ||
9 | * | ||
10 | * This driver is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this driver; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <linux/delay.h> | ||
20 | #include <sound/core.h> | ||
21 | #include <sound/control.h> | ||
22 | #include <sound/pcm.h> | ||
23 | #include <sound/pcm_params.h> | ||
24 | #include "xonar.h" | ||
25 | |||
26 | |||
27 | #define GPIO_CS53x1_M_MASK 0x000c | ||
28 | #define GPIO_CS53x1_M_SINGLE 0x0000 | ||
29 | #define GPIO_CS53x1_M_DOUBLE 0x0004 | ||
30 | #define GPIO_CS53x1_M_QUAD 0x0008 | ||
31 | |||
32 | |||
33 | void xonar_enable_output(struct oxygen *chip) | ||
34 | { | ||
35 | struct xonar_generic *data = chip->model_data; | ||
36 | |||
37 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, data->output_enable_bit); | ||
38 | msleep(data->anti_pop_delay); | ||
39 | oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); | ||
40 | } | ||
41 | |||
42 | void xonar_disable_output(struct oxygen *chip) | ||
43 | { | ||
44 | struct xonar_generic *data = chip->model_data; | ||
45 | |||
46 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); | ||
47 | } | ||
48 | |||
49 | static void xonar_ext_power_gpio_changed(struct oxygen *chip) | ||
50 | { | ||
51 | struct xonar_generic *data = chip->model_data; | ||
52 | u8 has_power; | ||
53 | |||
54 | has_power = !!(oxygen_read8(chip, data->ext_power_reg) | ||
55 | & data->ext_power_bit); | ||
56 | if (has_power != data->has_power) { | ||
57 | data->has_power = has_power; | ||
58 | if (has_power) { | ||
59 | snd_printk(KERN_NOTICE "power restored\n"); | ||
60 | } else { | ||
61 | snd_printk(KERN_CRIT | ||
62 | "Hey! Don't unplug the power cable!\n"); | ||
63 | /* TODO: stop PCMs */ | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
68 | void xonar_init_ext_power(struct oxygen *chip) | ||
69 | { | ||
70 | struct xonar_generic *data = chip->model_data; | ||
71 | |||
72 | oxygen_set_bits8(chip, data->ext_power_int_reg, | ||
73 | data->ext_power_bit); | ||
74 | chip->interrupt_mask |= OXYGEN_INT_GPIO; | ||
75 | chip->model.gpio_changed = xonar_ext_power_gpio_changed; | ||
76 | data->has_power = !!(oxygen_read8(chip, data->ext_power_reg) | ||
77 | & data->ext_power_bit); | ||
78 | } | ||
79 | |||
80 | void xonar_init_cs53x1(struct oxygen *chip) | ||
81 | { | ||
82 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_CS53x1_M_MASK); | ||
83 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
84 | GPIO_CS53x1_M_SINGLE, GPIO_CS53x1_M_MASK); | ||
85 | } | ||
86 | |||
87 | void xonar_set_cs53x1_params(struct oxygen *chip, | ||
88 | struct snd_pcm_hw_params *params) | ||
89 | { | ||
90 | unsigned int value; | ||
91 | |||
92 | if (params_rate(params) <= 54000) | ||
93 | value = GPIO_CS53x1_M_SINGLE; | ||
94 | else if (params_rate(params) <= 108000) | ||
95 | value = GPIO_CS53x1_M_DOUBLE; | ||
96 | else | ||
97 | value = GPIO_CS53x1_M_QUAD; | ||
98 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
99 | value, GPIO_CS53x1_M_MASK); | ||
100 | } | ||
101 | |||
102 | int xonar_gpio_bit_switch_get(struct snd_kcontrol *ctl, | ||
103 | struct snd_ctl_elem_value *value) | ||
104 | { | ||
105 | struct oxygen *chip = ctl->private_data; | ||
106 | u16 bit = ctl->private_value; | ||
107 | |||
108 | value->value.integer.value[0] = | ||
109 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & bit); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | int xonar_gpio_bit_switch_put(struct snd_kcontrol *ctl, | ||
114 | struct snd_ctl_elem_value *value) | ||
115 | { | ||
116 | struct oxygen *chip = ctl->private_data; | ||
117 | u16 bit = ctl->private_value; | ||
118 | u16 old_bits, new_bits; | ||
119 | int changed; | ||
120 | |||
121 | spin_lock_irq(&chip->reg_lock); | ||
122 | old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
123 | if (value->value.integer.value[0]) | ||
124 | new_bits = old_bits | bit; | ||
125 | else | ||
126 | new_bits = old_bits & ~bit; | ||
127 | changed = new_bits != old_bits; | ||
128 | if (changed) | ||
129 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); | ||
130 | spin_unlock_irq(&chip->reg_lock); | ||
131 | return changed; | ||
132 | } | ||
diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c new file mode 100644 index 000000000000..ba18fb546b4f --- /dev/null +++ b/sound/pci/oxygen/xonar_pcm179x.c | |||
@@ -0,0 +1,1115 @@ | |||
1 | /* | ||
2 | * card driver for models with PCM1796 DACs (Xonar D2/D2X/HDAV1.3/ST/STX) | ||
3 | * | ||
4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
5 | * | ||
6 | * | ||
7 | * This driver is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, version 2. | ||
9 | * | ||
10 | * This driver is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this driver; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /* | ||
20 | * Xonar D2/D2X | ||
21 | * ------------ | ||
22 | * | ||
23 | * CMI8788: | ||
24 | * | ||
25 | * SPI 0 -> 1st PCM1796 (front) | ||
26 | * SPI 1 -> 2nd PCM1796 (surround) | ||
27 | * SPI 2 -> 3rd PCM1796 (center/LFE) | ||
28 | * SPI 4 -> 4th PCM1796 (back) | ||
29 | * | ||
30 | * GPIO 2 -> M0 of CS5381 | ||
31 | * GPIO 3 -> M1 of CS5381 | ||
32 | * GPIO 5 <- external power present (D2X only) | ||
33 | * GPIO 7 -> ALT | ||
34 | * GPIO 8 -> enable output to speakers | ||
35 | * | ||
36 | * CM9780: | ||
37 | * | ||
38 | * GPO 0 -> route line-in (0) or AC97 output (1) to CS5381 input | ||
39 | */ | ||
40 | |||
41 | /* | ||
42 | * Xonar HDAV1.3 (Deluxe) | ||
43 | * ---------------------- | ||
44 | * | ||
45 | * CMI8788: | ||
46 | * | ||
47 | * I²C <-> PCM1796 (front) | ||
48 | * | ||
49 | * GPI 0 <- external power present | ||
50 | * | ||
51 | * GPIO 0 -> enable output to speakers | ||
52 | * GPIO 2 -> M0 of CS5381 | ||
53 | * GPIO 3 -> M1 of CS5381 | ||
54 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
55 | * | ||
56 | * TXD -> HDMI controller | ||
57 | * RXD <- HDMI controller | ||
58 | * | ||
59 | * PCM1796 front: AD1,0 <- 0,0 | ||
60 | * | ||
61 | * CM9780: | ||
62 | * | ||
63 | * GPO 0 -> route line-in (0) or AC97 output (1) to CS5381 input | ||
64 | * | ||
65 | * no daughterboard | ||
66 | * ---------------- | ||
67 | * | ||
68 | * GPIO 4 <- 1 | ||
69 | * | ||
70 | * H6 daughterboard | ||
71 | * ---------------- | ||
72 | * | ||
73 | * GPIO 4 <- 0 | ||
74 | * GPIO 5 <- 0 | ||
75 | * | ||
76 | * I²C <-> PCM1796 (surround) | ||
77 | * <-> PCM1796 (center/LFE) | ||
78 | * <-> PCM1796 (back) | ||
79 | * | ||
80 | * PCM1796 surround: AD1,0 <- 0,1 | ||
81 | * PCM1796 center/LFE: AD1,0 <- 1,0 | ||
82 | * PCM1796 back: AD1,0 <- 1,1 | ||
83 | * | ||
84 | * unknown daughterboard | ||
85 | * --------------------- | ||
86 | * | ||
87 | * GPIO 4 <- 0 | ||
88 | * GPIO 5 <- 1 | ||
89 | * | ||
90 | * I²C <-> CS4362A (surround, center/LFE, back) | ||
91 | * | ||
92 | * CS4362A: AD0 <- 0 | ||
93 | */ | ||
94 | |||
95 | /* | ||
96 | * Xonar Essence ST (Deluxe)/STX | ||
97 | * ----------------------------- | ||
98 | * | ||
99 | * CMI8788: | ||
100 | * | ||
101 | * I²C <-> PCM1792A | ||
102 | * <-> CS2000 (ST only) | ||
103 | * | ||
104 | * ADC1 MCLK -> REF_CLK of CS2000 (ST only) | ||
105 | * | ||
106 | * GPI 0 <- external power present (STX only) | ||
107 | * | ||
108 | * GPIO 0 -> enable output to speakers | ||
109 | * GPIO 1 -> route HP to front panel (0) or rear jack (1) | ||
110 | * GPIO 2 -> M0 of CS5381 | ||
111 | * GPIO 3 -> M1 of CS5381 | ||
112 | * GPIO 7 -> route output to speaker jacks (0) or HP (1) | ||
113 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
114 | * | ||
115 | * PCM1792A: | ||
116 | * | ||
117 | * AD1,0 <- 0,0 | ||
118 | * SCK <- CLK_OUT of CS2000 (ST only) | ||
119 | * | ||
120 | * CS2000: | ||
121 | * | ||
122 | * AD0 <- 0 | ||
123 | * | ||
124 | * CM9780: | ||
125 | * | ||
126 | * GPO 0 -> route line-in (0) or AC97 output (1) to CS5381 input | ||
127 | * | ||
128 | * H6 daughterboard | ||
129 | * ---------------- | ||
130 | * | ||
131 | * GPIO 4 <- 0 | ||
132 | * GPIO 5 <- 0 | ||
133 | */ | ||
134 | |||
135 | #include <linux/pci.h> | ||
136 | #include <linux/delay.h> | ||
137 | #include <linux/mutex.h> | ||
138 | #include <sound/ac97_codec.h> | ||
139 | #include <sound/control.h> | ||
140 | #include <sound/core.h> | ||
141 | #include <sound/pcm.h> | ||
142 | #include <sound/pcm_params.h> | ||
143 | #include <sound/tlv.h> | ||
144 | #include "xonar.h" | ||
145 | #include "cm9780.h" | ||
146 | #include "pcm1796.h" | ||
147 | #include "cs2000.h" | ||
148 | |||
149 | |||
150 | #define GPIO_D2X_EXT_POWER 0x0020 | ||
151 | #define GPIO_D2_ALT 0x0080 | ||
152 | #define GPIO_D2_OUTPUT_ENABLE 0x0100 | ||
153 | |||
154 | #define GPI_EXT_POWER 0x01 | ||
155 | #define GPIO_INPUT_ROUTE 0x0100 | ||
156 | |||
157 | #define GPIO_HDAV_OUTPUT_ENABLE 0x0001 | ||
158 | |||
159 | #define GPIO_DB_MASK 0x0030 | ||
160 | #define GPIO_DB_H6 0x0000 | ||
161 | |||
162 | #define GPIO_ST_OUTPUT_ENABLE 0x0001 | ||
163 | #define GPIO_ST_HP_REAR 0x0002 | ||
164 | #define GPIO_ST_HP 0x0080 | ||
165 | |||
166 | #define I2C_DEVICE_PCM1796(i) (0x98 + ((i) << 1)) /* 10011, ii, /W=0 */ | ||
167 | #define I2C_DEVICE_CS2000 0x9c /* 100111, 0, /W=0 */ | ||
168 | |||
169 | #define PCM1796_REG_BASE 16 | ||
170 | |||
171 | |||
172 | struct xonar_pcm179x { | ||
173 | struct xonar_generic generic; | ||
174 | unsigned int dacs; | ||
175 | u8 pcm1796_regs[4][5]; | ||
176 | unsigned int current_rate; | ||
177 | bool os_128; | ||
178 | bool hp_active; | ||
179 | s8 hp_gain_offset; | ||
180 | bool has_cs2000; | ||
181 | u8 cs2000_fun_cfg_1; | ||
182 | }; | ||
183 | |||
184 | struct xonar_hdav { | ||
185 | struct xonar_pcm179x pcm179x; | ||
186 | struct xonar_hdmi hdmi; | ||
187 | }; | ||
188 | |||
189 | |||
190 | static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec, | ||
191 | u8 reg, u8 value) | ||
192 | { | ||
193 | /* maps ALSA channel pair number to SPI output */ | ||
194 | static const u8 codec_map[4] = { | ||
195 | 0, 1, 2, 4 | ||
196 | }; | ||
197 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | | ||
198 | OXYGEN_SPI_DATA_LENGTH_2 | | ||
199 | OXYGEN_SPI_CLOCK_160 | | ||
200 | (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | | ||
201 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, | ||
202 | (reg << 8) | value); | ||
203 | } | ||
204 | |||
205 | static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec, | ||
206 | u8 reg, u8 value) | ||
207 | { | ||
208 | oxygen_write_i2c(chip, I2C_DEVICE_PCM1796(codec), reg, value); | ||
209 | } | ||
210 | |||
211 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, | ||
212 | u8 reg, u8 value) | ||
213 | { | ||
214 | struct xonar_pcm179x *data = chip->model_data; | ||
215 | |||
216 | if ((chip->model.function_flags & OXYGEN_FUNCTION_2WIRE_SPI_MASK) == | ||
217 | OXYGEN_FUNCTION_SPI) | ||
218 | pcm1796_write_spi(chip, codec, reg, value); | ||
219 | else | ||
220 | pcm1796_write_i2c(chip, codec, reg, value); | ||
221 | if ((unsigned int)(reg - PCM1796_REG_BASE) | ||
222 | < ARRAY_SIZE(data->pcm1796_regs[codec])) | ||
223 | data->pcm1796_regs[codec][reg - PCM1796_REG_BASE] = value; | ||
224 | } | ||
225 | |||
226 | static void pcm1796_write_cached(struct oxygen *chip, unsigned int codec, | ||
227 | u8 reg, u8 value) | ||
228 | { | ||
229 | struct xonar_pcm179x *data = chip->model_data; | ||
230 | |||
231 | if (value != data->pcm1796_regs[codec][reg - PCM1796_REG_BASE]) | ||
232 | pcm1796_write(chip, codec, reg, value); | ||
233 | } | ||
234 | |||
235 | static void cs2000_write(struct oxygen *chip, u8 reg, u8 value) | ||
236 | { | ||
237 | struct xonar_pcm179x *data = chip->model_data; | ||
238 | |||
239 | oxygen_write_i2c(chip, I2C_DEVICE_CS2000, reg, value); | ||
240 | if (reg == CS2000_FUN_CFG_1) | ||
241 | data->cs2000_fun_cfg_1 = value; | ||
242 | } | ||
243 | |||
244 | static void cs2000_write_cached(struct oxygen *chip, u8 reg, u8 value) | ||
245 | { | ||
246 | struct xonar_pcm179x *data = chip->model_data; | ||
247 | |||
248 | if (reg != CS2000_FUN_CFG_1 || | ||
249 | value != data->cs2000_fun_cfg_1) | ||
250 | cs2000_write(chip, reg, value); | ||
251 | } | ||
252 | |||
253 | static void pcm1796_registers_init(struct oxygen *chip) | ||
254 | { | ||
255 | struct xonar_pcm179x *data = chip->model_data; | ||
256 | unsigned int i; | ||
257 | s8 gain_offset; | ||
258 | |||
259 | gain_offset = data->hp_active ? data->hp_gain_offset : 0; | ||
260 | for (i = 0; i < data->dacs; ++i) { | ||
261 | /* set ATLD before ATL/ATR */ | ||
262 | pcm1796_write(chip, i, 18, | ||
263 | data->pcm1796_regs[0][18 - PCM1796_REG_BASE]); | ||
264 | pcm1796_write(chip, i, 16, chip->dac_volume[i * 2] | ||
265 | + gain_offset); | ||
266 | pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1] | ||
267 | + gain_offset); | ||
268 | pcm1796_write(chip, i, 19, | ||
269 | data->pcm1796_regs[0][19 - PCM1796_REG_BASE]); | ||
270 | pcm1796_write(chip, i, 20, | ||
271 | data->pcm1796_regs[0][20 - PCM1796_REG_BASE]); | ||
272 | pcm1796_write(chip, i, 21, 0); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | static void pcm1796_init(struct oxygen *chip) | ||
277 | { | ||
278 | struct xonar_pcm179x *data = chip->model_data; | ||
279 | |||
280 | data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = PCM1796_MUTE | | ||
281 | PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; | ||
282 | data->pcm1796_regs[0][19 - PCM1796_REG_BASE] = | ||
283 | PCM1796_FLT_SHARP | PCM1796_ATS_1; | ||
284 | data->pcm1796_regs[0][20 - PCM1796_REG_BASE] = PCM1796_OS_64; | ||
285 | pcm1796_registers_init(chip); | ||
286 | data->current_rate = 48000; | ||
287 | } | ||
288 | |||
289 | static void xonar_d2_init(struct oxygen *chip) | ||
290 | { | ||
291 | struct xonar_pcm179x *data = chip->model_data; | ||
292 | |||
293 | data->generic.anti_pop_delay = 300; | ||
294 | data->generic.output_enable_bit = GPIO_D2_OUTPUT_ENABLE; | ||
295 | data->dacs = 4; | ||
296 | |||
297 | pcm1796_init(chip); | ||
298 | |||
299 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT); | ||
300 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT); | ||
301 | |||
302 | oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); | ||
303 | |||
304 | xonar_init_cs53x1(chip); | ||
305 | xonar_enable_output(chip); | ||
306 | |||
307 | snd_component_add(chip->card, "PCM1796"); | ||
308 | snd_component_add(chip->card, "CS5381"); | ||
309 | } | ||
310 | |||
311 | static void xonar_d2x_init(struct oxygen *chip) | ||
312 | { | ||
313 | struct xonar_pcm179x *data = chip->model_data; | ||
314 | |||
315 | data->generic.ext_power_reg = OXYGEN_GPIO_DATA; | ||
316 | data->generic.ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK; | ||
317 | data->generic.ext_power_bit = GPIO_D2X_EXT_POWER; | ||
318 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER); | ||
319 | xonar_init_ext_power(chip); | ||
320 | xonar_d2_init(chip); | ||
321 | } | ||
322 | |||
323 | static void xonar_hdav_init(struct oxygen *chip) | ||
324 | { | ||
325 | struct xonar_hdav *data = chip->model_data; | ||
326 | |||
327 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
328 | OXYGEN_2WIRE_LENGTH_8 | | ||
329 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
330 | OXYGEN_2WIRE_SPEED_FAST); | ||
331 | |||
332 | data->pcm179x.generic.anti_pop_delay = 100; | ||
333 | data->pcm179x.generic.output_enable_bit = GPIO_HDAV_OUTPUT_ENABLE; | ||
334 | data->pcm179x.generic.ext_power_reg = OXYGEN_GPI_DATA; | ||
335 | data->pcm179x.generic.ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
336 | data->pcm179x.generic.ext_power_bit = GPI_EXT_POWER; | ||
337 | data->pcm179x.dacs = chip->model.private_data ? 4 : 1; | ||
338 | |||
339 | pcm1796_init(chip); | ||
340 | |||
341 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_INPUT_ROUTE); | ||
342 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_INPUT_ROUTE); | ||
343 | |||
344 | xonar_init_cs53x1(chip); | ||
345 | xonar_init_ext_power(chip); | ||
346 | xonar_hdmi_init(chip, &data->hdmi); | ||
347 | xonar_enable_output(chip); | ||
348 | |||
349 | snd_component_add(chip->card, "PCM1796"); | ||
350 | snd_component_add(chip->card, "CS5381"); | ||
351 | } | ||
352 | |||
353 | static void xonar_st_init_i2c(struct oxygen *chip) | ||
354 | { | ||
355 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
356 | OXYGEN_2WIRE_LENGTH_8 | | ||
357 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
358 | OXYGEN_2WIRE_SPEED_FAST); | ||
359 | } | ||
360 | |||
361 | static void xonar_st_init_common(struct oxygen *chip) | ||
362 | { | ||
363 | struct xonar_pcm179x *data = chip->model_data; | ||
364 | |||
365 | data->generic.anti_pop_delay = 100; | ||
366 | data->generic.output_enable_bit = GPIO_ST_OUTPUT_ENABLE; | ||
367 | data->dacs = chip->model.private_data ? 4 : 1; | ||
368 | data->hp_gain_offset = 2*-18; | ||
369 | |||
370 | pcm1796_init(chip); | ||
371 | |||
372 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, | ||
373 | GPIO_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP); | ||
374 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, | ||
375 | GPIO_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP); | ||
376 | |||
377 | xonar_init_cs53x1(chip); | ||
378 | xonar_enable_output(chip); | ||
379 | |||
380 | snd_component_add(chip->card, "PCM1792A"); | ||
381 | snd_component_add(chip->card, "CS5381"); | ||
382 | } | ||
383 | |||
384 | static void cs2000_registers_init(struct oxygen *chip) | ||
385 | { | ||
386 | struct xonar_pcm179x *data = chip->model_data; | ||
387 | |||
388 | cs2000_write(chip, CS2000_GLOBAL_CFG, CS2000_FREEZE); | ||
389 | cs2000_write(chip, CS2000_DEV_CTRL, 0); | ||
390 | cs2000_write(chip, CS2000_DEV_CFG_1, | ||
391 | CS2000_R_MOD_SEL_1 | | ||
392 | (0 << CS2000_R_SEL_SHIFT) | | ||
393 | CS2000_AUX_OUT_SRC_REF_CLK | | ||
394 | CS2000_EN_DEV_CFG_1); | ||
395 | cs2000_write(chip, CS2000_DEV_CFG_2, | ||
396 | (0 << CS2000_LOCK_CLK_SHIFT) | | ||
397 | CS2000_FRAC_N_SRC_STATIC); | ||
398 | cs2000_write(chip, CS2000_RATIO_0 + 0, 0x00); /* 1.0 */ | ||
399 | cs2000_write(chip, CS2000_RATIO_0 + 1, 0x10); | ||
400 | cs2000_write(chip, CS2000_RATIO_0 + 2, 0x00); | ||
401 | cs2000_write(chip, CS2000_RATIO_0 + 3, 0x00); | ||
402 | cs2000_write(chip, CS2000_FUN_CFG_1, data->cs2000_fun_cfg_1); | ||
403 | cs2000_write(chip, CS2000_FUN_CFG_2, 0); | ||
404 | cs2000_write(chip, CS2000_GLOBAL_CFG, CS2000_EN_DEV_CFG_2); | ||
405 | } | ||
406 | |||
407 | static void xonar_st_init(struct oxygen *chip) | ||
408 | { | ||
409 | struct xonar_pcm179x *data = chip->model_data; | ||
410 | |||
411 | data->has_cs2000 = 1; | ||
412 | data->cs2000_fun_cfg_1 = CS2000_REF_CLK_DIV_1; | ||
413 | |||
414 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, | ||
415 | OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_I2S | | ||
416 | OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 | | ||
417 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | ||
418 | |||
419 | xonar_st_init_i2c(chip); | ||
420 | cs2000_registers_init(chip); | ||
421 | xonar_st_init_common(chip); | ||
422 | |||
423 | snd_component_add(chip->card, "CS2000"); | ||
424 | } | ||
425 | |||
426 | static void xonar_stx_init(struct oxygen *chip) | ||
427 | { | ||
428 | struct xonar_pcm179x *data = chip->model_data; | ||
429 | |||
430 | xonar_st_init_i2c(chip); | ||
431 | data->generic.ext_power_reg = OXYGEN_GPI_DATA; | ||
432 | data->generic.ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
433 | data->generic.ext_power_bit = GPI_EXT_POWER; | ||
434 | xonar_init_ext_power(chip); | ||
435 | xonar_st_init_common(chip); | ||
436 | } | ||
437 | |||
438 | static void xonar_d2_cleanup(struct oxygen *chip) | ||
439 | { | ||
440 | xonar_disable_output(chip); | ||
441 | } | ||
442 | |||
443 | static void xonar_hdav_cleanup(struct oxygen *chip) | ||
444 | { | ||
445 | xonar_hdmi_cleanup(chip); | ||
446 | xonar_disable_output(chip); | ||
447 | msleep(2); | ||
448 | } | ||
449 | |||
450 | static void xonar_st_cleanup(struct oxygen *chip) | ||
451 | { | ||
452 | xonar_disable_output(chip); | ||
453 | } | ||
454 | |||
455 | static void xonar_d2_suspend(struct oxygen *chip) | ||
456 | { | ||
457 | xonar_d2_cleanup(chip); | ||
458 | } | ||
459 | |||
460 | static void xonar_hdav_suspend(struct oxygen *chip) | ||
461 | { | ||
462 | xonar_hdav_cleanup(chip); | ||
463 | } | ||
464 | |||
465 | static void xonar_st_suspend(struct oxygen *chip) | ||
466 | { | ||
467 | xonar_st_cleanup(chip); | ||
468 | } | ||
469 | |||
470 | static void xonar_d2_resume(struct oxygen *chip) | ||
471 | { | ||
472 | pcm1796_registers_init(chip); | ||
473 | xonar_enable_output(chip); | ||
474 | } | ||
475 | |||
476 | static void xonar_hdav_resume(struct oxygen *chip) | ||
477 | { | ||
478 | struct xonar_hdav *data = chip->model_data; | ||
479 | |||
480 | pcm1796_registers_init(chip); | ||
481 | xonar_hdmi_resume(chip, &data->hdmi); | ||
482 | xonar_enable_output(chip); | ||
483 | } | ||
484 | |||
485 | static void xonar_stx_resume(struct oxygen *chip) | ||
486 | { | ||
487 | pcm1796_registers_init(chip); | ||
488 | xonar_enable_output(chip); | ||
489 | } | ||
490 | |||
491 | static void xonar_st_resume(struct oxygen *chip) | ||
492 | { | ||
493 | cs2000_registers_init(chip); | ||
494 | xonar_stx_resume(chip); | ||
495 | } | ||
496 | |||
497 | static unsigned int mclk_from_rate(struct oxygen *chip, unsigned int rate) | ||
498 | { | ||
499 | struct xonar_pcm179x *data = chip->model_data; | ||
500 | |||
501 | if (rate <= 32000) | ||
502 | return OXYGEN_I2S_MCLK_512; | ||
503 | else if (rate <= 48000 && data->os_128) | ||
504 | return OXYGEN_I2S_MCLK_512; | ||
505 | else if (rate <= 96000) | ||
506 | return OXYGEN_I2S_MCLK_256; | ||
507 | else | ||
508 | return OXYGEN_I2S_MCLK_128; | ||
509 | } | ||
510 | |||
511 | static unsigned int get_pcm1796_i2s_mclk(struct oxygen *chip, | ||
512 | unsigned int channel, | ||
513 | struct snd_pcm_hw_params *params) | ||
514 | { | ||
515 | if (channel == PCM_MULTICH) | ||
516 | return mclk_from_rate(chip, params_rate(params)); | ||
517 | else | ||
518 | return oxygen_default_i2s_mclk(chip, channel, params); | ||
519 | } | ||
520 | |||
521 | static void update_pcm1796_oversampling(struct oxygen *chip) | ||
522 | { | ||
523 | struct xonar_pcm179x *data = chip->model_data; | ||
524 | unsigned int i; | ||
525 | u8 reg; | ||
526 | |||
527 | if (data->current_rate <= 32000) | ||
528 | reg = PCM1796_OS_128; | ||
529 | else if (data->current_rate <= 48000 && data->os_128) | ||
530 | reg = PCM1796_OS_128; | ||
531 | else if (data->current_rate <= 96000 || data->os_128) | ||
532 | reg = PCM1796_OS_64; | ||
533 | else | ||
534 | reg = PCM1796_OS_32; | ||
535 | for (i = 0; i < data->dacs; ++i) | ||
536 | pcm1796_write_cached(chip, i, 20, reg); | ||
537 | } | ||
538 | |||
539 | static void set_pcm1796_params(struct oxygen *chip, | ||
540 | struct snd_pcm_hw_params *params) | ||
541 | { | ||
542 | struct xonar_pcm179x *data = chip->model_data; | ||
543 | |||
544 | data->current_rate = params_rate(params); | ||
545 | update_pcm1796_oversampling(chip); | ||
546 | } | ||
547 | |||
548 | static void update_pcm1796_volume(struct oxygen *chip) | ||
549 | { | ||
550 | struct xonar_pcm179x *data = chip->model_data; | ||
551 | unsigned int i; | ||
552 | s8 gain_offset; | ||
553 | |||
554 | gain_offset = data->hp_active ? data->hp_gain_offset : 0; | ||
555 | for (i = 0; i < data->dacs; ++i) { | ||
556 | pcm1796_write_cached(chip, i, 16, chip->dac_volume[i * 2] | ||
557 | + gain_offset); | ||
558 | pcm1796_write_cached(chip, i, 17, chip->dac_volume[i * 2 + 1] | ||
559 | + gain_offset); | ||
560 | } | ||
561 | } | ||
562 | |||
563 | static void update_pcm1796_mute(struct oxygen *chip) | ||
564 | { | ||
565 | struct xonar_pcm179x *data = chip->model_data; | ||
566 | unsigned int i; | ||
567 | u8 value; | ||
568 | |||
569 | value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; | ||
570 | if (chip->dac_mute) | ||
571 | value |= PCM1796_MUTE; | ||
572 | for (i = 0; i < data->dacs; ++i) | ||
573 | pcm1796_write_cached(chip, i, 18, value); | ||
574 | } | ||
575 | |||
576 | static void update_cs2000_rate(struct oxygen *chip, unsigned int rate) | ||
577 | { | ||
578 | struct xonar_pcm179x *data = chip->model_data; | ||
579 | u8 rate_mclk, reg; | ||
580 | |||
581 | switch (rate) { | ||
582 | /* XXX Why is the I2S A MCLK half the actual I2S MCLK? */ | ||
583 | case 32000: | ||
584 | rate_mclk = OXYGEN_RATE_32000 | OXYGEN_I2S_MCLK_256; | ||
585 | break; | ||
586 | case 44100: | ||
587 | if (data->os_128) | ||
588 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_256; | ||
589 | else | ||
590 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_128; | ||
591 | break; | ||
592 | default: /* 48000 */ | ||
593 | if (data->os_128) | ||
594 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_256; | ||
595 | else | ||
596 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_128; | ||
597 | break; | ||
598 | case 64000: | ||
599 | rate_mclk = OXYGEN_RATE_32000 | OXYGEN_I2S_MCLK_256; | ||
600 | break; | ||
601 | case 88200: | ||
602 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_256; | ||
603 | break; | ||
604 | case 96000: | ||
605 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_256; | ||
606 | break; | ||
607 | case 176400: | ||
608 | rate_mclk = OXYGEN_RATE_44100 | OXYGEN_I2S_MCLK_256; | ||
609 | break; | ||
610 | case 192000: | ||
611 | rate_mclk = OXYGEN_RATE_48000 | OXYGEN_I2S_MCLK_256; | ||
612 | break; | ||
613 | } | ||
614 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, rate_mclk, | ||
615 | OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_MCLK_MASK); | ||
616 | if ((rate_mclk & OXYGEN_I2S_MCLK_MASK) <= OXYGEN_I2S_MCLK_128) | ||
617 | reg = CS2000_REF_CLK_DIV_1; | ||
618 | else | ||
619 | reg = CS2000_REF_CLK_DIV_2; | ||
620 | cs2000_write_cached(chip, CS2000_FUN_CFG_1, reg); | ||
621 | } | ||
622 | |||
623 | static void set_st_params(struct oxygen *chip, | ||
624 | struct snd_pcm_hw_params *params) | ||
625 | { | ||
626 | update_cs2000_rate(chip, params_rate(params)); | ||
627 | set_pcm1796_params(chip, params); | ||
628 | } | ||
629 | |||
630 | static void set_hdav_params(struct oxygen *chip, | ||
631 | struct snd_pcm_hw_params *params) | ||
632 | { | ||
633 | struct xonar_hdav *data = chip->model_data; | ||
634 | |||
635 | set_pcm1796_params(chip, params); | ||
636 | xonar_set_hdmi_params(chip, &data->hdmi, params); | ||
637 | } | ||
638 | |||
639 | static const struct snd_kcontrol_new alt_switch = { | ||
640 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
641 | .name = "Analog Loopback Switch", | ||
642 | .info = snd_ctl_boolean_mono_info, | ||
643 | .get = xonar_gpio_bit_switch_get, | ||
644 | .put = xonar_gpio_bit_switch_put, | ||
645 | .private_value = GPIO_D2_ALT, | ||
646 | }; | ||
647 | |||
648 | static int rolloff_info(struct snd_kcontrol *ctl, | ||
649 | struct snd_ctl_elem_info *info) | ||
650 | { | ||
651 | static const char *const names[2] = { | ||
652 | "Sharp Roll-off", "Slow Roll-off" | ||
653 | }; | ||
654 | |||
655 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
656 | info->count = 1; | ||
657 | info->value.enumerated.items = 2; | ||
658 | if (info->value.enumerated.item >= 2) | ||
659 | info->value.enumerated.item = 1; | ||
660 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
661 | return 0; | ||
662 | } | ||
663 | |||
664 | static int rolloff_get(struct snd_kcontrol *ctl, | ||
665 | struct snd_ctl_elem_value *value) | ||
666 | { | ||
667 | struct oxygen *chip = ctl->private_data; | ||
668 | struct xonar_pcm179x *data = chip->model_data; | ||
669 | |||
670 | value->value.enumerated.item[0] = | ||
671 | (data->pcm1796_regs[0][19 - PCM1796_REG_BASE] & | ||
672 | PCM1796_FLT_MASK) != PCM1796_FLT_SHARP; | ||
673 | return 0; | ||
674 | } | ||
675 | |||
676 | static int rolloff_put(struct snd_kcontrol *ctl, | ||
677 | struct snd_ctl_elem_value *value) | ||
678 | { | ||
679 | struct oxygen *chip = ctl->private_data; | ||
680 | struct xonar_pcm179x *data = chip->model_data; | ||
681 | unsigned int i; | ||
682 | int changed; | ||
683 | u8 reg; | ||
684 | |||
685 | mutex_lock(&chip->mutex); | ||
686 | reg = data->pcm1796_regs[0][19 - PCM1796_REG_BASE]; | ||
687 | reg &= ~PCM1796_FLT_MASK; | ||
688 | if (!value->value.enumerated.item[0]) | ||
689 | reg |= PCM1796_FLT_SHARP; | ||
690 | else | ||
691 | reg |= PCM1796_FLT_SLOW; | ||
692 | changed = reg != data->pcm1796_regs[0][19 - PCM1796_REG_BASE]; | ||
693 | if (changed) { | ||
694 | for (i = 0; i < data->dacs; ++i) | ||
695 | pcm1796_write(chip, i, 19, reg); | ||
696 | } | ||
697 | mutex_unlock(&chip->mutex); | ||
698 | return changed; | ||
699 | } | ||
700 | |||
701 | static const struct snd_kcontrol_new rolloff_control = { | ||
702 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
703 | .name = "DAC Filter Playback Enum", | ||
704 | .info = rolloff_info, | ||
705 | .get = rolloff_get, | ||
706 | .put = rolloff_put, | ||
707 | }; | ||
708 | |||
709 | static int os_128_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | ||
710 | { | ||
711 | static const char *const names[2] = { "64x", "128x" }; | ||
712 | |||
713 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
714 | info->count = 1; | ||
715 | info->value.enumerated.items = 2; | ||
716 | if (info->value.enumerated.item >= 2) | ||
717 | info->value.enumerated.item = 1; | ||
718 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
719 | return 0; | ||
720 | } | ||
721 | |||
722 | static int os_128_get(struct snd_kcontrol *ctl, | ||
723 | struct snd_ctl_elem_value *value) | ||
724 | { | ||
725 | struct oxygen *chip = ctl->private_data; | ||
726 | struct xonar_pcm179x *data = chip->model_data; | ||
727 | |||
728 | value->value.enumerated.item[0] = data->os_128; | ||
729 | return 0; | ||
730 | } | ||
731 | |||
732 | static int os_128_put(struct snd_kcontrol *ctl, | ||
733 | struct snd_ctl_elem_value *value) | ||
734 | { | ||
735 | struct oxygen *chip = ctl->private_data; | ||
736 | struct xonar_pcm179x *data = chip->model_data; | ||
737 | int changed; | ||
738 | |||
739 | mutex_lock(&chip->mutex); | ||
740 | changed = value->value.enumerated.item[0] != data->os_128; | ||
741 | if (changed) { | ||
742 | data->os_128 = value->value.enumerated.item[0]; | ||
743 | if (data->has_cs2000) | ||
744 | update_cs2000_rate(chip, data->current_rate); | ||
745 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | ||
746 | mclk_from_rate(chip, data->current_rate), | ||
747 | OXYGEN_I2S_MCLK_MASK); | ||
748 | update_pcm1796_oversampling(chip); | ||
749 | } | ||
750 | mutex_unlock(&chip->mutex); | ||
751 | return changed; | ||
752 | } | ||
753 | |||
754 | static const struct snd_kcontrol_new os_128_control = { | ||
755 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
756 | .name = "DAC Oversampling Playback Enum", | ||
757 | .info = os_128_info, | ||
758 | .get = os_128_get, | ||
759 | .put = os_128_put, | ||
760 | }; | ||
761 | |||
762 | static int st_output_switch_info(struct snd_kcontrol *ctl, | ||
763 | struct snd_ctl_elem_info *info) | ||
764 | { | ||
765 | static const char *const names[3] = { | ||
766 | "Speakers", "Headphones", "FP Headphones" | ||
767 | }; | ||
768 | |||
769 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
770 | info->count = 1; | ||
771 | info->value.enumerated.items = 3; | ||
772 | if (info->value.enumerated.item >= 3) | ||
773 | info->value.enumerated.item = 2; | ||
774 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
775 | return 0; | ||
776 | } | ||
777 | |||
778 | static int st_output_switch_get(struct snd_kcontrol *ctl, | ||
779 | struct snd_ctl_elem_value *value) | ||
780 | { | ||
781 | struct oxygen *chip = ctl->private_data; | ||
782 | u16 gpio; | ||
783 | |||
784 | gpio = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
785 | if (!(gpio & GPIO_ST_HP)) | ||
786 | value->value.enumerated.item[0] = 0; | ||
787 | else if (gpio & GPIO_ST_HP_REAR) | ||
788 | value->value.enumerated.item[0] = 1; | ||
789 | else | ||
790 | value->value.enumerated.item[0] = 2; | ||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | |||
795 | static int st_output_switch_put(struct snd_kcontrol *ctl, | ||
796 | struct snd_ctl_elem_value *value) | ||
797 | { | ||
798 | struct oxygen *chip = ctl->private_data; | ||
799 | struct xonar_pcm179x *data = chip->model_data; | ||
800 | u16 gpio_old, gpio; | ||
801 | |||
802 | mutex_lock(&chip->mutex); | ||
803 | gpio_old = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
804 | gpio = gpio_old; | ||
805 | switch (value->value.enumerated.item[0]) { | ||
806 | case 0: | ||
807 | gpio &= ~(GPIO_ST_HP | GPIO_ST_HP_REAR); | ||
808 | break; | ||
809 | case 1: | ||
810 | gpio |= GPIO_ST_HP | GPIO_ST_HP_REAR; | ||
811 | break; | ||
812 | case 2: | ||
813 | gpio = (gpio | GPIO_ST_HP) & ~GPIO_ST_HP_REAR; | ||
814 | break; | ||
815 | } | ||
816 | oxygen_write16(chip, OXYGEN_GPIO_DATA, gpio); | ||
817 | data->hp_active = gpio & GPIO_ST_HP; | ||
818 | update_pcm1796_volume(chip); | ||
819 | mutex_unlock(&chip->mutex); | ||
820 | return gpio != gpio_old; | ||
821 | } | ||
822 | |||
823 | static int st_hp_volume_offset_info(struct snd_kcontrol *ctl, | ||
824 | struct snd_ctl_elem_info *info) | ||
825 | { | ||
826 | static const char *const names[3] = { | ||
827 | "< 64 ohms", "64-300 ohms", "300-600 ohms" | ||
828 | }; | ||
829 | |||
830 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
831 | info->count = 1; | ||
832 | info->value.enumerated.items = 3; | ||
833 | if (info->value.enumerated.item > 2) | ||
834 | info->value.enumerated.item = 2; | ||
835 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
836 | return 0; | ||
837 | } | ||
838 | |||
839 | static int st_hp_volume_offset_get(struct snd_kcontrol *ctl, | ||
840 | struct snd_ctl_elem_value *value) | ||
841 | { | ||
842 | struct oxygen *chip = ctl->private_data; | ||
843 | struct xonar_pcm179x *data = chip->model_data; | ||
844 | |||
845 | mutex_lock(&chip->mutex); | ||
846 | if (data->hp_gain_offset < 2*-6) | ||
847 | value->value.enumerated.item[0] = 0; | ||
848 | else if (data->hp_gain_offset < 0) | ||
849 | value->value.enumerated.item[0] = 1; | ||
850 | else | ||
851 | value->value.enumerated.item[0] = 2; | ||
852 | mutex_unlock(&chip->mutex); | ||
853 | return 0; | ||
854 | } | ||
855 | |||
856 | |||
857 | static int st_hp_volume_offset_put(struct snd_kcontrol *ctl, | ||
858 | struct snd_ctl_elem_value *value) | ||
859 | { | ||
860 | static const s8 offsets[] = { 2*-18, 2*-6, 0 }; | ||
861 | struct oxygen *chip = ctl->private_data; | ||
862 | struct xonar_pcm179x *data = chip->model_data; | ||
863 | s8 offset; | ||
864 | int changed; | ||
865 | |||
866 | if (value->value.enumerated.item[0] > 2) | ||
867 | return -EINVAL; | ||
868 | offset = offsets[value->value.enumerated.item[0]]; | ||
869 | mutex_lock(&chip->mutex); | ||
870 | changed = offset != data->hp_gain_offset; | ||
871 | if (changed) { | ||
872 | data->hp_gain_offset = offset; | ||
873 | update_pcm1796_volume(chip); | ||
874 | } | ||
875 | mutex_unlock(&chip->mutex); | ||
876 | return changed; | ||
877 | } | ||
878 | |||
879 | static const struct snd_kcontrol_new st_controls[] = { | ||
880 | { | ||
881 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
882 | .name = "Analog Output", | ||
883 | .info = st_output_switch_info, | ||
884 | .get = st_output_switch_get, | ||
885 | .put = st_output_switch_put, | ||
886 | }, | ||
887 | { | ||
888 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
889 | .name = "Headphones Impedance Playback Enum", | ||
890 | .info = st_hp_volume_offset_info, | ||
891 | .get = st_hp_volume_offset_get, | ||
892 | .put = st_hp_volume_offset_put, | ||
893 | }, | ||
894 | }; | ||
895 | |||
896 | static void xonar_line_mic_ac97_switch(struct oxygen *chip, | ||
897 | unsigned int reg, unsigned int mute) | ||
898 | { | ||
899 | if (reg == AC97_LINE) { | ||
900 | spin_lock_irq(&chip->reg_lock); | ||
901 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
902 | mute ? GPIO_INPUT_ROUTE : 0, | ||
903 | GPIO_INPUT_ROUTE); | ||
904 | spin_unlock_irq(&chip->reg_lock); | ||
905 | } | ||
906 | } | ||
907 | |||
908 | static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -6000, 50, 0); | ||
909 | |||
910 | static int xonar_d2_control_filter(struct snd_kcontrol_new *template) | ||
911 | { | ||
912 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
913 | /* CD in is actually connected to the video in pin */ | ||
914 | template->private_value ^= AC97_CD ^ AC97_VIDEO; | ||
915 | return 0; | ||
916 | } | ||
917 | |||
918 | static int xonar_st_control_filter(struct snd_kcontrol_new *template) | ||
919 | { | ||
920 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
921 | return 1; /* no CD input */ | ||
922 | return 0; | ||
923 | } | ||
924 | |||
925 | static int add_pcm1796_controls(struct oxygen *chip) | ||
926 | { | ||
927 | int err; | ||
928 | |||
929 | err = snd_ctl_add(chip->card, snd_ctl_new1(&rolloff_control, chip)); | ||
930 | if (err < 0) | ||
931 | return err; | ||
932 | err = snd_ctl_add(chip->card, snd_ctl_new1(&os_128_control, chip)); | ||
933 | if (err < 0) | ||
934 | return err; | ||
935 | return 0; | ||
936 | } | ||
937 | |||
938 | static int xonar_d2_mixer_init(struct oxygen *chip) | ||
939 | { | ||
940 | int err; | ||
941 | |||
942 | err = snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); | ||
943 | if (err < 0) | ||
944 | return err; | ||
945 | err = add_pcm1796_controls(chip); | ||
946 | if (err < 0) | ||
947 | return err; | ||
948 | return 0; | ||
949 | } | ||
950 | |||
951 | static int xonar_hdav_mixer_init(struct oxygen *chip) | ||
952 | { | ||
953 | return add_pcm1796_controls(chip); | ||
954 | } | ||
955 | |||
956 | static int xonar_st_mixer_init(struct oxygen *chip) | ||
957 | { | ||
958 | unsigned int i; | ||
959 | int err; | ||
960 | |||
961 | for (i = 0; i < ARRAY_SIZE(st_controls); ++i) { | ||
962 | err = snd_ctl_add(chip->card, | ||
963 | snd_ctl_new1(&st_controls[i], chip)); | ||
964 | if (err < 0) | ||
965 | return err; | ||
966 | } | ||
967 | err = add_pcm1796_controls(chip); | ||
968 | if (err < 0) | ||
969 | return err; | ||
970 | return 0; | ||
971 | } | ||
972 | |||
973 | static const struct oxygen_model model_xonar_d2 = { | ||
974 | .longname = "Asus Virtuoso 200", | ||
975 | .chip = "AV200", | ||
976 | .init = xonar_d2_init, | ||
977 | .control_filter = xonar_d2_control_filter, | ||
978 | .mixer_init = xonar_d2_mixer_init, | ||
979 | .cleanup = xonar_d2_cleanup, | ||
980 | .suspend = xonar_d2_suspend, | ||
981 | .resume = xonar_d2_resume, | ||
982 | .get_i2s_mclk = get_pcm1796_i2s_mclk, | ||
983 | .set_dac_params = set_pcm1796_params, | ||
984 | .set_adc_params = xonar_set_cs53x1_params, | ||
985 | .update_dac_volume = update_pcm1796_volume, | ||
986 | .update_dac_mute = update_pcm1796_mute, | ||
987 | .dac_tlv = pcm1796_db_scale, | ||
988 | .model_data_size = sizeof(struct xonar_pcm179x), | ||
989 | .device_config = PLAYBACK_0_TO_I2S | | ||
990 | PLAYBACK_1_TO_SPDIF | | ||
991 | CAPTURE_0_FROM_I2S_2 | | ||
992 | CAPTURE_1_FROM_SPDIF | | ||
993 | MIDI_OUTPUT | | ||
994 | MIDI_INPUT, | ||
995 | .dac_channels = 8, | ||
996 | .dac_volume_min = 255 - 2*60, | ||
997 | .dac_volume_max = 255, | ||
998 | .misc_flags = OXYGEN_MISC_MIDI, | ||
999 | .function_flags = OXYGEN_FUNCTION_SPI | | ||
1000 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | ||
1001 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1002 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1003 | }; | ||
1004 | |||
1005 | static const struct oxygen_model model_xonar_hdav = { | ||
1006 | .longname = "Asus Virtuoso 200", | ||
1007 | .chip = "AV200", | ||
1008 | .init = xonar_hdav_init, | ||
1009 | .mixer_init = xonar_hdav_mixer_init, | ||
1010 | .cleanup = xonar_hdav_cleanup, | ||
1011 | .suspend = xonar_hdav_suspend, | ||
1012 | .resume = xonar_hdav_resume, | ||
1013 | .pcm_hardware_filter = xonar_hdmi_pcm_hardware_filter, | ||
1014 | .get_i2s_mclk = get_pcm1796_i2s_mclk, | ||
1015 | .set_dac_params = set_hdav_params, | ||
1016 | .set_adc_params = xonar_set_cs53x1_params, | ||
1017 | .update_dac_volume = update_pcm1796_volume, | ||
1018 | .update_dac_mute = update_pcm1796_mute, | ||
1019 | .uart_input = xonar_hdmi_uart_input, | ||
1020 | .ac97_switch = xonar_line_mic_ac97_switch, | ||
1021 | .dac_tlv = pcm1796_db_scale, | ||
1022 | .model_data_size = sizeof(struct xonar_hdav), | ||
1023 | .device_config = PLAYBACK_0_TO_I2S | | ||
1024 | PLAYBACK_1_TO_SPDIF | | ||
1025 | CAPTURE_0_FROM_I2S_2 | | ||
1026 | CAPTURE_1_FROM_SPDIF, | ||
1027 | .dac_channels = 8, | ||
1028 | .dac_volume_min = 255 - 2*60, | ||
1029 | .dac_volume_max = 255, | ||
1030 | .misc_flags = OXYGEN_MISC_MIDI, | ||
1031 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
1032 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1033 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1034 | }; | ||
1035 | |||
1036 | static const struct oxygen_model model_xonar_st = { | ||
1037 | .longname = "Asus Virtuoso 100", | ||
1038 | .chip = "AV200", | ||
1039 | .init = xonar_st_init, | ||
1040 | .control_filter = xonar_st_control_filter, | ||
1041 | .mixer_init = xonar_st_mixer_init, | ||
1042 | .cleanup = xonar_st_cleanup, | ||
1043 | .suspend = xonar_st_suspend, | ||
1044 | .resume = xonar_st_resume, | ||
1045 | .get_i2s_mclk = get_pcm1796_i2s_mclk, | ||
1046 | .set_dac_params = set_st_params, | ||
1047 | .set_adc_params = xonar_set_cs53x1_params, | ||
1048 | .update_dac_volume = update_pcm1796_volume, | ||
1049 | .update_dac_mute = update_pcm1796_mute, | ||
1050 | .ac97_switch = xonar_line_mic_ac97_switch, | ||
1051 | .dac_tlv = pcm1796_db_scale, | ||
1052 | .model_data_size = sizeof(struct xonar_pcm179x), | ||
1053 | .device_config = PLAYBACK_0_TO_I2S | | ||
1054 | PLAYBACK_1_TO_SPDIF | | ||
1055 | CAPTURE_0_FROM_I2S_2, | ||
1056 | .dac_channels = 2, | ||
1057 | .dac_volume_min = 255 - 2*60, | ||
1058 | .dac_volume_max = 255, | ||
1059 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
1060 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1061 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1062 | }; | ||
1063 | |||
1064 | int __devinit get_xonar_pcm179x_model(struct oxygen *chip, | ||
1065 | const struct pci_device_id *id) | ||
1066 | { | ||
1067 | switch (id->subdevice) { | ||
1068 | case 0x8269: | ||
1069 | chip->model = model_xonar_d2; | ||
1070 | chip->model.shortname = "Xonar D2"; | ||
1071 | break; | ||
1072 | case 0x82b7: | ||
1073 | chip->model = model_xonar_d2; | ||
1074 | chip->model.shortname = "Xonar D2X"; | ||
1075 | chip->model.init = xonar_d2x_init; | ||
1076 | break; | ||
1077 | case 0x8314: | ||
1078 | chip->model = model_xonar_hdav; | ||
1079 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); | ||
1080 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { | ||
1081 | default: | ||
1082 | chip->model.shortname = "Xonar HDAV1.3"; | ||
1083 | break; | ||
1084 | case GPIO_DB_H6: | ||
1085 | chip->model.shortname = "Xonar HDAV1.3+H6"; | ||
1086 | chip->model.private_data = 1; | ||
1087 | break; | ||
1088 | } | ||
1089 | break; | ||
1090 | case 0x835d: | ||
1091 | chip->model = model_xonar_st; | ||
1092 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); | ||
1093 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { | ||
1094 | default: | ||
1095 | chip->model.shortname = "Xonar ST"; | ||
1096 | break; | ||
1097 | case GPIO_DB_H6: | ||
1098 | chip->model.shortname = "Xonar ST+H6"; | ||
1099 | chip->model.dac_channels = 8; | ||
1100 | chip->model.private_data = 1; | ||
1101 | break; | ||
1102 | } | ||
1103 | break; | ||
1104 | case 0x835c: | ||
1105 | chip->model = model_xonar_st; | ||
1106 | chip->model.shortname = "Xonar STX"; | ||
1107 | chip->model.init = xonar_stx_init; | ||
1108 | chip->model.resume = xonar_stx_resume; | ||
1109 | chip->model.set_dac_params = set_pcm1796_params; | ||
1110 | break; | ||
1111 | default: | ||
1112 | return -EINVAL; | ||
1113 | } | ||
1114 | return 0; | ||
1115 | } | ||
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 0dce331a2a3b..a1b10d1a384d 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -3017,7 +3017,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry, | |||
3017 | insel = "Coaxial"; | 3017 | insel = "Coaxial"; |
3018 | break; | 3018 | break; |
3019 | default: | 3019 | default: |
3020 | insel = "Unkown"; | 3020 | insel = "Unknown"; |
3021 | } | 3021 | } |
3022 | 3022 | ||
3023 | switch (hdspm->control_register & HDSPM_SyncRefMask) { | 3023 | switch (hdspm->control_register & HDSPM_SyncRefMask) { |
@@ -3028,7 +3028,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry, | |||
3028 | syncref = "MADI"; | 3028 | syncref = "MADI"; |
3029 | break; | 3029 | break; |
3030 | default: | 3030 | default: |
3031 | syncref = "Unkown"; | 3031 | syncref = "Unknown"; |
3032 | } | 3032 | } |
3033 | snd_iprintf(buffer, "Inputsel = %s, SyncRef = %s\n", insel, | 3033 | snd_iprintf(buffer, "Inputsel = %s, SyncRef = %s\n", insel, |
3034 | syncref); | 3034 | syncref); |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 64b859925c0b..edaa729126bb 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c | |||
@@ -131,7 +131,7 @@ static int snd_pdacf_probe(struct pcmcia_device *link) | |||
131 | return err; | 131 | return err; |
132 | } | 132 | } |
133 | 133 | ||
134 | snd_card_set_dev(card, &handle_to_dev(link)); | 134 | snd_card_set_dev(card, &link->dev); |
135 | 135 | ||
136 | pdacf->index = i; | 136 | pdacf->index = i; |
137 | card_list[i] = card; | 137 | card_list[i] = card; |
@@ -142,12 +142,11 @@ static int snd_pdacf_probe(struct pcmcia_device *link) | |||
142 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 142 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
143 | link->io.NumPorts1 = 16; | 143 | link->io.NumPorts1 = 16; |
144 | 144 | ||
145 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT | 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.IRQInfo1 = 0 /* | IRQ_LEVEL_ID */; | ||
149 | link->irq.Handler = pdacf_interrupt; | 149 | link->irq.Handler = pdacf_interrupt; |
150 | link->irq.Instance = pdacf; | ||
151 | link->conf.Attributes = CONF_ENABLE_IRQ; | 150 | link->conf.Attributes = CONF_ENABLE_IRQ; |
152 | link->conf.IntType = INT_MEMORY_AND_IO; | 151 | link->conf.IntType = INT_MEMORY_AND_IO; |
153 | link->conf.ConfigIndex = 1; | 152 | link->conf.ConfigIndex = 1; |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index d057e6489643..5cfa608823f7 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | |||
@@ -51,7 +51,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s | |||
51 | return 0; /* already enough large */ | 51 | return 0; /* already enough large */ |
52 | vfree(runtime->dma_area); | 52 | vfree(runtime->dma_area); |
53 | } | 53 | } |
54 | runtime->dma_area = vmalloc_32(size); | 54 | runtime->dma_area = vmalloc_32_user(size); |
55 | if (! runtime->dma_area) | 55 | if (! runtime->dma_area) |
56 | return -ENOMEM; | 56 | return -ENOMEM; |
57 | runtime->dma_bytes = size; | 57 | runtime->dma_bytes = size; |
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 1492744ad67f..7be3b3357045 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c | |||
@@ -161,11 +161,9 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl, | |||
161 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 161 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
162 | link->io.NumPorts1 = 16; | 162 | link->io.NumPorts1 = 16; |
163 | 163 | ||
164 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; | 164 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; |
165 | 165 | ||
166 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | ||
167 | link->irq.Handler = &snd_vx_irq_handler; | 166 | link->irq.Handler = &snd_vx_irq_handler; |
168 | link->irq.Instance = chip; | ||
169 | 167 | ||
170 | link->conf.Attributes = CONF_ENABLE_IRQ; | 168 | link->conf.Attributes = CONF_ENABLE_IRQ; |
171 | link->conf.IntType = INT_MEMORY_AND_IO; | 169 | link->conf.IntType = INT_MEMORY_AND_IO; |
@@ -244,7 +242,7 @@ static int vxpocket_config(struct pcmcia_device *link) | |||
244 | if (ret) | 242 | if (ret) |
245 | goto failed; | 243 | goto failed; |
246 | 244 | ||
247 | chip->dev = &handle_to_dev(link); | 245 | chip->dev = &link->dev; |
248 | snd_card_set_dev(chip->card, chip->dev); | 246 | snd_card_set_dev(chip->card, chip->dev); |
249 | 247 | ||
250 | if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0) | 248 | if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0) |
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 2cc0eda4f20e..2e156467b814 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c | |||
@@ -479,7 +479,7 @@ static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol, | |||
479 | 479 | ||
480 | static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] __devinitdata = { | 480 | static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] __devinitdata = { |
481 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 481 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
482 | .name = "PC Speaker Playback Volume", | 482 | .name = "Speaker Playback Volume", |
483 | .info = snd_pmac_awacs_info_volume_amp, | 483 | .info = snd_pmac_awacs_info_volume_amp, |
484 | .get = snd_pmac_awacs_get_volume_amp, | 484 | .get = snd_pmac_awacs_get_volume_amp, |
485 | .put = snd_pmac_awacs_put_volume_amp, | 485 | .put = snd_pmac_awacs_put_volume_amp, |
@@ -525,7 +525,7 @@ static struct snd_kcontrol_new snd_pmac_awacs_amp_hp_sw __devinitdata = { | |||
525 | 525 | ||
526 | static struct snd_kcontrol_new snd_pmac_awacs_amp_spk_sw __devinitdata = { | 526 | static struct snd_kcontrol_new snd_pmac_awacs_amp_spk_sw __devinitdata = { |
527 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 527 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
528 | .name = "PC Speaker Playback Switch", | 528 | .name = "Speaker Playback Switch", |
529 | .info = snd_pmac_boolean_stereo_info, | 529 | .info = snd_pmac_boolean_stereo_info, |
530 | .get = snd_pmac_awacs_get_switch_amp, | 530 | .get = snd_pmac_awacs_get_switch_amp, |
531 | .put = snd_pmac_awacs_put_switch_amp, | 531 | .put = snd_pmac_awacs_put_switch_amp, |
@@ -696,17 +696,17 @@ static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] __devinitdata | |||
696 | }; | 696 | }; |
697 | 697 | ||
698 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __devinitdata = { | 698 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __devinitdata = { |
699 | AWACS_VOLUME("PC Speaker Playback Volume", 4, 6, 1), | 699 | AWACS_VOLUME("Speaker Playback Volume", 4, 6, 1), |
700 | }; | 700 | }; |
701 | 701 | ||
702 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __devinitdata = | 702 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __devinitdata = |
703 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); | 703 | AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); |
704 | 704 | ||
705 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 __devinitdata = | 705 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 __devinitdata = |
706 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 1); | 706 | AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 1); |
707 | 707 | ||
708 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 __devinitdata = | 708 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 __devinitdata = |
709 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); | 709 | AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); |
710 | 710 | ||
711 | 711 | ||
712 | /* | 712 | /* |
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index 16ed240e423c..0accfe49735b 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c | |||
@@ -505,7 +505,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __devinitdata = { | |||
505 | MASK_ADDR_BURGUNDY_GAINLINE, 1, 0), | 505 | MASK_ADDR_BURGUNDY_GAINLINE, 1, 0), |
506 | BURGUNDY_VOLUME_B("Mic Gain Capture Volume", 0, | 506 | BURGUNDY_VOLUME_B("Mic Gain Capture Volume", 0, |
507 | MASK_ADDR_BURGUNDY_GAINMIC, 1, 0), | 507 | MASK_ADDR_BURGUNDY_GAINMIC, 1, 0), |
508 | BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0, | 508 | BURGUNDY_VOLUME_B("Speaker Playback Volume", 0, |
509 | MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1), | 509 | MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1), |
510 | BURGUNDY_VOLUME_B("Line out Playback Volume", 0, | 510 | BURGUNDY_VOLUME_B("Line out Playback Volume", 0, |
511 | MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1, 1), | 511 | MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1, 1), |
@@ -527,7 +527,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __devinitdata = { | |||
527 | MASK_ADDR_BURGUNDY_VOLMIC, 16), | 527 | MASK_ADDR_BURGUNDY_VOLMIC, 16), |
528 | BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0, | 528 | BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0, |
529 | MASK_ADDR_BURGUNDY_GAINMIC, 1, 0), | 529 | MASK_ADDR_BURGUNDY_GAINMIC, 1, 0), |
530 | BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0, | 530 | BURGUNDY_VOLUME_B("Speaker Playback Volume", 0, |
531 | MASK_ADDR_BURGUNDY_ATTENMONO, 0, 1), | 531 | MASK_ADDR_BURGUNDY_ATTENMONO, 0, 1), |
532 | BURGUNDY_VOLUME_B("Line out Playback Volume", 0, | 532 | BURGUNDY_VOLUME_B("Line out Playback Volume", 0, |
533 | MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1), | 533 | MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1), |
@@ -549,11 +549,11 @@ BURGUNDY_SWITCH_B("Master Playback Switch", 0, | |||
549 | BURGUNDY_OUTPUT_INTERN | 549 | BURGUNDY_OUTPUT_INTERN |
550 | | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); | 550 | | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); |
551 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __devinitdata = | 551 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __devinitdata = |
552 | BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0, | 552 | BURGUNDY_SWITCH_B("Speaker Playback Switch", 0, |
553 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 553 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
554 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); | 554 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); |
555 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __devinitdata = | 555 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __devinitdata = |
556 | BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0, | 556 | BURGUNDY_SWITCH_B("Speaker Playback Switch", 0, |
557 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 557 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
558 | BURGUNDY_OUTPUT_INTERN, 0, 0); | 558 | BURGUNDY_OUTPUT_INTERN, 0, 0); |
559 | static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __devinitdata = | 559 | static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __devinitdata = |
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 08e584d1453a..789f44f4ac78 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c | |||
@@ -905,7 +905,7 @@ static struct snd_kcontrol_new tumbler_hp_sw __devinitdata = { | |||
905 | }; | 905 | }; |
906 | static struct snd_kcontrol_new tumbler_speaker_sw __devinitdata = { | 906 | static struct snd_kcontrol_new tumbler_speaker_sw __devinitdata = { |
907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
908 | .name = "PC Speaker Playback Switch", | 908 | .name = "Speaker Playback Switch", |
909 | .info = snd_pmac_boolean_mono_info, | 909 | .info = snd_pmac_boolean_mono_info, |
910 | .get = tumbler_get_mute_switch, | 910 | .get = tumbler_get_mute_switch, |
911 | .put = tumbler_put_mute_switch, | 911 | .put = tumbler_put_mute_switch, |
diff --git a/sound/sh/Kconfig b/sound/sh/Kconfig index aed0f90c3919..61139f3c1614 100644 --- a/sound/sh/Kconfig +++ b/sound/sh/Kconfig | |||
@@ -19,5 +19,13 @@ config SND_AICA | |||
19 | help | 19 | help |
20 | ALSA Sound driver for the SEGA Dreamcast console. | 20 | ALSA Sound driver for the SEGA Dreamcast console. |
21 | 21 | ||
22 | config SND_SH_DAC_AUDIO | ||
23 | tristate "SuperH DAC audio support" | ||
24 | depends on SND | ||
25 | depends on CPU_SH3 && HIGH_RES_TIMERS | ||
26 | select SND_PCM | ||
27 | help | ||
28 | Say Y here to include support for the on-chip DAC. | ||
29 | |||
22 | endif # SND_SUPERH | 30 | endif # SND_SUPERH |
23 | 31 | ||
diff --git a/sound/sh/Makefile b/sound/sh/Makefile index 8fdcb6e26f00..7d09b5188cf7 100644 --- a/sound/sh/Makefile +++ b/sound/sh/Makefile | |||
@@ -3,6 +3,8 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | snd-aica-objs := aica.o | 5 | snd-aica-objs := aica.o |
6 | snd-sh_dac_audio-objs := sh_dac_audio.o | ||
6 | 7 | ||
7 | # Toplevel Module Dependency | 8 | # Toplevel Module Dependency |
8 | obj-$(CONFIG_SND_AICA) += snd-aica.o | 9 | obj-$(CONFIG_SND_AICA) += snd-aica.o |
10 | obj-$(CONFIG_SND_SH_DAC_AUDIO) += snd-sh_dac_audio.o | ||
diff --git a/sound/sh/aica.c b/sound/sh/aica.c index 583a3693df75..a0df401ebb9f 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c | |||
@@ -49,6 +49,7 @@ MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>"); | |||
49 | MODULE_DESCRIPTION("Dreamcast AICA sound (pcm) driver"); | 49 | MODULE_DESCRIPTION("Dreamcast AICA sound (pcm) driver"); |
50 | MODULE_LICENSE("GPL"); | 50 | MODULE_LICENSE("GPL"); |
51 | MODULE_SUPPORTED_DEVICE("{{Yamaha/SEGA, AICA}}"); | 51 | MODULE_SUPPORTED_DEVICE("{{Yamaha/SEGA, AICA}}"); |
52 | MODULE_FIRMWARE("aica_firmware.bin"); | ||
52 | 53 | ||
53 | /* module parameters */ | 54 | /* module parameters */ |
54 | #define CARD_NAME "AICA" | 55 | #define CARD_NAME "AICA" |
diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c new file mode 100644 index 000000000000..76d9ad27d91c --- /dev/null +++ b/sound/sh/sh_dac_audio.c | |||
@@ -0,0 +1,453 @@ | |||
1 | /* | ||
2 | * sh_dac_audio.c - SuperH DAC audio driver for ALSA | ||
3 | * | ||
4 | * Copyright (c) 2009 by Rafael Ignacio Zurita <rizurita@yahoo.com> | ||
5 | * | ||
6 | * | ||
7 | * Based on sh_dac_audio.c (Copyright (C) 2004, 2005 by Andriy Skulysh) | ||
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 | |||
25 | #include <linux/hrtimer.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/initval.h> | ||
31 | #include <sound/pcm.h> | ||
32 | #include <sound/sh_dac_audio.h> | ||
33 | #include <asm/clock.h> | ||
34 | #include <asm/hd64461.h> | ||
35 | #include <mach/hp6xx.h> | ||
36 | #include <cpu/dac.h> | ||
37 | |||
38 | MODULE_AUTHOR("Rafael Ignacio Zurita <rizurita@yahoo.com>"); | ||
39 | MODULE_DESCRIPTION("SuperH DAC audio driver"); | ||
40 | MODULE_LICENSE("GPL"); | ||
41 | MODULE_SUPPORTED_DEVICE("{{SuperH DAC audio support}}"); | ||
42 | |||
43 | /* Module Parameters */ | ||
44 | static int index = SNDRV_DEFAULT_IDX1; | ||
45 | static char *id = SNDRV_DEFAULT_STR1; | ||
46 | module_param(index, int, 0444); | ||
47 | MODULE_PARM_DESC(index, "Index value for SuperH DAC audio."); | ||
48 | module_param(id, charp, 0444); | ||
49 | MODULE_PARM_DESC(id, "ID string for SuperH DAC audio."); | ||
50 | |||
51 | /* main struct */ | ||
52 | struct snd_sh_dac { | ||
53 | struct snd_card *card; | ||
54 | struct snd_pcm_substream *substream; | ||
55 | struct hrtimer hrtimer; | ||
56 | ktime_t wakeups_per_second; | ||
57 | |||
58 | int rate; | ||
59 | int empty; | ||
60 | char *data_buffer, *buffer_begin, *buffer_end; | ||
61 | int processed; /* bytes proccesed, to compare with period_size */ | ||
62 | int buffer_size; | ||
63 | struct dac_audio_pdata *pdata; | ||
64 | }; | ||
65 | |||
66 | |||
67 | static void dac_audio_start_timer(struct snd_sh_dac *chip) | ||
68 | { | ||
69 | hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, | ||
70 | HRTIMER_MODE_REL); | ||
71 | } | ||
72 | |||
73 | static void dac_audio_stop_timer(struct snd_sh_dac *chip) | ||
74 | { | ||
75 | hrtimer_cancel(&chip->hrtimer); | ||
76 | } | ||
77 | |||
78 | static void dac_audio_reset(struct snd_sh_dac *chip) | ||
79 | { | ||
80 | dac_audio_stop_timer(chip); | ||
81 | chip->buffer_begin = chip->buffer_end = chip->data_buffer; | ||
82 | chip->processed = 0; | ||
83 | chip->empty = 1; | ||
84 | } | ||
85 | |||
86 | static void dac_audio_set_rate(struct snd_sh_dac *chip) | ||
87 | { | ||
88 | chip->wakeups_per_second = ktime_set(0, 1000000000 / chip->rate); | ||
89 | } | ||
90 | |||
91 | |||
92 | /* PCM INTERFACE */ | ||
93 | |||
94 | static struct snd_pcm_hardware snd_sh_dac_pcm_hw = { | ||
95 | .info = (SNDRV_PCM_INFO_MMAP | | ||
96 | SNDRV_PCM_INFO_MMAP_VALID | | ||
97 | SNDRV_PCM_INFO_INTERLEAVED | | ||
98 | SNDRV_PCM_INFO_HALF_DUPLEX), | ||
99 | .formats = SNDRV_PCM_FMTBIT_U8, | ||
100 | .rates = SNDRV_PCM_RATE_8000, | ||
101 | .rate_min = 8000, | ||
102 | .rate_max = 8000, | ||
103 | .channels_min = 1, | ||
104 | .channels_max = 1, | ||
105 | .buffer_bytes_max = (48*1024), | ||
106 | .period_bytes_min = 1, | ||
107 | .period_bytes_max = (48*1024), | ||
108 | .periods_min = 1, | ||
109 | .periods_max = 1024, | ||
110 | }; | ||
111 | |||
112 | static int snd_sh_dac_pcm_open(struct snd_pcm_substream *substream) | ||
113 | { | ||
114 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
115 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
116 | |||
117 | runtime->hw = snd_sh_dac_pcm_hw; | ||
118 | |||
119 | chip->substream = substream; | ||
120 | chip->buffer_begin = chip->buffer_end = chip->data_buffer; | ||
121 | chip->processed = 0; | ||
122 | chip->empty = 1; | ||
123 | |||
124 | chip->pdata->start(chip->pdata); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream) | ||
130 | { | ||
131 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
132 | |||
133 | chip->substream = NULL; | ||
134 | |||
135 | dac_audio_stop_timer(chip); | ||
136 | chip->pdata->stop(chip->pdata); | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static int snd_sh_dac_pcm_hw_params(struct snd_pcm_substream *substream, | ||
142 | struct snd_pcm_hw_params *hw_params) | ||
143 | { | ||
144 | return snd_pcm_lib_malloc_pages(substream, | ||
145 | params_buffer_bytes(hw_params)); | ||
146 | } | ||
147 | |||
148 | static int snd_sh_dac_pcm_hw_free(struct snd_pcm_substream *substream) | ||
149 | { | ||
150 | return snd_pcm_lib_free_pages(substream); | ||
151 | } | ||
152 | |||
153 | static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream) | ||
154 | { | ||
155 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
156 | struct snd_pcm_runtime *runtime = chip->substream->runtime; | ||
157 | |||
158 | chip->buffer_size = runtime->buffer_size; | ||
159 | memset(chip->data_buffer, 0, chip->pdata->buffer_size); | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static int snd_sh_dac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
165 | { | ||
166 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
167 | |||
168 | switch (cmd) { | ||
169 | case SNDRV_PCM_TRIGGER_START: | ||
170 | dac_audio_start_timer(chip); | ||
171 | break; | ||
172 | case SNDRV_PCM_TRIGGER_STOP: | ||
173 | chip->buffer_begin = chip->buffer_end = chip->data_buffer; | ||
174 | chip->processed = 0; | ||
175 | chip->empty = 1; | ||
176 | dac_audio_stop_timer(chip); | ||
177 | break; | ||
178 | default: | ||
179 | return -EINVAL; | ||
180 | } | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, int channel, | ||
186 | snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) | ||
187 | { | ||
188 | /* channel is not used (interleaved data) */ | ||
189 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
190 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
191 | ssize_t b_count = frames_to_bytes(runtime , count); | ||
192 | ssize_t b_pos = frames_to_bytes(runtime , pos); | ||
193 | |||
194 | if (count < 0) | ||
195 | return -EINVAL; | ||
196 | |||
197 | if (!count) | ||
198 | return 0; | ||
199 | |||
200 | memcpy_toio(chip->data_buffer + b_pos, src, b_count); | ||
201 | chip->buffer_end = chip->data_buffer + b_pos + b_count; | ||
202 | |||
203 | if (chip->empty) { | ||
204 | chip->empty = 0; | ||
205 | dac_audio_start_timer(chip); | ||
206 | } | ||
207 | |||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream, | ||
212 | int channel, snd_pcm_uframes_t pos, | ||
213 | snd_pcm_uframes_t count) | ||
214 | { | ||
215 | /* channel is not used (interleaved data) */ | ||
216 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
217 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
218 | ssize_t b_count = frames_to_bytes(runtime , count); | ||
219 | ssize_t b_pos = frames_to_bytes(runtime , pos); | ||
220 | |||
221 | if (count < 0) | ||
222 | return -EINVAL; | ||
223 | |||
224 | if (!count) | ||
225 | return 0; | ||
226 | |||
227 | memset_io(chip->data_buffer + b_pos, 0, b_count); | ||
228 | chip->buffer_end = chip->data_buffer + b_pos + b_count; | ||
229 | |||
230 | if (chip->empty) { | ||
231 | chip->empty = 0; | ||
232 | dac_audio_start_timer(chip); | ||
233 | } | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static | ||
239 | snd_pcm_uframes_t snd_sh_dac_pcm_pointer(struct snd_pcm_substream *substream) | ||
240 | { | ||
241 | struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); | ||
242 | int pointer = chip->buffer_begin - chip->data_buffer; | ||
243 | |||
244 | return pointer; | ||
245 | } | ||
246 | |||
247 | /* pcm ops */ | ||
248 | static struct snd_pcm_ops snd_sh_dac_pcm_ops = { | ||
249 | .open = snd_sh_dac_pcm_open, | ||
250 | .close = snd_sh_dac_pcm_close, | ||
251 | .ioctl = snd_pcm_lib_ioctl, | ||
252 | .hw_params = snd_sh_dac_pcm_hw_params, | ||
253 | .hw_free = snd_sh_dac_pcm_hw_free, | ||
254 | .prepare = snd_sh_dac_pcm_prepare, | ||
255 | .trigger = snd_sh_dac_pcm_trigger, | ||
256 | .pointer = snd_sh_dac_pcm_pointer, | ||
257 | .copy = snd_sh_dac_pcm_copy, | ||
258 | .silence = snd_sh_dac_pcm_silence, | ||
259 | .mmap = snd_pcm_lib_mmap_iomem, | ||
260 | }; | ||
261 | |||
262 | static int __devinit snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) | ||
263 | { | ||
264 | int err; | ||
265 | struct snd_pcm *pcm; | ||
266 | |||
267 | /* device should be always 0 for us */ | ||
268 | err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm); | ||
269 | if (err < 0) | ||
270 | return err; | ||
271 | |||
272 | pcm->private_data = chip; | ||
273 | strcpy(pcm->name, "SH_DAC PCM"); | ||
274 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sh_dac_pcm_ops); | ||
275 | |||
276 | /* buffer size=48K */ | ||
277 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, | ||
278 | snd_dma_continuous_data(GFP_KERNEL), | ||
279 | 48 * 1024, | ||
280 | 48 * 1024); | ||
281 | |||
282 | return 0; | ||
283 | } | ||
284 | /* END OF PCM INTERFACE */ | ||
285 | |||
286 | |||
287 | /* driver .remove -- destructor */ | ||
288 | static int snd_sh_dac_remove(struct platform_device *devptr) | ||
289 | { | ||
290 | snd_card_free(platform_get_drvdata(devptr)); | ||
291 | platform_set_drvdata(devptr, NULL); | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | /* free -- it has been defined by create */ | ||
297 | static int snd_sh_dac_free(struct snd_sh_dac *chip) | ||
298 | { | ||
299 | /* release the data */ | ||
300 | kfree(chip->data_buffer); | ||
301 | kfree(chip); | ||
302 | |||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | static int snd_sh_dac_dev_free(struct snd_device *device) | ||
307 | { | ||
308 | struct snd_sh_dac *chip = device->device_data; | ||
309 | |||
310 | return snd_sh_dac_free(chip); | ||
311 | } | ||
312 | |||
313 | static enum hrtimer_restart sh_dac_audio_timer(struct hrtimer *handle) | ||
314 | { | ||
315 | struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac, | ||
316 | hrtimer); | ||
317 | struct snd_pcm_runtime *runtime = chip->substream->runtime; | ||
318 | ssize_t b_ps = frames_to_bytes(runtime, runtime->period_size); | ||
319 | |||
320 | if (!chip->empty) { | ||
321 | sh_dac_output(*chip->buffer_begin, chip->pdata->channel); | ||
322 | chip->buffer_begin++; | ||
323 | |||
324 | chip->processed++; | ||
325 | if (chip->processed >= b_ps) { | ||
326 | chip->processed -= b_ps; | ||
327 | snd_pcm_period_elapsed(chip->substream); | ||
328 | } | ||
329 | |||
330 | if (chip->buffer_begin == (chip->data_buffer + | ||
331 | chip->buffer_size - 1)) | ||
332 | chip->buffer_begin = chip->data_buffer; | ||
333 | |||
334 | if (chip->buffer_begin == chip->buffer_end) | ||
335 | chip->empty = 1; | ||
336 | |||
337 | } | ||
338 | |||
339 | if (!chip->empty) | ||
340 | hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, | ||
341 | HRTIMER_MODE_REL); | ||
342 | |||
343 | return HRTIMER_NORESTART; | ||
344 | } | ||
345 | |||
346 | /* create -- chip-specific constructor for the cards components */ | ||
347 | static int __devinit snd_sh_dac_create(struct snd_card *card, | ||
348 | struct platform_device *devptr, | ||
349 | struct snd_sh_dac **rchip) | ||
350 | { | ||
351 | struct snd_sh_dac *chip; | ||
352 | int err; | ||
353 | |||
354 | static struct snd_device_ops ops = { | ||
355 | .dev_free = snd_sh_dac_dev_free, | ||
356 | }; | ||
357 | |||
358 | *rchip = NULL; | ||
359 | |||
360 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
361 | if (chip == NULL) | ||
362 | return -ENOMEM; | ||
363 | |||
364 | chip->card = card; | ||
365 | |||
366 | hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | ||
367 | chip->hrtimer.function = sh_dac_audio_timer; | ||
368 | |||
369 | dac_audio_reset(chip); | ||
370 | chip->rate = 8000; | ||
371 | dac_audio_set_rate(chip); | ||
372 | |||
373 | chip->pdata = devptr->dev.platform_data; | ||
374 | |||
375 | chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL); | ||
376 | if (chip->data_buffer == NULL) { | ||
377 | kfree(chip); | ||
378 | return -ENOMEM; | ||
379 | } | ||
380 | |||
381 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); | ||
382 | if (err < 0) { | ||
383 | snd_sh_dac_free(chip); | ||
384 | return err; | ||
385 | } | ||
386 | |||
387 | *rchip = chip; | ||
388 | |||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | /* driver .probe -- constructor */ | ||
393 | static int __devinit snd_sh_dac_probe(struct platform_device *devptr) | ||
394 | { | ||
395 | struct snd_sh_dac *chip; | ||
396 | struct snd_card *card; | ||
397 | int err; | ||
398 | |||
399 | err = snd_card_create(index, id, THIS_MODULE, 0, &card); | ||
400 | if (err < 0) { | ||
401 | snd_printk(KERN_ERR "cannot allocate the card\n"); | ||
402 | return err; | ||
403 | } | ||
404 | |||
405 | err = snd_sh_dac_create(card, devptr, &chip); | ||
406 | if (err < 0) | ||
407 | goto probe_error; | ||
408 | |||
409 | err = snd_sh_dac_pcm(chip, 0); | ||
410 | if (err < 0) | ||
411 | goto probe_error; | ||
412 | |||
413 | strcpy(card->driver, "snd_sh_dac"); | ||
414 | strcpy(card->shortname, "SuperH DAC audio driver"); | ||
415 | printk(KERN_INFO "%s %s", card->longname, card->shortname); | ||
416 | |||
417 | err = snd_card_register(card); | ||
418 | if (err < 0) | ||
419 | goto probe_error; | ||
420 | |||
421 | snd_printk("ALSA driver for SuperH DAC audio"); | ||
422 | |||
423 | platform_set_drvdata(devptr, card); | ||
424 | return 0; | ||
425 | |||
426 | probe_error: | ||
427 | snd_card_free(card); | ||
428 | return err; | ||
429 | } | ||
430 | |||
431 | /* | ||
432 | * "driver" definition | ||
433 | */ | ||
434 | static struct platform_driver driver = { | ||
435 | .probe = snd_sh_dac_probe, | ||
436 | .remove = snd_sh_dac_remove, | ||
437 | .driver = { | ||
438 | .name = "dac_audio", | ||
439 | }, | ||
440 | }; | ||
441 | |||
442 | static int __init sh_dac_init(void) | ||
443 | { | ||
444 | return platform_driver_register(&driver); | ||
445 | } | ||
446 | |||
447 | static void __exit sh_dac_exit(void) | ||
448 | { | ||
449 | platform_driver_unregister(&driver); | ||
450 | } | ||
451 | |||
452 | module_init(sh_dac_init); | ||
453 | module_exit(sh_dac_exit); | ||
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 09d1af85b6f1..a9dc5fb54774 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
@@ -85,7 +85,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg, | |||
85 | * of data into val | 85 | * of data into val |
86 | */ | 86 | */ |
87 | 87 | ||
88 | if ((reg < 0 || reg > 9) && (reg != 15)) { | 88 | if (reg > 9 && reg != 15) { |
89 | printk(KERN_WARNING "%s Invalid register R%u\n", __func__, reg); | 89 | printk(KERN_WARNING "%s Invalid register R%u\n", __func__, reg); |
90 | return -1; | 90 | return -1; |
91 | } | 91 | } |
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/uda134x.c b/sound/soc/codecs/uda134x.c index aa40d985138f..3e99fe5131dd 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c | |||
@@ -101,7 +101,7 @@ static int uda134x_write(struct snd_soc_codec *codec, unsigned int reg, | |||
101 | pr_debug("%s reg: %02X, value:%02X\n", __func__, reg, value); | 101 | pr_debug("%s reg: %02X, value:%02X\n", __func__, reg, value); |
102 | 102 | ||
103 | if (reg >= UDA134X_REGS_NUM) { | 103 | if (reg >= UDA134X_REGS_NUM) { |
104 | printk(KERN_ERR "%s unkown register: reg: %u", | 104 | printk(KERN_ERR "%s unknown register: reg: %u", |
105 | __func__, reg); | 105 | __func__, reg); |
106 | return -EINVAL; | 106 | return -EINVAL; |
107 | } | 107 | } |
@@ -552,7 +552,7 @@ static int uda134x_soc_probe(struct platform_device *pdev) | |||
552 | ARRAY_SIZE(uda1341_snd_controls)); | 552 | ARRAY_SIZE(uda1341_snd_controls)); |
553 | break; | 553 | break; |
554 | default: | 554 | default: |
555 | printk(KERN_ERR "%s unkown codec type: %d", | 555 | printk(KERN_ERR "%s unknown codec type: %d", |
556 | __func__, pd->model); | 556 | __func__, pd->model); |
557 | return -EINVAL; | 557 | return -EINVAL; |
558 | } | 558 | } |
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/wm8903.c b/sound/soc/codecs/wm8903.c index b8cae1758642..ce5515e3f2b0 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -607,7 +607,7 @@ SOC_SINGLE("Right Input PGA Common Mode Switch", WM8903_ANALOGUE_RIGHT_INPUT_1, | |||
607 | SOC_SINGLE("DRC Switch", WM8903_DRC_0, 15, 1, 0), | 607 | SOC_SINGLE("DRC Switch", WM8903_DRC_0, 15, 1, 0), |
608 | SOC_ENUM("DRC Compressor Slope R0", drc_slope_r0), | 608 | SOC_ENUM("DRC Compressor Slope R0", drc_slope_r0), |
609 | SOC_ENUM("DRC Compressor Slope R1", drc_slope_r1), | 609 | SOC_ENUM("DRC Compressor Slope R1", drc_slope_r1), |
610 | SOC_SINGLE_TLV("DRC Compressor Threashold Volume", WM8903_DRC_3, 5, 124, 1, | 610 | SOC_SINGLE_TLV("DRC Compressor Threshold Volume", WM8903_DRC_3, 5, 124, 1, |
611 | drc_tlv_thresh), | 611 | drc_tlv_thresh), |
612 | SOC_SINGLE_TLV("DRC Volume", WM8903_DRC_3, 0, 30, 1, drc_tlv_amp), | 612 | SOC_SINGLE_TLV("DRC Volume", WM8903_DRC_3, 0, 30, 1, drc_tlv_amp), |
613 | SOC_SINGLE_TLV("DRC Minimum Gain Volume", WM8903_DRC_1, 2, 3, 1, drc_tlv_min), | 613 | SOC_SINGLE_TLV("DRC Minimum Gain Volume", WM8903_DRC_1, 2, 3, 1, drc_tlv_min), |
@@ -617,11 +617,11 @@ SOC_ENUM("DRC Decay Rate", drc_decay), | |||
617 | SOC_ENUM("DRC FF Delay", drc_ff_delay), | 617 | SOC_ENUM("DRC FF Delay", drc_ff_delay), |
618 | SOC_SINGLE("DRC Anticlip Switch", WM8903_DRC_0, 1, 1, 0), | 618 | SOC_SINGLE("DRC Anticlip Switch", WM8903_DRC_0, 1, 1, 0), |
619 | SOC_SINGLE("DRC QR Switch", WM8903_DRC_0, 2, 1, 0), | 619 | SOC_SINGLE("DRC QR Switch", WM8903_DRC_0, 2, 1, 0), |
620 | SOC_SINGLE_TLV("DRC QR Threashold Volume", WM8903_DRC_0, 6, 3, 0, drc_tlv_max), | 620 | SOC_SINGLE_TLV("DRC QR Threshold Volume", WM8903_DRC_0, 6, 3, 0, drc_tlv_max), |
621 | SOC_ENUM("DRC QR Decay Rate", drc_qr_decay), | 621 | SOC_ENUM("DRC QR Decay Rate", drc_qr_decay), |
622 | SOC_SINGLE("DRC Smoothing Switch", WM8903_DRC_0, 3, 1, 0), | 622 | SOC_SINGLE("DRC Smoothing Switch", WM8903_DRC_0, 3, 1, 0), |
623 | SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8903_DRC_0, 0, 1, 0), | 623 | SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8903_DRC_0, 0, 1, 0), |
624 | SOC_ENUM("DRC Smoothing Threashold", drc_smoothing), | 624 | SOC_ENUM("DRC Smoothing Threshold", drc_smoothing), |
625 | SOC_SINGLE_TLV("DRC Startup Volume", WM8903_DRC_0, 6, 18, 0, drc_tlv_startup), | 625 | SOC_SINGLE_TLV("DRC Startup Volume", WM8903_DRC_0, 6, 18, 0, drc_tlv_startup), |
626 | 626 | ||
627 | SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8903_ADC_DIGITAL_VOLUME_LEFT, | 627 | SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8903_ADC_DIGITAL_VOLUME_LEFT, |
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index 5e32f2ed5fc2..2981afae842c 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c | |||
@@ -689,7 +689,7 @@ SOC_DOUBLE_TLV("Digital Sidetone Volume", WM8993_DIGITAL_SIDE_TONE, | |||
689 | 689 | ||
690 | SOC_SINGLE("DRC Switch", WM8993_DRC_CONTROL_1, 15, 1, 0), | 690 | SOC_SINGLE("DRC Switch", WM8993_DRC_CONTROL_1, 15, 1, 0), |
691 | SOC_ENUM("DRC Path", drc_path), | 691 | SOC_ENUM("DRC Path", drc_path), |
692 | SOC_SINGLE_TLV("DRC Compressor Threashold Volume", WM8993_DRC_CONTROL_2, | 692 | SOC_SINGLE_TLV("DRC Compressor Threshold Volume", WM8993_DRC_CONTROL_2, |
693 | 2, 60, 1, drc_comp_threash), | 693 | 2, 60, 1, drc_comp_threash), |
694 | SOC_SINGLE_TLV("DRC Compressor Amplitude Volume", WM8993_DRC_CONTROL_3, | 694 | SOC_SINGLE_TLV("DRC Compressor Amplitude Volume", WM8993_DRC_CONTROL_3, |
695 | 11, 30, 1, drc_comp_amp), | 695 | 11, 30, 1, drc_comp_amp), |
@@ -709,7 +709,7 @@ SOC_SINGLE_TLV("DRC Quick Release Volume", WM8993_DRC_CONTROL_3, 2, 3, 0, | |||
709 | SOC_ENUM("DRC Quick Release Rate", drc_qr_rate), | 709 | SOC_ENUM("DRC Quick Release Rate", drc_qr_rate), |
710 | SOC_SINGLE("DRC Smoothing Switch", WM8993_DRC_CONTROL_1, 11, 1, 0), | 710 | SOC_SINGLE("DRC Smoothing Switch", WM8993_DRC_CONTROL_1, 11, 1, 0), |
711 | SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8993_DRC_CONTROL_1, 8, 1, 0), | 711 | SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8993_DRC_CONTROL_1, 8, 1, 0), |
712 | SOC_ENUM("DRC Smoothing Hysteresis Threashold", drc_smooth), | 712 | SOC_ENUM("DRC Smoothing Hysteresis Threshold", drc_smooth), |
713 | SOC_SINGLE_TLV("DRC Startup Volume", WM8993_DRC_CONTROL_4, 8, 18, 0, | 713 | SOC_SINGLE_TLV("DRC Startup Volume", WM8993_DRC_CONTROL_4, 8, 18, 0, |
714 | drc_startup_tlv), | 714 | drc_startup_tlv), |
715 | 715 | ||
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 4d74ecb0e56b..c58aab375edb 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
@@ -165,9 +165,9 @@ SOC_SINGLE("Mono Playback Switch", AC97_MASTER_TONE, 7, 1, 1), | |||
165 | SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_TONE, 6, 1, 0), | 165 | SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_TONE, 6, 1, 0), |
166 | SOC_SINGLE("Mono Playback Volume", AC97_MASTER_TONE, 0, 31, 1), | 166 | SOC_SINGLE("Mono Playback Volume", AC97_MASTER_TONE, 0, 31, 1), |
167 | 167 | ||
168 | SOC_SINGLE("PC Beep Playback Headphone Volume", AC97_AUX, 12, 7, 1), | 168 | SOC_SINGLE("Beep Playback Headphone Volume", AC97_AUX, 12, 7, 1), |
169 | SOC_SINGLE("PC Beep Playback Speaker Volume", AC97_AUX, 8, 7, 1), | 169 | SOC_SINGLE("Beep Playback Speaker Volume", AC97_AUX, 8, 7, 1), |
170 | SOC_SINGLE("PC Beep Playback Mono Volume", AC97_AUX, 4, 7, 1), | 170 | SOC_SINGLE("Beep Playback Mono Volume", AC97_AUX, 4, 7, 1), |
171 | 171 | ||
172 | SOC_SINGLE("Voice Playback Headphone Volume", AC97_PCM, 12, 7, 1), | 172 | SOC_SINGLE("Voice Playback Headphone Volume", AC97_PCM, 12, 7, 1), |
173 | SOC_SINGLE("Voice Playback Master Volume", AC97_PCM, 8, 7, 1), | 173 | SOC_SINGLE("Voice Playback Master Volume", AC97_PCM, 8, 7, 1), |
@@ -266,7 +266,7 @@ static int mixer_event(struct snd_soc_dapm_widget *w, | |||
266 | 266 | ||
267 | /* Left Headphone Mixers */ | 267 | /* Left Headphone Mixers */ |
268 | static const struct snd_kcontrol_new wm9713_hpl_mixer_controls[] = { | 268 | static const struct snd_kcontrol_new wm9713_hpl_mixer_controls[] = { |
269 | SOC_DAPM_SINGLE("PC Beep Playback Switch", HPL_MIXER, 5, 1, 0), | 269 | SOC_DAPM_SINGLE("Beep Playback Switch", HPL_MIXER, 5, 1, 0), |
270 | SOC_DAPM_SINGLE("Voice Playback Switch", HPL_MIXER, 4, 1, 0), | 270 | SOC_DAPM_SINGLE("Voice Playback Switch", HPL_MIXER, 4, 1, 0), |
271 | SOC_DAPM_SINGLE("Aux Playback Switch", HPL_MIXER, 3, 1, 0), | 271 | SOC_DAPM_SINGLE("Aux Playback Switch", HPL_MIXER, 3, 1, 0), |
272 | SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 2, 1, 0), | 272 | SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 2, 1, 0), |
@@ -276,7 +276,7 @@ SOC_DAPM_SINGLE("Bypass Playback Switch", HPL_MIXER, 0, 1, 0), | |||
276 | 276 | ||
277 | /* Right Headphone Mixers */ | 277 | /* Right Headphone Mixers */ |
278 | static const struct snd_kcontrol_new wm9713_hpr_mixer_controls[] = { | 278 | static const struct snd_kcontrol_new wm9713_hpr_mixer_controls[] = { |
279 | SOC_DAPM_SINGLE("PC Beep Playback Switch", HPR_MIXER, 5, 1, 0), | 279 | SOC_DAPM_SINGLE("Beep Playback Switch", HPR_MIXER, 5, 1, 0), |
280 | SOC_DAPM_SINGLE("Voice Playback Switch", HPR_MIXER, 4, 1, 0), | 280 | SOC_DAPM_SINGLE("Voice Playback Switch", HPR_MIXER, 4, 1, 0), |
281 | SOC_DAPM_SINGLE("Aux Playback Switch", HPR_MIXER, 3, 1, 0), | 281 | SOC_DAPM_SINGLE("Aux Playback Switch", HPR_MIXER, 3, 1, 0), |
282 | SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 2, 1, 0), | 282 | SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 2, 1, 0), |
@@ -294,7 +294,7 @@ SOC_DAPM_ENUM("Route", wm9713_enum[0]); | |||
294 | 294 | ||
295 | /* Speaker Mixer */ | 295 | /* Speaker Mixer */ |
296 | static const struct snd_kcontrol_new wm9713_speaker_mixer_controls[] = { | 296 | static const struct snd_kcontrol_new wm9713_speaker_mixer_controls[] = { |
297 | SOC_DAPM_SINGLE("PC Beep Playback Switch", AC97_AUX, 11, 1, 1), | 297 | SOC_DAPM_SINGLE("Beep Playback Switch", AC97_AUX, 11, 1, 1), |
298 | SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 11, 1, 1), | 298 | SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 11, 1, 1), |
299 | SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 11, 1, 1), | 299 | SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 11, 1, 1), |
300 | SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 14, 1, 1), | 300 | SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 14, 1, 1), |
@@ -304,7 +304,7 @@ SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 14, 1, 1), | |||
304 | 304 | ||
305 | /* Mono Mixer */ | 305 | /* Mono Mixer */ |
306 | static const struct snd_kcontrol_new wm9713_mono_mixer_controls[] = { | 306 | static const struct snd_kcontrol_new wm9713_mono_mixer_controls[] = { |
307 | SOC_DAPM_SINGLE("PC Beep Playback Switch", AC97_AUX, 7, 1, 1), | 307 | SOC_DAPM_SINGLE("Beep Playback Switch", AC97_AUX, 7, 1, 1), |
308 | SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 7, 1, 1), | 308 | SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 7, 1, 1), |
309 | SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 7, 1, 1), | 309 | SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 7, 1, 1), |
310 | SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 13, 1, 1), | 310 | SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 13, 1, 1), |
@@ -463,7 +463,7 @@ SND_SOC_DAPM_VMID("VMID"), | |||
463 | 463 | ||
464 | static const struct snd_soc_dapm_route audio_map[] = { | 464 | static const struct snd_soc_dapm_route audio_map[] = { |
465 | /* left HP mixer */ | 465 | /* left HP mixer */ |
466 | {"Left HP Mixer", "PC Beep Playback Switch", "PCBEEP"}, | 466 | {"Left HP Mixer", "Beep Playback Switch", "PCBEEP"}, |
467 | {"Left HP Mixer", "Voice Playback Switch", "Voice DAC"}, | 467 | {"Left HP Mixer", "Voice Playback Switch", "Voice DAC"}, |
468 | {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"}, | 468 | {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"}, |
469 | {"Left HP Mixer", "Bypass Playback Switch", "Left Line In"}, | 469 | {"Left HP Mixer", "Bypass Playback Switch", "Left Line In"}, |
@@ -472,7 +472,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
472 | {"Left HP Mixer", NULL, "Capture Headphone Mux"}, | 472 | {"Left HP Mixer", NULL, "Capture Headphone Mux"}, |
473 | 473 | ||
474 | /* right HP mixer */ | 474 | /* right HP mixer */ |
475 | {"Right HP Mixer", "PC Beep Playback Switch", "PCBEEP"}, | 475 | {"Right HP Mixer", "Beep Playback Switch", "PCBEEP"}, |
476 | {"Right HP Mixer", "Voice Playback Switch", "Voice DAC"}, | 476 | {"Right HP Mixer", "Voice Playback Switch", "Voice DAC"}, |
477 | {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"}, | 477 | {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"}, |
478 | {"Right HP Mixer", "Bypass Playback Switch", "Right Line In"}, | 478 | {"Right HP Mixer", "Bypass Playback Switch", "Right Line In"}, |
@@ -491,7 +491,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
491 | {"Capture Mixer", NULL, "Right Capture Source"}, | 491 | {"Capture Mixer", NULL, "Right Capture Source"}, |
492 | 492 | ||
493 | /* speaker mixer */ | 493 | /* speaker mixer */ |
494 | {"Speaker Mixer", "PC Beep Playback Switch", "PCBEEP"}, | 494 | {"Speaker Mixer", "Beep Playback Switch", "PCBEEP"}, |
495 | {"Speaker Mixer", "Voice Playback Switch", "Voice DAC"}, | 495 | {"Speaker Mixer", "Voice Playback Switch", "Voice DAC"}, |
496 | {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"}, | 496 | {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"}, |
497 | {"Speaker Mixer", "Bypass Playback Switch", "Line Mixer"}, | 497 | {"Speaker Mixer", "Bypass Playback Switch", "Line Mixer"}, |
@@ -499,7 +499,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
499 | {"Speaker Mixer", "MonoIn Playback Switch", "Mono In"}, | 499 | {"Speaker Mixer", "MonoIn Playback Switch", "Mono In"}, |
500 | 500 | ||
501 | /* mono mixer */ | 501 | /* mono mixer */ |
502 | {"Mono Mixer", "PC Beep Playback Switch", "PCBEEP"}, | 502 | {"Mono Mixer", "Beep Playback Switch", "PCBEEP"}, |
503 | {"Mono Mixer", "Voice Playback Switch", "Voice DAC"}, | 503 | {"Mono Mixer", "Voice Playback Switch", "Voice DAC"}, |
504 | {"Mono Mixer", "Aux Playback Switch", "Aux DAC"}, | 504 | {"Mono Mixer", "Aux Playback Switch", "Aux DAC"}, |
505 | {"Mono Mixer", "Bypass Playback Switch", "Line Mixer"}, | 505 | {"Mono Mixer", "Bypass Playback Switch", "Line Mixer"}, |
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index ae0fc9b135d4..b0f618e44840 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c | |||
@@ -31,8 +31,8 @@ | |||
31 | 31 | ||
32 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
33 | 33 | ||
34 | #include <mach/board-ams-delta.h> | 34 | #include <plat/board-ams-delta.h> |
35 | #include <mach/mcbsp.h> | 35 | #include <plat/mcbsp.h> |
36 | 36 | ||
37 | #include "omap-mcbsp.h" | 37 | #include "omap-mcbsp.h" |
38 | #include "omap-pcm.h" | 38 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 0a505938e42b..08e09d72790f 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
33 | #include <mach/hardware.h> | 33 | #include <mach/hardware.h> |
34 | #include <linux/gpio.h> | 34 | #include <linux/gpio.h> |
35 | #include <mach/mcbsp.h> | 35 | #include <plat/mcbsp.h> |
36 | 36 | ||
37 | #include "omap-mcbsp.h" | 37 | #include "omap-mcbsp.h" |
38 | #include "omap-pcm.h" | 38 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 45be94201c89..6bbbd2ab0ee7 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -31,9 +31,9 @@ | |||
31 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
32 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
33 | 33 | ||
34 | #include <mach/control.h> | 34 | #include <plat/control.h> |
35 | #include <mach/dma.h> | 35 | #include <plat/dma.h> |
36 | #include <mach/mcbsp.h> | 36 | #include <plat/mcbsp.h> |
37 | #include "omap-mcbsp.h" | 37 | #include "omap-mcbsp.h" |
38 | #include "omap-pcm.h" | 38 | #include "omap-pcm.h" |
39 | 39 | ||
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 6a829eef2a4f..9db2770e9640 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <sound/pcm_params.h> | 28 | #include <sound/pcm_params.h> |
29 | #include <sound/soc.h> | 29 | #include <sound/soc.h> |
30 | 30 | ||
31 | #include <mach/dma.h> | 31 | #include <plat/dma.h> |
32 | #include "omap-pcm.h" | 32 | #include "omap-pcm.h" |
33 | 33 | ||
34 | static const struct snd_pcm_hardware omap_pcm_hardware = { | 34 | static const struct snd_pcm_hardware omap_pcm_hardware = { |
diff --git a/sound/soc/omap/omap2evm.c b/sound/soc/omap/omap2evm.c index 027e1a40f8a1..c7adea38274c 100644 --- a/sound/soc/omap/omap2evm.c +++ b/sound/soc/omap/omap2evm.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
32 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
33 | #include <mach/gpio.h> | 33 | #include <mach/gpio.h> |
34 | #include <mach/mcbsp.h> | 34 | #include <plat/mcbsp.h> |
35 | 35 | ||
36 | #include "omap-mcbsp.h" | 36 | #include "omap-mcbsp.h" |
37 | #include "omap-pcm.h" | 37 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c index b0cff9f33b7e..d88ad5ca526c 100644 --- a/sound/soc/omap/omap3beagle.c +++ b/sound/soc/omap/omap3beagle.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
30 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
31 | #include <mach/gpio.h> | 31 | #include <mach/gpio.h> |
32 | #include <mach/mcbsp.h> | 32 | #include <plat/mcbsp.h> |
33 | 33 | ||
34 | #include "omap-mcbsp.h" | 34 | #include "omap-mcbsp.h" |
35 | #include "omap-pcm.h" | 35 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c index f484dcd63408..dfcb344092e4 100644 --- a/sound/soc/omap/omap3evm.c +++ b/sound/soc/omap/omap3evm.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <asm/mach-types.h> | 27 | #include <asm/mach-types.h> |
28 | #include <mach/hardware.h> | 28 | #include <mach/hardware.h> |
29 | #include <mach/gpio.h> | 29 | #include <mach/gpio.h> |
30 | #include <mach/mcbsp.h> | 30 | #include <plat/mcbsp.h> |
31 | 31 | ||
32 | #include "omap-mcbsp.h" | 32 | #include "omap-mcbsp.h" |
33 | #include "omap-pcm.h" | 33 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index a4e149b7f0eb..498ca2e03519 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
32 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
33 | #include <linux/gpio.h> | 33 | #include <linux/gpio.h> |
34 | #include <mach/mcbsp.h> | 34 | #include <plat/mcbsp.h> |
35 | 35 | ||
36 | #include "omap-mcbsp.h" | 36 | #include "omap-mcbsp.h" |
37 | #include "omap-pcm.h" | 37 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/overo.c b/sound/soc/omap/overo.c index 97a4d6308bd6..c25f5276ad6f 100644 --- a/sound/soc/omap/overo.c +++ b/sound/soc/omap/overo.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
30 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
31 | #include <mach/gpio.h> | 31 | #include <mach/gpio.h> |
32 | #include <mach/mcbsp.h> | 32 | #include <plat/mcbsp.h> |
33 | 33 | ||
34 | #include "omap-mcbsp.h" | 34 | #include "omap-mcbsp.h" |
35 | #include "omap-pcm.h" | 35 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 4a3f62d1f295..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> |
@@ -34,7 +34,7 @@ | |||
34 | #include <asm/mach-types.h> | 34 | #include <asm/mach-types.h> |
35 | #include <mach/hardware.h> | 35 | #include <mach/hardware.h> |
36 | #include <mach/gpio.h> | 36 | #include <mach/gpio.h> |
37 | #include <mach/mcbsp.h> | 37 | #include <plat/mcbsp.h> |
38 | 38 | ||
39 | #include "omap-mcbsp.h" | 39 | #include "omap-mcbsp.h" |
40 | #include "omap-pcm.h" | 40 | #include "omap-pcm.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/omap/zoom2.c b/sound/soc/omap/zoom2.c index f90b45f56220..f90a2ac888cf 100644 --- a/sound/soc/omap/zoom2.c +++ b/sound/soc/omap/zoom2.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
30 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
31 | #include <mach/gpio.h> | 31 | #include <mach/gpio.h> |
32 | #include <mach/mcbsp.h> | 32 | #include <plat/mcbsp.h> |
33 | 33 | ||
34 | #include "omap-mcbsp.h" | 34 | #include "omap-mcbsp.h" |
35 | #include "omap-pcm.h" | 35 | #include "omap-pcm.h" |
diff --git a/sound/soc/s3c24xx/s3c24xx_simtec.c b/sound/soc/s3c24xx/s3c24xx_simtec.c index 507b2ed5d58b..4984754f3298 100644 --- a/sound/soc/s3c24xx/s3c24xx_simtec.c +++ b/sound/soc/s3c24xx/s3c24xx_simtec.c | |||
@@ -270,7 +270,7 @@ static int attach_gpio_amp(struct device *dev, | |||
270 | gpio_direction_output(pd->amp_gain[1], 0); | 270 | gpio_direction_output(pd->amp_gain[1], 0); |
271 | } | 271 | } |
272 | 272 | ||
273 | /* note, curently we assume GPA0 isn't valid amp */ | 273 | /* note, currently we assume GPA0 isn't valid amp */ |
274 | if (pdata->amp_gpio > 0) { | 274 | if (pdata->amp_gpio > 0) { |
275 | ret = gpio_request(pd->amp_gpio, "gpio-amp"); | 275 | ret = gpio_request(pd->amp_gpio, "gpio-amp"); |
276 | if (ret) { | 276 | if (ret) { |
@@ -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/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c index 0eb1722f6581..1d61109e09fa 100644 --- a/sound/soc/s6000/s6000-pcm.c +++ b/sound/soc/s6000/s6000-pcm.c | |||
@@ -196,7 +196,7 @@ static int s6000_pcm_start(struct snd_pcm_substream *substream) | |||
196 | 0 /* destination skip after chunk (impossible) */, | 196 | 0 /* destination skip after chunk (impossible) */, |
197 | 4 /* 16 byte burst size */, | 197 | 4 /* 16 byte burst size */, |
198 | -1 /* don't conserve bandwidth */, | 198 | -1 /* don't conserve bandwidth */, |
199 | 0 /* low watermark irq descriptor theshold */, | 199 | 0 /* low watermark irq descriptor threshold */, |
200 | 0 /* disable hardware timestamps */, | 200 | 0 /* disable hardware timestamps */, |
201 | 1 /* enable channel */); | 201 | 1 /* enable channel */); |
202 | 202 | ||
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/sound_core.c b/sound/sound_core.c index 49c998186592..dbca7c909a31 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c | |||
@@ -353,7 +353,7 @@ static struct sound_unit *chains[SOUND_STEP]; | |||
353 | * @dev: device pointer | 353 | * @dev: device pointer |
354 | * | 354 | * |
355 | * Allocate a special sound device by minor number from the sound | 355 | * Allocate a special sound device by minor number from the sound |
356 | * subsystem. The allocated number is returned on succes. On failure | 356 | * subsystem. The allocated number is returned on success. On failure |
357 | * a negative error code is returned. | 357 | * a negative error code is returned. |
358 | */ | 358 | */ |
359 | 359 | ||
diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 63c8f45c0c22..67c91230c197 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c | |||
@@ -374,7 +374,7 @@ sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) | |||
374 | 374 | ||
375 | 375 | ||
376 | /* | 376 | /* |
377 | * increment sample couter | 377 | * increment sample counter |
378 | */ | 378 | */ |
379 | static void | 379 | static void |
380 | set_sample_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, | 380 | set_sample_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, |
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 8db0374e10d5..4963defee18a 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -752,7 +752,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s | |||
752 | return 0; /* already large enough */ | 752 | return 0; /* already large enough */ |
753 | vfree(runtime->dma_area); | 753 | vfree(runtime->dma_area); |
754 | } | 754 | } |
755 | runtime->dma_area = vmalloc(size); | 755 | runtime->dma_area = vmalloc_user(size); |
756 | if (!runtime->dma_area) | 756 | if (!runtime->dma_area) |
757 | return -ENOMEM; | 757 | return -ENOMEM; |
758 | runtime->dma_bytes = size; | 758 | runtime->dma_bytes = size; |
@@ -2893,7 +2893,9 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) | |||
2893 | if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || | 2893 | if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || |
2894 | altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && | 2894 | altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && |
2895 | altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { | 2895 | altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { |
2896 | if (snd_usb_create_midi_interface(chip, iface, NULL) < 0) { | 2896 | int err = snd_usbmidi_create(chip->card, iface, |
2897 | &chip->midi_list, NULL); | ||
2898 | if (err < 0) { | ||
2897 | snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); | 2899 | snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); |
2898 | continue; | 2900 | continue; |
2899 | } | 2901 | } |
@@ -3038,12 +3040,11 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, | |||
3038 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 3040 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
3039 | .data = &uaxx_ep | 3041 | .data = &uaxx_ep |
3040 | }; | 3042 | }; |
3041 | if (chip->usb_id == USB_ID(0x0582, 0x002b)) | 3043 | const struct snd_usb_audio_quirk *quirk = |
3042 | return snd_usb_create_midi_interface(chip, iface, | 3044 | chip->usb_id == USB_ID(0x0582, 0x002b) |
3043 | &ua700_quirk); | 3045 | ? &ua700_quirk : &uaxx_quirk; |
3044 | else | 3046 | return snd_usbmidi_create(chip->card, iface, |
3045 | return snd_usb_create_midi_interface(chip, iface, | 3047 | &chip->midi_list, quirk); |
3046 | &uaxx_quirk); | ||
3047 | } | 3048 | } |
3048 | 3049 | ||
3049 | if (altsd->bNumEndpoints != 1) | 3050 | if (altsd->bNumEndpoints != 1) |
@@ -3370,6 +3371,13 @@ static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, | |||
3370 | return 0; /* keep this altsetting */ | 3371 | return 0; /* keep this altsetting */ |
3371 | } | 3372 | } |
3372 | 3373 | ||
3374 | static int create_any_midi_quirk(struct snd_usb_audio *chip, | ||
3375 | struct usb_interface *intf, | ||
3376 | const struct snd_usb_audio_quirk *quirk) | ||
3377 | { | ||
3378 | return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk); | ||
3379 | } | ||
3380 | |||
3373 | /* | 3381 | /* |
3374 | * audio-interface quirks | 3382 | * audio-interface quirks |
3375 | * | 3383 | * |
@@ -3387,14 +3395,14 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip, | |||
3387 | static const quirk_func_t quirk_funcs[] = { | 3395 | static const quirk_func_t quirk_funcs[] = { |
3388 | [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, | 3396 | [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, |
3389 | [QUIRK_COMPOSITE] = create_composite_quirk, | 3397 | [QUIRK_COMPOSITE] = create_composite_quirk, |
3390 | [QUIRK_MIDI_STANDARD_INTERFACE] = snd_usb_create_midi_interface, | 3398 | [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk, |
3391 | [QUIRK_MIDI_FIXED_ENDPOINT] = snd_usb_create_midi_interface, | 3399 | [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk, |
3392 | [QUIRK_MIDI_YAMAHA] = snd_usb_create_midi_interface, | 3400 | [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk, |
3393 | [QUIRK_MIDI_MIDIMAN] = snd_usb_create_midi_interface, | 3401 | [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk, |
3394 | [QUIRK_MIDI_NOVATION] = snd_usb_create_midi_interface, | 3402 | [QUIRK_MIDI_NOVATION] = create_any_midi_quirk, |
3395 | [QUIRK_MIDI_FASTLANE] = snd_usb_create_midi_interface, | 3403 | [QUIRK_MIDI_FASTLANE] = create_any_midi_quirk, |
3396 | [QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface, | 3404 | [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk, |
3397 | [QUIRK_MIDI_CME] = snd_usb_create_midi_interface, | 3405 | [QUIRK_MIDI_CME] = create_any_midi_quirk, |
3398 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, | 3406 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, |
3399 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, | 3407 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, |
3400 | [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, | 3408 | [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 8e7f78941ba6..40ba8115fb81 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
@@ -132,7 +132,6 @@ struct snd_usb_audio { | |||
132 | int pcm_devs; | 132 | int pcm_devs; |
133 | 133 | ||
134 | struct list_head midi_list; /* list of midi interfaces */ | 134 | struct list_head midi_list; /* list of midi interfaces */ |
135 | int next_midi_device; | ||
136 | 135 | ||
137 | struct list_head mixer_list; /* list of mixer interfaces */ | 136 | struct list_head mixer_list; /* list of mixer interfaces */ |
138 | }; | 137 | }; |
@@ -210,7 +209,7 @@ struct snd_usb_midi_endpoint_info { | |||
210 | /* | 209 | /* |
211 | */ | 210 | */ |
212 | 211 | ||
213 | #define combine_word(s) ((*s) | ((unsigned int)(s)[1] << 8)) | 212 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) |
214 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) | 213 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) |
215 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) | 214 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) |
216 | 215 | ||
@@ -227,8 +226,10 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
227 | int ignore_error); | 226 | int ignore_error); |
228 | void snd_usb_mixer_disconnect(struct list_head *p); | 227 | void snd_usb_mixer_disconnect(struct list_head *p); |
229 | 228 | ||
230 | int snd_usb_create_midi_interface(struct snd_usb_audio *chip, struct usb_interface *iface, | 229 | int snd_usbmidi_create(struct snd_card *card, |
231 | const struct snd_usb_audio_quirk *quirk); | 230 | struct usb_interface *iface, |
231 | struct list_head *midi_list, | ||
232 | const struct snd_usb_audio_quirk *quirk); | ||
232 | void snd_usbmidi_input_stop(struct list_head* p); | 233 | void snd_usbmidi_input_stop(struct list_head* p); |
233 | void snd_usbmidi_input_start(struct list_head* p); | 234 | void snd_usbmidi_input_start(struct list_head* p); |
234 | void snd_usbmidi_disconnect(struct list_head *p); | 235 | void snd_usbmidi_disconnect(struct list_head *p); |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 0eff19ceb7e1..6e89b8368d9a 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * usbmidi.c - ALSA USB MIDI driver | 2 | * usbmidi.c - ALSA USB MIDI driver |
3 | * | 3 | * |
4 | * Copyright (c) 2002-2007 Clemens Ladisch | 4 | * Copyright (c) 2002-2009 Clemens Ladisch |
5 | * All rights reserved. | 5 | * All rights reserved. |
6 | * | 6 | * |
7 | * Based on the OSS usb-midi driver by NAGANO Daisuke, | 7 | * Based on the OSS usb-midi driver by NAGANO Daisuke, |
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/usb.h> | 47 | #include <linux/usb.h> |
48 | #include <linux/wait.h> | 48 | #include <linux/wait.h> |
49 | #include <sound/core.h> | 49 | #include <sound/core.h> |
50 | #include <sound/control.h> | ||
50 | #include <sound/rawmidi.h> | 51 | #include <sound/rawmidi.h> |
51 | #include <sound/asequencer.h> | 52 | #include <sound/asequencer.h> |
52 | #include "usbaudio.h" | 53 | #include "usbaudio.h" |
@@ -101,7 +102,8 @@ struct usb_protocol_ops { | |||
101 | }; | 102 | }; |
102 | 103 | ||
103 | struct snd_usb_midi { | 104 | struct snd_usb_midi { |
104 | struct snd_usb_audio *chip; | 105 | struct usb_device *dev; |
106 | struct snd_card *card; | ||
105 | struct usb_interface *iface; | 107 | struct usb_interface *iface; |
106 | const struct snd_usb_audio_quirk *quirk; | 108 | const struct snd_usb_audio_quirk *quirk; |
107 | struct snd_rawmidi *rmidi; | 109 | struct snd_rawmidi *rmidi; |
@@ -109,13 +111,19 @@ struct snd_usb_midi { | |||
109 | struct list_head list; | 111 | struct list_head list; |
110 | struct timer_list error_timer; | 112 | struct timer_list error_timer; |
111 | spinlock_t disc_lock; | 113 | spinlock_t disc_lock; |
114 | struct mutex mutex; | ||
115 | u32 usb_id; | ||
116 | int next_midi_device; | ||
112 | 117 | ||
113 | struct snd_usb_midi_endpoint { | 118 | struct snd_usb_midi_endpoint { |
114 | struct snd_usb_midi_out_endpoint *out; | 119 | struct snd_usb_midi_out_endpoint *out; |
115 | struct snd_usb_midi_in_endpoint *in; | 120 | struct snd_usb_midi_in_endpoint *in; |
116 | } endpoints[MIDI_MAX_ENDPOINTS]; | 121 | } endpoints[MIDI_MAX_ENDPOINTS]; |
117 | unsigned long input_triggered; | 122 | unsigned long input_triggered; |
123 | unsigned int opened; | ||
118 | unsigned char disconnected; | 124 | unsigned char disconnected; |
125 | |||
126 | struct snd_kcontrol *roland_load_ctl; | ||
119 | }; | 127 | }; |
120 | 128 | ||
121 | struct snd_usb_midi_out_endpoint { | 129 | struct snd_usb_midi_out_endpoint { |
@@ -255,7 +263,7 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb) | |||
255 | } | 263 | } |
256 | } | 264 | } |
257 | 265 | ||
258 | urb->dev = ep->umidi->chip->dev; | 266 | urb->dev = ep->umidi->dev; |
259 | snd_usbmidi_submit_urb(urb, GFP_ATOMIC); | 267 | snd_usbmidi_submit_urb(urb, GFP_ATOMIC); |
260 | } | 268 | } |
261 | 269 | ||
@@ -296,7 +304,7 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) | |||
296 | unsigned long flags; | 304 | unsigned long flags; |
297 | 305 | ||
298 | spin_lock_irqsave(&ep->buffer_lock, flags); | 306 | spin_lock_irqsave(&ep->buffer_lock, flags); |
299 | if (ep->umidi->chip->shutdown) { | 307 | if (ep->umidi->disconnected) { |
300 | spin_unlock_irqrestore(&ep->buffer_lock, flags); | 308 | spin_unlock_irqrestore(&ep->buffer_lock, flags); |
301 | return; | 309 | return; |
302 | } | 310 | } |
@@ -312,7 +320,7 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) | |||
312 | 320 | ||
313 | dump_urb("sending", urb->transfer_buffer, | 321 | dump_urb("sending", urb->transfer_buffer, |
314 | urb->transfer_buffer_length); | 322 | urb->transfer_buffer_length); |
315 | urb->dev = ep->umidi->chip->dev; | 323 | urb->dev = ep->umidi->dev; |
316 | if (snd_usbmidi_submit_urb(urb, GFP_ATOMIC) < 0) | 324 | if (snd_usbmidi_submit_urb(urb, GFP_ATOMIC) < 0) |
317 | break; | 325 | break; |
318 | ep->active_urbs |= 1 << urb_index; | 326 | ep->active_urbs |= 1 << urb_index; |
@@ -349,7 +357,7 @@ static void snd_usbmidi_error_timer(unsigned long data) | |||
349 | if (in && in->error_resubmit) { | 357 | if (in && in->error_resubmit) { |
350 | in->error_resubmit = 0; | 358 | in->error_resubmit = 0; |
351 | for (j = 0; j < INPUT_URBS; ++j) { | 359 | for (j = 0; j < INPUT_URBS; ++j) { |
352 | in->urbs[j]->dev = umidi->chip->dev; | 360 | in->urbs[j]->dev = umidi->dev; |
353 | snd_usbmidi_submit_urb(in->urbs[j], GFP_ATOMIC); | 361 | snd_usbmidi_submit_urb(in->urbs[j], GFP_ATOMIC); |
354 | } | 362 | } |
355 | } | 363 | } |
@@ -369,7 +377,7 @@ static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep, | |||
369 | return -ENOMEM; | 377 | return -ENOMEM; |
370 | dump_urb("sending", buf, len); | 378 | dump_urb("sending", buf, len); |
371 | if (ep->urbs[0].urb) | 379 | if (ep->urbs[0].urb) |
372 | err = usb_bulk_msg(ep->umidi->chip->dev, ep->urbs[0].urb->pipe, | 380 | err = usb_bulk_msg(ep->umidi->dev, ep->urbs[0].urb->pipe, |
373 | buf, len, NULL, 250); | 381 | buf, len, NULL, 250); |
374 | kfree(buf); | 382 | kfree(buf); |
375 | return err; | 383 | return err; |
@@ -724,8 +732,7 @@ static void snd_usbmidi_us122l_output(struct snd_usb_midi_out_endpoint *ep, | |||
724 | 732 | ||
725 | if (!ep->ports[0].active) | 733 | if (!ep->ports[0].active) |
726 | return; | 734 | return; |
727 | count = snd_usb_get_speed(ep->umidi->chip->dev) == USB_SPEED_HIGH | 735 | count = snd_usb_get_speed(ep->umidi->dev) == USB_SPEED_HIGH ? 1 : 2; |
728 | ? 1 : 2; | ||
729 | count = snd_rawmidi_transmit(ep->ports[0].substream, | 736 | count = snd_rawmidi_transmit(ep->ports[0].substream, |
730 | urb->transfer_buffer, | 737 | urb->transfer_buffer, |
731 | count); | 738 | count); |
@@ -879,6 +886,50 @@ static struct usb_protocol_ops snd_usbmidi_emagic_ops = { | |||
879 | }; | 886 | }; |
880 | 887 | ||
881 | 888 | ||
889 | static void update_roland_altsetting(struct snd_usb_midi* umidi) | ||
890 | { | ||
891 | struct usb_interface *intf; | ||
892 | struct usb_host_interface *hostif; | ||
893 | struct usb_interface_descriptor *intfd; | ||
894 | int is_light_load; | ||
895 | |||
896 | intf = umidi->iface; | ||
897 | is_light_load = intf->cur_altsetting != intf->altsetting; | ||
898 | if (umidi->roland_load_ctl->private_value == is_light_load) | ||
899 | return; | ||
900 | hostif = &intf->altsetting[umidi->roland_load_ctl->private_value]; | ||
901 | intfd = get_iface_desc(hostif); | ||
902 | snd_usbmidi_input_stop(&umidi->list); | ||
903 | usb_set_interface(umidi->dev, intfd->bInterfaceNumber, | ||
904 | intfd->bAlternateSetting); | ||
905 | snd_usbmidi_input_start(&umidi->list); | ||
906 | } | ||
907 | |||
908 | static void substream_open(struct snd_rawmidi_substream *substream, int open) | ||
909 | { | ||
910 | struct snd_usb_midi* umidi = substream->rmidi->private_data; | ||
911 | struct snd_kcontrol *ctl; | ||
912 | |||
913 | mutex_lock(&umidi->mutex); | ||
914 | if (open) { | ||
915 | if (umidi->opened++ == 0 && umidi->roland_load_ctl) { | ||
916 | ctl = umidi->roland_load_ctl; | ||
917 | ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; | ||
918 | snd_ctl_notify(umidi->card, | ||
919 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | ||
920 | update_roland_altsetting(umidi); | ||
921 | } | ||
922 | } else { | ||
923 | if (--umidi->opened == 0 && umidi->roland_load_ctl) { | ||
924 | ctl = umidi->roland_load_ctl; | ||
925 | ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; | ||
926 | snd_ctl_notify(umidi->card, | ||
927 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | ||
928 | } | ||
929 | } | ||
930 | mutex_unlock(&umidi->mutex); | ||
931 | } | ||
932 | |||
882 | static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) | 933 | static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) |
883 | { | 934 | { |
884 | struct snd_usb_midi* umidi = substream->rmidi->private_data; | 935 | struct snd_usb_midi* umidi = substream->rmidi->private_data; |
@@ -898,11 +949,13 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) | |||
898 | } | 949 | } |
899 | substream->runtime->private_data = port; | 950 | substream->runtime->private_data = port; |
900 | port->state = STATE_UNKNOWN; | 951 | port->state = STATE_UNKNOWN; |
952 | substream_open(substream, 1); | ||
901 | return 0; | 953 | return 0; |
902 | } | 954 | } |
903 | 955 | ||
904 | static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) | 956 | static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) |
905 | { | 957 | { |
958 | substream_open(substream, 0); | ||
906 | return 0; | 959 | return 0; |
907 | } | 960 | } |
908 | 961 | ||
@@ -912,7 +965,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, | |||
912 | 965 | ||
913 | port->active = up; | 966 | port->active = up; |
914 | if (up) { | 967 | if (up) { |
915 | if (port->ep->umidi->chip->shutdown) { | 968 | if (port->ep->umidi->disconnected) { |
916 | /* gobble up remaining bytes to prevent wait in | 969 | /* gobble up remaining bytes to prevent wait in |
917 | * snd_rawmidi_drain_output */ | 970 | * snd_rawmidi_drain_output */ |
918 | while (!snd_rawmidi_transmit_empty(substream)) | 971 | while (!snd_rawmidi_transmit_empty(substream)) |
@@ -954,11 +1007,13 @@ static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream) | |||
954 | 1007 | ||
955 | static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream) | 1008 | static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream) |
956 | { | 1009 | { |
1010 | substream_open(substream, 1); | ||
957 | return 0; | 1011 | return 0; |
958 | } | 1012 | } |
959 | 1013 | ||
960 | static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream) | 1014 | static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream) |
961 | { | 1015 | { |
1016 | substream_open(substream, 0); | ||
962 | return 0; | 1017 | return 0; |
963 | } | 1018 | } |
964 | 1019 | ||
@@ -988,7 +1043,7 @@ static struct snd_rawmidi_ops snd_usbmidi_input_ops = { | |||
988 | static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb, | 1043 | static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb, |
989 | unsigned int buffer_length) | 1044 | unsigned int buffer_length) |
990 | { | 1045 | { |
991 | usb_buffer_free(umidi->chip->dev, buffer_length, | 1046 | usb_buffer_free(umidi->dev, buffer_length, |
992 | urb->transfer_buffer, urb->transfer_dma); | 1047 | urb->transfer_buffer, urb->transfer_dma); |
993 | usb_free_urb(urb); | 1048 | usb_free_urb(urb); |
994 | } | 1049 | } |
@@ -1035,24 +1090,24 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi, | |||
1035 | } | 1090 | } |
1036 | } | 1091 | } |
1037 | if (ep_info->in_interval) | 1092 | if (ep_info->in_interval) |
1038 | pipe = usb_rcvintpipe(umidi->chip->dev, ep_info->in_ep); | 1093 | pipe = usb_rcvintpipe(umidi->dev, ep_info->in_ep); |
1039 | else | 1094 | else |
1040 | pipe = usb_rcvbulkpipe(umidi->chip->dev, ep_info->in_ep); | 1095 | pipe = usb_rcvbulkpipe(umidi->dev, ep_info->in_ep); |
1041 | length = usb_maxpacket(umidi->chip->dev, pipe, 0); | 1096 | length = usb_maxpacket(umidi->dev, pipe, 0); |
1042 | for (i = 0; i < INPUT_URBS; ++i) { | 1097 | for (i = 0; i < INPUT_URBS; ++i) { |
1043 | buffer = usb_buffer_alloc(umidi->chip->dev, length, GFP_KERNEL, | 1098 | buffer = usb_buffer_alloc(umidi->dev, length, GFP_KERNEL, |
1044 | &ep->urbs[i]->transfer_dma); | 1099 | &ep->urbs[i]->transfer_dma); |
1045 | if (!buffer) { | 1100 | if (!buffer) { |
1046 | snd_usbmidi_in_endpoint_delete(ep); | 1101 | snd_usbmidi_in_endpoint_delete(ep); |
1047 | return -ENOMEM; | 1102 | return -ENOMEM; |
1048 | } | 1103 | } |
1049 | if (ep_info->in_interval) | 1104 | if (ep_info->in_interval) |
1050 | usb_fill_int_urb(ep->urbs[i], umidi->chip->dev, | 1105 | usb_fill_int_urb(ep->urbs[i], umidi->dev, |
1051 | pipe, buffer, length, | 1106 | pipe, buffer, length, |
1052 | snd_usbmidi_in_urb_complete, | 1107 | snd_usbmidi_in_urb_complete, |
1053 | ep, ep_info->in_interval); | 1108 | ep, ep_info->in_interval); |
1054 | else | 1109 | else |
1055 | usb_fill_bulk_urb(ep->urbs[i], umidi->chip->dev, | 1110 | usb_fill_bulk_urb(ep->urbs[i], umidi->dev, |
1056 | pipe, buffer, length, | 1111 | pipe, buffer, length, |
1057 | snd_usbmidi_in_urb_complete, ep); | 1112 | snd_usbmidi_in_urb_complete, ep); |
1058 | ep->urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | 1113 | ep->urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; |
@@ -1062,15 +1117,6 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi, | |||
1062 | return 0; | 1117 | return 0; |
1063 | } | 1118 | } |
1064 | 1119 | ||
1065 | static unsigned int snd_usbmidi_count_bits(unsigned int x) | ||
1066 | { | ||
1067 | unsigned int bits; | ||
1068 | |||
1069 | for (bits = 0; x; ++bits) | ||
1070 | x &= x - 1; | ||
1071 | return bits; | ||
1072 | } | ||
1073 | |||
1074 | /* | 1120 | /* |
1075 | * Frees an output endpoint. | 1121 | * Frees an output endpoint. |
1076 | * May be called when ep hasn't been initialized completely. | 1122 | * May be called when ep hasn't been initialized completely. |
@@ -1113,15 +1159,15 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, | |||
1113 | ep->urbs[i].ep = ep; | 1159 | ep->urbs[i].ep = ep; |
1114 | } | 1160 | } |
1115 | if (ep_info->out_interval) | 1161 | if (ep_info->out_interval) |
1116 | pipe = usb_sndintpipe(umidi->chip->dev, ep_info->out_ep); | 1162 | pipe = usb_sndintpipe(umidi->dev, ep_info->out_ep); |
1117 | else | 1163 | else |
1118 | pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); | 1164 | pipe = usb_sndbulkpipe(umidi->dev, ep_info->out_ep); |
1119 | if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */ | 1165 | if (umidi->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */ |
1120 | ep->max_transfer = 4; | 1166 | ep->max_transfer = 4; |
1121 | else | 1167 | else |
1122 | ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); | 1168 | ep->max_transfer = usb_maxpacket(umidi->dev, pipe, 1); |
1123 | for (i = 0; i < OUTPUT_URBS; ++i) { | 1169 | for (i = 0; i < OUTPUT_URBS; ++i) { |
1124 | buffer = usb_buffer_alloc(umidi->chip->dev, | 1170 | buffer = usb_buffer_alloc(umidi->dev, |
1125 | ep->max_transfer, GFP_KERNEL, | 1171 | ep->max_transfer, GFP_KERNEL, |
1126 | &ep->urbs[i].urb->transfer_dma); | 1172 | &ep->urbs[i].urb->transfer_dma); |
1127 | if (!buffer) { | 1173 | if (!buffer) { |
@@ -1129,12 +1175,12 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, | |||
1129 | return -ENOMEM; | 1175 | return -ENOMEM; |
1130 | } | 1176 | } |
1131 | if (ep_info->out_interval) | 1177 | if (ep_info->out_interval) |
1132 | usb_fill_int_urb(ep->urbs[i].urb, umidi->chip->dev, | 1178 | usb_fill_int_urb(ep->urbs[i].urb, umidi->dev, |
1133 | pipe, buffer, ep->max_transfer, | 1179 | pipe, buffer, ep->max_transfer, |
1134 | snd_usbmidi_out_urb_complete, | 1180 | snd_usbmidi_out_urb_complete, |
1135 | &ep->urbs[i], ep_info->out_interval); | 1181 | &ep->urbs[i], ep_info->out_interval); |
1136 | else | 1182 | else |
1137 | usb_fill_bulk_urb(ep->urbs[i].urb, umidi->chip->dev, | 1183 | usb_fill_bulk_urb(ep->urbs[i].urb, umidi->dev, |
1138 | pipe, buffer, ep->max_transfer, | 1184 | pipe, buffer, ep->max_transfer, |
1139 | snd_usbmidi_out_urb_complete, | 1185 | snd_usbmidi_out_urb_complete, |
1140 | &ep->urbs[i]); | 1186 | &ep->urbs[i]); |
@@ -1172,6 +1218,7 @@ static void snd_usbmidi_free(struct snd_usb_midi* umidi) | |||
1172 | if (ep->in) | 1218 | if (ep->in) |
1173 | snd_usbmidi_in_endpoint_delete(ep->in); | 1219 | snd_usbmidi_in_endpoint_delete(ep->in); |
1174 | } | 1220 | } |
1221 | mutex_destroy(&umidi->mutex); | ||
1175 | kfree(umidi); | 1222 | kfree(umidi); |
1176 | } | 1223 | } |
1177 | 1224 | ||
@@ -1367,7 +1414,7 @@ static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number) | |||
1367 | int i; | 1414 | int i; |
1368 | 1415 | ||
1369 | for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_info); ++i) { | 1416 | for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_info); ++i) { |
1370 | if (snd_usbmidi_port_info[i].id == umidi->chip->usb_id && | 1417 | if (snd_usbmidi_port_info[i].id == umidi->usb_id && |
1371 | snd_usbmidi_port_info[i].port == number) | 1418 | snd_usbmidi_port_info[i].port == number) |
1372 | return &snd_usbmidi_port_info[i]; | 1419 | return &snd_usbmidi_port_info[i]; |
1373 | } | 1420 | } |
@@ -1405,7 +1452,7 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi, | |||
1405 | port_info = find_port_info(umidi, number); | 1452 | port_info = find_port_info(umidi, number); |
1406 | name_format = port_info ? port_info->name : "%s MIDI %d"; | 1453 | name_format = port_info ? port_info->name : "%s MIDI %d"; |
1407 | snprintf(substream->name, sizeof(substream->name), | 1454 | snprintf(substream->name, sizeof(substream->name), |
1408 | name_format, umidi->chip->card->shortname, number + 1); | 1455 | name_format, umidi->card->shortname, number + 1); |
1409 | 1456 | ||
1410 | *rsubstream = substream; | 1457 | *rsubstream = substream; |
1411 | } | 1458 | } |
@@ -1503,7 +1550,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, | |||
1503 | endpoints[epidx].out_ep = usb_endpoint_num(ep); | 1550 | endpoints[epidx].out_ep = usb_endpoint_num(ep); |
1504 | if (usb_endpoint_xfer_int(ep)) | 1551 | if (usb_endpoint_xfer_int(ep)) |
1505 | endpoints[epidx].out_interval = ep->bInterval; | 1552 | endpoints[epidx].out_interval = ep->bInterval; |
1506 | else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW) | 1553 | else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW) |
1507 | /* | 1554 | /* |
1508 | * Low speed bulk transfers don't exist, so | 1555 | * Low speed bulk transfers don't exist, so |
1509 | * force interrupt transfers for devices like | 1556 | * force interrupt transfers for devices like |
@@ -1523,7 +1570,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, | |||
1523 | endpoints[epidx].in_ep = usb_endpoint_num(ep); | 1570 | endpoints[epidx].in_ep = usb_endpoint_num(ep); |
1524 | if (usb_endpoint_xfer_int(ep)) | 1571 | if (usb_endpoint_xfer_int(ep)) |
1525 | endpoints[epidx].in_interval = ep->bInterval; | 1572 | endpoints[epidx].in_interval = ep->bInterval; |
1526 | else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW) | 1573 | else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW) |
1527 | endpoints[epidx].in_interval = 1; | 1574 | endpoints[epidx].in_interval = 1; |
1528 | endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; | 1575 | endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; |
1529 | snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n", | 1576 | snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n", |
@@ -1533,6 +1580,52 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, | |||
1533 | return 0; | 1580 | return 0; |
1534 | } | 1581 | } |
1535 | 1582 | ||
1583 | static int roland_load_info(struct snd_kcontrol *kcontrol, | ||
1584 | struct snd_ctl_elem_info *info) | ||
1585 | { | ||
1586 | static const char *const names[] = { "High Load", "Light Load" }; | ||
1587 | |||
1588 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1589 | info->count = 1; | ||
1590 | info->value.enumerated.items = 2; | ||
1591 | if (info->value.enumerated.item > 1) | ||
1592 | info->value.enumerated.item = 1; | ||
1593 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
1594 | return 0; | ||
1595 | } | ||
1596 | |||
1597 | static int roland_load_get(struct snd_kcontrol *kcontrol, | ||
1598 | struct snd_ctl_elem_value *value) | ||
1599 | { | ||
1600 | value->value.enumerated.item[0] = kcontrol->private_value; | ||
1601 | return 0; | ||
1602 | } | ||
1603 | |||
1604 | static int roland_load_put(struct snd_kcontrol *kcontrol, | ||
1605 | struct snd_ctl_elem_value *value) | ||
1606 | { | ||
1607 | struct snd_usb_midi* umidi = kcontrol->private_data; | ||
1608 | int changed; | ||
1609 | |||
1610 | if (value->value.enumerated.item[0] > 1) | ||
1611 | return -EINVAL; | ||
1612 | mutex_lock(&umidi->mutex); | ||
1613 | changed = value->value.enumerated.item[0] != kcontrol->private_value; | ||
1614 | if (changed) | ||
1615 | kcontrol->private_value = value->value.enumerated.item[0]; | ||
1616 | mutex_unlock(&umidi->mutex); | ||
1617 | return changed; | ||
1618 | } | ||
1619 | |||
1620 | static struct snd_kcontrol_new roland_load_ctl = { | ||
1621 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1622 | .name = "MIDI Input Mode", | ||
1623 | .info = roland_load_info, | ||
1624 | .get = roland_load_get, | ||
1625 | .put = roland_load_put, | ||
1626 | .private_value = 1, | ||
1627 | }; | ||
1628 | |||
1536 | /* | 1629 | /* |
1537 | * On Roland devices, use the second alternate setting to be able to use | 1630 | * On Roland devices, use the second alternate setting to be able to use |
1538 | * the interrupt input endpoint. | 1631 | * the interrupt input endpoint. |
@@ -1556,8 +1649,12 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi) | |||
1556 | 1649 | ||
1557 | snd_printdd(KERN_INFO "switching to altsetting %d with int ep\n", | 1650 | snd_printdd(KERN_INFO "switching to altsetting %d with int ep\n", |
1558 | intfd->bAlternateSetting); | 1651 | intfd->bAlternateSetting); |
1559 | usb_set_interface(umidi->chip->dev, intfd->bInterfaceNumber, | 1652 | usb_set_interface(umidi->dev, intfd->bInterfaceNumber, |
1560 | intfd->bAlternateSetting); | 1653 | intfd->bAlternateSetting); |
1654 | |||
1655 | umidi->roland_load_ctl = snd_ctl_new1(&roland_load_ctl, umidi); | ||
1656 | if (snd_ctl_add(umidi->card, umidi->roland_load_ctl) < 0) | ||
1657 | umidi->roland_load_ctl = NULL; | ||
1561 | } | 1658 | } |
1562 | 1659 | ||
1563 | /* | 1660 | /* |
@@ -1573,7 +1670,7 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi, | |||
1573 | struct usb_endpoint_descriptor* epd; | 1670 | struct usb_endpoint_descriptor* epd; |
1574 | int i, out_eps = 0, in_eps = 0; | 1671 | int i, out_eps = 0, in_eps = 0; |
1575 | 1672 | ||
1576 | if (USB_ID_VENDOR(umidi->chip->usb_id) == 0x0582) | 1673 | if (USB_ID_VENDOR(umidi->usb_id) == 0x0582) |
1577 | snd_usbmidi_switch_roland_altsetting(umidi); | 1674 | snd_usbmidi_switch_roland_altsetting(umidi); |
1578 | 1675 | ||
1579 | if (endpoint[0].out_ep || endpoint[0].in_ep) | 1676 | if (endpoint[0].out_ep || endpoint[0].in_ep) |
@@ -1760,12 +1857,12 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi, | |||
1760 | struct snd_rawmidi *rmidi; | 1857 | struct snd_rawmidi *rmidi; |
1761 | int err; | 1858 | int err; |
1762 | 1859 | ||
1763 | err = snd_rawmidi_new(umidi->chip->card, "USB MIDI", | 1860 | err = snd_rawmidi_new(umidi->card, "USB MIDI", |
1764 | umidi->chip->next_midi_device++, | 1861 | umidi->next_midi_device++, |
1765 | out_ports, in_ports, &rmidi); | 1862 | out_ports, in_ports, &rmidi); |
1766 | if (err < 0) | 1863 | if (err < 0) |
1767 | return err; | 1864 | return err; |
1768 | strcpy(rmidi->name, umidi->chip->card->shortname); | 1865 | strcpy(rmidi->name, umidi->card->shortname); |
1769 | rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | | 1866 | rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | |
1770 | SNDRV_RAWMIDI_INFO_INPUT | | 1867 | SNDRV_RAWMIDI_INFO_INPUT | |
1771 | SNDRV_RAWMIDI_INFO_DUPLEX; | 1868 | SNDRV_RAWMIDI_INFO_DUPLEX; |
@@ -1804,7 +1901,7 @@ static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) | |||
1804 | return; | 1901 | return; |
1805 | for (i = 0; i < INPUT_URBS; ++i) { | 1902 | for (i = 0; i < INPUT_URBS; ++i) { |
1806 | struct urb* urb = ep->urbs[i]; | 1903 | struct urb* urb = ep->urbs[i]; |
1807 | urb->dev = ep->umidi->chip->dev; | 1904 | urb->dev = ep->umidi->dev; |
1808 | snd_usbmidi_submit_urb(urb, GFP_KERNEL); | 1905 | snd_usbmidi_submit_urb(urb, GFP_KERNEL); |
1809 | } | 1906 | } |
1810 | } | 1907 | } |
@@ -1825,9 +1922,10 @@ void snd_usbmidi_input_start(struct list_head* p) | |||
1825 | /* | 1922 | /* |
1826 | * Creates and registers everything needed for a MIDI streaming interface. | 1923 | * Creates and registers everything needed for a MIDI streaming interface. |
1827 | */ | 1924 | */ |
1828 | int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | 1925 | int snd_usbmidi_create(struct snd_card *card, |
1829 | struct usb_interface* iface, | 1926 | struct usb_interface* iface, |
1830 | const struct snd_usb_audio_quirk* quirk) | 1927 | struct list_head *midi_list, |
1928 | const struct snd_usb_audio_quirk* quirk) | ||
1831 | { | 1929 | { |
1832 | struct snd_usb_midi* umidi; | 1930 | struct snd_usb_midi* umidi; |
1833 | struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS]; | 1931 | struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS]; |
@@ -1837,12 +1935,16 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | |||
1837 | umidi = kzalloc(sizeof(*umidi), GFP_KERNEL); | 1935 | umidi = kzalloc(sizeof(*umidi), GFP_KERNEL); |
1838 | if (!umidi) | 1936 | if (!umidi) |
1839 | return -ENOMEM; | 1937 | return -ENOMEM; |
1840 | umidi->chip = chip; | 1938 | umidi->dev = interface_to_usbdev(iface); |
1939 | umidi->card = card; | ||
1841 | umidi->iface = iface; | 1940 | umidi->iface = iface; |
1842 | umidi->quirk = quirk; | 1941 | umidi->quirk = quirk; |
1843 | umidi->usb_protocol_ops = &snd_usbmidi_standard_ops; | 1942 | umidi->usb_protocol_ops = &snd_usbmidi_standard_ops; |
1844 | init_timer(&umidi->error_timer); | 1943 | init_timer(&umidi->error_timer); |
1845 | spin_lock_init(&umidi->disc_lock); | 1944 | spin_lock_init(&umidi->disc_lock); |
1945 | mutex_init(&umidi->mutex); | ||
1946 | umidi->usb_id = USB_ID(le16_to_cpu(umidi->dev->descriptor.idVendor), | ||
1947 | le16_to_cpu(umidi->dev->descriptor.idProduct)); | ||
1846 | umidi->error_timer.function = snd_usbmidi_error_timer; | 1948 | umidi->error_timer.function = snd_usbmidi_error_timer; |
1847 | umidi->error_timer.data = (unsigned long)umidi; | 1949 | umidi->error_timer.data = (unsigned long)umidi; |
1848 | 1950 | ||
@@ -1851,7 +1953,7 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | |||
1851 | switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) { | 1953 | switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) { |
1852 | case QUIRK_MIDI_STANDARD_INTERFACE: | 1954 | case QUIRK_MIDI_STANDARD_INTERFACE: |
1853 | err = snd_usbmidi_get_ms_info(umidi, endpoints); | 1955 | err = snd_usbmidi_get_ms_info(umidi, endpoints); |
1854 | if (chip->usb_id == USB_ID(0x0763, 0x0150)) /* M-Audio Uno */ | 1956 | if (umidi->usb_id == USB_ID(0x0763, 0x0150)) /* M-Audio Uno */ |
1855 | umidi->usb_protocol_ops = | 1957 | umidi->usb_protocol_ops = |
1856 | &snd_usbmidi_maudio_broken_running_status_ops; | 1958 | &snd_usbmidi_maudio_broken_running_status_ops; |
1857 | break; | 1959 | break; |
@@ -1887,7 +1989,7 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | |||
1887 | * interface 0, so we have to make sure that the USB core looks | 1989 | * interface 0, so we have to make sure that the USB core looks |
1888 | * again at interface 0 by calling usb_set_interface() on it. | 1990 | * again at interface 0 by calling usb_set_interface() on it. |
1889 | */ | 1991 | */ |
1890 | usb_set_interface(umidi->chip->dev, 0, 0); | 1992 | usb_set_interface(umidi->dev, 0, 0); |
1891 | err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); | 1993 | err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); |
1892 | break; | 1994 | break; |
1893 | case QUIRK_MIDI_EMAGIC: | 1995 | case QUIRK_MIDI_EMAGIC: |
@@ -1914,8 +2016,8 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | |||
1914 | out_ports = 0; | 2016 | out_ports = 0; |
1915 | in_ports = 0; | 2017 | in_ports = 0; |
1916 | for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { | 2018 | for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { |
1917 | out_ports += snd_usbmidi_count_bits(endpoints[i].out_cables); | 2019 | out_ports += hweight16(endpoints[i].out_cables); |
1918 | in_ports += snd_usbmidi_count_bits(endpoints[i].in_cables); | 2020 | in_ports += hweight16(endpoints[i].in_cables); |
1919 | } | 2021 | } |
1920 | err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports); | 2022 | err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports); |
1921 | if (err < 0) { | 2023 | if (err < 0) { |
@@ -1933,14 +2035,14 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | |||
1933 | return err; | 2035 | return err; |
1934 | } | 2036 | } |
1935 | 2037 | ||
1936 | list_add(&umidi->list, &umidi->chip->midi_list); | 2038 | list_add_tail(&umidi->list, midi_list); |
1937 | 2039 | ||
1938 | for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) | 2040 | for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) |
1939 | snd_usbmidi_input_start_ep(umidi->endpoints[i].in); | 2041 | snd_usbmidi_input_start_ep(umidi->endpoints[i].in); |
1940 | return 0; | 2042 | return 0; |
1941 | } | 2043 | } |
1942 | 2044 | ||
1943 | EXPORT_SYMBOL(snd_usb_create_midi_interface); | 2045 | EXPORT_SYMBOL(snd_usbmidi_create); |
1944 | EXPORT_SYMBOL(snd_usbmidi_input_stop); | 2046 | EXPORT_SYMBOL(snd_usbmidi_input_stop); |
1945 | EXPORT_SYMBOL(snd_usbmidi_input_start); | 2047 | EXPORT_SYMBOL(snd_usbmidi_input_start); |
1946 | EXPORT_SYMBOL(snd_usbmidi_disconnect); | 2048 | EXPORT_SYMBOL(snd_usbmidi_disconnect); |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 9efcfd08d747..c998220b99c6 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -1071,6 +1071,15 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsig | |||
1071 | channels = (ftr[0] - 7) / csize - 1; | 1071 | channels = (ftr[0] - 7) / csize - 1; |
1072 | 1072 | ||
1073 | master_bits = snd_usb_combine_bytes(ftr + 6, csize); | 1073 | master_bits = snd_usb_combine_bytes(ftr + 6, csize); |
1074 | /* master configuration quirks */ | ||
1075 | switch (state->chip->usb_id) { | ||
1076 | case USB_ID(0x08bb, 0x2702): | ||
1077 | snd_printk(KERN_INFO | ||
1078 | "usbmixer: master volume quirk for PCM2702 chip\n"); | ||
1079 | /* disable non-functional volume control */ | ||
1080 | master_bits &= ~(1 << (USB_FEATURE_VOLUME - 1)); | ||
1081 | break; | ||
1082 | } | ||
1074 | if (channels > 0) | 1083 | if (channels > 0) |
1075 | first_ch_bits = snd_usb_combine_bytes(ftr + 6 + csize, csize); | 1084 | first_ch_bits = snd_usb_combine_bytes(ftr + 6 + csize, csize); |
1076 | else | 1085 | else |
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c index 3e5d66cf1f5a..77c35885e21c 100644 --- a/sound/usb/usbmixer_maps.c +++ b/sound/usb/usbmixer_maps.c | |||
@@ -277,6 +277,22 @@ static struct usbmix_name_map scratch_live_map[] = { | |||
277 | { 0 } /* terminator */ | 277 | { 0 } /* terminator */ |
278 | }; | 278 | }; |
279 | 279 | ||
280 | /* "Gamesurround Muse Pocket LT" looks same like "Sound Blaster MP3+" | ||
281 | * most importand difference is SU[8], it should be set to "Capture Source" | ||
282 | * to make alsamixer and PA working properly. | ||
283 | * FIXME: or mp3plus_map should use "Capture Source" too, | ||
284 | * so this maps can be merget | ||
285 | */ | ||
286 | static struct usbmix_name_map hercules_usb51_map[] = { | ||
287 | { 8, "Capture Source" }, /* SU, default "PCM Capture Source" */ | ||
288 | { 9, "Master Playback" }, /* FU, default "Speaker Playback" */ | ||
289 | { 10, "Mic Boost", 7 }, /* FU, default "Auto Gain Input" */ | ||
290 | { 11, "Line Capture" }, /* FU, default "PCM Capture" */ | ||
291 | { 13, "Mic Bypass Playback" }, /* FU, default "Mic Playback" */ | ||
292 | { 14, "Line Bypass Playback" }, /* FU, default "Line Playback" */ | ||
293 | { 0 } /* terminator */ | ||
294 | }; | ||
295 | |||
280 | /* | 296 | /* |
281 | * Control map entries | 297 | * Control map entries |
282 | */ | 298 | */ |
@@ -316,6 +332,13 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { | |||
316 | .ignore_ctl_error = 1, | 332 | .ignore_ctl_error = 1, |
317 | }, | 333 | }, |
318 | { | 334 | { |
335 | /* Hercules Gamesurround Muse Pocket LT | ||
336 | * (USB 5.1 Channel Audio Adapter) | ||
337 | */ | ||
338 | .id = USB_ID(0x06f8, 0xc000), | ||
339 | .map = hercules_usb51_map, | ||
340 | }, | ||
341 | { | ||
319 | .id = USB_ID(0x08bb, 0x2702), | 342 | .id = USB_ID(0x08bb, 0x2702), |
320 | .map = linex_map, | 343 | .map = linex_map, |
321 | .ignore_ctl_error = 1, | 344 | .ignore_ctl_error = 1, |
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index f6f201eb24ce..a892bda03df9 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h | |||
@@ -1563,6 +1563,29 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1563 | } | 1563 | } |
1564 | } | 1564 | } |
1565 | }, | 1565 | }, |
1566 | { | ||
1567 | /* has ID 0x00ea when not in Advanced Driver mode */ | ||
1568 | USB_DEVICE_VENDOR_SPEC(0x0582, 0x00e9), | ||
1569 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
1570 | /* .vendor_name = "Roland", */ | ||
1571 | /* .product_name = "UA-1G", */ | ||
1572 | .ifnum = QUIRK_ANY_INTERFACE, | ||
1573 | .type = QUIRK_COMPOSITE, | ||
1574 | .data = (const struct snd_usb_audio_quirk[]) { | ||
1575 | { | ||
1576 | .ifnum = 0, | ||
1577 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
1578 | }, | ||
1579 | { | ||
1580 | .ifnum = 1, | ||
1581 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
1582 | }, | ||
1583 | { | ||
1584 | .ifnum = -1 | ||
1585 | } | ||
1586 | } | ||
1587 | } | ||
1588 | }, | ||
1566 | 1589 | ||
1567 | /* Guillemot devices */ | 1590 | /* Guillemot devices */ |
1568 | { | 1591 | { |
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 99f33766cd51..91bb29666d26 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
@@ -59,11 +59,33 @@ static int us122l_create_usbmidi(struct snd_card *card) | |||
59 | .type = QUIRK_MIDI_US122L, | 59 | .type = QUIRK_MIDI_US122L, |
60 | .data = &quirk_data | 60 | .data = &quirk_data |
61 | }; | 61 | }; |
62 | struct usb_device *dev = US122L(card)->chip.dev; | 62 | struct usb_device *dev = US122L(card)->dev; |
63 | struct usb_interface *iface = usb_ifnum_to_if(dev, 1); | 63 | struct usb_interface *iface = usb_ifnum_to_if(dev, 1); |
64 | 64 | ||
65 | return snd_usb_create_midi_interface(&US122L(card)->chip, | 65 | return snd_usbmidi_create(card, iface, |
66 | iface, &quirk); | 66 | &US122L(card)->midi_list, &quirk); |
67 | } | ||
68 | |||
69 | static int us144_create_usbmidi(struct snd_card *card) | ||
70 | { | ||
71 | static struct snd_usb_midi_endpoint_info quirk_data = { | ||
72 | .out_ep = 4, | ||
73 | .in_ep = 3, | ||
74 | .out_cables = 0x001, | ||
75 | .in_cables = 0x001 | ||
76 | }; | ||
77 | static struct snd_usb_audio_quirk quirk = { | ||
78 | .vendor_name = "US144", | ||
79 | .product_name = NAME_ALLCAPS, | ||
80 | .ifnum = 0, | ||
81 | .type = QUIRK_MIDI_US122L, | ||
82 | .data = &quirk_data | ||
83 | }; | ||
84 | struct usb_device *dev = US122L(card)->dev; | ||
85 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); | ||
86 | |||
87 | return snd_usbmidi_create(card, iface, | ||
88 | &US122L(card)->midi_list, &quirk); | ||
67 | } | 89 | } |
68 | 90 | ||
69 | /* | 91 | /* |
@@ -171,7 +193,13 @@ static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file) | |||
171 | 193 | ||
172 | if (!us122l->first) | 194 | if (!us122l->first) |
173 | us122l->first = file; | 195 | us122l->first = file; |
174 | iface = usb_ifnum_to_if(us122l->chip.dev, 1); | 196 | |
197 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || | ||
198 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { | ||
199 | iface = usb_ifnum_to_if(us122l->dev, 0); | ||
200 | usb_autopm_get_interface(iface); | ||
201 | } | ||
202 | iface = usb_ifnum_to_if(us122l->dev, 1); | ||
175 | usb_autopm_get_interface(iface); | 203 | usb_autopm_get_interface(iface); |
176 | return 0; | 204 | return 0; |
177 | } | 205 | } |
@@ -179,8 +207,15 @@ static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file) | |||
179 | static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file) | 207 | static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file) |
180 | { | 208 | { |
181 | struct us122l *us122l = hw->private_data; | 209 | struct us122l *us122l = hw->private_data; |
182 | struct usb_interface *iface = usb_ifnum_to_if(us122l->chip.dev, 1); | 210 | struct usb_interface *iface; |
183 | snd_printdd(KERN_DEBUG "%p %p\n", hw, file); | 211 | snd_printdd(KERN_DEBUG "%p %p\n", hw, file); |
212 | |||
213 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || | ||
214 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { | ||
215 | iface = usb_ifnum_to_if(us122l->dev, 0); | ||
216 | usb_autopm_put_interface(iface); | ||
217 | } | ||
218 | iface = usb_ifnum_to_if(us122l->dev, 1); | ||
184 | usb_autopm_put_interface(iface); | 219 | usb_autopm_put_interface(iface); |
185 | if (us122l->first == file) | 220 | if (us122l->first == file) |
186 | us122l->first = NULL; | 221 | us122l->first = NULL; |
@@ -264,7 +299,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, | |||
264 | static void us122l_stop(struct us122l *us122l) | 299 | static void us122l_stop(struct us122l *us122l) |
265 | { | 300 | { |
266 | struct list_head *p; | 301 | struct list_head *p; |
267 | list_for_each(p, &us122l->chip.midi_list) | 302 | list_for_each(p, &us122l->midi_list) |
268 | snd_usbmidi_input_stop(p); | 303 | snd_usbmidi_input_stop(p); |
269 | 304 | ||
270 | usb_stream_stop(&us122l->sk); | 305 | usb_stream_stop(&us122l->sk); |
@@ -297,7 +332,7 @@ static bool us122l_start(struct us122l *us122l, | |||
297 | unsigned use_packsize = 0; | 332 | unsigned use_packsize = 0; |
298 | bool success = false; | 333 | bool success = false; |
299 | 334 | ||
300 | if (us122l->chip.dev->speed == USB_SPEED_HIGH) { | 335 | if (us122l->dev->speed == USB_SPEED_HIGH) { |
301 | /* The us-122l's descriptor defaults to iso max_packsize 78, | 336 | /* The us-122l's descriptor defaults to iso max_packsize 78, |
302 | which isn't needed for samplerates <= 48000. | 337 | which isn't needed for samplerates <= 48000. |
303 | Lets save some memory: | 338 | Lets save some memory: |
@@ -314,11 +349,11 @@ static bool us122l_start(struct us122l *us122l, | |||
314 | break; | 349 | break; |
315 | } | 350 | } |
316 | } | 351 | } |
317 | if (!usb_stream_new(&us122l->sk, us122l->chip.dev, 1, 2, | 352 | if (!usb_stream_new(&us122l->sk, us122l->dev, 1, 2, |
318 | rate, use_packsize, period_frames, 6)) | 353 | rate, use_packsize, period_frames, 6)) |
319 | goto out; | 354 | goto out; |
320 | 355 | ||
321 | err = us122l_set_sample_rate(us122l->chip.dev, rate); | 356 | err = us122l_set_sample_rate(us122l->dev, rate); |
322 | if (err < 0) { | 357 | if (err < 0) { |
323 | us122l_stop(us122l); | 358 | us122l_stop(us122l); |
324 | snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); | 359 | snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); |
@@ -330,7 +365,7 @@ static bool us122l_start(struct us122l *us122l, | |||
330 | snd_printk(KERN_ERR "us122l_start error %i \n", err); | 365 | snd_printk(KERN_ERR "us122l_start error %i \n", err); |
331 | goto out; | 366 | goto out; |
332 | } | 367 | } |
333 | list_for_each(p, &us122l->chip.midi_list) | 368 | list_for_each(p, &us122l->midi_list) |
334 | snd_usbmidi_input_start(p); | 369 | snd_usbmidi_input_start(p); |
335 | success = true; | 370 | success = true; |
336 | out: | 371 | out: |
@@ -357,7 +392,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, | |||
357 | err = -ENXIO; | 392 | err = -ENXIO; |
358 | goto free; | 393 | goto free; |
359 | } | 394 | } |
360 | high_speed = us122l->chip.dev->speed == USB_SPEED_HIGH; | 395 | high_speed = us122l->dev->speed == USB_SPEED_HIGH; |
361 | if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && | 396 | if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && |
362 | (!high_speed || | 397 | (!high_speed || |
363 | (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || | 398 | (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || |
@@ -417,7 +452,7 @@ static int usb_stream_hwdep_new(struct snd_card *card) | |||
417 | { | 452 | { |
418 | int err; | 453 | int err; |
419 | struct snd_hwdep *hw; | 454 | struct snd_hwdep *hw; |
420 | struct usb_device *dev = US122L(card)->chip.dev; | 455 | struct usb_device *dev = US122L(card)->dev; |
421 | 456 | ||
422 | err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); | 457 | err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); |
423 | if (err < 0) | 458 | if (err < 0) |
@@ -443,19 +478,31 @@ static bool us122l_create_card(struct snd_card *card) | |||
443 | int err; | 478 | int err; |
444 | struct us122l *us122l = US122L(card); | 479 | struct us122l *us122l = US122L(card); |
445 | 480 | ||
446 | err = usb_set_interface(us122l->chip.dev, 1, 1); | 481 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
482 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { | ||
483 | err = usb_set_interface(us122l->dev, 0, 1); | ||
484 | if (err) { | ||
485 | snd_printk(KERN_ERR "usb_set_interface error \n"); | ||
486 | return false; | ||
487 | } | ||
488 | } | ||
489 | err = usb_set_interface(us122l->dev, 1, 1); | ||
447 | if (err) { | 490 | if (err) { |
448 | snd_printk(KERN_ERR "usb_set_interface error \n"); | 491 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
449 | return false; | 492 | return false; |
450 | } | 493 | } |
451 | 494 | ||
452 | pt_info_set(us122l->chip.dev, 0x11); | 495 | pt_info_set(us122l->dev, 0x11); |
453 | pt_info_set(us122l->chip.dev, 0x10); | 496 | pt_info_set(us122l->dev, 0x10); |
454 | 497 | ||
455 | if (!us122l_start(us122l, 44100, 256)) | 498 | if (!us122l_start(us122l, 44100, 256)) |
456 | return false; | 499 | return false; |
457 | 500 | ||
458 | err = us122l_create_usbmidi(card); | 501 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
502 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) | ||
503 | err = us144_create_usbmidi(card); | ||
504 | else | ||
505 | err = us122l_create_usbmidi(card); | ||
459 | if (err < 0) { | 506 | if (err < 0) { |
460 | snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err); | 507 | snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err); |
461 | us122l_stop(us122l); | 508 | us122l_stop(us122l); |
@@ -465,7 +512,7 @@ static bool us122l_create_card(struct snd_card *card) | |||
465 | if (err < 0) { | 512 | if (err < 0) { |
466 | /* release the midi resources */ | 513 | /* release the midi resources */ |
467 | struct list_head *p; | 514 | struct list_head *p; |
468 | list_for_each(p, &us122l->chip.midi_list) | 515 | list_for_each(p, &us122l->midi_list) |
469 | snd_usbmidi_disconnect(p); | 516 | snd_usbmidi_disconnect(p); |
470 | 517 | ||
471 | us122l_stop(us122l); | 518 | us122l_stop(us122l); |
@@ -477,7 +524,7 @@ static bool us122l_create_card(struct snd_card *card) | |||
477 | static void snd_us122l_free(struct snd_card *card) | 524 | static void snd_us122l_free(struct snd_card *card) |
478 | { | 525 | { |
479 | struct us122l *us122l = US122L(card); | 526 | struct us122l *us122l = US122L(card); |
480 | int index = us122l->chip.index; | 527 | int index = us122l->card_index; |
481 | if (index >= 0 && index < SNDRV_CARDS) | 528 | if (index >= 0 && index < SNDRV_CARDS) |
482 | snd_us122l_card_used[index] = 0; | 529 | snd_us122l_card_used[index] = 0; |
483 | } | 530 | } |
@@ -497,13 +544,12 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
497 | sizeof(struct us122l), &card); | 544 | sizeof(struct us122l), &card); |
498 | if (err < 0) | 545 | if (err < 0) |
499 | return err; | 546 | return err; |
500 | snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; | 547 | snd_us122l_card_used[US122L(card)->card_index = dev] = 1; |
501 | card->private_free = snd_us122l_free; | 548 | card->private_free = snd_us122l_free; |
502 | US122L(card)->chip.dev = device; | 549 | US122L(card)->dev = device; |
503 | US122L(card)->chip.card = card; | ||
504 | mutex_init(&US122L(card)->mutex); | 550 | mutex_init(&US122L(card)->mutex); |
505 | init_waitqueue_head(&US122L(card)->sk.sleep); | 551 | init_waitqueue_head(&US122L(card)->sk.sleep); |
506 | INIT_LIST_HEAD(&US122L(card)->chip.midi_list); | 552 | INIT_LIST_HEAD(&US122L(card)->midi_list); |
507 | strcpy(card->driver, "USB "NAME_ALLCAPS""); | 553 | strcpy(card->driver, "USB "NAME_ALLCAPS""); |
508 | sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); | 554 | sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); |
509 | sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", | 555 | sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", |
@@ -511,8 +557,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
511 | le16_to_cpu(device->descriptor.idVendor), | 557 | le16_to_cpu(device->descriptor.idVendor), |
512 | le16_to_cpu(device->descriptor.idProduct), | 558 | le16_to_cpu(device->descriptor.idProduct), |
513 | 0, | 559 | 0, |
514 | US122L(card)->chip.dev->bus->busnum, | 560 | US122L(card)->dev->bus->busnum, |
515 | US122L(card)->chip.dev->devnum | 561 | US122L(card)->dev->devnum |
516 | ); | 562 | ); |
517 | *cardp = card; | 563 | *cardp = card; |
518 | return 0; | 564 | return 0; |
@@ -542,6 +588,7 @@ static int us122l_usb_probe(struct usb_interface *intf, | |||
542 | return err; | 588 | return err; |
543 | } | 589 | } |
544 | 590 | ||
591 | usb_get_intf(usb_ifnum_to_if(device, 0)); | ||
545 | usb_get_dev(device); | 592 | usb_get_dev(device); |
546 | *cardp = card; | 593 | *cardp = card; |
547 | return 0; | 594 | return 0; |
@@ -550,9 +597,17 @@ static int us122l_usb_probe(struct usb_interface *intf, | |||
550 | static int snd_us122l_probe(struct usb_interface *intf, | 597 | static int snd_us122l_probe(struct usb_interface *intf, |
551 | const struct usb_device_id *id) | 598 | const struct usb_device_id *id) |
552 | { | 599 | { |
600 | struct usb_device *device = interface_to_usbdev(intf); | ||
553 | struct snd_card *card; | 601 | struct snd_card *card; |
554 | int err; | 602 | int err; |
555 | 603 | ||
604 | if ((device->descriptor.idProduct == USB_ID_US144 || | ||
605 | device->descriptor.idProduct == USB_ID_US144MKII) | ||
606 | && device->speed == USB_SPEED_HIGH) { | ||
607 | snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n"); | ||
608 | return -ENODEV; | ||
609 | } | ||
610 | |||
556 | snd_printdd(KERN_DEBUG"%p:%i\n", | 611 | snd_printdd(KERN_DEBUG"%p:%i\n", |
557 | intf, intf->cur_altsetting->desc.bInterfaceNumber); | 612 | intf, intf->cur_altsetting->desc.bInterfaceNumber); |
558 | if (intf->cur_altsetting->desc.bInterfaceNumber != 1) | 613 | if (intf->cur_altsetting->desc.bInterfaceNumber != 1) |
@@ -584,15 +639,15 @@ static void snd_us122l_disconnect(struct usb_interface *intf) | |||
584 | mutex_lock(&us122l->mutex); | 639 | mutex_lock(&us122l->mutex); |
585 | us122l_stop(us122l); | 640 | us122l_stop(us122l); |
586 | mutex_unlock(&us122l->mutex); | 641 | mutex_unlock(&us122l->mutex); |
587 | us122l->chip.shutdown = 1; | ||
588 | 642 | ||
589 | /* release the midi resources */ | 643 | /* release the midi resources */ |
590 | list_for_each(p, &us122l->chip.midi_list) { | 644 | list_for_each(p, &us122l->midi_list) { |
591 | snd_usbmidi_disconnect(p); | 645 | snd_usbmidi_disconnect(p); |
592 | } | 646 | } |
593 | 647 | ||
594 | usb_put_intf(intf); | 648 | usb_put_intf(usb_ifnum_to_if(us122l->dev, 0)); |
595 | usb_put_dev(us122l->chip.dev); | 649 | usb_put_intf(usb_ifnum_to_if(us122l->dev, 1)); |
650 | usb_put_dev(us122l->dev); | ||
596 | 651 | ||
597 | while (atomic_read(&us122l->mmap_count)) | 652 | while (atomic_read(&us122l->mmap_count)) |
598 | msleep(500); | 653 | msleep(500); |
@@ -615,7 +670,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message) | |||
615 | if (!us122l) | 670 | if (!us122l) |
616 | return 0; | 671 | return 0; |
617 | 672 | ||
618 | list_for_each(p, &us122l->chip.midi_list) | 673 | list_for_each(p, &us122l->midi_list) |
619 | snd_usbmidi_input_stop(p); | 674 | snd_usbmidi_input_stop(p); |
620 | 675 | ||
621 | mutex_lock(&us122l->mutex); | 676 | mutex_lock(&us122l->mutex); |
@@ -642,16 +697,24 @@ static int snd_us122l_resume(struct usb_interface *intf) | |||
642 | 697 | ||
643 | mutex_lock(&us122l->mutex); | 698 | mutex_lock(&us122l->mutex); |
644 | /* needed, doesn't restart without: */ | 699 | /* needed, doesn't restart without: */ |
645 | err = usb_set_interface(us122l->chip.dev, 1, 1); | 700 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
701 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { | ||
702 | err = usb_set_interface(us122l->dev, 0, 1); | ||
703 | if (err) { | ||
704 | snd_printk(KERN_ERR "usb_set_interface error \n"); | ||
705 | goto unlock; | ||
706 | } | ||
707 | } | ||
708 | err = usb_set_interface(us122l->dev, 1, 1); | ||
646 | if (err) { | 709 | if (err) { |
647 | snd_printk(KERN_ERR "usb_set_interface error \n"); | 710 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
648 | goto unlock; | 711 | goto unlock; |
649 | } | 712 | } |
650 | 713 | ||
651 | pt_info_set(us122l->chip.dev, 0x11); | 714 | pt_info_set(us122l->dev, 0x11); |
652 | pt_info_set(us122l->chip.dev, 0x10); | 715 | pt_info_set(us122l->dev, 0x10); |
653 | 716 | ||
654 | err = us122l_set_sample_rate(us122l->chip.dev, | 717 | err = us122l_set_sample_rate(us122l->dev, |
655 | us122l->sk.s->cfg.sample_rate); | 718 | us122l->sk.s->cfg.sample_rate); |
656 | if (err < 0) { | 719 | if (err < 0) { |
657 | snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); | 720 | snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); |
@@ -661,7 +724,7 @@ static int snd_us122l_resume(struct usb_interface *intf) | |||
661 | if (err) | 724 | if (err) |
662 | goto unlock; | 725 | goto unlock; |
663 | 726 | ||
664 | list_for_each(p, &us122l->chip.midi_list) | 727 | list_for_each(p, &us122l->midi_list) |
665 | snd_usbmidi_input_start(p); | 728 | snd_usbmidi_input_start(p); |
666 | unlock: | 729 | unlock: |
667 | mutex_unlock(&us122l->mutex); | 730 | mutex_unlock(&us122l->mutex); |
@@ -675,11 +738,21 @@ static struct usb_device_id snd_us122l_usb_id_table[] = { | |||
675 | .idVendor = 0x0644, | 738 | .idVendor = 0x0644, |
676 | .idProduct = USB_ID_US122L | 739 | .idProduct = USB_ID_US122L |
677 | }, | 740 | }, |
678 | /* { */ /* US-144 maybe works when @USB1.1. Untested. */ | 741 | { /* US-144 only works at USB1.1! Disable module ehci-hcd. */ |
679 | /* .match_flags = USB_DEVICE_ID_MATCH_DEVICE, */ | 742 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
680 | /* .idVendor = 0x0644, */ | 743 | .idVendor = 0x0644, |
681 | /* .idProduct = USB_ID_US144 */ | 744 | .idProduct = USB_ID_US144 |
682 | /* }, */ | 745 | }, |
746 | { | ||
747 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | ||
748 | .idVendor = 0x0644, | ||
749 | .idProduct = USB_ID_US122MKII | ||
750 | }, | ||
751 | { | ||
752 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | ||
753 | .idVendor = 0x0644, | ||
754 | .idProduct = USB_ID_US144MKII | ||
755 | }, | ||
683 | { /* terminator */ } | 756 | { /* terminator */ } |
684 | }; | 757 | }; |
685 | 758 | ||
diff --git a/sound/usb/usx2y/us122l.h b/sound/usb/usx2y/us122l.h index 3d10c4b2a0f5..f263b3f96c86 100644 --- a/sound/usb/usx2y/us122l.h +++ b/sound/usb/usx2y/us122l.h | |||
@@ -3,7 +3,8 @@ | |||
3 | 3 | ||
4 | 4 | ||
5 | struct us122l { | 5 | struct us122l { |
6 | struct snd_usb_audio chip; | 6 | struct usb_device *dev; |
7 | int card_index; | ||
7 | int stride; | 8 | int stride; |
8 | struct usb_stream_kernel sk; | 9 | struct usb_stream_kernel sk; |
9 | 10 | ||
@@ -12,6 +13,7 @@ struct us122l { | |||
12 | unsigned second_periods_polled; | 13 | unsigned second_periods_polled; |
13 | struct file *master; | 14 | struct file *master; |
14 | struct file *slave; | 15 | struct file *slave; |
16 | struct list_head midi_list; | ||
15 | 17 | ||
16 | atomic_t mmap_count; | 18 | atomic_t mmap_count; |
17 | }; | 19 | }; |
@@ -23,5 +25,7 @@ struct us122l { | |||
23 | 25 | ||
24 | #define USB_ID_US122L 0x800E | 26 | #define USB_ID_US122L 0x800E |
25 | #define USB_ID_US144 0x800F | 27 | #define USB_ID_US144 0x800F |
28 | #define USB_ID_US122MKII 0x8021 | ||
29 | #define USB_ID_US144MKII 0x8020 | ||
26 | 30 | ||
27 | #endif | 31 | #endif |
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 52e04b2f35d3..1879b72c40f8 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -114,7 +114,7 @@ static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, | |||
114 | struct usX2Ydev *us428 = hw->private_data; | 114 | struct usX2Ydev *us428 = hw->private_data; |
115 | int id = -1; | 115 | int id = -1; |
116 | 116 | ||
117 | switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { | 117 | switch (le16_to_cpu(us428->dev->descriptor.idProduct)) { |
118 | case USB_ID_US122: | 118 | case USB_ID_US122: |
119 | id = USX2Y_TYPE_122; | 119 | id = USX2Y_TYPE_122; |
120 | break; | 120 | break; |
@@ -164,14 +164,14 @@ static int usX2Y_create_usbmidi(struct snd_card *card) | |||
164 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 164 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
165 | .data = &quirk_data_2 | 165 | .data = &quirk_data_2 |
166 | }; | 166 | }; |
167 | struct usb_device *dev = usX2Y(card)->chip.dev; | 167 | struct usb_device *dev = usX2Y(card)->dev; |
168 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); | 168 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); |
169 | struct snd_usb_audio_quirk *quirk = | 169 | struct snd_usb_audio_quirk *quirk = |
170 | le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? | 170 | le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? |
171 | &quirk_2 : &quirk_1; | 171 | &quirk_2 : &quirk_1; |
172 | 172 | ||
173 | snd_printdd("usX2Y_create_usbmidi \n"); | 173 | snd_printdd("usX2Y_create_usbmidi \n"); |
174 | return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); | 174 | return snd_usbmidi_create(card, iface, &usX2Y(card)->midi_list, quirk); |
175 | } | 175 | } |
176 | 176 | ||
177 | static int usX2Y_create_alsa_devices(struct snd_card *card) | 177 | static int usX2Y_create_alsa_devices(struct snd_card *card) |
@@ -202,7 +202,7 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, | |||
202 | snd_printdd( "dsp_load %s\n", dsp->name); | 202 | snd_printdd( "dsp_load %s\n", dsp->name); |
203 | 203 | ||
204 | if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { | 204 | if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { |
205 | struct usb_device* dev = priv->chip.dev; | 205 | struct usb_device* dev = priv->dev; |
206 | char *buf; | 206 | char *buf; |
207 | 207 | ||
208 | buf = memdup_user(dsp->image, dsp->length); | 208 | buf = memdup_user(dsp->image, dsp->length); |
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index cb4bb8373ca2..c42350eed2eb 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
@@ -239,8 +239,8 @@ static void i_usX2Y_In04Int(struct urb *urb) | |||
239 | for (j = 0; j < URBS_AsyncSeq && !err; ++j) | 239 | for (j = 0; j < URBS_AsyncSeq && !err; ++j) |
240 | if (0 == usX2Y->AS04.urb[j]->status) { | 240 | if (0 == usX2Y->AS04.urb[j]->status) { |
241 | struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more than 1 p4out is new, 1 gets lost. | 241 | struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more than 1 p4out is new, 1 gets lost. |
242 | usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->chip.dev, | 242 | usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->dev, |
243 | usb_sndbulkpipe(usX2Y->chip.dev, 0x04), &p4out->val.vol, | 243 | usb_sndbulkpipe(usX2Y->dev, 0x04), &p4out->val.vol, |
244 | p4out->type == eLT_Light ? sizeof(struct us428_lights) : 5, | 244 | p4out->type == eLT_Light ? sizeof(struct us428_lights) : 5, |
245 | i_usX2Y_Out04Int, usX2Y); | 245 | i_usX2Y_Out04Int, usX2Y); |
246 | err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC); | 246 | err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC); |
@@ -253,7 +253,7 @@ static void i_usX2Y_In04Int(struct urb *urb) | |||
253 | if (err) | 253 | if (err) |
254 | snd_printk(KERN_ERR "In04Int() usb_submit_urb err=%i\n", err); | 254 | snd_printk(KERN_ERR "In04Int() usb_submit_urb err=%i\n", err); |
255 | 255 | ||
256 | urb->dev = usX2Y->chip.dev; | 256 | urb->dev = usX2Y->dev; |
257 | usb_submit_urb(urb, GFP_ATOMIC); | 257 | usb_submit_urb(urb, GFP_ATOMIC); |
258 | } | 258 | } |
259 | 259 | ||
@@ -273,8 +273,8 @@ int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y) | |||
273 | err = -ENOMEM; | 273 | err = -ENOMEM; |
274 | break; | 274 | break; |
275 | } | 275 | } |
276 | usb_fill_bulk_urb( usX2Y->AS04.urb[i], usX2Y->chip.dev, | 276 | usb_fill_bulk_urb( usX2Y->AS04.urb[i], usX2Y->dev, |
277 | usb_sndbulkpipe(usX2Y->chip.dev, 0x04), | 277 | usb_sndbulkpipe(usX2Y->dev, 0x04), |
278 | usX2Y->AS04.buffer + URB_DataLen_AsyncSeq*i, 0, | 278 | usX2Y->AS04.buffer + URB_DataLen_AsyncSeq*i, 0, |
279 | i_usX2Y_Out04Int, usX2Y | 279 | i_usX2Y_Out04Int, usX2Y |
280 | ); | 280 | ); |
@@ -293,7 +293,7 @@ int usX2Y_In04_init(struct usX2Ydev *usX2Y) | |||
293 | } | 293 | } |
294 | 294 | ||
295 | init_waitqueue_head(&usX2Y->In04WaitQueue); | 295 | init_waitqueue_head(&usX2Y->In04WaitQueue); |
296 | usb_fill_int_urb(usX2Y->In04urb, usX2Y->chip.dev, usb_rcvintpipe(usX2Y->chip.dev, 0x4), | 296 | usb_fill_int_urb(usX2Y->In04urb, usX2Y->dev, usb_rcvintpipe(usX2Y->dev, 0x4), |
297 | usX2Y->In04Buf, 21, | 297 | usX2Y->In04Buf, 21, |
298 | i_usX2Y_In04Int, usX2Y, | 298 | i_usX2Y_In04Int, usX2Y, |
299 | 10); | 299 | 10); |
@@ -348,13 +348,12 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
348 | sizeof(struct usX2Ydev), &card); | 348 | sizeof(struct usX2Ydev), &card); |
349 | if (err < 0) | 349 | if (err < 0) |
350 | return err; | 350 | return err; |
351 | snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; | 351 | snd_usX2Y_card_used[usX2Y(card)->card_index = dev] = 1; |
352 | card->private_free = snd_usX2Y_card_private_free; | 352 | card->private_free = snd_usX2Y_card_private_free; |
353 | usX2Y(card)->chip.dev = device; | 353 | usX2Y(card)->dev = device; |
354 | usX2Y(card)->chip.card = card; | ||
355 | init_waitqueue_head(&usX2Y(card)->prepare_wait_queue); | 354 | init_waitqueue_head(&usX2Y(card)->prepare_wait_queue); |
356 | mutex_init(&usX2Y(card)->prepare_mutex); | 355 | mutex_init(&usX2Y(card)->prepare_mutex); |
357 | INIT_LIST_HEAD(&usX2Y(card)->chip.midi_list); | 356 | INIT_LIST_HEAD(&usX2Y(card)->midi_list); |
358 | strcpy(card->driver, "USB "NAME_ALLCAPS""); | 357 | strcpy(card->driver, "USB "NAME_ALLCAPS""); |
359 | sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); | 358 | sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); |
360 | sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", | 359 | sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", |
@@ -362,7 +361,7 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
362 | le16_to_cpu(device->descriptor.idVendor), | 361 | le16_to_cpu(device->descriptor.idVendor), |
363 | le16_to_cpu(device->descriptor.idProduct), | 362 | le16_to_cpu(device->descriptor.idProduct), |
364 | 0,//us428(card)->usbmidi.ifnum, | 363 | 0,//us428(card)->usbmidi.ifnum, |
365 | usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum | 364 | usX2Y(card)->dev->bus->busnum, usX2Y(card)->dev->devnum |
366 | ); | 365 | ); |
367 | *cardp = card; | 366 | *cardp = card; |
368 | return 0; | 367 | return 0; |
@@ -432,8 +431,8 @@ static void snd_usX2Y_card_private_free(struct snd_card *card) | |||
432 | usb_free_urb(usX2Y(card)->In04urb); | 431 | usb_free_urb(usX2Y(card)->In04urb); |
433 | if (usX2Y(card)->us428ctls_sharedmem) | 432 | if (usX2Y(card)->us428ctls_sharedmem) |
434 | snd_free_pages(usX2Y(card)->us428ctls_sharedmem, sizeof(*usX2Y(card)->us428ctls_sharedmem)); | 433 | snd_free_pages(usX2Y(card)->us428ctls_sharedmem, sizeof(*usX2Y(card)->us428ctls_sharedmem)); |
435 | if (usX2Y(card)->chip.index >= 0 && usX2Y(card)->chip.index < SNDRV_CARDS) | 434 | if (usX2Y(card)->card_index >= 0 && usX2Y(card)->card_index < SNDRV_CARDS) |
436 | snd_usX2Y_card_used[usX2Y(card)->chip.index] = 0; | 435 | snd_usX2Y_card_used[usX2Y(card)->card_index] = 0; |
437 | } | 436 | } |
438 | 437 | ||
439 | /* | 438 | /* |
@@ -445,13 +444,12 @@ static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr) | |||
445 | struct snd_card *card = ptr; | 444 | struct snd_card *card = ptr; |
446 | struct usX2Ydev *usX2Y = usX2Y(card); | 445 | struct usX2Ydev *usX2Y = usX2Y(card); |
447 | struct list_head *p; | 446 | struct list_head *p; |
448 | usX2Y->chip.shutdown = 1; | ||
449 | usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; | 447 | usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; |
450 | usX2Y_unlinkSeq(&usX2Y->AS04); | 448 | usX2Y_unlinkSeq(&usX2Y->AS04); |
451 | usb_kill_urb(usX2Y->In04urb); | 449 | usb_kill_urb(usX2Y->In04urb); |
452 | snd_card_disconnect(card); | 450 | snd_card_disconnect(card); |
453 | /* release the midi resources */ | 451 | /* release the midi resources */ |
454 | list_for_each(p, &usX2Y->chip.midi_list) { | 452 | list_for_each(p, &usX2Y->midi_list) { |
455 | snd_usbmidi_disconnect(p); | 453 | snd_usbmidi_disconnect(p); |
456 | } | 454 | } |
457 | if (usX2Y->us428ctls_sharedmem) | 455 | if (usX2Y->us428ctls_sharedmem) |
diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h index 456b5fdbc339..1d174cea352b 100644 --- a/sound/usb/usx2y/usbusx2y.h +++ b/sound/usb/usx2y/usbusx2y.h | |||
@@ -22,7 +22,8 @@ struct snd_usX2Y_urbSeq { | |||
22 | #include "usx2yhwdeppcm.h" | 22 | #include "usx2yhwdeppcm.h" |
23 | 23 | ||
24 | struct usX2Ydev { | 24 | struct usX2Ydev { |
25 | struct snd_usb_audio chip; | 25 | struct usb_device *dev; |
26 | int card_index; | ||
26 | int stride; | 27 | int stride; |
27 | struct urb *In04urb; | 28 | struct urb *In04urb; |
28 | void *In04Buf; | 29 | void *In04Buf; |
@@ -42,6 +43,9 @@ struct usX2Ydev { | |||
42 | struct snd_usX2Y_substream *subs[4]; | 43 | struct snd_usX2Y_substream *subs[4]; |
43 | struct snd_usX2Y_substream * volatile prepare_subs; | 44 | struct snd_usX2Y_substream * volatile prepare_subs; |
44 | wait_queue_head_t prepare_wait_queue; | 45 | wait_queue_head_t prepare_wait_queue; |
46 | struct list_head midi_list; | ||
47 | struct list_head pcm_list; | ||
48 | int pcm_devs; | ||
45 | }; | 49 | }; |
46 | 50 | ||
47 | 51 | ||
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 9efd27f6b52f..74a67a85aa81 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
@@ -199,7 +199,7 @@ static int usX2Y_urb_submit(struct snd_usX2Y_substream *subs, struct urb *urb, i | |||
199 | return -ENODEV; | 199 | return -ENODEV; |
200 | urb->start_frame = (frame + NRURBS * nr_of_packs()); // let hcd do rollover sanity checks | 200 | urb->start_frame = (frame + NRURBS * nr_of_packs()); // let hcd do rollover sanity checks |
201 | urb->hcpriv = NULL; | 201 | urb->hcpriv = NULL; |
202 | urb->dev = subs->usX2Y->chip.dev; /* we need to set this at each time */ | 202 | urb->dev = subs->usX2Y->dev; /* we need to set this at each time */ |
203 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { | 203 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { |
204 | snd_printk(KERN_ERR "usb_submit_urb() returned %i\n", err); | 204 | snd_printk(KERN_ERR "usb_submit_urb() returned %i\n", err); |
205 | return err; | 205 | return err; |
@@ -300,7 +300,7 @@ static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, | |||
300 | "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" | 300 | "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" |
301 | "Most propably some urb of usb-frame %i is still missing.\n" | 301 | "Most propably some urb of usb-frame %i is still missing.\n" |
302 | "Cause could be too long delays in usb-hcd interrupt handling.\n", | 302 | "Cause could be too long delays in usb-hcd interrupt handling.\n", |
303 | usb_get_current_frame_number(usX2Y->chip.dev), | 303 | usb_get_current_frame_number(usX2Y->dev), |
304 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | 304 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
305 | usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); | 305 | usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); |
306 | usX2Y_clients_stop(usX2Y); | 306 | usX2Y_clients_stop(usX2Y); |
@@ -313,7 +313,7 @@ static void i_usX2Y_urb_complete(struct urb *urb) | |||
313 | 313 | ||
314 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { | 314 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { |
315 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", | 315 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", |
316 | usb_get_current_frame_number(usX2Y->chip.dev), | 316 | usb_get_current_frame_number(usX2Y->dev), |
317 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | 317 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
318 | urb->status, urb->start_frame); | 318 | urb->status, urb->start_frame); |
319 | return; | 319 | return; |
@@ -424,7 +424,7 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) | |||
424 | int i; | 424 | int i; |
425 | unsigned int pipe; | 425 | unsigned int pipe; |
426 | int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 426 | int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
427 | struct usb_device *dev = subs->usX2Y->chip.dev; | 427 | struct usb_device *dev = subs->usX2Y->dev; |
428 | 428 | ||
429 | pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : | 429 | pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : |
430 | usb_rcvisocpipe(dev, subs->endpoint); | 430 | usb_rcvisocpipe(dev, subs->endpoint); |
@@ -500,7 +500,7 @@ static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs) | |||
500 | unsigned long pack; | 500 | unsigned long pack; |
501 | if (0 == i) | 501 | if (0 == i) |
502 | atomic_set(&subs->state, state_STARTING3); | 502 | atomic_set(&subs->state, state_STARTING3); |
503 | urb->dev = usX2Y->chip.dev; | 503 | urb->dev = usX2Y->dev; |
504 | urb->transfer_flags = URB_ISO_ASAP; | 504 | urb->transfer_flags = URB_ISO_ASAP; |
505 | for (pack = 0; pack < nr_of_packs(); pack++) { | 505 | for (pack = 0; pack < nr_of_packs(); pack++) { |
506 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; | 506 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; |
@@ -692,7 +692,7 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) | |||
692 | } | 692 | } |
693 | ((char*)(usbdata + i))[0] = ra[i].c1; | 693 | ((char*)(usbdata + i))[0] = ra[i].c1; |
694 | ((char*)(usbdata + i))[1] = ra[i].c2; | 694 | ((char*)(usbdata + i))[1] = ra[i].c2; |
695 | usb_fill_bulk_urb(us->urb[i], usX2Y->chip.dev, usb_sndbulkpipe(usX2Y->chip.dev, 4), | 695 | usb_fill_bulk_urb(us->urb[i], usX2Y->dev, usb_sndbulkpipe(usX2Y->dev, 4), |
696 | usbdata + i, 2, i_usX2Y_04Int, usX2Y); | 696 | usbdata + i, 2, i_usX2Y_04Int, usX2Y); |
697 | #ifdef OLD_USB | 697 | #ifdef OLD_USB |
698 | us->urb[i]->transfer_flags = USB_QUEUE_BULK; | 698 | us->urb[i]->transfer_flags = USB_QUEUE_BULK; |
@@ -740,17 +740,17 @@ static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format) | |||
740 | alternate = 1; | 740 | alternate = 1; |
741 | usX2Y->stride = 4; | 741 | usX2Y->stride = 4; |
742 | } | 742 | } |
743 | list_for_each(p, &usX2Y->chip.midi_list) { | 743 | list_for_each(p, &usX2Y->midi_list) { |
744 | snd_usbmidi_input_stop(p); | 744 | snd_usbmidi_input_stop(p); |
745 | } | 745 | } |
746 | usb_kill_urb(usX2Y->In04urb); | 746 | usb_kill_urb(usX2Y->In04urb); |
747 | if ((err = usb_set_interface(usX2Y->chip.dev, 0, alternate))) { | 747 | if ((err = usb_set_interface(usX2Y->dev, 0, alternate))) { |
748 | snd_printk(KERN_ERR "usb_set_interface error \n"); | 748 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
749 | return err; | 749 | return err; |
750 | } | 750 | } |
751 | usX2Y->In04urb->dev = usX2Y->chip.dev; | 751 | usX2Y->In04urb->dev = usX2Y->dev; |
752 | err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); | 752 | err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); |
753 | list_for_each(p, &usX2Y->chip.midi_list) { | 753 | list_for_each(p, &usX2Y->midi_list) { |
754 | snd_usbmidi_input_start(p); | 754 | snd_usbmidi_input_start(p); |
755 | } | 755 | } |
756 | usX2Y->format = format; | 756 | usX2Y->format = format; |
@@ -955,7 +955,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, | |||
955 | struct snd_pcm *pcm; | 955 | struct snd_pcm *pcm; |
956 | int err, i; | 956 | int err, i; |
957 | struct snd_usX2Y_substream **usX2Y_substream = | 957 | struct snd_usX2Y_substream **usX2Y_substream = |
958 | usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; | 958 | usX2Y(card)->subs + 2 * usX2Y(card)->pcm_devs; |
959 | 959 | ||
960 | for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; | 960 | for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; |
961 | i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { | 961 | i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { |
@@ -971,7 +971,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, | |||
971 | usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]->endpoint = playback_endpoint; | 971 | usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]->endpoint = playback_endpoint; |
972 | usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]->endpoint = capture_endpoint; | 972 | usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]->endpoint = capture_endpoint; |
973 | 973 | ||
974 | err = snd_pcm_new(card, NAME_ALLCAPS" Audio", usX2Y(card)->chip.pcm_devs, | 974 | err = snd_pcm_new(card, NAME_ALLCAPS" Audio", usX2Y(card)->pcm_devs, |
975 | playback_endpoint ? 1 : 0, 1, | 975 | playback_endpoint ? 1 : 0, 1, |
976 | &pcm); | 976 | &pcm); |
977 | if (err < 0) { | 977 | if (err < 0) { |
@@ -987,7 +987,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, | |||
987 | pcm->private_free = snd_usX2Y_pcm_private_free; | 987 | pcm->private_free = snd_usX2Y_pcm_private_free; |
988 | pcm->info_flags = 0; | 988 | pcm->info_flags = 0; |
989 | 989 | ||
990 | sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->chip.pcm_devs); | 990 | sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs); |
991 | 991 | ||
992 | if ((playback_endpoint && | 992 | if ((playback_endpoint && |
993 | 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, | 993 | 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, |
@@ -1001,7 +1001,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, | |||
1001 | snd_usX2Y_pcm_private_free(pcm); | 1001 | snd_usX2Y_pcm_private_free(pcm); |
1002 | return err; | 1002 | return err; |
1003 | } | 1003 | } |
1004 | usX2Y(card)->chip.pcm_devs++; | 1004 | usX2Y(card)->pcm_devs++; |
1005 | 1005 | ||
1006 | return 0; | 1006 | return 0; |
1007 | } | 1007 | } |
@@ -1013,14 +1013,14 @@ int usX2Y_audio_create(struct snd_card *card) | |||
1013 | { | 1013 | { |
1014 | int err = 0; | 1014 | int err = 0; |
1015 | 1015 | ||
1016 | INIT_LIST_HEAD(&usX2Y(card)->chip.pcm_list); | 1016 | INIT_LIST_HEAD(&usX2Y(card)->pcm_list); |
1017 | 1017 | ||
1018 | if (0 > (err = usX2Y_audio_stream_new(card, 0xA, 0x8))) | 1018 | if (0 > (err = usX2Y_audio_stream_new(card, 0xA, 0x8))) |
1019 | return err; | 1019 | return err; |
1020 | if (le16_to_cpu(usX2Y(card)->chip.dev->descriptor.idProduct) == USB_ID_US428) | 1020 | if (le16_to_cpu(usX2Y(card)->dev->descriptor.idProduct) == USB_ID_US428) |
1021 | if (0 > (err = usX2Y_audio_stream_new(card, 0, 0xA))) | 1021 | if (0 > (err = usX2Y_audio_stream_new(card, 0, 0xA))) |
1022 | return err; | 1022 | return err; |
1023 | if (le16_to_cpu(usX2Y(card)->chip.dev->descriptor.idProduct) != USB_ID_US122) | 1023 | if (le16_to_cpu(usX2Y(card)->dev->descriptor.idProduct) != USB_ID_US122) |
1024 | err = usX2Y_rate_set(usX2Y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122. | 1024 | err = usX2Y_rate_set(usX2Y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122. |
1025 | return err; | 1025 | return err; |
1026 | } | 1026 | } |
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 4b2304c2e02d..9ed6c3956ca7 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c | |||
@@ -234,7 +234,7 @@ static void i_usX2Y_usbpcm_urb_complete(struct urb *urb) | |||
234 | 234 | ||
235 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { | 235 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { |
236 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", | 236 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", |
237 | usb_get_current_frame_number(usX2Y->chip.dev), | 237 | usb_get_current_frame_number(usX2Y->dev), |
238 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | 238 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
239 | urb->status, urb->start_frame); | 239 | urb->status, urb->start_frame); |
240 | return; | 240 | return; |
@@ -318,7 +318,7 @@ static int usX2Y_usbpcm_urbs_allocate(struct snd_usX2Y_substream *subs) | |||
318 | int i; | 318 | int i; |
319 | unsigned int pipe; | 319 | unsigned int pipe; |
320 | int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 320 | int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
321 | struct usb_device *dev = subs->usX2Y->chip.dev; | 321 | struct usb_device *dev = subs->usX2Y->dev; |
322 | 322 | ||
323 | pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : | 323 | pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : |
324 | usb_rcvisocpipe(dev, subs->endpoint); | 324 | usb_rcvisocpipe(dev, subs->endpoint); |
@@ -441,7 +441,7 @@ static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs) | |||
441 | unsigned long pack; | 441 | unsigned long pack; |
442 | if (0 == u) | 442 | if (0 == u) |
443 | atomic_set(&subs->state, state_STARTING3); | 443 | atomic_set(&subs->state, state_STARTING3); |
444 | urb->dev = usX2Y->chip.dev; | 444 | urb->dev = usX2Y->dev; |
445 | urb->transfer_flags = URB_ISO_ASAP; | 445 | urb->transfer_flags = URB_ISO_ASAP; |
446 | for (pack = 0; pack < nr_of_packs(); pack++) { | 446 | for (pack = 0; pack < nr_of_packs(); pack++) { |
447 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs()); | 447 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs()); |
@@ -741,7 +741,7 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card) | |||
741 | int err; | 741 | int err; |
742 | struct snd_hwdep *hw; | 742 | struct snd_hwdep *hw; |
743 | struct snd_pcm *pcm; | 743 | struct snd_pcm *pcm; |
744 | struct usb_device *dev = usX2Y(card)->chip.dev; | 744 | struct usb_device *dev = usX2Y(card)->dev; |
745 | if (1 != nr_of_packs()) | 745 | if (1 != nr_of_packs()) |
746 | return 0; | 746 | return 0; |
747 | 747 | ||