aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/ac97/ac97_codec.c2
-rw-r--r--sound/pci/ad1889.c2
-rw-r--r--sound/pci/ali5451/ali5451.c4
-rw-r--r--sound/pci/als300.c9
-rw-r--r--sound/pci/als4000.c2
-rw-r--r--sound/pci/asihpi/asihpi.c294
-rw-r--r--sound/pci/asihpi/hpi.h74
-rw-r--r--sound/pci/asihpi/hpi6000.c61
-rw-r--r--sound/pci/asihpi/hpi6000.h2
-rw-r--r--sound/pci/asihpi/hpi6205.c57
-rw-r--r--sound/pci/asihpi/hpi_internal.h115
-rw-r--r--sound/pci/asihpi/hpi_version.h32
-rw-r--r--sound/pci/asihpi/hpicmn.c32
-rw-r--r--sound/pci/asihpi/hpicmn.h13
-rw-r--r--sound/pci/asihpi/hpidebug.c2
-rw-r--r--sound/pci/asihpi/hpidebug.h2
-rw-r--r--sound/pci/asihpi/hpidspcd.c30
-rw-r--r--sound/pci/asihpi/hpidspcd.h4
-rw-r--r--sound/pci/asihpi/hpifunc.c10
-rw-r--r--sound/pci/asihpi/hpimsginit.c2
-rw-r--r--sound/pci/asihpi/hpimsginit.h2
-rw-r--r--sound/pci/asihpi/hpimsgx.c3
-rw-r--r--sound/pci/asihpi/hpimsgx.h2
-rw-r--r--sound/pci/asihpi/hpioctl.c63
-rw-r--r--sound/pci/asihpi/hpioctl.h2
-rw-r--r--sound/pci/asihpi/hpios.c2
-rw-r--r--sound/pci/asihpi/hpios.h16
-rw-r--r--sound/pci/asihpi/hpipcida.h2
-rw-r--r--sound/pci/atiixp.c4
-rw-r--r--sound/pci/atiixp_modem.c2
-rw-r--r--sound/pci/au88x0/au88x0.c2
-rw-r--r--sound/pci/au88x0/au88x0_core.c10
-rw-r--r--sound/pci/au88x0/au88x0_pcm.c7
-rw-r--r--sound/pci/au88x0/au88x0_xtalk.c151
-rw-r--r--sound/pci/aw2/aw2-alsa.c2
-rw-r--r--sound/pci/azt3328.c2
-rw-r--r--sound/pci/bt87x.c4
-rw-r--r--sound/pci/ca0106/ca0106_main.c2
-rw-r--r--sound/pci/cmipci.c4
-rw-r--r--sound/pci/cs4281.c4
-rw-r--r--sound/pci/cs46xx/cs46xx.c8
-rw-r--r--sound/pci/cs5530.c9
-rw-r--r--sound/pci/cs5535audio/cs5535audio.c2
-rw-r--r--sound/pci/ctxfi/ctsrc.c2
-rw-r--r--sound/pci/ctxfi/cttimer.c4
-rw-r--r--sound/pci/ctxfi/xfi.c2
-rw-r--r--sound/pci/echoaudio/echoaudio.c2
-rw-r--r--sound/pci/emu10k1/emu10k1.c4
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c12
-rw-r--r--sound/pci/emu10k1/emu10k1x.c2
-rw-r--r--sound/pci/ens1370.c4
-rw-r--r--sound/pci/es1938.c2
-rw-r--r--sound/pci/es1968.c4
-rw-r--r--sound/pci/fm801.c2
-rw-r--r--sound/pci/hda/Kconfig1
-rw-r--r--sound/pci/hda/Makefile2
-rw-r--r--sound/pci/hda/alc262_quirks.c875
-rw-r--r--sound/pci/hda/alc880_quirks.c193
-rw-r--r--sound/pci/hda/alc882_quirks.c2867
-rw-r--r--sound/pci/hda/hda_codec.c302
-rw-r--r--sound/pci/hda/hda_codec.h6
-rw-r--r--sound/pci/hda/hda_intel.c112
-rw-r--r--sound/pci/hda/hda_jack.c353
-rw-r--r--sound/pci/hda/hda_jack.h86
-rw-r--r--sound/pci/hda/hda_local.h51
-rw-r--r--sound/pci/hda/hda_proc.c2
-rw-r--r--sound/pci/hda/patch_analog.c1
-rw-r--r--sound/pci/hda/patch_ca0110.c6
-rw-r--r--sound/pci/hda/patch_cirrus.c187
-rw-r--r--sound/pci/hda/patch_conexant.c79
-rw-r--r--sound/pci/hda/patch_hdmi.c59
-rw-r--r--sound/pci/hda/patch_realtek.c693
-rw-r--r--sound/pci/hda/patch_sigmatel.c248
-rw-r--r--sound/pci/hda/patch_via.c30
-rw-r--r--sound/pci/ice1712/amp.c7
-rw-r--r--sound/pci/ice1712/envy24ht.h1
-rw-r--r--sound/pci/ice1712/ice1712.c4
-rw-r--r--sound/pci/ice1712/ice1724.c65
-rw-r--r--sound/pci/intel8x0.c6
-rw-r--r--sound/pci/intel8x0m.c2
-rw-r--r--sound/pci/korg1212/korg1212.c2
-rw-r--r--sound/pci/lola/lola.c2
-rw-r--r--sound/pci/lx6464es/lx6464es.c2
-rw-r--r--sound/pci/maestro3.c4
-rw-r--r--sound/pci/mixart/mixart.c2
-rw-r--r--sound/pci/nm256/nm256.c12
-rw-r--r--sound/pci/oxygen/oxygen.c2
-rw-r--r--sound/pci/oxygen/virtuoso.c2
-rw-r--r--sound/pci/oxygen/xonar_cs43xx.c1
-rw-r--r--sound/pci/oxygen/xonar_dg.c3
-rw-r--r--sound/pci/oxygen/xonar_wm87x6.c6
-rw-r--r--sound/pci/pcxhr/pcxhr.c4
-rw-r--r--sound/pci/riptide/riptide.c2
-rw-r--r--sound/pci/rme32.c4
-rw-r--r--sound/pci/rme96.c2
-rw-r--r--sound/pci/rme9652/hdsp.c5
-rw-r--r--sound/pci/rme9652/hdspm.c32
-rw-r--r--sound/pci/rme9652/rme9652.c4
-rw-r--r--sound/pci/sis7019.c31
-rw-r--r--sound/pci/sonicvibes.c6
-rw-r--r--sound/pci/trident/trident.c2
-rw-r--r--sound/pci/via82xx.c4
-rw-r--r--sound/pci/via82xx_modem.c2
-rw-r--r--sound/pci/vx222/vx222.c4
-rw-r--r--sound/pci/ymfpci/ymfpci.c4
105 files changed, 2183 insertions, 5293 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index fac51eef272..9473fca9681 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -42,7 +42,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
42MODULE_DESCRIPTION("Universal interface for Audio Codec '97"); 42MODULE_DESCRIPTION("Universal interface for Audio Codec '97");
43MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
44 44
45static int enable_loopback; 45static bool enable_loopback;
46 46
47module_param(enable_loopback, bool, 0444); 47module_param(enable_loopback, bool, 0444);
48MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control"); 48MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control");
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index 6e311184bb1..9d91d61902b 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -66,7 +66,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
66module_param_array(id, charp, NULL, 0444); 66module_param_array(id, charp, NULL, 0444);
67MODULE_PARM_DESC(id, "ID string for the AD1889 soundcard."); 67MODULE_PARM_DESC(id, "ID string for the AD1889 soundcard.");
68 68
69static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 69static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
70module_param_array(enable, bool, NULL, 0444); 70module_param_array(enable, bool, NULL, 0444);
71MODULE_PARM_DESC(enable, "Enable AD1889 soundcard."); 71MODULE_PARM_DESC(enable, "Enable AD1889 soundcard.");
72 72
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index ef85ac5d900..bdd6164e9c7 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -48,7 +48,7 @@ MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}");
48static int index = SNDRV_DEFAULT_IDX1; /* Index */ 48static int index = SNDRV_DEFAULT_IDX1; /* Index */
49static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 49static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
50static int pcm_channels = 32; 50static int pcm_channels = 32;
51static int spdif; 51static bool spdif;
52 52
53module_param(index, int, 0444); 53module_param(index, int, 0444);
54MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio."); 54MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio.");
@@ -60,7 +60,7 @@ module_param(spdif, bool, 0444);
60MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); 60MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
61 61
62/* just for backward compatibility */ 62/* just for backward compatibility */
63static int enable; 63static bool enable;
64module_param(enable, bool, 0444); 64module_param(enable, bool, 0444);
65 65
66 66
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 8dc77a0a5d8..8196e229b2d 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -115,7 +115,14 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS300},{Avance Logic,ALS300+}}");
115 115
116static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 116static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
117static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 117static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
118static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 118static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
119
120module_param_array(index, int, NULL, 0444);
121MODULE_PARM_DESC(index, "Index value for ALS300 sound card.");
122module_param_array(id, charp, NULL, 0444);
123MODULE_PARM_DESC(id, "ID string for ALS300 sound card.");
124module_param_array(enable, bool, NULL, 0444);
125MODULE_PARM_DESC(enable, "Enable ALS300 sound card.");
119 126
120struct snd_als300 { 127struct snd_als300 {
121 unsigned long port; 128 unsigned long port;
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 28ef40e01cc..3269b8011ea 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -90,7 +90,7 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}");
90 90
91static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 91static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
92static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 92static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
93static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 93static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
94#ifdef SUPPORT_JOYSTICK 94#ifdef SUPPORT_JOYSTICK
95static int joystick_port[SNDRV_CARDS]; 95static int joystick_port[SNDRV_CARDS];
96#endif 96#endif
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index f4b9e2b7ae8..e8de831f98b 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -23,8 +23,11 @@
23 */ 23 */
24 24
25#include "hpi_internal.h" 25#include "hpi_internal.h"
26#include "hpi_version.h"
26#include "hpimsginit.h" 27#include "hpimsginit.h"
27#include "hpioctl.h" 28#include "hpioctl.h"
29#include "hpicmn.h"
30
28 31
29#include <linux/pci.h> 32#include <linux/pci.h>
30#include <linux/init.h> 33#include <linux/init.h>
@@ -44,7 +47,8 @@
44 47
45MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
46MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); 49MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>");
47MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); 50MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx "
51 HPI_VER_STRING);
48 52
49#if defined CONFIG_SND_DEBUG_VERBOSE 53#if defined CONFIG_SND_DEBUG_VERBOSE
50/** 54/**
@@ -63,8 +67,8 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx");
63 67
64static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ 68static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
65static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 69static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
66static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 70static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
67static int enable_hpi_hwdep = 1; 71static bool enable_hpi_hwdep = 1;
68 72
69module_param_array(index, int, NULL, S_IRUGO); 73module_param_array(index, int, NULL, S_IRUGO);
70MODULE_PARM_DESC(index, "ALSA index value for AudioScience soundcard."); 74MODULE_PARM_DESC(index, "ALSA index value for AudioScience soundcard.");
@@ -119,12 +123,7 @@ struct clk_cache {
119struct snd_card_asihpi { 123struct snd_card_asihpi {
120 struct snd_card *card; 124 struct snd_card *card;
121 struct pci_dev *pci; 125 struct pci_dev *pci;
122 u16 adapter_index; 126 struct hpi_adapter *hpi;
123 u32 serial_number;
124 u16 type;
125 u16 version;
126 u16 num_outstreams;
127 u16 num_instreams;
128 127
129 u32 h_mixer; 128 u32 h_mixer;
130 struct clk_cache cc; 129 struct clk_cache cc;
@@ -135,6 +134,8 @@ struct snd_card_asihpi {
135 u16 update_interval_frames; 134 u16 update_interval_frames;
136 u16 in_max_chans; 135 u16 in_max_chans;
137 u16 out_max_chans; 136 u16 out_max_chans;
137 u16 in_min_chans;
138 u16 out_min_chans;
138}; 139};
139 140
140/* Per stream data */ 141/* Per stream data */
@@ -495,6 +496,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
495 496
496 snd_printdd("stream_host_buffer_attach status 0x%x\n", 497 snd_printdd("stream_host_buffer_attach status 0x%x\n",
497 dpcm->hpi_buffer_attached); 498 dpcm->hpi_buffer_attached);
499
498 } 500 }
499 bytes_per_sec = params_rate(params) * params_channels(params); 501 bytes_per_sec = params_rate(params) * params_channels(params);
500 width = snd_pcm_format_width(params_format(params)); 502 width = snd_pcm_format_width(params_format(params));
@@ -757,8 +759,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
757 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 759 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
758 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; 760 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail;
759 if (state == HPI_STATE_STOPPED) { 761 if (state == HPI_STATE_STOPPED) {
760 if ((bytes_avail == 0) && 762 if (bytes_avail == 0) {
761 (on_card_bytes < ds->pcm_buf_host_rw_ofs)) {
762 hpi_handle_error(hpi_stream_start(ds->h_stream)); 763 hpi_handle_error(hpi_stream_start(ds->h_stream));
763 snd_printdd("P%d start\n", s->number); 764 snd_printdd("P%d start\n", s->number);
764 ds->drained_count = 0; 765 ds->drained_count = 0;
@@ -767,7 +768,7 @@ static void snd_card_asihpi_timer_function(unsigned long data)
767 snd_printd(KERN_WARNING "P%d drained\n", 768 snd_printd(KERN_WARNING "P%d drained\n",
768 s->number); 769 s->number);
769 ds->drained_count++; 770 ds->drained_count++;
770 if (ds->drained_count > 2) { 771 if (ds->drained_count > 20) {
771 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); 772 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
772 continue; 773 continue;
773 } 774 }
@@ -888,8 +889,8 @@ static void snd_card_asihpi_timer_function(unsigned long data)
888 pd, xfer2)); 889 pd, xfer2));
889 } 890 }
890 } 891 }
891 ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount; 892 ds->pcm_buf_host_rw_ofs += xfercount;
892 ds->pcm_buf_elapsed_dma_ofs = pcm_buf_dma_ofs; 893 ds->pcm_buf_elapsed_dma_ofs += xfercount;
893 snd_pcm_period_elapsed(s); 894 snd_pcm_period_elapsed(s);
894 } 895 }
895 } 896 }
@@ -902,7 +903,9 @@ static void snd_card_asihpi_timer_function(unsigned long data)
902static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, 903static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream,
903 unsigned int cmd, void *arg) 904 unsigned int cmd, void *arg)
904{ 905{
905 snd_printddd(KERN_INFO "P%d ioctl %d\n", substream->number, cmd); 906 char name[16];
907 snd_pcm_debug_name(substream, name, sizeof(name));
908 snd_printddd(KERN_INFO "%s ioctl %d\n", name, cmd);
906 return snd_pcm_lib_ioctl(substream, cmd, arg); 909 return snd_pcm_lib_ioctl(substream, cmd, arg);
907} 910}
908 911
@@ -927,21 +930,23 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream)
927 struct snd_pcm_runtime *runtime = substream->runtime; 930 struct snd_pcm_runtime *runtime = substream->runtime;
928 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; 931 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
929 snd_pcm_uframes_t ptr; 932 snd_pcm_uframes_t ptr;
933 char name[16];
934 snd_pcm_debug_name(substream, name, sizeof(name));
930 935
931 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); 936 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
932 snd_printddd("P%d pointer = 0x%04lx\n", substream->number, (unsigned long)ptr); 937 snd_printddd("%s pointer = 0x%04lx\n", name, (unsigned long)ptr);
933 return ptr; 938 return ptr;
934} 939}
935 940
936static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, 941static u64 snd_card_asihpi_playback_formats(struct snd_card_asihpi *asihpi,
937 u32 h_stream, 942 u32 h_stream)
938 struct snd_pcm_hardware *pcmhw)
939{ 943{
940 struct hpi_format hpi_format; 944 struct hpi_format hpi_format;
941 u16 format; 945 u16 format;
942 u16 err; 946 u16 err;
943 u32 h_control; 947 u32 h_control;
944 u32 sample_rate = 48000; 948 u32 sample_rate = 48000;
949 u64 formats = 0;
945 950
946 /* on cards without SRC, must query at valid rate, 951 /* on cards without SRC, must query at valid rate,
947 * maybe set by external sync 952 * maybe set by external sync
@@ -956,41 +961,29 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi,
956 961
957 for (format = HPI_FORMAT_PCM8_UNSIGNED; 962 for (format = HPI_FORMAT_PCM8_UNSIGNED;
958 format <= HPI_FORMAT_PCM24_SIGNED; format++) { 963 format <= HPI_FORMAT_PCM24_SIGNED; format++) {
959 err = hpi_format_create(&hpi_format, 964 err = hpi_format_create(&hpi_format, asihpi->out_max_chans,
960 2, format, sample_rate, 128000, 0); 965 format, sample_rate, 128000, 0);
961 if (!err) 966 if (!err)
962 err = hpi_outstream_query_format(h_stream, 967 err = hpi_outstream_query_format(h_stream, &hpi_format);
963 &hpi_format);
964 if (!err && (hpi_to_alsa_formats[format] != -1)) 968 if (!err && (hpi_to_alsa_formats[format] != -1))
965 pcmhw->formats |= 969 formats |= (1ULL << hpi_to_alsa_formats[format]);
966 (1ULL << hpi_to_alsa_formats[format]);
967 } 970 }
971 return formats;
968} 972}
969 973
970static struct snd_pcm_hardware snd_card_asihpi_playback = {
971 .channels_min = 1,
972 .channels_max = 2,
973 .buffer_bytes_max = BUFFER_BYTES_MAX,
974 .period_bytes_min = PERIOD_BYTES_MIN,
975 .period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN,
976 .periods_min = PERIODS_MIN,
977 .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN,
978 .fifo_size = 0,
979};
980
981static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) 974static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
982{ 975{
983 struct snd_pcm_runtime *runtime = substream->runtime; 976 struct snd_pcm_runtime *runtime = substream->runtime;
984 struct snd_card_asihpi_pcm *dpcm; 977 struct snd_card_asihpi_pcm *dpcm;
985 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 978 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
979 struct snd_pcm_hardware snd_card_asihpi_playback;
986 int err; 980 int err;
987 981
988 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); 982 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
989 if (dpcm == NULL) 983 if (dpcm == NULL)
990 return -ENOMEM; 984 return -ENOMEM;
991 985
992 err = 986 err = hpi_outstream_open(card->hpi->adapter->index,
993 hpi_outstream_open(card->adapter_index,
994 substream->number, &dpcm->h_stream); 987 substream->number, &dpcm->h_stream);
995 hpi_handle_error(err); 988 hpi_handle_error(err);
996 if (err) 989 if (err)
@@ -1012,12 +1005,19 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1012 runtime->private_data = dpcm; 1005 runtime->private_data = dpcm;
1013 runtime->private_free = snd_card_asihpi_runtime_free; 1006 runtime->private_free = snd_card_asihpi_runtime_free;
1014 1007
1015 snd_card_asihpi_playback.channels_max = card->out_max_chans; 1008 memset(&snd_card_asihpi_playback, 0, sizeof(snd_card_asihpi_playback));
1009 snd_card_asihpi_playback.buffer_bytes_max = BUFFER_BYTES_MAX;
1010 snd_card_asihpi_playback.period_bytes_min = PERIOD_BYTES_MIN;
1016 /*?snd_card_asihpi_playback.period_bytes_min = 1011 /*?snd_card_asihpi_playback.period_bytes_min =
1017 card->out_max_chans * 4096; */ 1012 card->out_max_chans * 4096; */
1018 1013 snd_card_asihpi_playback.period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN;
1019 snd_card_asihpi_playback_format(card, dpcm->h_stream, 1014 snd_card_asihpi_playback.periods_min = PERIODS_MIN;
1020 &snd_card_asihpi_playback); 1015 snd_card_asihpi_playback.periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN;
1016 /* snd_card_asihpi_playback.fifo_size = 0; */
1017 snd_card_asihpi_playback.channels_max = card->out_max_chans;
1018 snd_card_asihpi_playback.channels_min = card->out_min_chans;
1019 snd_card_asihpi_playback.formats =
1020 snd_card_asihpi_playback_formats(card, dpcm->h_stream);
1021 1021
1022 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_playback); 1022 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_playback);
1023 1023
@@ -1029,8 +1029,10 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1029 SNDRV_PCM_INFO_MMAP | 1029 SNDRV_PCM_INFO_MMAP |
1030 SNDRV_PCM_INFO_MMAP_VALID; 1030 SNDRV_PCM_INFO_MMAP_VALID;
1031 1031
1032 if (card->support_grouping) 1032 if (card->support_grouping) {
1033 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_SYNC_START; 1033 snd_card_asihpi_playback.info |= SNDRV_PCM_INFO_SYNC_START;
1034 snd_pcm_set_sync(substream);
1035 }
1034 1036
1035 /* struct is copied, so can create initializer dynamically */ 1037 /* struct is copied, so can create initializer dynamically */
1036 runtime->hw = snd_card_asihpi_playback; 1038 runtime->hw = snd_card_asihpi_playback;
@@ -1047,8 +1049,6 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
1047 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1049 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1048 card->update_interval_frames * 2, UINT_MAX); 1050 card->update_interval_frames * 2, UINT_MAX);
1049 1051
1050 snd_pcm_set_sync(substream);
1051
1052 snd_printdd("playback open\n"); 1052 snd_printdd("playback open\n");
1053 1053
1054 return 0; 1054 return 0;
@@ -1114,15 +1114,15 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream)
1114 1114
1115 1115
1116 1116
1117static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, 1117static u64 snd_card_asihpi_capture_formats(struct snd_card_asihpi *asihpi,
1118 u32 h_stream, 1118 u32 h_stream)
1119 struct snd_pcm_hardware *pcmhw)
1120{ 1119{
1121 struct hpi_format hpi_format; 1120 struct hpi_format hpi_format;
1122 u16 format; 1121 u16 format;
1123 u16 err; 1122 u16 err;
1124 u32 h_control; 1123 u32 h_control;
1125 u32 sample_rate = 48000; 1124 u32 sample_rate = 48000;
1125 u64 formats = 0;
1126 1126
1127 /* on cards without SRC, must query at valid rate, 1127 /* on cards without SRC, must query at valid rate,
1128 maybe set by external sync */ 1128 maybe set by external sync */
@@ -1137,34 +1137,22 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi,
1137 for (format = HPI_FORMAT_PCM8_UNSIGNED; 1137 for (format = HPI_FORMAT_PCM8_UNSIGNED;
1138 format <= HPI_FORMAT_PCM24_SIGNED; format++) { 1138 format <= HPI_FORMAT_PCM24_SIGNED; format++) {
1139 1139
1140 err = hpi_format_create(&hpi_format, 2, format, 1140 err = hpi_format_create(&hpi_format, asihpi->in_max_chans,
1141 sample_rate, 128000, 0); 1141 format, sample_rate, 128000, 0);
1142 if (!err) 1142 if (!err)
1143 err = hpi_instream_query_format(h_stream, 1143 err = hpi_instream_query_format(h_stream, &hpi_format);
1144 &hpi_format);
1145 if (!err) 1144 if (!err)
1146 pcmhw->formats |= 1145 formats |= (1ULL << hpi_to_alsa_formats[format]);
1147 (1ULL << hpi_to_alsa_formats[format]);
1148 } 1146 }
1147 return formats;
1149} 1148}
1150 1149
1151
1152static struct snd_pcm_hardware snd_card_asihpi_capture = {
1153 .channels_min = 1,
1154 .channels_max = 2,
1155 .buffer_bytes_max = BUFFER_BYTES_MAX,
1156 .period_bytes_min = PERIOD_BYTES_MIN,
1157 .period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN,
1158 .periods_min = PERIODS_MIN,
1159 .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN,
1160 .fifo_size = 0,
1161};
1162
1163static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) 1150static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1164{ 1151{
1165 struct snd_pcm_runtime *runtime = substream->runtime; 1152 struct snd_pcm_runtime *runtime = substream->runtime;
1166 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); 1153 struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
1167 struct snd_card_asihpi_pcm *dpcm; 1154 struct snd_card_asihpi_pcm *dpcm;
1155 struct snd_pcm_hardware snd_card_asihpi_capture;
1168 int err; 1156 int err;
1169 1157
1170 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); 1158 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
@@ -1172,10 +1160,10 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1172 return -ENOMEM; 1160 return -ENOMEM;
1173 1161
1174 snd_printdd("capture open adapter %d stream %d\n", 1162 snd_printdd("capture open adapter %d stream %d\n",
1175 card->adapter_index, substream->number); 1163 card->hpi->adapter->index, substream->number);
1176 1164
1177 err = hpi_handle_error( 1165 err = hpi_handle_error(
1178 hpi_instream_open(card->adapter_index, 1166 hpi_instream_open(card->hpi->adapter->index,
1179 substream->number, &dpcm->h_stream)); 1167 substream->number, &dpcm->h_stream));
1180 if (err) 1168 if (err)
1181 kfree(dpcm); 1169 kfree(dpcm);
@@ -1184,7 +1172,6 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1184 if (err) 1172 if (err)
1185 return -EIO; 1173 return -EIO;
1186 1174
1187
1188 init_timer(&dpcm->timer); 1175 init_timer(&dpcm->timer);
1189 dpcm->timer.data = (unsigned long) dpcm; 1176 dpcm->timer.data = (unsigned long) dpcm;
1190 dpcm->timer.function = snd_card_asihpi_timer_function; 1177 dpcm->timer.function = snd_card_asihpi_timer_function;
@@ -1192,9 +1179,17 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
1192 runtime->private_data = dpcm; 1179 runtime->private_data = dpcm;
1193 runtime->private_free = snd_card_asihpi_runtime_free; 1180 runtime->private_free = snd_card_asihpi_runtime_free;
1194 1181
1182 memset(&snd_card_asihpi_capture, 0, sizeof(snd_card_asihpi_capture));
1183 snd_card_asihpi_capture.buffer_bytes_max = BUFFER_BYTES_MAX;
1184 snd_card_asihpi_capture.period_bytes_min = PERIOD_BYTES_MIN;
1185 snd_card_asihpi_capture.period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN;
1186 snd_card_asihpi_capture.periods_min = PERIODS_MIN;
1187 snd_card_asihpi_capture.periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN;
1188 /* snd_card_asihpi_capture.fifo_size = 0; */
1195 snd_card_asihpi_capture.channels_max = card->in_max_chans; 1189 snd_card_asihpi_capture.channels_max = card->in_max_chans;
1196 snd_card_asihpi_capture_format(card, dpcm->h_stream, 1190 snd_card_asihpi_capture.channels_min = card->in_min_chans;
1197 &snd_card_asihpi_capture); 1191 snd_card_asihpi_capture.formats =
1192 snd_card_asihpi_capture_formats(card, dpcm->h_stream);
1198 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture); 1193 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture);
1199 snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED | 1194 snd_card_asihpi_capture.info = SNDRV_PCM_INFO_INTERLEAVED |
1200 SNDRV_PCM_INFO_MMAP | 1195 SNDRV_PCM_INFO_MMAP |
@@ -1240,15 +1235,20 @@ static struct snd_pcm_ops snd_card_asihpi_capture_mmap_ops = {
1240 .pointer = snd_card_asihpi_capture_pointer, 1235 .pointer = snd_card_asihpi_capture_pointer,
1241}; 1236};
1242 1237
1243static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, 1238static int __devinit snd_card_asihpi_pcm_new(
1244 int device, int substreams) 1239 struct snd_card_asihpi *asihpi, int device)
1245{ 1240{
1246 struct snd_pcm *pcm; 1241 struct snd_pcm *pcm;
1247 int err; 1242 int err;
1243 u16 num_instreams, num_outstreams, x16;
1244 u32 x32;
1245
1246 err = hpi_adapter_get_info(asihpi->hpi->adapter->index,
1247 &num_outstreams, &num_instreams,
1248 &x16, &x32, &x16);
1248 1249
1249 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, 1250 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device,
1250 asihpi->num_outstreams, asihpi->num_instreams, 1251 num_outstreams, num_instreams, &pcm);
1251 &pcm);
1252 if (err < 0) 1252 if (err < 0)
1253 return err; 1253 return err;
1254 /* pointer to ops struct is stored, dont change ops afterwards! */ 1254 /* pointer to ops struct is stored, dont change ops afterwards! */
@@ -1314,7 +1314,7 @@ static const char * const asihpi_src_names[] = {
1314 "Analog", 1314 "Analog",
1315 "Adapter", 1315 "Adapter",
1316 "RTP", 1316 "RTP",
1317 "GPI", 1317 "Internal"
1318}; 1318};
1319 1319
1320compile_time_assert( 1320compile_time_assert(
@@ -1332,7 +1332,6 @@ static const char * const asihpi_dst_names[] = {
1332 "Net", 1332 "Net",
1333 "Analog", 1333 "Analog",
1334 "RTP", 1334 "RTP",
1335 "GPO",
1336}; 1335};
1337 1336
1338compile_time_assert( 1337compile_time_assert(
@@ -1410,6 +1409,7 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol,
1410 struct snd_ctl_elem_info *uinfo) 1409 struct snd_ctl_elem_info *uinfo)
1411{ 1410{
1412 u32 h_control = kcontrol->private_value; 1411 u32 h_control = kcontrol->private_value;
1412 u32 count;
1413 u16 err; 1413 u16 err;
1414 /* native gains are in millibels */ 1414 /* native gains are in millibels */
1415 short min_gain_mB; 1415 short min_gain_mB;
@@ -1424,8 +1424,12 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol,
1424 step_gain_mB = VOL_STEP_mB; 1424 step_gain_mB = VOL_STEP_mB;
1425 } 1425 }
1426 1426
1427 err = hpi_meter_query_channels(h_control, &count);
1428 if (err)
1429 count = HPI_MAX_CHANNELS;
1430
1427 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1431 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1428 uinfo->count = 2; 1432 uinfo->count = count;
1429 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB; 1433 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB;
1430 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB; 1434 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB;
1431 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB; 1435 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB;
@@ -2033,8 +2037,15 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi,
2033static int snd_asihpi_meter_info(struct snd_kcontrol *kcontrol, 2037static int snd_asihpi_meter_info(struct snd_kcontrol *kcontrol,
2034 struct snd_ctl_elem_info *uinfo) 2038 struct snd_ctl_elem_info *uinfo)
2035{ 2039{
2040 u32 h_control = kcontrol->private_value;
2041 u32 count;
2042 u16 err;
2043 err = hpi_meter_query_channels(h_control, &count);
2044 if (err)
2045 count = HPI_MAX_CHANNELS;
2046
2036 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 2047 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2037 uinfo->count = HPI_MAX_CHANNELS; 2048 uinfo->count = count;
2038 uinfo->value.integer.min = 0; 2049 uinfo->value.integer.min = 0;
2039 uinfo->value.integer.max = 0x7FFFFFFF; 2050 uinfo->value.integer.max = 0x7FFFFFFF;
2040 return 0; 2051 return 0;
@@ -2248,6 +2259,9 @@ static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol,
2248 valid_modes++; 2259 valid_modes++;
2249 } 2260 }
2250 2261
2262 if (!valid_modes)
2263 return -EINVAL;
2264
2251 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2265 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2252 uinfo->count = 1; 2266 uinfo->count = 1;
2253 uinfo->value.enumerated.items = valid_modes; 2267 uinfo->value.enumerated.items = valid_modes;
@@ -2547,7 +2561,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
2547 strcpy(card->mixername, "Asihpi Mixer"); 2561 strcpy(card->mixername, "Asihpi Mixer");
2548 2562
2549 err = 2563 err =
2550 hpi_mixer_open(asihpi->adapter_index, 2564 hpi_mixer_open(asihpi->hpi->adapter->index,
2551 &asihpi->h_mixer); 2565 &asihpi->h_mixer);
2552 hpi_handle_error(err); 2566 hpi_handle_error(err);
2553 if (err) 2567 if (err)
@@ -2665,24 +2679,33 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,
2665 struct snd_info_buffer *buffer) 2679 struct snd_info_buffer *buffer)
2666{ 2680{
2667 struct snd_card_asihpi *asihpi = entry->private_data; 2681 struct snd_card_asihpi *asihpi = entry->private_data;
2668 u16 version;
2669 u32 h_control; 2682 u32 h_control;
2670 u32 rate = 0; 2683 u32 rate = 0;
2671 u16 source = 0; 2684 u16 source = 0;
2685
2686 u16 num_outstreams;
2687 u16 num_instreams;
2688 u16 version;
2689 u32 serial_number;
2690 u16 type;
2691
2672 int err; 2692 int err;
2673 2693
2674 snd_iprintf(buffer, "ASIHPI driver proc file\n"); 2694 snd_iprintf(buffer, "ASIHPI driver proc file\n");
2695
2696 hpi_handle_error(hpi_adapter_get_info(asihpi->hpi->adapter->index,
2697 &num_outstreams, &num_instreams,
2698 &version, &serial_number, &type));
2699
2675 snd_iprintf(buffer, 2700 snd_iprintf(buffer,
2676 "adapter ID=%4X\n_index=%d\n" 2701 "Adapter type ASI%4X\nHardware Index %d\n"
2677 "num_outstreams=%d\n_num_instreams=%d\n", 2702 "%d outstreams\n%d instreams\n",
2678 asihpi->type, asihpi->adapter_index, 2703 type, asihpi->hpi->adapter->index,
2679 asihpi->num_outstreams, asihpi->num_instreams); 2704 num_outstreams, num_instreams);
2680 2705
2681 version = asihpi->version;
2682 snd_iprintf(buffer, 2706 snd_iprintf(buffer,
2683 "serial#=%d\n_hw version %c%d\nDSP code version %03d\n", 2707 "Serial#%d\nHardware version %c%d\nDSP code version %03d\n",
2684 asihpi->serial_number, ((version >> 3) & 0xf) + 'A', 2708 serial_number, ((version >> 3) & 0xf) + 'A', version & 0x7,
2685 version & 0x7,
2686 ((version >> 13) * 100) + ((version >> 7) & 0x3f)); 2709 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
2687 2710
2688 err = hpi_mixer_get_control(asihpi->h_mixer, 2711 err = hpi_mixer_get_control(asihpi->h_mixer,
@@ -2690,18 +2713,15 @@ snd_asihpi_proc_read(struct snd_info_entry *entry,
2690 HPI_CONTROL_SAMPLECLOCK, &h_control); 2713 HPI_CONTROL_SAMPLECLOCK, &h_control);
2691 2714
2692 if (!err) { 2715 if (!err) {
2693 err = hpi_sample_clock_get_sample_rate( 2716 err = hpi_sample_clock_get_sample_rate(h_control, &rate);
2694 h_control, &rate);
2695 err += hpi_sample_clock_get_source(h_control, &source); 2717 err += hpi_sample_clock_get_source(h_control, &source);
2696 2718
2697 if (!err) 2719 if (!err)
2698 snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", 2720 snd_iprintf(buffer, "Sample Clock %dHz, source %s\n",
2699 rate, sampleclock_sources[source]); 2721 rate, sampleclock_sources[source]);
2700 } 2722 }
2701
2702} 2723}
2703 2724
2704
2705static void __devinit snd_asihpi_proc_init(struct snd_card_asihpi *asihpi) 2725static void __devinit snd_asihpi_proc_init(struct snd_card_asihpi *asihpi)
2706{ 2726{
2707 struct snd_info_entry *entry; 2727 struct snd_info_entry *entry;
@@ -2773,35 +2793,34 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2773 const struct pci_device_id *pci_id) 2793 const struct pci_device_id *pci_id)
2774{ 2794{
2775 int err; 2795 int err;
2776 2796 struct hpi_adapter *hpi;
2777 u16 version;
2778 int pcm_substreams;
2779
2780 struct hpi_adapter *hpi_card;
2781 struct snd_card *card; 2797 struct snd_card *card;
2782 struct snd_card_asihpi *asihpi; 2798 struct snd_card_asihpi *asihpi;
2783 2799
2784 u32 h_control; 2800 u32 h_control;
2785 u32 h_stream; 2801 u32 h_stream;
2802 u32 adapter_index;
2786 2803
2787 static int dev; 2804 static int dev;
2788 if (dev >= SNDRV_CARDS) 2805 if (dev >= SNDRV_CARDS)
2789 return -ENODEV; 2806 return -ENODEV;
2790 2807
2791 /* Should this be enable[hpi_card->index] ? */ 2808 /* Should this be enable[hpi->index] ? */
2792 if (!enable[dev]) { 2809 if (!enable[dev]) {
2793 dev++; 2810 dev++;
2794 return -ENOENT; 2811 return -ENOENT;
2795 } 2812 }
2796 2813
2814 /* Initialise low-level HPI driver */
2797 err = asihpi_adapter_probe(pci_dev, pci_id); 2815 err = asihpi_adapter_probe(pci_dev, pci_id);
2798 if (err < 0) 2816 if (err < 0)
2799 return err; 2817 return err;
2800 2818
2801 hpi_card = pci_get_drvdata(pci_dev); 2819 hpi = pci_get_drvdata(pci_dev);
2820 adapter_index = hpi->adapter->index;
2802 /* first try to give the card the same index as its hardware index */ 2821 /* first try to give the card the same index as its hardware index */
2803 err = snd_card_create(hpi_card->index, 2822 err = snd_card_create(adapter_index,
2804 id[hpi_card->index], THIS_MODULE, 2823 id[adapter_index], THIS_MODULE,
2805 sizeof(struct snd_card_asihpi), 2824 sizeof(struct snd_card_asihpi),
2806 &card); 2825 &card);
2807 if (err < 0) { 2826 if (err < 0) {
@@ -2815,50 +2834,32 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2815 return err; 2834 return err;
2816 snd_printk(KERN_WARNING 2835 snd_printk(KERN_WARNING
2817 "**** WARNING **** Adapter index %d->ALSA index %d\n", 2836 "**** WARNING **** Adapter index %d->ALSA index %d\n",
2818 hpi_card->index, card->number); 2837 adapter_index, card->number);
2819 } 2838 }
2820 2839
2821 snd_card_set_dev(card, &pci_dev->dev); 2840 snd_card_set_dev(card, &pci_dev->dev);
2822 2841
2823 asihpi = (struct snd_card_asihpi *) card->private_data; 2842 asihpi = card->private_data;
2824 asihpi->card = card; 2843 asihpi->card = card;
2825 asihpi->pci = pci_dev; 2844 asihpi->pci = pci_dev;
2826 asihpi->adapter_index = hpi_card->index; 2845 asihpi->hpi = hpi;
2827 hpi_handle_error(hpi_adapter_get_info( 2846
2828 asihpi->adapter_index, 2847 snd_printk(KERN_INFO "adapter ID=%4X index=%d\n",
2829 &asihpi->num_outstreams, 2848 asihpi->hpi->adapter->type, adapter_index);
2830 &asihpi->num_instreams, 2849
2831 &asihpi->version, 2850 err = hpi_adapter_get_property(adapter_index,
2832 &asihpi->serial_number, &asihpi->type));
2833
2834 version = asihpi->version;
2835 snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d "
2836 "num_instreams=%d S/N=%d\n"
2837 "Hw Version %c%d DSP code version %03d\n",
2838 asihpi->type, asihpi->adapter_index,
2839 asihpi->num_outstreams,
2840 asihpi->num_instreams, asihpi->serial_number,
2841 ((version >> 3) & 0xf) + 'A',
2842 version & 0x7,
2843 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
2844
2845 pcm_substreams = asihpi->num_outstreams;
2846 if (pcm_substreams < asihpi->num_instreams)
2847 pcm_substreams = asihpi->num_instreams;
2848
2849 err = hpi_adapter_get_property(asihpi->adapter_index,
2850 HPI_ADAPTER_PROPERTY_CAPS1, 2851 HPI_ADAPTER_PROPERTY_CAPS1,
2851 NULL, &asihpi->support_grouping); 2852 NULL, &asihpi->support_grouping);
2852 if (err) 2853 if (err)
2853 asihpi->support_grouping = 0; 2854 asihpi->support_grouping = 0;
2854 2855
2855 err = hpi_adapter_get_property(asihpi->adapter_index, 2856 err = hpi_adapter_get_property(adapter_index,
2856 HPI_ADAPTER_PROPERTY_CAPS2, 2857 HPI_ADAPTER_PROPERTY_CAPS2,
2857 &asihpi->support_mrx, NULL); 2858 &asihpi->support_mrx, NULL);
2858 if (err) 2859 if (err)
2859 asihpi->support_mrx = 0; 2860 asihpi->support_mrx = 0;
2860 2861
2861 err = hpi_adapter_get_property(asihpi->adapter_index, 2862 err = hpi_adapter_get_property(adapter_index,
2862 HPI_ADAPTER_PROPERTY_INTERVAL, 2863 HPI_ADAPTER_PROPERTY_INTERVAL,
2863 NULL, &asihpi->update_interval_frames); 2864 NULL, &asihpi->update_interval_frames);
2864 if (err) 2865 if (err)
@@ -2867,7 +2868,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2867 if (!asihpi->can_dma) 2868 if (!asihpi->can_dma)
2868 asihpi->update_interval_frames *= 2; 2869 asihpi->update_interval_frames *= 2;
2869 2870
2870 hpi_handle_error(hpi_instream_open(asihpi->adapter_index, 2871 hpi_handle_error(hpi_instream_open(adapter_index,
2871 0, &h_stream)); 2872 0, &h_stream));
2872 2873
2873 err = hpi_instream_host_buffer_free(h_stream); 2874 err = hpi_instream_host_buffer_free(h_stream);
@@ -2875,7 +2876,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2875 2876
2876 hpi_handle_error(hpi_instream_close(h_stream)); 2877 hpi_handle_error(hpi_instream_close(h_stream));
2877 2878
2878 err = hpi_adapter_get_property(asihpi->adapter_index, 2879 err = hpi_adapter_get_property(adapter_index,
2879 HPI_ADAPTER_PROPERTY_CURCHANNELS, 2880 HPI_ADAPTER_PROPERTY_CURCHANNELS,
2880 &asihpi->in_max_chans, &asihpi->out_max_chans); 2881 &asihpi->in_max_chans, &asihpi->out_max_chans);
2881 if (err) { 2882 if (err) {
@@ -2883,13 +2884,22 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2883 asihpi->out_max_chans = 2; 2884 asihpi->out_max_chans = 2;
2884 } 2885 }
2885 2886
2886 snd_printk(KERN_INFO "has dma:%d, grouping:%d, mrx:%d\n", 2887 if (asihpi->out_max_chans > 2) { /* assume LL mode */
2888 asihpi->out_min_chans = asihpi->out_max_chans;
2889 asihpi->in_min_chans = asihpi->in_max_chans;
2890 asihpi->support_grouping = 0;
2891 } else {
2892 asihpi->out_min_chans = 1;
2893 asihpi->in_min_chans = 1;
2894 }
2895
2896 snd_printk(KERN_INFO "Has dma:%d, grouping:%d, mrx:%d\n",
2887 asihpi->can_dma, 2897 asihpi->can_dma,
2888 asihpi->support_grouping, 2898 asihpi->support_grouping,
2889 asihpi->support_mrx 2899 asihpi->support_mrx
2890 ); 2900 );
2891 2901
2892 err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); 2902 err = snd_card_asihpi_pcm_new(asihpi, 0);
2893 if (err < 0) { 2903 if (err < 0) {
2894 snd_printk(KERN_ERR "pcm_new failed\n"); 2904 snd_printk(KERN_ERR "pcm_new failed\n");
2895 goto __nodev; 2905 goto __nodev;
@@ -2916,13 +2926,14 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev,
2916 2926
2917 strcpy(card->driver, "ASIHPI"); 2927 strcpy(card->driver, "ASIHPI");
2918 2928
2919 sprintf(card->shortname, "AudioScience ASI%4X", asihpi->type); 2929 sprintf(card->shortname, "AudioScience ASI%4X",
2930 asihpi->hpi->adapter->type);
2920 sprintf(card->longname, "%s %i", 2931 sprintf(card->longname, "%s %i",
2921 card->shortname, asihpi->adapter_index); 2932 card->shortname, adapter_index);
2922 err = snd_card_register(card); 2933 err = snd_card_register(card);
2923 2934
2924 if (!err) { 2935 if (!err) {
2925 hpi_card->snd_card_asihpi = card; 2936 hpi->snd_card = card;
2926 dev++; 2937 dev++;
2927 return 0; 2938 return 0;
2928 } 2939 }
@@ -2935,10 +2946,9 @@ __nodev:
2935 2946
2936static void __devexit snd_asihpi_remove(struct pci_dev *pci_dev) 2947static void __devexit snd_asihpi_remove(struct pci_dev *pci_dev)
2937{ 2948{
2938 struct hpi_adapter *hpi_card = pci_get_drvdata(pci_dev); 2949 struct hpi_adapter *hpi = pci_get_drvdata(pci_dev);
2939 2950 snd_card_free(hpi->snd_card);
2940 snd_card_free(hpi_card->snd_card_asihpi); 2951 hpi->snd_card = NULL;
2941 hpi_card->snd_card_asihpi = NULL;
2942 asihpi_adapter_remove(pci_dev); 2952 asihpi_adapter_remove(pci_dev);
2943} 2953}
2944 2954
diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h
index f2072728899..20887241a3a 100644
--- a/sound/pci/asihpi/hpi.h
+++ b/sound/pci/asihpi/hpi.h
@@ -30,26 +30,8 @@
30 30
31#ifndef _HPI_H_ 31#ifndef _HPI_H_
32#define _HPI_H_ 32#define _HPI_H_
33/* HPI Version
34If HPI_VER_MINOR is odd then its a development release not intended for the
35public. If HPI_VER_MINOR is even then is a release version
36i.e 3.05.02 is a development version
37*/
38#define HPI_VERSION_CONSTRUCTOR(maj, min, rel) \
39 ((maj << 16) + (min << 8) + rel)
40
41#define HPI_VER_MAJOR(v) ((int)(v >> 16))
42#define HPI_VER_MINOR(v) ((int)((v >> 8) & 0xFF))
43#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
44
45#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 8, 0)
46#define HPI_VER_STRING "4.08.00"
47
48/* Library version as documented in hpi-api-versions.txt */
49#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(10, 0, 0)
50 33
51#include <linux/types.h> 34#include <linux/types.h>
52#define HPI_BUILD_EXCLUDE_DEPRECATED
53#define HPI_BUILD_KERNEL_MODE 35#define HPI_BUILD_KERNEL_MODE
54 36
55/******************************************************************************/ 37/******************************************************************************/
@@ -213,7 +195,7 @@ enum HPI_SOURCENODES {
213 /** RTP stream input node - This node is a destination for 195 /** RTP stream input node - This node is a destination for
214 packets of RTP audio samples from other devices. */ 196 packets of RTP audio samples from other devices. */
215 HPI_SOURCENODE_RTP_DESTINATION = 112, 197 HPI_SOURCENODE_RTP_DESTINATION = 112,
216 HPI_SOURCENODE_GP_IN = 113, /**< general purpose input. */ 198 HPI_SOURCENODE_INTERNAL = 113, /**< node internal to the device. */
217 /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */ 199 /* !!!Update this AND hpidebug.h if you add a new sourcenode type!!! */
218 HPI_SOURCENODE_LAST_INDEX = 113 /**< largest ID */ 200 HPI_SOURCENODE_LAST_INDEX = 113 /**< largest ID */
219 /* AX6 max sourcenode types = 15 */ 201 /* AX6 max sourcenode types = 15 */
@@ -242,9 +224,8 @@ enum HPI_DESTNODES {
242 /** RTP stream output node - This node is a source for 224 /** RTP stream output node - This node is a source for
243 packets of RTP audio samples that are sent to other devices. */ 225 packets of RTP audio samples that are sent to other devices. */
244 HPI_DESTNODE_RTP_SOURCE = 208, 226 HPI_DESTNODE_RTP_SOURCE = 208,
245 HPI_DESTNODE_GP_OUT = 209, /**< general purpose output node. */
246 /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */ 227 /* !!!Update this AND hpidebug.h if you add a new destnode type!!! */
247 HPI_DESTNODE_LAST_INDEX = 209 /**< largest ID */ 228 HPI_DESTNODE_LAST_INDEX = 208 /**< largest ID */
248 /* AX6 max destnode types = 15 */ 229 /* AX6 max destnode types = 15 */
249}; 230};
250 231
@@ -450,7 +431,19 @@ Indicates that the adapter in it's current mode supports interrupts
450across the host bus. Note, this does not imply that interrupts are 431across the host bus. Note, this does not imply that interrupts are
451enabled. Instead it indicates that they can be enabled. 432enabled. Instead it indicates that they can be enabled.
452*/ 433*/
453 HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272 434 HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272,
435/** Readonly supports firmware updating.
436Indicates that the adapter implements an interface to update firmware
437on the adapter.
438*/
439 HPI_ADAPTER_PROPERTY_SUPPORTS_FW_UPDATE = 273,
440/** Readonly Firmware IDs
441Identifiy firmware independent of individual adapter type.
442May be used as a filter for firmware update images.
443Property 1 = Bootloader ID
444Property 2 = Main program ID
445*/
446 HPI_ADAPTER_PROPERTY_FIRMWARE_ID = 274
454}; 447};
455 448
456/** Adapter mode commands 449/** Adapter mode commands
@@ -638,7 +631,7 @@ enum HPI_MIXER_STORE_COMMAND {
638 HPI_MIXER_STORE_ENABLE = 4, 631 HPI_MIXER_STORE_ENABLE = 4,
639/** Disable auto storage of some control settings. */ 632/** Disable auto storage of some control settings. */
640 HPI_MIXER_STORE_DISABLE = 5, 633 HPI_MIXER_STORE_DISABLE = 5,
641/** Save the attributes of a single control. */ 634/** Unimplemented - save the attributes of a single control. */
642 HPI_MIXER_STORE_SAVE_SINGLE = 6 635 HPI_MIXER_STORE_SAVE_SINGLE = 6
643}; 636};
644 637
@@ -941,7 +934,7 @@ enum HPI_ERROR_CODES {
941 HPI_ERROR_BAD_ADAPTER_NUMBER = 202, 934 HPI_ERROR_BAD_ADAPTER_NUMBER = 202,
942 /** 2 adapters with the same adapter number. */ 935 /** 2 adapters with the same adapter number. */
943 HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203, 936 HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203,
944 /** DSP code failed to bootload. (unused?) */ 937 /** DSP code failed to bootload. Usually a DSP memory test failure. */
945 HPI_ERROR_DSP_BOOTLOAD = 204, 938 HPI_ERROR_DSP_BOOTLOAD = 204,
946 /** Couldn't find or open the DSP code file. */ 939 /** Couldn't find or open the DSP code file. */
947 HPI_ERROR_DSP_FILE_NOT_FOUND = 206, 940 HPI_ERROR_DSP_FILE_NOT_FOUND = 206,
@@ -978,6 +971,9 @@ enum HPI_ERROR_CODES {
978 HPI_ERROR_FLASH_VERIFY = 225, 971 HPI_ERROR_FLASH_VERIFY = 225,
979 HPI_ERROR_FLASH_TYPE = 226, 972 HPI_ERROR_FLASH_TYPE = 226,
980 HPI_ERROR_FLASH_START = 227, 973 HPI_ERROR_FLASH_START = 227,
974 HPI_ERROR_FLASH_READ = 228,
975 HPI_ERROR_FLASH_READ_NO_FILE = 229,
976 HPI_ERROR_FLASH_SIZE = 230,
981 977
982 /** Reserved for OEMs. */ 978 /** Reserved for OEMs. */
983 HPI_ERROR_RESERVED_1 = 290, 979 HPI_ERROR_RESERVED_1 = 290,
@@ -1020,6 +1016,8 @@ enum HPI_ERROR_CODES {
1020 HPI_ERROR_NO_INTERDSP_GROUPS = 315, 1016 HPI_ERROR_NO_INTERDSP_GROUPS = 315,
1021 /** Stream wait cancelled before threshold reached. */ 1017 /** Stream wait cancelled before threshold reached. */
1022 HPI_ERROR_WAIT_CANCELLED = 316, 1018 HPI_ERROR_WAIT_CANCELLED = 316,
1019 /** A character string is invalid. */
1020 HPI_ERROR_INVALID_STRING = 317,
1023 1021
1024 /** Invalid mixer node for this adapter. */ 1022 /** Invalid mixer node for this adapter. */
1025 HPI_ERROR_INVALID_NODE = 400, 1023 HPI_ERROR_INVALID_NODE = 400,
@@ -1046,11 +1044,15 @@ enum HPI_ERROR_CODES {
1046 /** I2C */ 1044 /** I2C */
1047 HPI_ERROR_I2C_BAD_ADR = 460, 1045 HPI_ERROR_I2C_BAD_ADR = 460,
1048 1046
1049 /** Entity errors */ 1047 /** Entity type did not match requested type */
1050 HPI_ERROR_ENTITY_TYPE_MISMATCH = 470, 1048 HPI_ERROR_ENTITY_TYPE_MISMATCH = 470,
1049 /** Entity item count did not match requested count */
1051 HPI_ERROR_ENTITY_ITEM_COUNT = 471, 1050 HPI_ERROR_ENTITY_ITEM_COUNT = 471,
1051 /** Entity type is not one of the valid types */
1052 HPI_ERROR_ENTITY_TYPE_INVALID = 472, 1052 HPI_ERROR_ENTITY_TYPE_INVALID = 472,
1053 /** Entity role is not one of the valid roles */
1053 HPI_ERROR_ENTITY_ROLE_INVALID = 473, 1054 HPI_ERROR_ENTITY_ROLE_INVALID = 473,
1055 /** Entity size doesn't match target size */
1054 HPI_ERROR_ENTITY_SIZE_MISMATCH = 474, 1056 HPI_ERROR_ENTITY_SIZE_MISMATCH = 474,
1055 1057
1056 /* AES18 specific errors were 500..507 */ 1058 /* AES18 specific errors were 500..507 */
@@ -1078,8 +1080,7 @@ enum HPI_ERROR_CODES {
1078/** \defgroup maximums HPI maximum values 1080/** \defgroup maximums HPI maximum values
1079\{ 1081\{
1080*/ 1082*/
1081/** Maximum number of adapters per HPI sub-system 1083/** Maximum number of PCI HPI adapters */
1082 WARNING: modifying this value changes the response structure size.*/
1083#define HPI_MAX_ADAPTERS 20 1084#define HPI_MAX_ADAPTERS 20
1084/** Maximum number of in or out streams per adapter */ 1085/** Maximum number of in or out streams per adapter */
1085#define HPI_MAX_STREAMS 16 1086#define HPI_MAX_STREAMS 16
@@ -1090,6 +1091,9 @@ enum HPI_ERROR_CODES {
1090#define HPI_MAX_ANC_BYTES_PER_FRAME (64) 1091#define HPI_MAX_ANC_BYTES_PER_FRAME (64)
1091#define HPI_STRING_LEN 16 1092#define HPI_STRING_LEN 16
1092 1093
1094/** Networked adapters have index >= 100 */
1095#define HPI_MIN_NETWORK_ADAPTER_IDX 100
1096
1093/** Velocity units */ 1097/** Velocity units */
1094#define HPI_OSTREAM_VELOCITY_UNITS 4096 1098#define HPI_OSTREAM_VELOCITY_UNITS 4096
1095/** OutStream timescale units */ 1099/** OutStream timescale units */
@@ -1111,14 +1115,14 @@ enum HPI_ERROR_CODES {
1111struct hpi_format { 1115struct hpi_format {
1112 u32 sample_rate; 1116 u32 sample_rate;
1113 /**< 11025, 32000, 44100 ... */ 1117 /**< 11025, 32000, 44100 ... */
1114 u32 bit_rate; /**< for MPEG */ 1118 u32 bit_rate; /**< for MPEG */
1115 u32 attributes; 1119 u32 attributes;
1116 /**< Stereo/JointStereo/Mono */ 1120 /**< Stereo/JointStereo/Mono */
1117 u16 mode_legacy; 1121 u16 mode_legacy;
1118 /**< Legacy ancillary mode or idle bit */ 1122 /**< Legacy ancillary mode or idle bit */
1119 u16 unused; /**< Unused */ 1123 u16 unused; /**< Unused */
1120 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ 1124 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
1121 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */ 1125 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */
1122}; 1126};
1123 1127
1124struct hpi_anc_frame { 1128struct hpi_anc_frame {
@@ -1144,9 +1148,6 @@ struct hpi_async_event {
1144 } u; 1148 } u;
1145}; 1149};
1146 1150
1147/* skip host side function declarations for
1148 DSP compile and documentation extraction */
1149
1150#ifndef DISABLE_PRAGMA_PACK1 1151#ifndef DISABLE_PRAGMA_PACK1
1151#pragma pack(pop) 1152#pragma pack(pop)
1152#endif 1153#endif
@@ -1357,7 +1358,7 @@ u16 hpi_volume_get_mute(u32 h_control, u32 *mute);
1357u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB, 1358u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
1358 short *max_gain_01dB, short *step_gain_01dB); 1359 short *max_gain_01dB, short *step_gain_01dB);
1359 1360
1360u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels); 1361u16 hpi_volume_query_channels(const u32 h_control, u32 *p_channels);
1361 1362
1362u16 hpi_volume_auto_fade(u32 h_control, 1363u16 hpi_volume_auto_fade(u32 h_control,
1363 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms); 1364 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms);
@@ -1366,6 +1367,9 @@ u16 hpi_volume_auto_fade_profile(u32 h_control,
1366 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms, 1367 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
1367 u16 profile); 1368 u16 profile);
1368 1369
1370u16 hpi_volume_query_auto_fade_profile(const u32 h_control, const u32 i,
1371 u16 *profile);
1372
1369/*****************/ 1373/*****************/
1370/* Level control */ 1374/* Level control */
1371/*****************/ 1375/*****************/
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index 3cc6f11c20a..2414d7a2239 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -231,6 +231,8 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
231static void control_message(struct hpi_adapter_obj *pao, 231static void control_message(struct hpi_adapter_obj *pao,
232 struct hpi_message *phm, struct hpi_response *phr) 232 struct hpi_message *phm, struct hpi_response *phr)
233{ 233{
234 struct hpi_hw_obj *phw = pao->priv;
235
234 switch (phm->function) { 236 switch (phm->function) {
235 case HPI_CONTROL_GET_STATE: 237 case HPI_CONTROL_GET_STATE:
236 if (pao->has_control_cache) { 238 if (pao->has_control_cache) {
@@ -248,17 +250,14 @@ static void control_message(struct hpi_adapter_obj *pao,
248 break; 250 break;
249 } 251 }
250 252
251 if (hpi_check_control_cache(((struct hpi_hw_obj *) 253 if (hpi_check_control_cache(phw->p_cache, phm, phr))
252 pao->priv)->p_cache, phm,
253 phr))
254 break; 254 break;
255 } 255 }
256 hw_message(pao, phm, phr); 256 hw_message(pao, phm, phr);
257 break; 257 break;
258 case HPI_CONTROL_SET_STATE: 258 case HPI_CONTROL_SET_STATE:
259 hw_message(pao, phm, phr); 259 hw_message(pao, phm, phr);
260 hpi_cmn_control_cache_sync_to_msg(((struct hpi_hw_obj *)pao-> 260 hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm, phr);
261 priv)->p_cache, phm, phr);
262 break; 261 break;
263 262
264 case HPI_CONTROL_GET_INFO: 263 case HPI_CONTROL_GET_INFO:
@@ -451,11 +450,11 @@ static void subsys_create_adapter(struct hpi_message *phm,
451 } 450 }
452 451
453 for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) { 452 for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) {
454 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 453 struct hpi_hw_obj *phw = pao->priv;
455 phw->ado[dsp_index].pa_parent_adapter = pao; 454 phw->ado[dsp_index].pa_parent_adapter = pao;
456 } 455 }
457 456
458 phr->u.s.adapter_type = ao.adapter_type; 457 phr->u.s.adapter_type = ao.type;
459 phr->u.s.adapter_index = ao.index; 458 phr->u.s.adapter_index = ao.index;
460 phr->error = 0; 459 phr->error = 0;
461} 460}
@@ -476,7 +475,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
476 u32 dsp_index = 0; 475 u32 dsp_index = 0;
477 u32 control_cache_size = 0; 476 u32 control_cache_size = 0;
478 u32 control_cache_count = 0; 477 u32 control_cache_count = 0;
479 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 478 struct hpi_hw_obj *phw = pao->priv;
480 479
481 /* The PCI2040 has the following address map */ 480 /* The PCI2040 has the following address map */
482 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ 481 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */
@@ -559,7 +558,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
559 if (error) 558 if (error)
560 return error; 559 return error;
561 } 560 }
562 pao->adapter_type = hr0.u.ax.info.adapter_type; 561 pao->type = hr0.u.ax.info.adapter_type;
563 pao->index = hr0.u.ax.info.adapter_index; 562 pao->index = hr0.u.ax.info.adapter_index;
564 } 563 }
565 564
@@ -584,9 +583,8 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
584 pao->has_control_cache = 1; 583 pao->has_control_cache = 1;
585 } 584 }
586 585
587 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", 586 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", pao->type,
588 pao->adapter_type, pao->index); 587 pao->index);
589 pao->open = 0; /* upon creation the adapter is closed */
590 588
591 if (phw->p_cache) 589 if (phw->p_cache)
592 phw->p_cache->adap_idx = pao->index; 590 phw->p_cache->adap_idx = pao->index;
@@ -596,7 +594,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao,
596 594
597static void delete_adapter_obj(struct hpi_adapter_obj *pao) 595static void delete_adapter_obj(struct hpi_adapter_obj *pao)
598{ 596{
599 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 597 struct hpi_hw_obj *phw = pao->priv;
600 598
601 if (pao->has_control_cache) 599 if (pao->has_control_cache)
602 hpi_free_control_cache(phw->p_cache); 600 hpi_free_control_cache(phw->p_cache);
@@ -639,7 +637,7 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao,
639static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, 637static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
640 u32 *pos_error_code) 638 u32 *pos_error_code)
641{ 639{
642 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 640 struct hpi_hw_obj *phw = pao->priv;
643 short error; 641 short error;
644 u32 timeout; 642 u32 timeout;
645 u32 read = 0; 643 u32 read = 0;
@@ -1220,8 +1218,8 @@ static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
1220static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, 1218static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao,
1221 u16 dsp_index, u32 hpi_address, u32 *source, u32 count) 1219 u16 dsp_index, u32 hpi_address, u32 *source, u32 count)
1222{ 1220{
1223 struct dsp_obj *pdo = 1221 struct hpi_hw_obj *phw = pao->priv;
1224 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1222 struct dsp_obj *pdo = &phw->ado[dsp_index];
1225 u32 time_out = PCI_TIMEOUT; 1223 u32 time_out = PCI_TIMEOUT;
1226 int c6711_burst_size = 128; 1224 int c6711_burst_size = 128;
1227 u32 local_hpi_address = hpi_address; 1225 u32 local_hpi_address = hpi_address;
@@ -1258,8 +1256,8 @@ static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao,
1258static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, 1256static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao,
1259 u16 dsp_index, u32 hpi_address, u32 *dest, u32 count) 1257 u16 dsp_index, u32 hpi_address, u32 *dest, u32 count)
1260{ 1258{
1261 struct dsp_obj *pdo = 1259 struct hpi_hw_obj *phw = pao->priv;
1262 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1260 struct dsp_obj *pdo = &phw->ado[dsp_index];
1263 u32 time_out = PCI_TIMEOUT; 1261 u32 time_out = PCI_TIMEOUT;
1264 int c6711_burst_size = 16; 1262 int c6711_burst_size = 16;
1265 u32 local_hpi_address = hpi_address; 1263 u32 local_hpi_address = hpi_address;
@@ -1298,7 +1296,7 @@ static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao,
1298static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, 1296static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1299 u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr) 1297 u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr)
1300{ 1298{
1301 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 1299 struct hpi_hw_obj *phw = pao->priv;
1302 struct dsp_obj *pdo = &phw->ado[dsp_index]; 1300 struct dsp_obj *pdo = &phw->ado[dsp_index];
1303 u32 timeout; 1301 u32 timeout;
1304 u16 ack; 1302 u16 ack;
@@ -1414,8 +1412,8 @@ static short hpi6000_send_data_check_adr(u32 address, u32 length_in_dwords)
1414static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, 1412static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index,
1415 struct hpi_message *phm, struct hpi_response *phr) 1413 struct hpi_message *phm, struct hpi_response *phr)
1416{ 1414{
1417 struct dsp_obj *pdo = 1415 struct hpi_hw_obj *phw = pao->priv;
1418 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1416 struct dsp_obj *pdo = &phw->ado[dsp_index];
1419 u32 data_sent = 0; 1417 u32 data_sent = 0;
1420 u16 ack; 1418 u16 ack;
1421 u32 length, address; 1419 u32 length, address;
@@ -1487,8 +1485,8 @@ static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index,
1487static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index, 1485static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index,
1488 struct hpi_message *phm, struct hpi_response *phr) 1486 struct hpi_message *phm, struct hpi_response *phr)
1489{ 1487{
1490 struct dsp_obj *pdo = 1488 struct hpi_hw_obj *phw = pao->priv;
1491 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1489 struct dsp_obj *pdo = &phw->ado[dsp_index];
1492 u32 data_got = 0; 1490 u32 data_got = 0;
1493 u16 ack; 1491 u16 ack;
1494 u32 length, address; 1492 u32 length, address;
@@ -1551,8 +1549,8 @@ static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo)
1551static short hpi6000_send_host_command(struct hpi_adapter_obj *pao, 1549static short hpi6000_send_host_command(struct hpi_adapter_obj *pao,
1552 u16 dsp_index, u32 host_cmd) 1550 u16 dsp_index, u32 host_cmd)
1553{ 1551{
1554 struct dsp_obj *pdo = 1552 struct hpi_hw_obj *phw = pao->priv;
1555 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1553 struct dsp_obj *pdo = &phw->ado[dsp_index];
1556 u32 timeout = TIMEOUT; 1554 u32 timeout = TIMEOUT;
1557 1555
1558 /* set command */ 1556 /* set command */
@@ -1577,7 +1575,7 @@ static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao,
1577{ 1575{
1578 u32 hPI_error; 1576 u32 hPI_error;
1579 1577
1580 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 1578 struct hpi_hw_obj *phw = pao->priv;
1581 1579
1582 /* read the error bits from the PCI2040 */ 1580 /* read the error bits from the PCI2040 */
1583 hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT); 1581 hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT);
@@ -1597,8 +1595,8 @@ static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao,
1597static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index, 1595static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index,
1598 u32 ack_value) 1596 u32 ack_value)
1599{ 1597{
1600 struct dsp_obj *pdo = 1598 struct hpi_hw_obj *phw = pao->priv;
1601 &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; 1599 struct dsp_obj *pdo = &phw->ado[dsp_index];
1602 u32 ack = 0L; 1600 u32 ack = 0L;
1603 u32 timeout; 1601 u32 timeout;
1604 u32 hPIC = 0L; 1602 u32 hPIC = 0L;
@@ -1640,7 +1638,7 @@ static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao,
1640 struct hpi_message *phm) 1638 struct hpi_message *phm)
1641{ 1639{
1642 const u16 dsp_index = 0; 1640 const u16 dsp_index = 0;
1643 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; 1641 struct hpi_hw_obj *phw = pao->priv;
1644 struct dsp_obj *pdo = &phw->ado[dsp_index]; 1642 struct dsp_obj *pdo = &phw->ado[dsp_index];
1645 u32 timeout; 1643 u32 timeout;
1646 u32 cache_dirty_flag; 1644 u32 cache_dirty_flag;
@@ -1740,7 +1738,8 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
1740{ 1738{
1741 u16 error = 0; 1739 u16 error = 0;
1742 u16 dsp_index = 0; 1740 u16 dsp_index = 0;
1743 u16 num_dsp = ((struct hpi_hw_obj *)pao->priv)->num_dsp; 1741 struct hpi_hw_obj *phw = pao->priv;
1742 u16 num_dsp = phw->num_dsp;
1744 1743
1745 if (num_dsp < 2) 1744 if (num_dsp < 2)
1746 dsp_index = 0; 1745 dsp_index = 0;
diff --git a/sound/pci/asihpi/hpi6000.h b/sound/pci/asihpi/hpi6000.h
index 4c7d507c0ec..7e0deeff5e7 100644
--- a/sound/pci/asihpi/hpi6000.h
+++ b/sound/pci/asihpi/hpi6000.h
@@ -1,7 +1,7 @@
1/***************************************************************************** 1/*****************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index e041a6ae1c5..4f2873880b1 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -45,18 +45,21 @@
45#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016 45#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
46 46
47/* initialization/bootload errors */ 47/* initialization/bootload errors */
48#define HPI6205_ERROR_6205_NO_IRQ 1002 48#define HPI6205_ERROR_6205_NO_IRQ 1002
49#define HPI6205_ERROR_6205_INIT_FAILED 1003 49#define HPI6205_ERROR_6205_INIT_FAILED 1003
50#define HPI6205_ERROR_6205_REG 1006 50#define HPI6205_ERROR_6205_REG 1006
51#define HPI6205_ERROR_6205_DSPPAGE 1007 51#define HPI6205_ERROR_6205_DSPPAGE 1007
52#define HPI6205_ERROR_C6713_HPIC 1009 52#define HPI6205_ERROR_C6713_HPIC 1009
53#define HPI6205_ERROR_C6713_HPIA 1010 53#define HPI6205_ERROR_C6713_HPIA 1010
54#define HPI6205_ERROR_C6713_PLL 1011 54#define HPI6205_ERROR_C6713_PLL 1011
55#define HPI6205_ERROR_DSP_INTMEM 1012 55#define HPI6205_ERROR_DSP_INTMEM 1012
56#define HPI6205_ERROR_DSP_EXTMEM 1013 56#define HPI6205_ERROR_DSP_EXTMEM 1013
57#define HPI6205_ERROR_DSP_PLD 1014 57#define HPI6205_ERROR_DSP_PLD 1014
58#define HPI6205_ERROR_6205_EEPROM 1017 58#define HPI6205_ERROR_6205_EEPROM 1017
59#define HPI6205_ERROR_DSP_EMIF 1018 59#define HPI6205_ERROR_DSP_EMIF1 1018
60#define HPI6205_ERROR_DSP_EMIF2 1019
61#define HPI6205_ERROR_DSP_EMIF3 1020
62#define HPI6205_ERROR_DSP_EMIF4 1021
60 63
61/*****************************************************************************/ 64/*****************************************************************************/
62/* for C6205 PCI i/f */ 65/* for C6205 PCI i/f */
@@ -488,7 +491,7 @@ static void subsys_create_adapter(struct hpi_message *phm,
488 return; 491 return;
489 } 492 }
490 493
491 phr->u.s.adapter_type = ao.adapter_type; 494 phr->u.s.adapter_type = ao.type;
492 phr->u.s.adapter_index = ao.index; 495 phr->u.s.adapter_index = ao.index;
493 phr->error = 0; 496 phr->error = 0;
494} 497}
@@ -503,7 +506,7 @@ static void adapter_delete(struct hpi_adapter_obj *pao,
503 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 506 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
504 return; 507 return;
505 } 508 }
506 phw = (struct hpi_hw_obj *)pao->priv; 509 phw = pao->priv;
507 /* reset adapter h/w */ 510 /* reset adapter h/w */
508 /* Reset C6713 #1 */ 511 /* Reset C6713 #1 */
509 boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); 512 boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0);
@@ -652,7 +655,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
652 if (hr.error) 655 if (hr.error)
653 return hr.error; 656 return hr.error;
654 657
655 pao->adapter_type = hr.u.ax.info.adapter_type; 658 pao->type = hr.u.ax.info.adapter_type;
656 pao->index = hr.u.ax.info.adapter_index; 659 pao->index = hr.u.ax.info.adapter_index;
657 660
658 max_streams = 661 max_streams =
@@ -665,8 +668,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
665 hr.u.ax.info.serial_number); 668 hr.u.ax.info.serial_number);
666 } 669 }
667 670
668 pao->open = 0; /* upon creation the adapter is closed */
669
670 if (phw->p_cache) 671 if (phw->p_cache)
671 phw->p_cache->adap_idx = pao->index; 672 phw->p_cache->adap_idx = pao->index;
672 673
@@ -803,8 +804,8 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao,
803 obj_index]; 804 obj_index];
804 status->samples_processed = 0; 805 status->samples_processed = 0;
805 status->stream_state = HPI_STATE_STOPPED; 806 status->stream_state = HPI_STATE_STOPPED;
806 status->dSP_index = 0; 807 status->dsp_index = 0;
807 status->host_index = status->dSP_index; 808 status->host_index = status->dsp_index;
808 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 809 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
809 status->auxiliary_data_available = 0; 810 status->auxiliary_data_available = 0;
810 811
@@ -878,7 +879,7 @@ static void outstream_host_buffer_free(struct hpi_adapter_obj *pao,
878static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status) 879static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status)
879{ 880{
880 return status->size_in_bytes - (status->host_index - 881 return status->size_in_bytes - (status->host_index -
881 status->dSP_index); 882 status->dsp_index);
882} 883}
883 884
884static void outstream_write(struct hpi_adapter_obj *pao, 885static void outstream_write(struct hpi_adapter_obj *pao,
@@ -1080,8 +1081,8 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao,
1080 obj_index]; 1081 obj_index];
1081 status->samples_processed = 0; 1082 status->samples_processed = 0;
1082 status->stream_state = HPI_STATE_STOPPED; 1083 status->stream_state = HPI_STATE_STOPPED;
1083 status->dSP_index = 0; 1084 status->dsp_index = 0;
1084 status->host_index = status->dSP_index; 1085 status->host_index = status->dsp_index;
1085 status->size_in_bytes = phm->u.d.u.buffer.buffer_size; 1086 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
1086 status->auxiliary_data_available = 0; 1087 status->auxiliary_data_available = 0;
1087 1088
@@ -1162,7 +1163,7 @@ static void instream_start(struct hpi_adapter_obj *pao,
1162 1163
1163static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status) 1164static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status)
1164{ 1165{
1165 return status->dSP_index - status->host_index; 1166 return status->dsp_index - status->host_index;
1166} 1167}
1167 1168
1168static void instream_read(struct hpi_adapter_obj *pao, 1169static void instream_read(struct hpi_adapter_obj *pao,
@@ -1614,7 +1615,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1614 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); 1615 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting);
1615 if (setting != boot_loader_read_mem32(pao, dsp_index, 1616 if (setting != boot_loader_read_mem32(pao, dsp_index,
1616 0x01800008)) 1617 0x01800008))
1617 return HPI6205_ERROR_DSP_EMIF; 1618 return HPI6205_ERROR_DSP_EMIF1;
1618 1619
1619 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ 1620 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */
1620 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1621 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1627,7 +1628,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1627 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); 1628 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting);
1628 if (setting != boot_loader_read_mem32(pao, dsp_index, 1629 if (setting != boot_loader_read_mem32(pao, dsp_index,
1629 0x01800004)) 1630 0x01800004))
1630 return HPI6205_ERROR_DSP_EMIF; 1631 return HPI6205_ERROR_DSP_EMIF2;
1631 1632
1632 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ 1633 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */
1633 /* which occupies D15..0. 6713 starts at 27MHz, so need */ 1634 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1639,7 +1640,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1639 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); 1640 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting);
1640 if (setting != boot_loader_read_mem32(pao, dsp_index, 1641 if (setting != boot_loader_read_mem32(pao, dsp_index,
1641 0x01800010)) 1642 0x01800010))
1642 return HPI6205_ERROR_DSP_EMIF; 1643 return HPI6205_ERROR_DSP_EMIF3;
1643 1644
1644 /* EMIF CE3 setup - 32 bit async. */ 1645 /* EMIF CE3 setup - 32 bit async. */
1645 /* This is the PLD on the ASI5000 cards only */ 1646 /* This is the PLD on the ASI5000 cards only */
@@ -1650,7 +1651,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
1650 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); 1651 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting);
1651 if (setting != boot_loader_read_mem32(pao, dsp_index, 1652 if (setting != boot_loader_read_mem32(pao, dsp_index,
1652 0x01800014)) 1653 0x01800014))
1653 return HPI6205_ERROR_DSP_EMIF; 1654 return HPI6205_ERROR_DSP_EMIF4;
1654 1655
1655 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ 1656 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */
1656 /* need to use this else DSP code crashes? */ 1657 /* need to use this else DSP code crashes? */
diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h
index d497030c160..4cc315daeda 100644
--- a/sound/pci/asihpi/hpi_internal.h
+++ b/sound/pci/asihpi/hpi_internal.h
@@ -25,6 +25,7 @@ HPI internal definitions
25#define _HPI_INTERNAL_H_ 25#define _HPI_INTERNAL_H_
26 26
27#include "hpi.h" 27#include "hpi.h"
28
28/** maximum number of memory regions mapped to an adapter */ 29/** maximum number of memory regions mapped to an adapter */
29#define HPI_MAX_ADAPTER_MEM_SPACES (2) 30#define HPI_MAX_ADAPTER_MEM_SPACES (2)
30 31
@@ -220,8 +221,6 @@ enum HPI_CONTROL_ATTRIBUTES {
220 221
221 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1), 222 HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
222 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2), 223 HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
223 /*HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3), */
224 /*HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4), */
225 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5), 224 HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
226 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6), 225 HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
227 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7), 226 HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
@@ -241,7 +240,9 @@ enum HPI_CONTROL_ATTRIBUTES {
241 HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5), 240 HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
242 HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6), 241 HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
243 HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7), 242 HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
244 HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8) 243 HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8),
244
245 HPI_UNIVERSAL_ENTITY = HPI_CTL_ATTR(UNIVERSAL, 1)
245}; 246};
246 247
247#define HPI_POLARITY_POSITIVE 0 248#define HPI_POLARITY_POSITIVE 0
@@ -393,14 +394,10 @@ enum HPI_FUNCTION_IDS {
393 HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1), 394 HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
394 HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2), 395 HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
395 HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3), 396 HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
396 /* HPI_SUBSYS_FIND_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 4), */
397 HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5), 397 HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
398 HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6), 398 HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
399 /* HPI_SUBSYS_DELETE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 7), */
400 HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8), 399 HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
401 HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9), 400 HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
402 /* HPI_SUBSYS_READ_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 10), */
403 /* HPI_SUBSYS_WRITE_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 11), */
404 HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12), 401 HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
405 HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13), 402 HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
406 HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14), 403 HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
@@ -430,7 +427,10 @@ enum HPI_FUNCTION_IDS {
430 HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19), 427 HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19),
431 HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20), 428 HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20),
432 HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21), 429 HPI_ADAPTER_DELETE = HPI_FUNC_ID(ADAPTER, 21),
433#define HPI_ADAPTER_FUNCTION_COUNT 21 430 HPI_ADAPTER_READ_FLASH = HPI_FUNC_ID(ADAPTER, 22),
431 HPI_ADAPTER_END_FLASH = HPI_FUNC_ID(ADAPTER, 23),
432 HPI_ADAPTER_FILESTORE_DELETE_ALL = HPI_FUNC_ID(ADAPTER, 24),
433#define HPI_ADAPTER_FUNCTION_COUNT 24
434 434
435 HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1), 435 HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
436 HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2), 436 HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
@@ -495,7 +495,9 @@ enum HPI_FUNCTION_IDS {
495 HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10), 495 HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
496 HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11), 496 HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
497 HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12), 497 HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12),
498#define HPI_MIXER_FUNCTION_COUNT 12 498 HPI_MIXER_GET_BLOCK_HANDLE = HPI_FUNC_ID(MIXER, 13),
499 HPI_MIXER_GET_PARAMETER_HANDLE = HPI_FUNC_ID(MIXER, 14),
500#define HPI_MIXER_FUNCTION_COUNT 14
499 501
500 HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1), 502 HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
501 HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2), 503 HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
@@ -618,7 +620,7 @@ struct hpi_hostbuffer_status {
618 u32 auxiliary_data_available; 620 u32 auxiliary_data_available;
619 u32 stream_state; 621 u32 stream_state;
620 /* DSP index in to the host bus master buffer. */ 622 /* DSP index in to the host bus master buffer. */
621 u32 dSP_index; 623 u32 dsp_index;
622 /* Host index in to the host bus master buffer. */ 624 /* Host index in to the host bus master buffer. */
623 u32 host_index; 625 u32 host_index;
624 u32 size_in_bytes; 626 u32 size_in_bytes;
@@ -661,13 +663,6 @@ union hpi_adapterx_msg {
661 u16 index; 663 u16 index;
662 } module_info; 664 } module_info;
663 struct { 665 struct {
664 u32 checksum;
665 u16 sequence;
666 u16 length;
667 u16 offset; /**< offset from start of msg to data */
668 u16 unused;
669 } program_flash;
670 struct {
671 u16 index; 666 u16 index;
672 u16 what; 667 u16 what;
673 u16 property_index; 668 u16 property_index;
@@ -678,25 +673,18 @@ union hpi_adapterx_msg {
678 u16 parameter2; 673 u16 parameter2;
679 } property_set; 674 } property_set;
680 struct { 675 struct {
681 u32 offset;
682 } query_flash;
683 struct {
684 u32 pad32; 676 u32 pad32;
685 u16 key1; 677 u16 key1;
686 u16 key2; 678 u16 key2;
687 } restart; 679 } restart;
688 struct { 680 struct {
689 u32 offset;
690 u32 length;
691 u32 key;
692 } start_flash;
693 struct {
694 u32 pad32; 681 u32 pad32;
695 u16 value; 682 u16 value;
696 } test_assert; 683 } test_assert;
697 struct { 684 struct {
698 u32 yes; 685 u32 yes;
699 } irq_query; 686 } irq_query;
687 u32 pad[3];
700}; 688};
701 689
702struct hpi_adapter_res { 690struct hpi_adapter_res {
@@ -724,18 +712,10 @@ union hpi_adapterx_res {
724 u32 adapter_mode; 712 u32 adapter_mode;
725 } mode; 713 } mode;
726 struct { 714 struct {
727 u16 sequence;
728 } program_flash;
729 struct {
730 u16 parameter1; 715 u16 parameter1;
731 u16 parameter2; 716 u16 parameter2;
732 } property_get; 717 } property_get;
733 struct { 718 struct {
734 u32 checksum;
735 u32 length;
736 u32 version;
737 } query_flash;
738 struct {
739 u32 yes; 719 u32 yes;
740 } irq_query; 720 } irq_query;
741}; 721};
@@ -1150,74 +1130,9 @@ struct hpi_res_adapter_get_info {
1150 struct hpi_adapter_res p; 1130 struct hpi_adapter_res p;
1151}; 1131};
1152 1132
1153/* padding is so these are same size as v0 hpi_message */
1154struct hpi_msg_adapter_query_flash {
1155 struct hpi_message_header h;
1156 u32 offset;
1157 u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 res */
1158 sizeof(struct hpi_message_header) - 1 * sizeof(u32)];
1159};
1160
1161/* padding is so these are same size as v0 hpi_response */
1162struct hpi_res_adapter_query_flash {
1163 struct hpi_response_header h;
1164 u32 checksum;
1165 u32 length;
1166 u32 version;
1167 u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */
1168 sizeof(struct hpi_response_header) - 3 * sizeof(u32)];
1169};
1170
1171struct hpi_msg_adapter_start_flash {
1172 struct hpi_message_header h;
1173 u32 offset;
1174 u32 length;
1175 u32 key;
1176 u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 res */
1177 sizeof(struct hpi_message_header) - 3 * sizeof(u32)];
1178};
1179
1180struct hpi_res_adapter_start_flash {
1181 struct hpi_response_header h;
1182 u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */
1183 sizeof(struct hpi_response_header)];
1184};
1185
1186struct hpi_msg_adapter_program_flash_payload {
1187 u32 checksum;
1188 u16 sequence;
1189 u16 length;
1190 u16 offset; /**< offset from start of msg to data */
1191 u16 unused;
1192 /* ensure sizeof(header + payload) == sizeof(hpi_message_V0)
1193 because old firmware expects data after message of this size */
1194 u8 pad_to_version0_size[sizeof(struct hpi_message) - /* V0 message */
1195 sizeof(struct hpi_message_header) - sizeof(u32) -
1196 4 * sizeof(u16)];
1197};
1198
1199struct hpi_msg_adapter_program_flash {
1200 struct hpi_message_header h;
1201 struct hpi_msg_adapter_program_flash_payload p;
1202 u32 data[256];
1203};
1204
1205struct hpi_res_adapter_program_flash {
1206 struct hpi_response_header h;
1207 u16 sequence;
1208 u8 pad_to_version0_size[sizeof(struct hpi_response) - /* V0 res */
1209 sizeof(struct hpi_response_header) - sizeof(u16)];
1210};
1211
1212struct hpi_msg_adapter_debug_read {
1213 struct hpi_message_header h;
1214 u32 dsp_address;
1215 u32 count_bytes;
1216};
1217
1218struct hpi_res_adapter_debug_read { 1133struct hpi_res_adapter_debug_read {
1219 struct hpi_response_header h; 1134 struct hpi_response_header h;
1220 u8 bytes[256]; 1135 u8 bytes[1024];
1221}; 1136};
1222 1137
1223struct hpi_msg_cobranet_hmi { 1138struct hpi_msg_cobranet_hmi {
@@ -1461,7 +1376,7 @@ struct hpi_control_cache_pad {
1461/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */ 1376/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1462struct hpi_fifo_buffer { 1377struct hpi_fifo_buffer {
1463 u32 size; 1378 u32 size;
1464 u32 dSP_index; 1379 u32 dsp_index;
1465 u32 host_index; 1380 u32 host_index;
1466}; 1381};
1467 1382
diff --git a/sound/pci/asihpi/hpi_version.h b/sound/pci/asihpi/hpi_version.h
new file mode 100644
index 00000000000..e9146e53bd5
--- /dev/null
+++ b/sound/pci/asihpi/hpi_version.h
@@ -0,0 +1,32 @@
1/** HPI Version Definitions
2Development releases have odd minor version.
3Production releases have even minor version.
4
5\file hpi_version.h
6*/
7
8#ifndef _HPI_VERSION_H
9#define _HPI_VERSION_H
10
11/* Use single digits for versions less that 10 to avoid octal. */
12/* *** HPI_VER is the only edit required to update version *** */
13/** HPI version */
14#define HPI_VER HPI_VERSION_CONSTRUCTOR(4, 10, 1)
15
16/** HPI version string in dotted decimal format */
17#define HPI_VER_STRING "4.10.01"
18
19/** Library version as documented in hpi-api-versions.txt */
20#define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(10, 2, 0)
21
22/** Construct hpi version number from major, minor, release numbers */
23#define HPI_VERSION_CONSTRUCTOR(maj, min, r) ((maj << 16) + (min << 8) + r)
24
25/** Extract major version from hpi version number */
26#define HPI_VER_MAJOR(v) ((int)(v >> 16))
27/** Extract minor version from hpi version number */
28#define HPI_VER_MINOR(v) ((int)((v >> 8) & 0xFF))
29/** Extract release from hpi version number */
30#define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
31
32#endif
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index bd47521b24e..7ed5c26c373 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -68,7 +68,7 @@ u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
68u16 hpi_add_adapter(struct hpi_adapter_obj *pao) 68u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
69{ 69{
70 u16 retval = 0; 70 u16 retval = 0;
71 /*HPI_ASSERT(pao->wAdapterType); */ 71 /*HPI_ASSERT(pao->type); */
72 72
73 hpios_alistlock_lock(&adapters); 73 hpios_alistlock_lock(&adapters);
74 74
@@ -77,13 +77,13 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
77 goto unlock; 77 goto unlock;
78 } 78 }
79 79
80 if (adapters.adapter[pao->index].adapter_type) { 80 if (adapters.adapter[pao->index].type) {
81 int a; 81 int a;
82 for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) { 82 for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) {
83 if (!adapters.adapter[a].adapter_type) { 83 if (!adapters.adapter[a].type) {
84 HPI_DEBUG_LOG(WARNING, 84 HPI_DEBUG_LOG(WARNING,
85 "ASI%X duplicate index %d moved to %d\n", 85 "ASI%X duplicate index %d moved to %d\n",
86 pao->adapter_type, pao->index, a); 86 pao->type, pao->index, a);
87 pao->index = a; 87 pao->index = a;
88 break; 88 break;
89 } 89 }
@@ -104,13 +104,13 @@ unlock:
104 104
105void hpi_delete_adapter(struct hpi_adapter_obj *pao) 105void hpi_delete_adapter(struct hpi_adapter_obj *pao)
106{ 106{
107 if (!pao->adapter_type) { 107 if (!pao->type) {
108 HPI_DEBUG_LOG(ERROR, "removing null adapter?\n"); 108 HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
109 return; 109 return;
110 } 110 }
111 111
112 hpios_alistlock_lock(&adapters); 112 hpios_alistlock_lock(&adapters);
113 if (adapters.adapter[pao->index].adapter_type) 113 if (adapters.adapter[pao->index].type)
114 adapters.gw_num_adapters--; 114 adapters.gw_num_adapters--;
115 memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0])); 115 memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
116 hpios_alistlock_unlock(&adapters); 116 hpios_alistlock_unlock(&adapters);
@@ -132,7 +132,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
132 } 132 }
133 133
134 pao = &adapters.adapter[adapter_index]; 134 pao = &adapters.adapter[adapter_index];
135 if (pao->adapter_type != 0) { 135 if (pao->type != 0) {
136 /* 136 /*
137 HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n", 137 HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n",
138 wAdapterIndex); 138 wAdapterIndex);
@@ -165,7 +165,7 @@ static void subsys_get_adapter(struct hpi_message *phm,
165 165
166 /* find the nCount'th nonzero adapter in array */ 166 /* find the nCount'th nonzero adapter in array */
167 for (index = 0; index < HPI_MAX_ADAPTERS; index++) { 167 for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
168 if (adapters.adapter[index].adapter_type) { 168 if (adapters.adapter[index].type) {
169 if (!count) 169 if (!count)
170 break; 170 break;
171 count--; 171 count--;
@@ -174,11 +174,11 @@ static void subsys_get_adapter(struct hpi_message *phm,
174 174
175 if (index < HPI_MAX_ADAPTERS) { 175 if (index < HPI_MAX_ADAPTERS) {
176 phr->u.s.adapter_index = adapters.adapter[index].index; 176 phr->u.s.adapter_index = adapters.adapter[index].index;
177 phr->u.s.adapter_type = adapters.adapter[index].adapter_type; 177 phr->u.s.adapter_type = adapters.adapter[index].type;
178 } else { 178 } else {
179 phr->u.s.adapter_index = 0; 179 phr->u.s.adapter_index = 0;
180 phr->u.s.adapter_type = 0; 180 phr->u.s.adapter_type = 0;
181 phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER; 181 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
182 } 182 }
183} 183}
184 184
@@ -324,6 +324,8 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
324 } 324 }
325 325
326 phr->error = 0; 326 phr->error = 0;
327 phr->specific_error = 0;
328 phr->version = 0;
327 329
328 /* set the default response size */ 330 /* set the default response size */
329 response_size = 331 response_size =
@@ -531,8 +533,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
531 found ? "Cached" : "Uncached", phm->adapter_index, 533 found ? "Cached" : "Uncached", phm->adapter_index,
532 pI->control_index, pI->control_type, phm->u.c.attribute); 534 pI->control_index, pI->control_type, phm->u.c.attribute);
533 535
534 if (found) 536 if (found) {
535 phr->size = (u16)response_size; 537 phr->size = (u16)response_size;
538 phr->type = HPI_TYPE_RESPONSE;
539 phr->object = phm->object;
540 phr->function = phm->function;
541 }
536 542
537 return found; 543 return found;
538} 544}
@@ -631,7 +637,7 @@ struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
631 if (!p_cache) 637 if (!p_cache)
632 return NULL; 638 return NULL;
633 639
634 p_cache->p_info = kzalloc(sizeof(*p_cache->p_info) * control_count, 640 p_cache->p_info = kcalloc(control_count, sizeof(*p_cache->p_info),
635 GFP_KERNEL); 641 GFP_KERNEL);
636 if (!p_cache->p_info) { 642 if (!p_cache->p_info) {
637 kfree(p_cache); 643 kfree(p_cache);
diff --git a/sound/pci/asihpi/hpicmn.h b/sound/pci/asihpi/hpicmn.h
index d53cdf6e535..e4412128304 100644
--- a/sound/pci/asihpi/hpicmn.h
+++ b/sound/pci/asihpi/hpicmn.h
@@ -1,7 +1,7 @@
1/** 1/**
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -18,12 +18,15 @@
18 18
19*/ 19*/
20 20
21struct hpi_adapter_obj;
22
23/* a function that takes an adapter obj and returns an int */
24typedef int adapter_int_func(struct hpi_adapter_obj *pao);
25
21struct hpi_adapter_obj { 26struct hpi_adapter_obj {
22 struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */ 27 struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */
23 u16 adapter_type; /* ASI6701 etc */ 28 u16 type; /* 0x6644 == ASI6644 etc */
24 u16 index; /* */ 29 u16 index;
25 u16 open; /* =1 when adapter open */
26 u16 mixer_open;
27 30
28 struct hpios_spinlock dsp_lock; 31 struct hpios_spinlock dsp_lock;
29 32
diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c
index b52baf62791..ac86a1f1d3b 100644
--- a/sound/pci/asihpi/hpidebug.c
+++ b/sound/pci/asihpi/hpidebug.c
@@ -1,7 +1,7 @@
1/************************************************************************ 1/************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpidebug.h b/sound/pci/asihpi/hpidebug.h
index 940f54c3c53..2c9af2329d3 100644
--- a/sound/pci/asihpi/hpidebug.h
+++ b/sound/pci/asihpi/hpidebug.h
@@ -1,7 +1,7 @@
1/***************************************************************************** 1/*****************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index 71d32c868c9..456a758f04f 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -25,6 +25,7 @@ hotplug firmware loader from individual dsp code files
25#define SOURCEFILE_NAME "hpidspcd.c" 25#define SOURCEFILE_NAME "hpidspcd.c"
26#include "hpidspcd.h" 26#include "hpidspcd.h"
27#include "hpidebug.h" 27#include "hpidebug.h"
28#include "hpi_version.h"
28 29
29struct dsp_code_private { 30struct dsp_code_private {
30 /** Firmware descriptor */ 31 /** Firmware descriptor */
@@ -32,9 +33,6 @@ struct dsp_code_private {
32 struct pci_dev *dev; 33 struct pci_dev *dev;
33}; 34};
34 35
35#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
36 HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
37
38/*-------------------------------------------------------------------*/ 36/*-------------------------------------------------------------------*/
39short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code, 37short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
40 u32 *os_error_code) 38 u32 *os_error_code)
@@ -66,22 +64,25 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
66 if ((header.type != 0x45444F43) || /* "CODE" */ 64 if ((header.type != 0x45444F43) || /* "CODE" */
67 (header.adapter != adapter) 65 (header.adapter != adapter)
68 || (header.size != firmware->size)) { 66 || (header.size != firmware->size)) {
69 dev_printk(KERN_ERR, &dev->dev, "Invalid firmware file\n"); 67 dev_printk(KERN_ERR, &dev->dev,
68 "Invalid firmware header size %d != file %zd\n",
69 header.size, firmware->size);
70 goto error2; 70 goto error2;
71 } 71 }
72 72
73 if ((header.version / 100 & ~1) != (HPI_VER_DECIMAL / 100 & ~1)) { 73 if ((header.version >> 9) != (HPI_VER >> 9)) {
74 /* Consider even and subsequent odd minor versions to be compatible */
74 dev_printk(KERN_ERR, &dev->dev, 75 dev_printk(KERN_ERR, &dev->dev,
75 "Incompatible firmware version " 76 "Incompatible firmware version "
76 "DSP image %d != Driver %d\n", header.version, 77 "DSP image %X != Driver %X\n", header.version,
77 HPI_VER_DECIMAL); 78 HPI_VER);
78 goto error2; 79 goto error2;
79 } 80 }
80 81
81 if (header.version != HPI_VER_DECIMAL) { 82 if (header.version != HPI_VER) {
82 dev_printk(KERN_WARNING, &dev->dev, 83 dev_printk(KERN_INFO, &dev->dev,
83 "Firmware: release version mismatch DSP image %d != Driver %d\n", 84 "Firmware: release version mismatch DSP image %X != Driver %X\n",
84 header.version, HPI_VER_DECIMAL); 85 header.version, HPI_VER);
85 } 86 }
86 87
87 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); 88 HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
@@ -108,11 +109,8 @@ error1:
108/*-------------------------------------------------------------------*/ 109/*-------------------------------------------------------------------*/
109void hpi_dsp_code_close(struct dsp_code *dsp_code) 110void hpi_dsp_code_close(struct dsp_code *dsp_code)
110{ 111{
111 if (dsp_code->pvt->firmware) { 112 HPI_DEBUG_LOG(DEBUG, "dsp code closed\n");
112 HPI_DEBUG_LOG(DEBUG, "dsp code closed\n"); 113 release_firmware(dsp_code->pvt->firmware);
113 release_firmware(dsp_code->pvt->firmware);
114 dsp_code->pvt->firmware = NULL;
115 }
116 kfree(dsp_code->pvt); 114 kfree(dsp_code->pvt);
117} 115}
118 116
diff --git a/sound/pci/asihpi/hpidspcd.h b/sound/pci/asihpi/hpidspcd.h
index b22881122f1..659d19ca6d4 100644
--- a/sound/pci/asihpi/hpidspcd.h
+++ b/sound/pci/asihpi/hpidspcd.h
@@ -27,10 +27,6 @@ Functions for reading DSP code to load into DSP
27 27
28#include "hpi_internal.h" 28#include "hpi_internal.h"
29 29
30/** Code header version is decimal encoded e.g. 4.06.10 is 40601 */
31#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
32HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
33
34/** Header structure for dsp firmware file 30/** Header structure for dsp firmware file
35 This structure must match that used in s2bin.c for generation of asidsp.bin 31 This structure must match that used in s2bin.c for generation of asidsp.bin
36 */ 32 */
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c
index ebb568d695f..510e56cffd3 100644
--- a/sound/pci/asihpi/hpifunc.c
+++ b/sound/pci/asihpi/hpifunc.c
@@ -2826,6 +2826,16 @@ u16 hpi_volume_auto_fade(u32 h_control,
2826 duration_ms, HPI_VOLUME_AUTOFADE_LOG); 2826 duration_ms, HPI_VOLUME_AUTOFADE_LOG);
2827} 2827}
2828 2828
2829u16 hpi_volume_query_auto_fade_profile(const u32 h_volume, const u32 i,
2830 u16 *profile)
2831{
2832 u16 e;
2833 u32 u;
2834 e = hpi_control_query(h_volume, HPI_VOLUME_AUTOFADE, i, 0, &u);
2835 *profile = (u16)u;
2836 return e;
2837}
2838
2829u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB) 2839u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
2830{ 2840{
2831 struct hpi_message hm; 2841 struct hpi_message hm;
diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
index 52400a6b5f1..032d563e370 100644
--- a/sound/pci/asihpi/hpimsginit.c
+++ b/sound/pci/asihpi/hpimsginit.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpimsginit.h b/sound/pci/asihpi/hpimsginit.h
index bfd330d78b5..5b48708c7d1 100644
--- a/sound/pci/asihpi/hpimsginit.h
+++ b/sound/pci/asihpi/hpimsginit.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c
index 2e779421a61..d4790ddc225 100644
--- a/sound/pci/asihpi/hpimsgx.c
+++ b/sound/pci/asihpi/hpimsgx.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -22,6 +22,7 @@ Extended Message Function With Response Caching
22*****************************************************************************/ 22*****************************************************************************/
23#define SOURCEFILE_NAME "hpimsgx.c" 23#define SOURCEFILE_NAME "hpimsgx.c"
24#include "hpi_internal.h" 24#include "hpi_internal.h"
25#include "hpi_version.h"
25#include "hpimsginit.h" 26#include "hpimsginit.h"
26#include "hpicmn.h" 27#include "hpicmn.h"
27#include "hpimsgx.h" 28#include "hpimsgx.h"
diff --git a/sound/pci/asihpi/hpimsgx.h b/sound/pci/asihpi/hpimsgx.h
index fd49e7542a8..37f3efd95a7 100644
--- a/sound/pci/asihpi/hpimsgx.h
+++ b/sound/pci/asihpi/hpimsgx.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index f6b9517b469..60915620556 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -21,6 +21,7 @@ Common Linux HPI ioctl and module probe/remove functions
21#define SOURCEFILE_NAME "hpioctl.c" 21#define SOURCEFILE_NAME "hpioctl.c"
22 22
23#include "hpi_internal.h" 23#include "hpi_internal.h"
24#include "hpi_version.h"
24#include "hpimsginit.h" 25#include "hpimsginit.h"
25#include "hpidebug.h" 26#include "hpidebug.h"
26#include "hpimsgx.h" 27#include "hpimsgx.h"
@@ -65,9 +66,7 @@ static struct hpi_adapter adapters[HPI_MAX_ADAPTERS];
65static void hpi_send_recv_f(struct hpi_message *phm, struct hpi_response *phr, 66static void hpi_send_recv_f(struct hpi_message *phm, struct hpi_response *phr,
66 struct file *file) 67 struct file *file)
67{ 68{
68 int adapter = phm->adapter_index; 69 if ((phm->adapter_index >= HPI_MAX_ADAPTERS)
69
70 if ((adapter >= HPI_MAX_ADAPTERS || adapter < 0)
71 && (phm->object != HPI_OBJ_SUBSYSTEM)) 70 && (phm->object != HPI_OBJ_SUBSYSTEM))
72 phr->error = HPI_ERROR_INVALID_OBJ_INDEX; 71 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
73 else 72 else
@@ -178,19 +177,14 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
178 } else { 177 } else {
179 u16 __user *ptr = NULL; 178 u16 __user *ptr = NULL;
180 u32 size = 0; 179 u32 size = 0;
181 u32 adapter_present;
182 /* -1=no data 0=read from user mem, 1=write to user mem */ 180 /* -1=no data 0=read from user mem, 1=write to user mem */
183 int wrflag = -1; 181 int wrflag = -1;
184 struct hpi_adapter *pa; 182 struct hpi_adapter *pa = NULL;
185 183
186 if (hm->h.adapter_index < HPI_MAX_ADAPTERS) { 184 if (hm->h.adapter_index < ARRAY_SIZE(adapters))
187 pa = &adapters[hm->h.adapter_index]; 185 pa = &adapters[hm->h.adapter_index];
188 adapter_present = pa->type;
189 } else {
190 adapter_present = 0;
191 }
192 186
193 if (!adapter_present) { 187 if (!pa || !pa->adapter || !pa->adapter->type) {
194 hpi_init_response(&hr->r0, hm->h.object, 188 hpi_init_response(&hr->r0, hm->h.object,
195 hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER); 189 hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER);
196 190
@@ -317,6 +311,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
317 const struct pci_device_id *pci_id) 311 const struct pci_device_id *pci_id)
318{ 312{
319 int idx, nm; 313 int idx, nm;
314 int adapter_index;
320 unsigned int memlen; 315 unsigned int memlen;
321 struct hpi_message hm; 316 struct hpi_message hm;
322 struct hpi_response hr; 317 struct hpi_response hr;
@@ -345,8 +340,6 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
345 340
346 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID; 341 hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
347 342
348 adapter.pci = pci_dev;
349
350 nm = HPI_MAX_ADAPTER_MEM_SPACES; 343 nm = HPI_MAX_ADAPTER_MEM_SPACES;
351 344
352 for (idx = 0; idx < nm; idx++) { 345 for (idx = 0; idx < nm; idx++) {
@@ -355,18 +348,16 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
355 348
356 if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { 349 if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) {
357 memlen = pci_resource_len(pci_dev, idx); 350 memlen = pci_resource_len(pci_dev, idx);
358 adapter.ap_remapped_mem_base[idx] = 351 pci.ap_mem_base[idx] =
359 ioremap(pci_resource_start(pci_dev, idx), 352 ioremap(pci_resource_start(pci_dev, idx),
360 memlen); 353 memlen);
361 if (!adapter.ap_remapped_mem_base[idx]) { 354 if (!pci.ap_mem_base[idx]) {
362 HPI_DEBUG_LOG(ERROR, 355 HPI_DEBUG_LOG(ERROR,
363 "ioremap failed, aborting\n"); 356 "ioremap failed, aborting\n");
364 /* unmap previously mapped pci mem space */ 357 /* unmap previously mapped pci mem space */
365 goto err; 358 goto err;
366 } 359 }
367 } 360 }
368
369 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx];
370 } 361 }
371 362
372 pci.pci_dev = pci_dev; 363 pci.pci_dev = pci_dev;
@@ -378,6 +369,9 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
378 if (hr.error) 369 if (hr.error)
379 goto err; 370 goto err;
380 371
372 adapter_index = hr.u.s.adapter_index;
373 adapter.adapter = hpi_find_adapter(adapter_index);
374
381 if (prealloc_stream_buf) { 375 if (prealloc_stream_buf) {
382 adapter.p_buffer = vmalloc(prealloc_stream_buf); 376 adapter.p_buffer = vmalloc(prealloc_stream_buf);
383 if (!adapter.p_buffer) { 377 if (!adapter.p_buffer) {
@@ -389,36 +383,32 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev,
389 } 383 }
390 } 384 }
391 385
392 adapter.index = hr.u.s.adapter_index;
393 adapter.type = hr.u.s.adapter_type;
394
395 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 386 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
396 HPI_ADAPTER_OPEN); 387 HPI_ADAPTER_OPEN);
397 hm.adapter_index = adapter.index; 388 hm.adapter_index = adapter.adapter->index;
398 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 389 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
399 390
400 if (hr.error) 391 if (hr.error)
401 goto err; 392 goto err;
402 393
403 adapter.snd_card_asihpi = NULL;
404 /* WARNING can't init mutex in 'adapter' 394 /* WARNING can't init mutex in 'adapter'
405 * and then copy it to adapters[] ?!?! 395 * and then copy it to adapters[] ?!?!
406 */ 396 */
407 adapters[adapter.index] = adapter; 397 adapters[adapter_index] = adapter;
408 mutex_init(&adapters[adapter.index].mutex); 398 mutex_init(&adapters[adapter_index].mutex);
409 pci_set_drvdata(pci_dev, &adapters[adapter.index]); 399 pci_set_drvdata(pci_dev, &adapters[adapter_index]);
410 400
411 dev_printk(KERN_INFO, &pci_dev->dev, 401 dev_printk(KERN_INFO, &pci_dev->dev,
412 "probe succeeded for ASI%04X HPI index %d\n", adapter.type, 402 "probe succeeded for ASI%04X HPI index %d\n",
413 adapter.index); 403 adapter.adapter->type, adapter_index);
414 404
415 return 0; 405 return 0;
416 406
417err: 407err:
418 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { 408 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
419 if (adapter.ap_remapped_mem_base[idx]) { 409 if (pci.ap_mem_base[idx]) {
420 iounmap(adapter.ap_remapped_mem_base[idx]); 410 iounmap(pci.ap_mem_base[idx]);
421 adapter.ap_remapped_mem_base[idx] = NULL; 411 pci.ap_mem_base[idx] = NULL;
422 } 412 }
423 } 413 }
424 414
@@ -437,19 +427,20 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
437 struct hpi_message hm; 427 struct hpi_message hm;
438 struct hpi_response hr; 428 struct hpi_response hr;
439 struct hpi_adapter *pa; 429 struct hpi_adapter *pa;
430 struct hpi_pci pci;
431
440 pa = pci_get_drvdata(pci_dev); 432 pa = pci_get_drvdata(pci_dev);
433 pci = pa->adapter->pci;
441 434
442 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, 435 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
443 HPI_ADAPTER_DELETE); 436 HPI_ADAPTER_DELETE);
444 hm.adapter_index = pa->index; 437 hm.adapter_index = pa->adapter->index;
445 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); 438 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
446 439
447 /* unmap PCI memory space, mapped during device init. */ 440 /* unmap PCI memory space, mapped during device init. */
448 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { 441 for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
449 if (pa->ap_remapped_mem_base[idx]) { 442 if (pci.ap_mem_base[idx])
450 iounmap(pa->ap_remapped_mem_base[idx]); 443 iounmap(pci.ap_mem_base[idx]);
451 pa->ap_remapped_mem_base[idx] = NULL;
452 }
453 } 444 }
454 445
455 if (pa->p_buffer) 446 if (pa->p_buffer)
@@ -461,7 +452,7 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
461 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n", 452 "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n",
462 pci_dev->vendor, pci_dev->device, 453 pci_dev->vendor, pci_dev->device,
463 pci_dev->subsystem_vendor, pci_dev->subsystem_device, 454 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
464 pci_dev->devfn, pa->index); 455 pci_dev->devfn, pa->adapter->index);
465 456
466 memset(pa, 0, sizeof(*pa)); 457 memset(pa, 0, sizeof(*pa));
467} 458}
diff --git a/sound/pci/asihpi/hpioctl.h b/sound/pci/asihpi/hpioctl.h
index 847f72f03fe..2614aff672e 100644
--- a/sound/pci/asihpi/hpioctl.h
+++ b/sound/pci/asihpi/hpioctl.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpios.c b/sound/pci/asihpi/hpios.c
index ff2a19b544f..2d7d1c2e1d0 100644
--- a/sound/pci/asihpi/hpios.c
+++ b/sound/pci/asihpi/hpios.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h
index 2f605e34bad..c5cef113c20 100644
--- a/sound/pci/asihpi/hpios.h
+++ b/sound/pci/asihpi/hpios.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -149,20 +149,18 @@ static inline void cond_unlock(struct hpios_spinlock *l)
149#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) 149#define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock))
150#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock)) 150#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock))
151 151
152struct snd_card;
153
154/** pci drvdata points to an instance of this struct */
152struct hpi_adapter { 155struct hpi_adapter {
156 struct hpi_adapter_obj *adapter;
157 struct snd_card *snd_card;
158
153 /* mutex prevents contention for one card 159 /* mutex prevents contention for one card
154 between multiple user programs (via ioctl) */ 160 between multiple user programs (via ioctl) */
155 struct mutex mutex; 161 struct mutex mutex;
156 u16 index;
157 u16 type;
158
159 /* ALSA card structure */
160 void *snd_card_asihpi;
161
162 char *p_buffer; 162 char *p_buffer;
163 size_t buffer_size; 163 size_t buffer_size;
164 struct pci_dev *pci;
165 void __iomem *ap_remapped_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
166}; 164};
167 165
168#endif 166#endif
diff --git a/sound/pci/asihpi/hpipcida.h b/sound/pci/asihpi/hpipcida.h
index bb30868ce1a..db570ddf64b 100644
--- a/sound/pci/asihpi/hpipcida.h
+++ b/sound/pci/asihpi/hpipcida.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 15e4e5ee388..590682f115e 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -43,7 +43,7 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
43static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 43static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
44static int ac97_clock = 48000; 44static int ac97_clock = 48000;
45static char *ac97_quirk; 45static char *ac97_quirk;
46static int spdif_aclink = 1; 46static bool spdif_aclink = 1;
47static int ac97_codec = -1; 47static int ac97_codec = -1;
48 48
49module_param(index, int, 0444); 49module_param(index, int, 0444);
@@ -60,7 +60,7 @@ module_param(spdif_aclink, bool, 0444);
60MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); 60MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
61 61
62/* just for backward compatibility */ 62/* just for backward compatibility */
63static int enable; 63static bool enable;
64module_param(enable, bool, 0444); 64module_param(enable, bool, 0444);
65 65
66 66
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 57bf8f4bc7a..524d35f3123 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -51,7 +51,7 @@ module_param(ac97_clock, int, 0444);
51MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); 51MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
52 52
53/* just for backward compatibility */ 53/* just for backward compatibility */
54static int enable; 54static bool enable;
55module_param(enable, bool, 0444); 55module_param(enable, bool, 0444);
56 56
57 57
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index dc326be58c4..762bb108c51 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -26,7 +26,7 @@
26// module parameters (see "Module Parameters") 26// module parameters (see "Module Parameters")
27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
29static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 29static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
30static int pcifix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 255 }; 30static int pcifix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 255 };
31 31
32module_param_array(index, int, NULL, 0444); 32module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 489150380ea..6933a27a5d7 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -805,7 +805,7 @@ static void vortex_fifo_setadbvalid(vortex_t * vortex, int fifo, int en)
805} 805}
806 806
807static void 807static void
808vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int b, int priority, 808vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int stereo, int priority,
809 int empty, int valid, int f) 809 int empty, int valid, int f)
810{ 810{
811 int temp, lifeboat = 0; 811 int temp, lifeboat = 0;
@@ -837,7 +837,7 @@ vortex_fifo_setadbctrl(vortex_t * vortex, int fifo, int b, int priority,
837#else 837#else
838 temp = (this_4 & 0x3f) << 0xc; 838 temp = (this_4 & 0x3f) << 0xc;
839#endif 839#endif
840 temp = (temp & 0xfffffffd) | ((b & 1) << 1); 840 temp = (temp & 0xfffffffd) | ((stereo & 1) << 1);
841 temp = (temp & 0xfffffff3) | ((priority & 3) << 2); 841 temp = (temp & 0xfffffff3) | ((priority & 3) << 2);
842 temp = (temp & 0xffffffef) | ((valid & 1) << 4); 842 temp = (temp & 0xffffffef) | ((valid & 1) << 4);
843 temp |= FIFO_U1; 843 temp |= FIFO_U1;
@@ -1148,11 +1148,11 @@ vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma,
1148 1148
1149static void 1149static void
1150vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, int dir, 1150vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, int dir,
1151 int fmt, int d, u32 offset) 1151 int fmt, int stereo, u32 offset)
1152{ 1152{
1153 stream_t *dma = &vortex->dma_adb[adbdma]; 1153 stream_t *dma = &vortex->dma_adb[adbdma];
1154 1154
1155 dma->dma_unknown = d; 1155 dma->dma_unknown = stereo;
1156 dma->dma_ctrl = 1156 dma->dma_ctrl =
1157 ((offset & OFFSET_MASK) | (dma->dma_ctrl & ~OFFSET_MASK)); 1157 ((offset & OFFSET_MASK) | (dma->dma_ctrl & ~OFFSET_MASK));
1158 /* Enable PCMOUT interrupts. */ 1158 /* Enable PCMOUT interrupts. */
@@ -1336,7 +1336,6 @@ static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma)
1336 dma->fifo_status = FIFO_PAUSE; 1336 dma->fifo_status = FIFO_PAUSE;
1337} 1337}
1338 1338
1339#if 0 // Using pause instead
1340static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma) 1339static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma)
1341{ 1340{
1342 stream_t *dma = &vortex->dma_adb[adbdma]; 1341 stream_t *dma = &vortex->dma_adb[adbdma];
@@ -1351,7 +1350,6 @@ static void vortex_adbdma_stopfifo(vortex_t * vortex, int adbdma)
1351 dma->fifo_enabled = 0; 1350 dma->fifo_enabled = 0;
1352} 1351}
1353 1352
1354#endif
1355/* WTDMA */ 1353/* WTDMA */
1356 1354
1357#ifndef CHIP_AU8810 1355#ifndef CHIP_AU8810
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c
index c5f7ae46afe..0488633ea87 100644
--- a/sound/pci/au88x0/au88x0_pcm.c
+++ b/sound/pci/au88x0/au88x0_pcm.c
@@ -307,8 +307,8 @@ static int snd_vortex_pcm_prepare(struct snd_pcm_substream *substream)
307 fmt = vortex_alsafmt_aspfmt(runtime->format); 307 fmt = vortex_alsafmt_aspfmt(runtime->format);
308 spin_lock_irq(&chip->lock); 308 spin_lock_irq(&chip->lock);
309 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) { 309 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) {
310 vortex_adbdma_setmode(chip, dma, 1, dir, fmt, 0 /*? */ , 310 vortex_adbdma_setmode(chip, dma, 1, dir, fmt,
311 0); 311 runtime->channels == 1 ? 0 : 1, 0);
312 vortex_adbdma_setstartbuffer(chip, dma, 0); 312 vortex_adbdma_setstartbuffer(chip, dma, 0);
313 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_SPDIF) 313 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_SPDIF)
314 vortex_adb_setsrc(chip, dma, runtime->rate, dir); 314 vortex_adb_setsrc(chip, dma, runtime->rate, dir);
@@ -353,8 +353,7 @@ static int snd_vortex_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
353 //printk(KERN_INFO "vortex: stop %d\n", dma); 353 //printk(KERN_INFO "vortex: stop %d\n", dma);
354 stream->fifo_enabled = 0; 354 stream->fifo_enabled = 0;
355 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) 355 if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT)
356 vortex_adbdma_pausefifo(chip, dma); 356 vortex_adbdma_stopfifo(chip, dma);
357 //vortex_adbdma_stopfifo(chip, dma);
358#ifndef CHIP_AU8810 357#ifndef CHIP_AU8810
359 else { 358 else {
360 printk(KERN_INFO "vortex: wt stop %d\n", dma); 359 printk(KERN_INFO "vortex: wt stop %d\n", dma);
diff --git a/sound/pci/au88x0/au88x0_xtalk.c b/sound/pci/au88x0/au88x0_xtalk.c
index b4151e208b7..b278e285fd4 100644
--- a/sound/pci/au88x0/au88x0_xtalk.c
+++ b/sound/pci/au88x0/au88x0_xtalk.c
@@ -48,43 +48,61 @@ static unsigned short const wXtalkNarrowLeftDelay = 0x7;
48static unsigned short const wXtalkNarrowRightDelay = 0x7; 48static unsigned short const wXtalkNarrowRightDelay = 0x7;
49 49
50static xtalk_gains_t const asXtalkGainsDefault = { 50static xtalk_gains_t const asXtalkGainsDefault = {
51 0x4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 0x4000, 4000, 51 0x4000, 0x4000, 0x4000, 0x4000, 0x4000,
52 0x4000 52 0x4000, 0x4000, 0x4000, 0x4000, 0x4000
53}; 53};
54 54
55static xtalk_gains_t const asXtalkGainsTest = { 55static xtalk_gains_t const asXtalkGainsTest = {
56 0x8000, 0x7FFF, 0, 0xFFFF, 0x0001, 0xC000, 0x4000, 0xFFFE, 0x0002, 56 0x7fff, 0x8000, 0x0000, 0x0000, 0x0001,
57 0 57 0xffff, 0x4000, 0xc000, 0x0002, 0xfffe
58}; 58};
59
59static xtalk_gains_t const asXtalkGains1Chan = { 60static xtalk_gains_t const asXtalkGains1Chan = {
60 0x7FFF, 0, 0, 0, 0x7FFF, 0, 0, 0, 0, 0 61 0x7FFF, 0, 0, 0, 0,
62 0x7FFF, 0, 0, 0, 0,
61}; 63};
62 64
63// Input gain for 4 A3D slices. One possible input pair is left zero. 65// Input gain for 4 A3D slices. One possible input pair is left zero.
64static xtalk_gains_t const asXtalkGainsAllChan = { 66static xtalk_gains_t const asXtalkGainsAllChan = {
65 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 67 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0,
66 0 68 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0
67 //0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff,0x7FFF,0x7FFF,0x7FFF,0x7FFF,0x7fff 69};
70
71static xtalk_gains_t const asXtalkGainsZeros = {
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
68}; 73};
69static xtalk_gains_t const asXtalkGainsZeros;
70 74
71static xtalk_dline_t const alXtalkDlineZeros; 75static xtalk_dline_t const alXtalkDlineZeros = {
76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
78};
72static xtalk_dline_t const alXtalkDlineTest = { 79static xtalk_dline_t const alXtalkDlineTest = {
73 0xFC18, 0x03E8FFFF, 0x186A0, 0x7960FFFE, 1, 0xFFFFFFFF, 80 0x0000fc18, 0xfff03e8, 0x000186a0, 0xfffe7960, 1, 0xffffffff, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
82 0, 0, 0, 0, 0, 0, 0, 0
83};
84
85static xtalk_instate_t const asXtalkInStateZeros = {
75 0, 0, 0, 0 86 0, 0, 0, 0
76}; 87};
77 88
78static xtalk_instate_t const asXtalkInStateZeros; 89static xtalk_instate_t const asXtalkInStateTest = {
79static xtalk_instate_t const asXtalkInStateTest = 90 0x0080, 0xff80, 0x0001, 0xffff
80 { 0xFF80, 0x0080, 0xFFFF, 0x0001 }; 91};
81static xtalk_state_t const asXtalkOutStateZeros; 92
93static xtalk_state_t const asXtalkOutStateZeros = {
94 {0, 0, 0, 0},
95 {0, 0, 0, 0},
96 {0, 0, 0, 0},
97 {0, 0, 0, 0},
98 {0, 0, 0, 0}
99};
82 100
83static short const sDiamondKLeftEq = 0x401d; 101static short const sDiamondKLeftEq = 0x401d;
84static short const sDiamondKRightEq = 0x401d; 102static short const sDiamondKRightEq = 0x401d;
85static short const sDiamondKLeftXt = 0xF90E; 103static short const sDiamondKLeftXt = 0xF90E;
86static short const sDiamondKRightXt = 0xF90E; 104static short const sDiamondKRightXt = 0xF90E;
87static short const sDiamondShiftLeftEq = 1; /* 0xF90E Is this a bug ??? */ 105static short const sDiamondShiftLeftEq = 1;
88static short const sDiamondShiftRightEq = 1; 106static short const sDiamondShiftRightEq = 1;
89static short const sDiamondShiftLeftXt = 0; 107static short const sDiamondShiftLeftXt = 0;
90static short const sDiamondShiftRightXt = 0; 108static short const sDiamondShiftRightXt = 0;
@@ -94,29 +112,29 @@ static unsigned short const wDiamondRightDelay = 0xb;
94static xtalk_coefs_t const asXtalkWideCoefsLeftEq = { 112static xtalk_coefs_t const asXtalkWideCoefsLeftEq = {
95 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0}, 113 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
96 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0}, 114 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
97 {0x340B, 0xf504, 0x6CE8, 0x0D23, 0x00E4}, 115 {0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
98 {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA}, 116 {0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
99 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0} 117 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
100}; 118};
101static xtalk_coefs_t const asXtalkWideCoefsRightEq = { 119static xtalk_coefs_t const asXtalkWideCoefsRightEq = {
102 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0}, 120 {0xEC4C, 0xDCE9, 0xFDC2, 0xFEEC, 0},
103 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0}, 121 {0x5F60, 0xCBCB, 0xFC26, 0x0305, 0},
104 {0x340B, 0xF504, 0x6CE8, 0x0D23, 0x00E4}, 122 {0x340B, 0xe8f5, 0x236c, 0xe40d, 0},
105 {0xD500, 0x8D76, 0xACC7, 0x5B05, 0x00FA}, 123 {0x76d5, 0xc78d, 0x05ac, 0xfa5b, 0},
106 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0} 124 {0x7F04, 0xC0FA, 0x0263, 0xFDA2, 0}
107}; 125};
108static xtalk_coefs_t const asXtalkWideCoefsLeftXt = { 126static xtalk_coefs_t const asXtalkWideCoefsLeftXt = {
109 {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047}, 127 {0x55c6, 0xc97b, 0x005b, 0x0047, 0},
110 {0x6000, 0x206A, 0xC6CA, 0x40FF, 0}, 128 {0x6a60, 0xca20, 0xffc6, 0x0040, 0},
111 {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001}, 129 {0x6411, 0xd711, 0xfca1, 0x0190, 0},
112 {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0}, 130 {0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
113 {0, 0, 0, 0, 0} 131 {0, 0, 0, 0, 0}
114}; 132};
115static xtalk_coefs_t const asXtalkWideCoefsRightXt = { 133static xtalk_coefs_t const asXtalkWideCoefsRightXt = {
116 {0x86C3, 0x7B55, 0x89C3, 0x005B, 0x0047}, 134 {0x55c6, 0xc97b, 0x005b, 0x0047, 0},
117 {0x6000, 0x206A, 0xC6CA, 0x40FF, 0}, 135 {0x6a60, 0xca20, 0xffc6, 0x0040, 0},
118 {0x1100, 0x1164, 0xA1D7, 0x90FC, 0x0001}, 136 {0x6411, 0xd711, 0xfca1, 0x0190, 0},
119 {0xDC00, 0x9E77, 0xB8C7, 0x0AFF, 0}, 137 {0x77dc, 0xc79e, 0xffb8, 0x000a, 0},
120 {0, 0, 0, 0, 0} 138 {0, 0, 0, 0, 0}
121}; 139};
122static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = { 140static xtalk_coefs_t const asXtalkNarrowCoefsLeftEq = {
@@ -151,7 +169,14 @@ static xtalk_coefs_t const asXtalkNarrowCoefsRightXt = {
151 {0, 0, 0, 0, 0} 169 {0, 0, 0, 0, 0}
152}; 170};
153 171
154static xtalk_coefs_t const asXtalkCoefsZeros; 172static xtalk_coefs_t const asXtalkCoefsZeros = {
173 {0, 0, 0, 0, 0},
174 {0, 0, 0, 0, 0},
175 {0, 0, 0, 0, 0},
176 {0, 0, 0, 0, 0},
177 {0, 0, 0, 0, 0}
178};
179
155static xtalk_coefs_t const asXtalkCoefsPipe = { 180static xtalk_coefs_t const asXtalkCoefsPipe = {
156 {0, 0, 0x0FA0, 0, 0}, 181 {0, 0, 0x0FA0, 0, 0},
157 {0, 0, 0x0FA0, 0, 0}, 182 {0, 0, 0x0FA0, 0, 0},
@@ -186,7 +211,7 @@ static xtalk_coefs_t const asXtalkCoefsDenTest = {
186static xtalk_state_t const asXtalkOutStateTest = { 211static xtalk_state_t const asXtalkOutStateTest = {
187 {0x7FFF, 0x0004, 0xFFFC, 0}, 212 {0x7FFF, 0x0004, 0xFFFC, 0},
188 {0xFE00, 0x0008, 0xFFF8, 0x4000}, 213 {0xFE00, 0x0008, 0xFFF8, 0x4000},
189 {0x200, 0x0010, 0xFFF0, 0xC000}, 214 {0x0200, 0x0010, 0xFFF0, 0xC000},
190 {0x8000, 0x0020, 0xFFE0, 0}, 215 {0x8000, 0x0020, 0xFFE0, 0},
191 {0, 0, 0, 0} 216 {0, 0, 0, 0}
192}; 217};
@@ -306,10 +331,10 @@ vortex_XtalkHw_SetLeftEQStates(vortex_t * vortex,
306 hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]); 331 hwwrite(vortex->mmio, 0x2421C + i * 0x24, coefs[i][2]);
307 hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]); 332 hwwrite(vortex->mmio, 0x24220 + i * 0x24, coefs[i][3]);
308 } 333 }
309 hwwrite(vortex->mmio, 0x244F8 + i * 0x24, arg_0[0]); 334 hwwrite(vortex->mmio, 0x244F8, arg_0[0]);
310 hwwrite(vortex->mmio, 0x244FC + i * 0x24, arg_0[1]); 335 hwwrite(vortex->mmio, 0x244FC, arg_0[1]);
311 hwwrite(vortex->mmio, 0x24500 + i * 0x24, arg_0[2]); 336 hwwrite(vortex->mmio, 0x24500, arg_0[2]);
312 hwwrite(vortex->mmio, 0x24504 + i * 0x24, arg_0[3]); 337 hwwrite(vortex->mmio, 0x24504, arg_0[3]);
313} 338}
314 339
315static void 340static void
@@ -325,10 +350,10 @@ vortex_XtalkHw_SetRightEQStates(vortex_t * vortex,
325 hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]); 350 hwwrite(vortex->mmio, 0x242D0 + i * 0x24, coefs[i][2]);
326 hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]); 351 hwwrite(vortex->mmio, 0x244D4 + i * 0x24, coefs[i][3]);
327 } 352 }
328 hwwrite(vortex->mmio, 0x24508 + i * 0x24, arg_0[0]); 353 hwwrite(vortex->mmio, 0x24508, arg_0[0]);
329 hwwrite(vortex->mmio, 0x2450C + i * 0x24, arg_0[1]); 354 hwwrite(vortex->mmio, 0x2450C, arg_0[1]);
330 hwwrite(vortex->mmio, 0x24510 + i * 0x24, arg_0[2]); 355 hwwrite(vortex->mmio, 0x24510, arg_0[2]);
331 hwwrite(vortex->mmio, 0x24514 + i * 0x24, arg_0[3]); 356 hwwrite(vortex->mmio, 0x24514, arg_0[3]);
332} 357}
333 358
334static void 359static void
@@ -344,10 +369,10 @@ vortex_XtalkHw_SetLeftXTStates(vortex_t * vortex,
344 hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]); 369 hwwrite(vortex->mmio, 0x24384 + i * 0x24, coefs[i][2]);
345 hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]); 370 hwwrite(vortex->mmio, 0x24388 + i * 0x24, coefs[i][3]);
346 } 371 }
347 hwwrite(vortex->mmio, 0x24518 + i * 0x24, arg_0[0]); 372 hwwrite(vortex->mmio, 0x24518, arg_0[0]);
348 hwwrite(vortex->mmio, 0x2451C + i * 0x24, arg_0[1]); 373 hwwrite(vortex->mmio, 0x2451C, arg_0[1]);
349 hwwrite(vortex->mmio, 0x24520 + i * 0x24, arg_0[2]); 374 hwwrite(vortex->mmio, 0x24520, arg_0[2]);
350 hwwrite(vortex->mmio, 0x24524 + i * 0x24, arg_0[3]); 375 hwwrite(vortex->mmio, 0x24524, arg_0[3]);
351} 376}
352 377
353static void 378static void
@@ -363,10 +388,10 @@ vortex_XtalkHw_SetRightXTStates(vortex_t * vortex,
363 hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]); 388 hwwrite(vortex->mmio, 0x24438 + i * 0x24, coefs[i][2]);
364 hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]); 389 hwwrite(vortex->mmio, 0x2443C + i * 0x24, coefs[i][3]);
365 } 390 }
366 hwwrite(vortex->mmio, 0x24528 + i * 0x24, arg_0[0]); 391 hwwrite(vortex->mmio, 0x24528, arg_0[0]);
367 hwwrite(vortex->mmio, 0x2452C + i * 0x24, arg_0[1]); 392 hwwrite(vortex->mmio, 0x2452C, arg_0[1]);
368 hwwrite(vortex->mmio, 0x24530 + i * 0x24, arg_0[2]); 393 hwwrite(vortex->mmio, 0x24530, arg_0[2]);
369 hwwrite(vortex->mmio, 0x24534 + i * 0x24, arg_0[3]); 394 hwwrite(vortex->mmio, 0x24534, arg_0[3]);
370} 395}
371 396
372#if 0 397#if 0
@@ -450,10 +475,10 @@ vortex_XtalkHw_GetLeftEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
450 coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24); 475 coefs[i][2] = hwread(vortex->mmio, 0x2421C + i * 0x24);
451 coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24); 476 coefs[i][3] = hwread(vortex->mmio, 0x24220 + i * 0x24);
452 } 477 }
453 arg_0[0] = hwread(vortex->mmio, 0x244F8 + i * 0x24); 478 arg_0[0] = hwread(vortex->mmio, 0x244F8);
454 arg_0[1] = hwread(vortex->mmio, 0x244FC + i * 0x24); 479 arg_0[1] = hwread(vortex->mmio, 0x244FC);
455 arg_0[2] = hwread(vortex->mmio, 0x24500 + i * 0x24); 480 arg_0[2] = hwread(vortex->mmio, 0x24500);
456 arg_0[3] = hwread(vortex->mmio, 0x24504 + i * 0x24); 481 arg_0[3] = hwread(vortex->mmio, 0x24504);
457} 482}
458 483
459static void 484static void
@@ -468,10 +493,10 @@ vortex_XtalkHw_GetRightEQStates(vortex_t * vortex, xtalk_instate_t arg_0,
468 coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24); 493 coefs[i][2] = hwread(vortex->mmio, 0x242D0 + i * 0x24);
469 coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24); 494 coefs[i][3] = hwread(vortex->mmio, 0x242D4 + i * 0x24);
470 } 495 }
471 arg_0[0] = hwread(vortex->mmio, 0x24508 + i * 0x24); 496 arg_0[0] = hwread(vortex->mmio, 0x24508);
472 arg_0[1] = hwread(vortex->mmio, 0x2450C + i * 0x24); 497 arg_0[1] = hwread(vortex->mmio, 0x2450C);
473 arg_0[2] = hwread(vortex->mmio, 0x24510 + i * 0x24); 498 arg_0[2] = hwread(vortex->mmio, 0x24510);
474 arg_0[3] = hwread(vortex->mmio, 0x24514 + i * 0x24); 499 arg_0[3] = hwread(vortex->mmio, 0x24514);
475} 500}
476 501
477static void 502static void
@@ -486,10 +511,10 @@ vortex_XtalkHw_GetLeftXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
486 coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24); 511 coefs[i][2] = hwread(vortex->mmio, 0x24384 + i * 0x24);
487 coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24); 512 coefs[i][3] = hwread(vortex->mmio, 0x24388 + i * 0x24);
488 } 513 }
489 arg_0[0] = hwread(vortex->mmio, 0x24518 + i * 0x24); 514 arg_0[0] = hwread(vortex->mmio, 0x24518);
490 arg_0[1] = hwread(vortex->mmio, 0x2451C + i * 0x24); 515 arg_0[1] = hwread(vortex->mmio, 0x2451C);
491 arg_0[2] = hwread(vortex->mmio, 0x24520 + i * 0x24); 516 arg_0[2] = hwread(vortex->mmio, 0x24520);
492 arg_0[3] = hwread(vortex->mmio, 0x24524 + i * 0x24); 517 arg_0[3] = hwread(vortex->mmio, 0x24524);
493} 518}
494 519
495static void 520static void
@@ -504,10 +529,10 @@ vortex_XtalkHw_GetRightXTStates(vortex_t * vortex, xtalk_instate_t arg_0,
504 coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24); 529 coefs[i][2] = hwread(vortex->mmio, 0x24438 + i * 0x24);
505 coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24); 530 coefs[i][3] = hwread(vortex->mmio, 0x2443C + i * 0x24);
506 } 531 }
507 arg_0[0] = hwread(vortex->mmio, 0x24528 + i * 0x24); 532 arg_0[0] = hwread(vortex->mmio, 0x24528);
508 arg_0[1] = hwread(vortex->mmio, 0x2452C + i * 0x24); 533 arg_0[1] = hwread(vortex->mmio, 0x2452C);
509 arg_0[2] = hwread(vortex->mmio, 0x24530 + i * 0x24); 534 arg_0[2] = hwread(vortex->mmio, 0x24530);
510 arg_0[3] = hwread(vortex->mmio, 0x24534 + i * 0x24); 535 arg_0[3] = hwread(vortex->mmio, 0x24534);
511} 536}
512 537
513#endif 538#endif
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index 7a581151db0..1c523193146 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -153,7 +153,7 @@ static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
153 ********************************/ 153 ********************************/
154static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 154static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
155static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 155static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
156static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 156static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
157 157
158module_param_array(index, int, NULL, 0444); 158module_param_array(index, int, NULL, 0444);
159MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard."); 159MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard.");
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index bc1e6830b50..95ffa6a9db6 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -301,7 +301,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
301module_param_array(id, charp, NULL, 0444); 301module_param_array(id, charp, NULL, 0444);
302MODULE_PARM_DESC(id, "ID string for AZF3328 soundcard."); 302MODULE_PARM_DESC(id, "ID string for AZF3328 soundcard.");
303 303
304static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 304static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
305module_param_array(enable, bool, NULL, 0444); 305module_param_array(enable, bool, NULL, 0444);
306MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard."); 306MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard.");
307 307
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index c1c2d0c1c7f..62d6163fc9d 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -42,9 +42,9 @@ MODULE_SUPPORTED_DEVICE("{{Brooktree,Bt878},"
42 42
43static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */ 43static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
45static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 45static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
46static int digital_rate[SNDRV_CARDS]; /* digital input rate */ 46static int digital_rate[SNDRV_CARDS]; /* digital input rate */
47static int load_all; /* allow to load the non-whitelisted cards */ 47static bool load_all; /* allow to load the non-whitelisted cards */
48 48
49module_param_array(index, int, NULL, 0444); 49module_param_array(index, int, NULL, 0444);
50MODULE_PARM_DESC(index, "Index value for Bt87x soundcard"); 50MODULE_PARM_DESC(index, "Index value for Bt87x soundcard");
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index fe99fdeaf15..08d6ebfe5a6 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -156,7 +156,7 @@ MODULE_SUPPORTED_DEVICE("{{Creative,SB CA0106 chip}}");
156// module parameters (see "Module Parameters") 156// module parameters (see "Module Parameters")
157static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 157static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
158static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 158static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
159static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 159static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
160static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */ 160static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */
161 161
162module_param_array(index, int, NULL, 0444); 162module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 954c9934748..19b06269adc 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -54,10 +54,10 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8738},"
54 54
55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
57static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 57static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
58static long mpu_port[SNDRV_CARDS]; 58static long mpu_port[SNDRV_CARDS];
59static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; 59static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
60static int soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; 60static bool soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
61#ifdef SUPPORT_JOYSTICK 61#ifdef SUPPORT_JOYSTICK
62static int joystick_port[SNDRV_CARDS]; 62static int joystick_port[SNDRV_CARDS];
63#endif 63#endif
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index a6c6c5c53af..a9f368f60df 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -44,8 +44,8 @@ MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,CS4281}}");
44 44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 47static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
48static int dual_codec[SNDRV_CARDS]; /* dual codec */ 48static bool dual_codec[SNDRV_CARDS]; /* dual codec */
49 49
50module_param_array(index, int, NULL, 0444); 50module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for CS4281 soundcard."); 51MODULE_PARM_DESC(index, "Index value for CS4281 soundcard.");
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index a4ecb40f850..819d79d0586 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -46,10 +46,10 @@ MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,Sound Fusion (CS4280)},"
46 46
47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
49static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 49static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
50static int external_amp[SNDRV_CARDS]; 50static bool external_amp[SNDRV_CARDS];
51static int thinkpad[SNDRV_CARDS]; 51static bool thinkpad[SNDRV_CARDS];
52static int mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 52static bool mmap_valid[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
53 53
54module_param_array(index, int, NULL, 0444); 54module_param_array(index, int, NULL, 0444);
55MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard."); 55MODULE_PARM_DESC(index, "Index value for the CS46xx soundcard.");
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
index 958f4949e97..c47cabff2bf 100644
--- a/sound/pci/cs5530.c
+++ b/sound/pci/cs5530.c
@@ -50,7 +50,14 @@ MODULE_LICENSE("GPL");
50 50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 53static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
54
55module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for CS5530 Audio driver.");
57module_param_array(id, charp, NULL, 0444);
58MODULE_PARM_DESC(id, "ID string for CS5530 Audio driver.");
59module_param_array(enable, bool, NULL, 0444);
60MODULE_PARM_DESC(enable, "Enable CS5530 Audio driver.");
54 61
55struct snd_cs5530 { 62struct snd_cs5530 {
56 struct snd_card *card; 63 struct snd_card *card;
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index b8959d2c804..a2fb2173e98 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -57,7 +57,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
57 57
58static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 58static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
59static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 59static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
60static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 60static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
61 61
62module_param_array(index, int, NULL, 0444); 62module_param_array(index, int, NULL, 0444);
63MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME); 63MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME);
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index e134b3a5780..6e77e86307c 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -437,7 +437,7 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc)
437 437
438 /* Allocate mem for master src resource */ 438 /* Allocate mem for master src resource */
439 if (MEMRD == desc->mode) 439 if (MEMRD == desc->mode)
440 src = kzalloc(sizeof(*src)*desc->multi, GFP_KERNEL); 440 src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
441 else 441 else
442 src = kzalloc(sizeof(*src), GFP_KERNEL); 442 src = kzalloc(sizeof(*src), GFP_KERNEL);
443 443
diff --git a/sound/pci/ctxfi/cttimer.c b/sound/pci/ctxfi/cttimer.c
index 93b0aedc36d..03fb909085a 100644
--- a/sound/pci/ctxfi/cttimer.c
+++ b/sound/pci/ctxfi/cttimer.c
@@ -15,8 +15,8 @@
15#include "cthardware.h" 15#include "cthardware.h"
16#include "cttimer.h" 16#include "cttimer.h"
17 17
18static int use_system_timer; 18static bool use_system_timer;
19MODULE_PARM_DESC(use_system_timer, "Foce to use system-timer"); 19MODULE_PARM_DESC(use_system_timer, "Force to use system-timer");
20module_param(use_system_timer, bool, S_IRUGO); 20module_param(use_system_timer, bool, S_IRUGO);
21 21
22struct ct_timer_ops { 22struct ct_timer_ops {
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c
index 33931ef5e12..15d95d2bace 100644
--- a/sound/pci/ctxfi/xfi.c
+++ b/sound/pci/ctxfi/xfi.c
@@ -32,7 +32,7 @@ module_param(multiple, uint, S_IRUGO);
32 32
33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
35static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
36static unsigned int subsystem[SNDRV_CARDS]; 36static unsigned int subsystem[SNDRV_CARDS];
37 37
38module_param_array(index, int, NULL, 0444); 38module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 9fd694c6186..595c11f904b 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -26,7 +26,7 @@ MODULE_DEVICE_TABLE(pci, snd_echo_ids);
26 26
27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 27static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 28static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
29static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 29static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
30 30
31module_param_array(index, int, NULL, 0444); 31module_param_array(index, int, NULL, 0444);
32MODULE_PARM_DESC(index, "Index value for " ECHOCARD_NAME " soundcard."); 32MODULE_PARM_DESC(index, "Index value for " ECHOCARD_NAME " soundcard.");
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index eaa198e122c..790c65d980c 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -44,13 +44,13 @@ MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
44 44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 47static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
48static int extin[SNDRV_CARDS]; 48static int extin[SNDRV_CARDS];
49static int extout[SNDRV_CARDS]; 49static int extout[SNDRV_CARDS];
50static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4}; 50static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
51static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64}; 51static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
52static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128}; 52static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
53static int enable_ir[SNDRV_CARDS]; 53static bool enable_ir[SNDRV_CARDS];
54static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */ 54static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */
55static uint delay_pcm_irq[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 55static uint delay_pcm_irq[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
56 56
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 6a3e5677f59..754924081d0 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1480,6 +1480,18 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1480 .spdif_bug = 1, 1480 .spdif_bug = 1,
1481 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1481 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1482 .ac97_chip = 1} , 1482 .ac97_chip = 1} ,
1483 /* 0x20051102 also has SB0350 written on it, treated as Audigy 2 ZS by
1484 Creative's Windows driver */
1485 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20051102,
1486 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350a]",
1487 .id = "Audigy2",
1488 .emu10k2_chip = 1,
1489 .ca0102_chip = 1,
1490 .ca0151_chip = 1,
1491 .spk71 = 1,
1492 .spdif_bug = 1,
1493 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1494 .ac97_chip = 1} ,
1483 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1495 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1484 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]", 1496 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]",
1485 .id = "Audigy2", 1497 .id = "Audigy2",
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 2228be9f30e..47a651cb6e8 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -50,7 +50,7 @@ MODULE_SUPPORTED_DEVICE("{{Dell Creative Labs,SB Live!}");
50// module parameters (see "Module Parameters") 50// module parameters (see "Module Parameters")
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 53static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
54 54
55module_param_array(index, int, NULL, 0444); 55module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for the EMU10K1X soundcard."); 56MODULE_PARM_DESC(index, "Index value for the EMU10K1X soundcard.");
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index d085ad03efe..47a245e8419 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -83,12 +83,12 @@ MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI ES1371/73},"
83 83
84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
85static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 85static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
86static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 86static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */
87#ifdef SUPPORT_JOYSTICK 87#ifdef SUPPORT_JOYSTICK
88#ifdef CHIP1371 88#ifdef CHIP1371
89static int joystick_port[SNDRV_CARDS]; 89static int joystick_port[SNDRV_CARDS];
90#else 90#else
91static int joystick[SNDRV_CARDS]; 91static bool joystick[SNDRV_CARDS];
92#endif 92#endif
93#endif 93#endif
94#ifdef CHIP1371 94#ifdef CHIP1371
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 04cc21f5d01..53eb76b4110 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -79,7 +79,7 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1938},"
79 79
80static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 80static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
81static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 81static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
82static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 82static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
83 83
84module_param_array(index, int, NULL, 0444); 84module_param_array(index, int, NULL, 0444);
85MODULE_PARM_DESC(index, "Index value for ESS Solo-1 soundcard."); 85MODULE_PARM_DESC(index, "Index value for ESS Solo-1 soundcard.");
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 297a151bdba..cb557c603a8 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -132,7 +132,7 @@ MODULE_SUPPORTED_DEVICE("{{ESS,Maestro 2e},"
132 132
133static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */ 133static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 1-MAX */
134static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 134static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
135static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 135static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
136static int total_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1024 }; 136static int total_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1024 };
137static int pcm_substreams_p[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4 }; 137static int pcm_substreams_p[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4 };
138static int pcm_substreams_c[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1 }; 138static int pcm_substreams_c[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1 };
@@ -140,7 +140,7 @@ static int clock[SNDRV_CARDS];
140static int use_pm[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 140static int use_pm[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
141static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 141static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
142#ifdef SUPPORT_JOYSTICK 142#ifdef SUPPORT_JOYSTICK
143static int joystick[SNDRV_CARDS]; 143static bool joystick[SNDRV_CARDS];
144#endif 144#endif
145 145
146module_param_array(index, int, NULL, 0444); 146module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index ec05ef5a5ab..9597ef1eccc 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -48,7 +48,7 @@ MODULE_SUPPORTED_DEVICE("{{ForteMedia,FM801},"
48 48
49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 50static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
51static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 51static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
52/* 52/*
53 * Enable TEA575x tuner 53 * Enable TEA575x tuner
54 * 1 = MediaForte 256-PCS 54 * 1 = MediaForte 256-PCS
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
index bb7e102d672..163b6b5de3e 100644
--- a/sound/pci/hda/Kconfig
+++ b/sound/pci/hda/Kconfig
@@ -2,6 +2,7 @@ menuconfig SND_HDA_INTEL
2 tristate "Intel HD Audio" 2 tristate "Intel HD Audio"
3 select SND_PCM 3 select SND_PCM
4 select SND_VMASTER 4 select SND_VMASTER
5 select SND_KCTL_JACK
5 help 6 help
6 Say Y here to include support for Intel "High Definition 7 Say Y here to include support for Intel "High Definition
7 Audio" (Azalia) and its compatible devices. 8 Audio" (Azalia) and its compatible devices.
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index f928d663472..ace157cc3d1 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,6 +1,6 @@
1snd-hda-intel-objs := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2 2
3snd-hda-codec-y := hda_codec.o 3snd-hda-codec-y := hda_codec.o hda_jack.o
4snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 4snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
5snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o 5snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
6snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 6snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
diff --git a/sound/pci/hda/alc262_quirks.c b/sound/pci/hda/alc262_quirks.c
deleted file mode 100644
index 7894b2b5aac..00000000000
--- a/sound/pci/hda/alc262_quirks.c
+++ /dev/null
@@ -1,875 +0,0 @@
1/*
2 * ALC262 quirk models
3 * included by patch_realtek.c
4 */
5
6/* ALC262 models */
7enum {
8 ALC262_AUTO,
9 ALC262_BASIC,
10 ALC262_HIPPO,
11 ALC262_HIPPO_1,
12 ALC262_FUJITSU,
13 ALC262_BENQ_ED8,
14 ALC262_BENQ_T31,
15 ALC262_ULTRA,
16 ALC262_LENOVO_3000,
17 ALC262_NEC,
18 ALC262_TOSHIBA_S06,
19 ALC262_TOSHIBA_RX1,
20 ALC262_TYAN,
21 ALC262_MODEL_LAST /* last tag */
22};
23
24#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
25#define ALC262_DIGIN_NID ALC880_DIGIN_NID
26
27#define alc262_dac_nids alc260_dac_nids
28#define alc262_adc_nids alc882_adc_nids
29#define alc262_adc_nids_alt alc882_adc_nids_alt
30#define alc262_capsrc_nids alc882_capsrc_nids
31#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
32
33#define alc262_modes alc260_modes
34#define alc262_capture_source alc882_capture_source
35
36static const hda_nid_t alc262_dmic_adc_nids[1] = {
37 /* ADC0 */
38 0x09
39};
40
41static const hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
42
43static const struct snd_kcontrol_new alc262_base_mixer[] = {
44 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
45 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
46 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
47 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
48 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
49 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
50 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
51 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
52 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
53 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
54 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
55 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
56 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
57 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
58 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
59 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
60 { } /* end */
61};
62
63/* bind hp and internal speaker mute (with plug check) as master switch */
64
65static int alc262_hippo_master_sw_get(struct snd_kcontrol *kcontrol,
66 struct snd_ctl_elem_value *ucontrol)
67{
68 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
69 struct alc_spec *spec = codec->spec;
70 *ucontrol->value.integer.value = !spec->master_mute;
71 return 0;
72}
73
74static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
75 struct snd_ctl_elem_value *ucontrol)
76{
77 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
78 struct alc_spec *spec = codec->spec;
79 int val = !*ucontrol->value.integer.value;
80
81 if (val == spec->master_mute)
82 return 0;
83 spec->master_mute = val;
84 update_outputs(codec);
85 return 1;
86}
87
88#define ALC262_HIPPO_MASTER_SWITCH \
89 { \
90 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
91 .name = "Master Playback Switch", \
92 .info = snd_ctl_boolean_mono_info, \
93 .get = alc262_hippo_master_sw_get, \
94 .put = alc262_hippo_master_sw_put, \
95 }, \
96 { \
97 .iface = NID_MAPPING, \
98 .name = "Master Playback Switch", \
99 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
100 (SUBDEV_SPEAKER(0) << 16), \
101 }
102
103#define alc262_hp_master_sw_get alc262_hippo_master_sw_get
104#define alc262_hp_master_sw_put alc262_hippo_master_sw_put
105
106static const struct snd_kcontrol_new alc262_hippo_mixer[] = {
107 ALC262_HIPPO_MASTER_SWITCH,
108 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
115 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
118 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
120 { } /* end */
121};
122
123static const struct snd_kcontrol_new alc262_hippo1_mixer[] = {
124 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
125 ALC262_HIPPO_MASTER_SWITCH,
126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
132 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
135 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
136 { } /* end */
137};
138
139/* mute/unmute internal speaker according to the hp jack and mute state */
140static void alc262_hippo_setup(struct hda_codec *codec)
141{
142 struct alc_spec *spec = codec->spec;
143
144 spec->autocfg.hp_pins[0] = 0x15;
145 spec->autocfg.speaker_pins[0] = 0x14;
146 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
147}
148
149static void alc262_hippo1_setup(struct hda_codec *codec)
150{
151 struct alc_spec *spec = codec->spec;
152
153 spec->autocfg.hp_pins[0] = 0x1b;
154 spec->autocfg.speaker_pins[0] = 0x14;
155 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
156}
157
158
159static const struct snd_kcontrol_new alc262_sony_mixer[] = {
160 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
161 ALC262_HIPPO_MASTER_SWITCH,
162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
164 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
165 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
166 { } /* end */
167};
168
169static const struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
170 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
171 ALC262_HIPPO_MASTER_SWITCH,
172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
175 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
176 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
177 { } /* end */
178};
179
180static const struct snd_kcontrol_new alc262_tyan_mixer[] = {
181 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
182 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
183 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
184 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
189 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
190 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
191 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
192 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
193 { } /* end */
194};
195
196static const struct hda_verb alc262_tyan_verbs[] = {
197 /* Headphone automute */
198 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
199 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
201
202 /* P11 AUX_IN, white 4-pin connector */
203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
204 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
205 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
206 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
207
208 {}
209};
210
211/* unsolicited event for HP jack sensing */
212static void alc262_tyan_setup(struct hda_codec *codec)
213{
214 struct alc_spec *spec = codec->spec;
215
216 spec->autocfg.hp_pins[0] = 0x1b;
217 spec->autocfg.speaker_pins[0] = 0x15;
218 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
219}
220
221
222#define alc262_capture_mixer alc882_capture_mixer
223#define alc262_capture_alt_mixer alc882_capture_alt_mixer
224
225/*
226 * generic initialization of ADC, input mixers and output mixers
227 */
228static const struct hda_verb alc262_init_verbs[] = {
229 /*
230 * Unmute ADC0-2 and set the default input to mic-in
231 */
232 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
234 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
236 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
238
239 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
240 * mixer widget
241 * Note: PASD motherboards uses the Line In 2 as the input for
242 * front panel mic (mic 2)
243 */
244 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
250
251 /*
252 * Set up output mixers (0x0c - 0x0e)
253 */
254 /* set vol=0 to output mixers */
255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
257 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
258 /* set up input amps for analog loopback */
259 /* Amp Indices: DAC = 0, mixer = 1 */
260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
265 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
266
267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
269 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
270 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
272 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
273
274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
277 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
278 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
279
280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
281 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
282
283 /* FIXME: use matrix-type input source selection */
284 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
285 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
290 /* Input mixer2 */
291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
295 /* Input mixer3 */
296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
300
301 { }
302};
303
304static const struct hda_verb alc262_eapd_verbs[] = {
305 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
306 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
307 { }
308};
309
310static const struct hda_verb alc262_hippo1_unsol_verbs[] = {
311 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
312 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
313 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
314
315 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
317 {}
318};
319
320static const struct hda_verb alc262_sony_unsol_verbs[] = {
321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
323 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
324
325 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
327 {}
328};
329
330static const struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
331 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
332 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
336 { } /* end */
337};
338
339static const struct hda_verb alc262_toshiba_s06_verbs[] = {
340 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
344 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
345 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
346 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
348 {}
349};
350
351static void alc262_toshiba_s06_setup(struct hda_codec *codec)
352{
353 struct alc_spec *spec = codec->spec;
354
355 spec->autocfg.hp_pins[0] = 0x15;
356 spec->autocfg.speaker_pins[0] = 0x14;
357 spec->ext_mic_pin = 0x18;
358 spec->int_mic_pin = 0x12;
359 spec->auto_mic = 1;
360 alc_simple_setup_automute(spec, ALC_AUTOMUTE_PIN);
361}
362
363/*
364 * nec model
365 * 0x15 = headphone
366 * 0x16 = internal speaker
367 * 0x18 = external mic
368 */
369
370static const struct snd_kcontrol_new alc262_nec_mixer[] = {
371 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
372 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
373
374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
376 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
377
378 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
379 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
380 { } /* end */
381};
382
383static const struct hda_verb alc262_nec_verbs[] = {
384 /* Unmute Speaker */
385 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
386
387 /* Headphone */
388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
390
391 /* External mic to headphone */
392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
393 /* External mic to speaker */
394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
395 {}
396};
397
398/*
399 * fujitsu model
400 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
401 * 0x1b = port replicator headphone out
402 */
403
404static const struct hda_verb alc262_fujitsu_unsol_verbs[] = {
405 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
407 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
409 {}
410};
411
412static const struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
413 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
414 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
415 {}
416};
417
418static const struct hda_verb alc262_lenovo_3000_init_verbs[] = {
419 /* Front Mic pin: input vref at 50% */
420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
422 {}
423};
424
425static const struct hda_input_mux alc262_fujitsu_capture_source = {
426 .num_items = 3,
427 .items = {
428 { "Mic", 0x0 },
429 { "Internal Mic", 0x1 },
430 { "CD", 0x4 },
431 },
432};
433
434static void alc262_fujitsu_setup(struct hda_codec *codec)
435{
436 struct alc_spec *spec = codec->spec;
437
438 spec->autocfg.hp_pins[0] = 0x14;
439 spec->autocfg.hp_pins[1] = 0x1b;
440 spec->autocfg.speaker_pins[0] = 0x15;
441 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
442}
443
444/* bind volumes of both NID 0x0c and 0x0d */
445static const struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
446 .ops = &snd_hda_bind_vol,
447 .values = {
448 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
449 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
450 0
451 },
452};
453
454static const struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
455 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
456 {
457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
458 .name = "Master Playback Switch",
459 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
460 .info = snd_ctl_boolean_mono_info,
461 .get = alc262_hp_master_sw_get,
462 .put = alc262_hp_master_sw_put,
463 },
464 {
465 .iface = NID_MAPPING,
466 .name = "Master Playback Switch",
467 .private_value = 0x1b,
468 },
469 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
470 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
471 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
474 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
475 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
476 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
477 { } /* end */
478};
479
480static void alc262_lenovo_3000_setup(struct hda_codec *codec)
481{
482 struct alc_spec *spec = codec->spec;
483
484 spec->autocfg.hp_pins[0] = 0x1b;
485 spec->autocfg.speaker_pins[0] = 0x14;
486 spec->autocfg.speaker_pins[1] = 0x16;
487 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
488}
489
490static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
491 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
492 {
493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
494 .name = "Master Playback Switch",
495 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
496 .info = snd_ctl_boolean_mono_info,
497 .get = alc262_hp_master_sw_get,
498 .put = alc262_hp_master_sw_put,
499 },
500 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
501 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
502 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
505 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
506 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
507 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
508 { } /* end */
509};
510
511static const struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
512 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
513 ALC262_HIPPO_MASTER_SWITCH,
514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
516 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
517 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
518 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
519 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
520 { } /* end */
521};
522
523/* additional init verbs for Benq laptops */
524static const struct hda_verb alc262_EAPD_verbs[] = {
525 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
526 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
527 {}
528};
529
530static const struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
531 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
533
534 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
535 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
536 {}
537};
538
539/* Samsung Q1 Ultra Vista model setup */
540static const struct snd_kcontrol_new alc262_ultra_mixer[] = {
541 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
542 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
544 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
545 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
546 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
547 { } /* end */
548};
549
550static const struct hda_verb alc262_ultra_verbs[] = {
551 /* output mixer */
552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
555 /* speaker */
556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
559 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
560 /* HP */
561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
565 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
566 /* internal mic */
567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
569 /* ADC, choose mic */
570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
580 {}
581};
582
583/* mute/unmute internal speaker according to the hp jack and mute state */
584static void alc262_ultra_automute(struct hda_codec *codec)
585{
586 struct alc_spec *spec = codec->spec;
587 unsigned int mute;
588
589 mute = 0;
590 /* auto-mute only when HP is used as HP */
591 if (!spec->cur_mux[0]) {
592 spec->hp_jack_present = snd_hda_jack_detect(codec, 0x15);
593 if (spec->hp_jack_present)
594 mute = HDA_AMP_MUTE;
595 }
596 /* mute/unmute internal speaker */
597 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
598 HDA_AMP_MUTE, mute);
599 /* mute/unmute HP */
600 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
601 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
602}
603
604/* unsolicited event for HP jack sensing */
605static void alc262_ultra_unsol_event(struct hda_codec *codec,
606 unsigned int res)
607{
608 if ((res >> 26) != ALC_HP_EVENT)
609 return;
610 alc262_ultra_automute(codec);
611}
612
613static const struct hda_input_mux alc262_ultra_capture_source = {
614 .num_items = 2,
615 .items = {
616 { "Mic", 0x1 },
617 { "Headphone", 0x7 },
618 },
619};
620
621static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct alc_spec *spec = codec->spec;
626 int ret;
627
628 ret = alc_mux_enum_put(kcontrol, ucontrol);
629 if (!ret)
630 return 0;
631 /* reprogram the HP pin as mic or HP according to the input source */
632 snd_hda_codec_write_cache(codec, 0x15, 0,
633 AC_VERB_SET_PIN_WIDGET_CONTROL,
634 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
635 alc262_ultra_automute(codec); /* mute/unmute HP */
636 return ret;
637}
638
639static const struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
640 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
641 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
642 {
643 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
644 .name = "Capture Source",
645 .info = alc_mux_enum_info,
646 .get = alc_mux_enum_get,
647 .put = alc262_ultra_mux_enum_put,
648 },
649 {
650 .iface = NID_MAPPING,
651 .name = "Capture Source",
652 .private_value = 0x15,
653 },
654 { } /* end */
655};
656
657static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
658
659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
661 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
662
663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
667
668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
669 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
670 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
671 {}
672};
673
674/*
675 * configuration and preset
676 */
677static const char * const alc262_models[ALC262_MODEL_LAST] = {
678 [ALC262_BASIC] = "basic",
679 [ALC262_HIPPO] = "hippo",
680 [ALC262_HIPPO_1] = "hippo_1",
681 [ALC262_FUJITSU] = "fujitsu",
682 [ALC262_BENQ_ED8] = "benq",
683 [ALC262_BENQ_T31] = "benq-t31",
684 [ALC262_TOSHIBA_S06] = "toshiba-s06",
685 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
686 [ALC262_ULTRA] = "ultra",
687 [ALC262_LENOVO_3000] = "lenovo-3000",
688 [ALC262_NEC] = "nec",
689 [ALC262_TYAN] = "tyan",
690 [ALC262_AUTO] = "auto",
691};
692
693static const struct snd_pci_quirk alc262_cfg_tbl[] = {
694 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
695 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
696 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
697 ALC262_TOSHIBA_RX1),
698 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
699 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
700 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
701 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
702 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
703 ALC262_ULTRA),
704 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
705 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
706 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
707 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
708 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
709 {}
710};
711
712static const struct alc_config_preset alc262_presets[] = {
713 [ALC262_BASIC] = {
714 .mixers = { alc262_base_mixer },
715 .init_verbs = { alc262_init_verbs },
716 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
717 .dac_nids = alc262_dac_nids,
718 .hp_nid = 0x03,
719 .num_channel_mode = ARRAY_SIZE(alc262_modes),
720 .channel_mode = alc262_modes,
721 .input_mux = &alc262_capture_source,
722 },
723 [ALC262_HIPPO] = {
724 .mixers = { alc262_hippo_mixer },
725 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
726 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
727 .dac_nids = alc262_dac_nids,
728 .hp_nid = 0x03,
729 .dig_out_nid = ALC262_DIGOUT_NID,
730 .num_channel_mode = ARRAY_SIZE(alc262_modes),
731 .channel_mode = alc262_modes,
732 .input_mux = &alc262_capture_source,
733 .unsol_event = alc_sku_unsol_event,
734 .setup = alc262_hippo_setup,
735 .init_hook = alc_inithook,
736 },
737 [ALC262_HIPPO_1] = {
738 .mixers = { alc262_hippo1_mixer },
739 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
740 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
741 .dac_nids = alc262_dac_nids,
742 .hp_nid = 0x02,
743 .dig_out_nid = ALC262_DIGOUT_NID,
744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
745 .channel_mode = alc262_modes,
746 .input_mux = &alc262_capture_source,
747 .unsol_event = alc_sku_unsol_event,
748 .setup = alc262_hippo1_setup,
749 .init_hook = alc_inithook,
750 },
751 [ALC262_FUJITSU] = {
752 .mixers = { alc262_fujitsu_mixer },
753 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
754 alc262_fujitsu_unsol_verbs },
755 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
756 .dac_nids = alc262_dac_nids,
757 .hp_nid = 0x03,
758 .dig_out_nid = ALC262_DIGOUT_NID,
759 .num_channel_mode = ARRAY_SIZE(alc262_modes),
760 .channel_mode = alc262_modes,
761 .input_mux = &alc262_fujitsu_capture_source,
762 .unsol_event = alc_sku_unsol_event,
763 .setup = alc262_fujitsu_setup,
764 .init_hook = alc_inithook,
765 },
766 [ALC262_BENQ_ED8] = {
767 .mixers = { alc262_base_mixer },
768 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
769 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
770 .dac_nids = alc262_dac_nids,
771 .hp_nid = 0x03,
772 .num_channel_mode = ARRAY_SIZE(alc262_modes),
773 .channel_mode = alc262_modes,
774 .input_mux = &alc262_capture_source,
775 },
776 [ALC262_BENQ_T31] = {
777 .mixers = { alc262_benq_t31_mixer },
778 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
779 alc_hp15_unsol_verbs },
780 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
781 .dac_nids = alc262_dac_nids,
782 .hp_nid = 0x03,
783 .num_channel_mode = ARRAY_SIZE(alc262_modes),
784 .channel_mode = alc262_modes,
785 .input_mux = &alc262_capture_source,
786 .unsol_event = alc_sku_unsol_event,
787 .setup = alc262_hippo_setup,
788 .init_hook = alc_inithook,
789 },
790 [ALC262_ULTRA] = {
791 .mixers = { alc262_ultra_mixer },
792 .cap_mixer = alc262_ultra_capture_mixer,
793 .init_verbs = { alc262_ultra_verbs },
794 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
795 .dac_nids = alc262_dac_nids,
796 .num_channel_mode = ARRAY_SIZE(alc262_modes),
797 .channel_mode = alc262_modes,
798 .input_mux = &alc262_ultra_capture_source,
799 .adc_nids = alc262_adc_nids, /* ADC0 */
800 .capsrc_nids = alc262_capsrc_nids,
801 .num_adc_nids = 1, /* single ADC */
802 .unsol_event = alc262_ultra_unsol_event,
803 .init_hook = alc262_ultra_automute,
804 },
805 [ALC262_LENOVO_3000] = {
806 .mixers = { alc262_lenovo_3000_mixer },
807 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
808 alc262_lenovo_3000_unsol_verbs,
809 alc262_lenovo_3000_init_verbs },
810 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
811 .dac_nids = alc262_dac_nids,
812 .hp_nid = 0x03,
813 .dig_out_nid = ALC262_DIGOUT_NID,
814 .num_channel_mode = ARRAY_SIZE(alc262_modes),
815 .channel_mode = alc262_modes,
816 .input_mux = &alc262_fujitsu_capture_source,
817 .unsol_event = alc_sku_unsol_event,
818 .setup = alc262_lenovo_3000_setup,
819 .init_hook = alc_inithook,
820 },
821 [ALC262_NEC] = {
822 .mixers = { alc262_nec_mixer },
823 .init_verbs = { alc262_nec_verbs },
824 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
825 .dac_nids = alc262_dac_nids,
826 .hp_nid = 0x03,
827 .num_channel_mode = ARRAY_SIZE(alc262_modes),
828 .channel_mode = alc262_modes,
829 .input_mux = &alc262_capture_source,
830 },
831 [ALC262_TOSHIBA_S06] = {
832 .mixers = { alc262_toshiba_s06_mixer },
833 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
834 alc262_eapd_verbs },
835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
836 .capsrc_nids = alc262_dmic_capsrc_nids,
837 .dac_nids = alc262_dac_nids,
838 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
839 .num_adc_nids = 1, /* single ADC */
840 .dig_out_nid = ALC262_DIGOUT_NID,
841 .num_channel_mode = ARRAY_SIZE(alc262_modes),
842 .channel_mode = alc262_modes,
843 .unsol_event = alc_sku_unsol_event,
844 .setup = alc262_toshiba_s06_setup,
845 .init_hook = alc_inithook,
846 },
847 [ALC262_TOSHIBA_RX1] = {
848 .mixers = { alc262_toshiba_rx1_mixer },
849 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
850 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
851 .dac_nids = alc262_dac_nids,
852 .hp_nid = 0x03,
853 .num_channel_mode = ARRAY_SIZE(alc262_modes),
854 .channel_mode = alc262_modes,
855 .input_mux = &alc262_capture_source,
856 .unsol_event = alc_sku_unsol_event,
857 .setup = alc262_hippo_setup,
858 .init_hook = alc_inithook,
859 },
860 [ALC262_TYAN] = {
861 .mixers = { alc262_tyan_mixer },
862 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
863 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
864 .dac_nids = alc262_dac_nids,
865 .hp_nid = 0x02,
866 .dig_out_nid = ALC262_DIGOUT_NID,
867 .num_channel_mode = ARRAY_SIZE(alc262_modes),
868 .channel_mode = alc262_modes,
869 .input_mux = &alc262_capture_source,
870 .unsol_event = alc_sku_unsol_event,
871 .setup = alc262_tyan_setup,
872 .init_hook = alc_hp_automute,
873 },
874};
875
diff --git a/sound/pci/hda/alc880_quirks.c b/sound/pci/hda/alc880_quirks.c
index bea22edcfd8..5b68435d195 100644
--- a/sound/pci/hda/alc880_quirks.c
+++ b/sound/pci/hda/alc880_quirks.c
@@ -26,8 +26,6 @@ enum {
26 ALC880_CLEVO, 26 ALC880_CLEVO,
27 ALC880_TCL_S700, 27 ALC880_TCL_S700,
28 ALC880_LG, 28 ALC880_LG,
29 ALC880_LG_LW,
30 ALC880_MEDION_RIM,
31#ifdef CONFIG_SND_DEBUG 29#ifdef CONFIG_SND_DEBUG
32 ALC880_TEST, 30 ALC880_TEST,
33#endif 31#endif
@@ -1052,163 +1050,6 @@ static void alc880_lg_setup(struct hda_codec *codec)
1052 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP); 1050 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1053} 1051}
1054 1052
1055/*
1056 * LG LW20
1057 *
1058 * Pin assignment:
1059 * Speaker-out: 0x14
1060 * Mic-In: 0x18
1061 * Built-in Mic-In: 0x19
1062 * Line-In: 0x1b
1063 * HP-Out: 0x1a
1064 * SPDIF-Out: 0x1e
1065 */
1066
1067static const struct hda_input_mux alc880_lg_lw_capture_source = {
1068 .num_items = 3,
1069 .items = {
1070 { "Mic", 0x0 },
1071 { "Internal Mic", 0x1 },
1072 { "Line In", 0x2 },
1073 },
1074};
1075
1076#define alc880_lg_lw_modes alc880_threestack_modes
1077
1078static const struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1079 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1080 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1081 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1082 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1083 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1084 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1085 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1086 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1089 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1090 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1091 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1092 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1093 {
1094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1095 .name = "Channel Mode",
1096 .info = alc_ch_mode_info,
1097 .get = alc_ch_mode_get,
1098 .put = alc_ch_mode_put,
1099 },
1100 { } /* end */
1101};
1102
1103static const struct hda_verb alc880_lg_lw_init_verbs[] = {
1104 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1105 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1106 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1107
1108 /* set capture source to mic-in */
1109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1110 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1111 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1113 /* speaker-out */
1114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1115 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1116 /* HP-out */
1117 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1118 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1119 /* mic-in to input */
1120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1122 /* built-in mic */
1123 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1125 /* jack sense */
1126 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
1127 { }
1128};
1129
1130/* toggle speaker-output according to the hp-jack state */
1131static void alc880_lg_lw_setup(struct hda_codec *codec)
1132{
1133 struct alc_spec *spec = codec->spec;
1134
1135 spec->autocfg.hp_pins[0] = 0x1b;
1136 spec->autocfg.speaker_pins[0] = 0x14;
1137 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1138}
1139
1140static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
1141 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1142 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1145 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1146 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
1147 { } /* end */
1148};
1149
1150static const struct hda_input_mux alc880_medion_rim_capture_source = {
1151 .num_items = 2,
1152 .items = {
1153 { "Mic", 0x0 },
1154 { "Internal Mic", 0x1 },
1155 },
1156};
1157
1158static const struct hda_verb alc880_medion_rim_init_verbs[] = {
1159 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1160
1161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1162 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1163
1164 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1166 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1167 /* Mic2 (as headphone out) for HP output */
1168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1170 /* Internal Speaker */
1171 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1172 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1173
1174 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1175 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1176
1177 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
1178 { }
1179};
1180
1181/* toggle speaker-output according to the hp-jack state */
1182static void alc880_medion_rim_automute(struct hda_codec *codec)
1183{
1184 struct alc_spec *spec = codec->spec;
1185 alc_hp_automute(codec);
1186 /* toggle EAPD */
1187 if (spec->hp_jack_present)
1188 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
1189 else
1190 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
1191}
1192
1193static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
1194 unsigned int res)
1195{
1196 /* Looks like the unsol event is incompatible with the standard
1197 * definition. 4bit tag is placed at 28 bit!
1198 */
1199 if ((res >> 28) == ALC_HP_EVENT)
1200 alc880_medion_rim_automute(codec);
1201}
1202
1203static void alc880_medion_rim_setup(struct hda_codec *codec)
1204{
1205 struct alc_spec *spec = codec->spec;
1206
1207 spec->autocfg.hp_pins[0] = 0x14;
1208 spec->autocfg.speaker_pins[0] = 0x1b;
1209 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1210}
1211
1212#ifdef CONFIG_SND_HDA_POWER_SAVE 1053#ifdef CONFIG_SND_HDA_POWER_SAVE
1213static const struct hda_amp_list alc880_lg_loopbacks[] = { 1054static const struct hda_amp_list alc880_lg_loopbacks[] = {
1214 { 0x0b, HDA_INPUT, 1 }, 1055 { 0x0b, HDA_INPUT, 1 },
@@ -1505,8 +1346,6 @@ static const char * const alc880_models[ALC880_MODEL_LAST] = {
1505 [ALC880_FUJITSU] = "fujitsu", 1346 [ALC880_FUJITSU] = "fujitsu",
1506 [ALC880_F1734] = "F1734", 1347 [ALC880_F1734] = "F1734",
1507 [ALC880_LG] = "lg", 1348 [ALC880_LG] = "lg",
1508 [ALC880_LG_LW] = "lg-lw",
1509 [ALC880_MEDION_RIM] = "medion",
1510#ifdef CONFIG_SND_DEBUG 1349#ifdef CONFIG_SND_DEBUG
1511 [ALC880_TEST] = "test", 1350 [ALC880_TEST] = "test",
1512#endif 1351#endif
@@ -1557,18 +1396,15 @@ static const struct snd_pci_quirk alc880_cfg_tbl[] = {
1557 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), 1396 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
1558 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), 1397 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
1559 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), 1398 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
1560 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
1561 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), 1399 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
1562 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), 1400 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
1563 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), 1401 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
1564 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), 1402 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
1565 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734), 1403 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
1566 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), 1404 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
1567 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
1568 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), 1405 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
1569 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG), 1406 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
1570 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), 1407 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
1571 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
1572 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), 1408 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
1573 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ 1409 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
1574 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), 1410 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
@@ -1848,35 +1684,6 @@ static const struct alc_config_preset alc880_presets[] = {
1848 .loopbacks = alc880_lg_loopbacks, 1684 .loopbacks = alc880_lg_loopbacks,
1849#endif 1685#endif
1850 }, 1686 },
1851 [ALC880_LG_LW] = {
1852 .mixers = { alc880_lg_lw_mixer },
1853 .init_verbs = { alc880_volume_init_verbs,
1854 alc880_lg_lw_init_verbs },
1855 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1856 .dac_nids = alc880_dac_nids,
1857 .dig_out_nid = ALC880_DIGOUT_NID,
1858 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
1859 .channel_mode = alc880_lg_lw_modes,
1860 .input_mux = &alc880_lg_lw_capture_source,
1861 .unsol_event = alc_sku_unsol_event,
1862 .setup = alc880_lg_lw_setup,
1863 .init_hook = alc_hp_automute,
1864 },
1865 [ALC880_MEDION_RIM] = {
1866 .mixers = { alc880_medion_rim_mixer },
1867 .init_verbs = { alc880_volume_init_verbs,
1868 alc880_medion_rim_init_verbs,
1869 alc_gpio2_init_verbs },
1870 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1871 .dac_nids = alc880_dac_nids,
1872 .dig_out_nid = ALC880_DIGOUT_NID,
1873 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1874 .channel_mode = alc880_2_jack_modes,
1875 .input_mux = &alc880_medion_rim_capture_source,
1876 .unsol_event = alc880_medion_rim_unsol_event,
1877 .setup = alc880_medion_rim_setup,
1878 .init_hook = alc880_medion_rim_automute,
1879 },
1880#ifdef CONFIG_SND_DEBUG 1687#ifdef CONFIG_SND_DEBUG
1881 [ALC880_TEST] = { 1688 [ALC880_TEST] = {
1882 .mixers = { alc880_test_mixer }, 1689 .mixers = { alc880_test_mixer },
diff --git a/sound/pci/hda/alc882_quirks.c b/sound/pci/hda/alc882_quirks.c
index e251514a26a..bdf0ed4ab3e 100644
--- a/sound/pci/hda/alc882_quirks.c
+++ b/sound/pci/hda/alc882_quirks.c
@@ -6,509 +6,15 @@
6/* ALC882 models */ 6/* ALC882 models */
7enum { 7enum {
8 ALC882_AUTO, 8 ALC882_AUTO,
9 ALC882_3ST_DIG,
10 ALC882_6ST_DIG,
11 ALC882_ARIMA,
12 ALC882_W2JC,
13 ALC882_TARGA,
14 ALC882_ASUS_A7J,
15 ALC882_ASUS_A7M,
16 ALC885_MACPRO,
17 ALC885_MBA21, 9 ALC885_MBA21,
18 ALC885_MBP3, 10 ALC885_MBP3,
19 ALC885_MB5, 11 ALC885_MB5,
20 ALC885_MACMINI3, 12 ALC885_MACMINI3,
21 ALC885_IMAC24,
22 ALC885_IMAC91, 13 ALC885_IMAC91,
23 ALC883_3ST_2ch_DIG,
24 ALC883_3ST_6ch_DIG,
25 ALC883_3ST_6ch,
26 ALC883_6ST_DIG,
27 ALC883_TARGA_DIG,
28 ALC883_TARGA_2ch_DIG,
29 ALC883_TARGA_8ch_DIG,
30 ALC883_ACER,
31 ALC883_ACER_ASPIRE,
32 ALC888_ACER_ASPIRE_4930G,
33 ALC888_ACER_ASPIRE_6530G,
34 ALC888_ACER_ASPIRE_8930G,
35 ALC888_ACER_ASPIRE_7730G,
36 ALC883_MEDION,
37 ALC883_MEDION_WIM2160,
38 ALC883_LAPTOP_EAPD,
39 ALC883_LENOVO_101E_2ch,
40 ALC883_LENOVO_NB0763,
41 ALC888_LENOVO_MS7195_DIG,
42 ALC888_LENOVO_SKY,
43 ALC883_HAIER_W66,
44 ALC888_3ST_HP,
45 ALC888_6ST_DELL,
46 ALC883_MITAC,
47 ALC883_CLEVO_M540R,
48 ALC883_CLEVO_M720,
49 ALC883_FUJITSU_PI2515,
50 ALC888_FUJITSU_XA3530,
51 ALC883_3ST_6ch_INTEL,
52 ALC889A_INTEL,
53 ALC889_INTEL,
54 ALC888_ASUS_M90V,
55 ALC888_ASUS_EEE1601,
56 ALC889A_MB31, 14 ALC889A_MB31,
57 ALC1200_ASUS_P5Q,
58 ALC883_SONY_VAIO_TT,
59 ALC882_MODEL_LAST, 15 ALC882_MODEL_LAST,
60}; 16};
61 17
62/*
63 * 2ch mode
64 */
65static const struct hda_verb alc888_4ST_ch2_intel_init[] = {
66/* Mic-in jack as mic in */
67 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
68 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
69/* Line-in jack as Line in */
70 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
71 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
72/* Line-Out as Front */
73 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
74 { } /* end */
75};
76
77/*
78 * 4ch mode
79 */
80static const struct hda_verb alc888_4ST_ch4_intel_init[] = {
81/* Mic-in jack as mic in */
82 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
83 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
84/* Line-in jack as Surround */
85 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
86 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
87/* Line-Out as Front */
88 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
89 { } /* end */
90};
91
92/*
93 * 6ch mode
94 */
95static const struct hda_verb alc888_4ST_ch6_intel_init[] = {
96/* Mic-in jack as CLFE */
97 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
98 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
99/* Line-in jack as Surround */
100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
102/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
103 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
104 { } /* end */
105};
106
107/*
108 * 8ch mode
109 */
110static const struct hda_verb alc888_4ST_ch8_intel_init[] = {
111/* Mic-in jack as CLFE */
112 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
113 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
114/* Line-in jack as Surround */
115 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
116 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
117/* Line-Out as Side */
118 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
119 { } /* end */
120};
121
122static const struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
123 { 2, alc888_4ST_ch2_intel_init },
124 { 4, alc888_4ST_ch4_intel_init },
125 { 6, alc888_4ST_ch6_intel_init },
126 { 8, alc888_4ST_ch8_intel_init },
127};
128
129/*
130 * ALC888 Fujitsu Siemens Amillo xa3530
131 */
132
133static const struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
134/* Front Mic: set to PIN_IN (empty by default) */
135 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
136/* Connect Internal HP to Front */
137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
139 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
140/* Connect Bass HP to Front */
141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
144/* Connect Line-Out side jack (SPDIF) to Side */
145 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
146 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
147 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
148/* Connect Mic jack to CLFE */
149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
150 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
151 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
152/* Connect Line-in jack to Surround */
153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
155 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
156/* Connect HP out jack to Front */
157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
159 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
160/* Enable unsolicited event for HP jack and Line-out jack */
161 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
162 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
163 {}
164};
165
166static void alc889_automute_setup(struct hda_codec *codec)
167{
168 struct alc_spec *spec = codec->spec;
169
170 spec->autocfg.hp_pins[0] = 0x15;
171 spec->autocfg.speaker_pins[0] = 0x14;
172 spec->autocfg.speaker_pins[1] = 0x16;
173 spec->autocfg.speaker_pins[2] = 0x17;
174 spec->autocfg.speaker_pins[3] = 0x19;
175 spec->autocfg.speaker_pins[4] = 0x1a;
176 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
177}
178
179static void alc889_intel_init_hook(struct hda_codec *codec)
180{
181 alc889_coef_init(codec);
182 alc_hp_automute(codec);
183}
184
185static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
186{
187 struct alc_spec *spec = codec->spec;
188
189 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
190 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
191 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
192 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
193 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
194}
195
196/*
197 * ALC888 Acer Aspire 4930G model
198 */
199
200static const struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
201/* Front Mic: set to PIN_IN (empty by default) */
202 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
203/* Unselect Front Mic by default in input mixer 3 */
204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
205/* Enable unsolicited event for HP jack */
206 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
207/* Connect Internal HP to front */
208 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
210 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
211/* Connect HP out to front */
212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
215 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
216 { }
217};
218
219/*
220 * ALC888 Acer Aspire 6530G model
221 */
222
223static const struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
224/* Route to built-in subwoofer as well as speakers */
225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
227 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
228 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
229/* Bias voltage on for external mic port */
230 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
231/* Front Mic: set to PIN_IN (empty by default) */
232 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
233/* Unselect Front Mic by default in input mixer 3 */
234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
235/* Enable unsolicited event for HP jack */
236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
237/* Enable speaker output */
238 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
240 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
241/* Enable headphone output */
242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
244 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
245 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
246 { }
247};
248
249/*
250 *ALC888 Acer Aspire 7730G model
251 */
252
253static const struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
254/* Bias voltage on for external mic port */
255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
256/* Front Mic: set to PIN_IN (empty by default) */
257 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
258/* Unselect Front Mic by default in input mixer 3 */
259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
260/* Enable unsolicited event for HP jack */
261 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
262/* Enable speaker output */
263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
265 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
266/* Enable headphone output */
267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
270 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
271/*Enable internal subwoofer */
272 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
274 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
275 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
276 { }
277};
278
279/*
280 * ALC889 Acer Aspire 8930G model
281 */
282
283static const struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
284/* Front Mic: set to PIN_IN (empty by default) */
285 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
286/* Unselect Front Mic by default in input mixer 3 */
287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
288/* Enable unsolicited event for HP jack */
289 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
290/* Connect Internal Front to Front */
291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
293 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
294/* Connect Internal Rear to Rear */
295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
296 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
297 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
298/* Connect Internal CLFE to CLFE */
299 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
300 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
301 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
302/* Connect HP out to Front */
303 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
305 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
306/* Enable all DACs */
307/* DAC DISABLE/MUTE 1? */
308/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
309 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
310 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
311/* DAC DISABLE/MUTE 2? */
312/* some bit here disables the other DACs. Init=0x4900 */
313 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
314 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
315/* DMIC fix
316 * This laptop has a stereo digital microphone. The mics are only 1cm apart
317 * which makes the stereo useless. However, either the mic or the ALC889
318 * makes the signal become a difference/sum signal instead of standard
319 * stereo, which is annoying. So instead we flip this bit which makes the
320 * codec replicate the sum signal to both channels, turning it into a
321 * normal mono mic.
322 */
323/* DMIC_CONTROL? Init value = 0x0001 */
324 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
325 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
326 { }
327};
328
329static const struct hda_input_mux alc888_2_capture_sources[2] = {
330 /* Front mic only available on one ADC */
331 {
332 .num_items = 4,
333 .items = {
334 { "Mic", 0x0 },
335 { "Line", 0x2 },
336 { "CD", 0x4 },
337 { "Front Mic", 0xb },
338 },
339 },
340 {
341 .num_items = 3,
342 .items = {
343 { "Mic", 0x0 },
344 { "Line", 0x2 },
345 { "CD", 0x4 },
346 },
347 }
348};
349
350static const struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
351 /* Interal mic only available on one ADC */
352 {
353 .num_items = 5,
354 .items = {
355 { "Mic", 0x0 },
356 { "Line In", 0x2 },
357 { "CD", 0x4 },
358 { "Input Mix", 0xa },
359 { "Internal Mic", 0xb },
360 },
361 },
362 {
363 .num_items = 4,
364 .items = {
365 { "Mic", 0x0 },
366 { "Line In", 0x2 },
367 { "CD", 0x4 },
368 { "Input Mix", 0xa },
369 },
370 }
371};
372
373static const struct hda_input_mux alc889_capture_sources[3] = {
374 /* Digital mic only available on first "ADC" */
375 {
376 .num_items = 5,
377 .items = {
378 { "Mic", 0x0 },
379 { "Line", 0x2 },
380 { "CD", 0x4 },
381 { "Front Mic", 0xb },
382 { "Input Mix", 0xa },
383 },
384 },
385 {
386 .num_items = 4,
387 .items = {
388 { "Mic", 0x0 },
389 { "Line", 0x2 },
390 { "CD", 0x4 },
391 { "Input Mix", 0xa },
392 },
393 },
394 {
395 .num_items = 4,
396 .items = {
397 { "Mic", 0x0 },
398 { "Line", 0x2 },
399 { "CD", 0x4 },
400 { "Input Mix", 0xa },
401 },
402 }
403};
404
405static const struct snd_kcontrol_new alc888_base_mixer[] = {
406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
407 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
408 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
409 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
410 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
411 HDA_OUTPUT),
412 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
413 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
414 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
415 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
416 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
422 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
424 { } /* end */
425};
426
427static const struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
429 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
430 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
431 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
432 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
433 HDA_OUTPUT),
434 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
435 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
436 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
437 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
438 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
439 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
440 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
441 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
442 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
444 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
446 { } /* end */
447};
448
449static const struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
450 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
451 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
452 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
453 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
455 HDA_OUTPUT),
456 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
457 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
458 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
459 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
460 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
462 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
464 { } /* end */
465};
466
467
468static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
469{
470 struct alc_spec *spec = codec->spec;
471
472 spec->autocfg.hp_pins[0] = 0x15;
473 spec->autocfg.speaker_pins[0] = 0x14;
474 spec->autocfg.speaker_pins[1] = 0x16;
475 spec->autocfg.speaker_pins[2] = 0x17;
476 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
477}
478
479static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
480{
481 struct alc_spec *spec = codec->spec;
482
483 spec->autocfg.hp_pins[0] = 0x15;
484 spec->autocfg.speaker_pins[0] = 0x14;
485 spec->autocfg.speaker_pins[1] = 0x16;
486 spec->autocfg.speaker_pins[2] = 0x17;
487 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
488}
489
490static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
491{
492 struct alc_spec *spec = codec->spec;
493
494 spec->autocfg.hp_pins[0] = 0x15;
495 spec->autocfg.speaker_pins[0] = 0x14;
496 spec->autocfg.speaker_pins[1] = 0x16;
497 spec->autocfg.speaker_pins[2] = 0x17;
498 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
499}
500
501static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
502{
503 struct alc_spec *spec = codec->spec;
504
505 spec->autocfg.hp_pins[0] = 0x15;
506 spec->autocfg.speaker_pins[0] = 0x14;
507 spec->autocfg.speaker_pins[1] = 0x16;
508 spec->autocfg.speaker_pins[2] = 0x1b;
509 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
510}
511
512#define ALC882_DIGOUT_NID 0x06 18#define ALC882_DIGOUT_NID 0x06
513#define ALC882_DIGIN_NID 0x0a 19#define ALC882_DIGIN_NID 0x0a
514#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID 20#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
@@ -531,15 +37,9 @@ static const hda_nid_t alc882_dac_nids[4] = {
531#define alc882_adc_nids alc880_adc_nids 37#define alc882_adc_nids alc880_adc_nids
532#define alc882_adc_nids_alt alc880_adc_nids_alt 38#define alc882_adc_nids_alt alc880_adc_nids_alt
533#define alc883_adc_nids alc882_adc_nids_alt 39#define alc883_adc_nids alc882_adc_nids_alt
534static const hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
535static const hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
536#define alc889_adc_nids alc880_adc_nids
537 40
538static const hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
539static const hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; 41static const hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
540#define alc883_capsrc_nids alc882_capsrc_nids_alt 42#define alc883_capsrc_nids alc882_capsrc_nids_alt
541static const hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
542#define alc889_capsrc_nids alc882_capsrc_nids
543 43
544/* input MUX */ 44/* input MUX */
545/* FIXME: should be a matrix-type input source selection */ 45/* FIXME: should be a matrix-type input source selection */
@@ -556,15 +56,6 @@ static const struct hda_input_mux alc882_capture_source = {
556 56
557#define alc883_capture_source alc882_capture_source 57#define alc883_capture_source alc882_capture_source
558 58
559static const struct hda_input_mux alc889_capture_source = {
560 .num_items = 3,
561 .items = {
562 { "Front Mic", 0x0 },
563 { "Mic", 0x3 },
564 { "Line", 0x2 },
565 },
566};
567
568static const struct hda_input_mux mb5_capture_source = { 59static const struct hda_input_mux mb5_capture_source = {
569 .num_items = 3, 60 .num_items = 3,
570 .items = { 61 .items = {
@@ -592,49 +83,6 @@ static const struct hda_input_mux alc883_3stack_6ch_intel = {
592 }, 83 },
593}; 84};
594 85
595static const struct hda_input_mux alc883_lenovo_101e_capture_source = {
596 .num_items = 2,
597 .items = {
598 { "Mic", 0x1 },
599 { "Line", 0x2 },
600 },
601};
602
603static const struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
604 .num_items = 4,
605 .items = {
606 { "Mic", 0x0 },
607 { "Internal Mic", 0x1 },
608 { "Line", 0x2 },
609 { "CD", 0x4 },
610 },
611};
612
613static const struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
614 .num_items = 2,
615 .items = {
616 { "Mic", 0x0 },
617 { "Internal Mic", 0x1 },
618 },
619};
620
621static const struct hda_input_mux alc883_lenovo_sky_capture_source = {
622 .num_items = 3,
623 .items = {
624 { "Mic", 0x0 },
625 { "Front Mic", 0x1 },
626 { "Line", 0x4 },
627 },
628};
629
630static const struct hda_input_mux alc883_asus_eee1601_capture_source = {
631 .num_items = 2,
632 .items = {
633 { "Mic", 0x0 },
634 { "Line", 0x2 },
635 },
636};
637
638static const struct hda_input_mux alc889A_mb31_capture_source = { 86static const struct hda_input_mux alc889A_mb31_capture_source = {
639 .num_items = 2, 87 .num_items = 2,
640 .items = { 88 .items = {
@@ -654,131 +102,6 @@ static const struct hda_input_mux alc889A_imac91_capture_source = {
654 }, 102 },
655}; 103};
656 104
657/*
658 * 2ch mode
659 */
660static const struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
661 { 2, NULL }
662};
663
664/*
665 * 2ch mode
666 */
667static const struct hda_verb alc882_3ST_ch2_init[] = {
668 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
669 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
670 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
671 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
672 { } /* end */
673};
674
675/*
676 * 4ch mode
677 */
678static const struct hda_verb alc882_3ST_ch4_init[] = {
679 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
680 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
681 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
682 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
683 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
684 { } /* end */
685};
686
687/*
688 * 6ch mode
689 */
690static const struct hda_verb alc882_3ST_ch6_init[] = {
691 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
692 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
693 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
694 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
695 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
696 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
697 { } /* end */
698};
699
700static const struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
701 { 2, alc882_3ST_ch2_init },
702 { 4, alc882_3ST_ch4_init },
703 { 6, alc882_3ST_ch6_init },
704};
705
706#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
707
708/*
709 * 2ch mode
710 */
711static const struct hda_verb alc883_3ST_ch2_clevo_init[] = {
712 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
713 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
714 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
715 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
716 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
717 { } /* end */
718};
719
720/*
721 * 4ch mode
722 */
723static const struct hda_verb alc883_3ST_ch4_clevo_init[] = {
724 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
725 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
726 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
727 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
728 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
729 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
730 { } /* end */
731};
732
733/*
734 * 6ch mode
735 */
736static const struct hda_verb alc883_3ST_ch6_clevo_init[] = {
737 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
740 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
742 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
743 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
744 { } /* end */
745};
746
747static const struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
748 { 2, alc883_3ST_ch2_clevo_init },
749 { 4, alc883_3ST_ch4_clevo_init },
750 { 6, alc883_3ST_ch6_clevo_init },
751};
752
753
754/*
755 * 6ch mode
756 */
757static const struct hda_verb alc882_sixstack_ch6_init[] = {
758 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
759 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
760 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
761 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
762 { } /* end */
763};
764
765/*
766 * 8ch mode
767 */
768static const struct hda_verb alc882_sixstack_ch8_init[] = {
769 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
770 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
771 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
772 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
773 { } /* end */
774};
775
776static const struct hda_channel_mode alc882_sixstack_modes[2] = {
777 { 6, alc882_sixstack_ch6_init },
778 { 8, alc882_sixstack_ch8_init },
779};
780
781
782/* Macbook Air 2,1 */ 105/* Macbook Air 2,1 */
783 106
784static const struct hda_channel_mode alc885_mba21_ch_modes[1] = { 107static const struct hda_channel_mode alc885_mba21_ch_modes[1] = {
@@ -847,216 +170,6 @@ static const struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
847 170
848#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes 171#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
849 172
850/*
851 * 2ch mode
852 */
853static const struct hda_verb alc883_4ST_ch2_init[] = {
854 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
855 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
856 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
857 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
859 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
860 { } /* end */
861};
862
863/*
864 * 4ch mode
865 */
866static const struct hda_verb alc883_4ST_ch4_init[] = {
867 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
868 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
871 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
872 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
873 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
874 { } /* end */
875};
876
877/*
878 * 6ch mode
879 */
880static const struct hda_verb alc883_4ST_ch6_init[] = {
881 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
882 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
883 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
884 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
885 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
886 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
887 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
888 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
889 { } /* end */
890};
891
892/*
893 * 8ch mode
894 */
895static const struct hda_verb alc883_4ST_ch8_init[] = {
896 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
897 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
898 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
899 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
900 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
901 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
902 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
903 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
904 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
905 { } /* end */
906};
907
908static const struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
909 { 2, alc883_4ST_ch2_init },
910 { 4, alc883_4ST_ch4_init },
911 { 6, alc883_4ST_ch6_init },
912 { 8, alc883_4ST_ch8_init },
913};
914
915
916/*
917 * 2ch mode
918 */
919static const struct hda_verb alc883_3ST_ch2_intel_init[] = {
920 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
921 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
922 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
923 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
924 { } /* end */
925};
926
927/*
928 * 4ch mode
929 */
930static const struct hda_verb alc883_3ST_ch4_intel_init[] = {
931 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
932 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
933 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
934 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
935 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
936 { } /* end */
937};
938
939/*
940 * 6ch mode
941 */
942static const struct hda_verb alc883_3ST_ch6_intel_init[] = {
943 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
944 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
945 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
946 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
947 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
948 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
949 { } /* end */
950};
951
952static const struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
953 { 2, alc883_3ST_ch2_intel_init },
954 { 4, alc883_3ST_ch4_intel_init },
955 { 6, alc883_3ST_ch6_intel_init },
956};
957
958/*
959 * 2ch mode
960 */
961static const struct hda_verb alc889_ch2_intel_init[] = {
962 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
963 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
964 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
965 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
966 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
967 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
968 { } /* end */
969};
970
971/*
972 * 6ch mode
973 */
974static const struct hda_verb alc889_ch6_intel_init[] = {
975 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
976 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
977 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
978 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
979 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
980 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
981 { } /* end */
982};
983
984/*
985 * 8ch mode
986 */
987static const struct hda_verb alc889_ch8_intel_init[] = {
988 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
989 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
990 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
991 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
992 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
993 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
994 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
995 { } /* end */
996};
997
998static const struct hda_channel_mode alc889_8ch_intel_modes[3] = {
999 { 2, alc889_ch2_intel_init },
1000 { 6, alc889_ch6_intel_init },
1001 { 8, alc889_ch8_intel_init },
1002};
1003
1004/*
1005 * 6ch mode
1006 */
1007static const struct hda_verb alc883_sixstack_ch6_init[] = {
1008 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
1009 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1010 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1011 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1012 { } /* end */
1013};
1014
1015/*
1016 * 8ch mode
1017 */
1018static const struct hda_verb alc883_sixstack_ch8_init[] = {
1019 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1020 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1021 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1022 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1023 { } /* end */
1024};
1025
1026static const struct hda_channel_mode alc883_sixstack_modes[2] = {
1027 { 6, alc883_sixstack_ch6_init },
1028 { 8, alc883_sixstack_ch8_init },
1029};
1030
1031
1032/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
1033 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
1034 */
1035static const struct snd_kcontrol_new alc882_base_mixer[] = {
1036 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1037 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1039 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1040 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1041 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1042 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1043 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1044 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1045 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1052 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1054 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1055 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
1056 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1057 { } /* end */
1058};
1059
1060/* Macbook Air 2,1 same control for HP and internal Speaker */ 173/* Macbook Air 2,1 same control for HP and internal Speaker */
1061 174
1062static const struct snd_kcontrol_new alc885_mba21_mixer[] = { 175static const struct snd_kcontrol_new alc885_mba21_mixer[] = {
@@ -1121,70 +234,6 @@ static const struct snd_kcontrol_new alc885_imac91_mixer[] = {
1121}; 234};
1122 235
1123 236
1124static const struct snd_kcontrol_new alc882_w2jc_mixer[] = {
1125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1126 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1132 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1134 { } /* end */
1135};
1136
1137static const struct snd_kcontrol_new alc882_targa_mixer[] = {
1138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1142 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1147 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1148 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1149 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1150 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
1151 { } /* end */
1152};
1153
1154/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
1155 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
1156 */
1157static const struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
1158 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1159 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1161 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
1162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1164 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1165 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1166 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
1167 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
1168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1170 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1171 { } /* end */
1172};
1173
1174static const struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
1175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1176 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1178 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1179 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1180 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1181 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1183 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1185 { } /* end */
1186};
1187
1188static const struct snd_kcontrol_new alc882_chmode_mixer[] = { 237static const struct snd_kcontrol_new alc882_chmode_mixer[] = {
1189 { 238 {
1190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1258,179 +307,8 @@ static const struct hda_verb alc882_base_init_verbs[] = {
1258 { } 307 { }
1259}; 308};
1260 309
1261static const struct hda_verb alc882_adc1_init_verbs[] = {
1262 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
1263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1267 /* ADC1: mute amp left and right */
1268 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1269 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1270 { }
1271};
1272
1273static const struct hda_verb alc882_eapd_verbs[] = {
1274 /* change to EAPD mode */
1275 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1276 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1277 { }
1278};
1279
1280static const struct hda_verb alc889_eapd_verbs[] = {
1281 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1282 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1283 { }
1284};
1285
1286static const struct hda_verb alc_hp15_unsol_verbs[] = {
1287 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
1288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1289 {}
1290};
1291
1292static const struct hda_verb alc885_init_verbs[] = {
1293 /* Front mixer: unmute input/output amp left and right (volume = 0) */
1294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1296 /* Rear mixer */
1297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1299 /* CLFE mixer */
1300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1302 /* Side mixer */
1303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1304 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1305
1306 /* Front HP Pin: output 0 (0x0c) */
1307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1310 /* Front Pin: output 0 (0x0c) */
1311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1313 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1314 /* Rear Pin: output 1 (0x0d) */
1315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1317 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
1318 /* CLFE Pin: output 2 (0x0e) */
1319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1320 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1321 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1322 /* Side Pin: output 3 (0x0f) */
1323 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1324 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1325 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1326 /* Mic (rear) pin: input vref at 80% */
1327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1328 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1329 /* Front Mic pin: input vref at 80% */
1330 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1332 /* Line In pin: input */
1333 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1334 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1335
1336 /* Mixer elements: 0x18, , 0x1a, 0x1b */
1337 /* Input mixer1 */
1338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1339 /* Input mixer2 */
1340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1341 /* Input mixer3 */
1342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1343 /* ADC2: mute amp left and right */
1344 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1345 /* ADC3: mute amp left and right */
1346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1347
1348 { }
1349};
1350
1351static const struct hda_verb alc885_init_input_verbs[] = {
1352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1355 { }
1356};
1357
1358
1359/* Unmute Selector 24h and set the default input to front mic */
1360static const struct hda_verb alc889_init_input_verbs[] = {
1361 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
1362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1363 { }
1364};
1365
1366
1367#define alc883_init_verbs alc882_base_init_verbs 310#define alc883_init_verbs alc882_base_init_verbs
1368 311
1369/* Mac Pro test */
1370static const struct snd_kcontrol_new alc882_macpro_mixer[] = {
1371 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1372 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
1374 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
1375 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
1376 /* FIXME: this looks suspicious...
1377 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
1378 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
1379 */
1380 { } /* end */
1381};
1382
1383static const struct hda_verb alc882_macpro_init_verbs[] = {
1384 /* Front mixer: unmute input/output amp left and right (volume = 0) */
1385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1388 /* Front Pin: output 0 (0x0c) */
1389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1392 /* Front Mic pin: input vref at 80% */
1393 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1395 /* Speaker: output */
1396 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
1399 /* Headphone output (output 0 - 0x0c) */
1400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1402 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
1403
1404 /* FIXME: use matrix-type input source selection */
1405 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
1406 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
1407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1411 /* Input mixer2 */
1412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1416 /* Input mixer3 */
1417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1421 /* ADC1: mute amp left and right */
1422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1423 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1424 /* ADC2: mute amp left and right */
1425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1426 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1427 /* ADC3: mute amp left and right */
1428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1429 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1430
1431 { }
1432};
1433
1434/* Macbook 5,1 */ 312/* Macbook 5,1 */
1435static const struct hda_verb alc885_mb5_init_verbs[] = { 313static const struct hda_verb alc885_mb5_init_verbs[] = {
1436 /* DACs */ 314 /* DACs */
@@ -1669,34 +547,6 @@ static const struct hda_verb alc885_imac91_init_verbs[] = {
1669 { } 547 { }
1670}; 548};
1671 549
1672/* iMac 24 mixer. */
1673static const struct snd_kcontrol_new alc885_imac24_mixer[] = {
1674 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
1675 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
1676 { } /* end */
1677};
1678
1679/* iMac 24 init verbs. */
1680static const struct hda_verb alc885_imac24_init_verbs[] = {
1681 /* Internal speakers: output 0 (0x0c) */
1682 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1683 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
1685 /* Internal speakers: output 0 (0x0c) */
1686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1688 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1689 /* Headphone: output 0 (0x0c) */
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1693 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
1694 /* Front Mic: input vref at 80% */
1695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1697 { }
1698};
1699
1700/* Toggle speaker-output according to the hp-jack state */ 550/* Toggle speaker-output according to the hp-jack state */
1701static void alc885_imac24_setup(struct hda_codec *codec) 551static void alc885_imac24_setup(struct hda_codec *codec)
1702{ 552{
@@ -1742,127 +592,6 @@ static void alc885_imac91_setup(struct hda_codec *codec)
1742 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP); 592 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1743} 593}
1744 594
1745static const struct hda_verb alc882_targa_verbs[] = {
1746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1748
1749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1751
1752 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1753 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
1754 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1755
1756 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
1757 { } /* end */
1758};
1759
1760/* toggle speaker-output according to the hp-jack state */
1761static void alc882_targa_automute(struct hda_codec *codec)
1762{
1763 struct alc_spec *spec = codec->spec;
1764 alc_hp_automute(codec);
1765 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
1766 spec->hp_jack_present ? 1 : 3);
1767}
1768
1769static void alc882_targa_setup(struct hda_codec *codec)
1770{
1771 struct alc_spec *spec = codec->spec;
1772
1773 spec->autocfg.hp_pins[0] = 0x14;
1774 spec->autocfg.speaker_pins[0] = 0x1b;
1775 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1776}
1777
1778static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
1779{
1780 if ((res >> 26) == ALC_HP_EVENT)
1781 alc882_targa_automute(codec);
1782}
1783
1784static const struct hda_verb alc882_asus_a7j_verbs[] = {
1785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1787
1788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1790 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1791
1792 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
1793 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1794 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
1795
1796 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1797 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
1798 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1799 { } /* end */
1800};
1801
1802static const struct hda_verb alc882_asus_a7m_verbs[] = {
1803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1805
1806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1809
1810 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
1811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1812 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
1813
1814 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1815 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
1816 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1817 { } /* end */
1818};
1819
1820static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1821{
1822 unsigned int gpiostate, gpiomask, gpiodir;
1823
1824 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1825 AC_VERB_GET_GPIO_DATA, 0);
1826
1827 if (!muted)
1828 gpiostate |= (1 << pin);
1829 else
1830 gpiostate &= ~(1 << pin);
1831
1832 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1833 AC_VERB_GET_GPIO_MASK, 0);
1834 gpiomask |= (1 << pin);
1835
1836 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1837 AC_VERB_GET_GPIO_DIRECTION, 0);
1838 gpiodir |= (1 << pin);
1839
1840
1841 snd_hda_codec_write(codec, codec->afg, 0,
1842 AC_VERB_SET_GPIO_MASK, gpiomask);
1843 snd_hda_codec_write(codec, codec->afg, 0,
1844 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1845
1846 msleep(1);
1847
1848 snd_hda_codec_write(codec, codec->afg, 0,
1849 AC_VERB_SET_GPIO_DATA, gpiostate);
1850}
1851
1852/* set up GPIO at initialization */
1853static void alc885_macpro_init_hook(struct hda_codec *codec)
1854{
1855 alc882_gpio_mute(codec, 0, 0);
1856 alc882_gpio_mute(codec, 1, 0);
1857}
1858
1859/* set up GPIO and update auto-muting at initialization */
1860static void alc885_imac24_init_hook(struct hda_codec *codec)
1861{
1862 alc885_macpro_init_hook(codec);
1863 alc_hp_automute(codec);
1864}
1865
1866/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ 595/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
1867static const struct hda_verb alc889A_mb31_ch2_init[] = { 596static const struct hda_verb alc889A_mb31_ch2_init[] = {
1868 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ 597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
@@ -1906,77 +635,6 @@ static const struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
1906 { 6, alc889A_mb31_ch6_init }, 635 { 6, alc889A_mb31_ch6_init },
1907}; 636};
1908 637
1909static const struct hda_verb alc883_medion_eapd_verbs[] = {
1910 /* eanable EAPD on medion laptop */
1911 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1912 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1913 { }
1914};
1915
1916#define alc883_base_mixer alc882_base_mixer
1917
1918static const struct snd_kcontrol_new alc883_mitac_mixer[] = {
1919 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1920 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1921 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1922 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1923 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1924 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1927 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
1931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1932 { } /* end */
1933};
1934
1935static const struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
1936 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1937 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1938 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1939 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1940 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1941 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
1945 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1946 { } /* end */
1947};
1948
1949static const struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
1950 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1951 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1952 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1953 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1955 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1957 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1958 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
1959 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1960 { } /* end */
1961};
1962
1963static const struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
1964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1972 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
1973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1975 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
1976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1977 { } /* end */
1978};
1979
1980static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { 638static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
1981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 639 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1982 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 640 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -2000,235 +658,6 @@ static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
2000 { } /* end */ 658 { } /* end */
2001}; 659};
2002 660
2003static const struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
2004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2006 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2007 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2008 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2009 HDA_OUTPUT),
2010 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2011 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2012 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2014 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2015 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2019 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
2020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2021 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2022 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
2023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2024 { } /* end */
2025};
2026
2027static const struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
2028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2030 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2031 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2032 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2033 HDA_OUTPUT),
2034 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2035 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2036 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2037 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2038 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
2039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2040 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2041 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2043 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
2044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2045 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2046 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
2047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2048 { } /* end */
2049};
2050
2051static const struct snd_kcontrol_new alc883_fivestack_mixer[] = {
2052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2054 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2055 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2056 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2057 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2061 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2062 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2063 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2064 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2066 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2068 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2069 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
2070 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2071 { } /* end */
2072};
2073
2074static const struct snd_kcontrol_new alc883_targa_mixer[] = {
2075 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2076 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2077 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2078 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2079 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2080 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2081 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2082 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2083 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2084 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2085 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2086 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2089 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2090 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2092 { } /* end */
2093};
2094
2095static const struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
2096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2099 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2103 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2105 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
2107 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2108 { } /* end */
2109};
2110
2111static const struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
2112 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2113 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2114 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2115 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
2116 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2117 { } /* end */
2118};
2119
2120static const struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
2121 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2122 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2123 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2124 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2125 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2129 { } /* end */
2130};
2131
2132static const struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
2133 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2134 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
2135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2138 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2139 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2140 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2141 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2142 { } /* end */
2143};
2144
2145static const struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
2146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2147 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2148 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
2150 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
2151 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
2152 { } /* end */
2153};
2154
2155static const struct hda_verb alc883_medion_wim2160_verbs[] = {
2156 /* Unmute front mixer */
2157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2159
2160 /* Set speaker pin to front mixer */
2161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2162
2163 /* Init headphone pin */
2164 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2165 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2166 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
2167 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2168
2169 { } /* end */
2170};
2171
2172/* toggle speaker-output according to the hp-jack state */
2173static void alc883_medion_wim2160_setup(struct hda_codec *codec)
2174{
2175 struct alc_spec *spec = codec->spec;
2176
2177 spec->autocfg.hp_pins[0] = 0x1a;
2178 spec->autocfg.speaker_pins[0] = 0x15;
2179 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2180}
2181
2182static const struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
2183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2184 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2186 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2187 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2189 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2191 { } /* end */
2192};
2193
2194static const struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
2195 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2196 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2199 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2200 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2202 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2204 { } /* end */
2205};
2206
2207static const struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
2208 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2210 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2211 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
2212 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
2213 0x0d, 1, 0x0, HDA_OUTPUT),
2214 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2215 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2216 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2217 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2218 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2227 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
2228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2229 { } /* end */
2230};
2231
2232static const struct snd_kcontrol_new alc889A_mb31_mixer[] = { 661static const struct snd_kcontrol_new alc889A_mb31_mixer[] = {
2233 /* Output mixers */ 662 /* Output mixers */
2234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 663 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
@@ -2255,61 +684,6 @@ static const struct snd_kcontrol_new alc889A_mb31_mixer[] = {
2255 { } /* end */ 684 { } /* end */
2256}; 685};
2257 686
2258static const struct snd_kcontrol_new alc883_vaiott_mixer[] = {
2259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2263 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
2264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2265 { } /* end */
2266};
2267
2268static const struct hda_bind_ctls alc883_bind_cap_vol = {
2269 .ops = &snd_hda_bind_vol,
2270 .values = {
2271 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
2272 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
2273 0
2274 },
2275};
2276
2277static const struct hda_bind_ctls alc883_bind_cap_switch = {
2278 .ops = &snd_hda_bind_sw,
2279 .values = {
2280 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
2281 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
2282 0
2283 },
2284};
2285
2286static const struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
2287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2288 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2290 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2291 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2293 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2295 { } /* end */
2296};
2297
2298static const struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
2299 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
2300 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
2301 {
2302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2303 /* .name = "Capture Source", */
2304 .name = "Input Source",
2305 .count = 1,
2306 .info = alc_mux_enum_info,
2307 .get = alc_mux_enum_get,
2308 .put = alc_mux_enum_put,
2309 },
2310 { } /* end */
2311};
2312
2313static const struct snd_kcontrol_new alc883_chmode_mixer[] = { 687static const struct snd_kcontrol_new alc883_chmode_mixer[] = {
2314 { 688 {
2315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -2321,423 +695,6 @@ static const struct snd_kcontrol_new alc883_chmode_mixer[] = {
2321 { } /* end */ 695 { } /* end */
2322}; 696};
2323 697
2324/* toggle speaker-output according to the hp-jack state */
2325static void alc883_mitac_setup(struct hda_codec *codec)
2326{
2327 struct alc_spec *spec = codec->spec;
2328
2329 spec->autocfg.hp_pins[0] = 0x15;
2330 spec->autocfg.speaker_pins[0] = 0x14;
2331 spec->autocfg.speaker_pins[1] = 0x17;
2332 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2333}
2334
2335static const struct hda_verb alc883_mitac_verbs[] = {
2336 /* HP */
2337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2339 /* Subwoofer */
2340 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2341 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2342
2343 /* enable unsolicited event */
2344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2345 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN}, */
2346
2347 { } /* end */
2348};
2349
2350static const struct hda_verb alc883_clevo_m540r_verbs[] = {
2351 /* HP */
2352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2354 /* Int speaker */
2355 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
2356
2357 /* enable unsolicited event */
2358 /*
2359 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2360 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
2361 */
2362
2363 { } /* end */
2364};
2365
2366static const struct hda_verb alc883_clevo_m720_verbs[] = {
2367 /* HP */
2368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2370 /* Int speaker */
2371 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
2372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2373
2374 /* enable unsolicited event */
2375 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2376 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
2377
2378 { } /* end */
2379};
2380
2381static const struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
2382 /* HP */
2383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2385 /* Subwoofer */
2386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
2387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2388
2389 /* enable unsolicited event */
2390 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2391
2392 { } /* end */
2393};
2394
2395static const struct hda_verb alc883_targa_verbs[] = {
2396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2398
2399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2401
2402/* Connect Line-Out side jack (SPDIF) to Side */
2403 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2404 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2405 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2406/* Connect Mic jack to CLFE */
2407 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2408 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
2410/* Connect Line-in jack to Surround */
2411 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2412 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2413 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
2414/* Connect HP out jack to Front */
2415 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2416 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2417 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2418
2419 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2420
2421 { } /* end */
2422};
2423
2424static const struct hda_verb alc883_lenovo_101e_verbs[] = {
2425 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2426 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_FRONT_EVENT|AC_USRSP_EN},
2427 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT|AC_USRSP_EN},
2428 { } /* end */
2429};
2430
2431static const struct hda_verb alc883_lenovo_nb0763_verbs[] = {
2432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2434 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2436 { } /* end */
2437};
2438
2439static const struct hda_verb alc888_lenovo_ms7195_verbs[] = {
2440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2442 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2443 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_FRONT_EVENT | AC_USRSP_EN},
2444 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2445 { } /* end */
2446};
2447
2448static const struct hda_verb alc883_haier_w66_verbs[] = {
2449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2451
2452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2453
2454 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2456 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2457 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2458 { } /* end */
2459};
2460
2461static const struct hda_verb alc888_lenovo_sky_verbs[] = {
2462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
2469 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2470 { } /* end */
2471};
2472
2473static const struct hda_verb alc888_6st_dell_verbs[] = {
2474 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2475 { }
2476};
2477
2478static const struct hda_verb alc883_vaiott_verbs[] = {
2479 /* HP */
2480 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2481 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2482
2483 /* enable unsolicited event */
2484 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2485
2486 { } /* end */
2487};
2488
2489static void alc888_3st_hp_setup(struct hda_codec *codec)
2490{
2491 struct alc_spec *spec = codec->spec;
2492
2493 spec->autocfg.hp_pins[0] = 0x1b;
2494 spec->autocfg.speaker_pins[0] = 0x14;
2495 spec->autocfg.speaker_pins[1] = 0x16;
2496 spec->autocfg.speaker_pins[2] = 0x18;
2497 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2498}
2499
2500static const struct hda_verb alc888_3st_hp_verbs[] = {
2501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
2502 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
2503 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
2504 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2505 { } /* end */
2506};
2507
2508/*
2509 * 2ch mode
2510 */
2511static const struct hda_verb alc888_3st_hp_2ch_init[] = {
2512 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2513 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2514 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2515 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2516 { } /* end */
2517};
2518
2519/*
2520 * 4ch mode
2521 */
2522static const struct hda_verb alc888_3st_hp_4ch_init[] = {
2523 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2524 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2525 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2526 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2527 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
2528 { } /* end */
2529};
2530
2531/*
2532 * 6ch mode
2533 */
2534static const struct hda_verb alc888_3st_hp_6ch_init[] = {
2535 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2536 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2537 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
2538 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2539 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2540 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
2541 { } /* end */
2542};
2543
2544static const struct hda_channel_mode alc888_3st_hp_modes[3] = {
2545 { 2, alc888_3st_hp_2ch_init },
2546 { 4, alc888_3st_hp_4ch_init },
2547 { 6, alc888_3st_hp_6ch_init },
2548};
2549
2550static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
2551{
2552 struct alc_spec *spec = codec->spec;
2553
2554 spec->autocfg.hp_pins[0] = 0x1b;
2555 spec->autocfg.line_out_pins[0] = 0x14;
2556 spec->autocfg.speaker_pins[0] = 0x15;
2557 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2558}
2559
2560/* toggle speaker-output according to the hp-jack state */
2561static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
2562{
2563 struct alc_spec *spec = codec->spec;
2564
2565 spec->autocfg.hp_pins[0] = 0x14;
2566 spec->autocfg.speaker_pins[0] = 0x15;
2567 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2568}
2569
2570/* toggle speaker-output according to the hp-jack state */
2571#define alc883_targa_init_hook alc882_targa_init_hook
2572#define alc883_targa_unsol_event alc882_targa_unsol_event
2573
2574static void alc883_clevo_m720_setup(struct hda_codec *codec)
2575{
2576 struct alc_spec *spec = codec->spec;
2577
2578 spec->autocfg.hp_pins[0] = 0x15;
2579 spec->autocfg.speaker_pins[0] = 0x14;
2580 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2581}
2582
2583static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
2584{
2585 alc_hp_automute(codec);
2586 alc88x_simple_mic_automute(codec);
2587}
2588
2589static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
2590 unsigned int res)
2591{
2592 switch (res >> 26) {
2593 case ALC_MIC_EVENT:
2594 alc88x_simple_mic_automute(codec);
2595 break;
2596 default:
2597 alc_sku_unsol_event(codec, res);
2598 break;
2599 }
2600}
2601
2602/* toggle speaker-output according to the hp-jack state */
2603static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
2604{
2605 struct alc_spec *spec = codec->spec;
2606
2607 spec->autocfg.hp_pins[0] = 0x14;
2608 spec->autocfg.speaker_pins[0] = 0x15;
2609 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2610}
2611
2612static void alc883_haier_w66_setup(struct hda_codec *codec)
2613{
2614 struct alc_spec *spec = codec->spec;
2615
2616 spec->autocfg.hp_pins[0] = 0x1b;
2617 spec->autocfg.speaker_pins[0] = 0x14;
2618 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2619}
2620
2621static void alc883_lenovo_101e_setup(struct hda_codec *codec)
2622{
2623 struct alc_spec *spec = codec->spec;
2624
2625 spec->autocfg.hp_pins[0] = 0x1b;
2626 spec->autocfg.line_out_pins[0] = 0x14;
2627 spec->autocfg.speaker_pins[0] = 0x15;
2628 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2629}
2630
2631/* toggle speaker-output according to the hp-jack state */
2632static void alc883_acer_aspire_setup(struct hda_codec *codec)
2633{
2634 struct alc_spec *spec = codec->spec;
2635
2636 spec->autocfg.hp_pins[0] = 0x14;
2637 spec->autocfg.speaker_pins[0] = 0x15;
2638 spec->autocfg.speaker_pins[1] = 0x16;
2639 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2640}
2641
2642static const struct hda_verb alc883_acer_eapd_verbs[] = {
2643 /* HP Pin: output 0 (0x0c) */
2644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2647 /* Front Pin: output 0 (0x0c) */
2648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2649 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2651 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
2652 /* eanable EAPD on medion laptop */
2653 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2654 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
2655 /* enable unsolicited event */
2656 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2657 { }
2658};
2659
2660static void alc888_6st_dell_setup(struct hda_codec *codec)
2661{
2662 struct alc_spec *spec = codec->spec;
2663
2664 spec->autocfg.hp_pins[0] = 0x1b;
2665 spec->autocfg.speaker_pins[0] = 0x14;
2666 spec->autocfg.speaker_pins[1] = 0x15;
2667 spec->autocfg.speaker_pins[2] = 0x16;
2668 spec->autocfg.speaker_pins[3] = 0x17;
2669 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2670}
2671
2672static void alc888_lenovo_sky_setup(struct hda_codec *codec)
2673{
2674 struct alc_spec *spec = codec->spec;
2675
2676 spec->autocfg.hp_pins[0] = 0x1b;
2677 spec->autocfg.speaker_pins[0] = 0x14;
2678 spec->autocfg.speaker_pins[1] = 0x15;
2679 spec->autocfg.speaker_pins[2] = 0x16;
2680 spec->autocfg.speaker_pins[3] = 0x17;
2681 spec->autocfg.speaker_pins[4] = 0x1a;
2682 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2683}
2684
2685static void alc883_vaiott_setup(struct hda_codec *codec)
2686{
2687 struct alc_spec *spec = codec->spec;
2688
2689 spec->autocfg.hp_pins[0] = 0x15;
2690 spec->autocfg.speaker_pins[0] = 0x14;
2691 spec->autocfg.speaker_pins[1] = 0x17;
2692 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2693}
2694
2695static const struct hda_verb alc888_asus_m90v_verbs[] = {
2696 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2699 /* enable unsolicited event */
2700 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2701 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_MIC_EVENT | AC_USRSP_EN},
2702 { } /* end */
2703};
2704
2705static void alc883_mode2_setup(struct hda_codec *codec)
2706{
2707 struct alc_spec *spec = codec->spec;
2708
2709 spec->autocfg.hp_pins[0] = 0x1b;
2710 spec->autocfg.speaker_pins[0] = 0x14;
2711 spec->autocfg.speaker_pins[1] = 0x15;
2712 spec->autocfg.speaker_pins[2] = 0x16;
2713 spec->ext_mic_pin = 0x18;
2714 spec->int_mic_pin = 0x19;
2715 spec->auto_mic = 1;
2716 alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
2717}
2718
2719static const struct hda_verb alc888_asus_eee1601_verbs[] = {
2720 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2721 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2722 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2725 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2726 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
2727 /* enable unsolicited event */
2728 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC_HP_EVENT | AC_USRSP_EN},
2729 { } /* end */
2730};
2731
2732static void alc883_eee1601_inithook(struct hda_codec *codec)
2733{
2734 struct alc_spec *spec = codec->spec;
2735
2736 spec->autocfg.hp_pins[0] = 0x14;
2737 spec->autocfg.speaker_pins[0] = 0x1b;
2738 alc_hp_automute(codec);
2739}
2740
2741static const struct hda_verb alc889A_mb31_verbs[] = { 698static const struct hda_verb alc889A_mb31_verbs[] = {
2742 /* Init rear pin (used as headphone output) */ 699 /* Init rear pin (used as headphone output) */
2743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */ 700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
@@ -2773,211 +730,30 @@ static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
2773 alc889A_mb31_automute(codec); 730 alc889A_mb31_automute(codec);
2774} 731}
2775 732
2776static const hda_nid_t alc883_slave_dig_outs[] = {
2777 ALC1200_DIGOUT_NID, 0,
2778};
2779
2780static const hda_nid_t alc1200_slave_dig_outs[] = {
2781 ALC883_DIGOUT_NID, 0,
2782};
2783
2784/* 733/*
2785 * configuration and preset 734 * configuration and preset
2786 */ 735 */
2787static const char * const alc882_models[ALC882_MODEL_LAST] = { 736static const char * const alc882_models[ALC882_MODEL_LAST] = {
2788 [ALC882_3ST_DIG] = "3stack-dig",
2789 [ALC882_6ST_DIG] = "6stack-dig",
2790 [ALC882_ARIMA] = "arima",
2791 [ALC882_W2JC] = "w2jc",
2792 [ALC882_TARGA] = "targa",
2793 [ALC882_ASUS_A7J] = "asus-a7j",
2794 [ALC882_ASUS_A7M] = "asus-a7m",
2795 [ALC885_MACPRO] = "macpro",
2796 [ALC885_MB5] = "mb5", 737 [ALC885_MB5] = "mb5",
2797 [ALC885_MACMINI3] = "macmini3", 738 [ALC885_MACMINI3] = "macmini3",
2798 [ALC885_MBA21] = "mba21", 739 [ALC885_MBA21] = "mba21",
2799 [ALC885_MBP3] = "mbp3", 740 [ALC885_MBP3] = "mbp3",
2800 [ALC885_IMAC24] = "imac24",
2801 [ALC885_IMAC91] = "imac91", 741 [ALC885_IMAC91] = "imac91",
2802 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
2803 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
2804 [ALC883_3ST_6ch] = "3stack-6ch",
2805 [ALC883_6ST_DIG] = "alc883-6stack-dig",
2806 [ALC883_TARGA_DIG] = "targa-dig",
2807 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
2808 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
2809 [ALC883_ACER] = "acer",
2810 [ALC883_ACER_ASPIRE] = "acer-aspire",
2811 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
2812 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
2813 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
2814 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
2815 [ALC883_MEDION] = "medion",
2816 [ALC883_MEDION_WIM2160] = "medion-wim2160",
2817 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
2818 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
2819 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
2820 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
2821 [ALC888_LENOVO_SKY] = "lenovo-sky",
2822 [ALC883_HAIER_W66] = "haier-w66",
2823 [ALC888_3ST_HP] = "3stack-hp",
2824 [ALC888_6ST_DELL] = "6stack-dell",
2825 [ALC883_MITAC] = "mitac",
2826 [ALC883_CLEVO_M540R] = "clevo-m540r",
2827 [ALC883_CLEVO_M720] = "clevo-m720",
2828 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
2829 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
2830 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
2831 [ALC889A_INTEL] = "intel-alc889a",
2832 [ALC889_INTEL] = "intel-x58",
2833 [ALC1200_ASUS_P5Q] = "asus-p5q",
2834 [ALC889A_MB31] = "mb31", 742 [ALC889A_MB31] = "mb31",
2835 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
2836 [ALC882_AUTO] = "auto", 743 [ALC882_AUTO] = "auto",
2837}; 744};
2838 745
2839static const struct snd_pci_quirk alc882_cfg_tbl[] = {
2840 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
2841
2842 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
2843 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
2844 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
2845 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
2846 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
2847 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
2848 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2849 ALC888_ACER_ASPIRE_4930G),
2850 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2851 ALC888_ACER_ASPIRE_4930G),
2852 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2853 ALC888_ACER_ASPIRE_8930G),
2854 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2855 ALC888_ACER_ASPIRE_8930G),
2856 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
2857 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
2858 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2859 ALC888_ACER_ASPIRE_6530G),
2860 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2861 ALC888_ACER_ASPIRE_6530G),
2862 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2863 ALC888_ACER_ASPIRE_7730G),
2864 /* default Acer -- disabled as it causes more problems.
2865 * model=auto should work fine now
2866 */
2867 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
2868
2869 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
2870
2871 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavilion", ALC883_6ST_DIG),
2872 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
2873 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
2874 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
2875 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
2876 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
2877
2878 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
2879 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
2880 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
2881 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
2882 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
2883 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
2884 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
2888 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
2889
2890 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
2891 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
2892 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
2893 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
2894 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
2895 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
2896 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
2897 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
2898 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
2899
2900 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
2901 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
2902 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
2903 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
2904 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
2905 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
2906 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
2907 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
2908 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
2909 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
2910 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
2911 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
2912 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
2913 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
2914 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
2915 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
2916 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
2917 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
2918 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
2919 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
2920 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
2921 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
2922 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
2923 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
2924 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
2925 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
2926 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
2927 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
2928 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
2929 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
2930 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
2931
2932 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
2933 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
2934 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
2935 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
2936 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
2937 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
2938 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
2939 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
2940 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
2941 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
2942 ALC883_FUJITSU_PI2515),
2943 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
2944 ALC888_FUJITSU_XA3530),
2945 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
2946 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
2947 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
2948 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
2949 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
2950 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
2951 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
2952 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
2953
2954 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
2955 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
2956 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
2957 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
2958 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
2959 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
2960 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
2961
2962 {}
2963};
2964
2965/* codec SSID table for Intel Mac */ 746/* codec SSID table for Intel Mac */
2966static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { 747static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
2967 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3), 748 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
2968 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3), 749 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
2969 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3), 750 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
2970 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
2971 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
2972 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
2973 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), 751 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
2974 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31), 752 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
2975 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
2976 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3), 753 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
2977 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21), 754 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
2978 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), 755 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
2979 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), 756 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
2980 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
2981 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91), 757 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
2982 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), 758 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
2983 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5), 759 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
@@ -2991,53 +767,6 @@ static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
2991}; 767};
2992 768
2993static const struct alc_config_preset alc882_presets[] = { 769static const struct alc_config_preset alc882_presets[] = {
2994 [ALC882_3ST_DIG] = {
2995 .mixers = { alc882_base_mixer },
2996 .init_verbs = { alc882_base_init_verbs,
2997 alc882_adc1_init_verbs },
2998 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
2999 .dac_nids = alc882_dac_nids,
3000 .dig_out_nid = ALC882_DIGOUT_NID,
3001 .dig_in_nid = ALC882_DIGIN_NID,
3002 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3003 .channel_mode = alc882_ch_modes,
3004 .need_dac_fix = 1,
3005 .input_mux = &alc882_capture_source,
3006 },
3007 [ALC882_6ST_DIG] = {
3008 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3009 .init_verbs = { alc882_base_init_verbs,
3010 alc882_adc1_init_verbs },
3011 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3012 .dac_nids = alc882_dac_nids,
3013 .dig_out_nid = ALC882_DIGOUT_NID,
3014 .dig_in_nid = ALC882_DIGIN_NID,
3015 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3016 .channel_mode = alc882_sixstack_modes,
3017 .input_mux = &alc882_capture_source,
3018 },
3019 [ALC882_ARIMA] = {
3020 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3021 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
3022 alc882_eapd_verbs },
3023 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3024 .dac_nids = alc882_dac_nids,
3025 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3026 .channel_mode = alc882_sixstack_modes,
3027 .input_mux = &alc882_capture_source,
3028 },
3029 [ALC882_W2JC] = {
3030 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
3031 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
3032 alc882_eapd_verbs, alc880_gpio1_init_verbs },
3033 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3034 .dac_nids = alc882_dac_nids,
3035 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3036 .channel_mode = alc880_threestack_modes,
3037 .need_dac_fix = 1,
3038 .input_mux = &alc882_capture_source,
3039 .dig_out_nid = ALC882_DIGOUT_NID,
3040 },
3041 [ALC885_MBA21] = { 770 [ALC885_MBA21] = {
3042 .mixers = { alc885_mba21_mixer }, 771 .mixers = { alc885_mba21_mixer },
3043 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs }, 772 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
@@ -3096,32 +825,6 @@ static const struct alc_config_preset alc882_presets[] = {
3096 .setup = alc885_macmini3_setup, 825 .setup = alc885_macmini3_setup,
3097 .init_hook = alc_hp_automute, 826 .init_hook = alc_hp_automute,
3098 }, 827 },
3099 [ALC885_MACPRO] = {
3100 .mixers = { alc882_macpro_mixer },
3101 .init_verbs = { alc882_macpro_init_verbs },
3102 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3103 .dac_nids = alc882_dac_nids,
3104 .dig_out_nid = ALC882_DIGOUT_NID,
3105 .dig_in_nid = ALC882_DIGIN_NID,
3106 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3107 .channel_mode = alc882_ch_modes,
3108 .input_mux = &alc882_capture_source,
3109 .init_hook = alc885_macpro_init_hook,
3110 },
3111 [ALC885_IMAC24] = {
3112 .mixers = { alc885_imac24_mixer },
3113 .init_verbs = { alc885_imac24_init_verbs },
3114 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3115 .dac_nids = alc882_dac_nids,
3116 .dig_out_nid = ALC882_DIGOUT_NID,
3117 .dig_in_nid = ALC882_DIGIN_NID,
3118 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3119 .channel_mode = alc882_ch_modes,
3120 .input_mux = &alc882_capture_source,
3121 .unsol_event = alc_sku_unsol_event,
3122 .setup = alc885_imac24_setup,
3123 .init_hook = alc885_imac24_init_hook,
3124 },
3125 [ALC885_IMAC91] = { 828 [ALC885_IMAC91] = {
3126 .mixers = {alc885_imac91_mixer}, 829 .mixers = {alc885_imac91_mixer},
3127 .init_verbs = { alc885_imac91_init_verbs, 830 .init_verbs = { alc885_imac91_init_verbs,
@@ -3137,564 +840,6 @@ static const struct alc_config_preset alc882_presets[] = {
3137 .setup = alc885_imac91_setup, 840 .setup = alc885_imac91_setup,
3138 .init_hook = alc_hp_automute, 841 .init_hook = alc_hp_automute,
3139 }, 842 },
3140 [ALC882_TARGA] = {
3141 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
3142 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
3143 alc880_gpio3_init_verbs, alc882_targa_verbs},
3144 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3145 .dac_nids = alc882_dac_nids,
3146 .dig_out_nid = ALC882_DIGOUT_NID,
3147 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3148 .adc_nids = alc882_adc_nids,
3149 .capsrc_nids = alc882_capsrc_nids,
3150 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
3151 .channel_mode = alc882_3ST_6ch_modes,
3152 .need_dac_fix = 1,
3153 .input_mux = &alc882_capture_source,
3154 .unsol_event = alc_sku_unsol_event,
3155 .setup = alc882_targa_setup,
3156 .init_hook = alc882_targa_automute,
3157 },
3158 [ALC882_ASUS_A7J] = {
3159 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
3160 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
3161 alc882_asus_a7j_verbs},
3162 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3163 .dac_nids = alc882_dac_nids,
3164 .dig_out_nid = ALC882_DIGOUT_NID,
3165 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3166 .adc_nids = alc882_adc_nids,
3167 .capsrc_nids = alc882_capsrc_nids,
3168 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
3169 .channel_mode = alc882_3ST_6ch_modes,
3170 .need_dac_fix = 1,
3171 .input_mux = &alc882_capture_source,
3172 },
3173 [ALC882_ASUS_A7M] = {
3174 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
3175 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
3176 alc882_eapd_verbs, alc880_gpio1_init_verbs,
3177 alc882_asus_a7m_verbs },
3178 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3179 .dac_nids = alc882_dac_nids,
3180 .dig_out_nid = ALC882_DIGOUT_NID,
3181 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3182 .channel_mode = alc880_threestack_modes,
3183 .need_dac_fix = 1,
3184 .input_mux = &alc882_capture_source,
3185 },
3186 [ALC883_3ST_2ch_DIG] = {
3187 .mixers = { alc883_3ST_2ch_mixer },
3188 .init_verbs = { alc883_init_verbs },
3189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3190 .dac_nids = alc883_dac_nids,
3191 .dig_out_nid = ALC883_DIGOUT_NID,
3192 .dig_in_nid = ALC883_DIGIN_NID,
3193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3194 .channel_mode = alc883_3ST_2ch_modes,
3195 .input_mux = &alc883_capture_source,
3196 },
3197 [ALC883_3ST_6ch_DIG] = {
3198 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
3199 .init_verbs = { alc883_init_verbs },
3200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3201 .dac_nids = alc883_dac_nids,
3202 .dig_out_nid = ALC883_DIGOUT_NID,
3203 .dig_in_nid = ALC883_DIGIN_NID,
3204 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3205 .channel_mode = alc883_3ST_6ch_modes,
3206 .need_dac_fix = 1,
3207 .input_mux = &alc883_capture_source,
3208 },
3209 [ALC883_3ST_6ch] = {
3210 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
3211 .init_verbs = { alc883_init_verbs },
3212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3213 .dac_nids = alc883_dac_nids,
3214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3215 .channel_mode = alc883_3ST_6ch_modes,
3216 .need_dac_fix = 1,
3217 .input_mux = &alc883_capture_source,
3218 },
3219 [ALC883_3ST_6ch_INTEL] = {
3220 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
3221 .init_verbs = { alc883_init_verbs },
3222 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3223 .dac_nids = alc883_dac_nids,
3224 .dig_out_nid = ALC883_DIGOUT_NID,
3225 .dig_in_nid = ALC883_DIGIN_NID,
3226 .slave_dig_outs = alc883_slave_dig_outs,
3227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
3228 .channel_mode = alc883_3ST_6ch_intel_modes,
3229 .need_dac_fix = 1,
3230 .input_mux = &alc883_3stack_6ch_intel,
3231 },
3232 [ALC889A_INTEL] = {
3233 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
3234 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
3235 alc_hp15_unsol_verbs },
3236 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3237 .dac_nids = alc883_dac_nids,
3238 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
3239 .adc_nids = alc889_adc_nids,
3240 .dig_out_nid = ALC883_DIGOUT_NID,
3241 .dig_in_nid = ALC883_DIGIN_NID,
3242 .slave_dig_outs = alc883_slave_dig_outs,
3243 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
3244 .channel_mode = alc889_8ch_intel_modes,
3245 .capsrc_nids = alc889_capsrc_nids,
3246 .input_mux = &alc889_capture_source,
3247 .setup = alc889_automute_setup,
3248 .init_hook = alc_hp_automute,
3249 .unsol_event = alc_sku_unsol_event,
3250 .need_dac_fix = 1,
3251 },
3252 [ALC889_INTEL] = {
3253 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
3254 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
3255 alc889_eapd_verbs, alc_hp15_unsol_verbs},
3256 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3257 .dac_nids = alc883_dac_nids,
3258 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
3259 .adc_nids = alc889_adc_nids,
3260 .dig_out_nid = ALC883_DIGOUT_NID,
3261 .dig_in_nid = ALC883_DIGIN_NID,
3262 .slave_dig_outs = alc883_slave_dig_outs,
3263 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
3264 .channel_mode = alc889_8ch_intel_modes,
3265 .capsrc_nids = alc889_capsrc_nids,
3266 .input_mux = &alc889_capture_source,
3267 .setup = alc889_automute_setup,
3268 .init_hook = alc889_intel_init_hook,
3269 .unsol_event = alc_sku_unsol_event,
3270 .need_dac_fix = 1,
3271 },
3272 [ALC883_6ST_DIG] = {
3273 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
3274 .init_verbs = { alc883_init_verbs },
3275 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3276 .dac_nids = alc883_dac_nids,
3277 .dig_out_nid = ALC883_DIGOUT_NID,
3278 .dig_in_nid = ALC883_DIGIN_NID,
3279 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
3280 .channel_mode = alc883_sixstack_modes,
3281 .input_mux = &alc883_capture_source,
3282 },
3283 [ALC883_TARGA_DIG] = {
3284 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
3285 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
3286 alc883_targa_verbs},
3287 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3288 .dac_nids = alc883_dac_nids,
3289 .dig_out_nid = ALC883_DIGOUT_NID,
3290 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3291 .channel_mode = alc883_3ST_6ch_modes,
3292 .need_dac_fix = 1,
3293 .input_mux = &alc883_capture_source,
3294 .unsol_event = alc883_targa_unsol_event,
3295 .setup = alc882_targa_setup,
3296 .init_hook = alc882_targa_automute,
3297 },
3298 [ALC883_TARGA_2ch_DIG] = {
3299 .mixers = { alc883_targa_2ch_mixer},
3300 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
3301 alc883_targa_verbs},
3302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3303 .dac_nids = alc883_dac_nids,
3304 .adc_nids = alc883_adc_nids_alt,
3305 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
3306 .capsrc_nids = alc883_capsrc_nids,
3307 .dig_out_nid = ALC883_DIGOUT_NID,
3308 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3309 .channel_mode = alc883_3ST_2ch_modes,
3310 .input_mux = &alc883_capture_source,
3311 .unsol_event = alc883_targa_unsol_event,
3312 .setup = alc882_targa_setup,
3313 .init_hook = alc882_targa_automute,
3314 },
3315 [ALC883_TARGA_8ch_DIG] = {
3316 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
3317 alc883_chmode_mixer },
3318 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
3319 alc883_targa_verbs },
3320 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3321 .dac_nids = alc883_dac_nids,
3322 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
3323 .adc_nids = alc883_adc_nids_rev,
3324 .capsrc_nids = alc883_capsrc_nids_rev,
3325 .dig_out_nid = ALC883_DIGOUT_NID,
3326 .dig_in_nid = ALC883_DIGIN_NID,
3327 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
3328 .channel_mode = alc883_4ST_8ch_modes,
3329 .need_dac_fix = 1,
3330 .input_mux = &alc883_capture_source,
3331 .unsol_event = alc883_targa_unsol_event,
3332 .setup = alc882_targa_setup,
3333 .init_hook = alc882_targa_automute,
3334 },
3335 [ALC883_ACER] = {
3336 .mixers = { alc883_base_mixer },
3337 /* On TravelMate laptops, GPIO 0 enables the internal speaker
3338 * and the headphone jack. Turn this on and rely on the
3339 * standard mute methods whenever the user wants to turn
3340 * these outputs off.
3341 */
3342 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
3343 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3344 .dac_nids = alc883_dac_nids,
3345 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3346 .channel_mode = alc883_3ST_2ch_modes,
3347 .input_mux = &alc883_capture_source,
3348 },
3349 [ALC883_ACER_ASPIRE] = {
3350 .mixers = { alc883_acer_aspire_mixer },
3351 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
3352 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3353 .dac_nids = alc883_dac_nids,
3354 .dig_out_nid = ALC883_DIGOUT_NID,
3355 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3356 .channel_mode = alc883_3ST_2ch_modes,
3357 .input_mux = &alc883_capture_source,
3358 .unsol_event = alc_sku_unsol_event,
3359 .setup = alc883_acer_aspire_setup,
3360 .init_hook = alc_hp_automute,
3361 },
3362 [ALC888_ACER_ASPIRE_4930G] = {
3363 .mixers = { alc888_acer_aspire_4930g_mixer,
3364 alc883_chmode_mixer },
3365 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
3366 alc888_acer_aspire_4930g_verbs },
3367 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3368 .dac_nids = alc883_dac_nids,
3369 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
3370 .adc_nids = alc883_adc_nids_rev,
3371 .capsrc_nids = alc883_capsrc_nids_rev,
3372 .dig_out_nid = ALC883_DIGOUT_NID,
3373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3374 .channel_mode = alc883_3ST_6ch_modes,
3375 .need_dac_fix = 1,
3376 .const_channel_count = 6,
3377 .num_mux_defs =
3378 ARRAY_SIZE(alc888_2_capture_sources),
3379 .input_mux = alc888_2_capture_sources,
3380 .unsol_event = alc_sku_unsol_event,
3381 .setup = alc888_acer_aspire_4930g_setup,
3382 .init_hook = alc_hp_automute,
3383 },
3384 [ALC888_ACER_ASPIRE_6530G] = {
3385 .mixers = { alc888_acer_aspire_6530_mixer },
3386 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
3387 alc888_acer_aspire_6530g_verbs },
3388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3389 .dac_nids = alc883_dac_nids,
3390 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
3391 .adc_nids = alc883_adc_nids_rev,
3392 .capsrc_nids = alc883_capsrc_nids_rev,
3393 .dig_out_nid = ALC883_DIGOUT_NID,
3394 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3395 .channel_mode = alc883_3ST_2ch_modes,
3396 .num_mux_defs =
3397 ARRAY_SIZE(alc888_2_capture_sources),
3398 .input_mux = alc888_acer_aspire_6530_sources,
3399 .unsol_event = alc_sku_unsol_event,
3400 .setup = alc888_acer_aspire_6530g_setup,
3401 .init_hook = alc_hp_automute,
3402 },
3403 [ALC888_ACER_ASPIRE_8930G] = {
3404 .mixers = { alc889_acer_aspire_8930g_mixer,
3405 alc883_chmode_mixer },
3406 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
3407 alc889_acer_aspire_8930g_verbs,
3408 alc889_eapd_verbs},
3409 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3410 .dac_nids = alc883_dac_nids,
3411 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
3412 .adc_nids = alc889_adc_nids,
3413 .capsrc_nids = alc889_capsrc_nids,
3414 .dig_out_nid = ALC883_DIGOUT_NID,
3415 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3416 .channel_mode = alc883_3ST_6ch_modes,
3417 .need_dac_fix = 1,
3418 .const_channel_count = 6,
3419 .num_mux_defs =
3420 ARRAY_SIZE(alc889_capture_sources),
3421 .input_mux = alc889_capture_sources,
3422 .unsol_event = alc_sku_unsol_event,
3423 .setup = alc889_acer_aspire_8930g_setup,
3424 .init_hook = alc_hp_automute,
3425#ifdef CONFIG_SND_HDA_POWER_SAVE
3426 .power_hook = alc_power_eapd,
3427#endif
3428 },
3429 [ALC888_ACER_ASPIRE_7730G] = {
3430 .mixers = { alc883_3ST_6ch_mixer,
3431 alc883_chmode_mixer },
3432 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
3433 alc888_acer_aspire_7730G_verbs },
3434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3435 .dac_nids = alc883_dac_nids,
3436 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
3437 .adc_nids = alc883_adc_nids_rev,
3438 .capsrc_nids = alc883_capsrc_nids_rev,
3439 .dig_out_nid = ALC883_DIGOUT_NID,
3440 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3441 .channel_mode = alc883_3ST_6ch_modes,
3442 .need_dac_fix = 1,
3443 .const_channel_count = 6,
3444 .input_mux = &alc883_capture_source,
3445 .unsol_event = alc_sku_unsol_event,
3446 .setup = alc888_acer_aspire_7730g_setup,
3447 .init_hook = alc_hp_automute,
3448 },
3449 [ALC883_MEDION] = {
3450 .mixers = { alc883_fivestack_mixer,
3451 alc883_chmode_mixer },
3452 .init_verbs = { alc883_init_verbs,
3453 alc883_medion_eapd_verbs },
3454 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3455 .dac_nids = alc883_dac_nids,
3456 .adc_nids = alc883_adc_nids_alt,
3457 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
3458 .capsrc_nids = alc883_capsrc_nids,
3459 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
3460 .channel_mode = alc883_sixstack_modes,
3461 .input_mux = &alc883_capture_source,
3462 },
3463 [ALC883_MEDION_WIM2160] = {
3464 .mixers = { alc883_medion_wim2160_mixer },
3465 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
3466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3467 .dac_nids = alc883_dac_nids,
3468 .dig_out_nid = ALC883_DIGOUT_NID,
3469 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
3470 .adc_nids = alc883_adc_nids,
3471 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3472 .channel_mode = alc883_3ST_2ch_modes,
3473 .input_mux = &alc883_capture_source,
3474 .unsol_event = alc_sku_unsol_event,
3475 .setup = alc883_medion_wim2160_setup,
3476 .init_hook = alc_hp_automute,
3477 },
3478 [ALC883_LAPTOP_EAPD] = {
3479 .mixers = { alc883_base_mixer },
3480 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
3481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3482 .dac_nids = alc883_dac_nids,
3483 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3484 .channel_mode = alc883_3ST_2ch_modes,
3485 .input_mux = &alc883_capture_source,
3486 },
3487 [ALC883_CLEVO_M540R] = {
3488 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
3489 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
3490 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3491 .dac_nids = alc883_dac_nids,
3492 .dig_out_nid = ALC883_DIGOUT_NID,
3493 .dig_in_nid = ALC883_DIGIN_NID,
3494 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
3495 .channel_mode = alc883_3ST_6ch_clevo_modes,
3496 .need_dac_fix = 1,
3497 .input_mux = &alc883_capture_source,
3498 /* This machine has the hardware HP auto-muting, thus
3499 * we need no software mute via unsol event
3500 */
3501 },
3502 [ALC883_CLEVO_M720] = {
3503 .mixers = { alc883_clevo_m720_mixer },
3504 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
3505 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3506 .dac_nids = alc883_dac_nids,
3507 .dig_out_nid = ALC883_DIGOUT_NID,
3508 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3509 .channel_mode = alc883_3ST_2ch_modes,
3510 .input_mux = &alc883_capture_source,
3511 .unsol_event = alc883_clevo_m720_unsol_event,
3512 .setup = alc883_clevo_m720_setup,
3513 .init_hook = alc883_clevo_m720_init_hook,
3514 },
3515 [ALC883_LENOVO_101E_2ch] = {
3516 .mixers = { alc883_lenovo_101e_2ch_mixer},
3517 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
3518 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3519 .dac_nids = alc883_dac_nids,
3520 .adc_nids = alc883_adc_nids_alt,
3521 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
3522 .capsrc_nids = alc883_capsrc_nids,
3523 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3524 .channel_mode = alc883_3ST_2ch_modes,
3525 .input_mux = &alc883_lenovo_101e_capture_source,
3526 .setup = alc883_lenovo_101e_setup,
3527 .unsol_event = alc_sku_unsol_event,
3528 .init_hook = alc_inithook,
3529 },
3530 [ALC883_LENOVO_NB0763] = {
3531 .mixers = { alc883_lenovo_nb0763_mixer },
3532 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
3533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3534 .dac_nids = alc883_dac_nids,
3535 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3536 .channel_mode = alc883_3ST_2ch_modes,
3537 .need_dac_fix = 1,
3538 .input_mux = &alc883_lenovo_nb0763_capture_source,
3539 .unsol_event = alc_sku_unsol_event,
3540 .setup = alc883_lenovo_nb0763_setup,
3541 .init_hook = alc_hp_automute,
3542 },
3543 [ALC888_LENOVO_MS7195_DIG] = {
3544 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
3545 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
3546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3547 .dac_nids = alc883_dac_nids,
3548 .dig_out_nid = ALC883_DIGOUT_NID,
3549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3550 .channel_mode = alc883_3ST_6ch_modes,
3551 .need_dac_fix = 1,
3552 .input_mux = &alc883_capture_source,
3553 .unsol_event = alc_sku_unsol_event,
3554 .setup = alc888_lenovo_ms7195_setup,
3555 .init_hook = alc_inithook,
3556 },
3557 [ALC883_HAIER_W66] = {
3558 .mixers = { alc883_targa_2ch_mixer},
3559 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
3560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3561 .dac_nids = alc883_dac_nids,
3562 .dig_out_nid = ALC883_DIGOUT_NID,
3563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3564 .channel_mode = alc883_3ST_2ch_modes,
3565 .input_mux = &alc883_capture_source,
3566 .unsol_event = alc_sku_unsol_event,
3567 .setup = alc883_haier_w66_setup,
3568 .init_hook = alc_hp_automute,
3569 },
3570 [ALC888_3ST_HP] = {
3571 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
3572 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
3573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3574 .dac_nids = alc883_dac_nids,
3575 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
3576 .channel_mode = alc888_3st_hp_modes,
3577 .need_dac_fix = 1,
3578 .input_mux = &alc883_capture_source,
3579 .unsol_event = alc_sku_unsol_event,
3580 .setup = alc888_3st_hp_setup,
3581 .init_hook = alc_hp_automute,
3582 },
3583 [ALC888_6ST_DELL] = {
3584 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
3585 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
3586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3587 .dac_nids = alc883_dac_nids,
3588 .dig_out_nid = ALC883_DIGOUT_NID,
3589 .dig_in_nid = ALC883_DIGIN_NID,
3590 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
3591 .channel_mode = alc883_sixstack_modes,
3592 .input_mux = &alc883_capture_source,
3593 .unsol_event = alc_sku_unsol_event,
3594 .setup = alc888_6st_dell_setup,
3595 .init_hook = alc_hp_automute,
3596 },
3597 [ALC883_MITAC] = {
3598 .mixers = { alc883_mitac_mixer },
3599 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
3600 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3601 .dac_nids = alc883_dac_nids,
3602 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3603 .channel_mode = alc883_3ST_2ch_modes,
3604 .input_mux = &alc883_capture_source,
3605 .unsol_event = alc_sku_unsol_event,
3606 .setup = alc883_mitac_setup,
3607 .init_hook = alc_hp_automute,
3608 },
3609 [ALC883_FUJITSU_PI2515] = {
3610 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
3611 .init_verbs = { alc883_init_verbs,
3612 alc883_2ch_fujitsu_pi2515_verbs},
3613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3614 .dac_nids = alc883_dac_nids,
3615 .dig_out_nid = ALC883_DIGOUT_NID,
3616 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3617 .channel_mode = alc883_3ST_2ch_modes,
3618 .input_mux = &alc883_fujitsu_pi2515_capture_source,
3619 .unsol_event = alc_sku_unsol_event,
3620 .setup = alc883_2ch_fujitsu_pi2515_setup,
3621 .init_hook = alc_hp_automute,
3622 },
3623 [ALC888_FUJITSU_XA3530] = {
3624 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
3625 .init_verbs = { alc883_init_verbs,
3626 alc888_fujitsu_xa3530_verbs },
3627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3628 .dac_nids = alc883_dac_nids,
3629 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
3630 .adc_nids = alc883_adc_nids_rev,
3631 .capsrc_nids = alc883_capsrc_nids_rev,
3632 .dig_out_nid = ALC883_DIGOUT_NID,
3633 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
3634 .channel_mode = alc888_4ST_8ch_intel_modes,
3635 .num_mux_defs =
3636 ARRAY_SIZE(alc888_2_capture_sources),
3637 .input_mux = alc888_2_capture_sources,
3638 .unsol_event = alc_sku_unsol_event,
3639 .setup = alc888_fujitsu_xa3530_setup,
3640 .init_hook = alc_hp_automute,
3641 },
3642 [ALC888_LENOVO_SKY] = {
3643 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
3644 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
3645 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3646 .dac_nids = alc883_dac_nids,
3647 .dig_out_nid = ALC883_DIGOUT_NID,
3648 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
3649 .channel_mode = alc883_sixstack_modes,
3650 .need_dac_fix = 1,
3651 .input_mux = &alc883_lenovo_sky_capture_source,
3652 .unsol_event = alc_sku_unsol_event,
3653 .setup = alc888_lenovo_sky_setup,
3654 .init_hook = alc_hp_automute,
3655 },
3656 [ALC888_ASUS_M90V] = {
3657 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
3658 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
3659 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3660 .dac_nids = alc883_dac_nids,
3661 .dig_out_nid = ALC883_DIGOUT_NID,
3662 .dig_in_nid = ALC883_DIGIN_NID,
3663 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
3664 .channel_mode = alc883_3ST_6ch_modes,
3665 .need_dac_fix = 1,
3666 .input_mux = &alc883_fujitsu_pi2515_capture_source,
3667 .unsol_event = alc_sku_unsol_event,
3668 .setup = alc883_mode2_setup,
3669 .init_hook = alc_inithook,
3670 },
3671 [ALC888_ASUS_EEE1601] = {
3672 .mixers = { alc883_asus_eee1601_mixer },
3673 .cap_mixer = alc883_asus_eee1601_cap_mixer,
3674 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
3675 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3676 .dac_nids = alc883_dac_nids,
3677 .dig_out_nid = ALC883_DIGOUT_NID,
3678 .dig_in_nid = ALC883_DIGIN_NID,
3679 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3680 .channel_mode = alc883_3ST_2ch_modes,
3681 .need_dac_fix = 1,
3682 .input_mux = &alc883_asus_eee1601_capture_source,
3683 .unsol_event = alc_sku_unsol_event,
3684 .init_hook = alc883_eee1601_inithook,
3685 },
3686 [ALC1200_ASUS_P5Q] = {
3687 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
3688 .init_verbs = { alc883_init_verbs },
3689 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3690 .dac_nids = alc883_dac_nids,
3691 .dig_out_nid = ALC1200_DIGOUT_NID,
3692 .dig_in_nid = ALC883_DIGIN_NID,
3693 .slave_dig_outs = alc1200_slave_dig_outs,
3694 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
3695 .channel_mode = alc883_sixstack_modes,
3696 .input_mux = &alc883_capture_source,
3697 },
3698 [ALC889A_MB31] = { 843 [ALC889A_MB31] = {
3699 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer}, 844 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
3700 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs, 845 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
@@ -3711,18 +856,6 @@ static const struct alc_config_preset alc882_presets[] = {
3711 .unsol_event = alc889A_mb31_unsol_event, 856 .unsol_event = alc889A_mb31_unsol_event,
3712 .init_hook = alc889A_mb31_automute, 857 .init_hook = alc889A_mb31_automute,
3713 }, 858 },
3714 [ALC883_SONY_VAIO_TT] = {
3715 .mixers = { alc883_vaiott_mixer },
3716 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
3717 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
3718 .dac_nids = alc883_dac_nids,
3719 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
3720 .channel_mode = alc883_3ST_2ch_modes,
3721 .input_mux = &alc883_capture_source,
3722 .unsol_event = alc_sku_unsol_event,
3723 .setup = alc883_vaiott_setup,
3724 .init_hook = alc_hp_automute,
3725 },
3726}; 859};
3727 860
3728 861
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 4562e9de6a1..4df72c0e8c3 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -33,6 +33,7 @@
33#include <sound/jack.h> 33#include <sound/jack.h>
34#include "hda_local.h" 34#include "hda_local.h"
35#include "hda_beep.h" 35#include "hda_beep.h"
36#include "hda_jack.h"
36#include <sound/hda_hwdep.h> 37#include <sound/hda_hwdep.h>
37 38
38#define CREATE_TRACE_POINTS 39#define CREATE_TRACE_POINTS
@@ -1723,43 +1724,6 @@ int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
1723} 1724}
1724EXPORT_SYMBOL_HDA(snd_hda_override_pin_caps); 1725EXPORT_SYMBOL_HDA(snd_hda_override_pin_caps);
1725 1726
1726/**
1727 * snd_hda_pin_sense - execute pin sense measurement
1728 * @codec: the CODEC to sense
1729 * @nid: the pin NID to sense
1730 *
1731 * Execute necessary pin sense measurement and return its Presence Detect,
1732 * Impedance, ELD Valid etc. status bits.
1733 */
1734u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
1735{
1736 u32 pincap;
1737
1738 if (!codec->no_trigger_sense) {
1739 pincap = snd_hda_query_pin_caps(codec, nid);
1740 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1741 snd_hda_codec_read(codec, nid, 0,
1742 AC_VERB_SET_PIN_SENSE, 0);
1743 }
1744 return snd_hda_codec_read(codec, nid, 0,
1745 AC_VERB_GET_PIN_SENSE, 0);
1746}
1747EXPORT_SYMBOL_HDA(snd_hda_pin_sense);
1748
1749/**
1750 * snd_hda_jack_detect - query pin Presence Detect status
1751 * @codec: the CODEC to sense
1752 * @nid: the pin NID to sense
1753 *
1754 * Query and return the pin's Presence Detect status.
1755 */
1756int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
1757{
1758 u32 sense = snd_hda_pin_sense(codec, nid);
1759 return !!(sense & AC_PINSENSE_PRESENCE);
1760}
1761EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
1762
1763/* 1727/*
1764 * read the current volume to info 1728 * read the current volume to info
1765 * if the cache exists, read the cache value. 1729 * if the cache exists, read the cache value.
@@ -2308,6 +2272,7 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2308 } 2272 }
2309 if (codec->patch_ops.free) 2273 if (codec->patch_ops.free)
2310 codec->patch_ops.free(codec); 2274 codec->patch_ops.free(codec);
2275 snd_hda_jack_tbl_clear(codec);
2311 codec->proc_widget_hook = NULL; 2276 codec->proc_widget_hook = NULL;
2312 codec->spec = NULL; 2277 codec->spec = NULL;
2313 free_hda_cache(&codec->amp_cache); 2278 free_hda_cache(&codec->amp_cache);
@@ -3364,6 +3329,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3364 restore_pincfgs(codec); /* restore all current pin configs */ 3329 restore_pincfgs(codec); /* restore all current pin configs */
3365 restore_shutup_pins(codec); 3330 restore_shutup_pins(codec);
3366 hda_exec_init_verbs(codec); 3331 hda_exec_init_verbs(codec);
3332 snd_hda_jack_set_dirty_all(codec);
3367 if (codec->patch_ops.resume) 3333 if (codec->patch_ops.resume)
3368 codec->patch_ops.resume(codec); 3334 codec->patch_ops.resume(codec);
3369 else { 3335 else {
@@ -3850,6 +3816,12 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
3850 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) 3816 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))
3851 return audio_idx[type][i]; 3817 return audio_idx[type][i];
3852 3818
3819 /* non-fixed slots starting from 10 */
3820 for (i = 10; i < 32; i++) {
3821 if (!test_and_set_bit(i, bus->pcm_dev_bits))
3822 return i;
3823 }
3824
3853 snd_printk(KERN_WARNING "Too many %s devices\n", 3825 snd_printk(KERN_WARNING "Too many %s devices\n",
3854 snd_hda_pcm_type_name[type]); 3826 snd_hda_pcm_type_name[type]);
3855 return -EAGAIN; 3827 return -EAGAIN;
@@ -5004,8 +4976,8 @@ EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr);
5004 * "Rear", "Internal". 4976 * "Rear", "Internal".
5005 */ 4977 */
5006 4978
5007const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, 4979static const char *hda_get_input_pin_label(struct hda_codec *codec,
5008 int check_location) 4980 hda_nid_t pin, bool check_location)
5009{ 4981{
5010 unsigned int def_conf; 4982 unsigned int def_conf;
5011 static const char * const mic_names[] = { 4983 static const char * const mic_names[] = {
@@ -5044,7 +5016,6 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
5044 return "Misc"; 5016 return "Misc";
5045 } 5017 }
5046} 5018}
5047EXPORT_SYMBOL_HDA(hda_get_input_pin_label);
5048 5019
5049/* Check whether the location prefix needs to be added to the label. 5020/* Check whether the location prefix needs to be added to the label.
5050 * If all mic-jacks are in the same location (e.g. rear panel), we don't 5021 * If all mic-jacks are in the same location (e.g. rear panel), we don't
@@ -5101,6 +5072,149 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
5101} 5072}
5102EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); 5073EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
5103 5074
5075/* return the position of NID in the list, or -1 if not found */
5076static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
5077{
5078 int i;
5079 for (i = 0; i < nums; i++)
5080 if (list[i] == nid)
5081 return i;
5082 return -1;
5083}
5084
5085/* get a unique suffix or an index number */
5086static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
5087 int num_pins, int *indexp)
5088{
5089 static const char * const channel_sfx[] = {
5090 " Front", " Surround", " CLFE", " Side"
5091 };
5092 int i;
5093
5094 i = find_idx_in_nid_list(nid, pins, num_pins);
5095 if (i < 0)
5096 return NULL;
5097 if (num_pins == 1)
5098 return "";
5099 if (num_pins > ARRAY_SIZE(channel_sfx)) {
5100 if (indexp)
5101 *indexp = i;
5102 return "";
5103 }
5104 return channel_sfx[i];
5105}
5106
5107static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
5108 const struct auto_pin_cfg *cfg,
5109 const char *name, char *label, int maxlen,
5110 int *indexp)
5111{
5112 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5113 int attr = snd_hda_get_input_pin_attr(def_conf);
5114 const char *pfx = "", *sfx = "";
5115
5116 /* handle as a speaker if it's a fixed line-out */
5117 if (!strcmp(name, "Line-Out") && attr == INPUT_PIN_ATTR_INT)
5118 name = "Speaker";
5119 /* check the location */
5120 switch (attr) {
5121 case INPUT_PIN_ATTR_DOCK:
5122 pfx = "Dock ";
5123 break;
5124 case INPUT_PIN_ATTR_FRONT:
5125 pfx = "Front ";
5126 break;
5127 }
5128 if (cfg) {
5129 /* try to give a unique suffix if needed */
5130 sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs,
5131 indexp);
5132 if (!sfx)
5133 sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs,
5134 indexp);
5135 if (!sfx) {
5136 /* don't add channel suffix for Headphone controls */
5137 int idx = find_idx_in_nid_list(nid, cfg->hp_pins,
5138 cfg->hp_outs);
5139 if (idx >= 0)
5140 *indexp = idx;
5141 sfx = "";
5142 }
5143 }
5144 snprintf(label, maxlen, "%s%s%s", pfx, name, sfx);
5145 return 1;
5146}
5147
5148/**
5149 * snd_hda_get_pin_label - Get a label for the given I/O pin
5150 *
5151 * Get a label for the given pin. This function works for both input and
5152 * output pins. When @cfg is given as non-NULL, the function tries to get
5153 * an optimized label using hda_get_autocfg_input_label().
5154 *
5155 * This function tries to give a unique label string for the pin as much as
5156 * possible. For example, when the multiple line-outs are present, it adds
5157 * the channel suffix like "Front", "Surround", etc (only when @cfg is given).
5158 * If no unique name with a suffix is available and @indexp is non-NULL, the
5159 * index number is stored in the pointer.
5160 */
5161int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
5162 const struct auto_pin_cfg *cfg,
5163 char *label, int maxlen, int *indexp)
5164{
5165 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5166 const char *name = NULL;
5167 int i;
5168
5169 if (indexp)
5170 *indexp = 0;
5171 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
5172 return 0;
5173
5174 switch (get_defcfg_device(def_conf)) {
5175 case AC_JACK_LINE_OUT:
5176 return fill_audio_out_name(codec, nid, cfg, "Line-Out",
5177 label, maxlen, indexp);
5178 case AC_JACK_SPEAKER:
5179 return fill_audio_out_name(codec, nid, cfg, "Speaker",
5180 label, maxlen, indexp);
5181 case AC_JACK_HP_OUT:
5182 return fill_audio_out_name(codec, nid, cfg, "Headphone",
5183 label, maxlen, indexp);
5184 case AC_JACK_SPDIF_OUT:
5185 case AC_JACK_DIG_OTHER_OUT:
5186 if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
5187 name = "HDMI";
5188 else
5189 name = "SPDIF";
5190 if (cfg && indexp) {
5191 i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
5192 cfg->dig_outs);
5193 if (i >= 0)
5194 *indexp = i;
5195 }
5196 break;
5197 default:
5198 if (cfg) {
5199 for (i = 0; i < cfg->num_inputs; i++) {
5200 if (cfg->inputs[i].pin != nid)
5201 continue;
5202 name = hda_get_autocfg_input_label(codec, cfg, i);
5203 if (name)
5204 break;
5205 }
5206 }
5207 if (!name)
5208 name = hda_get_input_pin_label(codec, nid, true);
5209 break;
5210 }
5211 if (!name)
5212 return 0;
5213 strlcpy(label, name, maxlen);
5214 return 1;
5215}
5216EXPORT_SYMBOL_HDA(snd_hda_get_pin_label);
5217
5104/** 5218/**
5105 * snd_hda_add_imux_item - Add an item to input_mux 5219 * snd_hda_add_imux_item - Add an item to input_mux
5106 * 5220 *
@@ -5252,113 +5366,5 @@ void snd_print_pcm_bits(int pcm, char *buf, int buflen)
5252} 5366}
5253EXPORT_SYMBOL_HDA(snd_print_pcm_bits); 5367EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
5254 5368
5255#ifdef CONFIG_SND_HDA_INPUT_JACK
5256/*
5257 * Input-jack notification support
5258 */
5259struct hda_jack_item {
5260 hda_nid_t nid;
5261 int type;
5262 struct snd_jack *jack;
5263};
5264
5265static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid,
5266 int type)
5267{
5268 switch (type) {
5269 case SND_JACK_HEADPHONE:
5270 return "Headphone";
5271 case SND_JACK_MICROPHONE:
5272 return "Mic";
5273 case SND_JACK_LINEOUT:
5274 return "Line-out";
5275 case SND_JACK_LINEIN:
5276 return "Line-in";
5277 case SND_JACK_HEADSET:
5278 return "Headset";
5279 case SND_JACK_VIDEOOUT:
5280 return "HDMI/DP";
5281 default:
5282 return "Misc";
5283 }
5284}
5285
5286static void hda_free_jack_priv(struct snd_jack *jack)
5287{
5288 struct hda_jack_item *jacks = jack->private_data;
5289 jacks->nid = 0;
5290 jacks->jack = NULL;
5291}
5292
5293int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
5294 const char *name)
5295{
5296 struct hda_jack_item *jack;
5297 int err;
5298
5299 snd_array_init(&codec->jacks, sizeof(*jack), 32);
5300 jack = snd_array_new(&codec->jacks);
5301 if (!jack)
5302 return -ENOMEM;
5303
5304 jack->nid = nid;
5305 jack->type = type;
5306 if (!name)
5307 name = get_jack_default_name(codec, nid, type);
5308 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
5309 if (err < 0) {
5310 jack->nid = 0;
5311 return err;
5312 }
5313 jack->jack->private_data = jack;
5314 jack->jack->private_free = hda_free_jack_priv;
5315 return 0;
5316}
5317EXPORT_SYMBOL_HDA(snd_hda_input_jack_add);
5318
5319void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid)
5320{
5321 struct hda_jack_item *jacks = codec->jacks.list;
5322 int i;
5323
5324 if (!jacks)
5325 return;
5326
5327 for (i = 0; i < codec->jacks.used; i++, jacks++) {
5328 unsigned int pin_ctl;
5329 unsigned int present;
5330 int type;
5331
5332 if (jacks->nid != nid)
5333 continue;
5334 present = snd_hda_jack_detect(codec, nid);
5335 type = jacks->type;
5336 if (type == (SND_JACK_HEADPHONE | SND_JACK_LINEOUT)) {
5337 pin_ctl = snd_hda_codec_read(codec, nid, 0,
5338 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5339 type = (pin_ctl & AC_PINCTL_HP_EN) ?
5340 SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
5341 }
5342 snd_jack_report(jacks->jack, present ? type : 0);
5343 }
5344}
5345EXPORT_SYMBOL_HDA(snd_hda_input_jack_report);
5346
5347/* free jack instances manually when clearing/reconfiguring */
5348void snd_hda_input_jack_free(struct hda_codec *codec)
5349{
5350 if (!codec->bus->shutdown && codec->jacks.list) {
5351 struct hda_jack_item *jacks = codec->jacks.list;
5352 int i;
5353 for (i = 0; i < codec->jacks.used; i++, jacks++) {
5354 if (jacks->jack)
5355 snd_device_free(codec->bus->card, jacks->jack);
5356 }
5357 }
5358 snd_array_free(&codec->jacks);
5359}
5360EXPORT_SYMBOL_HDA(snd_hda_input_jack_free);
5361#endif /* CONFIG_SND_HDA_INPUT_JACK */
5362
5363MODULE_DESCRIPTION("HDA codec core"); 5369MODULE_DESCRIPTION("HDA codec core");
5364MODULE_LICENSE("GPL"); 5370MODULE_LICENSE("GPL");
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 564471169ca..e9f71dc0d46 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -547,9 +547,6 @@ enum {
547/* max. codec address */ 547/* max. codec address */
548#define HDA_MAX_CODEC_ADDRESS 0x0f 548#define HDA_MAX_CODEC_ADDRESS 0x0f
549 549
550/* max number of PCM devics per card */
551#define HDA_MAX_PCMS 10
552
553/* 550/*
554 * generic arrays 551 * generic arrays
555 */ 552 */
@@ -869,6 +866,9 @@ struct hda_codec {
869 void (*proc_widget_hook)(struct snd_info_buffer *buffer, 866 void (*proc_widget_hook)(struct snd_info_buffer *buffer,
870 struct hda_codec *codec, hda_nid_t nid); 867 struct hda_codec *codec, hda_nid_t nid);
871 868
869 /* jack detection */
870 struct snd_array jacktbl;
871
872#ifdef CONFIG_SND_HDA_INPUT_JACK 872#ifdef CONFIG_SND_HDA_INPUT_JACK
873 /* jack detection */ 873 /* jack detection */
874 struct snd_array jacks; 874 struct snd_array jacks;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index c2f79e63124..0852e204a4c 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -58,13 +58,13 @@
58 58
59static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 59static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
60static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 60static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
61static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 61static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
62static char *model[SNDRV_CARDS]; 62static char *model[SNDRV_CARDS];
63static int position_fix[SNDRV_CARDS]; 63static int position_fix[SNDRV_CARDS];
64static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; 64static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
65static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; 65static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
66static int probe_only[SNDRV_CARDS]; 66static int probe_only[SNDRV_CARDS];
67static int single_cmd; 67static bool single_cmd;
68static int enable_msi = -1; 68static int enable_msi = -1;
69#ifdef CONFIG_SND_HDA_PATCH_LOADER 69#ifdef CONFIG_SND_HDA_PATCH_LOADER
70static char *patch[SNDRV_CARDS]; 70static char *patch[SNDRV_CARDS];
@@ -116,12 +116,12 @@ MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
116 * this may give more power-saving, but will take longer time to 116 * this may give more power-saving, but will take longer time to
117 * wake up. 117 * wake up.
118 */ 118 */
119static int power_save_controller = 1; 119static bool power_save_controller = 1;
120module_param(power_save_controller, bool, 0644); 120module_param(power_save_controller, bool, 0644);
121MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); 121MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
122#endif 122#endif
123 123
124static int align_buffer_size = 1; 124static bool align_buffer_size = 1;
125module_param(align_buffer_size, bool, 0644); 125module_param(align_buffer_size, bool, 0644);
126MODULE_PARM_DESC(align_buffer_size, 126MODULE_PARM_DESC(align_buffer_size,
127 "Force buffer and period sizes to be multiple of 128 bytes."); 127 "Force buffer and period sizes to be multiple of 128 bytes.");
@@ -407,6 +407,14 @@ struct azx_rb {
407 u32 res[AZX_MAX_CODECS]; /* last read value */ 407 u32 res[AZX_MAX_CODECS]; /* last read value */
408}; 408};
409 409
410struct azx_pcm {
411 struct azx *chip;
412 struct snd_pcm *pcm;
413 struct hda_codec *codec;
414 struct hda_pcm_stream *hinfo[2];
415 struct list_head list;
416};
417
410struct azx { 418struct azx {
411 struct snd_card *card; 419 struct snd_card *card;
412 struct pci_dev *pci; 420 struct pci_dev *pci;
@@ -434,7 +442,7 @@ struct azx {
434 struct azx_dev *azx_dev; 442 struct azx_dev *azx_dev;
435 443
436 /* PCM */ 444 /* PCM */
437 struct snd_pcm *pcm[HDA_MAX_PCMS]; 445 struct list_head pcm_list; /* azx_pcm list */
438 446
439 /* HD codec */ 447 /* HD codec */
440 unsigned short codec_mask; 448 unsigned short codec_mask;
@@ -479,6 +487,7 @@ enum {
479 AZX_DRIVER_SCH, 487 AZX_DRIVER_SCH,
480 AZX_DRIVER_ATI, 488 AZX_DRIVER_ATI,
481 AZX_DRIVER_ATIHDMI, 489 AZX_DRIVER_ATIHDMI,
490 AZX_DRIVER_ATIHDMI_NS,
482 AZX_DRIVER_VIA, 491 AZX_DRIVER_VIA,
483 AZX_DRIVER_SIS, 492 AZX_DRIVER_SIS,
484 AZX_DRIVER_ULI, 493 AZX_DRIVER_ULI,
@@ -525,6 +534,7 @@ static char *driver_short_names[] __devinitdata = {
525 [AZX_DRIVER_SCH] = "HDA Intel MID", 534 [AZX_DRIVER_SCH] = "HDA Intel MID",
526 [AZX_DRIVER_ATI] = "HDA ATI SB", 535 [AZX_DRIVER_ATI] = "HDA ATI SB",
527 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", 536 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
537 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
528 [AZX_DRIVER_VIA] = "HDA VIA VT82xx", 538 [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
529 [AZX_DRIVER_SIS] = "HDA SIS966", 539 [AZX_DRIVER_SIS] = "HDA SIS966",
530 [AZX_DRIVER_ULI] = "HDA ULI M5461", 540 [AZX_DRIVER_ULI] = "HDA ULI M5461",
@@ -1143,16 +1153,6 @@ static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
1143 1153
1144static void azx_init_pci(struct azx *chip) 1154static void azx_init_pci(struct azx *chip)
1145{ 1155{
1146 /* force to non-snoop mode for a new VIA controller when BIOS is set */
1147 if (chip->snoop && chip->driver_type == AZX_DRIVER_VIA) {
1148 u8 snoop;
1149 pci_read_config_byte(chip->pci, 0x42, &snoop);
1150 if (!(snoop & 0x80) && chip->pci->revision == 0x30) {
1151 chip->snoop = 0;
1152 snd_printdd(SFX "Force to non-snoop mode\n");
1153 }
1154 }
1155
1156 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 1156 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
1157 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 1157 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
1158 * Ensuring these bits are 0 clears playback static on some HD Audio 1158 * Ensuring these bits are 0 clears playback static on some HD Audio
@@ -1486,10 +1486,9 @@ static void azx_bus_reset(struct hda_bus *bus)
1486 azx_init_chip(chip, 1); 1486 azx_init_chip(chip, 1);
1487#ifdef CONFIG_PM 1487#ifdef CONFIG_PM
1488 if (chip->initialized) { 1488 if (chip->initialized) {
1489 int i; 1489 struct azx_pcm *p;
1490 1490 list_for_each_entry(p, &chip->pcm_list, list)
1491 for (i = 0; i < HDA_MAX_PCMS; i++) 1491 snd_pcm_suspend_all(p->pcm);
1492 snd_pcm_suspend_all(chip->pcm[i]);
1493 snd_hda_suspend(chip->bus); 1492 snd_hda_suspend(chip->bus);
1494 snd_hda_resume(chip->bus); 1493 snd_hda_resume(chip->bus);
1495 } 1494 }
@@ -1667,12 +1666,6 @@ static struct snd_pcm_hardware azx_pcm_hw = {
1667 .fifo_size = 0, 1666 .fifo_size = 0,
1668}; 1667};
1669 1668
1670struct azx_pcm {
1671 struct azx *chip;
1672 struct hda_codec *codec;
1673 struct hda_pcm_stream *hinfo[2];
1674};
1675
1676static int azx_pcm_open(struct snd_pcm_substream *substream) 1669static int azx_pcm_open(struct snd_pcm_substream *substream)
1677{ 1670{
1678 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1671 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
@@ -2197,7 +2190,7 @@ static void azx_pcm_free(struct snd_pcm *pcm)
2197{ 2190{
2198 struct azx_pcm *apcm = pcm->private_data; 2191 struct azx_pcm *apcm = pcm->private_data;
2199 if (apcm) { 2192 if (apcm) {
2200 apcm->chip->pcm[pcm->device] = NULL; 2193 list_del(&apcm->list);
2201 kfree(apcm); 2194 kfree(apcm);
2202 } 2195 }
2203} 2196}
@@ -2215,14 +2208,11 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
2215 unsigned int size; 2208 unsigned int size;
2216 int s, err; 2209 int s, err;
2217 2210
2218 if (pcm_dev >= HDA_MAX_PCMS) { 2211 list_for_each_entry(apcm, &chip->pcm_list, list) {
2219 snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n", 2212 if (apcm->pcm->device == pcm_dev) {
2220 pcm_dev); 2213 snd_printk(KERN_ERR SFX "PCM %d already exists\n", pcm_dev);
2221 return -EINVAL; 2214 return -EBUSY;
2222 } 2215 }
2223 if (chip->pcm[pcm_dev]) {
2224 snd_printk(KERN_ERR SFX "PCM %d already exists\n", pcm_dev);
2225 return -EBUSY;
2226 } 2216 }
2227 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev, 2217 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
2228 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams, 2218 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
@@ -2235,12 +2225,13 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
2235 if (apcm == NULL) 2225 if (apcm == NULL)
2236 return -ENOMEM; 2226 return -ENOMEM;
2237 apcm->chip = chip; 2227 apcm->chip = chip;
2228 apcm->pcm = pcm;
2238 apcm->codec = codec; 2229 apcm->codec = codec;
2239 pcm->private_data = apcm; 2230 pcm->private_data = apcm;
2240 pcm->private_free = azx_pcm_free; 2231 pcm->private_free = azx_pcm_free;
2241 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM) 2232 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
2242 pcm->dev_class = SNDRV_PCM_CLASS_MODEM; 2233 pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
2243 chip->pcm[pcm_dev] = pcm; 2234 list_add_tail(&apcm->list, &chip->pcm_list);
2244 cpcm->pcm = pcm; 2235 cpcm->pcm = pcm;
2245 for (s = 0; s < 2; s++) { 2236 for (s = 0; s < 2; s++) {
2246 apcm->hinfo[s] = &cpcm->stream[s]; 2237 apcm->hinfo[s] = &cpcm->stream[s];
@@ -2370,12 +2361,12 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
2370{ 2361{
2371 struct snd_card *card = pci_get_drvdata(pci); 2362 struct snd_card *card = pci_get_drvdata(pci);
2372 struct azx *chip = card->private_data; 2363 struct azx *chip = card->private_data;
2373 int i; 2364 struct azx_pcm *p;
2374 2365
2375 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2366 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2376 azx_clear_irq_pending(chip); 2367 azx_clear_irq_pending(chip);
2377 for (i = 0; i < HDA_MAX_PCMS; i++) 2368 list_for_each_entry(p, &chip->pcm_list, list)
2378 snd_pcm_suspend_all(chip->pcm[i]); 2369 snd_pcm_suspend_all(p->pcm);
2379 if (chip->initialized) 2370 if (chip->initialized)
2380 snd_hda_suspend(chip->bus); 2371 snd_hda_suspend(chip->bus);
2381 azx_stop_chip(chip); 2372 azx_stop_chip(chip);
@@ -2502,12 +2493,10 @@ static int azx_dev_free(struct snd_device *device)
2502static struct snd_pci_quirk position_fix_list[] __devinitdata = { 2493static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2503 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), 2494 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB),
2504 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), 2495 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB),
2505 SND_PCI_QUIRK(0x1028, 0x02c6, "Dell Inspiron 1010", POS_FIX_LPIB),
2506 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), 2496 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB),
2507 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2497 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
2508 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), 2498 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB),
2509 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), 2499 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB),
2510 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS 1101HA", POS_FIX_LPIB),
2511 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), 2500 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB),
2512 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB), 2501 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB),
2513 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB), 2502 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
@@ -2634,6 +2623,35 @@ static void __devinit check_msi(struct azx *chip)
2634 } 2623 }
2635} 2624}
2636 2625
2626/* check the snoop mode availability */
2627static void __devinit azx_check_snoop_available(struct azx *chip)
2628{
2629 bool snoop = chip->snoop;
2630
2631 switch (chip->driver_type) {
2632 case AZX_DRIVER_VIA:
2633 /* force to non-snoop mode for a new VIA controller
2634 * when BIOS is set
2635 */
2636 if (snoop) {
2637 u8 val;
2638 pci_read_config_byte(chip->pci, 0x42, &val);
2639 if (!(val & 0x80) && chip->pci->revision == 0x30)
2640 snoop = false;
2641 }
2642 break;
2643 case AZX_DRIVER_ATIHDMI_NS:
2644 /* new ATI HDMI requires non-snoop */
2645 snoop = false;
2646 break;
2647 }
2648
2649 if (snoop != chip->snoop) {
2650 snd_printk(KERN_INFO SFX "Force to %s mode\n",
2651 snoop ? "snoop" : "non-snoop");
2652 chip->snoop = snoop;
2653 }
2654}
2637 2655
2638/* 2656/*
2639 * constructor 2657 * constructor
@@ -2672,6 +2690,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2672 check_msi(chip); 2690 check_msi(chip);
2673 chip->dev_index = dev; 2691 chip->dev_index = dev;
2674 INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); 2692 INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work);
2693 INIT_LIST_HEAD(&chip->pcm_list);
2675 2694
2676 chip->position_fix[0] = chip->position_fix[1] = 2695 chip->position_fix[0] = chip->position_fix[1] =
2677 check_position_fix(chip, position_fix[dev]); 2696 check_position_fix(chip, position_fix[dev]);
@@ -2679,6 +2698,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2679 2698
2680 chip->single_cmd = single_cmd; 2699 chip->single_cmd = single_cmd;
2681 chip->snoop = hda_snoop; 2700 chip->snoop = hda_snoop;
2701 azx_check_snoop_available(chip);
2682 2702
2683 if (bdl_pos_adj[dev] < 0) { 2703 if (bdl_pos_adj[dev] < 0) {
2684 switch (chip->driver_type) { 2704 switch (chip->driver_type) {
@@ -2777,6 +2797,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2777 chip->capture_streams = ULI_NUM_CAPTURE; 2797 chip->capture_streams = ULI_NUM_CAPTURE;
2778 break; 2798 break;
2779 case AZX_DRIVER_ATIHDMI: 2799 case AZX_DRIVER_ATIHDMI:
2800 case AZX_DRIVER_ATIHDMI_NS:
2780 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; 2801 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
2781 chip->capture_streams = ATIHDMI_NUM_CAPTURE; 2802 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
2782 break; 2803 break;
@@ -2972,6 +2993,9 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
2972 { PCI_DEVICE(0x8086, 0x811b), 2993 { PCI_DEVICE(0x8086, 0x811b),
2973 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 2994 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
2974 AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_LPIB }, /* Poulsbo */ 2995 AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_LPIB }, /* Poulsbo */
2996 { PCI_DEVICE(0x8086, 0x080a),
2997 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
2998 AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_LPIB }, /* Oaktrail */
2975 /* ICH */ 2999 /* ICH */
2976 { PCI_DEVICE(0x8086, 0x2668), 3000 { PCI_DEVICE(0x8086, 0x2668),
2977 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC | 3001 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
@@ -3039,6 +3063,14 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
3039 .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, 3063 .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
3040 { PCI_DEVICE(0x1002, 0xaa48), 3064 { PCI_DEVICE(0x1002, 0xaa48),
3041 .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, 3065 .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
3066 { PCI_DEVICE(0x1002, 0x9902),
3067 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
3068 { PCI_DEVICE(0x1002, 0xaaa0),
3069 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
3070 { PCI_DEVICE(0x1002, 0xaaa8),
3071 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
3072 { PCI_DEVICE(0x1002, 0xaab0),
3073 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI },
3042 /* VIA VT8251/VT8237A */ 3074 /* VIA VT8251/VT8237A */
3043 { PCI_DEVICE(0x1106, 0x3288), 3075 { PCI_DEVICE(0x1106, 0x3288),
3044 .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA }, 3076 .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA },
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
new file mode 100644
index 00000000000..d8a35da0803
--- /dev/null
+++ b/sound/pci/hda/hda_jack.c
@@ -0,0 +1,353 @@
1/*
2 * Jack-detection handling for HD-audio
3 *
4 * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
5 *
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/init.h>
13#include <linux/slab.h>
14#include <linux/export.h>
15#include <sound/core.h>
16#include <sound/control.h>
17#include <sound/jack.h>
18#include "hda_codec.h"
19#include "hda_local.h"
20#include "hda_jack.h"
21
22/* execute pin sense measurement */
23static u32 read_pin_sense(struct hda_codec *codec, hda_nid_t nid)
24{
25 u32 pincap;
26
27 if (!codec->no_trigger_sense) {
28 pincap = snd_hda_query_pin_caps(codec, nid);
29 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
30 snd_hda_codec_read(codec, nid, 0,
31 AC_VERB_SET_PIN_SENSE, 0);
32 }
33 return snd_hda_codec_read(codec, nid, 0,
34 AC_VERB_GET_PIN_SENSE, 0);
35}
36
37/**
38 * snd_hda_jack_tbl_get - query the jack-table entry for the given NID
39 */
40struct hda_jack_tbl *
41snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid)
42{
43 struct hda_jack_tbl *jack = codec->jacktbl.list;
44 int i;
45
46 if (!nid || !jack)
47 return NULL;
48 for (i = 0; i < codec->jacktbl.used; i++, jack++)
49 if (jack->nid == nid)
50 return jack;
51 return NULL;
52}
53EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_get);
54
55/**
56 * snd_hda_jack_tbl_get_from_tag - query the jack-table entry for the given tag
57 */
58struct hda_jack_tbl *
59snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag)
60{
61 struct hda_jack_tbl *jack = codec->jacktbl.list;
62 int i;
63
64 if (!tag || !jack)
65 return NULL;
66 for (i = 0; i < codec->jacktbl.used; i++, jack++)
67 if (jack->tag == tag)
68 return jack;
69 return NULL;
70}
71EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_get_from_tag);
72
73/**
74 * snd_hda_jack_tbl_new - create a jack-table entry for the given NID
75 */
76struct hda_jack_tbl *
77snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid)
78{
79 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
80 if (jack)
81 return jack;
82 snd_array_init(&codec->jacktbl, sizeof(*jack), 16);
83 jack = snd_array_new(&codec->jacktbl);
84 if (!jack)
85 return NULL;
86 jack->nid = nid;
87 jack->jack_dirty = 1;
88 jack->tag = codec->jacktbl.used;
89 return jack;
90}
91EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_new);
92
93void snd_hda_jack_tbl_clear(struct hda_codec *codec)
94{
95#ifdef CONFIG_SND_HDA_INPUT_JACK
96 /* free jack instances manually when clearing/reconfiguring */
97 if (!codec->bus->shutdown && codec->jacktbl.list) {
98 struct hda_jack_tbl *jack = codec->jacktbl.list;
99 int i;
100 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
101 if (jack->jack)
102 snd_device_free(codec->bus->card, jack->jack);
103 }
104 }
105#endif
106 snd_array_free(&codec->jacktbl);
107}
108
109/* update the cached value and notification flag if needed */
110static void jack_detect_update(struct hda_codec *codec,
111 struct hda_jack_tbl *jack)
112{
113 if (jack->jack_dirty || !jack->jack_detect) {
114 jack->pin_sense = read_pin_sense(codec, jack->nid);
115 jack->jack_dirty = 0;
116 }
117}
118
119/**
120 * snd_hda_set_dirty_all - Mark all the cached as dirty
121 *
122 * This function sets the dirty flag to all entries of jack table.
123 * It's called from the resume path in hda_codec.c.
124 */
125void snd_hda_jack_set_dirty_all(struct hda_codec *codec)
126{
127 struct hda_jack_tbl *jack = codec->jacktbl.list;
128 int i;
129
130 for (i = 0; i < codec->jacktbl.used; i++, jack++)
131 if (jack->nid)
132 jack->jack_dirty = 1;
133}
134EXPORT_SYMBOL_HDA(snd_hda_jack_set_dirty_all);
135
136/**
137 * snd_hda_pin_sense - execute pin sense measurement
138 * @codec: the CODEC to sense
139 * @nid: the pin NID to sense
140 *
141 * Execute necessary pin sense measurement and return its Presence Detect,
142 * Impedance, ELD Valid etc. status bits.
143 */
144u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
145{
146 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
147 if (jack) {
148 jack_detect_update(codec, jack);
149 return jack->pin_sense;
150 }
151 return read_pin_sense(codec, nid);
152}
153EXPORT_SYMBOL_HDA(snd_hda_pin_sense);
154
155#define get_jack_plug_state(sense) !!(sense & AC_PINSENSE_PRESENCE)
156
157/**
158 * snd_hda_jack_detect - query pin Presence Detect status
159 * @codec: the CODEC to sense
160 * @nid: the pin NID to sense
161 *
162 * Query and return the pin's Presence Detect status.
163 */
164int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
165{
166 u32 sense = snd_hda_pin_sense(codec, nid);
167 return get_jack_plug_state(sense);
168}
169EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
170
171/**
172 * snd_hda_jack_detect_enable - enable the jack-detection
173 */
174int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
175 unsigned char action)
176{
177 struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid);
178 if (!jack)
179 return -ENOMEM;
180 if (jack->jack_detect)
181 return 0; /* already registered */
182 jack->jack_detect = 1;
183 if (action)
184 jack->action = action;
185 return snd_hda_codec_write_cache(codec, nid, 0,
186 AC_VERB_SET_UNSOLICITED_ENABLE,
187 AC_USRSP_EN | jack->tag);
188}
189EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);
190
191/**
192 * snd_hda_jack_report_sync - sync the states of all jacks and report if changed
193 */
194void snd_hda_jack_report_sync(struct hda_codec *codec)
195{
196 struct hda_jack_tbl *jack = codec->jacktbl.list;
197 int i, state;
198
199 for (i = 0; i < codec->jacktbl.used; i++, jack++)
200 if (jack->nid) {
201 jack_detect_update(codec, jack);
202 if (!jack->kctl)
203 continue;
204 state = get_jack_plug_state(jack->pin_sense);
205 snd_kctl_jack_report(codec->bus->card, jack->kctl, state);
206#ifdef CONFIG_SND_HDA_INPUT_JACK
207 if (jack->jack)
208 snd_jack_report(jack->jack,
209 state ? jack->type : 0);
210#endif
211 }
212}
213EXPORT_SYMBOL_HDA(snd_hda_jack_report_sync);
214
215#ifdef CONFIG_SND_HDA_INPUT_JACK
216/* guess the jack type from the pin-config */
217static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid)
218{
219 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
220 switch (get_defcfg_device(def_conf)) {
221 case AC_JACK_LINE_OUT:
222 case AC_JACK_SPEAKER:
223 return SND_JACK_LINEOUT;
224 case AC_JACK_HP_OUT:
225 return SND_JACK_HEADPHONE;
226 case AC_JACK_SPDIF_OUT:
227 case AC_JACK_DIG_OTHER_OUT:
228 return SND_JACK_AVOUT;
229 case AC_JACK_MIC_IN:
230 return SND_JACK_MICROPHONE;
231 default:
232 return SND_JACK_LINEIN;
233 }
234}
235
236static void hda_free_jack_priv(struct snd_jack *jack)
237{
238 struct hda_jack_tbl *jacks = jack->private_data;
239 jacks->nid = 0;
240 jacks->jack = NULL;
241}
242#endif
243
244/**
245 * snd_hda_jack_add_kctl - Add a kctl for the given pin
246 *
247 * This assigns a jack-detection kctl to the given pin. The kcontrol
248 * will have the given name and index.
249 */
250int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
251 const char *name, int idx)
252{
253 struct hda_jack_tbl *jack;
254 struct snd_kcontrol *kctl;
255 int err, state;
256
257 jack = snd_hda_jack_tbl_new(codec, nid);
258 if (!jack)
259 return 0;
260 if (jack->kctl)
261 return 0; /* already created */
262 kctl = snd_kctl_jack_new(name, idx, codec);
263 if (!kctl)
264 return -ENOMEM;
265 err = snd_hda_ctl_add(codec, nid, kctl);
266 if (err < 0)
267 return err;
268 jack->kctl = kctl;
269 state = snd_hda_jack_detect(codec, nid);
270 snd_kctl_jack_report(codec->bus->card, kctl, state);
271#ifdef CONFIG_SND_HDA_INPUT_JACK
272 jack->type = get_input_jack_type(codec, nid);
273 err = snd_jack_new(codec->bus->card, name, jack->type, &jack->jack);
274 if (err < 0)
275 return err;
276 jack->jack->private_data = jack;
277 jack->jack->private_free = hda_free_jack_priv;
278 snd_jack_report(jack->jack, state ? jack->type : 0);
279#endif
280 return 0;
281}
282EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl);
283
284static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
285 const struct auto_pin_cfg *cfg)
286{
287 unsigned int def_conf, conn;
288 char name[44];
289 int idx, err;
290
291 if (!nid)
292 return 0;
293 if (!is_jack_detectable(codec, nid))
294 return 0;
295 def_conf = snd_hda_codec_get_pincfg(codec, nid);
296 conn = get_defcfg_connect(def_conf);
297 if (conn != AC_JACK_PORT_COMPLEX)
298 return 0;
299
300 snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx);
301 err = snd_hda_jack_add_kctl(codec, nid, name, idx);
302 if (err < 0)
303 return err;
304 return snd_hda_jack_detect_enable(codec, nid, 0);
305}
306
307/**
308 * snd_hda_jack_add_kctls - Add kctls for all pins included in the given pincfg
309 */
310int snd_hda_jack_add_kctls(struct hda_codec *codec,
311 const struct auto_pin_cfg *cfg)
312{
313 const hda_nid_t *p;
314 int i, err;
315
316 for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) {
317 err = add_jack_kctl(codec, *p, cfg);
318 if (err < 0)
319 return err;
320 }
321 for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) {
322 if (*p == *cfg->line_out_pins) /* might be duplicated */
323 break;
324 err = add_jack_kctl(codec, *p, cfg);
325 if (err < 0)
326 return err;
327 }
328 for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) {
329 if (*p == *cfg->line_out_pins) /* might be duplicated */
330 break;
331 err = add_jack_kctl(codec, *p, cfg);
332 if (err < 0)
333 return err;
334 }
335 for (i = 0; i < cfg->num_inputs; i++) {
336 err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg);
337 if (err < 0)
338 return err;
339 }
340 for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) {
341 err = add_jack_kctl(codec, *p, cfg);
342 if (err < 0)
343 return err;
344 }
345 err = add_jack_kctl(codec, cfg->dig_in_pin, cfg);
346 if (err < 0)
347 return err;
348 err = add_jack_kctl(codec, cfg->mono_out_pin, cfg);
349 if (err < 0)
350 return err;
351 return 0;
352}
353EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls);
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
new file mode 100644
index 00000000000..f8f97c71c9c
--- /dev/null
+++ b/sound/pci/hda/hda_jack.h
@@ -0,0 +1,86 @@
1/*
2 * Jack-detection handling for HD-audio
3 *
4 * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
5 *
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __SOUND_HDA_JACK_H
13#define __SOUND_HDA_JACK_H
14
15struct hda_jack_tbl {
16 hda_nid_t nid;
17 unsigned char action; /* event action (0 = none) */
18 unsigned char tag; /* unsol event tag */
19 unsigned int private_data; /* arbitrary data */
20 /* jack-detection stuff */
21 unsigned int pin_sense; /* cached pin-sense value */
22 unsigned int jack_detect:1; /* capable of jack-detection? */
23 unsigned int jack_dirty:1; /* needs to update? */
24 struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */
25#ifdef CONFIG_SND_HDA_INPUT_JACK
26 int type;
27 struct snd_jack *jack;
28#endif
29};
30
31struct hda_jack_tbl *
32snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid);
33struct hda_jack_tbl *
34snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag);
35
36struct hda_jack_tbl *
37snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid);
38void snd_hda_jack_tbl_clear(struct hda_codec *codec);
39
40/**
41 * snd_hda_jack_get_action - get jack-tbl entry for the tag
42 *
43 * Call this from the unsol event handler to get the assigned action for the
44 * event. This will mark the dirty flag for the later reporting, too.
45 */
46static inline unsigned char
47snd_hda_jack_get_action(struct hda_codec *codec, unsigned int tag)
48{
49 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
50 if (jack) {
51 jack->jack_dirty = 1;
52 return jack->action;
53 }
54 return 0;
55}
56
57void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
58
59int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
60 unsigned char action);
61
62u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
63int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
64
65static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
66{
67 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT))
68 return false;
69 if (!codec->ignore_misc_bit &&
70 (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
71 AC_DEFCFG_MISC_NO_PRESENCE))
72 return false;
73 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
74 return false;
75 return true;
76}
77
78int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
79 const char *name, int idx);
80int snd_hda_jack_add_kctls(struct hda_codec *codec,
81 const struct auto_pin_cfg *cfg);
82
83void snd_hda_jack_report_sync(struct hda_codec *codec);
84
85
86#endif /* __SOUND_HDA_JACK_H */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 618ddad1723..aca8d3193b9 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -394,11 +394,12 @@ struct auto_pin_cfg_item {
394}; 394};
395 395
396struct auto_pin_cfg; 396struct auto_pin_cfg;
397const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
398 int check_location);
399const char *hda_get_autocfg_input_label(struct hda_codec *codec, 397const char *hda_get_autocfg_input_label(struct hda_codec *codec,
400 const struct auto_pin_cfg *cfg, 398 const struct auto_pin_cfg *cfg,
401 int input); 399 int input);
400int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
401 const struct auto_pin_cfg *cfg,
402 char *label, int maxlen, int *indexp);
402int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, 403int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
403 int index, int *type_index_ret); 404 int index, int *type_index_ret);
404 405
@@ -487,7 +488,12 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
487} 488}
488 489
489/* get the widget type from widget capability bits */ 490/* get the widget type from widget capability bits */
490#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT) 491static inline int get_wcaps_type(unsigned int wcaps)
492{
493 if (!wcaps)
494 return -1; /* invalid type */
495 return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
496}
491 497
492static inline unsigned int get_wcaps_channels(u32 wcaps) 498static inline unsigned int get_wcaps_channels(u32 wcaps)
493{ 499{
@@ -505,21 +511,6 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
505u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid); 511u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
506int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid, 512int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
507 unsigned int caps); 513 unsigned int caps);
508u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
509int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
510
511static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
512{
513 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT))
514 return false;
515 if (!codec->ignore_misc_bit &&
516 (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
517 AC_DEFCFG_MISC_NO_PRESENCE))
518 return false;
519 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
520 return false;
521 return true;
522}
523 514
524/* flags for hda_nid_item */ 515/* flags for hda_nid_item */
525#define HDA_NID_ITEM_AMP (1<<0) 516#define HDA_NID_ITEM_AMP (1<<0)
@@ -688,28 +679,4 @@ static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
688#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 679#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
689void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen); 680void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
690 681
691/*
692 * Input-jack notification support
693 */
694#ifdef CONFIG_SND_HDA_INPUT_JACK
695int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
696 const char *name);
697void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid);
698void snd_hda_input_jack_free(struct hda_codec *codec);
699#else /* CONFIG_SND_HDA_INPUT_JACK */
700static inline int snd_hda_input_jack_add(struct hda_codec *codec,
701 hda_nid_t nid, int type,
702 const char *name)
703{
704 return 0;
705}
706static inline void snd_hda_input_jack_report(struct hda_codec *codec,
707 hda_nid_t nid)
708{
709}
710static inline void snd_hda_input_jack_free(struct hda_codec *codec)
711{
712}
713#endif /* CONFIG_SND_HDA_INPUT_JACK */
714
715#endif /* __SOUND_HDA_LOCAL_H */ 682#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 2c981b55940..254ab520460 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -54,6 +54,8 @@ static const char *get_wid_type_name(unsigned int wid_value)
54 [AC_WID_BEEP] = "Beep Generator Widget", 54 [AC_WID_BEEP] = "Beep Generator Widget",
55 [AC_WID_VENDOR] = "Vendor Defined Widget", 55 [AC_WID_VENDOR] = "Vendor Defined Widget",
56 }; 56 };
57 if (wid_value == -1)
58 return "UNKNOWN Widget";
57 wid_value &= 0xf; 59 wid_value &= 0xf;
58 if (names[wid_value]) 60 if (names[wid_value])
59 return names[wid_value]; 61 return names[wid_value];
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index bcb3310c394..9cb14b42dff 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -29,6 +29,7 @@
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_beep.h" 31#include "hda_beep.h"
32#include "hda_jack.h"
32 33
33struct ad198x_spec { 34struct ad198x_spec {
34 const struct snd_kcontrol_new *mixers[6]; 35 const struct snd_kcontrol_new *mixers[6];
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c
index 993757b6573..09ccfabb4a1 100644
--- a/sound/pci/hda/patch_ca0110.c
+++ b/sound/pci/hda/patch_ca0110.c
@@ -41,7 +41,7 @@ struct ca0110_spec {
41 hda_nid_t dig_out; 41 hda_nid_t dig_out;
42 hda_nid_t dig_in; 42 hda_nid_t dig_in;
43 unsigned int num_inputs; 43 unsigned int num_inputs;
44 const char *input_labels[AUTO_PIN_LAST]; 44 char input_labels[AUTO_PIN_LAST][32];
45 struct hda_pcm pcm_rec[2]; /* PCM information */ 45 struct hda_pcm pcm_rec[2]; /* PCM information */
46}; 46};
47 47
@@ -476,7 +476,9 @@ static void parse_input(struct hda_codec *codec)
476 if (j >= cfg->num_inputs) 476 if (j >= cfg->num_inputs)
477 continue; 477 continue;
478 spec->input_pins[n] = pin; 478 spec->input_pins[n] = pin;
479 spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1); 479 snd_hda_get_pin_label(codec, pin, cfg,
480 spec->input_labels[n],
481 sizeof(spec->input_labels[n]), NULL);
480 spec->adcs[n] = nid; 482 spec->adcs[n] = nid;
481 n++; 483 n++;
482 } 484 }
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 70a7abda7e2..0e99357e822 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -26,6 +26,7 @@
26#include <sound/core.h> 26#include <sound/core.h>
27#include "hda_codec.h" 27#include "hda_codec.h"
28#include "hda_local.h" 28#include "hda_local.h"
29#include "hda_jack.h"
29#include <sound/tlv.h> 30#include <sound/tlv.h>
30 31
31/* 32/*
@@ -78,6 +79,7 @@ enum {
78 CS420X_MBP53, 79 CS420X_MBP53,
79 CS420X_MBP55, 80 CS420X_MBP55,
80 CS420X_IMAC27, 81 CS420X_IMAC27,
82 CS420X_IMAC27_122,
81 CS420X_APPLE, 83 CS420X_APPLE,
82 CS420X_AUTO, 84 CS420X_AUTO,
83 CS420X_MODELS 85 CS420X_MODELS
@@ -137,7 +139,7 @@ enum {
137*/ 139*/
138#define CS4210_DAC_NID 0x02 140#define CS4210_DAC_NID 0x02
139#define CS4210_ADC_NID 0x03 141#define CS4210_ADC_NID 0x03
140#define CS421X_VENDOR_NID 0x0B 142#define CS4210_VENDOR_NID 0x0B
141#define CS421X_DMIC_PIN_NID 0x09 /* Port E */ 143#define CS421X_DMIC_PIN_NID 0x09 /* Port E */
142#define CS421X_SPDIF_PIN_NID 0x0A /* Port H */ 144#define CS421X_SPDIF_PIN_NID 0x0A /* Port H */
143 145
@@ -148,6 +150,10 @@ enum {
148 150
149#define SPDIF_EVENT 0x04 151#define SPDIF_EVENT 0x04
150 152
153/* Cirrus Logic CS4213 is like CS4210 but does not have SPDIF input/output */
154#define CS4213_VENDOR_NID 0x09
155
156
151static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx) 157static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
152{ 158{
153 struct cs_spec *spec = codec->spec; 159 struct cs_spec *spec = codec->spec;
@@ -721,8 +727,9 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol,
721 if (uinfo->value.enumerated.item >= spec->num_inputs) 727 if (uinfo->value.enumerated.item >= spec->num_inputs)
722 uinfo->value.enumerated.item = spec->num_inputs - 1; 728 uinfo->value.enumerated.item = spec->num_inputs - 1;
723 idx = spec->input_idx[uinfo->value.enumerated.item]; 729 idx = spec->input_idx[uinfo->value.enumerated.item];
724 strcpy(uinfo->value.enumerated.name, 730 snd_hda_get_pin_label(codec, cfg->inputs[idx].pin, cfg,
725 hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1)); 731 uinfo->value.enumerated.name,
732 sizeof(uinfo->value.enumerated.name), NULL);
726 return 0; 733 return 0;
727} 734}
728 735
@@ -920,16 +927,14 @@ static void cs_automute(struct hda_codec *codec)
920 927
921 /* mute speakers if spdif or hp jack is plugged in */ 928 /* mute speakers if spdif or hp jack is plugged in */
922 for (i = 0; i < cfg->speaker_outs; i++) { 929 for (i = 0; i < cfg->speaker_outs; i++) {
930 int pin_ctl = hp_present ? 0 : PIN_OUT;
931 /* detect on spdif is specific to CS4210 */
932 if (spdif_present && (spec->vendor_nid == CS4210_VENDOR_NID))
933 pin_ctl = 0;
934
923 nid = cfg->speaker_pins[i]; 935 nid = cfg->speaker_pins[i];
924 snd_hda_codec_write(codec, nid, 0, 936 snd_hda_codec_write(codec, nid, 0,
925 AC_VERB_SET_PIN_WIDGET_CONTROL, 937 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_ctl);
926 hp_present ? 0 : PIN_OUT);
927 /* detect on spdif is specific to CS421x */
928 if (spec->vendor_nid == CS421X_VENDOR_NID) {
929 snd_hda_codec_write(codec, nid, 0,
930 AC_VERB_SET_PIN_WIDGET_CONTROL,
931 spdif_present ? 0 : PIN_OUT);
932 }
933 } 938 }
934 if (spec->gpio_eapd_hp) { 939 if (spec->gpio_eapd_hp) {
935 unsigned int gpio = hp_present ? 940 unsigned int gpio = hp_present ?
@@ -938,8 +943,8 @@ static void cs_automute(struct hda_codec *codec)
938 AC_VERB_SET_GPIO_DATA, gpio); 943 AC_VERB_SET_GPIO_DATA, gpio);
939 } 944 }
940 945
941 /* specific to CS421x */ 946 /* specific to CS4210 */
942 if (spec->vendor_nid == CS421X_VENDOR_NID) { 947 if (spec->vendor_nid == CS4210_VENDOR_NID) {
943 /* mute HPs if spdif jack (SENSE_B) is present */ 948 /* mute HPs if spdif jack (SENSE_B) is present */
944 for (i = 0; i < cfg->hp_outs; i++) { 949 for (i = 0; i < cfg->hp_outs; i++) {
945 nid = cfg->hp_pins[i]; 950 nid = cfg->hp_pins[i];
@@ -976,7 +981,12 @@ static void cs_automic(struct hda_codec *codec)
976 present = snd_hda_jack_detect(codec, nid); 981 present = snd_hda_jack_detect(codec, nid);
977 982
978 /* specific to CS421x, single ADC */ 983 /* specific to CS421x, single ADC */
979 if (spec->vendor_nid == CS421X_VENDOR_NID) { 984 if (spec->vendor_nid == CS420X_VENDOR_NID) {
985 if (present)
986 change_cur_input(codec, spec->automic_idx, 0);
987 else
988 change_cur_input(codec, !spec->automic_idx, 0);
989 } else {
980 if (present) { 990 if (present) {
981 spec->last_input = spec->cur_input; 991 spec->last_input = spec->cur_input;
982 spec->cur_input = spec->automic_idx; 992 spec->cur_input = spec->automic_idx;
@@ -984,11 +994,6 @@ static void cs_automic(struct hda_codec *codec)
984 spec->cur_input = spec->last_input; 994 spec->cur_input = spec->last_input;
985 } 995 }
986 cs_update_input_select(codec); 996 cs_update_input_select(codec);
987 } else {
988 if (present)
989 change_cur_input(codec, spec->automic_idx, 0);
990 else
991 change_cur_input(codec, !spec->automic_idx, 0);
992 } 997 }
993} 998}
994 999
@@ -1027,9 +1032,7 @@ static void init_output(struct hda_codec *codec)
1027 if (!cfg->speaker_outs) 1032 if (!cfg->speaker_outs)
1028 continue; 1033 continue;
1029 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 1034 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1030 snd_hda_codec_write(codec, nid, 0, 1035 snd_hda_jack_detect_enable(codec, nid, HP_EVENT);
1031 AC_VERB_SET_UNSOLICITED_ENABLE,
1032 AC_USRSP_EN | HP_EVENT);
1033 spec->hp_detect = 1; 1036 spec->hp_detect = 1;
1034 } 1037 }
1035 } 1038 }
@@ -1070,19 +1073,10 @@ static void init_input(struct hda_codec *codec)
1070 AC_VERB_SET_AMP_GAIN_MUTE, 1073 AC_VERB_SET_AMP_GAIN_MUTE,
1071 AMP_IN_MUTE(spec->adc_idx[i])); 1074 AMP_IN_MUTE(spec->adc_idx[i]));
1072 if (spec->mic_detect && spec->automic_idx == i) 1075 if (spec->mic_detect && spec->automic_idx == i)
1073 snd_hda_codec_write(codec, pin, 0, 1076 snd_hda_jack_detect_enable(codec, pin, MIC_EVENT);
1074 AC_VERB_SET_UNSOLICITED_ENABLE,
1075 AC_USRSP_EN | MIC_EVENT);
1076 } 1077 }
1077 /* specific to CS421x */ 1078 /* CS420x has multiple ADC, CS421x has single ADC */
1078 if (spec->vendor_nid == CS421X_VENDOR_NID) { 1079 if (spec->vendor_nid == CS420X_VENDOR_NID) {
1079 if (spec->mic_detect)
1080 cs_automic(codec);
1081 else {
1082 spec->cur_adc = spec->adc_nid[spec->cur_input];
1083 cs_update_input_select(codec);
1084 }
1085 } else {
1086 change_cur_input(codec, spec->cur_input, 1); 1080 change_cur_input(codec, spec->cur_input, 1);
1087 if (spec->mic_detect) 1081 if (spec->mic_detect)
1088 cs_automic(codec); 1082 cs_automic(codec);
@@ -1096,6 +1090,13 @@ static void init_input(struct hda_codec *codec)
1096 * selected in IDX_SPDIF_CTL. 1090 * selected in IDX_SPDIF_CTL.
1097 */ 1091 */
1098 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); 1092 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef);
1093 } else {
1094 if (spec->mic_detect)
1095 cs_automic(codec);
1096 else {
1097 spec->cur_adc = spec->adc_nid[spec->cur_input];
1098 cs_update_input_select(codec);
1099 }
1099 } 1100 }
1100} 1101}
1101 1102
@@ -1200,11 +1201,14 @@ static int cs_init(struct hda_codec *codec)
1200 init_output(codec); 1201 init_output(codec);
1201 init_input(codec); 1202 init_input(codec);
1202 init_digital(codec); 1203 init_digital(codec);
1204 snd_hda_jack_report_sync(codec);
1205
1203 return 0; 1206 return 0;
1204} 1207}
1205 1208
1206static int cs_build_controls(struct hda_codec *codec) 1209static int cs_build_controls(struct hda_codec *codec)
1207{ 1210{
1211 struct cs_spec *spec = codec->spec;
1208 int err; 1212 int err;
1209 1213
1210 err = build_output(codec); 1214 err = build_output(codec);
@@ -1219,7 +1223,15 @@ static int cs_build_controls(struct hda_codec *codec)
1219 err = build_digital_input(codec); 1223 err = build_digital_input(codec);
1220 if (err < 0) 1224 if (err < 0)
1221 return err; 1225 return err;
1222 return cs_init(codec); 1226 err = cs_init(codec);
1227 if (err < 0)
1228 return err;
1229
1230 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1231 if (err < 0)
1232 return err;
1233
1234 return 0;
1223} 1235}
1224 1236
1225static void cs_free(struct hda_codec *codec) 1237static void cs_free(struct hda_codec *codec)
@@ -1232,7 +1244,7 @@ static void cs_free(struct hda_codec *codec)
1232 1244
1233static void cs_unsol_event(struct hda_codec *codec, unsigned int res) 1245static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
1234{ 1246{
1235 switch ((res >> 26) & 0x7f) { 1247 switch (snd_hda_jack_get_action(codec, res >> 26)) {
1236 case HP_EVENT: 1248 case HP_EVENT:
1237 cs_automute(codec); 1249 cs_automute(codec);
1238 break; 1250 break;
@@ -1240,6 +1252,7 @@ static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
1240 cs_automic(codec); 1252 cs_automic(codec);
1241 break; 1253 break;
1242 } 1254 }
1255 snd_hda_jack_report_sync(codec);
1243} 1256}
1244 1257
1245static const struct hda_codec_ops cs_patch_ops = { 1258static const struct hda_codec_ops cs_patch_ops = {
@@ -1278,6 +1291,7 @@ static const char * const cs420x_models[CS420X_MODELS] = {
1278 [CS420X_MBP53] = "mbp53", 1291 [CS420X_MBP53] = "mbp53",
1279 [CS420X_MBP55] = "mbp55", 1292 [CS420X_MBP55] = "mbp55",
1280 [CS420X_IMAC27] = "imac27", 1293 [CS420X_IMAC27] = "imac27",
1294 [CS420X_IMAC27_122] = "imac27_122",
1281 [CS420X_APPLE] = "apple", 1295 [CS420X_APPLE] = "apple",
1282 [CS420X_AUTO] = "auto", 1296 [CS420X_AUTO] = "auto",
1283}; 1297};
@@ -1294,6 +1308,7 @@ static const struct snd_pci_quirk cs420x_cfg_tbl[] = {
1294}; 1308};
1295 1309
1296static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = { 1310static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = {
1311 SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
1297 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE), 1312 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
1298 {} /* terminator */ 1313 {} /* terminator */
1299}; 1314};
@@ -1393,6 +1408,12 @@ static int patch_cs420x(struct hda_codec *codec)
1393 spec->gpio_mask = spec->gpio_dir = 1408 spec->gpio_mask = spec->gpio_dir =
1394 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; 1409 spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
1395 break; 1410 break;
1411 case CS420X_IMAC27_122:
1412 spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */
1413 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
1414 spec->gpio_mask = spec->gpio_dir =
1415 spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
1416 break;
1396 } 1417 }
1397 1418
1398 err = cs_parse_auto_config(codec); 1419 err = cs_parse_auto_config(codec);
@@ -1557,7 +1578,7 @@ static const struct snd_kcontrol_new cs421x_speaker_bost_ctl = {
1557 .tlv = { .p = cs421x_speaker_boost_db_scale }, 1578 .tlv = { .p = cs421x_speaker_boost_db_scale },
1558}; 1579};
1559 1580
1560static void cs421x_pinmux_init(struct hda_codec *codec) 1581static void cs4210_pinmux_init(struct hda_codec *codec)
1561{ 1582{
1562 struct cs_spec *spec = codec->spec; 1583 struct cs_spec *spec = codec->spec;
1563 unsigned int def_conf, coef; 1584 unsigned int def_conf, coef;
@@ -1602,10 +1623,7 @@ static void init_cs421x_digital(struct hda_codec *codec)
1602 if (!cfg->speaker_outs) 1623 if (!cfg->speaker_outs)
1603 continue; 1624 continue;
1604 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 1625 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1605 1626 snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT);
1606 snd_hda_codec_write(codec, nid, 0,
1607 AC_VERB_SET_UNSOLICITED_ENABLE,
1608 AC_USRSP_EN | SPDIF_EVENT);
1609 spec->spdif_detect = 1; 1627 spec->spdif_detect = 1;
1610 } 1628 }
1611 } 1629 }
@@ -1615,10 +1633,11 @@ static int cs421x_init(struct hda_codec *codec)
1615{ 1633{
1616 struct cs_spec *spec = codec->spec; 1634 struct cs_spec *spec = codec->spec;
1617 1635
1618 snd_hda_sequence_write(codec, cs421x_coef_init_verbs); 1636 if (spec->vendor_nid == CS4210_VENDOR_NID) {
1619 snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes); 1637 snd_hda_sequence_write(codec, cs421x_coef_init_verbs);
1620 1638 snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes);
1621 cs421x_pinmux_init(codec); 1639 cs4210_pinmux_init(codec);
1640 }
1622 1641
1623 if (spec->gpio_mask) { 1642 if (spec->gpio_mask) {
1624 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, 1643 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
@@ -1632,6 +1651,7 @@ static int cs421x_init(struct hda_codec *codec)
1632 init_output(codec); 1651 init_output(codec);
1633 init_input(codec); 1652 init_input(codec);
1634 init_cs421x_digital(codec); 1653 init_cs421x_digital(codec);
1654 snd_hda_jack_report_sync(codec);
1635 1655
1636 return 0; 1656 return 0;
1637} 1657}
@@ -1771,32 +1791,21 @@ static int build_cs421x_output(struct hda_codec *codec)
1771 struct auto_pin_cfg *cfg = &spec->autocfg; 1791 struct auto_pin_cfg *cfg = &spec->autocfg;
1772 struct snd_kcontrol *kctl; 1792 struct snd_kcontrol *kctl;
1773 int err; 1793 int err;
1774 char *name = "HP/Speakers"; 1794 char *name = "Master";
1775 1795
1776 fix_volume_caps(codec, dac); 1796 fix_volume_caps(codec, dac);
1777 if (!spec->vmaster_sw) {
1778 err = add_vmaster(codec, dac);
1779 if (err < 0)
1780 return err;
1781 }
1782 1797
1783 err = add_mute(codec, name, 0, 1798 err = add_mute(codec, name, 0,
1784 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); 1799 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl);
1785 if (err < 0) 1800 if (err < 0)
1786 return err; 1801 return err;
1787 err = snd_ctl_add_slave(spec->vmaster_sw, kctl);
1788 if (err < 0)
1789 return err;
1790 1802
1791 err = add_volume(codec, name, 0, 1803 err = add_volume(codec, name, 0,
1792 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); 1804 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl);
1793 if (err < 0) 1805 if (err < 0)
1794 return err; 1806 return err;
1795 err = snd_ctl_add_slave(spec->vmaster_vol, kctl);
1796 if (err < 0)
1797 return err;
1798 1807
1799 if (cfg->speaker_outs) { 1808 if (cfg->speaker_outs && (spec->vendor_nid == CS4210_VENDOR_NID)) {
1800 err = snd_hda_ctl_add(codec, 0, 1809 err = snd_hda_ctl_add(codec, 0,
1801 snd_ctl_new1(&cs421x_speaker_bost_ctl, codec)); 1810 snd_ctl_new1(&cs421x_speaker_bost_ctl, codec));
1802 if (err < 0) 1811 if (err < 0)
@@ -1807,6 +1816,7 @@ static int build_cs421x_output(struct hda_codec *codec)
1807 1816
1808static int cs421x_build_controls(struct hda_codec *codec) 1817static int cs421x_build_controls(struct hda_codec *codec)
1809{ 1818{
1819 struct cs_spec *spec = codec->spec;
1810 int err; 1820 int err;
1811 1821
1812 err = build_cs421x_output(codec); 1822 err = build_cs421x_output(codec);
@@ -1818,12 +1828,20 @@ static int cs421x_build_controls(struct hda_codec *codec)
1818 err = build_digital_output(codec); 1828 err = build_digital_output(codec);
1819 if (err < 0) 1829 if (err < 0)
1820 return err; 1830 return err;
1821 return cs421x_init(codec); 1831 err = cs421x_init(codec);
1832 if (err < 0)
1833 return err;
1834
1835 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1836 if (err < 0)
1837 return err;
1838
1839 return 0;
1822} 1840}
1823 1841
1824static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res) 1842static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res)
1825{ 1843{
1826 switch ((res >> 26) & 0x3f) { 1844 switch (snd_hda_jack_get_action(codec, res >> 26)) {
1827 case HP_EVENT: 1845 case HP_EVENT:
1828 case SPDIF_EVENT: 1846 case SPDIF_EVENT:
1829 cs_automute(codec); 1847 cs_automute(codec);
@@ -1833,6 +1851,7 @@ static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res)
1833 cs_automic(codec); 1851 cs_automic(codec);
1834 break; 1852 break;
1835 } 1853 }
1854 snd_hda_jack_report_sync(codec);
1836} 1855}
1837 1856
1838static int parse_cs421x_input(struct hda_codec *codec) 1857static int parse_cs421x_input(struct hda_codec *codec)
@@ -1883,6 +1902,7 @@ static int cs421x_parse_auto_config(struct hda_codec *codec)
1883*/ 1902*/
1884static int cs421x_suspend(struct hda_codec *codec, pm_message_t state) 1903static int cs421x_suspend(struct hda_codec *codec, pm_message_t state)
1885{ 1904{
1905 struct cs_spec *spec = codec->spec;
1886 unsigned int coef; 1906 unsigned int coef;
1887 1907
1888 snd_hda_shutup_pins(codec); 1908 snd_hda_shutup_pins(codec);
@@ -1892,15 +1912,17 @@ static int cs421x_suspend(struct hda_codec *codec, pm_message_t state)
1892 snd_hda_codec_write(codec, CS4210_ADC_NID, 0, 1912 snd_hda_codec_write(codec, CS4210_ADC_NID, 0,
1893 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 1913 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
1894 1914
1895 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); 1915 if (spec->vendor_nid == CS4210_VENDOR_NID) {
1896 coef |= 0x0004; /* PDREF */ 1916 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
1897 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); 1917 coef |= 0x0004; /* PDREF */
1918 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
1919 }
1898 1920
1899 return 0; 1921 return 0;
1900} 1922}
1901#endif 1923#endif
1902 1924
1903static struct hda_codec_ops cs4210_patch_ops = { 1925static struct hda_codec_ops cs421x_patch_ops = {
1904 .build_controls = cs421x_build_controls, 1926 .build_controls = cs421x_build_controls,
1905 .build_pcms = cs_build_pcms, 1927 .build_pcms = cs_build_pcms,
1906 .init = cs421x_init, 1928 .init = cs421x_init,
@@ -1911,7 +1933,7 @@ static struct hda_codec_ops cs4210_patch_ops = {
1911#endif 1933#endif
1912}; 1934};
1913 1935
1914static int patch_cs421x(struct hda_codec *codec) 1936static int patch_cs4210(struct hda_codec *codec)
1915{ 1937{
1916 struct cs_spec *spec; 1938 struct cs_spec *spec;
1917 int err; 1939 int err;
@@ -1921,7 +1943,7 @@ static int patch_cs421x(struct hda_codec *codec)
1921 return -ENOMEM; 1943 return -ENOMEM;
1922 codec->spec = spec; 1944 codec->spec = spec;
1923 1945
1924 spec->vendor_nid = CS421X_VENDOR_NID; 1946 spec->vendor_nid = CS4210_VENDOR_NID;
1925 1947
1926 spec->board_config = 1948 spec->board_config =
1927 snd_hda_check_board_config(codec, CS421X_MODELS, 1949 snd_hda_check_board_config(codec, CS421X_MODELS,
@@ -1949,14 +1971,39 @@ static int patch_cs421x(struct hda_codec *codec)
1949 is auto-parsed. If GPIO or SENSE_B is forced, DMIC input 1971 is auto-parsed. If GPIO or SENSE_B is forced, DMIC input
1950 is disabled. 1972 is disabled.
1951 */ 1973 */
1952 cs421x_pinmux_init(codec); 1974 cs4210_pinmux_init(codec);
1953 1975
1954 err = cs421x_parse_auto_config(codec); 1976 err = cs421x_parse_auto_config(codec);
1955 if (err < 0) 1977 if (err < 0)
1956 goto error; 1978 goto error;
1957 1979
1958 codec->patch_ops = cs4210_patch_ops; 1980 codec->patch_ops = cs421x_patch_ops;
1981
1982 return 0;
1983
1984 error:
1985 kfree(codec->spec);
1986 codec->spec = NULL;
1987 return err;
1988}
1989
1990static int patch_cs4213(struct hda_codec *codec)
1991{
1992 struct cs_spec *spec;
1993 int err;
1994
1995 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1996 if (!spec)
1997 return -ENOMEM;
1998 codec->spec = spec;
1999
2000 spec->vendor_nid = CS4213_VENDOR_NID;
2001
2002 err = cs421x_parse_auto_config(codec);
2003 if (err < 0)
2004 goto error;
1959 2005
2006 codec->patch_ops = cs421x_patch_ops;
1960 return 0; 2007 return 0;
1961 2008
1962 error: 2009 error:
@@ -1972,13 +2019,15 @@ static int patch_cs421x(struct hda_codec *codec)
1972static const struct hda_codec_preset snd_hda_preset_cirrus[] = { 2019static const struct hda_codec_preset snd_hda_preset_cirrus[] = {
1973 { .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x }, 2020 { .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x },
1974 { .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x }, 2021 { .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x },
1975 { .id = 0x10134210, .name = "CS4210", .patch = patch_cs421x }, 2022 { .id = 0x10134210, .name = "CS4210", .patch = patch_cs4210 },
2023 { .id = 0x10134213, .name = "CS4213", .patch = patch_cs4213 },
1976 {} /* terminator */ 2024 {} /* terminator */
1977}; 2025};
1978 2026
1979MODULE_ALIAS("snd-hda-codec-id:10134206"); 2027MODULE_ALIAS("snd-hda-codec-id:10134206");
1980MODULE_ALIAS("snd-hda-codec-id:10134207"); 2028MODULE_ALIAS("snd-hda-codec-id:10134207");
1981MODULE_ALIAS("snd-hda-codec-id:10134210"); 2029MODULE_ALIAS("snd-hda-codec-id:10134210");
2030MODULE_ALIAS("snd-hda-codec-id:10134213");
1982 2031
1983MODULE_LICENSE("GPL"); 2032MODULE_LICENSE("GPL");
1984MODULE_DESCRIPTION("Cirrus Logic HD-audio codec"); 2033MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 0de21193a2b..8a32a69c83c 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -31,6 +31,7 @@
31#include "hda_codec.h" 31#include "hda_codec.h"
32#include "hda_local.h" 32#include "hda_local.h"
33#include "hda_beep.h" 33#include "hda_beep.h"
34#include "hda_jack.h"
34 35
35#define CXT_PIN_DIR_IN 0x00 36#define CXT_PIN_DIR_IN 0x00
36#define CXT_PIN_DIR_OUT 0x01 37#define CXT_PIN_DIR_OUT 0x01
@@ -415,40 +416,6 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
415 &spec->cur_mux[adc_idx]); 416 &spec->cur_mux[adc_idx]);
416} 417}
417 418
418static int conexant_init_jacks(struct hda_codec *codec)
419{
420#ifdef CONFIG_SND_HDA_INPUT_JACK
421 struct conexant_spec *spec = codec->spec;
422 int i;
423
424 for (i = 0; i < spec->num_init_verbs; i++) {
425 const struct hda_verb *hv;
426
427 hv = spec->init_verbs[i];
428 while (hv->nid) {
429 int err = 0;
430 switch (hv->param ^ AC_USRSP_EN) {
431 case CONEXANT_HP_EVENT:
432 err = snd_hda_input_jack_add(codec, hv->nid,
433 SND_JACK_HEADPHONE, NULL);
434 snd_hda_input_jack_report(codec, hv->nid);
435 break;
436 case CXT5051_PORTC_EVENT:
437 case CONEXANT_MIC_EVENT:
438 err = snd_hda_input_jack_add(codec, hv->nid,
439 SND_JACK_MICROPHONE, NULL);
440 snd_hda_input_jack_report(codec, hv->nid);
441 break;
442 }
443 if (err < 0)
444 return err;
445 ++hv;
446 }
447 }
448#endif /* CONFIG_SND_HDA_INPUT_JACK */
449 return 0;
450}
451
452static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 419static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg,
453 unsigned int power_state) 420 unsigned int power_state)
454{ 421{
@@ -474,7 +441,6 @@ static int conexant_init(struct hda_codec *codec)
474 441
475static void conexant_free(struct hda_codec *codec) 442static void conexant_free(struct hda_codec *codec)
476{ 443{
477 snd_hda_input_jack_free(codec);
478 snd_hda_detach_beep_device(codec); 444 snd_hda_detach_beep_device(codec);
479 kfree(codec->spec); 445 kfree(codec->spec);
480} 446}
@@ -1120,8 +1086,6 @@ static const char * const cxt5045_models[CXT5045_MODELS] = {
1120 1086
1121static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 1087static const struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1122 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 1088 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
1123 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1124 CXT5045_LAPTOP_HPSENSE),
1125 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 1089 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
1126 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 1090 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
1127 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 1091 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
@@ -1750,7 +1714,6 @@ static void cxt5051_hp_automute(struct hda_codec *codec)
1750static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1714static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1751 unsigned int res) 1715 unsigned int res)
1752{ 1716{
1753 int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
1754 switch (res >> 26) { 1717 switch (res >> 26) {
1755 case CONEXANT_HP_EVENT: 1718 case CONEXANT_HP_EVENT:
1756 cxt5051_hp_automute(codec); 1719 cxt5051_hp_automute(codec);
@@ -1762,7 +1725,6 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1762 cxt5051_portc_automic(codec); 1725 cxt5051_portc_automic(codec);
1763 break; 1726 break;
1764 } 1727 }
1765 snd_hda_input_jack_report(codec, nid);
1766} 1728}
1767 1729
1768static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1730static const struct snd_kcontrol_new cxt5051_playback_mixers[] = {
@@ -1901,8 +1863,6 @@ static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid,
1901 snd_hda_codec_write(codec, nid, 0, 1863 snd_hda_codec_write(codec, nid, 0,
1902 AC_VERB_SET_UNSOLICITED_ENABLE, 1864 AC_VERB_SET_UNSOLICITED_ENABLE,
1903 AC_USRSP_EN | event); 1865 AC_USRSP_EN | event);
1904 snd_hda_input_jack_add(codec, nid, SND_JACK_MICROPHONE, NULL);
1905 snd_hda_input_jack_report(codec, nid);
1906} 1866}
1907 1867
1908static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1868static const struct hda_verb cxt5051_ideapad_init_verbs[] = {
@@ -1918,7 +1878,6 @@ static int cxt5051_init(struct hda_codec *codec)
1918 struct conexant_spec *spec = codec->spec; 1878 struct conexant_spec *spec = codec->spec;
1919 1879
1920 conexant_init(codec); 1880 conexant_init(codec);
1921 conexant_init_jacks(codec);
1922 1881
1923 if (spec->auto_mic & AUTO_MIC_PORTB) 1882 if (spec->auto_mic & AUTO_MIC_PORTB)
1924 cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 1883 cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT);
@@ -3450,7 +3409,6 @@ static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
3450 hda_nid_t nid = pins[i]; 3409 hda_nid_t nid = pins[i];
3451 if (!nid || !is_jack_detectable(codec, nid)) 3410 if (!nid || !is_jack_detectable(codec, nid))
3452 break; 3411 break;
3453 snd_hda_input_jack_report(codec, nid);
3454 present |= snd_hda_jack_detect(codec, nid); 3412 present |= snd_hda_jack_detect(codec, nid);
3455 } 3413 }
3456 return present; 3414 return present;
@@ -3755,8 +3713,7 @@ static void cx_auto_automic(struct hda_codec *codec)
3755 3713
3756static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) 3714static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res)
3757{ 3715{
3758 int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; 3716 switch (snd_hda_jack_get_action(codec, res >> 26)) {
3759 switch (res >> 26) {
3760 case CONEXANT_HP_EVENT: 3717 case CONEXANT_HP_EVENT:
3761 cx_auto_hp_automute(codec); 3718 cx_auto_hp_automute(codec);
3762 break; 3719 break;
@@ -3765,9 +3722,9 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res)
3765 break; 3722 break;
3766 case CONEXANT_MIC_EVENT: 3723 case CONEXANT_MIC_EVENT:
3767 cx_auto_automic(codec); 3724 cx_auto_automic(codec);
3768 snd_hda_input_jack_report(codec, nid);
3769 break; 3725 break;
3770 } 3726 }
3727 snd_hda_jack_report_sync(codec);
3771} 3728}
3772 3729
3773/* check whether the pin config is suitable for auto-mic switching; 3730/* check whether the pin config is suitable for auto-mic switching;
@@ -3979,13 +3936,11 @@ static void mute_outputs(struct hda_codec *codec, int num_nids,
3979} 3936}
3980 3937
3981static void enable_unsol_pins(struct hda_codec *codec, int num_pins, 3938static void enable_unsol_pins(struct hda_codec *codec, int num_pins,
3982 hda_nid_t *pins, unsigned int tag) 3939 hda_nid_t *pins, unsigned int action)
3983{ 3940{
3984 int i; 3941 int i;
3985 for (i = 0; i < num_pins; i++) 3942 for (i = 0; i < num_pins; i++)
3986 snd_hda_codec_write(codec, pins[i], 0, 3943 snd_hda_jack_detect_enable(codec, pins[i], action);
3987 AC_VERB_SET_UNSOLICITED_ENABLE,
3988 AC_USRSP_EN | tag);
3989} 3944}
3990 3945
3991static void cx_auto_init_output(struct hda_codec *codec) 3946static void cx_auto_init_output(struct hda_codec *codec)
@@ -4060,16 +4015,14 @@ static void cx_auto_init_input(struct hda_codec *codec)
4060 4015
4061 if (spec->auto_mic) { 4016 if (spec->auto_mic) {
4062 if (spec->auto_mic_ext >= 0) { 4017 if (spec->auto_mic_ext >= 0) {
4063 snd_hda_codec_write(codec, 4018 snd_hda_jack_detect_enable(codec,
4064 cfg->inputs[spec->auto_mic_ext].pin, 0, 4019 cfg->inputs[spec->auto_mic_ext].pin,
4065 AC_VERB_SET_UNSOLICITED_ENABLE, 4020 CONEXANT_MIC_EVENT);
4066 AC_USRSP_EN | CONEXANT_MIC_EVENT);
4067 } 4021 }
4068 if (spec->auto_mic_dock >= 0) { 4022 if (spec->auto_mic_dock >= 0) {
4069 snd_hda_codec_write(codec, 4023 snd_hda_jack_detect_enable(codec,
4070 cfg->inputs[spec->auto_mic_dock].pin, 0, 4024 cfg->inputs[spec->auto_mic_dock].pin,
4071 AC_VERB_SET_UNSOLICITED_ENABLE, 4025 CONEXANT_MIC_EVENT);
4072 AC_USRSP_EN | CONEXANT_MIC_EVENT);
4073 } 4026 }
4074 cx_auto_automic(codec); 4027 cx_auto_automic(codec);
4075 } else { 4028 } else {
@@ -4097,6 +4050,7 @@ static int cx_auto_init(struct hda_codec *codec)
4097 cx_auto_init_output(codec); 4050 cx_auto_init_output(codec);
4098 cx_auto_init_input(codec); 4051 cx_auto_init_input(codec);
4099 cx_auto_init_digital(codec); 4052 cx_auto_init_digital(codec);
4053 snd_hda_jack_report_sync(codec);
4100 return 0; 4054 return 0;
4101} 4055}
4102 4056
@@ -4326,6 +4280,7 @@ static int cx_auto_build_input_controls(struct hda_codec *codec)
4326 4280
4327static int cx_auto_build_controls(struct hda_codec *codec) 4281static int cx_auto_build_controls(struct hda_codec *codec)
4328{ 4282{
4283 struct conexant_spec *spec = codec->spec;
4329 int err; 4284 int err;
4330 4285
4331 err = cx_auto_build_output_controls(codec); 4286 err = cx_auto_build_output_controls(codec);
@@ -4334,7 +4289,13 @@ static int cx_auto_build_controls(struct hda_codec *codec)
4334 err = cx_auto_build_input_controls(codec); 4289 err = cx_auto_build_input_controls(codec);
4335 if (err < 0) 4290 if (err < 0)
4336 return err; 4291 return err;
4337 return conexant_build_controls(codec); 4292 err = conexant_build_controls(codec);
4293 if (err < 0)
4294 return err;
4295 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
4296 if (err < 0)
4297 return err;
4298 return 0;
4338} 4299}
4339 4300
4340static int cx_auto_search_adcs(struct hda_codec *codec) 4301static int cx_auto_search_adcs(struct hda_codec *codec)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index c505fd5d338..1168ebd3fb5 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -36,6 +36,7 @@
36#include <sound/jack.h> 36#include <sound/jack.h>
37#include "hda_codec.h" 37#include "hda_codec.h"
38#include "hda_local.h" 38#include "hda_local.h"
39#include "hda_jack.h"
39 40
40static bool static_hdmi_pcm; 41static bool static_hdmi_pcm;
41module_param(static_hdmi_pcm, bool, 0644); 42module_param(static_hdmi_pcm, bool, 0644);
@@ -48,8 +49,8 @@ MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
48 * 49 *
49 * The HDA correspondence of pipes/ports are converter/pin nodes. 50 * The HDA correspondence of pipes/ports are converter/pin nodes.
50 */ 51 */
51#define MAX_HDMI_CVTS 4 52#define MAX_HDMI_CVTS 8
52#define MAX_HDMI_PINS 4 53#define MAX_HDMI_PINS 8
53 54
54struct hdmi_spec_per_cvt { 55struct hdmi_spec_per_cvt {
55 hda_nid_t cvt_nid; 56 hda_nid_t cvt_nid;
@@ -754,10 +755,18 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
754static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 755static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
755{ 756{
756 struct hdmi_spec *spec = codec->spec; 757 struct hdmi_spec *spec = codec->spec;
757 int pin_nid = res >> AC_UNSOL_RES_TAG_SHIFT; 758 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
759 int pin_nid;
758 int pd = !!(res & AC_UNSOL_RES_PD); 760 int pd = !!(res & AC_UNSOL_RES_PD);
759 int eldv = !!(res & AC_UNSOL_RES_ELDV); 761 int eldv = !!(res & AC_UNSOL_RES_ELDV);
760 int pin_idx; 762 int pin_idx;
763 struct hda_jack_tbl *jack;
764
765 jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
766 if (!jack)
767 return;
768 pin_nid = jack->nid;
769 jack->jack_dirty = 1;
761 770
762 printk(KERN_INFO 771 printk(KERN_INFO
763 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 772 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
@@ -768,6 +777,7 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
768 return; 777 return;
769 778
770 hdmi_present_sense(&spec->pins[pin_idx], 1); 779 hdmi_present_sense(&spec->pins[pin_idx], 1);
780 snd_hda_jack_report_sync(codec);
771} 781}
772 782
773static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) 783static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -795,11 +805,10 @@ static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
795 805
796static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) 806static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
797{ 807{
798 struct hdmi_spec *spec = codec->spec;
799 int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 808 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
800 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; 809 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
801 810
802 if (pin_nid_to_pin_index(spec, tag) < 0) { 811 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) {
803 snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); 812 snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
804 return; 813 return;
805 } 814 }
@@ -996,8 +1005,6 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
996 msecs_to_jiffies(300)); 1005 msecs_to_jiffies(300));
997 } 1006 }
998 } 1007 }
999
1000 snd_hda_input_jack_report(codec, pin_nid);
1001} 1008}
1002 1009
1003static void hdmi_repoll_eld(struct work_struct *work) 1010static void hdmi_repoll_eld(struct work_struct *work)
@@ -1126,12 +1133,12 @@ static int hdmi_parse_codec(struct hda_codec *codec)
1126 1133
1127/* 1134/*
1128 */ 1135 */
1129static char *generic_hdmi_pcm_names[MAX_HDMI_PINS] = { 1136static char *get_hdmi_pcm_name(int idx)
1130 "HDMI 0", 1137{
1131 "HDMI 1", 1138 static char names[MAX_HDMI_PINS][8];
1132 "HDMI 2", 1139 sprintf(&names[idx][0], "HDMI %d", idx);
1133 "HDMI 3", 1140 return &names[idx][0];
1134}; 1141}
1135 1142
1136/* 1143/*
1137 * HDMI callbacks 1144 * HDMI callbacks
@@ -1209,7 +1216,7 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
1209 struct hda_pcm_stream *pstr; 1216 struct hda_pcm_stream *pstr;
1210 1217
1211 info = &spec->pcm_rec[pin_idx]; 1218 info = &spec->pcm_rec[pin_idx];
1212 info->name = generic_hdmi_pcm_names[pin_idx]; 1219 info->name = get_hdmi_pcm_name(pin_idx);
1213 info->pcm_type = HDA_PCM_TYPE_HDMI; 1220 info->pcm_type = HDA_PCM_TYPE_HDMI;
1214 1221
1215 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; 1222 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
@@ -1226,21 +1233,15 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
1226 1233
1227static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx) 1234static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
1228{ 1235{
1229 int err; 1236 char hdmi_str[32] = "HDMI/DP";
1230 char hdmi_str[32];
1231 struct hdmi_spec *spec = codec->spec; 1237 struct hdmi_spec *spec = codec->spec;
1232 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; 1238 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
1233 int pcmdev = spec->pcm_rec[pin_idx].device; 1239 int pcmdev = spec->pcm_rec[pin_idx].device;
1234 1240
1235 snprintf(hdmi_str, sizeof(hdmi_str), "HDMI/DP,pcm=%d", pcmdev); 1241 if (pcmdev > 0)
1236 1242 sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
1237 err = snd_hda_input_jack_add(codec, per_pin->pin_nid,
1238 SND_JACK_VIDEOOUT, pcmdev > 0 ? hdmi_str : NULL);
1239 if (err < 0)
1240 return err;
1241 1243
1242 hdmi_present_sense(per_pin, 0); 1244 return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, 0);
1243 return 0;
1244} 1245}
1245 1246
1246static int generic_hdmi_build_controls(struct hda_codec *codec) 1247static int generic_hdmi_build_controls(struct hda_codec *codec)
@@ -1270,6 +1271,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
1270 1271
1271 if (err < 0) 1272 if (err < 0)
1272 return err; 1273 return err;
1274
1275 hdmi_present_sense(per_pin, 0);
1273 } 1276 }
1274 1277
1275 return 0; 1278 return 0;
@@ -1286,14 +1289,13 @@ static int generic_hdmi_init(struct hda_codec *codec)
1286 struct hdmi_eld *eld = &per_pin->sink_eld; 1289 struct hdmi_eld *eld = &per_pin->sink_eld;
1287 1290
1288 hdmi_init_pin(codec, pin_nid); 1291 hdmi_init_pin(codec, pin_nid);
1289 snd_hda_codec_write(codec, pin_nid, 0, 1292 snd_hda_jack_detect_enable(codec, pin_nid, pin_nid);
1290 AC_VERB_SET_UNSOLICITED_ENABLE,
1291 AC_USRSP_EN | pin_nid);
1292 1293
1293 per_pin->codec = codec; 1294 per_pin->codec = codec;
1294 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); 1295 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld);
1295 snd_hda_eld_proc_new(codec, eld, pin_idx); 1296 snd_hda_eld_proc_new(codec, eld, pin_idx);
1296 } 1297 }
1298 snd_hda_jack_report_sync(codec);
1297 return 0; 1299 return 0;
1298} 1300}
1299 1301
@@ -1309,7 +1311,6 @@ static void generic_hdmi_free(struct hda_codec *codec)
1309 cancel_delayed_work(&per_pin->work); 1311 cancel_delayed_work(&per_pin->work);
1310 snd_hda_eld_proc_free(codec, eld); 1312 snd_hda_eld_proc_free(codec, eld);
1311 } 1313 }
1312 snd_hda_input_jack_free(codec);
1313 1314
1314 flush_workqueue(codec->bus->workq); 1315 flush_workqueue(codec->bus->workq);
1315 kfree(spec); 1316 kfree(spec);
@@ -1364,7 +1365,7 @@ static int simple_playback_build_pcms(struct hda_codec *codec)
1364 chans = get_wcaps(codec, spec->cvts[i].cvt_nid); 1365 chans = get_wcaps(codec, spec->cvts[i].cvt_nid);
1365 chans = get_wcaps_channels(chans); 1366 chans = get_wcaps_channels(chans);
1366 1367
1367 info->name = generic_hdmi_pcm_names[i]; 1368 info->name = get_hdmi_pcm_name(i);
1368 info->pcm_type = HDA_PCM_TYPE_HDMI; 1369 info->pcm_type = HDA_PCM_TYPE_HDMI;
1369 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; 1370 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
1370 snd_BUG_ON(!spec->pcm_playback); 1371 snd_BUG_ON(!spec->pcm_playback);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 1d07e8fa243..5e82acf77c5 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -33,6 +33,7 @@
33#include "hda_codec.h" 33#include "hda_codec.h"
34#include "hda_local.h" 34#include "hda_local.h"
35#include "hda_beep.h" 35#include "hda_beep.h"
36#include "hda_jack.h"
36 37
37/* unsol event tags */ 38/* unsol event tags */
38#define ALC_FRONT_EVENT 0x01 39#define ALC_FRONT_EVENT 0x01
@@ -183,6 +184,8 @@ struct alc_spec {
183 unsigned int single_input_src:1; 184 unsigned int single_input_src:1;
184 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ 185 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
185 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ 186 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
187 unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */
188 unsigned int use_jack_tbl:1; /* 1 for model=auto */
186 189
187 /* auto-mute control */ 190 /* auto-mute control */
188 int automute_mode; 191 int automute_mode;
@@ -283,6 +286,8 @@ static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
283 spec->capsrc_nids[idx] : spec->adc_nids[idx]; 286 spec->capsrc_nids[idx] : spec->adc_nids[idx];
284} 287}
285 288
289static void call_update_outputs(struct hda_codec *codec);
290
286/* select the given imux item; either unmute exclusively or select the route */ 291/* select the given imux item; either unmute exclusively or select the route */
287static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, 292static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
288 unsigned int idx, bool force) 293 unsigned int idx, bool force)
@@ -306,6 +311,19 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
306 return 0; 311 return 0;
307 spec->cur_mux[adc_idx] = idx; 312 spec->cur_mux[adc_idx] = idx;
308 313
314 /* for shared I/O, change the pin-control accordingly */
315 if (spec->shared_mic_hp) {
316 /* NOTE: this assumes that there are only two inputs, the
317 * first is the real internal mic and the second is HP jack.
318 */
319 snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0,
320 AC_VERB_SET_PIN_WIDGET_CONTROL,
321 spec->cur_mux[adc_idx] ?
322 PIN_VREF80 : PIN_HP);
323 spec->automute_speaker = !spec->cur_mux[adc_idx];
324 call_update_outputs(codec);
325 }
326
309 if (spec->dyn_adc_switch) { 327 if (spec->dyn_adc_switch) {
310 alc_dyn_adc_pcm_resetup(codec, idx); 328 alc_dyn_adc_pcm_resetup(codec, idx);
311 adc_idx = spec->dyn_adc_idx[idx]; 329 adc_idx = spec->dyn_adc_idx[idx];
@@ -450,46 +468,6 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
450} 468}
451 469
452/* 470/*
453 * Jack-reporting via input-jack layer
454 */
455
456/* initialization of jacks; currently checks only a few known pins */
457static int alc_init_jacks(struct hda_codec *codec)
458{
459#ifdef CONFIG_SND_HDA_INPUT_JACK
460 struct alc_spec *spec = codec->spec;
461 int err;
462 unsigned int hp_nid = spec->autocfg.hp_pins[0];
463 unsigned int mic_nid = spec->ext_mic_pin;
464 unsigned int dock_nid = spec->dock_mic_pin;
465
466 if (hp_nid) {
467 err = snd_hda_input_jack_add(codec, hp_nid,
468 SND_JACK_HEADPHONE, NULL);
469 if (err < 0)
470 return err;
471 snd_hda_input_jack_report(codec, hp_nid);
472 }
473
474 if (mic_nid) {
475 err = snd_hda_input_jack_add(codec, mic_nid,
476 SND_JACK_MICROPHONE, NULL);
477 if (err < 0)
478 return err;
479 snd_hda_input_jack_report(codec, mic_nid);
480 }
481 if (dock_nid) {
482 err = snd_hda_input_jack_add(codec, dock_nid,
483 SND_JACK_MICROPHONE, NULL);
484 if (err < 0)
485 return err;
486 snd_hda_input_jack_report(codec, dock_nid);
487 }
488#endif /* CONFIG_SND_HDA_INPUT_JACK */
489 return 0;
490}
491
492/*
493 * Jack detections for HP auto-mute and mic-switch 471 * Jack detections for HP auto-mute and mic-switch
494 */ 472 */
495 473
@@ -502,7 +480,6 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
502 hda_nid_t nid = pins[i]; 480 hda_nid_t nid = pins[i];
503 if (!nid) 481 if (!nid)
504 break; 482 break;
505 snd_hda_input_jack_report(codec, nid);
506 present |= snd_hda_jack_detect(codec, nid); 483 present |= snd_hda_jack_detect(codec, nid);
507 } 484 }
508 return present; 485 return present;
@@ -554,7 +531,8 @@ static void update_outputs(struct hda_codec *codec)
554 * in general, HP pins/amps control should be enabled in all cases, 531 * in general, HP pins/amps control should be enabled in all cases,
555 * but currently set only for master_mute, just to be safe 532 * but currently set only for master_mute, just to be safe
556 */ 533 */
557 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 534 if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */
535 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
558 spec->autocfg.hp_pins, spec->master_mute, true); 536 spec->autocfg.hp_pins, spec->master_mute, true);
559 537
560 if (!spec->automute_speaker) 538 if (!spec->automute_speaker)
@@ -641,19 +619,18 @@ static void alc_mic_automute(struct hda_codec *codec)
641 alc_mux_select(codec, 0, spec->dock_mic_idx, false); 619 alc_mux_select(codec, 0, spec->dock_mic_idx, false);
642 else 620 else
643 alc_mux_select(codec, 0, spec->int_mic_idx, false); 621 alc_mux_select(codec, 0, spec->int_mic_idx, false);
644
645 snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]);
646 if (spec->dock_mic_idx >= 0)
647 snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]);
648} 622}
649 623
650/* unsolicited event for HP jack sensing */ 624/* unsolicited event for HP jack sensing */
651static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 625static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
652{ 626{
627 struct alc_spec *spec = codec->spec;
653 if (codec->vendor_id == 0x10ec0880) 628 if (codec->vendor_id == 0x10ec0880)
654 res >>= 28; 629 res >>= 28;
655 else 630 else
656 res >>= 26; 631 res >>= 26;
632 if (spec->use_jack_tbl)
633 res = snd_hda_jack_get_action(codec, res);
657 switch (res) { 634 switch (res) {
658 case ALC_HP_EVENT: 635 case ALC_HP_EVENT:
659 alc_hp_automute(codec); 636 alc_hp_automute(codec);
@@ -665,6 +642,7 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
665 alc_mic_automute(codec); 642 alc_mic_automute(codec);
666 break; 643 break;
667 } 644 }
645 snd_hda_jack_report_sync(codec);
668} 646}
669 647
670/* call init functions of standard auto-mute helpers */ 648/* call init functions of standard auto-mute helpers */
@@ -954,9 +932,7 @@ static void alc_init_automute(struct hda_codec *codec)
954 continue; 932 continue;
955 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", 933 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
956 nid); 934 nid);
957 snd_hda_codec_write_cache(codec, nid, 0, 935 snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT);
958 AC_VERB_SET_UNSOLICITED_ENABLE,
959 AC_USRSP_EN | ALC_HP_EVENT);
960 spec->detect_hp = 1; 936 spec->detect_hp = 1;
961 } 937 }
962 938
@@ -968,9 +944,8 @@ static void alc_init_automute(struct hda_codec *codec)
968 continue; 944 continue;
969 snd_printdd("realtek: Enable Line-Out " 945 snd_printdd("realtek: Enable Line-Out "
970 "auto-muting on NID 0x%x\n", nid); 946 "auto-muting on NID 0x%x\n", nid);
971 snd_hda_codec_write_cache(codec, nid, 0, 947 snd_hda_jack_detect_enable(codec, nid,
972 AC_VERB_SET_UNSOLICITED_ENABLE, 948 ALC_FRONT_EVENT);
973 AC_USRSP_EN | ALC_FRONT_EVENT);
974 spec->detect_lo = 1; 949 spec->detect_lo = 1;
975 } 950 }
976 spec->automute_lo_possible = spec->detect_hp; 951 spec->automute_lo_possible = spec->detect_hp;
@@ -1109,13 +1084,10 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1109 return false; /* no corresponding imux */ 1084 return false; /* no corresponding imux */
1110 } 1085 }
1111 1086
1112 snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0, 1087 snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT);
1113 AC_VERB_SET_UNSOLICITED_ENABLE,
1114 AC_USRSP_EN | ALC_MIC_EVENT);
1115 if (spec->dock_mic_pin) 1088 if (spec->dock_mic_pin)
1116 snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0, 1089 snd_hda_jack_detect_enable(codec, spec->dock_mic_pin,
1117 AC_VERB_SET_UNSOLICITED_ENABLE, 1090 ALC_MIC_EVENT);
1118 AC_USRSP_EN | ALC_MIC_EVENT);
1119 1091
1120 spec->auto_mic_valid_imux = 1; 1092 spec->auto_mic_valid_imux = 1;
1121 spec->auto_mic = 1; 1093 spec->auto_mic = 1;
@@ -1133,6 +1105,9 @@ static void alc_init_auto_mic(struct hda_codec *codec)
1133 hda_nid_t fixed, ext, dock; 1105 hda_nid_t fixed, ext, dock;
1134 int i; 1106 int i;
1135 1107
1108 if (spec->shared_mic_hp)
1109 return; /* no auto-mic for the shared I/O */
1110
1136 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; 1111 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
1137 1112
1138 fixed = ext = dock = 0; 1113 fixed = ext = dock = 0;
@@ -1524,6 +1499,7 @@ static void alc_pick_fixup(struct hda_codec *codec,
1524 const struct alc_fixup *fixlist) 1499 const struct alc_fixup *fixlist)
1525{ 1500{
1526 struct alc_spec *spec = codec->spec; 1501 struct alc_spec *spec = codec->spec;
1502 const struct snd_pci_quirk *q;
1527 int id = -1; 1503 int id = -1;
1528 const char *name = NULL; 1504 const char *name = NULL;
1529 1505
@@ -1538,12 +1514,25 @@ static void alc_pick_fixup(struct hda_codec *codec,
1538 } 1514 }
1539 } 1515 }
1540 if (id < 0) { 1516 if (id < 0) {
1541 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1517 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1542 if (quirk) { 1518 if (q) {
1543 id = quirk->value; 1519 id = q->value;
1520#ifdef CONFIG_SND_DEBUG_VERBOSE
1521 name = q->name;
1522#endif
1523 }
1524 }
1525 if (id < 0) {
1526 for (q = quirk; q->subvendor; q++) {
1527 unsigned int vendorid =
1528 q->subdevice | (q->subvendor << 16);
1529 if (vendorid == codec->subsystem_id) {
1530 id = q->value;
1544#ifdef CONFIG_SND_DEBUG_VERBOSE 1531#ifdef CONFIG_SND_DEBUG_VERBOSE
1545 name = quirk->name; 1532 name = q->name;
1546#endif 1533#endif
1534 break;
1535 }
1547 } 1536 }
1548 } 1537 }
1549 1538
@@ -2040,6 +2029,10 @@ static int alc_build_controls(struct hda_codec *codec)
2040 2029
2041 alc_free_kctls(codec); /* no longer needed */ 2030 alc_free_kctls(codec); /* no longer needed */
2042 2031
2032 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
2033 if (err < 0)
2034 return err;
2035
2043 return 0; 2036 return 0;
2044} 2037}
2045 2038
@@ -2067,6 +2060,8 @@ static int alc_init(struct hda_codec *codec)
2067 2060
2068 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); 2061 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
2069 2062
2063 snd_hda_jack_report_sync(codec);
2064
2070 hda_call_check_power_status(codec, 0x01); 2065 hda_call_check_power_status(codec, 0x01);
2071 return 0; 2066 return 0;
2072} 2067}
@@ -2450,7 +2445,6 @@ static void alc_free(struct hda_codec *codec)
2450 return; 2445 return;
2451 2446
2452 alc_shutup(codec); 2447 alc_shutup(codec);
2453 snd_hda_input_jack_free(codec);
2454 alc_free_kctls(codec); 2448 alc_free_kctls(codec);
2455 alc_free_bind_ctls(codec); 2449 alc_free_bind_ctls(codec);
2456 kfree(spec); 2450 kfree(spec);
@@ -2685,6 +2679,9 @@ static int alc_auto_fill_adc_caps(struct hda_codec *codec)
2685 int max_nums = ARRAY_SIZE(spec->private_adc_nids); 2679 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
2686 int i, nums = 0; 2680 int i, nums = 0;
2687 2681
2682 if (spec->shared_mic_hp)
2683 max_nums = 1; /* no multi streams with the shared HP/mic */
2684
2688 nid = codec->start_nid; 2685 nid = codec->start_nid;
2689 for (i = 0; i < codec->num_nodes; i++, nid++) { 2686 for (i = 0; i < codec->num_nodes; i++, nid++) {
2690 hda_nid_t src; 2687 hda_nid_t src;
@@ -2747,6 +2744,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
2747 continue; 2744 continue;
2748 2745
2749 label = hda_get_autocfg_input_label(codec, cfg, i); 2746 label = hda_get_autocfg_input_label(codec, cfg, i);
2747 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
2748 label = "Headphone Mic";
2750 if (prev_label && !strcmp(label, prev_label)) 2749 if (prev_label && !strcmp(label, prev_label))
2751 type_idx++; 2750 type_idx++;
2752 else 2751 else
@@ -2781,6 +2780,39 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
2781 return 0; 2780 return 0;
2782} 2781}
2783 2782
2783/* create a shared input with the headphone out */
2784static int alc_auto_create_shared_input(struct hda_codec *codec)
2785{
2786 struct alc_spec *spec = codec->spec;
2787 struct auto_pin_cfg *cfg = &spec->autocfg;
2788 unsigned int defcfg;
2789 hda_nid_t nid;
2790
2791 /* only one internal input pin? */
2792 if (cfg->num_inputs != 1)
2793 return 0;
2794 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin);
2795 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
2796 return 0;
2797
2798 if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
2799 nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */
2800 else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT)
2801 nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */
2802 else
2803 return 0; /* both not available */
2804
2805 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
2806 return 0; /* no input */
2807
2808 cfg->inputs[1].pin = nid;
2809 cfg->inputs[1].type = AUTO_PIN_MIC;
2810 cfg->num_inputs = 2;
2811 spec->shared_mic_hp = 1;
2812 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid);
2813 return 0;
2814}
2815
2784static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 2816static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
2785 unsigned int pin_type) 2817 unsigned int pin_type)
2786{ 2818{
@@ -2919,6 +2951,23 @@ static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2919 return 0; 2951 return 0;
2920} 2952}
2921 2953
2954/* check whether the DAC is reachable from the pin */
2955static bool alc_auto_is_dac_reachable(struct hda_codec *codec,
2956 hda_nid_t pin, hda_nid_t dac)
2957{
2958 hda_nid_t srcs[5];
2959 int i, num;
2960
2961 pin = alc_go_down_to_selector(codec, pin);
2962 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2963 for (i = 0; i < num; i++) {
2964 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2965 if (nid == dac)
2966 return true;
2967 }
2968 return false;
2969}
2970
2922static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) 2971static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
2923{ 2972{
2924 hda_nid_t sel = alc_go_down_to_selector(codec, pin); 2973 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
@@ -2949,13 +2998,17 @@ static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2949} 2998}
2950 2999
2951static int alc_auto_fill_multi_ios(struct hda_codec *codec, 3000static int alc_auto_fill_multi_ios(struct hda_codec *codec,
2952 unsigned int location); 3001 unsigned int location, int offset);
3002static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3003 hda_nid_t pin, hda_nid_t dac);
2953 3004
2954/* fill in the dac_nids table from the parsed pin configuration */ 3005/* fill in the dac_nids table from the parsed pin configuration */
2955static int alc_auto_fill_dac_nids(struct hda_codec *codec) 3006static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2956{ 3007{
2957 struct alc_spec *spec = codec->spec; 3008 struct alc_spec *spec = codec->spec;
2958 struct auto_pin_cfg *cfg = &spec->autocfg; 3009 struct auto_pin_cfg *cfg = &spec->autocfg;
3010 unsigned int location, defcfg;
3011 int num_pins;
2959 bool redone = false; 3012 bool redone = false;
2960 int i; 3013 int i;
2961 3014
@@ -3010,13 +3063,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3010 3063
3011 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3064 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3012 /* try to fill multi-io first */ 3065 /* try to fill multi-io first */
3013 unsigned int location, defcfg;
3014 int num_pins;
3015
3016 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]); 3066 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
3017 location = get_defcfg_location(defcfg); 3067 location = get_defcfg_location(defcfg);
3018 3068
3019 num_pins = alc_auto_fill_multi_ios(codec, location); 3069 num_pins = alc_auto_fill_multi_ios(codec, location, 0);
3020 if (num_pins > 0) { 3070 if (num_pins > 0) {
3021 spec->multi_ios = num_pins; 3071 spec->multi_ios = num_pins;
3022 spec->ext_channel_count = 2; 3072 spec->ext_channel_count = 2;
@@ -3050,6 +3100,25 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3050 } 3100 }
3051 } 3101 }
3052 3102
3103 if (!spec->multi_ios &&
3104 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3105 cfg->hp_outs) {
3106 /* try multi-ios with HP + inputs */
3107 defcfg = snd_hda_codec_get_pincfg(codec, cfg->hp_pins[0]);
3108 location = get_defcfg_location(defcfg);
3109
3110 num_pins = alc_auto_fill_multi_ios(codec, location, 1);
3111 if (num_pins > 0) {
3112 spec->multi_ios = num_pins;
3113 spec->ext_channel_count = 2;
3114 spec->multiout.num_dacs = num_pins + 1;
3115 }
3116 }
3117
3118 if (cfg->line_out_pins[0])
3119 spec->vmaster_nid =
3120 alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0],
3121 spec->multiout.dac_nids[0]);
3053 return 0; 3122 return 0;
3054} 3123}
3055 3124
@@ -3081,8 +3150,15 @@ static int alc_auto_add_vol_ctl(struct hda_codec *codec,
3081 val); 3150 val);
3082} 3151}
3083 3152
3084#define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \ 3153static int alc_auto_add_stereo_vol(struct hda_codec *codec,
3085 alc_auto_add_vol_ctl(codec, pfx, cidx, nid, 3) 3154 const char *pfx, int cidx,
3155 hda_nid_t nid)
3156{
3157 int chs = 1;
3158 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3159 chs = 3;
3160 return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs);
3161}
3086 3162
3087/* create a mute-switch for the given mixer widget; 3163/* create a mute-switch for the given mixer widget;
3088 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute 3164 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
@@ -3114,8 +3190,14 @@ static int alc_auto_add_sw_ctl(struct hda_codec *codec,
3114 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); 3190 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
3115} 3191}
3116 3192
3117#define alc_auto_add_stereo_sw(codec, pfx, cidx, nid) \ 3193static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx,
3118 alc_auto_add_sw_ctl(codec, pfx, cidx, nid, 3) 3194 int cidx, hda_nid_t nid)
3195{
3196 int chs = 1;
3197 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3198 chs = 3;
3199 return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs);
3200}
3119 3201
3120static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, 3202static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
3121 hda_nid_t pin, hda_nid_t dac) 3203 hda_nid_t pin, hda_nid_t dac)
@@ -3441,17 +3523,19 @@ static void alc_auto_init_extra_out(struct hda_codec *codec)
3441 * multi-io helper 3523 * multi-io helper
3442 */ 3524 */
3443static int alc_auto_fill_multi_ios(struct hda_codec *codec, 3525static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3444 unsigned int location) 3526 unsigned int location,
3527 int offset)
3445{ 3528{
3446 struct alc_spec *spec = codec->spec; 3529 struct alc_spec *spec = codec->spec;
3447 struct auto_pin_cfg *cfg = &spec->autocfg; 3530 struct auto_pin_cfg *cfg = &spec->autocfg;
3448 hda_nid_t prime_dac = spec->private_dac_nids[0]; 3531 hda_nid_t prime_dac = spec->private_dac_nids[0];
3449 int type, i, num_pins = 0; 3532 int type, i, dacs, num_pins = 0;
3450 3533
3534 dacs = spec->multiout.num_dacs;
3451 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { 3535 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3452 for (i = 0; i < cfg->num_inputs; i++) { 3536 for (i = 0; i < cfg->num_inputs; i++) {
3453 hda_nid_t nid = cfg->inputs[i].pin; 3537 hda_nid_t nid = cfg->inputs[i].pin;
3454 hda_nid_t dac; 3538 hda_nid_t dac = 0;
3455 unsigned int defcfg, caps; 3539 unsigned int defcfg, caps;
3456 if (cfg->inputs[i].type != type) 3540 if (cfg->inputs[i].type != type)
3457 continue; 3541 continue;
@@ -3463,7 +3547,13 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3463 caps = snd_hda_query_pin_caps(codec, nid); 3547 caps = snd_hda_query_pin_caps(codec, nid);
3464 if (!(caps & AC_PINCAP_OUT)) 3548 if (!(caps & AC_PINCAP_OUT))
3465 continue; 3549 continue;
3466 dac = alc_auto_look_for_dac(codec, nid); 3550 if (offset && offset + num_pins < dacs) {
3551 dac = spec->private_dac_nids[offset + num_pins];
3552 if (!alc_auto_is_dac_reachable(codec, nid, dac))
3553 dac = 0;
3554 }
3555 if (!dac)
3556 dac = alc_auto_look_for_dac(codec, nid);
3467 if (!dac) 3557 if (!dac)
3468 continue; 3558 continue;
3469 spec->multi_io[num_pins].pin = nid; 3559 spec->multi_io[num_pins].pin = nid;
@@ -3472,11 +3562,11 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3472 spec->private_dac_nids[spec->multiout.num_dacs++] = dac; 3562 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
3473 } 3563 }
3474 } 3564 }
3475 spec->multiout.num_dacs = 1; 3565 spec->multiout.num_dacs = dacs;
3476 if (num_pins < 2) { 3566 if (num_pins < 2) {
3477 /* clear up again */ 3567 /* clear up again */
3478 memset(spec->private_dac_nids, 0, 3568 memset(spec->private_dac_nids + dacs, 0,
3479 sizeof(spec->private_dac_nids)); 3569 sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - dacs));
3480 spec->private_dac_nids[0] = prime_dac; 3570 spec->private_dac_nids[0] = prime_dac;
3481 return 0; 3571 return 0;
3482 } 3572 }
@@ -3700,6 +3790,8 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
3700 char boost_label[32]; 3790 char boost_label[32];
3701 3791
3702 label = hda_get_autocfg_input_label(codec, cfg, i); 3792 label = hda_get_autocfg_input_label(codec, cfg, i);
3793 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
3794 label = "Headphone Mic";
3703 if (prev_label && !strcmp(label, prev_label)) 3795 if (prev_label && !strcmp(label, prev_label))
3704 type_idx++; 3796 type_idx++;
3705 else 3797 else
@@ -3812,6 +3904,7 @@ static void set_capture_mixer(struct hda_codec *codec)
3812static void alc_auto_init_std(struct hda_codec *codec) 3904static void alc_auto_init_std(struct hda_codec *codec)
3813{ 3905{
3814 struct alc_spec *spec = codec->spec; 3906 struct alc_spec *spec = codec->spec;
3907 spec->use_jack_tbl = 1;
3815 alc_auto_init_multi_out(codec); 3908 alc_auto_init_multi_out(codec);
3816 alc_auto_init_extra_out(codec); 3909 alc_auto_init_extra_out(codec);
3817 alc_auto_init_analog_input(codec); 3910 alc_auto_init_analog_input(codec);
@@ -3904,6 +3997,9 @@ static int alc_parse_auto_config(struct hda_codec *codec,
3904 err = alc_auto_create_speaker_out(codec); 3997 err = alc_auto_create_speaker_out(codec);
3905 if (err < 0) 3998 if (err < 0)
3906 return err; 3999 return err;
4000 err = alc_auto_create_shared_input(codec);
4001 if (err < 0)
4002 return err;
3907 err = alc_auto_create_input_ctls(codec); 4003 err = alc_auto_create_input_ctls(codec);
3908 if (err < 0) 4004 if (err < 0)
3909 return err; 4005 return err;
@@ -3951,6 +4047,37 @@ static const struct hda_amp_list alc880_loopbacks[] = {
3951#endif 4047#endif
3952 4048
3953/* 4049/*
4050 * ALC880 fix-ups
4051 */
4052enum {
4053 ALC880_FIXUP_GPIO2,
4054 ALC880_FIXUP_MEDION_RIM,
4055};
4056
4057static const struct alc_fixup alc880_fixups[] = {
4058 [ALC880_FIXUP_GPIO2] = {
4059 .type = ALC_FIXUP_VERBS,
4060 .v.verbs = alc_gpio2_init_verbs,
4061 },
4062 [ALC880_FIXUP_MEDION_RIM] = {
4063 .type = ALC_FIXUP_VERBS,
4064 .v.verbs = (const struct hda_verb[]) {
4065 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4066 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4067 { }
4068 },
4069 .chained = true,
4070 .chain_id = ALC880_FIXUP_GPIO2,
4071 },
4072};
4073
4074static const struct snd_pci_quirk alc880_fixup_tbl[] = {
4075 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
4076 {}
4077};
4078
4079
4080/*
3954 * board setups 4081 * board setups
3955 */ 4082 */
3956#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 4083#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
@@ -3996,6 +4123,11 @@ static int patch_alc880(struct hda_codec *codec)
3996 } 4123 }
3997 4124
3998 if (board_config == ALC_MODEL_AUTO) { 4125 if (board_config == ALC_MODEL_AUTO) {
4126 alc_pick_fixup(codec, NULL, alc880_fixup_tbl, alc880_fixups);
4127 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4128 }
4129
4130 if (board_config == ALC_MODEL_AUTO) {
3999 /* automatic parse from the BIOS config */ 4131 /* automatic parse from the BIOS config */
4000 err = alc880_parse_auto_config(codec); 4132 err = alc880_parse_auto_config(codec);
4001 if (err < 0) 4133 if (err < 0)
@@ -4010,8 +4142,10 @@ static int patch_alc880(struct hda_codec *codec)
4010#endif 4142#endif
4011 } 4143 }
4012 4144
4013 if (board_config != ALC_MODEL_AUTO) 4145 if (board_config != ALC_MODEL_AUTO) {
4146 spec->vmaster_nid = 0x0c;
4014 setup_preset(codec, &alc880_presets[board_config]); 4147 setup_preset(codec, &alc880_presets[board_config]);
4148 }
4015 4149
4016 if (!spec->no_analog && !spec->adc_nids) { 4150 if (!spec->no_analog && !spec->adc_nids) {
4017 alc_auto_fill_adc_caps(codec); 4151 alc_auto_fill_adc_caps(codec);
@@ -4029,7 +4163,7 @@ static int patch_alc880(struct hda_codec *codec)
4029 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4163 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4030 } 4164 }
4031 4165
4032 spec->vmaster_nid = 0x0c; 4166 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4033 4167
4034 codec->patch_ops = alc_patch_ops; 4168 codec->patch_ops = alc_patch_ops;
4035 if (board_config == ALC_MODEL_AUTO) 4169 if (board_config == ALC_MODEL_AUTO)
@@ -4137,8 +4271,10 @@ static int patch_alc260(struct hda_codec *codec)
4137#endif 4271#endif
4138 } 4272 }
4139 4273
4140 if (board_config != ALC_MODEL_AUTO) 4274 if (board_config != ALC_MODEL_AUTO) {
4141 setup_preset(codec, &alc260_presets[board_config]); 4275 setup_preset(codec, &alc260_presets[board_config]);
4276 spec->vmaster_nid = 0x08;
4277 }
4142 4278
4143 if (!spec->no_analog && !spec->adc_nids) { 4279 if (!spec->no_analog && !spec->adc_nids) {
4144 alc_auto_fill_adc_caps(codec); 4280 alc_auto_fill_adc_caps(codec);
@@ -4158,8 +4294,6 @@ static int patch_alc260(struct hda_codec *codec)
4158 4294
4159 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4295 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4160 4296
4161 spec->vmaster_nid = 0x08;
4162
4163 codec->patch_ops = alc_patch_ops; 4297 codec->patch_ops = alc_patch_ops;
4164 if (board_config == ALC_MODEL_AUTO) 4298 if (board_config == ALC_MODEL_AUTO)
4165 spec->init_hook = alc_auto_init_std; 4299 spec->init_hook = alc_auto_init_std;
@@ -4196,15 +4330,78 @@ static int patch_alc260(struct hda_codec *codec)
4196 * Pin config fixes 4330 * Pin config fixes
4197 */ 4331 */
4198enum { 4332enum {
4199 PINFIX_ABIT_AW9D_MAX, 4333 ALC882_FIXUP_ABIT_AW9D_MAX,
4200 PINFIX_LENOVO_Y530, 4334 ALC882_FIXUP_LENOVO_Y530,
4201 PINFIX_PB_M5210, 4335 ALC882_FIXUP_PB_M5210,
4202 PINFIX_ACER_ASPIRE_7736, 4336 ALC882_FIXUP_ACER_ASPIRE_7736,
4203 PINFIX_ASUS_W90V, 4337 ALC882_FIXUP_ASUS_W90V,
4338 ALC889_FIXUP_VAIO_TT,
4339 ALC888_FIXUP_EEE1601,
4340 ALC882_FIXUP_EAPD,
4341 ALC883_FIXUP_EAPD,
4342 ALC883_FIXUP_ACER_EAPD,
4343 ALC882_FIXUP_GPIO3,
4344 ALC889_FIXUP_COEF,
4345 ALC882_FIXUP_ASUS_W2JC,
4346 ALC882_FIXUP_ACER_ASPIRE_4930G,
4347 ALC882_FIXUP_ACER_ASPIRE_8930G,
4348 ALC882_FIXUP_ASPIRE_8930G_VERBS,
4349 ALC885_FIXUP_MACPRO_GPIO,
4204}; 4350};
4205 4351
4352static void alc889_fixup_coef(struct hda_codec *codec,
4353 const struct alc_fixup *fix, int action)
4354{
4355 if (action != ALC_FIXUP_ACT_INIT)
4356 return;
4357 alc889_coef_init(codec);
4358}
4359
4360/* toggle speaker-output according to the hp-jack state */
4361static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4362{
4363 unsigned int gpiostate, gpiomask, gpiodir;
4364
4365 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4366 AC_VERB_GET_GPIO_DATA, 0);
4367
4368 if (!muted)
4369 gpiostate |= (1 << pin);
4370 else
4371 gpiostate &= ~(1 << pin);
4372
4373 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4374 AC_VERB_GET_GPIO_MASK, 0);
4375 gpiomask |= (1 << pin);
4376
4377 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4378 AC_VERB_GET_GPIO_DIRECTION, 0);
4379 gpiodir |= (1 << pin);
4380
4381
4382 snd_hda_codec_write(codec, codec->afg, 0,
4383 AC_VERB_SET_GPIO_MASK, gpiomask);
4384 snd_hda_codec_write(codec, codec->afg, 0,
4385 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4386
4387 msleep(1);
4388
4389 snd_hda_codec_write(codec, codec->afg, 0,
4390 AC_VERB_SET_GPIO_DATA, gpiostate);
4391}
4392
4393/* set up GPIO at initialization */
4394static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
4395 const struct alc_fixup *fix, int action)
4396{
4397 if (action != ALC_FIXUP_ACT_INIT)
4398 return;
4399 alc882_gpio_mute(codec, 0, 0);
4400 alc882_gpio_mute(codec, 1, 0);
4401}
4402
4206static const struct alc_fixup alc882_fixups[] = { 4403static const struct alc_fixup alc882_fixups[] = {
4207 [PINFIX_ABIT_AW9D_MAX] = { 4404 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
4208 .type = ALC_FIXUP_PINS, 4405 .type = ALC_FIXUP_PINS,
4209 .v.pins = (const struct alc_pincfg[]) { 4406 .v.pins = (const struct alc_pincfg[]) {
4210 { 0x15, 0x01080104 }, /* side */ 4407 { 0x15, 0x01080104 }, /* side */
@@ -4213,7 +4410,7 @@ static const struct alc_fixup alc882_fixups[] = {
4213 { } 4410 { }
4214 } 4411 }
4215 }, 4412 },
4216 [PINFIX_LENOVO_Y530] = { 4413 [ALC882_FIXUP_LENOVO_Y530] = {
4217 .type = ALC_FIXUP_PINS, 4414 .type = ALC_FIXUP_PINS,
4218 .v.pins = (const struct alc_pincfg[]) { 4415 .v.pins = (const struct alc_pincfg[]) {
4219 { 0x15, 0x99130112 }, /* rear int speakers */ 4416 { 0x15, 0x99130112 }, /* rear int speakers */
@@ -4221,32 +4418,180 @@ static const struct alc_fixup alc882_fixups[] = {
4221 { } 4418 { }
4222 } 4419 }
4223 }, 4420 },
4224 [PINFIX_PB_M5210] = { 4421 [ALC882_FIXUP_PB_M5210] = {
4225 .type = ALC_FIXUP_VERBS, 4422 .type = ALC_FIXUP_VERBS,
4226 .v.verbs = (const struct hda_verb[]) { 4423 .v.verbs = (const struct hda_verb[]) {
4227 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 4424 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4228 {} 4425 {}
4229 } 4426 }
4230 }, 4427 },
4231 [PINFIX_ACER_ASPIRE_7736] = { 4428 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
4232 .type = ALC_FIXUP_SKU, 4429 .type = ALC_FIXUP_SKU,
4233 .v.sku = ALC_FIXUP_SKU_IGNORE, 4430 .v.sku = ALC_FIXUP_SKU_IGNORE,
4234 }, 4431 },
4235 [PINFIX_ASUS_W90V] = { 4432 [ALC882_FIXUP_ASUS_W90V] = {
4236 .type = ALC_FIXUP_PINS, 4433 .type = ALC_FIXUP_PINS,
4237 .v.pins = (const struct alc_pincfg[]) { 4434 .v.pins = (const struct alc_pincfg[]) {
4238 { 0x16, 0x99130110 }, /* fix sequence for CLFE */ 4435 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
4239 { } 4436 { }
4240 } 4437 }
4241 }, 4438 },
4439 [ALC889_FIXUP_VAIO_TT] = {
4440 .type = ALC_FIXUP_PINS,
4441 .v.pins = (const struct alc_pincfg[]) {
4442 { 0x17, 0x90170111 }, /* hidden surround speaker */
4443 { }
4444 }
4445 },
4446 [ALC888_FIXUP_EEE1601] = {
4447 .type = ALC_FIXUP_VERBS,
4448 .v.verbs = (const struct hda_verb[]) {
4449 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4450 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
4451 { }
4452 }
4453 },
4454 [ALC882_FIXUP_EAPD] = {
4455 .type = ALC_FIXUP_VERBS,
4456 .v.verbs = (const struct hda_verb[]) {
4457 /* change to EAPD mode */
4458 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4459 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4460 { }
4461 }
4462 },
4463 [ALC883_FIXUP_EAPD] = {
4464 .type = ALC_FIXUP_VERBS,
4465 .v.verbs = (const struct hda_verb[]) {
4466 /* change to EAPD mode */
4467 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4468 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4469 { }
4470 }
4471 },
4472 [ALC883_FIXUP_ACER_EAPD] = {
4473 .type = ALC_FIXUP_VERBS,
4474 .v.verbs = (const struct hda_verb[]) {
4475 /* eanable EAPD on Acer laptops */
4476 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4477 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4478 { }
4479 }
4480 },
4481 [ALC882_FIXUP_GPIO3] = {
4482 .type = ALC_FIXUP_VERBS,
4483 .v.verbs = alc_gpio3_init_verbs,
4484 },
4485 [ALC882_FIXUP_ASUS_W2JC] = {
4486 .type = ALC_FIXUP_VERBS,
4487 .v.verbs = alc_gpio1_init_verbs,
4488 .chained = true,
4489 .chain_id = ALC882_FIXUP_EAPD,
4490 },
4491 [ALC889_FIXUP_COEF] = {
4492 .type = ALC_FIXUP_FUNC,
4493 .v.func = alc889_fixup_coef,
4494 },
4495 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
4496 .type = ALC_FIXUP_PINS,
4497 .v.pins = (const struct alc_pincfg[]) {
4498 { 0x16, 0x99130111 }, /* CLFE speaker */
4499 { 0x17, 0x99130112 }, /* surround speaker */
4500 { }
4501 }
4502 },
4503 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
4504 .type = ALC_FIXUP_PINS,
4505 .v.pins = (const struct alc_pincfg[]) {
4506 { 0x16, 0x99130111 }, /* CLFE speaker */
4507 { 0x1b, 0x99130112 }, /* surround speaker */
4508 { }
4509 },
4510 .chained = true,
4511 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
4512 },
4513 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
4514 /* additional init verbs for Acer Aspire 8930G */
4515 .type = ALC_FIXUP_VERBS,
4516 .v.verbs = (const struct hda_verb[]) {
4517 /* Enable all DACs */
4518 /* DAC DISABLE/MUTE 1? */
4519 /* setting bits 1-5 disables DAC nids 0x02-0x06
4520 * apparently. Init=0x38 */
4521 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
4522 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4523 /* DAC DISABLE/MUTE 2? */
4524 /* some bit here disables the other DACs.
4525 * Init=0x4900 */
4526 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
4527 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4528 /* DMIC fix
4529 * This laptop has a stereo digital microphone.
4530 * The mics are only 1cm apart which makes the stereo
4531 * useless. However, either the mic or the ALC889
4532 * makes the signal become a difference/sum signal
4533 * instead of standard stereo, which is annoying.
4534 * So instead we flip this bit which makes the
4535 * codec replicate the sum signal to both channels,
4536 * turning it into a normal mono mic.
4537 */
4538 /* DMIC_CONTROL? Init value = 0x0001 */
4539 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4540 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
4541 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4542 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4543 { }
4544 }
4545 },
4546 [ALC885_FIXUP_MACPRO_GPIO] = {
4547 .type = ALC_FIXUP_FUNC,
4548 .v.func = alc885_fixup_macpro_gpio,
4549 },
4242}; 4550};
4243 4551
4244static const struct snd_pci_quirk alc882_fixup_tbl[] = { 4552static const struct snd_pci_quirk alc882_fixup_tbl[] = {
4245 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), 4553 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
4246 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", PINFIX_ASUS_W90V), 4554 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4247 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), 4555 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
4248 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 4556 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4249 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), 4557 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
4558 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
4559 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
4560 ALC882_FIXUP_ACER_ASPIRE_4930G),
4561 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
4562 ALC882_FIXUP_ACER_ASPIRE_4930G),
4563 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
4564 ALC882_FIXUP_ACER_ASPIRE_8930G),
4565 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
4566 ALC882_FIXUP_ACER_ASPIRE_8930G),
4567 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
4568 ALC882_FIXUP_ACER_ASPIRE_4930G),
4569 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
4570 ALC882_FIXUP_ACER_ASPIRE_4930G),
4571 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
4572 ALC882_FIXUP_ACER_ASPIRE_4930G),
4573 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
4574 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
4575 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
4576 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
4577 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
4578 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
4579 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
4580
4581 /* All Apple entries are in codec SSIDs */
4582 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
4583 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
4584 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
4585 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
4586 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
4587
4588 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
4589 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
4590 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
4591 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
4592 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
4593 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
4594 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
4250 {} 4595 {}
4251}; 4596};
4252 4597
@@ -4295,8 +4640,7 @@ static int patch_alc882(struct hda_codec *codec)
4295 goto error; 4640 goto error;
4296 4641
4297 board_config = alc_board_config(codec, ALC882_MODEL_LAST, 4642 board_config = alc_board_config(codec, ALC882_MODEL_LAST,
4298 alc882_models, alc882_cfg_tbl); 4643 alc882_models, NULL);
4299
4300 if (board_config < 0) 4644 if (board_config < 0)
4301 board_config = alc_board_codec_sid_config(codec, 4645 board_config = alc_board_codec_sid_config(codec,
4302 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl); 4646 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
@@ -4319,18 +4663,12 @@ static int patch_alc882(struct hda_codec *codec)
4319 err = alc882_parse_auto_config(codec); 4663 err = alc882_parse_auto_config(codec);
4320 if (err < 0) 4664 if (err < 0)
4321 goto error; 4665 goto error;
4322#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4323 else if (!err) {
4324 printk(KERN_INFO
4325 "hda_codec: Cannot set up configuration "
4326 "from BIOS. Using base mode...\n");
4327 board_config = ALC882_3ST_DIG;
4328 }
4329#endif
4330 } 4666 }
4331 4667
4332 if (board_config != ALC_MODEL_AUTO) 4668 if (board_config != ALC_MODEL_AUTO) {
4333 setup_preset(codec, &alc882_presets[board_config]); 4669 setup_preset(codec, &alc882_presets[board_config]);
4670 spec->vmaster_nid = 0x0c;
4671 }
4334 4672
4335 if (!spec->no_analog && !spec->adc_nids) { 4673 if (!spec->no_analog && !spec->adc_nids) {
4336 alc_auto_fill_adc_caps(codec); 4674 alc_auto_fill_adc_caps(codec);
@@ -4350,13 +4688,10 @@ static int patch_alc882(struct hda_codec *codec)
4350 4688
4351 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4689 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4352 4690
4353 spec->vmaster_nid = 0x0c;
4354
4355 codec->patch_ops = alc_patch_ops; 4691 codec->patch_ops = alc_patch_ops;
4356 if (board_config == ALC_MODEL_AUTO) 4692 if (board_config == ALC_MODEL_AUTO)
4357 spec->init_hook = alc_auto_init_std; 4693 spec->init_hook = alc_auto_init_std;
4358 4694
4359 alc_init_jacks(codec);
4360#ifdef CONFIG_SND_HDA_POWER_SAVE 4695#ifdef CONFIG_SND_HDA_POWER_SAVE
4361 if (!spec->loopback.amplist) 4696 if (!spec->loopback.amplist)
4362 spec->loopback.amplist = alc882_loopbacks; 4697 spec->loopback.amplist = alc882_loopbacks;
@@ -4384,12 +4719,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
4384 * Pin config fixes 4719 * Pin config fixes
4385 */ 4720 */
4386enum { 4721enum {
4387 PINFIX_FSC_H270, 4722 ALC262_FIXUP_FSC_H270,
4388 PINFIX_HP_Z200, 4723 ALC262_FIXUP_HP_Z200,
4724 ALC262_FIXUP_TYAN,
4725 ALC262_FIXUP_TOSHIBA_RX1,
4726 ALC262_FIXUP_LENOVO_3000,
4727 ALC262_FIXUP_BENQ,
4728 ALC262_FIXUP_BENQ_T31,
4389}; 4729};
4390 4730
4391static const struct alc_fixup alc262_fixups[] = { 4731static const struct alc_fixup alc262_fixups[] = {
4392 [PINFIX_FSC_H270] = { 4732 [ALC262_FIXUP_FSC_H270] = {
4393 .type = ALC_FIXUP_PINS, 4733 .type = ALC_FIXUP_PINS,
4394 .v.pins = (const struct alc_pincfg[]) { 4734 .v.pins = (const struct alc_pincfg[]) {
4395 { 0x14, 0x99130110 }, /* speaker */ 4735 { 0x14, 0x99130110 }, /* speaker */
@@ -4398,18 +4738,68 @@ static const struct alc_fixup alc262_fixups[] = {
4398 { } 4738 { }
4399 } 4739 }
4400 }, 4740 },
4401 [PINFIX_HP_Z200] = { 4741 [ALC262_FIXUP_HP_Z200] = {
4402 .type = ALC_FIXUP_PINS, 4742 .type = ALC_FIXUP_PINS,
4403 .v.pins = (const struct alc_pincfg[]) { 4743 .v.pins = (const struct alc_pincfg[]) {
4404 { 0x16, 0x99130120 }, /* internal speaker */ 4744 { 0x16, 0x99130120 }, /* internal speaker */
4405 { } 4745 { }
4406 } 4746 }
4407 }, 4747 },
4748 [ALC262_FIXUP_TYAN] = {
4749 .type = ALC_FIXUP_PINS,
4750 .v.pins = (const struct alc_pincfg[]) {
4751 { 0x14, 0x1993e1f0 }, /* int AUX */
4752 { }
4753 }
4754 },
4755 [ALC262_FIXUP_TOSHIBA_RX1] = {
4756 .type = ALC_FIXUP_PINS,
4757 .v.pins = (const struct alc_pincfg[]) {
4758 { 0x14, 0x90170110 }, /* speaker */
4759 { 0x15, 0x0421101f }, /* HP */
4760 { 0x1a, 0x40f000f0 }, /* N/A */
4761 { 0x1b, 0x40f000f0 }, /* N/A */
4762 { 0x1e, 0x40f000f0 }, /* N/A */
4763 }
4764 },
4765 [ALC262_FIXUP_LENOVO_3000] = {
4766 .type = ALC_FIXUP_VERBS,
4767 .v.verbs = (const struct hda_verb[]) {
4768 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4769 {}
4770 },
4771 .chained = true,
4772 .chain_id = ALC262_FIXUP_BENQ,
4773 },
4774 [ALC262_FIXUP_BENQ] = {
4775 .type = ALC_FIXUP_VERBS,
4776 .v.verbs = (const struct hda_verb[]) {
4777 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4778 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4779 {}
4780 }
4781 },
4782 [ALC262_FIXUP_BENQ_T31] = {
4783 .type = ALC_FIXUP_VERBS,
4784 .v.verbs = (const struct hda_verb[]) {
4785 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4786 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4787 {}
4788 }
4789 },
4408}; 4790};
4409 4791
4410static const struct snd_pci_quirk alc262_fixup_tbl[] = { 4792static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4411 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200), 4793 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
4412 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), 4794 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ),
4795 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
4796 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
4797 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
4798 ALC262_FIXUP_TOSHIBA_RX1),
4799 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
4800 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
4801 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
4802 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
4413 {} 4803 {}
4414}; 4804};
4415 4805
@@ -4420,14 +4810,9 @@ static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4420 4810
4421/* 4811/*
4422 */ 4812 */
4423#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4424#include "alc262_quirks.c"
4425#endif
4426
4427static int patch_alc262(struct hda_codec *codec) 4813static int patch_alc262(struct hda_codec *codec)
4428{ 4814{
4429 struct alc_spec *spec; 4815 struct alc_spec *spec;
4430 int board_config;
4431 int err; 4816 int err;
4432 4817
4433 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4818 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -4454,37 +4839,13 @@ static int patch_alc262(struct hda_codec *codec)
4454 4839
4455 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 4840 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4456 4841
4457 board_config = alc_board_config(codec, ALC262_MODEL_LAST, 4842 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4458 alc262_models, alc262_cfg_tbl); 4843 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4459
4460 if (board_config < 0) {
4461 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4462 codec->chip_name);
4463 board_config = ALC_MODEL_AUTO;
4464 }
4465
4466 if (board_config == ALC_MODEL_AUTO) {
4467 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4468 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4469 }
4470
4471 if (board_config == ALC_MODEL_AUTO) {
4472 /* automatic parse from the BIOS config */
4473 err = alc262_parse_auto_config(codec);
4474 if (err < 0)
4475 goto error;
4476#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4477 else if (!err) {
4478 printk(KERN_INFO
4479 "hda_codec: Cannot set up configuration "
4480 "from BIOS. Using base mode...\n");
4481 board_config = ALC262_BASIC;
4482 }
4483#endif
4484 }
4485 4844
4486 if (board_config != ALC_MODEL_AUTO) 4845 /* automatic parse from the BIOS config */
4487 setup_preset(codec, &alc262_presets[board_config]); 4846 err = alc262_parse_auto_config(codec);
4847 if (err < 0)
4848 goto error;
4488 4849
4489 if (!spec->no_analog && !spec->adc_nids) { 4850 if (!spec->no_analog && !spec->adc_nids) {
4490 alc_auto_fill_adc_caps(codec); 4851 alc_auto_fill_adc_caps(codec);
@@ -4504,14 +4865,10 @@ static int patch_alc262(struct hda_codec *codec)
4504 4865
4505 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4866 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4506 4867
4507 spec->vmaster_nid = 0x0c;
4508
4509 codec->patch_ops = alc_patch_ops; 4868 codec->patch_ops = alc_patch_ops;
4510 if (board_config == ALC_MODEL_AUTO) 4869 spec->init_hook = alc_auto_init_std;
4511 spec->init_hook = alc_auto_init_std;
4512 spec->shutup = alc_eapd_shutup; 4870 spec->shutup = alc_eapd_shutup;
4513 4871
4514 alc_init_jacks(codec);
4515#ifdef CONFIG_SND_HDA_POWER_SAVE 4872#ifdef CONFIG_SND_HDA_POWER_SAVE
4516 if (!spec->loopback.amplist) 4873 if (!spec->loopback.amplist)
4517 spec->loopback.amplist = alc262_loopbacks; 4874 spec->loopback.amplist = alc262_loopbacks;
@@ -4618,14 +4975,10 @@ static int patch_alc268(struct hda_codec *codec)
4618 if (!spec->no_analog && !spec->cap_mixer) 4975 if (!spec->no_analog && !spec->cap_mixer)
4619 set_capture_mixer(codec); 4976 set_capture_mixer(codec);
4620 4977
4621 spec->vmaster_nid = 0x02;
4622
4623 codec->patch_ops = alc_patch_ops; 4978 codec->patch_ops = alc_patch_ops;
4624 spec->init_hook = alc_auto_init_std; 4979 spec->init_hook = alc_auto_init_std;
4625 spec->shutup = alc_eapd_shutup; 4980 spec->shutup = alc_eapd_shutup;
4626 4981
4627 alc_init_jacks(codec);
4628
4629 return 0; 4982 return 0;
4630 4983
4631 error: 4984 error:
@@ -4967,7 +5320,7 @@ static const struct alc_fixup alc269_fixups[] = {
4967 { } 5320 { }
4968 }, 5321 },
4969 }, 5322 },
4970 [ALC269_FIXUP_DMIC] = { 5323 [ALC269VB_FIXUP_DMIC] = {
4971 .type = ALC_FIXUP_PINS, 5324 .type = ALC_FIXUP_PINS,
4972 .v.pins = (const struct alc_pincfg[]) { 5325 .v.pins = (const struct alc_pincfg[]) {
4973 { 0x12, 0x99a3092f }, /* int-mic */ 5326 { 0x12, 0x99a3092f }, /* int-mic */
@@ -5174,8 +5527,6 @@ static int patch_alc269(struct hda_codec *codec)
5174 5527
5175 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5528 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5176 5529
5177 spec->vmaster_nid = 0x02;
5178
5179 codec->patch_ops = alc_patch_ops; 5530 codec->patch_ops = alc_patch_ops;
5180#ifdef CONFIG_PM 5531#ifdef CONFIG_PM
5181 codec->patch_ops.resume = alc269_resume; 5532 codec->patch_ops.resume = alc269_resume;
@@ -5183,7 +5534,6 @@ static int patch_alc269(struct hda_codec *codec)
5183 spec->init_hook = alc_auto_init_std; 5534 spec->init_hook = alc_auto_init_std;
5184 spec->shutup = alc269_shutup; 5535 spec->shutup = alc269_shutup;
5185 5536
5186 alc_init_jacks(codec);
5187#ifdef CONFIG_SND_HDA_POWER_SAVE 5537#ifdef CONFIG_SND_HDA_POWER_SAVE
5188 if (!spec->loopback.amplist) 5538 if (!spec->loopback.amplist)
5189 spec->loopback.amplist = alc269_loopbacks; 5539 spec->loopback.amplist = alc269_loopbacks;
@@ -5280,8 +5630,6 @@ static int patch_alc861(struct hda_codec *codec)
5280 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 5630 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
5281 } 5631 }
5282 5632
5283 spec->vmaster_nid = 0x03;
5284
5285 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5633 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5286 5634
5287 codec->patch_ops = alc_patch_ops; 5635 codec->patch_ops = alc_patch_ops;
@@ -5406,8 +5754,6 @@ static int patch_alc861vd(struct hda_codec *codec)
5406 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5754 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5407 } 5755 }
5408 5756
5409 spec->vmaster_nid = 0x02;
5410
5411 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5757 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5412 5758
5413 codec->patch_ops = alc_patch_ops; 5759 codec->patch_ops = alc_patch_ops;
@@ -5790,7 +6136,6 @@ static int patch_alc662(struct hda_codec *codec)
5790 break; 6136 break;
5791 } 6137 }
5792 } 6138 }
5793 spec->vmaster_nid = 0x02;
5794 6139
5795 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 6140 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5796 6141
@@ -5798,8 +6143,6 @@ static int patch_alc662(struct hda_codec *codec)
5798 spec->init_hook = alc_auto_init_std; 6143 spec->init_hook = alc_auto_init_std;
5799 spec->shutup = alc_eapd_shutup; 6144 spec->shutup = alc_eapd_shutup;
5800 6145
5801 alc_init_jacks(codec);
5802
5803#ifdef CONFIG_SND_HDA_POWER_SAVE 6146#ifdef CONFIG_SND_HDA_POWER_SAVE
5804 if (!spec->loopback.amplist) 6147 if (!spec->loopback.amplist)
5805 spec->loopback.amplist = alc662_loopbacks; 6148 spec->loopback.amplist = alc662_loopbacks;
@@ -5846,8 +6189,6 @@ static int patch_alc680(struct hda_codec *codec)
5846 if (!spec->no_analog && !spec->cap_mixer) 6189 if (!spec->no_analog && !spec->cap_mixer)
5847 set_capture_mixer(codec); 6190 set_capture_mixer(codec);
5848 6191
5849 spec->vmaster_nid = 0x02;
5850
5851 codec->patch_ops = alc_patch_ops; 6192 codec->patch_ops = alc_patch_ops;
5852 spec->init_hook = alc_auto_init_std; 6193 spec->init_hook = alc_auto_init_std;
5853 6194
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 616678fde48..87e684fa830 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -37,6 +37,7 @@
37#include "hda_codec.h" 37#include "hda_codec.h"
38#include "hda_local.h" 38#include "hda_local.h"
39#include "hda_beep.h" 39#include "hda_beep.h"
40#include "hda_jack.h"
40 41
41enum { 42enum {
42 STAC_VREF_EVENT = 1, 43 STAC_VREF_EVENT = 1,
@@ -96,7 +97,6 @@ enum {
96 STAC_92HD83XXX_PWR_REF, 97 STAC_92HD83XXX_PWR_REF,
97 STAC_DELL_S14, 98 STAC_DELL_S14,
98 STAC_DELL_VOSTRO_3500, 99 STAC_DELL_VOSTRO_3500,
99 STAC_92HD83XXX_HP,
100 STAC_92HD83XXX_HP_cNB11_INTQUAD, 100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
101 STAC_HP_DV7_4000, 101 STAC_HP_DV7_4000,
102 STAC_92HD83XXX_MODELS 102 STAC_92HD83XXX_MODELS
@@ -176,13 +176,6 @@ enum {
176 STAC_9872_MODELS 176 STAC_9872_MODELS
177}; 177};
178 178
179struct sigmatel_event {
180 hda_nid_t nid;
181 unsigned char type;
182 unsigned char tag;
183 int data;
184};
185
186struct sigmatel_mic_route { 179struct sigmatel_mic_route {
187 hda_nid_t pin; 180 hda_nid_t pin;
188 signed char mux_idx; 181 signed char mux_idx;
@@ -231,9 +224,6 @@ struct sigmatel_spec {
231 const hda_nid_t *pwr_nids; 224 const hda_nid_t *pwr_nids;
232 const hda_nid_t *dac_list; 225 const hda_nid_t *dac_list;
233 226
234 /* events */
235 struct snd_array events;
236
237 /* playback */ 227 /* playback */
238 struct hda_input_mux *mono_mux; 228 struct hda_input_mux *mono_mux;
239 unsigned int cur_mmux; 229 unsigned int cur_mmux;
@@ -1094,13 +1084,10 @@ static const char * const slave_sws[] = {
1094}; 1084};
1095 1085
1096static void stac92xx_free_kctls(struct hda_codec *codec); 1086static void stac92xx_free_kctls(struct hda_codec *codec);
1097static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1098 1087
1099static int stac92xx_build_controls(struct hda_codec *codec) 1088static int stac92xx_build_controls(struct hda_codec *codec)
1100{ 1089{
1101 struct sigmatel_spec *spec = codec->spec; 1090 struct sigmatel_spec *spec = codec->spec;
1102 struct auto_pin_cfg *cfg = &spec->autocfg;
1103 hda_nid_t nid;
1104 int err; 1091 int err;
1105 int i; 1092 int i;
1106 1093
@@ -1186,31 +1173,9 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1186 1173
1187 stac92xx_free_kctls(codec); /* no longer needed */ 1174 stac92xx_free_kctls(codec); /* no longer needed */
1188 1175
1189 /* create jack input elements */ 1176 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1190 if (spec->hp_detect) { 1177 if (err < 0)
1191 for (i = 0; i < cfg->hp_outs; i++) { 1178 return err;
1192 int type = SND_JACK_HEADPHONE;
1193 nid = cfg->hp_pins[i];
1194 /* jack detection */
1195 if (cfg->hp_outs == i)
1196 type |= SND_JACK_LINEOUT;
1197 err = stac92xx_add_jack(codec, nid, type);
1198 if (err < 0)
1199 return err;
1200 }
1201 }
1202 for (i = 0; i < cfg->line_outs; i++) {
1203 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1204 SND_JACK_LINEOUT);
1205 if (err < 0)
1206 return err;
1207 }
1208 for (i = 0; i < cfg->num_inputs; i++) {
1209 nid = cfg->inputs[i].pin;
1210 err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE);
1211 if (err < 0)
1212 return err;
1213 }
1214 1179
1215 return 0; 1180 return 0;
1216} 1181}
@@ -1692,7 +1657,6 @@ static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1692 [STAC_92HD83XXX_PWR_REF] = "mic-ref", 1657 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1693 [STAC_DELL_S14] = "dell-s14", 1658 [STAC_DELL_S14] = "dell-s14",
1694 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500", 1659 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
1695 [STAC_92HD83XXX_HP] = "hp",
1696 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad", 1660 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
1697 [STAC_HP_DV7_4000] = "hp-dv7-4000", 1661 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1698}; 1662};
@@ -1707,8 +1671,6 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1707 "unknown Dell", STAC_DELL_S14), 1671 "unknown Dell", STAC_DELL_S14),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028, 1672 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1709 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500), 1673 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
1710 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1711 "HP", STAC_92HD83XXX_HP),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656, 1674 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), 1675 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657, 1676 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
@@ -2875,7 +2837,8 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2875 } 2837 }
2876 2838
2877 if (control) { 2839 if (control) {
2878 strcpy(name, hda_get_input_pin_label(codec, nid, 1)); 2840 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2841 name, sizeof(name), NULL);
2879 return stac92xx_add_control(codec->spec, control, 2842 return stac92xx_add_control(codec->spec, control,
2880 strcat(name, " Jack Mode"), nid); 2843 strcat(name, " Jack Mode"), nid);
2881 } 2844 }
@@ -3553,7 +3516,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3553 for (i = 0; i < spec->num_dmics; i++) { 3516 for (i = 0; i < spec->num_dmics; i++) {
3554 hda_nid_t nid; 3517 hda_nid_t nid;
3555 int index, type_idx; 3518 int index, type_idx;
3556 const char *label; 3519 char label[32];
3557 3520
3558 nid = spec->dmic_nids[i]; 3521 nid = spec->dmic_nids[i];
3559 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 3522 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
@@ -3566,7 +3529,8 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3566 if (index < 0) 3529 if (index < 0)
3567 continue; 3530 continue;
3568 3531
3569 label = hda_get_input_pin_label(codec, nid, 1); 3532 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3533 label, sizeof(label), NULL);
3570 snd_hda_add_imux_item(dimux, label, index, &type_idx); 3534 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3571 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) 3535 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3572 snd_hda_add_imux_item(imux, label, index, &type_idx); 3536 snd_hda_add_imux_item(imux, label, index, &type_idx);
@@ -4164,65 +4128,18 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4164 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ 4128 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4165} 4129}
4166 4130
4167static int stac92xx_add_jack(struct hda_codec *codec, 4131static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
4168 hda_nid_t nid, int type)
4169{
4170#ifdef CONFIG_SND_HDA_INPUT_JACK
4171 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4172 int connectivity = get_defcfg_connect(def_conf);
4173
4174 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4175 return 0;
4176
4177 return snd_hda_input_jack_add(codec, nid, type, NULL);
4178#else
4179 return 0;
4180#endif /* CONFIG_SND_HDA_INPUT_JACK */
4181}
4182
4183static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4184 unsigned char type, int data) 4132 unsigned char type, int data)
4185{ 4133{
4186 struct sigmatel_event *event; 4134 struct hda_jack_tbl *event;
4187 4135
4188 snd_array_init(&spec->events, sizeof(*event), 32); 4136 event = snd_hda_jack_tbl_new(codec, nid);
4189 event = snd_array_new(&spec->events);
4190 if (!event) 4137 if (!event)
4191 return -ENOMEM; 4138 return -ENOMEM;
4192 event->nid = nid; 4139 event->action = type;
4193 event->type = type; 4140 event->private_data = data;
4194 event->tag = spec->events.used;
4195 event->data = data;
4196
4197 return event->tag;
4198}
4199
4200static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4201 hda_nid_t nid)
4202{
4203 struct sigmatel_spec *spec = codec->spec;
4204 struct sigmatel_event *event = spec->events.list;
4205 int i;
4206
4207 for (i = 0; i < spec->events.used; i++, event++) {
4208 if (event->nid == nid)
4209 return event;
4210 }
4211 return NULL;
4212}
4213
4214static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4215 unsigned char tag)
4216{
4217 struct sigmatel_spec *spec = codec->spec;
4218 struct sigmatel_event *event = spec->events.list;
4219 int i;
4220 4141
4221 for (i = 0; i < spec->events.used; i++, event++) { 4142 return 0;
4222 if (event->tag == tag)
4223 return event;
4224 }
4225 return NULL;
4226} 4143}
4227 4144
4228/* check if given nid is a valid pin and no other events are assigned 4145/* check if given nid is a valid pin and no other events are assigned
@@ -4232,24 +4149,17 @@ static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4232static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, 4149static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4233 unsigned int type) 4150 unsigned int type)
4234{ 4151{
4235 struct sigmatel_event *event; 4152 struct hda_jack_tbl *event;
4236 int tag;
4237 4153
4238 if (!is_jack_detectable(codec, nid)) 4154 if (!is_jack_detectable(codec, nid))
4239 return 0; 4155 return 0;
4240 event = stac_get_event(codec, nid); 4156 event = snd_hda_jack_tbl_new(codec, nid);
4241 if (event) { 4157 if (!event)
4242 if (event->type != type) 4158 return -ENOMEM;
4243 return 0; 4159 if (event->action && event->action != type)
4244 tag = event->tag; 4160 return 0;
4245 } else { 4161 event->action = type;
4246 tag = stac_add_event(codec->spec, nid, type, 0); 4162 snd_hda_jack_detect_enable(codec, nid, 0);
4247 if (tag < 0)
4248 return 0;
4249 }
4250 snd_hda_codec_write_cache(codec, nid, 0,
4251 AC_VERB_SET_UNSOLICITED_ENABLE,
4252 AC_USRSP_EN | tag);
4253 return 1; 4163 return 1;
4254} 4164}
4255 4165
@@ -4326,6 +4236,27 @@ static void stac_store_hints(struct hda_codec *codec)
4326 } 4236 }
4327} 4237}
4328 4238
4239static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4240 const hda_nid_t *pins)
4241{
4242 while (num_pins--)
4243 stac_issue_unsol_event(codec, *pins++);
4244}
4245
4246/* fake event to set up pins */
4247static void stac_fake_hp_events(struct hda_codec *codec)
4248{
4249 struct sigmatel_spec *spec = codec->spec;
4250
4251 if (spec->autocfg.hp_outs)
4252 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4253 spec->autocfg.hp_pins);
4254 if (spec->autocfg.line_outs &&
4255 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4256 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4257 spec->autocfg.line_out_pins);
4258}
4259
4329static int stac92xx_init(struct hda_codec *codec) 4260static int stac92xx_init(struct hda_codec *codec)
4330{ 4261{
4331 struct sigmatel_spec *spec = codec->spec; 4262 struct sigmatel_spec *spec = codec->spec;
@@ -4376,10 +4307,7 @@ static int stac92xx_init(struct hda_codec *codec)
4376 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], 4307 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4377 AC_PINCTL_OUT_EN); 4308 AC_PINCTL_OUT_EN);
4378 /* fake event to set up pins */ 4309 /* fake event to set up pins */
4379 if (cfg->hp_pins[0]) 4310 stac_fake_hp_events(codec);
4380 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4381 else if (cfg->line_out_pins[0])
4382 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4383 } else { 4311 } else {
4384 stac92xx_auto_init_multi_out(codec); 4312 stac92xx_auto_init_multi_out(codec);
4385 stac92xx_auto_init_hp_out(codec); 4313 stac92xx_auto_init_hp_out(codec);
@@ -4477,6 +4405,8 @@ static int stac92xx_init(struct hda_codec *codec)
4477 stac_toggle_power_map(codec, nid, 0); 4405 stac_toggle_power_map(codec, nid, 0);
4478 } 4406 }
4479 4407
4408 snd_hda_jack_report_sync(codec);
4409
4480 /* sync mute LED */ 4410 /* sync mute LED */
4481 if (spec->gpio_led) 4411 if (spec->gpio_led)
4482 hda_call_check_power_status(codec, 0x01); 4412 hda_call_check_power_status(codec, 0x01);
@@ -4533,8 +4463,6 @@ static void stac92xx_free(struct hda_codec *codec)
4533 return; 4463 return;
4534 4464
4535 stac92xx_shutup(codec); 4465 stac92xx_shutup(codec);
4536 snd_hda_input_jack_free(codec);
4537 snd_array_free(&spec->events);
4538 4466
4539 kfree(spec); 4467 kfree(spec);
4540 snd_hda_detach_beep_device(codec); 4468 snd_hda_detach_beep_device(codec);
@@ -4798,26 +4726,13 @@ static void stac92xx_mic_detect(struct hda_codec *codec)
4798 mic->mux_idx); 4726 mic->mux_idx);
4799} 4727}
4800 4728
4801static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) 4729static void handle_unsol_event(struct hda_codec *codec,
4802{ 4730 struct hda_jack_tbl *event)
4803 struct sigmatel_event *event = stac_get_event(codec, nid);
4804 if (!event)
4805 return;
4806 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4807}
4808
4809static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4810{ 4731{
4811 struct sigmatel_spec *spec = codec->spec; 4732 struct sigmatel_spec *spec = codec->spec;
4812 struct sigmatel_event *event; 4733 int data;
4813 int tag, data;
4814
4815 tag = (res >> 26) & 0x7f;
4816 event = stac_get_event_from_tag(codec, tag);
4817 if (!event)
4818 return;
4819 4734
4820 switch (event->type) { 4735 switch (event->action) {
4821 case STAC_HP_EVENT: 4736 case STAC_HP_EVENT:
4822 case STAC_LO_EVENT: 4737 case STAC_LO_EVENT:
4823 stac92xx_hp_detect(codec); 4738 stac92xx_hp_detect(codec);
@@ -4827,7 +4742,7 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4827 break; 4742 break;
4828 } 4743 }
4829 4744
4830 switch (event->type) { 4745 switch (event->action) {
4831 case STAC_HP_EVENT: 4746 case STAC_HP_EVENT:
4832 case STAC_LO_EVENT: 4747 case STAC_LO_EVENT:
4833 case STAC_MIC_EVENT: 4748 case STAC_MIC_EVENT:
@@ -4835,7 +4750,6 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4835 case STAC_PWR_EVENT: 4750 case STAC_PWR_EVENT:
4836 if (spec->num_pwrs > 0) 4751 if (spec->num_pwrs > 0)
4837 stac92xx_pin_sense(codec, event->nid); 4752 stac92xx_pin_sense(codec, event->nid);
4838 snd_hda_input_jack_report(codec, event->nid);
4839 4753
4840 switch (codec->subsystem_id) { 4754 switch (codec->subsystem_id) {
4841 case 0x103c308f: 4755 case 0x103c308f:
@@ -4860,11 +4774,33 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4860 AC_VERB_GET_GPIO_DATA, 0); 4774 AC_VERB_GET_GPIO_DATA, 0);
4861 /* toggle VREF state based on GPIOx status */ 4775 /* toggle VREF state based on GPIOx status */
4862 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, 4776 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4863 !!(data & (1 << event->data))); 4777 !!(data & (1 << event->private_data)));
4864 break; 4778 break;
4865 } 4779 }
4866} 4780}
4867 4781
4782static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4783{
4784 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
4785 if (!event)
4786 return;
4787 handle_unsol_event(codec, event);
4788}
4789
4790static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4791{
4792 struct hda_jack_tbl *event;
4793 int tag;
4794
4795 tag = (res >> 26) & 0x7f;
4796 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
4797 if (!event)
4798 return;
4799 event->jack_dirty = 1;
4800 handle_unsol_event(codec, event);
4801 snd_hda_jack_report_sync(codec);
4802}
4803
4868static int hp_blike_system(u32 subsystem_id); 4804static int hp_blike_system(u32 subsystem_id);
4869 4805
4870static void set_hp_led_gpio(struct hda_codec *codec) 4806static void set_hp_led_gpio(struct hda_codec *codec)
@@ -4903,7 +4839,7 @@ static void set_hp_led_gpio(struct hda_codec *codec)
4903 * Need more information on whether it is true across the entire series. 4839 * Need more information on whether it is true across the entire series.
4904 * -- kunal 4840 * -- kunal
4905 */ 4841 */
4906static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity) 4842static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
4907{ 4843{
4908 struct sigmatel_spec *spec = codec->spec; 4844 struct sigmatel_spec *spec = codec->spec;
4909 const struct dmi_device *dev = NULL; 4845 const struct dmi_device *dev = NULL;
@@ -4939,9 +4875,11 @@ static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4939 4875
4940 /* 4876 /*
4941 * Fallback case - if we don't find the DMI strings, 4877 * Fallback case - if we don't find the DMI strings,
4942 * we statically set the GPIO - if not a B-series system. 4878 * we statically set the GPIO - if not a B-series system
4879 * and default polarity is provided
4943 */ 4880 */
4944 if (!hp_blike_system(codec->subsystem_id)) { 4881 if (!hp_blike_system(codec->subsystem_id) &&
4882 (default_polarity == 0 || default_polarity == 1)) {
4945 set_hp_led_gpio(codec); 4883 set_hp_led_gpio(codec);
4946 spec->gpio_led_polarity = default_polarity; 4884 spec->gpio_led_polarity = default_polarity;
4947 return 1; 4885 return 1;
@@ -5028,19 +4966,11 @@ static void stac927x_proc_hook(struct snd_info_buffer *buffer,
5028#ifdef CONFIG_PM 4966#ifdef CONFIG_PM
5029static int stac92xx_resume(struct hda_codec *codec) 4967static int stac92xx_resume(struct hda_codec *codec)
5030{ 4968{
5031 struct sigmatel_spec *spec = codec->spec;
5032
5033 stac92xx_init(codec); 4969 stac92xx_init(codec);
5034 snd_hda_codec_resume_amp(codec); 4970 snd_hda_codec_resume_amp(codec);
5035 snd_hda_codec_resume_cache(codec); 4971 snd_hda_codec_resume_cache(codec);
5036 /* fake event to set up pins again to override cached values */ 4972 /* fake event to set up pins again to override cached values */
5037 if (spec->hp_detect) { 4973 stac_fake_hp_events(codec);
5038 if (spec->autocfg.hp_pins[0])
5039 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
5040 else if (spec->autocfg.line_out_pins[0])
5041 stac_issue_unsol_event(codec,
5042 spec->autocfg.line_out_pins[0]);
5043 }
5044 return 0; 4974 return 0;
5045} 4975}
5046 4976
@@ -5651,7 +5581,7 @@ again:
5651 5581
5652 codec->patch_ops = stac92xx_patch_ops; 5582 codec->patch_ops = stac92xx_patch_ops;
5653 5583
5654 if (find_mute_led_gpio(codec, 0)) 5584 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
5655 snd_printd("mute LED gpio %d polarity %d\n", 5585 snd_printd("mute LED gpio %d polarity %d\n",
5656 spec->gpio_led, 5586 spec->gpio_led,
5657 spec->gpio_led_polarity); 5587 spec->gpio_led_polarity);
@@ -5839,15 +5769,13 @@ again:
5839 switch (spec->board_config) { 5769 switch (spec->board_config) {
5840 case STAC_HP_M4: 5770 case STAC_HP_M4:
5841 /* Enable VREF power saving on GPIO1 detect */ 5771 /* Enable VREF power saving on GPIO1 detect */
5842 err = stac_add_event(spec, codec->afg, 5772 err = stac_add_event(codec, codec->afg,
5843 STAC_VREF_EVENT, 0x02); 5773 STAC_VREF_EVENT, 0x02);
5844 if (err < 0) 5774 if (err < 0)
5845 return err; 5775 return err;
5846 snd_hda_codec_write_cache(codec, codec->afg, 0, 5776 snd_hda_codec_write_cache(codec, codec->afg, 0,
5847 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); 5777 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5848 snd_hda_codec_write_cache(codec, codec->afg, 0, 5778 snd_hda_jack_detect_enable(codec, codec->afg, 0);
5849 AC_VERB_SET_UNSOLICITED_ENABLE,
5850 AC_USRSP_EN | err);
5851 spec->gpio_mask |= 0x02; 5779 spec->gpio_mask |= 0x02;
5852 break; 5780 break;
5853 } 5781 }
@@ -5964,7 +5892,7 @@ again:
5964 } 5892 }
5965 } 5893 }
5966 5894
5967 if (find_mute_led_gpio(codec, 1)) 5895 if (find_mute_led_cfg(codec, 1))
5968 snd_printd("mute LED gpio %d polarity %d\n", 5896 snd_printd("mute LED gpio %d polarity %d\n",
5969 spec->gpio_led, 5897 spec->gpio_led,
5970 spec->gpio_led_polarity); 5898 spec->gpio_led_polarity);
@@ -6318,14 +6246,12 @@ static int patch_stac9205(struct hda_codec *codec)
6318 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); 6246 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6319 6247
6320 /* Enable unsol response for GPIO4/Dock HP connection */ 6248 /* Enable unsol response for GPIO4/Dock HP connection */
6321 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); 6249 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
6322 if (err < 0) 6250 if (err < 0)
6323 return err; 6251 return err;
6324 snd_hda_codec_write_cache(codec, codec->afg, 0, 6252 snd_hda_codec_write_cache(codec, codec->afg, 0,
6325 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); 6253 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6326 snd_hda_codec_write_cache(codec, codec->afg, 0, 6254 snd_hda_jack_detect_enable(codec, codec->afg, 0);
6327 AC_VERB_SET_UNSOLICITED_ENABLE,
6328 AC_USRSP_EN | err);
6329 6255
6330 spec->gpio_dir = 0x0b; 6256 spec->gpio_dir = 0x0b;
6331 spec->eapd_mask = 0x01; 6257 spec->eapd_mask = 0x01;
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index b5137629f8e..03e63fed9ca 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -54,6 +54,7 @@
54#include <sound/asoundef.h> 54#include <sound/asoundef.h>
55#include "hda_codec.h" 55#include "hda_codec.h"
56#include "hda_local.h" 56#include "hda_local.h"
57#include "hda_jack.h"
57 58
58/* Pin Widget NID */ 59/* Pin Widget NID */
59#define VT1708_HP_PIN_NID 0x20 60#define VT1708_HP_PIN_NID 0x20
@@ -1503,6 +1504,11 @@ static int via_build_controls(struct hda_codec *codec)
1503 analog_low_current_mode(codec); 1504 analog_low_current_mode(codec);
1504 1505
1505 via_free_kctls(codec); /* no longer needed */ 1506 via_free_kctls(codec); /* no longer needed */
1507
1508 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1509 if (err < 0)
1510 return err;
1511
1506 return 0; 1512 return 0;
1507} 1513}
1508 1514
@@ -1714,6 +1720,7 @@ static void via_unsol_event(struct hda_codec *codec,
1714 unsigned int res) 1720 unsigned int res)
1715{ 1721{
1716 res >>= 26; 1722 res >>= 26;
1723 res = snd_hda_jack_get_action(codec, res);
1717 1724
1718 if (res & VIA_JACK_EVENT) 1725 if (res & VIA_JACK_EVENT)
1719 set_widgets_power_state(codec); 1726 set_widgets_power_state(codec);
@@ -1724,6 +1731,7 @@ static void via_unsol_event(struct hda_codec *codec,
1724 via_hp_automute(codec); 1731 via_hp_automute(codec);
1725 else if (res == VIA_GPIO_EVENT) 1732 else if (res == VIA_GPIO_EVENT)
1726 via_gpio_control(codec); 1733 via_gpio_control(codec);
1734 snd_hda_jack_report_sync(codec);
1727} 1735}
1728 1736
1729#ifdef CONFIG_PM 1737#ifdef CONFIG_PM
@@ -2200,7 +2208,10 @@ static int via_auto_create_loopback_switch(struct hda_codec *codec)
2200{ 2208{
2201 struct via_spec *spec = codec->spec; 2209 struct via_spec *spec = codec->spec;
2202 2210
2203 if (!spec->aa_mix_nid || !spec->out_mix_path.depth) 2211 if (!spec->aa_mix_nid)
2212 return 0; /* no loopback switching available */
2213 if (!(spec->out_mix_path.depth || spec->hp_mix_path.depth ||
2214 spec->speaker_path.depth))
2204 return 0; /* no loopback switching available */ 2215 return 0; /* no loopback switching available */
2205 if (!via_clone_control(spec, &via_aamix_ctl_enum)) 2216 if (!via_clone_control(spec, &via_aamix_ctl_enum))
2206 return -ENOMEM; 2217 return -ENOMEM;
@@ -2736,9 +2747,8 @@ static void via_auto_init_unsol_event(struct hda_codec *codec)
2736 int i; 2747 int i;
2737 2748
2738 if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0])) 2749 if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0]))
2739 snd_hda_codec_write(codec, cfg->hp_pins[0], 0, 2750 snd_hda_jack_detect_enable(codec, cfg->hp_pins[0],
2740 AC_VERB_SET_UNSOLICITED_ENABLE, 2751 VIA_HP_EVENT | VIA_JACK_EVENT);
2741 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT);
2742 2752
2743 if (cfg->speaker_pins[0]) 2753 if (cfg->speaker_pins[0])
2744 ev = VIA_LINE_EVENT; 2754 ev = VIA_LINE_EVENT;
@@ -2747,16 +2757,14 @@ static void via_auto_init_unsol_event(struct hda_codec *codec)
2747 for (i = 0; i < cfg->line_outs; i++) { 2757 for (i = 0; i < cfg->line_outs; i++) {
2748 if (cfg->line_out_pins[i] && 2758 if (cfg->line_out_pins[i] &&
2749 is_jack_detectable(codec, cfg->line_out_pins[i])) 2759 is_jack_detectable(codec, cfg->line_out_pins[i]))
2750 snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, 2760 snd_hda_jack_detect_enable(codec, cfg->line_out_pins[i],
2751 AC_VERB_SET_UNSOLICITED_ENABLE, 2761 ev | VIA_JACK_EVENT);
2752 AC_USRSP_EN | ev | VIA_JACK_EVENT);
2753 } 2762 }
2754 2763
2755 for (i = 0; i < cfg->num_inputs; i++) { 2764 for (i = 0; i < cfg->num_inputs; i++) {
2756 if (is_jack_detectable(codec, cfg->inputs[i].pin)) 2765 if (is_jack_detectable(codec, cfg->inputs[i].pin))
2757 snd_hda_codec_write(codec, cfg->inputs[i].pin, 0, 2766 snd_hda_jack_detect_enable(codec, cfg->inputs[i].pin,
2758 AC_VERB_SET_UNSOLICITED_ENABLE, 2767 VIA_JACK_EVENT);
2759 AC_USRSP_EN | VIA_JACK_EVENT);
2760 } 2768 }
2761} 2769}
2762 2770
@@ -2779,6 +2787,7 @@ static int via_init(struct hda_codec *codec)
2779 2787
2780 via_hp_automute(codec); 2788 via_hp_automute(codec);
2781 vt1708_update_hp_work(spec); 2789 vt1708_update_hp_work(spec);
2790 snd_hda_jack_report_sync(codec);
2782 2791
2783 return 0; 2792 return 0;
2784} 2793}
@@ -2789,6 +2798,7 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
2789 vt1708_hp_work.work); 2798 vt1708_hp_work.work);
2790 if (spec->codec_type != VT1708) 2799 if (spec->codec_type != VT1708)
2791 return; 2800 return;
2801 snd_hda_jack_set_dirty_all(spec->codec);
2792 /* if jack state toggled */ 2802 /* if jack state toggled */
2793 if (spec->vt1708_hp_present 2803 if (spec->vt1708_hp_present
2794 != snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) { 2804 != snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) {
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index e328cfb7620..e525da2673b 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -68,8 +68,11 @@ static int __devinit snd_vt1724_amp_init(struct snd_ice1712 *ice)
68 68
69static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice) 69static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
70{ 70{
71 /* we use pins 39 and 41 of the VT1616 for left and right read outputs */ 71 if (ice->ac97)
72 snd_ac97_write_cache(ice->ac97, 0x5a, snd_ac97_read(ice->ac97, 0x5a) & ~0x8000); 72 /* we use pins 39 and 41 of the VT1616 for left and right
73 read outputs */
74 snd_ac97_write_cache(ice->ac97, 0x5a,
75 snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
73 return 0; 76 return 0;
74} 77}
75 78
diff --git a/sound/pci/ice1712/envy24ht.h b/sound/pci/ice1712/envy24ht.h
index a0c5e009bb4..4ca33a800bc 100644
--- a/sound/pci/ice1712/envy24ht.h
+++ b/sound/pci/ice1712/envy24ht.h
@@ -66,6 +66,7 @@ enum {
66#define VT1724_CFG_CLOCK384 0x40 /* 16.9344Mhz, 44.1kHz*384 */ 66#define VT1724_CFG_CLOCK384 0x40 /* 16.9344Mhz, 44.1kHz*384 */
67#define VT1724_CFG_MPU401 0x20 /* MPU401 UARTs */ 67#define VT1724_CFG_MPU401 0x20 /* MPU401 UARTs */
68#define VT1724_CFG_ADC_MASK 0x0c /* one, two or one and S/PDIF, stereo ADCs */ 68#define VT1724_CFG_ADC_MASK 0x0c /* one, two or one and S/PDIF, stereo ADCs */
69#define VT1724_CFG_ADC_NONE 0x0c /* no ADCs */
69#define VT1724_CFG_DAC_MASK 0x03 /* one, two, three, four stereo DACs */ 70#define VT1724_CFG_DAC_MASK 0x03 /* one, two, three, four stereo DACs */
70 71
71#define VT1724_REG_AC97_CFG 0x05 /* byte */ 72#define VT1724_REG_AC97_CFG 0x05 /* byte */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 44446f2222d..132a86e09d0 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -84,9 +84,9 @@ MODULE_SUPPORTED_DEVICE("{"
84 84
85static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 85static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
86static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 86static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
87static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 87static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
88static char *model[SNDRV_CARDS]; 88static char *model[SNDRV_CARDS];
89static int omni[SNDRV_CARDS]; /* Delta44 & 66 Omni I/O support */ 89static bool omni[SNDRV_CARDS]; /* Delta44 & 66 Omni I/O support */
90static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transceiver reset timeout value in msec */ 90static int cs8427_timeout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 500}; /* CS8427 S/PDIF transceiver reset timeout value in msec */
91static int dxr_enable[SNDRV_CARDS]; /* DXR enable for DMX6FIRE */ 91static int dxr_enable[SNDRV_CARDS]; /* DXR enable for DMX6FIRE */
92 92
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 4353e76bf0a..92362973764 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -80,7 +80,7 @@ MODULE_SUPPORTED_DEVICE("{"
80 80
81static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 81static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
82static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 82static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
83static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 83static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
84static char *model[SNDRV_CARDS]; 84static char *model[SNDRV_CARDS];
85 85
86module_param_array(index, int, NULL, 0444); 86module_param_array(index, int, NULL, 0444);
@@ -1117,14 +1117,21 @@ static struct snd_pcm_ops snd_vt1724_capture_pro_ops = {
1117static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device) 1117static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device)
1118{ 1118{
1119 struct snd_pcm *pcm; 1119 struct snd_pcm *pcm;
1120 int err; 1120 int capt, err;
1121 1121
1122 err = snd_pcm_new(ice->card, "ICE1724", device, 1, 1, &pcm); 1122 if ((ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_ADC_MASK) ==
1123 VT1724_CFG_ADC_NONE)
1124 capt = 0;
1125 else
1126 capt = 1;
1127 err = snd_pcm_new(ice->card, "ICE1724", device, 1, capt, &pcm);
1123 if (err < 0) 1128 if (err < 0)
1124 return err; 1129 return err;
1125 1130
1126 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_vt1724_playback_pro_ops); 1131 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_vt1724_playback_pro_ops);
1127 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_vt1724_capture_pro_ops); 1132 if (capt)
1133 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1134 &snd_vt1724_capture_pro_ops);
1128 1135
1129 pcm->private_data = ice; 1136 pcm->private_data = ice;
1130 pcm->info_flags = 0; 1137 pcm->info_flags = 0;
@@ -1825,7 +1832,12 @@ static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
1825 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1832 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1826 uinfo->count = 1; 1833 uinfo->count = 1;
1827 1834
1828 uinfo->value.enumerated.items = hw_rates_count + ice->ext_clock_count; 1835 /* internal clocks */
1836 uinfo->value.enumerated.items = hw_rates_count;
1837 /* external clocks */
1838 if (ice->force_rdma1 ||
1839 (ice->eeprom.data[ICE_EEP2_SPDIF] & VT1724_CFG_SPDIF_IN))
1840 uinfo->value.enumerated.items += ice->ext_clock_count;
1829 /* upper limit - keep at top */ 1841 /* upper limit - keep at top */
1830 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1842 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1831 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1843 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
@@ -2173,6 +2185,40 @@ static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
2173 2185
2174static struct snd_ice1712_card_info no_matched __devinitdata; 2186static struct snd_ice1712_card_info no_matched __devinitdata;
2175 2187
2188
2189/*
2190 ooAoo cards with no controls
2191*/
2192static unsigned char ooaoo_sq210_eeprom[] __devinitdata = {
2193 [ICE_EEP2_SYSCONF] = 0x4c, /* 49MHz crystal, no mpu401, no ADC,
2194 1xDACs */
2195 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2196 [ICE_EEP2_I2S] = 0x78, /* no volume, 96k, 24bit, 192k */
2197 [ICE_EEP2_SPDIF] = 0xc1, /* out-en, out-int, out-ext */
2198 [ICE_EEP2_GPIO_DIR] = 0x00, /* no GPIOs are used */
2199 [ICE_EEP2_GPIO_DIR1] = 0x00,
2200 [ICE_EEP2_GPIO_DIR2] = 0x00,
2201 [ICE_EEP2_GPIO_MASK] = 0xff,
2202 [ICE_EEP2_GPIO_MASK1] = 0xff,
2203 [ICE_EEP2_GPIO_MASK2] = 0xff,
2204
2205 [ICE_EEP2_GPIO_STATE] = 0x00, /* inputs */
2206 [ICE_EEP2_GPIO_STATE1] = 0x00, /* all 1, but GPIO_CPLD_RW
2207 and GPIO15 always zero */
2208 [ICE_EEP2_GPIO_STATE2] = 0x00, /* inputs */
2209};
2210
2211
2212struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] __devinitdata = {
2213 {
2214 .name = "ooAoo SQ210a",
2215 .model = "sq210a",
2216 .eeprom_size = sizeof(ooaoo_sq210_eeprom),
2217 .eeprom_data = ooaoo_sq210_eeprom,
2218 },
2219 { } /* terminator */
2220};
2221
2176static struct snd_ice1712_card_info *card_tables[] __devinitdata = { 2222static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2177 snd_vt1724_revo_cards, 2223 snd_vt1724_revo_cards,
2178 snd_vt1724_amp_cards, 2224 snd_vt1724_amp_cards,
@@ -2187,6 +2233,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2187 snd_vt1724_wtm_cards, 2233 snd_vt1724_wtm_cards,
2188 snd_vt1724_se_cards, 2234 snd_vt1724_se_cards,
2189 snd_vt1724_qtet_cards, 2235 snd_vt1724_qtet_cards,
2236 snd_vt1724_ooaoo_cards,
2190 NULL, 2237 NULL,
2191}; 2238};
2192 2239
@@ -2270,7 +2317,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2270 } 2317 }
2271 } 2318 }
2272 for (tbl = card_tables; *tbl; tbl++) { 2319 for (tbl = card_tables; *tbl; tbl++) {
2273 for (c = *tbl; c->subvendor; c++) { 2320 for (c = *tbl; c->name; c++) {
2274 if (modelname && c->model && 2321 if (modelname && c->model &&
2275 !strcmp(modelname, c->model)) { 2322 !strcmp(modelname, c->model)) {
2276 printk(KERN_INFO "ice1724: Using board model %s\n", 2323 printk(KERN_INFO "ice1724: Using board model %s\n",
@@ -2579,8 +2626,10 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2579 ice->ext_clock_count = 0; 2626 ice->ext_clock_count = 0;
2580 2627
2581 for (tbl = card_tables; *tbl; tbl++) { 2628 for (tbl = card_tables; *tbl; tbl++) {
2582 for (c = *tbl; c->subvendor; c++) { 2629 for (c = *tbl; c->name; c++) {
2583 if (c->subvendor == ice->eeprom.subvendor) { 2630 if ((model[dev] && c->model &&
2631 !strcmp(model[dev], c->model)) ||
2632 (c->subvendor == ice->eeprom.subvendor)) {
2584 strcpy(card->shortname, c->name); 2633 strcpy(card->shortname, c->name);
2585 if (c->driver) /* specific driver? */ 2634 if (c->driver) /* specific driver? */
2586 strcpy(card->driver, c->driver); 2635 strcpy(card->driver, c->driver);
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 11718b49b2e..40b181bab93 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -79,9 +79,9 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
79static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 79static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
80static int ac97_clock; 80static int ac97_clock;
81static char *ac97_quirk; 81static char *ac97_quirk;
82static int buggy_semaphore; 82static bool buggy_semaphore;
83static int buggy_irq = -1; /* auto-check */ 83static int buggy_irq = -1; /* auto-check */
84static int xbox; 84static bool xbox;
85static int spdif_aclink = -1; 85static int spdif_aclink = -1;
86static int inside_vm = -1; 86static int inside_vm = -1;
87 87
@@ -105,7 +105,7 @@ module_param(inside_vm, bool, 0444);
105MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization."); 105MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
106 106
107/* just for backward compatibility */ 107/* just for backward compatibility */
108static int enable; 108static bool enable;
109module_param(enable, bool, 0444); 109module_param(enable, bool, 0444);
110static int joystick; 110static int joystick;
111module_param(joystick, int, 0444); 111module_param(joystick, int, 0444);
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 0f7041ec7dd..d689913a61b 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -68,7 +68,7 @@ module_param(ac97_clock, int, 0444);
68MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); 68MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
69 69
70/* just for backward compatibility */ 70/* just for backward compatibility */
71static int enable; 71static bool enable;
72module_param(enable, bool, 0444); 72module_param(enable, bool, 0444);
73 73
74/* 74/*
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 841864b6b37..8fea45ab588 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -408,7 +408,7 @@ MODULE_FIRMWARE("korg/k1212.dsp");
408 408
409static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 409static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
410static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 410static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
411static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 411static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
412 412
413module_param_array(index, int, NULL, 0444); 413module_param_array(index, int, NULL, 0444);
414MODULE_PARM_DESC(index, "Index value for Korg 1212 soundcard."); 414MODULE_PARM_DESC(index, "Index value for Korg 1212 soundcard.");
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 924168ef1ed..37598273685 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -35,7 +35,7 @@
35/* Standard options */ 35/* Standard options */
36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 36static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 37static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
38static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 38static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
39 39
40module_param_array(index, int, NULL, 0444); 40module_param_array(index, int, NULL, 0444);
41MODULE_PARM_DESC(index, "Index value for Digigram Lola driver."); 41MODULE_PARM_DESC(index, "Index value for Digigram Lola driver.");
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 04ae84b2a10..d94c0c292bd 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -42,7 +42,7 @@ MODULE_SUPPORTED_DEVICE("{digigram lx6464es{}}");
42 42
43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 43static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 44static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
45static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 45static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
46 46
47module_param_array(index, int, NULL, 0444); 47module_param_array(index, int, NULL, 0444);
48MODULE_PARM_DESC(index, "Index value for Digigram LX6464ES interface."); 48MODULE_PARM_DESC(index, "Index value for Digigram LX6464ES interface.");
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 863c8bdaecd..78229b0dad2 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -64,8 +64,8 @@ MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
64 64
65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
67static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */ 67static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */
68static int external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 68static bool external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
69static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; 69static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
70 70
71module_param_array(index, int, NULL, 0444); 71module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index a0bd1d99793..487837c01c9 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -49,7 +49,7 @@ MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
49 49
50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
51static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 51static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
52static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 52static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
53 53
54module_param_array(index, int, NULL, 0444); 54module_param_array(index, int, NULL, 0444);
55MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard."); 55MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index c6c45d979f7..ade2c64bd60 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -57,12 +57,12 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index */
57static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 57static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
58static int playback_bufsize = 16; 58static int playback_bufsize = 16;
59static int capture_bufsize = 16; 59static int capture_bufsize = 16;
60static int force_ac97; /* disabled as default */ 60static bool force_ac97; /* disabled as default */
61static int buffer_top; /* not specified */ 61static int buffer_top; /* not specified */
62static int use_cache; /* disabled */ 62static bool use_cache; /* disabled */
63static int vaio_hack; /* disabled */ 63static bool vaio_hack; /* disabled */
64static int reset_workaround; 64static bool reset_workaround;
65static int reset_workaround_2; 65static bool reset_workaround_2;
66 66
67module_param(index, int, 0444); 67module_param(index, int, 0444);
68MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 68MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
@@ -86,7 +86,7 @@ module_param(reset_workaround_2, bool, 0444);
86MODULE_PARM_DESC(reset_workaround_2, "Enable extended AC97 RESET workaround for some other laptops."); 86MODULE_PARM_DESC(reset_workaround_2, "Enable extended AC97 RESET workaround for some other laptops.");
87 87
88/* just for backward compatibility */ 88/* just for backward compatibility */
89static int enable; 89static bool enable;
90module_param(enable, bool, 0444); 90module_param(enable, bool, 0444);
91 91
92 92
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 5f3a13d4369..eab663eef11 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -74,7 +74,7 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8786}"
74 74
75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 75static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 76static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
77static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 77static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
78 78
79module_param_array(index, int, NULL, 0444); 79module_param_array(index, int, NULL, 0444);
80MODULE_PARM_DESC(index, "card index"); 80MODULE_PARM_DESC(index, "card index");
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 4149a0cb8b7..3fdee495017 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -32,7 +32,7 @@ MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
32 32
33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
35static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
36 36
37module_param_array(index, int, NULL, 0444); 37module_param_array(index, int, NULL, 0444);
38MODULE_PARM_DESC(index, "card index"); 38MODULE_PARM_DESC(index, "card index");
diff --git a/sound/pci/oxygen/xonar_cs43xx.c b/sound/pci/oxygen/xonar_cs43xx.c
index 252719101c4..c8febf4b9bd 100644
--- a/sound/pci/oxygen/xonar_cs43xx.c
+++ b/sound/pci/oxygen/xonar_cs43xx.c
@@ -418,6 +418,7 @@ static const struct oxygen_model model_xonar_d1 = {
418 .device_config = PLAYBACK_0_TO_I2S | 418 .device_config = PLAYBACK_0_TO_I2S |
419 PLAYBACK_1_TO_SPDIF | 419 PLAYBACK_1_TO_SPDIF |
420 CAPTURE_0_FROM_I2S_2 | 420 CAPTURE_0_FROM_I2S_2 |
421 CAPTURE_1_FROM_SPDIF |
421 AC97_FMIC_SWITCH, 422 AC97_FMIC_SWITCH,
422 .dac_channels_pcm = 8, 423 .dac_channels_pcm = 8,
423 .dac_channels_mixer = 8, 424 .dac_channels_mixer = 8,
diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
index bc6eb58be38..793bdf03d7e 100644
--- a/sound/pci/oxygen/xonar_dg.c
+++ b/sound/pci/oxygen/xonar_dg.c
@@ -597,7 +597,8 @@ struct oxygen_model model_xonar_dg = {
597 .model_data_size = sizeof(struct dg), 597 .model_data_size = sizeof(struct dg),
598 .device_config = PLAYBACK_0_TO_I2S | 598 .device_config = PLAYBACK_0_TO_I2S |
599 PLAYBACK_1_TO_SPDIF | 599 PLAYBACK_1_TO_SPDIF |
600 CAPTURE_0_FROM_I2S_2, 600 CAPTURE_0_FROM_I2S_2 |
601 CAPTURE_1_FROM_SPDIF,
601 .dac_channels_pcm = 6, 602 .dac_channels_pcm = 6,
602 .dac_channels_mixer = 0, 603 .dac_channels_mixer = 0,
603 .function_flags = OXYGEN_FUNCTION_SPI, 604 .function_flags = OXYGEN_FUNCTION_SPI,
diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c
index 42d1ab13621..478303e6c2b 100644
--- a/sound/pci/oxygen/xonar_wm87x6.c
+++ b/sound/pci/oxygen/xonar_wm87x6.c
@@ -1274,7 +1274,8 @@ static const struct oxygen_model model_xonar_ds = {
1274 .model_data_size = sizeof(struct xonar_wm87x6), 1274 .model_data_size = sizeof(struct xonar_wm87x6),
1275 .device_config = PLAYBACK_0_TO_I2S | 1275 .device_config = PLAYBACK_0_TO_I2S |
1276 PLAYBACK_1_TO_SPDIF | 1276 PLAYBACK_1_TO_SPDIF |
1277 CAPTURE_0_FROM_I2S_1, 1277 CAPTURE_0_FROM_I2S_1 |
1278 CAPTURE_1_FROM_SPDIF,
1278 .dac_channels_pcm = 8, 1279 .dac_channels_pcm = 8,
1279 .dac_channels_mixer = 8, 1280 .dac_channels_mixer = 8,
1280 .dac_volume_min = 255 - 2*60, 1281 .dac_volume_min = 255 - 2*60,
@@ -1306,7 +1307,8 @@ static const struct oxygen_model model_xonar_hdav_slim = {
1306 .model_data_size = sizeof(struct xonar_wm87x6), 1307 .model_data_size = sizeof(struct xonar_wm87x6),
1307 .device_config = PLAYBACK_0_TO_I2S | 1308 .device_config = PLAYBACK_0_TO_I2S |
1308 PLAYBACK_1_TO_SPDIF | 1309 PLAYBACK_1_TO_SPDIF |
1309 CAPTURE_0_FROM_I2S_1, 1310 CAPTURE_0_FROM_I2S_1 |
1311 CAPTURE_1_FROM_SPDIF,
1310 .dac_channels_pcm = 8, 1312 .dac_channels_pcm = 8,
1311 .dac_channels_mixer = 2, 1313 .dac_channels_mixer = 2,
1312 .dac_volume_min = 255 - 2*60, 1314 .dac_volume_min = 255 - 2*60,
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 56a52659742..fd1809ab73b 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -52,8 +52,8 @@ MODULE_SUPPORTED_DEVICE("{{Digigram," DRIVER_NAME "}}");
52 52
53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
55static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 55static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
56static int mono[SNDRV_CARDS]; /* capture mono only */ 56static bool mono[SNDRV_CARDS]; /* capture mono only */
57 57
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard"); 59MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard");
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index dcbedd33a62..0481d94aac9 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -122,7 +122,7 @@ MODULE_FIRMWARE("riptide.hex");
122 122
123static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 123static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
124static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 124static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
125static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; 125static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
126 126
127#ifdef SUPPORT_JOYSTICK 127#ifdef SUPPORT_JOYSTICK
128static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 }; 128static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 };
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 21bcb47fab5..b4819d5e41d 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -89,8 +89,8 @@
89 89
90static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 90static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
91static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 91static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
92static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 92static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
93static int fullduplex[SNDRV_CARDS]; // = {[0 ... (SNDRV_CARDS - 1)] = 1}; 93static bool fullduplex[SNDRV_CARDS]; // = {[0 ... (SNDRV_CARDS - 1)] = 1};
94 94
95module_param_array(index, int, NULL, 0444); 95module_param_array(index, int, NULL, 0444);
96MODULE_PARM_DESC(index, "Index value for RME Digi32 soundcard."); 96MODULE_PARM_DESC(index, "Index value for RME Digi32 soundcard.");
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 4585c9729fe..ba894158e76 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -53,7 +53,7 @@ MODULE_SUPPORTED_DEVICE("{{RME,Digi96},"
53 53
54static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 54static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
55static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 55static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
56static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 56static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
57 57
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for RME Digi96 soundcard."); 59MODULE_PARM_DESC(index, "Index value for RME Digi96 soundcard.");
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index f2a3758dac5..b68cdec03b9 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -45,7 +45,7 @@
45 45
46static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 46static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
47static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 47static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
48static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 48static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
49 49
50module_param_array(index, int, NULL, 0444); 50module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface."); 51MODULE_PARM_DESC(index, "Index value for RME Hammerfall DSP interface.");
@@ -2640,8 +2640,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2640 uinfo->value.enumerated.items = 3; 2640 uinfo->value.enumerated.items = 3;
2641 break; 2641 break;
2642 default: 2642 default:
2643 uinfo->value.enumerated.items = 0; 2643 return -EINVAL;
2644 break;
2645 } 2644 }
2646 2645
2647 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2646 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 19ee2203cbb..cc9f6c83d66 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -61,7 +61,7 @@
61 61
62static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 62static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
63static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 63static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
64static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ 64static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
65 65
66module_param_array(index, int, NULL, 0444); 66module_param_array(index, int, NULL, 0444);
67MODULE_PARM_DESC(index, "Index value for RME HDSPM interface."); 67MODULE_PARM_DESC(index, "Index value for RME HDSPM interface.");
@@ -941,6 +941,8 @@ struct hdspm {
941 941
942 cycles_t last_interrupt; 942 cycles_t last_interrupt;
943 943
944 unsigned int serial;
945
944 struct hdspm_peak_rms peak_rms; 946 struct hdspm_peak_rms peak_rms;
945}; 947};
946 948
@@ -4694,7 +4696,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry,
4694 4696
4695 snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n", 4697 snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n",
4696 (hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF, 4698 (hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF,
4697 (hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF); 4699 hdspm->serial);
4698 4700
4699 snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", 4701 snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
4700 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); 4702 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase);
@@ -6266,8 +6268,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6266 hdspm_version.card_type = hdspm->io_type; 6268 hdspm_version.card_type = hdspm->io_type;
6267 strncpy(hdspm_version.cardname, hdspm->card_name, 6269 strncpy(hdspm_version.cardname, hdspm->card_name,
6268 sizeof(hdspm_version.cardname)); 6270 sizeof(hdspm_version.cardname));
6269 hdspm_version.serial = (hdspm_read(hdspm, 6271 hdspm_version.serial = hdspm->serial;
6270 HDSPM_midiStatusIn0)>>8) & 0xFFFFFF;
6271 hdspm_version.firmware_rev = hdspm->firmware_rev; 6272 hdspm_version.firmware_rev = hdspm->firmware_rev;
6272 hdspm_version.addons = 0; 6273 hdspm_version.addons = 0;
6273 if (hdspm->tco) 6274 if (hdspm->tco)
@@ -6782,6 +6783,25 @@ static int __devinit snd_hdspm_create(struct snd_card *card,
6782 tasklet_init(&hdspm->midi_tasklet, 6783 tasklet_init(&hdspm->midi_tasklet,
6783 hdspm_midi_tasklet, (unsigned long) hdspm); 6784 hdspm_midi_tasklet, (unsigned long) hdspm);
6784 6785
6786
6787 if (hdspm->io_type != MADIface) {
6788 hdspm->serial = (hdspm_read(hdspm,
6789 HDSPM_midiStatusIn0)>>8) & 0xFFFFFF;
6790 /* id contains either a user-provided value or the default
6791 * NULL. If it's the default, we're safe to
6792 * fill card->id with the serial number.
6793 *
6794 * If the serial number is 0xFFFFFF, then we're dealing with
6795 * an old PCI revision that comes without a sane number. In
6796 * this case, we don't set card->id to avoid collisions
6797 * when running with multiple cards.
6798 */
6799 if (NULL == id[hdspm->dev] && hdspm->serial != 0xFFFFFF) {
6800 sprintf(card->id, "HDSPMx%06x", hdspm->serial);
6801 snd_card_set_id(card, card->id);
6802 }
6803 }
6804
6785 snd_printdd("create alsa devices.\n"); 6805 snd_printdd("create alsa devices.\n");
6786 err = snd_hdspm_create_alsa_devices(card, hdspm); 6806 err = snd_hdspm_create_alsa_devices(card, hdspm);
6787 if (err < 0) 6807 if (err < 0)
@@ -6868,10 +6888,10 @@ static int __devinit snd_hdspm_probe(struct pci_dev *pci,
6868 if (hdspm->io_type != MADIface) { 6888 if (hdspm->io_type != MADIface) {
6869 sprintf(card->shortname, "%s_%x", 6889 sprintf(card->shortname, "%s_%x",
6870 hdspm->card_name, 6890 hdspm->card_name,
6871 (hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF); 6891 hdspm->serial);
6872 sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d", 6892 sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d",
6873 hdspm->card_name, 6893 hdspm->card_name,
6874 (hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF, 6894 hdspm->serial,
6875 hdspm->port, hdspm->irq); 6895 hdspm->port, hdspm->irq);
6876 } else { 6896 } else {
6877 sprintf(card->shortname, "%s", hdspm->card_name); 6897 sprintf(card->shortname, "%s", hdspm->card_name);
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 732c5e83743..b737d1619cc 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -38,8 +38,8 @@
38 38
39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 39static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 40static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
41static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 41static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
42static int precise_ptr[SNDRV_CARDS]; /* Enable precise pointer */ 42static bool precise_ptr[SNDRV_CARDS]; /* Enable precise pointer */
43 43
44module_param_array(index, int, NULL, 0444); 44module_param_array(index, int, NULL, 0444);
45MODULE_PARM_DESC(index, "Index value for RME Digi9652 (Hammerfall) soundcard."); 45MODULE_PARM_DESC(index, "Index value for RME Digi9652 (Hammerfall) soundcard.");
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 28dfafb56dd..ff500a87f76 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -40,7 +40,7 @@ MODULE_SUPPORTED_DEVICE("{{SiS,SiS7019 Audio Accelerator}}");
40 40
41static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 41static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
42static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 42static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
43static int enable = 1; 43static bool enable = 1;
44static int codecs = 1; 44static int codecs = 1;
45 45
46module_param(index, int, 0444); 46module_param(index, int, 0444);
@@ -983,7 +983,7 @@ timeout:
983 mutex_unlock(&sis->ac97_mutex); 983 mutex_unlock(&sis->ac97_mutex);
984 984
985 if (!count) { 985 if (!count) {
986 printk(KERN_ERR "sis7019: ac97 codec %d timeout cmd 0x%08x\n", 986 dev_err(&sis->pci->dev, "ac97 codec %d timeout cmd 0x%08x\n",
987 codec, cmd); 987 codec, cmd);
988 } 988 }
989 989
@@ -1142,13 +1142,13 @@ static int sis_chip_init(struct sis7019 *sis)
1142 /* All done, check for errors. 1142 /* All done, check for errors.
1143 */ 1143 */
1144 if (!sis->codecs_present) { 1144 if (!sis->codecs_present) {
1145 printk(KERN_ERR "sis7019: could not find any codecs\n"); 1145 dev_err(&sis->pci->dev, "could not find any codecs\n");
1146 return -EIO; 1146 return -EIO;
1147 } 1147 }
1148 1148
1149 if (sis->codecs_present != codecs) { 1149 if (sis->codecs_present != codecs) {
1150 printk(KERN_WARNING "sis7019: missing codecs, found %0x, expected %0x\n", 1150 dev_warn(&sis->pci->dev, "missing codecs, found %0x, expected %0x\n",
1151 sis->codecs_present, codecs); 1151 sis->codecs_present, codecs);
1152 } 1152 }
1153 1153
1154 /* Let the hardware know that the audio driver is alive, 1154 /* Let the hardware know that the audio driver is alive,
@@ -1256,18 +1256,18 @@ static int sis_resume(struct pci_dev *pci)
1256 pci_restore_state(pci); 1256 pci_restore_state(pci);
1257 1257
1258 if (pci_enable_device(pci) < 0) { 1258 if (pci_enable_device(pci) < 0) {
1259 printk(KERN_ERR "sis7019: unable to re-enable device\n"); 1259 dev_err(&pci->dev, "unable to re-enable device\n");
1260 goto error; 1260 goto error;
1261 } 1261 }
1262 1262
1263 if (sis_chip_init(sis)) { 1263 if (sis_chip_init(sis)) {
1264 printk(KERN_ERR "sis7019: unable to re-init controller\n"); 1264 dev_err(&pci->dev, "unable to re-init controller\n");
1265 goto error; 1265 goto error;
1266 } 1266 }
1267 1267
1268 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED, 1268 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED,
1269 KBUILD_MODNAME, sis)) { 1269 KBUILD_MODNAME, sis)) {
1270 printk(KERN_ERR "sis7019: unable to regain IRQ %d\n", pci->irq); 1270 dev_err(&pci->dev, "unable to regain IRQ %d\n", pci->irq);
1271 goto error; 1271 goto error;
1272 } 1272 }
1273 1273
@@ -1335,8 +1335,7 @@ static int __devinit sis_chip_create(struct snd_card *card,
1335 goto error_out; 1335 goto error_out;
1336 1336
1337 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0) { 1337 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
1338 printk(KERN_ERR "sis7019: architecture does not support " 1338 dev_err(&pci->dev, "architecture does not support 30-bit PCI busmaster DMA");
1339 "30-bit PCI busmaster DMA");
1340 goto error_out_enabled; 1339 goto error_out_enabled;
1341 } 1340 }
1342 1341
@@ -1350,20 +1349,20 @@ static int __devinit sis_chip_create(struct snd_card *card,
1350 1349
1351 rc = pci_request_regions(pci, "SiS7019"); 1350 rc = pci_request_regions(pci, "SiS7019");
1352 if (rc) { 1351 if (rc) {
1353 printk(KERN_ERR "sis7019: unable request regions\n"); 1352 dev_err(&pci->dev, "unable request regions\n");
1354 goto error_out_enabled; 1353 goto error_out_enabled;
1355 } 1354 }
1356 1355
1357 rc = -EIO; 1356 rc = -EIO;
1358 sis->ioaddr = ioremap_nocache(pci_resource_start(pci, 1), 0x4000); 1357 sis->ioaddr = ioremap_nocache(pci_resource_start(pci, 1), 0x4000);
1359 if (!sis->ioaddr) { 1358 if (!sis->ioaddr) {
1360 printk(KERN_ERR "sis7019: unable to remap MMIO, aborting\n"); 1359 dev_err(&pci->dev, "unable to remap MMIO, aborting\n");
1361 goto error_out_cleanup; 1360 goto error_out_cleanup;
1362 } 1361 }
1363 1362
1364 rc = sis_alloc_suspend(sis); 1363 rc = sis_alloc_suspend(sis);
1365 if (rc < 0) { 1364 if (rc < 0) {
1366 printk(KERN_ERR "sis7019: unable to allocate state storage\n"); 1365 dev_err(&pci->dev, "unable to allocate state storage\n");
1367 goto error_out_cleanup; 1366 goto error_out_cleanup;
1368 } 1367 }
1369 1368
@@ -1371,9 +1370,9 @@ static int __devinit sis_chip_create(struct snd_card *card,
1371 if (rc) 1370 if (rc)
1372 goto error_out_cleanup; 1371 goto error_out_cleanup;
1373 1372
1374 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED, 1373 if (request_irq(pci->irq, sis_interrupt, IRQF_SHARED, KBUILD_MODNAME,
1375 KBUILD_MODNAME, sis)) { 1374 sis)) {
1376 printk(KERN_ERR "unable to allocate irq %d\n", sis->irq); 1375 dev_err(&pci->dev, "unable to allocate irq %d\n", sis->irq);
1377 goto error_out_cleanup; 1376 goto error_out_cleanup;
1378 } 1377 }
1379 1378
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 31b6ad3ab1d..54cc802050f 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -52,9 +52,9 @@ MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}");
52 52
53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 53static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 54static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
55static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 55static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
56static int reverb[SNDRV_CARDS]; 56static bool reverb[SNDRV_CARDS];
57static int mge[SNDRV_CARDS]; 57static bool mge[SNDRV_CARDS];
58static unsigned int dmaio = 0x7a00; /* DDMA i/o address */ 58static unsigned int dmaio = 0x7a00; /* DDMA i/o address */
59 59
60module_param_array(index, int, NULL, 0444); 60module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index deb04b92412..5f1def7f45e 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -47,7 +47,7 @@ MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
47 47
48static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 48static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 49static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
50static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 50static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; 51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32};
52static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192}; 52static int wavetable_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8192};
53 53
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index ae98d56d05b..75630408c6d 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -80,7 +80,7 @@ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
80static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 80static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
81static long mpu_port; 81static long mpu_port;
82#ifdef SUPPORT_JOYSTICK 82#ifdef SUPPORT_JOYSTICK
83static int joystick; 83static bool joystick;
84#endif 84#endif
85static int ac97_clock = 48000; 85static int ac97_clock = 48000;
86static char *ac97_quirk; 86static char *ac97_quirk;
@@ -110,7 +110,7 @@ module_param(nodelay, int, 0444);
110MODULE_PARM_DESC(nodelay, "Disable 500ms init delay"); 110MODULE_PARM_DESC(nodelay, "Disable 500ms init delay");
111 111
112/* just for backward compatibility */ 112/* just for backward compatibility */
113static int enable; 113static bool enable;
114module_param(enable, bool, 0444); 114module_param(enable, bool, 0444);
115 115
116 116
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 80a9c2bf330..5efcbcac506 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -66,7 +66,7 @@ module_param(ac97_clock, int, 0444);
66MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); 66MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
67 67
68/* just for backward compatibility */ 68/* just for backward compatibility */
69static int enable; 69static bool enable;
70module_param(enable, bool, 0444); 70module_param(enable, bool, 0444);
71 71
72 72
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index 6765822fb3b..6a534bfe127 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -37,8 +37,8 @@ MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
37 37
38static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 38static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
39static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 39static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
40static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 40static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
41static int mic[SNDRV_CARDS]; /* microphone */ 41static bool mic[SNDRV_CARDS]; /* microphone */
42static int ibl[SNDRV_CARDS]; /* microphone */ 42static int ibl[SNDRV_CARDS]; /* microphone */
43 43
44module_param_array(index, int, NULL, 0444); 44module_param_array(index, int, NULL, 0444);
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index e97ddcac0d3..e57b89e8aa8 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -41,13 +41,13 @@ MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724},"
41 41
42static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 42static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
43static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 43static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
44static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 44static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
45static long fm_port[SNDRV_CARDS]; 45static long fm_port[SNDRV_CARDS];
46static long mpu_port[SNDRV_CARDS]; 46static long mpu_port[SNDRV_CARDS];
47#ifdef SUPPORT_JOYSTICK 47#ifdef SUPPORT_JOYSTICK
48static long joystick_port[SNDRV_CARDS]; 48static long joystick_port[SNDRV_CARDS];
49#endif 49#endif
50static int rear_switch[SNDRV_CARDS]; 50static bool rear_switch[SNDRV_CARDS];
51 51
52module_param_array(index, int, NULL, 0444); 52module_param_array(index, int, NULL, 0444);
53MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard."); 53MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard.");