aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-03-28 07:03:58 -0400
committerTakashi Iwai <tiwai@suse.de>2011-03-28 07:03:58 -0400
commitcdccfc8dc0bf62a1da327324a8d639139acc9279 (patch)
treedca7934b27d510c9c006558979ebc48e07a531cf /sound/pci
parentb21a8ee67013372f439fbd1591e91d09de49bb9c (diff)
parentc6b358748e19ce7e230b0926ac42696bc485a562 (diff)
Merge branch 'fix/misc' into topic/misc
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/asihpi/asihpi.c137
-rw-r--r--sound/pci/au88x0/au88x0.h4
-rw-r--r--sound/pci/au88x0/au88x0_core.c4
-rw-r--r--sound/pci/hda/patch_analog.c89
-rw-r--r--sound/pci/hda/patch_realtek.c48
-rw-r--r--sound/pci/hda/patch_via.c58
6 files changed, 239 insertions, 101 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 0ac1f98d91a1..f53a31e939c1 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -22,21 +22,6 @@
22 * for any purpose including commercial applications. 22 * for any purpose including commercial applications.
23 */ 23 */
24 24
25/* >0: print Hw params, timer vars. >1: print stream write/copy sizes */
26#define REALLY_VERBOSE_LOGGING 0
27
28#if REALLY_VERBOSE_LOGGING
29#define VPRINTK1 snd_printd
30#else
31#define VPRINTK1(...)
32#endif
33
34#if REALLY_VERBOSE_LOGGING > 1
35#define VPRINTK2 snd_printd
36#else
37#define VPRINTK2(...)
38#endif
39
40#include "hpi_internal.h" 25#include "hpi_internal.h"
41#include "hpimsginit.h" 26#include "hpimsginit.h"
42#include "hpioctl.h" 27#include "hpioctl.h"
@@ -57,11 +42,25 @@
57#include <sound/tlv.h> 42#include <sound/tlv.h>
58#include <sound/hwdep.h> 43#include <sound/hwdep.h>
59 44
60
61MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
62MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); 46MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>");
63MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); 47MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
64 48
49#if defined CONFIG_SND_DEBUG_VERBOSE
50/**
51 * snd_printddd - very verbose debug printk
52 * @format: format string
53 *
54 * Works like snd_printk() for debugging purposes.
55 * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
56 * Must set snd module debug parameter to 3 to enable at runtime.
57 */
58#define snd_printddd(format, args...) \
59 __snd_printk(3, __FILE__, __LINE__, format, ##args)
60#else
61#define snd_printddd(format, args...) do { } while (0)
62#endif
63
65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ 64static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 65static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
67static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 66static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
@@ -289,7 +288,6 @@ static u16 handle_error(u16 err, int line, char *filename)
289#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) 288#define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__)
290 289
291/***************************** GENERAL PCM ****************/ 290/***************************** GENERAL PCM ****************/
292#if REALLY_VERBOSE_LOGGING
293static void print_hwparams(struct snd_pcm_hw_params *p) 291static void print_hwparams(struct snd_pcm_hw_params *p)
294{ 292{
295 snd_printd("HWPARAMS \n"); 293 snd_printd("HWPARAMS \n");
@@ -304,9 +302,6 @@ static void print_hwparams(struct snd_pcm_hw_params *p)
304 snd_printd("periods %d \n", params_periods(p)); 302 snd_printd("periods %d \n", params_periods(p));
305 snd_printd("buffer_size %d \n", params_buffer_size(p)); 303 snd_printd("buffer_size %d \n", params_buffer_size(p));
306} 304}
307#else
308#define print_hwparams(x)
309#endif
310 305
311static snd_pcm_format_t hpi_to_alsa_formats[] = { 306static snd_pcm_format_t hpi_to_alsa_formats[] = {
312 -1, /* INVALID */ 307 -1, /* INVALID */
@@ -381,13 +376,13 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi,
381 "No local sampleclock, err %d\n", err); 376 "No local sampleclock, err %d\n", err);
382 } 377 }
383 378
384 for (idx = 0; idx < 100; idx++) { 379 for (idx = -1; idx < 100; idx++) {
385 if (hpi_sample_clock_query_local_rate( 380 if (idx == -1) {
386 h_control, idx, &sample_rate)) { 381 if (hpi_sample_clock_get_sample_rate(h_control,
387 if (!idx) 382 &sample_rate))
388 snd_printk(KERN_ERR 383 continue;
389 "Local rate query failed\n"); 384 } else if (hpi_sample_clock_query_local_rate(h_control,
390 385 idx, &sample_rate)) {
391 break; 386 break;
392 } 387 }
393 388
@@ -440,8 +435,6 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi,
440 } 435 }
441 } 436 }
442 437
443 /* printk(KERN_INFO "Supported rates %X %d %d\n",
444 rates, rate_min, rate_max); */
445 pcmhw->rates = rates; 438 pcmhw->rates = rates;
446 pcmhw->rate_min = rate_min; 439 pcmhw->rate_min = rate_min;
447 pcmhw->rate_max = rate_max; 440 pcmhw->rate_max = rate_max;
@@ -466,7 +459,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
466 if (err) 459 if (err)
467 return err; 460 return err;
468 461
469 VPRINTK1(KERN_INFO "format %d, %d chans, %d_hz\n", 462 snd_printdd("format %d, %d chans, %d_hz\n",
470 format, params_channels(params), 463 format, params_channels(params),
471 params_rate(params)); 464 params_rate(params));
472 465
@@ -489,13 +482,12 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
489 err = hpi_stream_host_buffer_attach(dpcm->h_stream, 482 err = hpi_stream_host_buffer_attach(dpcm->h_stream,
490 params_buffer_bytes(params), runtime->dma_addr); 483 params_buffer_bytes(params), runtime->dma_addr);
491 if (err == 0) { 484 if (err == 0) {
492 VPRINTK1(KERN_INFO 485 snd_printdd(
493 "stream_host_buffer_attach succeeded %u %lu\n", 486 "stream_host_buffer_attach succeeded %u %lu\n",
494 params_buffer_bytes(params), 487 params_buffer_bytes(params),
495 (unsigned long)runtime->dma_addr); 488 (unsigned long)runtime->dma_addr);
496 } else { 489 } else {
497 snd_printd(KERN_INFO 490 snd_printd("stream_host_buffer_attach error %d\n",
498 "stream_host_buffer_attach error %d\n",
499 err); 491 err);
500 return -ENOMEM; 492 return -ENOMEM;
501 } 493 }
@@ -504,7 +496,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
504 &dpcm->hpi_buffer_attached, 496 &dpcm->hpi_buffer_attached,
505 NULL, NULL, NULL); 497 NULL, NULL, NULL);
506 498
507 VPRINTK1(KERN_INFO "stream_host_buffer_attach status 0x%x\n", 499 snd_printdd("stream_host_buffer_attach status 0x%x\n",
508 dpcm->hpi_buffer_attached); 500 dpcm->hpi_buffer_attached);
509 } 501 }
510 bytes_per_sec = params_rate(params) * params_channels(params); 502 bytes_per_sec = params_rate(params) * params_channels(params);
@@ -517,7 +509,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
517 dpcm->bytes_per_sec = bytes_per_sec; 509 dpcm->bytes_per_sec = bytes_per_sec;
518 dpcm->buffer_bytes = params_buffer_bytes(params); 510 dpcm->buffer_bytes = params_buffer_bytes(params);
519 dpcm->period_bytes = params_period_bytes(params); 511 dpcm->period_bytes = params_period_bytes(params);
520 VPRINTK1(KERN_INFO "buffer_bytes=%d, period_bytes=%d, bps=%d\n", 512 snd_printdd("buffer_bytes=%d, period_bytes=%d, bps=%d\n",
521 dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec); 513 dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec);
522 514
523 return 0; 515 return 0;
@@ -573,7 +565,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
573 struct snd_pcm_substream *s; 565 struct snd_pcm_substream *s;
574 u16 e; 566 u16 e;
575 567
576 VPRINTK1(KERN_INFO "%c%d trigger\n", 568 snd_printdd("%c%d trigger\n",
577 SCHR(substream->stream), substream->number); 569 SCHR(substream->stream), substream->number);
578 switch (cmd) { 570 switch (cmd) {
579 case SNDRV_PCM_TRIGGER_START: 571 case SNDRV_PCM_TRIGGER_START:
@@ -597,7 +589,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
597 * data?? 589 * data??
598 */ 590 */
599 unsigned int preload = ds->period_bytes * 1; 591 unsigned int preload = ds->period_bytes * 1;
600 VPRINTK2(KERN_INFO "%d preload x%x\n", s->number, preload); 592 snd_printddd("%d preload x%x\n", s->number, preload);
601 hpi_handle_error(hpi_outstream_write_buf( 593 hpi_handle_error(hpi_outstream_write_buf(
602 ds->h_stream, 594 ds->h_stream,
603 &runtime->dma_area[0], 595 &runtime->dma_area[0],
@@ -607,7 +599,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
607 } 599 }
608 600
609 if (card->support_grouping) { 601 if (card->support_grouping) {
610 VPRINTK1(KERN_INFO "\t%c%d group\n", 602 snd_printdd("\t%c%d group\n",
611 SCHR(s->stream), 603 SCHR(s->stream),
612 s->number); 604 s->number);
613 e = hpi_stream_group_add( 605 e = hpi_stream_group_add(
@@ -622,7 +614,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
622 } else 614 } else
623 break; 615 break;
624 } 616 }
625 VPRINTK1(KERN_INFO "start\n"); 617 snd_printdd("start\n");
626 /* start the master stream */ 618 /* start the master stream */
627 snd_card_asihpi_pcm_timer_start(substream); 619 snd_card_asihpi_pcm_timer_start(substream);
628 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) || 620 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ||
@@ -644,14 +636,14 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
644 s->runtime->status->state = SNDRV_PCM_STATE_SETUP; 636 s->runtime->status->state = SNDRV_PCM_STATE_SETUP;
645 637
646 if (card->support_grouping) { 638 if (card->support_grouping) {
647 VPRINTK1(KERN_INFO "\t%c%d group\n", 639 snd_printdd("\t%c%d group\n",
648 SCHR(s->stream), 640 SCHR(s->stream),
649 s->number); 641 s->number);
650 snd_pcm_trigger_done(s, substream); 642 snd_pcm_trigger_done(s, substream);
651 } else 643 } else
652 break; 644 break;
653 } 645 }
654 VPRINTK1(KERN_INFO "stop\n"); 646 snd_printdd("stop\n");
655 647
656 /* _prepare and _hwparams reset the stream */ 648 /* _prepare and _hwparams reset the stream */
657 hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); 649 hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
@@ -664,12 +656,12 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream,
664 break; 656 break;
665 657
666 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 658 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
667 VPRINTK1(KERN_INFO "pause release\n"); 659 snd_printdd("pause release\n");
668 hpi_handle_error(hpi_stream_start(dpcm->h_stream)); 660 hpi_handle_error(hpi_stream_start(dpcm->h_stream));
669 snd_card_asihpi_pcm_timer_start(substream); 661 snd_card_asihpi_pcm_timer_start(substream);
670 break; 662 break;
671 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 663 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
672 VPRINTK1(KERN_INFO "pause\n"); 664 snd_printdd("pause\n");
673 snd_card_asihpi_pcm_timer_stop(substream); 665 snd_card_asihpi_pcm_timer_stop(substream);
674 hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); 666 hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
675 break; 667 break;
@@ -741,7 +733,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
741 u16 state; 733 u16 state;
742 u32 buffer_size, bytes_avail, samples_played, on_card_bytes; 734 u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
743 735
744 VPRINTK1(KERN_INFO "%c%d snd_card_asihpi_timer_function\n", 736 snd_printdd("%c%d snd_card_asihpi_timer_function\n",
745 SCHR(substream->stream), substream->number); 737 SCHR(substream->stream), substream->number);
746 738
747 /* find minimum newdata and buffer pos in group */ 739 /* find minimum newdata and buffer pos in group */
@@ -770,10 +762,10 @@ static void snd_card_asihpi_timer_function(unsigned long data)
770 if ((bytes_avail == 0) && 762 if ((bytes_avail == 0) &&
771 (on_card_bytes < ds->pcm_buf_host_rw_ofs)) { 763 (on_card_bytes < ds->pcm_buf_host_rw_ofs)) {
772 hpi_handle_error(hpi_stream_start(ds->h_stream)); 764 hpi_handle_error(hpi_stream_start(ds->h_stream));
773 VPRINTK1(KERN_INFO "P%d start\n", s->number); 765 snd_printdd("P%d start\n", s->number);
774 } 766 }
775 } else if (state == HPI_STATE_DRAINED) { 767 } else if (state == HPI_STATE_DRAINED) {
776 VPRINTK1(KERN_WARNING "P%d drained\n", 768 snd_printd(KERN_WARNING "P%d drained\n",
777 s->number); 769 s->number);
778 /*snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); 770 /*snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
779 continue; */ 771 continue; */
@@ -794,13 +786,13 @@ static void snd_card_asihpi_timer_function(unsigned long data)
794 newdata); 786 newdata);
795 } 787 }
796 788
797 VPRINTK1(KERN_INFO "PB timer hw_ptr x%04lX, appl_ptr x%04lX\n", 789 snd_printdd("hw_ptr x%04lX, appl_ptr x%04lX\n",
798 (unsigned long)frames_to_bytes(runtime, 790 (unsigned long)frames_to_bytes(runtime,
799 runtime->status->hw_ptr), 791 runtime->status->hw_ptr),
800 (unsigned long)frames_to_bytes(runtime, 792 (unsigned long)frames_to_bytes(runtime,
801 runtime->control->appl_ptr)); 793 runtime->control->appl_ptr));
802 794
803 VPRINTK1(KERN_INFO "%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X," 795 snd_printdd("%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X,"
804 " aux=x%04X space=x%04X\n", 796 " aux=x%04X space=x%04X\n",
805 loops, SCHR(s->stream), s->number, 797 loops, SCHR(s->stream), s->number,
806 state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, 798 state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail,
@@ -822,7 +814,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
822 814
823 next_jiffies = max(next_jiffies, 1U); 815 next_jiffies = max(next_jiffies, 1U);
824 dpcm->timer.expires = jiffies + next_jiffies; 816 dpcm->timer.expires = jiffies + next_jiffies;
825 VPRINTK1(KERN_INFO "jif %d buf pos x%04X newdata x%04X xfer x%04X\n", 817 snd_printdd("jif %d buf pos x%04X newdata x%04X xfer x%04X\n",
826 next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); 818 next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
827 819
828 snd_pcm_group_for_each_entry(s, substream) { 820 snd_pcm_group_for_each_entry(s, substream) {
@@ -837,7 +829,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
837 if (xfercount && (on_card_bytes <= ds->period_bytes)) { 829 if (xfercount && (on_card_bytes <= ds->period_bytes)) {
838 if (card->support_mmap) { 830 if (card->support_mmap) {
839 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 831 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
840 VPRINTK2(KERN_INFO "P%d write x%04x\n", 832 snd_printddd("P%d write x%04x\n",
841 s->number, 833 s->number,
842 ds->period_bytes); 834 ds->period_bytes);
843 hpi_handle_error( 835 hpi_handle_error(
@@ -848,7 +840,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
848 xfercount, 840 xfercount,
849 &ds->format)); 841 &ds->format));
850 } else { 842 } else {
851 VPRINTK2(KERN_INFO "C%d read x%04x\n", 843 snd_printddd("C%d read x%04x\n",
852 s->number, 844 s->number,
853 xfercount); 845 xfercount);
854 hpi_handle_error( 846 hpi_handle_error(
@@ -871,7 +863,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
871static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, 863static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream,
872 unsigned int cmd, void *arg) 864 unsigned int cmd, void *arg)
873{ 865{
874 /* snd_printd(KERN_INFO "Playback ioctl %d\n", cmd); */ 866 snd_printdd(KERN_INFO "Playback ioctl %d\n", cmd);
875 return snd_pcm_lib_ioctl(substream, cmd, arg); 867 return snd_pcm_lib_ioctl(substream, cmd, arg);
876} 868}
877 869
@@ -881,7 +873,7 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream *
881 struct snd_pcm_runtime *runtime = substream->runtime; 873 struct snd_pcm_runtime *runtime = substream->runtime;
882 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 874 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
883 875
884 VPRINTK1(KERN_INFO "playback prepare %d\n", substream->number); 876 snd_printdd("playback prepare %d\n", substream->number);
885 877
886 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); 878 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
887 dpcm->pcm_buf_host_rw_ofs = 0; 879 dpcm->pcm_buf_host_rw_ofs = 0;
@@ -898,7 +890,7 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream)
898 snd_pcm_uframes_t ptr; 890 snd_pcm_uframes_t ptr;
899 891
900 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); 892 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
901 /* VPRINTK2(KERN_INFO "playback_pointer=x%04lx\n", (unsigned long)ptr); */ 893 snd_printddd("playback_pointer=x%04lx\n", (unsigned long)ptr);
902 return ptr; 894 return ptr;
903} 895}
904 896
@@ -1014,12 +1006,13 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1014 1006
1015 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1007 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1016 card->update_interval_frames); 1008 card->update_interval_frames);
1009
1017 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1010 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1018 card->update_interval_frames * 2, UINT_MAX); 1011 card->update_interval_frames * 2, UINT_MAX);
1019 1012
1020 snd_pcm_set_sync(substream); 1013 snd_pcm_set_sync(substream);
1021 1014
1022 VPRINTK1(KERN_INFO "playback open\n"); 1015 snd_printdd("playback open\n");
1023 1016
1024 return 0; 1017 return 0;
1025} 1018}
@@ -1030,7 +1023,7 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream)
1030 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 1023 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1031 1024
1032 hpi_handle_error(hpi_outstream_close(dpcm->h_stream)); 1025 hpi_handle_error(hpi_outstream_close(dpcm->h_stream));
1033 VPRINTK1(KERN_INFO "playback close\n"); 1026 snd_printdd("playback close\n");
1034 1027
1035 return 0; 1028 return 0;
1036} 1029}
@@ -1050,13 +1043,13 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream,
1050 if (copy_from_user(runtime->dma_area, src, len)) 1043 if (copy_from_user(runtime->dma_area, src, len))
1051 return -EFAULT; 1044 return -EFAULT;
1052 1045
1053 VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n", 1046 snd_printddd("playback copy%d %u bytes\n",
1054 substream->number, len); 1047 substream->number, len);
1055 1048
1056 hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream, 1049 hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream,
1057 runtime->dma_area, len, &dpcm->format)); 1050 runtime->dma_area, len, &dpcm->format));
1058 1051
1059 dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; 1052 dpcm->pcm_buf_host_rw_ofs += len;
1060 1053
1061 return 0; 1054 return 0;
1062} 1055}
@@ -1066,16 +1059,11 @@ static int snd_card_asihpi_playback_silence(struct snd_pcm_substream *
1066 snd_pcm_uframes_t pos, 1059 snd_pcm_uframes_t pos,
1067 snd_pcm_uframes_t count) 1060 snd_pcm_uframes_t count)
1068{ 1061{
1069 unsigned int len; 1062 /* Usually writes silence to DMA buffer, which should be overwritten
1070 struct snd_pcm_runtime *runtime = substream->runtime; 1063 by real audio later. Our fifos cannot be overwritten, and are not
1071 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 1064 free-running DMAs. Silence is output on fifo underflow.
1072 1065 This callback is still required to allow the copy callback to be used.
1073 len = frames_to_bytes(runtime, count); 1066 */
1074 VPRINTK1(KERN_INFO "playback silence %u bytes\n", len);
1075
1076 memset(runtime->dma_area, 0, len);
1077 hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream,
1078 runtime->dma_area, len, &dpcm->format));
1079 return 0; 1067 return 0;
1080} 1068}
1081 1069
@@ -1110,7 +1098,7 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream)
1110 struct snd_pcm_runtime *runtime = substream->runtime; 1098 struct snd_pcm_runtime *runtime = substream->runtime;
1111 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 1099 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1112 1100
1113 VPRINTK2(KERN_INFO "capture pointer %d=%d\n", 1101 snd_printddd("capture pointer %d=%d\n",
1114 substream->number, dpcm->pcm_buf_dma_ofs); 1102 substream->number, dpcm->pcm_buf_dma_ofs);
1115 /* NOTE Unlike playback can't use actual samples_played 1103 /* NOTE Unlike playback can't use actual samples_played
1116 for the capture position, because those samples aren't yet in 1104 for the capture position, because those samples aren't yet in
@@ -1135,7 +1123,7 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream)
1135 dpcm->pcm_buf_dma_ofs = 0; 1123 dpcm->pcm_buf_dma_ofs = 0;
1136 dpcm->pcm_buf_elapsed_dma_ofs = 0; 1124 dpcm->pcm_buf_elapsed_dma_ofs = 0;
1137 1125
1138 VPRINTK1("Capture Prepare %d\n", substream->number); 1126 snd_printdd("Capture Prepare %d\n", substream->number);
1139 return 0; 1127 return 0;
1140} 1128}
1141 1129
@@ -1198,7 +1186,7 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1198 if (dpcm == NULL) 1186 if (dpcm == NULL)
1199 return -ENOMEM; 1187 return -ENOMEM;
1200 1188
1201 VPRINTK1("hpi_instream_open adapter %d stream %d\n", 1189 snd_printdd("capture open adapter %d stream %d\n",
1202 card->adapter_index, substream->number); 1190 card->adapter_index, substream->number);
1203 1191
1204 err = hpi_handle_error( 1192 err = hpi_handle_error(
@@ -1268,7 +1256,7 @@ static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream,
1268 1256
1269 len = frames_to_bytes(runtime, count); 1257 len = frames_to_bytes(runtime, count);
1270 1258
1271 VPRINTK2(KERN_INFO "capture copy%d %d bytes\n", substream->number, len); 1259 snd_printddd("capture copy%d %d bytes\n", substream->number, len);
1272 hpi_handle_error(hpi_instream_read_buf(dpcm->h_stream, 1260 hpi_handle_error(hpi_instream_read_buf(dpcm->h_stream,
1273 runtime->dma_area, len)); 1261 runtime->dma_area, len));
1274 1262
@@ -2887,6 +2875,9 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2887 if (err) 2875 if (err)
2888 asihpi->update_interval_frames = 512; 2876 asihpi->update_interval_frames = 512;
2889 2877
2878 if (!asihpi->support_mmap)
2879 asihpi->update_interval_frames *= 2;
2880
2890 hpi_handle_error(hpi_instream_open(asihpi->adapter_index, 2881 hpi_handle_error(hpi_instream_open(asihpi->adapter_index,
2891 0, &h_stream)); 2882 0, &h_stream));
2892 2883
@@ -2909,7 +2900,6 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2909 asihpi->support_mrx 2900 asihpi->support_mrx
2910 ); 2901 );
2911 2902
2912
2913 err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); 2903 err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams);
2914 if (err < 0) { 2904 if (err < 0) {
2915 snd_printk(KERN_ERR "pcm_new failed\n"); 2905 snd_printk(KERN_ERR "pcm_new failed\n");
@@ -2944,6 +2934,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2944 sprintf(card->longname, "%s %i", 2934 sprintf(card->longname, "%s %i",
2945 card->shortname, asihpi->adapter_index); 2935 card->shortname, asihpi->adapter_index);
2946 err = snd_card_register(card); 2936 err = snd_card_register(card);
2937
2947 if (!err) { 2938 if (!err) {
2948 hpi_card->snd_card_asihpi = card; 2939 hpi_card->snd_card_asihpi = card;
2949 dev++; 2940 dev++;
diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h
index cf46bba563cf..ecb8f4daf408 100644
--- a/sound/pci/au88x0/au88x0.h
+++ b/sound/pci/au88x0/au88x0.h
@@ -211,7 +211,7 @@ static void vortex_adbdma_startfifo(vortex_t * vortex, int adbdma);
211//static void vortex_adbdma_stopfifo(vortex_t *vortex, int adbdma); 211//static void vortex_adbdma_stopfifo(vortex_t *vortex, int adbdma);
212static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma); 212static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma);
213static void vortex_adbdma_resumefifo(vortex_t * vortex, int adbdma); 213static void vortex_adbdma_resumefifo(vortex_t * vortex, int adbdma);
214static int inline vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma); 214static inline int vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma);
215static void vortex_adbdma_resetup(vortex_t *vortex, int adbdma); 215static void vortex_adbdma_resetup(vortex_t *vortex, int adbdma);
216 216
217#ifndef CHIP_AU8810 217#ifndef CHIP_AU8810
@@ -219,7 +219,7 @@ static void vortex_wtdma_startfifo(vortex_t * vortex, int wtdma);
219static void vortex_wtdma_stopfifo(vortex_t * vortex, int wtdma); 219static void vortex_wtdma_stopfifo(vortex_t * vortex, int wtdma);
220static void vortex_wtdma_pausefifo(vortex_t * vortex, int wtdma); 220static void vortex_wtdma_pausefifo(vortex_t * vortex, int wtdma);
221static void vortex_wtdma_resumefifo(vortex_t * vortex, int wtdma); 221static void vortex_wtdma_resumefifo(vortex_t * vortex, int wtdma);
222static int inline vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma); 222static inline int vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma);
223#endif 223#endif
224 224
225/* global stuff. */ 225/* global stuff. */
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 16c0bdfbb164..489150380eac 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -1249,7 +1249,7 @@ static void vortex_adbdma_resetup(vortex_t *vortex, int adbdma) {
1249 } 1249 }
1250} 1250}
1251 1251
1252static int inline vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma) 1252static inline int vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma)
1253{ 1253{
1254 stream_t *dma = &vortex->dma_adb[adbdma]; 1254 stream_t *dma = &vortex->dma_adb[adbdma];
1255 int temp, page, delta; 1255 int temp, page, delta;
@@ -1506,7 +1506,7 @@ static int vortex_wtdma_getcursubuffer(vortex_t * vortex, int wtdma)
1506 POS_SHIFT) & POS_MASK); 1506 POS_SHIFT) & POS_MASK);
1507} 1507}
1508#endif 1508#endif
1509static int inline vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma) 1509static inline int vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma)
1510{ 1510{
1511 stream_t *dma = &vortex->dma_wt[wtdma]; 1511 stream_t *dma = &vortex->dma_wt[wtdma];
1512 int temp; 1512 int temp;
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 734c6ee55d8a..2942d2a9ea10 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -4256,6 +4256,84 @@ static int ad1984a_thinkpad_init(struct hda_codec *codec)
4256} 4256}
4257 4257
4258/* 4258/*
4259 * Precision R5500
4260 * 0x12 - HP/line-out
4261 * 0x13 - speaker (mono)
4262 * 0x15 - mic-in
4263 */
4264
4265static struct hda_verb ad1984a_precision_verbs[] = {
4266 /* Unmute main output path */
4267 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4268 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x1f}, /* 0dB */
4269 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) + 0x17}, /* 0dB */
4270 /* Analog mixer; mute as default */
4271 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4272 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4273 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4274 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4275 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4276 /* Select mic as input */
4277 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
4278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x27}, /* 0dB */
4279 /* Configure as mic */
4280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
4282 /* HP unmute */
4283 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4284 /* turn on EAPD */
4285 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4286 /* unsolicited event for pin-sense */
4287 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4288 { } /* end */
4289};
4290
4291static struct snd_kcontrol_new ad1984a_precision_mixers[] = {
4292 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4293 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
4294 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4295 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
4297 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
4298 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT),
4299 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
4300 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x13, 0x0, HDA_OUTPUT),
4301 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4302 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4303 { } /* end */
4304};
4305
4306
4307/* mute internal speaker if HP is plugged */
4308static void ad1984a_precision_automute(struct hda_codec *codec)
4309{
4310 unsigned int present;
4311
4312 present = snd_hda_jack_detect(codec, 0x12);
4313 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
4314 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
4315}
4316
4317
4318/* unsolicited event for HP jack sensing */
4319static void ad1984a_precision_unsol_event(struct hda_codec *codec,
4320 unsigned int res)
4321{
4322 if ((res >> 26) != AD1884A_HP_EVENT)
4323 return;
4324 ad1984a_precision_automute(codec);
4325}
4326
4327/* initialize jack-sensing, too */
4328static int ad1984a_precision_init(struct hda_codec *codec)
4329{
4330 ad198x_init(codec);
4331 ad1984a_precision_automute(codec);
4332 return 0;
4333}
4334
4335
4336/*
4259 * HP Touchsmart 4337 * HP Touchsmart
4260 * port-A (0x11) - front hp-out 4338 * port-A (0x11) - front hp-out
4261 * port-B (0x14) - unused 4339 * port-B (0x14) - unused
@@ -4384,6 +4462,7 @@ enum {
4384 AD1884A_MOBILE, 4462 AD1884A_MOBILE,
4385 AD1884A_THINKPAD, 4463 AD1884A_THINKPAD,
4386 AD1984A_TOUCHSMART, 4464 AD1984A_TOUCHSMART,
4465 AD1984A_PRECISION,
4387 AD1884A_MODELS 4466 AD1884A_MODELS
4388}; 4467};
4389 4468
@@ -4393,9 +4472,11 @@ static const char * const ad1884a_models[AD1884A_MODELS] = {
4393 [AD1884A_MOBILE] = "mobile", 4472 [AD1884A_MOBILE] = "mobile",
4394 [AD1884A_THINKPAD] = "thinkpad", 4473 [AD1884A_THINKPAD] = "thinkpad",
4395 [AD1984A_TOUCHSMART] = "touchsmart", 4474 [AD1984A_TOUCHSMART] = "touchsmart",
4475 [AD1984A_PRECISION] = "precision",
4396}; 4476};
4397 4477
4398static struct snd_pci_quirk ad1884a_cfg_tbl[] = { 4478static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
4479 SND_PCI_QUIRK(0x1028, 0x04ac, "Precision R5500", AD1984A_PRECISION),
4399 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), 4480 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
4400 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), 4481 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
4401 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), 4482 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
@@ -4489,6 +4570,14 @@ static int patch_ad1884a(struct hda_codec *codec)
4489 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event; 4570 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
4490 codec->patch_ops.init = ad1984a_thinkpad_init; 4571 codec->patch_ops.init = ad1984a_thinkpad_init;
4491 break; 4572 break;
4573 case AD1984A_PRECISION:
4574 spec->mixers[0] = ad1984a_precision_mixers;
4575 spec->init_verbs[spec->num_init_verbs++] =
4576 ad1984a_precision_verbs;
4577 spec->multiout.dig_out_nid = 0;
4578 codec->patch_ops.unsol_event = ad1984a_precision_unsol_event;
4579 codec->patch_ops.init = ad1984a_precision_init;
4580 break;
4492 case AD1984A_TOUCHSMART: 4581 case AD1984A_TOUCHSMART:
4493 spec->mixers[0] = ad1984a_touchsmart_mixers; 4582 spec->mixers[0] = ad1984a_touchsmart_mixers;
4494 spec->init_verbs[0] = ad1984a_touchsmart_verbs; 4583 spec->init_verbs[0] = ad1984a_touchsmart_verbs;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 28f95d14ba6a..12c6f4508c54 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1290,7 +1290,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
1290 case 0x10ec0883: 1290 case 0x10ec0883:
1291 case 0x10ec0885: 1291 case 0x10ec0885:
1292 case 0x10ec0887: 1292 case 0x10ec0887:
1293 case 0x10ec0889: 1293 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
1294 alc889_coef_init(codec); 1294 alc889_coef_init(codec);
1295 break; 1295 break;
1296 case 0x10ec0888: 1296 case 0x10ec0888:
@@ -9863,7 +9863,6 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
9863 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 9863 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
9864 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), 9864 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
9865 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 9865 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
9866 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9867 9866
9868 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 9867 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9869 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 9868 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
@@ -10700,6 +10699,7 @@ enum {
10700 PINFIX_LENOVO_Y530, 10699 PINFIX_LENOVO_Y530,
10701 PINFIX_PB_M5210, 10700 PINFIX_PB_M5210,
10702 PINFIX_ACER_ASPIRE_7736, 10701 PINFIX_ACER_ASPIRE_7736,
10702 PINFIX_GIGABYTE_880GM,
10703}; 10703};
10704 10704
10705static const struct alc_fixup alc882_fixups[] = { 10705static const struct alc_fixup alc882_fixups[] = {
@@ -10731,6 +10731,13 @@ static const struct alc_fixup alc882_fixups[] = {
10731 .type = ALC_FIXUP_SKU, 10731 .type = ALC_FIXUP_SKU,
10732 .v.sku = ALC_FIXUP_SKU_IGNORE, 10732 .v.sku = ALC_FIXUP_SKU_IGNORE,
10733 }, 10733 },
10734 [PINFIX_GIGABYTE_880GM] = {
10735 .type = ALC_FIXUP_PINS,
10736 .v.pins = (const struct alc_pincfg[]) {
10737 { 0x14, 0x1114410 }, /* set as speaker */
10738 { }
10739 }
10740 },
10734}; 10741};
10735 10742
10736static struct snd_pci_quirk alc882_fixup_tbl[] = { 10743static struct snd_pci_quirk alc882_fixup_tbl[] = {
@@ -10738,6 +10745,7 @@ static struct snd_pci_quirk alc882_fixup_tbl[] = {
10738 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), 10745 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
10739 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 10746 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10740 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), 10747 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
10748 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", PINFIX_GIGABYTE_880GM),
10741 {} 10749 {}
10742}; 10750};
10743 10751
@@ -16008,9 +16016,12 @@ static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
16008 return err; 16016 return err;
16009 } else { 16017 } else {
16010 const char *name = pfx; 16018 const char *name = pfx;
16011 if (!name) 16019 int index = i;
16020 if (!name) {
16012 name = chname[i]; 16021 name = chname[i];
16013 err = __alc861_create_out_sw(codec, name, nid, i, 3); 16022 index = 0;
16023 }
16024 err = __alc861_create_out_sw(codec, name, nid, index, 3);
16014 if (err < 0) 16025 if (err < 0)
16015 return err; 16026 return err;
16016 } 16027 }
@@ -17161,16 +17172,19 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17161 return err; 17172 return err;
17162 } else { 17173 } else {
17163 const char *name = pfx; 17174 const char *name = pfx;
17164 if (!name) 17175 int index = i;
17176 if (!name) {
17165 name = chname[i]; 17177 name = chname[i];
17178 index = 0;
17179 }
17166 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, 17180 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17167 name, i, 17181 name, index,
17168 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 17182 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17169 HDA_OUTPUT)); 17183 HDA_OUTPUT));
17170 if (err < 0) 17184 if (err < 0)
17171 return err; 17185 return err;
17172 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, 17186 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17173 name, i, 17187 name, index,
17174 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 17188 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
17175 HDA_INPUT)); 17189 HDA_INPUT));
17176 if (err < 0) 17190 if (err < 0)
@@ -18768,8 +18782,6 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
18768 ALC662_3ST_6ch_DIG), 18782 ALC662_3ST_6ch_DIG),
18769 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO), 18783 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
18770 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), 18784 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
18771 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18772 ALC662_3ST_6ch_DIG),
18773 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13), 18785 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
18774 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), 18786 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
18775 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA), 18787 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
@@ -19219,12 +19231,15 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19219 return err; 19231 return err;
19220 } else { 19232 } else {
19221 const char *name = pfx; 19233 const char *name = pfx;
19222 if (!name) 19234 int index = i;
19235 if (!name) {
19223 name = chname[i]; 19236 name = chname[i];
19224 err = __alc662_add_vol_ctl(spec, name, nid, i, 3); 19237 index = 0;
19238 }
19239 err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
19225 if (err < 0) 19240 if (err < 0)
19226 return err; 19241 return err;
19227 err = __alc662_add_sw_ctl(spec, name, mix, i, 3); 19242 err = __alc662_add_sw_ctl(spec, name, mix, index, 3);
19228 if (err < 0) 19243 if (err < 0)
19229 return err; 19244 return err;
19230 } 19245 }
@@ -19440,6 +19455,7 @@ enum {
19440 ALC662_FIXUP_IDEAPAD, 19455 ALC662_FIXUP_IDEAPAD,
19441 ALC272_FIXUP_MARIO, 19456 ALC272_FIXUP_MARIO,
19442 ALC662_FIXUP_CZC_P10T, 19457 ALC662_FIXUP_CZC_P10T,
19458 ALC662_FIXUP_GIGABYTE,
19443}; 19459};
19444 19460
19445static const struct alc_fixup alc662_fixups[] = { 19461static const struct alc_fixup alc662_fixups[] = {
@@ -19468,12 +19484,20 @@ static const struct alc_fixup alc662_fixups[] = {
19468 {} 19484 {}
19469 } 19485 }
19470 }, 19486 },
19487 [ALC662_FIXUP_GIGABYTE] = {
19488 .type = ALC_FIXUP_PINS,
19489 .v.pins = (const struct alc_pincfg[]) {
19490 { 0x14, 0x1114410 }, /* set as speaker */
19491 { }
19492 }
19493 },
19471}; 19494};
19472 19495
19473static struct snd_pci_quirk alc662_fixup_tbl[] = { 19496static struct snd_pci_quirk alc662_fixup_tbl[] = {
19474 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), 19497 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
19475 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 19498 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
19476 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 19499 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
19500 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", ALC662_FIXUP_GIGABYTE),
19477 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 19501 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
19478 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 19502 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19479 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), 19503 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 63b0054200a8..1371b57c11e8 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -159,6 +159,7 @@ struct via_spec {
159#endif 159#endif
160}; 160};
161 161
162static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
162static struct via_spec * via_new_spec(struct hda_codec *codec) 163static struct via_spec * via_new_spec(struct hda_codec *codec)
163{ 164{
164 struct via_spec *spec; 165 struct via_spec *spec;
@@ -169,6 +170,10 @@ static struct via_spec * via_new_spec(struct hda_codec *codec)
169 170
170 codec->spec = spec; 171 codec->spec = spec;
171 spec->codec = codec; 172 spec->codec = codec;
173 spec->codec_type = get_codec_type(codec);
174 /* VT1708BCE & VT1708S are almost same */
175 if (spec->codec_type == VT1708BCE)
176 spec->codec_type = VT1708S;
172 return spec; 177 return spec;
173} 178}
174 179
@@ -1101,6 +1106,7 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol,
1101 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1102 struct via_spec *spec = codec->spec; 1107 struct via_spec *spec = codec->spec;
1103 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1108 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1109 int ret;
1104 1110
1105 if (!spec->mux_nids[adc_idx]) 1111 if (!spec->mux_nids[adc_idx])
1106 return -EINVAL; 1112 return -EINVAL;
@@ -1109,12 +1115,14 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol,
1109 AC_VERB_GET_POWER_STATE, 0x00) != AC_PWRST_D0) 1115 AC_VERB_GET_POWER_STATE, 0x00) != AC_PWRST_D0)
1110 snd_hda_codec_write(codec, spec->mux_nids[adc_idx], 0, 1116 snd_hda_codec_write(codec, spec->mux_nids[adc_idx], 0,
1111 AC_VERB_SET_POWER_STATE, AC_PWRST_D0); 1117 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
1112 /* update jack power state */
1113 set_jack_power_state(codec);
1114 1118
1115 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 1119 ret = snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
1116 spec->mux_nids[adc_idx], 1120 spec->mux_nids[adc_idx],
1117 &spec->cur_mux[adc_idx]); 1121 &spec->cur_mux[adc_idx]);
1122 /* update jack power state */
1123 set_jack_power_state(codec);
1124
1125 return ret;
1118} 1126}
1119 1127
1120static int via_independent_hp_info(struct snd_kcontrol *kcontrol, 1128static int via_independent_hp_info(struct snd_kcontrol *kcontrol,
@@ -1188,8 +1196,16 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol,
1188 /* Get Independent Mode index of headphone pin widget */ 1196 /* Get Independent Mode index of headphone pin widget */
1189 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel 1197 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel
1190 ? 1 : 0; 1198 ? 1 : 0;
1191 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); 1199 if (spec->codec_type == VT1718S)
1200 snd_hda_codec_write(codec, nid, 0,
1201 AC_VERB_SET_CONNECT_SEL, pinsel ? 2 : 0);
1202 else
1203 snd_hda_codec_write(codec, nid, 0,
1204 AC_VERB_SET_CONNECT_SEL, pinsel);
1192 1205
1206 if (spec->codec_type == VT1812)
1207 snd_hda_codec_write(codec, 0x35, 0,
1208 AC_VERB_SET_CONNECT_SEL, pinsel);
1193 if (spec->multiout.hp_nid && spec->multiout.hp_nid 1209 if (spec->multiout.hp_nid && spec->multiout.hp_nid
1194 != spec->multiout.dac_nids[HDA_FRONT]) 1210 != spec->multiout.dac_nids[HDA_FRONT])
1195 snd_hda_codec_setup_stream(codec, spec->multiout.hp_nid, 1211 snd_hda_codec_setup_stream(codec, spec->multiout.hp_nid,
@@ -1208,6 +1224,8 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol,
1208 activate_ctl(codec, "Headphone Playback Switch", 1224 activate_ctl(codec, "Headphone Playback Switch",
1209 spec->hp_independent_mode); 1225 spec->hp_independent_mode);
1210 } 1226 }
1227 /* update jack power state */
1228 set_jack_power_state(codec);
1211 return 0; 1229 return 0;
1212} 1230}
1213 1231
@@ -1248,9 +1266,12 @@ static int via_hp_build(struct hda_codec *codec)
1248 break; 1266 break;
1249 } 1267 }
1250 1268
1251 nums = snd_hda_get_connections(codec, nid, conn, HDA_MAX_CONNECTIONS); 1269 if (spec->codec_type != VT1708) {
1252 if (nums <= 1) 1270 nums = snd_hda_get_connections(codec, nid,
1253 return 0; 1271 conn, HDA_MAX_CONNECTIONS);
1272 if (nums <= 1)
1273 return 0;
1274 }
1254 1275
1255 knew = via_clone_control(spec, &via_hp_mixer[0]); 1276 knew = via_clone_control(spec, &via_hp_mixer[0]);
1256 if (knew == NULL) 1277 if (knew == NULL)
@@ -1310,6 +1331,11 @@ static void mute_aa_path(struct hda_codec *codec, int mute)
1310 start_idx = 2; 1331 start_idx = 2;
1311 end_idx = 4; 1332 end_idx = 4;
1312 break; 1333 break;
1334 case VT1718S:
1335 nid_mixer = 0x21;
1336 start_idx = 1;
1337 end_idx = 3;
1338 break;
1313 default: 1339 default:
1314 return; 1340 return;
1315 } 1341 }
@@ -2185,10 +2211,6 @@ static int via_init(struct hda_codec *codec)
2185 for (i = 0; i < spec->num_iverbs; i++) 2211 for (i = 0; i < spec->num_iverbs; i++)
2186 snd_hda_sequence_write(codec, spec->init_verbs[i]); 2212 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2187 2213
2188 spec->codec_type = get_codec_type(codec);
2189 if (spec->codec_type == VT1708BCE)
2190 spec->codec_type = VT1708S; /* VT1708BCE & VT1708S are almost
2191 same */
2192 /* Lydia Add for EAPD enable */ 2214 /* Lydia Add for EAPD enable */
2193 if (!spec->dig_in_nid) { /* No Digital In connection */ 2215 if (!spec->dig_in_nid) { /* No Digital In connection */
2194 if (spec->dig_in_pin) { 2216 if (spec->dig_in_pin) {
@@ -2438,7 +2460,14 @@ static int vt_auto_create_analog_input_ctls(struct hda_codec *codec,
2438 else 2460 else
2439 type_idx = 0; 2461 type_idx = 0;
2440 label = hda_get_autocfg_input_label(codec, cfg, i); 2462 label = hda_get_autocfg_input_label(codec, cfg, i);
2441 err = via_new_analog_input(spec, label, type_idx, idx, cap_nid); 2463 if (spec->codec_type == VT1708S ||
2464 spec->codec_type == VT1702 ||
2465 spec->codec_type == VT1716S)
2466 err = via_new_analog_input(spec, label, type_idx,
2467 idx+1, cap_nid);
2468 else
2469 err = via_new_analog_input(spec, label, type_idx,
2470 idx, cap_nid);
2442 if (err < 0) 2471 if (err < 0)
2443 return err; 2472 return err;
2444 snd_hda_add_imux_item(imux, label, idx, NULL); 2473 snd_hda_add_imux_item(imux, label, idx, NULL);
@@ -4147,6 +4176,11 @@ static int patch_vt1708S(struct hda_codec *codec)
4147 spec->stream_name_analog = "VT1708BCE Analog"; 4176 spec->stream_name_analog = "VT1708BCE Analog";
4148 spec->stream_name_digital = "VT1708BCE Digital"; 4177 spec->stream_name_digital = "VT1708BCE Digital";
4149 } 4178 }
4179 /* correct names for VT1818S */
4180 if (codec->vendor_id == 0x11060440) {
4181 spec->stream_name_analog = "VT1818S Analog";
4182 spec->stream_name_digital = "VT1818S Digital";
4183 }
4150 return 0; 4184 return 0;
4151} 4185}
4152 4186