aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-07-30 01:55:32 -0400
committerLen Brown <len.brown@intel.com>2005-07-30 01:55:32 -0400
commitadbedd34244e2b054557002817f979a9b004a405 (patch)
tree78e4a524e84f8b3e23ae8b49ac689048584e4668 /sound/pci
parentd6ac1a7910d22626bc77e73db091e00b810715f4 (diff)
parentb0825488a642cadcf39709961dde61440cb0731c (diff)
merge 2.6.13-rc4 with ACPI's to-linus tree
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/ac97/ac97_codec.c25
-rw-r--r--sound/pci/ac97/ac97_patch.c3
-rw-r--r--sound/pci/ali5451/ali5451.c4
-rw-r--r--sound/pci/atiixp_modem.c1
-rw-r--r--sound/pci/cmipci.c9
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c15
-rw-r--r--sound/pci/emu10k1/emu10k1.c10
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c133
-rw-r--r--sound/pci/emu10k1/p16v.c20
-rw-r--r--sound/pci/ens1370.c22
-rw-r--r--sound/pci/es1968.c14
-rw-r--r--sound/pci/hda/hda_codec.h3
-rw-r--r--sound/pci/hda/hda_intel.c6
-rw-r--r--sound/pci/hda/patch_cmedia.c5
-rw-r--r--sound/pci/hda/patch_realtek.c28
-rw-r--r--sound/pci/hda/patch_sigmatel.c812
-rw-r--r--sound/pci/intel8x0.c17
-rw-r--r--sound/pci/maestro3.c26
-rw-r--r--sound/pci/mixart/mixart.c4
-rw-r--r--sound/pci/rme9652/hdsp.c68
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/via82xx.c16
-rw-r--r--sound/pci/via82xx_modem.c13
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c6
24 files changed, 852 insertions, 412 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index a4b72cd2eea0..6983eea226da 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -367,6 +367,7 @@ int snd_ac97_update(ac97_t *ac97, unsigned short reg, unsigned short value)
367 ac97->regs[reg] = value; 367 ac97->regs[reg] = value;
368 ac97->bus->ops->write(ac97, reg, value); 368 ac97->bus->ops->write(ac97, reg, value);
369 } 369 }
370 set_bit(reg, ac97->reg_accessed);
370 up(&ac97->reg_mutex); 371 up(&ac97->reg_mutex);
371 return change; 372 return change;
372} 373}
@@ -410,6 +411,7 @@ int snd_ac97_update_bits_nolock(ac97_t *ac97, unsigned short reg,
410 ac97->regs[reg] = new; 411 ac97->regs[reg] = new;
411 ac97->bus->ops->write(ac97, reg, new); 412 ac97->bus->ops->write(ac97, reg, new);
412 } 413 }
414 set_bit(reg, ac97->reg_accessed);
413 return change; 415 return change;
414} 416}
415 417
@@ -1076,6 +1078,11 @@ static void check_volume_resolution(ac97_t *ac97, int reg, unsigned char *lo_max
1076 for (i = 0 ; i < ARRAY_SIZE(cbit); i++) { 1078 for (i = 0 ; i < ARRAY_SIZE(cbit); i++) {
1077 unsigned short val; 1079 unsigned short val;
1078 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8)); 1080 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8));
1081 /* Do the read twice due to buffers on some ac97 codecs.
1082 * e.g. The STAC9704 returns exactly what you wrote the the register
1083 * if you read it immediately. This causes the detect routine to fail.
1084 */
1085 val = snd_ac97_read(ac97, reg);
1079 val = snd_ac97_read(ac97, reg); 1086 val = snd_ac97_read(ac97, reg);
1080 if (! *lo_max && (val & 0x7f) == cbit[i]) 1087 if (! *lo_max && (val & 0x7f) == cbit[i])
1081 *lo_max = max[i]; 1088 *lo_max = max[i];
@@ -2224,7 +2231,7 @@ void snd_ac97_restore_iec958(ac97_t *ac97)
2224 */ 2231 */
2225void snd_ac97_resume(ac97_t *ac97) 2232void snd_ac97_resume(ac97_t *ac97)
2226{ 2233{
2227 int i; 2234 unsigned long end_time;
2228 2235
2229 if (ac97->bus->ops->reset) { 2236 if (ac97->bus->ops->reset) {
2230 ac97->bus->ops->reset(ac97); 2237 ac97->bus->ops->reset(ac97);
@@ -2242,26 +2249,26 @@ void snd_ac97_resume(ac97_t *ac97)
2242 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]); 2249 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]);
2243 if (ac97_is_audio(ac97)) { 2250 if (ac97_is_audio(ac97)) {
2244 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101); 2251 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101);
2245 for (i = HZ/10; i >= 0; i--) { 2252 end_time = jiffies + msecs_to_jiffies(100);
2253 do {
2246 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101) 2254 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101)
2247 break; 2255 break;
2248 set_current_state(TASK_UNINTERRUPTIBLE); 2256 set_current_state(TASK_UNINTERRUPTIBLE);
2249 schedule_timeout(1); 2257 schedule_timeout(1);
2250 } 2258 } while (time_after_eq(end_time, jiffies));
2251 /* FIXME: extra delay */ 2259 /* FIXME: extra delay */
2252 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000); 2260 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);
2253 if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000) { 2261 if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000)
2254 set_current_state(TASK_UNINTERRUPTIBLE); 2262 msleep(250);
2255 schedule_timeout(HZ/4);
2256 }
2257 } else { 2263 } else {
2258 for (i = HZ/10; i >= 0; i--) { 2264 end_time = jiffies + msecs_to_jiffies(100);
2265 do {
2259 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID); 2266 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID);
2260 if (val != 0xffff && (val & 1) != 0) 2267 if (val != 0xffff && (val & 1) != 0)
2261 break; 2268 break;
2262 set_current_state(TASK_UNINTERRUPTIBLE); 2269 set_current_state(TASK_UNINTERRUPTIBLE);
2263 schedule_timeout(1); 2270 schedule_timeout(1);
2264 } 2271 } while (time_after_eq(end_time, jiffies));
2265 } 2272 }
2266__reset_ready: 2273__reset_ready:
2267 2274
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index a15eb8522b7c..66edc857d3e6 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -1528,6 +1528,9 @@ static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = {
1528 }, 1528 },
1529 AC97_SURROUND_JACK_MODE_CTL, 1529 AC97_SURROUND_JACK_MODE_CTL,
1530 AC97_CHANNEL_MODE_CTL, 1530 AC97_CHANNEL_MODE_CTL,
1531
1532 AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 10, 1, 0),
1533 AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),
1531}; 1534};
1532 1535
1533static int patch_ad1888_specific(ac97_t *ac97) 1536static int patch_ad1888_specific(ac97_t *ac97)
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index eb5c36d31a52..f08ae71f902d 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -399,7 +399,7 @@ static int snd_ali_codec_ready( ali_t *codec,
399 unsigned long end_time; 399 unsigned long end_time;
400 unsigned int res; 400 unsigned int res;
401 401
402 end_time = jiffies + 10 * (HZ >> 2); 402 end_time = jiffies + 10 * msecs_to_jiffies(250);
403 do { 403 do {
404 res = snd_ali_5451_peek(codec,port); 404 res = snd_ali_5451_peek(codec,port);
405 if (! (res & 0x8000)) 405 if (! (res & 0x8000))
@@ -422,7 +422,7 @@ static int snd_ali_stimer_ready(ali_t *codec, int sched)
422 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); 422 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);
423 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); 423 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
424 424
425 end_time = jiffies + 10 * (HZ >> 2); 425 end_time = jiffies + 10 * msecs_to_jiffies(250);
426 do { 426 do {
427 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); 427 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
428 if (dwChk2 != dwChk1) 428 if (dwChk2 != dwChk1)
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index a6b4b8d589fd..8d2002951bd7 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -265,6 +265,7 @@ struct snd_atiixp {
265 */ 265 */
266static struct pci_device_id snd_atiixp_ids[] = { 266static struct pci_device_id snd_atiixp_ids[] = {
267 { 0x1002, 0x434d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */ 267 { 0x1002, 0x434d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */
268 { 0x1002, 0x4378, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB400 */
268 { 0, } 269 { 0, }
269}; 270};
270 271
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 4725b4a010be..f5a4ac1ceef9 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -306,7 +306,7 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address.");
306#define CM_REG_FM_PCI 0x50 306#define CM_REG_FM_PCI 0x50
307 307
308/* 308/*
309 * for CMI-8338 .. this is not valid for CMI-8738. 309 * access from SB-mixer port
310 */ 310 */
311#define CM_REG_EXTENT_IND 0xf0 311#define CM_REG_EXTENT_IND 0xf0
312#define CM_VPHONE_MASK 0xe0 /* Phone volume control (0-3) << 5 */ 312#define CM_VPHONE_MASK 0xe0 /* Phone volume control (0-3) << 5 */
@@ -315,6 +315,7 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address.");
315#define CM_VSPKM 0x08 /* Speaker mute control, default high */ 315#define CM_VSPKM 0x08 /* Speaker mute control, default high */
316#define CM_RLOOPREN 0x04 /* Rec. R-channel enable */ 316#define CM_RLOOPREN 0x04 /* Rec. R-channel enable */
317#define CM_RLOOPLEN 0x02 /* Rec. L-channel enable */ 317#define CM_RLOOPLEN 0x02 /* Rec. L-channel enable */
318#define CM_VADMIC3 0x01 /* Mic record boost */
318 319
319/* 320/*
320 * CMI-8338 spec ver 0.5 (this is not valid for CMI-8738): 321 * CMI-8338 spec ver 0.5 (this is not valid for CMI-8738):
@@ -2135,8 +2136,12 @@ static snd_kcontrol_new_t snd_cmipci_mixers[] __devinitdata = {
2135 CMIPCI_MIXER_VOL_STEREO("Aux Playback Volume", CM_REG_AUX_VOL, 4, 0, 15), 2136 CMIPCI_MIXER_VOL_STEREO("Aux Playback Volume", CM_REG_AUX_VOL, 4, 0, 15),
2136 CMIPCI_MIXER_SW_STEREO("Aux Playback Switch", CM_REG_MIXER2, CM_VAUXLM_SHIFT, CM_VAUXRM_SHIFT, 0), 2137 CMIPCI_MIXER_SW_STEREO("Aux Playback Switch", CM_REG_MIXER2, CM_VAUXLM_SHIFT, CM_VAUXRM_SHIFT, 0),
2137 CMIPCI_MIXER_SW_STEREO("Aux Capture Switch", CM_REG_MIXER2, CM_RAUXLEN_SHIFT, CM_RAUXREN_SHIFT, 0), 2138 CMIPCI_MIXER_SW_STEREO("Aux Capture Switch", CM_REG_MIXER2, CM_RAUXLEN_SHIFT, CM_RAUXREN_SHIFT, 0),
2138 CMIPCI_MIXER_SW_MONO("Mic Boost", CM_REG_MIXER2, CM_MICGAINZ_SHIFT, 1), 2139 CMIPCI_MIXER_SW_MONO("Mic Boost Playback Switch", CM_REG_MIXER2, CM_MICGAINZ_SHIFT, 1),
2139 CMIPCI_MIXER_VOL_MONO("Mic Capture Volume", CM_REG_MIXER2, CM_VADMIC_SHIFT, 7), 2140 CMIPCI_MIXER_VOL_MONO("Mic Capture Volume", CM_REG_MIXER2, CM_VADMIC_SHIFT, 7),
2141 CMIPCI_SB_VOL_MONO("Phone Playback Volume", CM_REG_EXTENT_IND, 5, 7),
2142 CMIPCI_DOUBLE("Phone Playback Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 4, 4, 1, 0, 0),
2143 CMIPCI_DOUBLE("PC Speaker Playnack Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 3, 3, 1, 0, 0),
2144 CMIPCI_DOUBLE("Mic Boost Capture Switch", CM_REG_EXTENT_IND, CM_REG_EXTENT_IND, 0, 0, 1, 0, 0),
2140}; 2145};
2141 2146
2142/* 2147/*
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index fd4c50c88bc9..ff28af1f658e 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2400,8 +2400,7 @@ static void snd_cs46xx_codec_reset (ac97_t * ac97)
2400 if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) 2400 if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05)
2401 return; 2401 return;
2402 2402
2403 set_current_state(TASK_UNINTERRUPTIBLE); 2403 msleep(10);
2404 schedule_timeout(HZ/100);
2405 } while (time_after_eq(end_time, jiffies)); 2404 } while (time_after_eq(end_time, jiffies));
2406 2405
2407 snd_printk("CS46xx secondary codec dont respond!\n"); 2406 snd_printk("CS46xx secondary codec dont respond!\n");
@@ -2435,8 +2434,7 @@ static int __devinit cs46xx_detect_codec(cs46xx_t *chip, int codec)
2435 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]); 2434 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]);
2436 return err; 2435 return err;
2437 } 2436 }
2438 set_current_state(TASK_INTERRUPTIBLE); 2437 msleep(10);
2439 schedule_timeout(HZ/100);
2440 } 2438 }
2441 snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec); 2439 snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec);
2442 return -ENXIO; 2440 return -ENXIO;
@@ -3018,8 +3016,7 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip)
3018 /* 3016 /*
3019 * Wait until the PLL has stabilized. 3017 * Wait until the PLL has stabilized.
3020 */ 3018 */
3021 set_current_state(TASK_UNINTERRUPTIBLE); 3019 msleep(100);
3022 schedule_timeout(HZ/10); /* 100ms */
3023 3020
3024 /* 3021 /*
3025 * Turn on clocking of the core so that we can setup the serial ports. 3022 * Turn on clocking of the core so that we can setup the serial ports.
@@ -3072,8 +3069,7 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip)
3072 */ 3069 */
3073 if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY) 3070 if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY)
3074 goto ok1; 3071 goto ok1;
3075 set_current_state(TASK_UNINTERRUPTIBLE); 3072 msleep(10);
3076 schedule_timeout((HZ+99)/100);
3077 } 3073 }
3078 3074
3079 3075
@@ -3122,8 +3118,7 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip)
3122 */ 3118 */
3123 if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4)) 3119 if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4))
3124 goto ok2; 3120 goto ok2;
3125 set_current_state(TASK_UNINTERRUPTIBLE); 3121 msleep(10);
3126 schedule_timeout((HZ+99)/100);
3127 } 3122 }
3128 3123
3129#ifndef CONFIG_SND_CS46XX_NEW_DSP 3124#ifndef CONFIG_SND_CS46XX_NEW_DSP
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index 2085a998eaeb..b17142cabead 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -52,6 +52,7 @@ static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
52static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64}; 52static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
53static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128}; 53static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
54static int enable_ir[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 54static int enable_ir[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
55static uint subsystem[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* Force card subsystem model */
55 56
56module_param_array(index, int, NULL, 0444); 57module_param_array(index, int, NULL, 0444);
57MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard."); 58MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard.");
@@ -71,7 +72,8 @@ module_param_array(max_buffer_size, int, NULL, 0444);
71MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB."); 72MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB.");
72module_param_array(enable_ir, bool, NULL, 0444); 73module_param_array(enable_ir, bool, NULL, 0444);
73MODULE_PARM_DESC(enable_ir, "Enable IR."); 74MODULE_PARM_DESC(enable_ir, "Enable IR.");
74 75module_param_array(subsystem, uint, NULL, 0444);
76MODULE_PARM_DESC(subsystem, "Force card subsystem model.");
75/* 77/*
76 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 78 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400
77 */ 79 */
@@ -122,7 +124,7 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
122 max_buffer_size[dev] = 1024; 124 max_buffer_size[dev] = 1024;
123 if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev], 125 if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev],
124 (long)max_buffer_size[dev] * 1024 * 1024, 126 (long)max_buffer_size[dev] * 1024 * 1024,
125 enable_ir[dev], 127 enable_ir[dev], subsystem[dev],
126 &emu)) < 0) { 128 &emu)) < 0) {
127 snd_card_free(card); 129 snd_card_free(card);
128 return err; 130 return err;
@@ -140,7 +142,7 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
140 return err; 142 return err;
141 } 143 }
142 /* This stores the periods table. */ 144 /* This stores the periods table. */
143 if (emu->audigy && emu->revision == 4) { /* P16V */ 145 if (emu->card_capabilities->ca0151_chip) { /* P16V */
144 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &emu->p16v_buffer) < 0) { 146 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &emu->p16v_buffer) < 0) {
145 snd_p16v_free(emu); 147 snd_p16v_free(emu);
146 return -ENOMEM; 148 return -ENOMEM;
@@ -161,7 +163,7 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
161 snd_card_free(card); 163 snd_card_free(card);
162 return err; 164 return err;
163 } 165 }
164 if (emu->audigy && emu->revision == 4) { /* P16V */ 166 if (emu->card_capabilities->ca0151_chip) { /* P16V */
165 if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) { 167 if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) {
166 snd_card_free(card); 168 snd_card_free(card);
167 return err; 169 return err;
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index a341e758acde..746b51ef3966 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -191,7 +191,7 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir)
191 /* Set playback routing. */ 191 /* Set playback routing. */
192 snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, 0x78e4); 192 snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, 0x78e4);
193 } 193 }
194 if (emu->audigy && (emu->serial == 0x10011102) ) { /* audigy2 Value */ 194 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
195 /* Hacks for Alice3 to work independent of haP16V driver */ 195 /* Hacks for Alice3 to work independent of haP16V driver */
196 u32 tmp; 196 u32 tmp;
197 197
@@ -253,6 +253,8 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir)
253 HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); 253 HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
254 else 254 else
255 outl(HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); 255 outl(HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
256 /* FIXME: Remove all these emu->model and replace it with a card recognition parameter,
257 * e.g. card_capabilities->joystick */
256 } else if (emu->model == 0x20 || 258 } else if (emu->model == 0x20 ||
257 emu->model == 0xc400 || 259 emu->model == 0xc400 ||
258 (emu->model == 0x21 && emu->revision < 6)) 260 (emu->model == 0x21 && emu->revision < 6))
@@ -299,12 +301,12 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir)
299 if (emu->audigy) { 301 if (emu->audigy) {
300 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); 302 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
301 303
302 if (emu->revision == 4) { /* audigy2 */ 304 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
303 /* Unmute Analog now. Set GPO6 to 1 for Apollo. 305 /* Unmute Analog now. Set GPO6 to 1 for Apollo.
304 * This has to be done after init ALice3 I2SOut beyond 48KHz. 306 * This has to be done after init ALice3 I2SOut beyond 48KHz.
305 * So, sequence is important. */ 307 * So, sequence is important. */
306 outl(inl(emu->port + A_IOCFG) | 0x0040, emu->port + A_IOCFG); 308 outl(inl(emu->port + A_IOCFG) | 0x0040, emu->port + A_IOCFG);
307 } else if (emu->serial == 0x10011102) { /* audigy2 value */ 309 } else if (emu->card_capabilities->ca0108_chip) { /* audigy2 value */
308 /* Unmute Analog now. */ 310 /* Unmute Analog now. */
309 outl(inl(emu->port + A_IOCFG) | 0x0060, emu->port + A_IOCFG); 311 outl(inl(emu->port + A_IOCFG) | 0x0060, emu->port + A_IOCFG);
310 } else { 312 } else {
@@ -614,6 +616,7 @@ static int snd_emu10k1_dev_free(snd_device_t *device)
614 616
615static emu_chip_details_t emu_chip_details[] = { 617static emu_chip_details_t emu_chip_details[] = {
616 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ 618 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/
619 /* Tested by James@superbug.co.uk 3rd July 2005 */
617 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, 620 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
618 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", 621 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]",
619 .id = "Audigy2", 622 .id = "Audigy2",
@@ -627,6 +630,14 @@ static emu_chip_details_t emu_chip_details[] = {
627 .emu10k2_chip = 1, 630 .emu10k2_chip = 1,
628 .ca0108_chip = 1, 631 .ca0108_chip = 1,
629 .ac97_chip = 1} , 632 .ac97_chip = 1} ,
633 /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */
634 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
635 .driver = "Audigy2", .name = "E-mu 1212m [4001]",
636 .id = "EMU1212m",
637 .emu10k2_chip = 1,
638 .ca0102_chip = 1,
639 .ecard = 1} ,
640 /* Tested by James@superbug.co.uk 3rd July 2005 */
630 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 641 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
631 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 642 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]",
632 .id = "Audigy2", 643 .id = "Audigy2",
@@ -687,18 +698,18 @@ static emu_chip_details_t emu_chip_details[] = {
687 .ca0151_chip = 1, 698 .ca0151_chip = 1,
688 .spdif_bug = 1, 699 .spdif_bug = 1,
689 .ac97_chip = 1} , 700 .ac97_chip = 1} ,
690 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10020052, 701 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102,
691 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", 702 .driver = "Audigy", .name = "Audigy 1 [SB0090]",
692 .id = "Audigy", 703 .id = "Audigy",
693 .emu10k2_chip = 1, 704 .emu10k2_chip = 1,
694 .ca0102_chip = 1, 705 .ca0102_chip = 1,
695 .spdif_bug = 1,
696 .ac97_chip = 1} , 706 .ac97_chip = 1} ,
697 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, 707 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102,
698 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 708 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]",
699 .id = "Audigy", 709 .id = "Audigy",
700 .emu10k2_chip = 1, 710 .emu10k2_chip = 1,
701 .ca0102_chip = 1, 711 .ca0102_chip = 1,
712 .spdif_bug = 1,
702 .ac97_chip = 1} , 713 .ac97_chip = 1} ,
703 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, 714 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102,
704 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 715 .driver = "Audigy", .name = "Audigy 1 [SB0090]",
@@ -712,54 +723,49 @@ static emu_chip_details_t emu_chip_details[] = {
712 .emu10k2_chip = 1, 723 .emu10k2_chip = 1,
713 .ca0102_chip = 1, 724 .ca0102_chip = 1,
714 .ac97_chip = 1} , 725 .ac97_chip = 1} ,
715 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 726 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102,
716 .driver = "EMU10K1", .name = "E-mu APS [4001]", 727 .driver = "EMU10K1", .name = "SBLive! [SB0105]",
717 .id = "APS",
718 .emu10k1_chip = 1,
719 .ecard = 1} ,
720 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
721 .driver = "EMU10K1", .name = "SBLive! Player 5.1 [SB0060]",
722 .id = "Live", 728 .id = "Live",
723 .emu10k1_chip = 1, 729 .emu10k1_chip = 1,
724 .ac97_chip = 1, 730 .ac97_chip = 1,
725 .sblive51 = 1} , 731 .sblive51 = 1} ,
726 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 732 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102,
727 .driver = "EMU10K1", .name = "SB Live 5.1", 733 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]",
728 .id = "Live", 734 .id = "Live",
729 .emu10k1_chip = 1, 735 .emu10k1_chip = 1,
730 .ac97_chip = 1, 736 .ac97_chip = 1,
731 .sblive51 = 1} , 737 .sblive51 = 1} ,
732 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, 738 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102,
733 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", 739 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]",
734 .id = "Live",
735 .emu10k1_chip = 1,
736 .ac97_chip = 1} ,
737 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
738 .driver = "EMU10K1", .name = "SBLive! [CT4620]",
739 .id = "Live", 740 .id = "Live",
740 .emu10k1_chip = 1, 741 .emu10k1_chip = 1,
741 .ac97_chip = 1, 742 .ac97_chip = 1,
742 .sblive51 = 1} , 743 .sblive51 = 1} ,
743 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, 744 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102,
744 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", 745 .driver = "EMU10K1", .name = "SB Live 5.1",
745 .id = "Live", 746 .id = "Live",
746 .emu10k1_chip = 1, 747 .emu10k1_chip = 1,
747 .ac97_chip = 1, 748 .ac97_chip = 1,
748 .sblive51 = 1} , 749 .sblive51 = 1} ,
749 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, 750 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
750 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", 751 .driver = "EMU10K1", .name = "SBLive! Player 5.1 [SB0060]",
751 .id = "Live", 752 .id = "Live",
752 .emu10k1_chip = 1, 753 .emu10k1_chip = 1,
753 .ac97_chip = 1, 754 .ac97_chip = 1,
754 .sblive51 = 1} , 755 .sblive51 = 1} ,
755 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, 756 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
756 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", 757 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]",
757 .id = "Live", 758 .id = "Live",
758 .emu10k1_chip = 1, 759 .emu10k1_chip = 1,
759 .ac97_chip = 1, 760 .ac97_chip = 1,
760 .sblive51 = 1} , 761 .sblive51 = 1} ,
761 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, 762 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
762 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", 763 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]",
764 .id = "Live",
765 .emu10k1_chip = 1,
766 .ac97_chip = 1} ,
767 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102,
768 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]",
763 .id = "Live", 769 .id = "Live",
764 .emu10k1_chip = 1, 770 .emu10k1_chip = 1,
765 .ac97_chip = 1, 771 .ac97_chip = 1,
@@ -770,50 +776,50 @@ static emu_chip_details_t emu_chip_details[] = {
770 .emu10k1_chip = 1, 776 .emu10k1_chip = 1,
771 .ac97_chip = 1, 777 .ac97_chip = 1,
772 .sblive51 = 1} , 778 .sblive51 = 1} ,
773 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, 779 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102,
774 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", 780 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]",
775 .id = "Live", 781 .id = "Live",
776 .emu10k1_chip = 1, 782 .emu10k1_chip = 1,
777 .ac97_chip = 1, 783 .ac97_chip = 1,
778 .sblive51 = 1} , 784 .sblive51 = 1} ,
779 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 785 /* Tested by James@superbug.co.uk 3rd July 2005 */
780 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 786 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102,
787 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]",
781 .id = "Live", 788 .id = "Live",
782 .emu10k1_chip = 1, 789 .emu10k1_chip = 1,
783 .ac97_chip = 1, 790 .ac97_chip = 1,
784 .sblive51 = 1} , 791 .sblive51 = 1} ,
785 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, 792 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102,
786 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", 793 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]",
787 .id = "Live", 794 .id = "Live",
788 .emu10k1_chip = 1, 795 .emu10k1_chip = 1,
789 .ac97_chip = 1, 796 .ac97_chip = 1,
790 .sblive51 = 1} , 797 .sblive51 = 1} ,
791 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, 798 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102,
792 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", 799 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]",
793 .id = "Live", 800 .id = "Live",
794 .emu10k1_chip = 1, 801 .emu10k1_chip = 1,
795 .ac97_chip = 1, 802 .ac97_chip = 1,
796 .sblive51 = 1} , 803 .sblive51 = 1} ,
797 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 804 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102,
798 .driver = "EMU10K1", .name = "SBLive! Value [SB0060]", 805 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]",
799 .id = "Live", 806 .id = "Live",
800 .emu10k1_chip = 1, 807 .emu10k1_chip = 1,
801 .ac97_chip = 1, 808 .ac97_chip = 1,
802 .sblive51 = 1} , 809 .sblive51 = 1} ,
803 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, 810 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102,
804 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", 811 .driver = "EMU10K1", .name = "E-mu APS [4001]",
805 .id = "Live", 812 .id = "APS",
806 .emu10k1_chip = 1, 813 .emu10k1_chip = 1,
807 .ac97_chip = 1, 814 .ecard = 1} ,
808 .sblive51 = 1} , 815 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
809 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, 816 .driver = "EMU10K1", .name = "SBLive! [CT4620]",
810 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]",
811 .id = "Live", 817 .id = "Live",
812 .emu10k1_chip = 1, 818 .emu10k1_chip = 1,
813 .ac97_chip = 1, 819 .ac97_chip = 1,
814 .sblive51 = 1} , 820 .sblive51 = 1} ,
815 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, 821 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102,
816 .driver = "EMU10K1", .name = "SBLive! [SB0105]", 822 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]",
817 .id = "Live", 823 .id = "Live",
818 .emu10k1_chip = 1, 824 .emu10k1_chip = 1,
819 .ac97_chip = 1, 825 .ac97_chip = 1,
@@ -833,6 +839,7 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
833 unsigned short extout_mask, 839 unsigned short extout_mask,
834 long max_cache_bytes, 840 long max_cache_bytes,
835 int enable_ir, 841 int enable_ir,
842 uint subsystem,
836 emu10k1_t ** remu) 843 emu10k1_t ** remu)
837{ 844{
838 emu10k1_t *emu; 845 emu10k1_t *emu;
@@ -878,10 +885,16 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
878 885
879 for (c = emu_chip_details; c->vendor; c++) { 886 for (c = emu_chip_details; c->vendor; c++) {
880 if (c->vendor == pci->vendor && c->device == pci->device) { 887 if (c->vendor == pci->vendor && c->device == pci->device) {
881 if (c->subsystem && c->subsystem != emu->serial) 888 if (subsystem) {
882 continue; 889 if (c->subsystem && (c->subsystem == subsystem) ) {
883 if (c->revision && c->revision != emu->revision) 890 break;
884 continue; 891 } else continue;
892 } else {
893 if (c->subsystem && (c->subsystem != emu->serial) )
894 continue;
895 if (c->revision && c->revision != emu->revision)
896 continue;
897 }
885 break; 898 break;
886 } 899 }
887 } 900 }
@@ -892,10 +905,14 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
892 return -ENOENT; 905 return -ENOENT;
893 } 906 }
894 emu->card_capabilities = c; 907 emu->card_capabilities = c;
895 if (c->subsystem != 0) 908 if (c->subsystem && !subsystem)
896 snd_printdd("Sound card name=%s\n", c->name); 909 snd_printdd("Sound card name=%s\n", c->name);
897 else 910 else if (subsystem)
898 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x\n", c->name, pci->vendor, pci->device, emu->serial); 911 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x. Forced to subsytem=0x%x\n",
912 c->name, pci->vendor, pci->device, emu->serial, c->subsystem);
913 else
914 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n",
915 c->name, pci->vendor, pci->device, emu->serial);
899 916
900 if (!*card->id && c->id) { 917 if (!*card->id && c->id) {
901 int i, n = 0; 918 int i, n = 0;
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 98f980189892..a1691330d3b6 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -822,7 +822,7 @@ static int snd_p16v_volume_put_analog_unknown(snd_kcontrol_t * kcontrol,
822static snd_kcontrol_new_t snd_p16v_volume_control_analog_front = 822static snd_kcontrol_new_t snd_p16v_volume_control_analog_front =
823{ 823{
824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
825 .name = "HD Analog Front Volume", 825 .name = "HD Analog Front Playback Volume",
826 .info = snd_p16v_volume_info, 826 .info = snd_p16v_volume_info,
827 .get = snd_p16v_volume_get_analog_front, 827 .get = snd_p16v_volume_get_analog_front,
828 .put = snd_p16v_volume_put_analog_front 828 .put = snd_p16v_volume_put_analog_front
@@ -831,7 +831,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_front =
831static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe = 831static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe =
832{ 832{
833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
834 .name = "HD Analog Center/LFE Volume", 834 .name = "HD Analog Center/LFE Playback Volume",
835 .info = snd_p16v_volume_info, 835 .info = snd_p16v_volume_info,
836 .get = snd_p16v_volume_get_analog_center_lfe, 836 .get = snd_p16v_volume_get_analog_center_lfe,
837 .put = snd_p16v_volume_put_analog_center_lfe 837 .put = snd_p16v_volume_put_analog_center_lfe
@@ -840,7 +840,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe =
840static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown = 840static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown =
841{ 841{
842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
843 .name = "HD Analog Unknown Volume", 843 .name = "HD Analog Unknown Playback Volume",
844 .info = snd_p16v_volume_info, 844 .info = snd_p16v_volume_info,
845 .get = snd_p16v_volume_get_analog_unknown, 845 .get = snd_p16v_volume_get_analog_unknown,
846 .put = snd_p16v_volume_put_analog_unknown 846 .put = snd_p16v_volume_put_analog_unknown
@@ -849,7 +849,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown =
849static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear = 849static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear =
850{ 850{
851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
852 .name = "HD Analog Rear Volume", 852 .name = "HD Analog Rear Playback Volume",
853 .info = snd_p16v_volume_info, 853 .info = snd_p16v_volume_info,
854 .get = snd_p16v_volume_get_analog_rear, 854 .get = snd_p16v_volume_get_analog_rear,
855 .put = snd_p16v_volume_put_analog_rear 855 .put = snd_p16v_volume_put_analog_rear
@@ -858,7 +858,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear =
858static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front = 858static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front =
859{ 859{
860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
861 .name = "HD SPDIF Front Volume", 861 .name = "HD SPDIF Front Playback Volume",
862 .info = snd_p16v_volume_info, 862 .info = snd_p16v_volume_info,
863 .get = snd_p16v_volume_get_spdif_front, 863 .get = snd_p16v_volume_get_spdif_front,
864 .put = snd_p16v_volume_put_spdif_front 864 .put = snd_p16v_volume_put_spdif_front
@@ -867,7 +867,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front =
867static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe = 867static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe =
868{ 868{
869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
870 .name = "HD SPDIF Center/LFE Volume", 870 .name = "HD SPDIF Center/LFE Playback Volume",
871 .info = snd_p16v_volume_info, 871 .info = snd_p16v_volume_info,
872 .get = snd_p16v_volume_get_spdif_center_lfe, 872 .get = snd_p16v_volume_get_spdif_center_lfe,
873 .put = snd_p16v_volume_put_spdif_center_lfe 873 .put = snd_p16v_volume_put_spdif_center_lfe
@@ -876,7 +876,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe =
876static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown = 876static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown =
877{ 877{
878 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 878 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
879 .name = "HD SPDIF Unknown Volume", 879 .name = "HD SPDIF Unknown Playback Volume",
880 .info = snd_p16v_volume_info, 880 .info = snd_p16v_volume_info,
881 .get = snd_p16v_volume_get_spdif_unknown, 881 .get = snd_p16v_volume_get_spdif_unknown,
882 .put = snd_p16v_volume_put_spdif_unknown 882 .put = snd_p16v_volume_put_spdif_unknown
@@ -885,7 +885,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown =
885static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear = 885static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear =
886{ 886{
887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
888 .name = "HD SPDIF Rear Volume", 888 .name = "HD SPDIF Rear Playback Volume",
889 .info = snd_p16v_volume_info, 889 .info = snd_p16v_volume_info,
890 .get = snd_p16v_volume_get_spdif_rear, 890 .get = snd_p16v_volume_get_spdif_rear,
891 .put = snd_p16v_volume_put_spdif_rear 891 .put = snd_p16v_volume_put_spdif_rear
@@ -936,7 +936,7 @@ static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol,
936static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata = 936static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata =
937{ 937{
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
939 .name = "HD Capture source", 939 .name = "HD source Capture",
940 .info = snd_p16v_capture_source_info, 940 .info = snd_p16v_capture_source_info,
941 .get = snd_p16v_capture_source_get, 941 .get = snd_p16v_capture_source_get,
942 .put = snd_p16v_capture_source_put 942 .put = snd_p16v_capture_source_put
@@ -985,7 +985,7 @@ static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol,
985static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata = 985static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata =
986{ 986{
987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
988 .name = "HD Capture channel", 988 .name = "HD channel Capture",
989 .info = snd_p16v_capture_channel_info, 989 .info = snd_p16v_capture_channel_info,
990 .get = snd_p16v_capture_channel_get, 990 .get = snd_p16v_capture_channel_get,
991 .put = snd_p16v_capture_channel_put 991 .put = snd_p16v_capture_channel_put
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 4e63498a58b2..78a81f3912a1 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -685,6 +685,15 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97,
685 return 0; 685 return 0;
686} 686}
687 687
688static void snd_es1371_codec_wait(ac97_t *ac97)
689{
690 msleep(750);
691 snd_es1371_codec_read(ac97, AC97_RESET);
692 snd_es1371_codec_read(ac97, AC97_VENDOR_ID1);
693 snd_es1371_codec_read(ac97, AC97_VENDOR_ID2);
694 msleep(50);
695}
696
688static void snd_es1371_adc_rate(ensoniq_t * ensoniq, unsigned int rate) 697static void snd_es1371_adc_rate(ensoniq_t * ensoniq, unsigned int rate)
689{ 698{
690 unsigned int n, truncm, freq, result; 699 unsigned int n, truncm, freq, result;
@@ -1585,6 +1594,7 @@ static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq)
1585 static ac97_bus_ops_t ops = { 1594 static ac97_bus_ops_t ops = {
1586 .write = snd_es1371_codec_write, 1595 .write = snd_es1371_codec_write,
1587 .read = snd_es1371_codec_read, 1596 .read = snd_es1371_codec_read,
1597 .wait = snd_es1371_codec_wait,
1588 }; 1598 };
1589 1599
1590 if ((err = snd_ac97_bus(card, 0, &ops, NULL, &pbus)) < 0) 1600 if ((err = snd_ac97_bus(card, 0, &ops, NULL, &pbus)) < 0)
@@ -2008,21 +2018,11 @@ static int __devinit snd_ensoniq_create(snd_card_t * card,
2008 if (pci->vendor == es1371_ac97_reset_hack[idx].vid && 2018 if (pci->vendor == es1371_ac97_reset_hack[idx].vid &&
2009 pci->device == es1371_ac97_reset_hack[idx].did && 2019 pci->device == es1371_ac97_reset_hack[idx].did &&
2010 ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { 2020 ensoniq->rev == es1371_ac97_reset_hack[idx].rev) {
2011 unsigned long tmo;
2012 signed long tmo2;
2013
2014 ensoniq->cssr |= ES_1371_ST_AC97_RST; 2021 ensoniq->cssr |= ES_1371_ST_AC97_RST;
2015 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); 2022 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS));
2016 /* need to delay around 20ms(bleech) to give 2023 /* need to delay around 20ms(bleech) to give
2017 some CODECs enough time to wakeup */ 2024 some CODECs enough time to wakeup */
2018 tmo = jiffies + (HZ / 50) + 1; 2025 msleep(20);
2019 while (1) {
2020 tmo2 = tmo - jiffies;
2021 if (tmo2 <= 0)
2022 break;
2023 set_current_state(TASK_UNINTERRUPTIBLE);
2024 schedule_timeout(tmo2);
2025 }
2026 break; 2026 break;
2027 } 2027 }
2028 /* AC'97 warm reset to start the bitclk */ 2028 /* AC'97 warm reset to start the bitclk */
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 327a341e276b..9d7a28783930 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -664,11 +664,6 @@ static inline u16 maestro_read(es1968_t *chip, u16 reg)
664 return result; 664 return result;
665} 665}
666 666
667#define big_mdelay(msec) do {\
668 set_current_state(TASK_UNINTERRUPTIBLE);\
669 schedule_timeout(((msec) * HZ + 999) / 1000);\
670} while (0)
671
672/* Wait for the codec bus to be free */ 667/* Wait for the codec bus to be free */
673static int snd_es1968_ac97_wait(es1968_t *chip) 668static int snd_es1968_ac97_wait(es1968_t *chip)
674{ 669{
@@ -1809,8 +1804,7 @@ static void __devinit es1968_measure_clock(es1968_t *chip)
1809 snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR); 1804 snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR);
1810 do_gettimeofday(&start_time); 1805 do_gettimeofday(&start_time);
1811 spin_unlock_irq(&chip->reg_lock); 1806 spin_unlock_irq(&chip->reg_lock);
1812 set_current_state(TASK_UNINTERRUPTIBLE); 1807 msleep(50);
1813 schedule_timeout(HZ / 20); /* 50 msec */
1814 spin_lock_irq(&chip->reg_lock); 1808 spin_lock_irq(&chip->reg_lock);
1815 offset = __apu_get_register(chip, apu, 5); 1809 offset = __apu_get_register(chip, apu, 5);
1816 do_gettimeofday(&stop_time); 1810 do_gettimeofday(&stop_time);
@@ -2093,7 +2087,7 @@ static void snd_es1968_ac97_reset(es1968_t *chip)
2093 outw(0x0000, ioaddr + 0x60); /* write 0 to gpio 0 */ 2087 outw(0x0000, ioaddr + 0x60); /* write 0 to gpio 0 */
2094 udelay(20); 2088 udelay(20);
2095 outw(0x0001, ioaddr + 0x60); /* write 1 to gpio 1 */ 2089 outw(0x0001, ioaddr + 0x60); /* write 1 to gpio 1 */
2096 big_mdelay(20); 2090 msleep(20);
2097 2091
2098 outw(save_68 | 0x1, ioaddr + 0x68); /* now restore .. */ 2092 outw(save_68 | 0x1, ioaddr + 0x68); /* now restore .. */
2099 outw((inw(ioaddr + 0x38) & 0xfffc) | 0x1, ioaddr + 0x38); 2093 outw((inw(ioaddr + 0x38) & 0xfffc) | 0x1, ioaddr + 0x38);
@@ -2109,7 +2103,7 @@ static void snd_es1968_ac97_reset(es1968_t *chip)
2109 outw(0x0001, ioaddr + 0x60); /* write 1 to gpio */ 2103 outw(0x0001, ioaddr + 0x60); /* write 1 to gpio */
2110 udelay(20); 2104 udelay(20);
2111 outw(0x0009, ioaddr + 0x60); /* write 9 to gpio */ 2105 outw(0x0009, ioaddr + 0x60); /* write 9 to gpio */
2112 big_mdelay(500); 2106 msleep(500);
2113 //outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38); 2107 //outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38);
2114 outw(inw(ioaddr + 0x3a) & 0xfffc, ioaddr + 0x3a); 2108 outw(inw(ioaddr + 0x3a) & 0xfffc, ioaddr + 0x3a);
2115 outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c); 2109 outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c);
@@ -2135,7 +2129,7 @@ static void snd_es1968_ac97_reset(es1968_t *chip)
2135 2129
2136 if (w > 10000) { 2130 if (w > 10000) {
2137 outb(inb(ioaddr + 0x37) | 0x08, ioaddr + 0x37); /* do a software reset */ 2131 outb(inb(ioaddr + 0x37) | 0x08, ioaddr + 0x37); /* do a software reset */
2138 big_mdelay(500); /* oh my.. */ 2132 msleep(500); /* oh my.. */
2139 outb(inb(ioaddr + 0x37) & ~0x08, 2133 outb(inb(ioaddr + 0x37) & ~0x08,
2140 ioaddr + 0x37); 2134 ioaddr + 0x37);
2141 udelay(1); 2135 udelay(1);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 59991560d492..dd0d99d2ad27 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -262,6 +262,9 @@ enum {
262#define AC_PINCTL_OUT_EN (1<<6) 262#define AC_PINCTL_OUT_EN (1<<6)
263#define AC_PINCTL_HP_EN (1<<7) 263#define AC_PINCTL_HP_EN (1<<7)
264 264
265/* Unsolicited response - 8bit */
266#define AC_USRSP_EN (1<<7)
267
265/* configuration default - 32bit */ 268/* configuration default - 32bit */
266#define AC_DEFCFG_SEQUENCE (0xf<<0) 269#define AC_DEFCFG_SEQUENCE (0xf<<0)
267#define AC_DEFCFG_DEF_ASSOC (0xf<<4) 270#define AC_DEFCFG_DEF_ASSOC (0xf<<4)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 5e0cca36ed57..288ab0764830 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -178,6 +178,9 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
178#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ 178#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
179#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ 179#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
180 180
181/* GCTL unsolicited response enable bit */
182#define ICH6_GCTL_UREN (1<<8)
183
181/* GCTL reset bit */ 184/* GCTL reset bit */
182#define ICH6_GCTL_RESET (1<<0) 185#define ICH6_GCTL_RESET (1<<0)
183 186
@@ -562,6 +565,9 @@ static int azx_reset(azx_t *chip)
562 return -EBUSY; 565 return -EBUSY;
563 } 566 }
564 567
568 /* Accept unsolicited responses */
569 azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN);
570
565 /* detect codecs */ 571 /* detect codecs */
566 if (! chip->codec_mask) { 572 if (! chip->codec_mask) {
567 chip->codec_mask = azx_readw(chip, STATESTS); 573 chip->codec_mask = azx_readw(chip, STATESTS);
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 2d6e3e3d0a38..86f195f19eef 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -408,7 +408,7 @@ static int cmi9880_fill_multi_dac_nids(struct hda_codec *codec, const struct aut
408 /* search for an empty channel */ 408 /* search for an empty channel */
409 for (j = 0; j < cfg->line_outs; j++) { 409 for (j = 0; j < cfg->line_outs; j++) {
410 if (! assigned[j]) { 410 if (! assigned[j]) {
411 spec->dac_nids[i] = i + 0x03; 411 spec->dac_nids[i] = j + 0x03;
412 assigned[j] = 1; 412 assigned[j] = 1;
413 break; 413 break;
414 } 414 }
@@ -444,11 +444,10 @@ static int cmi9880_fill_multi_init(struct hda_codec *codec, const struct auto_pi
444 len = snd_hda_get_connections(codec, nid, conn, 4); 444 len = snd_hda_get_connections(codec, nid, conn, 4);
445 for (k = 0; k < len; k++) 445 for (k = 0; k < len; k++)
446 if (conn[k] == spec->dac_nids[i]) { 446 if (conn[k] == spec->dac_nids[i]) {
447 spec->multi_init[j].param = j; 447 spec->multi_init[j].param = k;
448 break; 448 break;
449 } 449 }
450 j++; 450 j++;
451 break;
452 } 451 }
453 } 452 }
454 return 0; 453 return 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index bab89843d850..9b8569900787 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -40,6 +40,7 @@ enum {
40 ALC880_W810, 40 ALC880_W810,
41 ALC880_Z71V, 41 ALC880_Z71V,
42 ALC880_AUTO, 42 ALC880_AUTO,
43 ALC880_6ST,
43 ALC880_6ST_DIG, 44 ALC880_6ST_DIG,
44 ALC880_F1734, 45 ALC880_F1734,
45 ALC880_ASUS, 46 ALC880_ASUS,
@@ -119,6 +120,7 @@ struct alc_spec {
119 unsigned int num_kctl_alloc, num_kctl_used; 120 unsigned int num_kctl_alloc, num_kctl_used;
120 snd_kcontrol_new_t *kctl_alloc; 121 snd_kcontrol_new_t *kctl_alloc;
121 struct hda_input_mux private_imux; 122 struct hda_input_mux private_imux;
123 hda_nid_t private_dac_nids[4];
122}; 124};
123 125
124 126
@@ -1547,9 +1549,10 @@ static struct hda_board_config alc880_cfg_tbl[] = {
1547 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, 1549 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1548 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, 1550 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1549 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, 1551 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1550 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, 1552 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1551 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, 1553 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1552 { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, 1554 /* note subvendor = 0 below */
1555 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1553 1556
1554 { .modelname = "w810", .config = ALC880_W810 }, 1557 { .modelname = "w810", .config = ALC880_W810 },
1555 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, 1558 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
@@ -1557,7 +1560,10 @@ static struct hda_board_config alc880_cfg_tbl[] = {
1557 { .modelname = "z71v", .config = ALC880_Z71V }, 1560 { .modelname = "z71v", .config = ALC880_Z71V },
1558 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, 1561 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1559 1562
1560 { .modelname = "6statack-digout", .config = ALC880_6ST_DIG }, 1563 { .modelname = "6stack", .config = ALC880_6ST },
1564 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
1565
1566 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
1561 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, 1567 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1562 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, 1568 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1563 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, 1569 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
@@ -1644,6 +1650,15 @@ static struct alc_config_preset alc880_presets[] = {
1644 .channel_mode = alc880_fivestack_modes, 1650 .channel_mode = alc880_fivestack_modes,
1645 .input_mux = &alc880_capture_source, 1651 .input_mux = &alc880_capture_source,
1646 }, 1652 },
1653 [ALC880_6ST] = {
1654 .mixers = { alc880_six_stack_mixer },
1655 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1656 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1657 .dac_nids = alc880_6st_dac_nids,
1658 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1659 .channel_mode = alc880_sixstack_modes,
1660 .input_mux = &alc880_6stack_capture_source,
1661 },
1647 [ALC880_6ST_DIG] = { 1662 [ALC880_6ST_DIG] = {
1648 .mixers = { alc880_six_stack_mixer }, 1663 .mixers = { alc880_six_stack_mixer },
1649 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 1664 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
@@ -1656,7 +1671,8 @@ static struct alc_config_preset alc880_presets[] = {
1656 }, 1671 },
1657 [ALC880_W810] = { 1672 [ALC880_W810] = {
1658 .mixers = { alc880_w810_base_mixer }, 1673 .mixers = { alc880_w810_base_mixer },
1659 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs }, 1674 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1675 alc880_gpio2_init_verbs },
1660 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 1676 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1661 .dac_nids = alc880_w810_dac_nids, 1677 .dac_nids = alc880_w810_dac_nids,
1662 .dig_out_nid = ALC880_DIGOUT_NID, 1678 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -1666,8 +1682,7 @@ static struct alc_config_preset alc880_presets[] = {
1666 }, 1682 },
1667 [ALC880_Z71V] = { 1683 [ALC880_Z71V] = {
1668 .mixers = { alc880_z71v_mixer }, 1684 .mixers = { alc880_z71v_mixer },
1669 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs, 1685 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
1670 alc880_gpio2_init_verbs },
1671 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 1686 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1672 .dac_nids = alc880_z71v_dac_nids, 1687 .dac_nids = alc880_z71v_dac_nids,
1673 .dig_out_nid = ALC880_DIGOUT_NID, 1688 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -1809,6 +1824,7 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi
1809 int i, j; 1824 int i, j;
1810 1825
1811 memset(assigned, 0, sizeof(assigned)); 1826 memset(assigned, 0, sizeof(assigned));
1827 spec->multiout.dac_nids = spec->private_dac_nids;
1812 1828
1813 /* check the pins hardwired to audio widget */ 1829 /* check the pins hardwired to audio widget */
1814 for (i = 0; i < cfg->line_outs; i++) { 1830 for (i = 0; i < cfg->line_outs; i++) {
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 013be2ea513a..9d503da7320d 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -30,32 +30,37 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <sound/core.h> 32#include <sound/core.h>
33#include <sound/asoundef.h>
33#include "hda_codec.h" 34#include "hda_codec.h"
34#include "hda_local.h" 35#include "hda_local.h"
35 36
36#undef STAC_TEST 37#undef STAC_TEST
37 38
39#define NUM_CONTROL_ALLOC 32
40#define STAC_HP_EVENT 0x37
41#define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT)
42
38struct sigmatel_spec { 43struct sigmatel_spec {
44 snd_kcontrol_new_t *mixers[4];
45 unsigned int num_mixers;
46
47 unsigned int surr_switch: 1;
48
39 /* playback */ 49 /* playback */
40 struct hda_multi_out multiout; 50 struct hda_multi_out multiout;
41 hda_nid_t playback_nid; 51 hda_nid_t dac_nids[4];
42 52
43 /* capture */ 53 /* capture */
44 hda_nid_t *adc_nids; 54 hda_nid_t *adc_nids;
45 unsigned int num_adcs; 55 unsigned int num_adcs;
46 hda_nid_t *mux_nids; 56 hda_nid_t *mux_nids;
47 unsigned int num_muxes; 57 unsigned int num_muxes;
48 hda_nid_t capture_nid;
49 hda_nid_t dig_in_nid; 58 hda_nid_t dig_in_nid;
50 59
51 /* power management*/ 60#ifdef STAC_TEST
52 hda_nid_t *pstate_nids;
53 unsigned int num_pstates;
54
55 /* pin widgets */ 61 /* pin widgets */
56 hda_nid_t *pin_nids; 62 hda_nid_t *pin_nids;
57 unsigned int num_pins; 63 unsigned int num_pins;
58#ifdef STAC_TEST
59 unsigned int *pin_configs; 64 unsigned int *pin_configs;
60#endif 65#endif
61 66
@@ -64,16 +69,20 @@ struct sigmatel_spec {
64 snd_kcontrol_new_t *mixer; 69 snd_kcontrol_new_t *mixer;
65 70
66 /* capture source */ 71 /* capture source */
67 struct hda_input_mux input_mux; 72 struct hda_input_mux *input_mux;
68 char input_labels[HDA_MAX_NUM_INPUTS][16];
69 unsigned int cur_mux[2]; 73 unsigned int cur_mux[2];
70 74
71 /* channel mode */ 75 /* channel mode */
72 unsigned int num_ch_modes; 76 unsigned int num_ch_modes;
73 unsigned int cur_ch_mode; 77 unsigned int cur_ch_mode;
74 const struct sigmatel_channel_mode *channel_modes;
75 78
76 struct hda_pcm pcm_rec[1]; /* PCM information */ 79 struct hda_pcm pcm_rec[2]; /* PCM information */
80
81 /* dynamic controls and input_mux */
82 struct auto_pin_cfg autocfg;
83 unsigned int num_kctl_alloc, num_kctl_used;
84 snd_kcontrol_new_t *kctl_alloc;
85 struct hda_input_mux private_imux;
77}; 86};
78 87
79static hda_nid_t stac9200_adc_nids[1] = { 88static hda_nid_t stac9200_adc_nids[1] = {
@@ -88,14 +97,6 @@ static hda_nid_t stac9200_dac_nids[1] = {
88 0x02, 97 0x02,
89}; 98};
90 99
91static hda_nid_t stac9200_pstate_nids[3] = {
92 0x01, 0x02, 0x03,
93};
94
95static hda_nid_t stac9200_pin_nids[8] = {
96 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
97};
98
99static hda_nid_t stac922x_adc_nids[2] = { 100static hda_nid_t stac922x_adc_nids[2] = {
100 0x06, 0x07, 101 0x06, 0x07,
101}; 102};
@@ -104,24 +105,22 @@ static hda_nid_t stac922x_mux_nids[2] = {
104 0x12, 0x13, 105 0x12, 0x13,
105}; 106};
106 107
107static hda_nid_t stac922x_dac_nids[4] = { 108#ifdef STAC_TEST
108 0x02, 0x03, 0x04, 0x05, 109static hda_nid_t stac9200_pin_nids[8] = {
109}; 110 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
110
111static hda_nid_t stac922x_pstate_nids[8] = {
112 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11,
113}; 111};
114 112
115static hda_nid_t stac922x_pin_nids[10] = { 113static hda_nid_t stac922x_pin_nids[10] = {
116 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 114 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
117 0x0f, 0x10, 0x11, 0x15, 0x1b, 115 0x0f, 0x10, 0x11, 0x15, 0x1b,
118}; 116};
117#endif
119 118
120static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 119static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
121{ 120{
122 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
123 struct sigmatel_spec *spec = codec->spec; 122 struct sigmatel_spec *spec = codec->spec;
124 return snd_hda_input_mux_info(&spec->input_mux, uinfo); 123 return snd_hda_input_mux_info(spec->input_mux, uinfo);
125} 124}
126 125
127static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 126static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
@@ -140,26 +139,64 @@ static int stac92xx_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
140 struct sigmatel_spec *spec = codec->spec; 139 struct sigmatel_spec *spec = codec->spec;
141 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 140 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
142 141
143 return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol, 142 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
144 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); 143 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
145} 144}
146 145
147static struct hda_verb stac9200_ch2_init[] = { 146static struct hda_verb stac9200_core_init[] = {
148 /* set dac0mux for dac converter */ 147 /* set dac0mux for dac converter */
149 { 0x07, 0x701, 0x00}, 148 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
150 {} 149 {}
151}; 150};
152 151
153static struct hda_verb stac922x_ch2_init[] = { 152static struct hda_verb stac922x_core_init[] = {
154 /* set master volume and direct control */ 153 /* set master volume and direct control */
155 { 0x16, 0x70f, 0xff}, 154 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
156 {} 155 {}
157}; 156};
158 157
159struct sigmatel_channel_mode { 158static int stac922x_channel_modes[3] = {2, 6, 8};
160 unsigned int channels; 159
161 const struct hda_verb *sequence; 160static int stac922x_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
162}; 161{
162 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
163 struct sigmatel_spec *spec = codec->spec;
164
165 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
166 uinfo->count = 1;
167 uinfo->value.enumerated.items = spec->num_ch_modes;
168 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
169 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
170 sprintf(uinfo->value.enumerated.name, "%dch",
171 stac922x_channel_modes[uinfo->value.enumerated.item]);
172 return 0;
173}
174
175static int stac922x_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
176{
177 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
178 struct sigmatel_spec *spec = codec->spec;
179
180 ucontrol->value.enumerated.item[0] = spec->cur_ch_mode;
181 return 0;
182}
183
184static int stac922x_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
185{
186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
187 struct sigmatel_spec *spec = codec->spec;
188
189 if (ucontrol->value.enumerated.item[0] >= spec->num_ch_modes)
190 ucontrol->value.enumerated.item[0] = spec->num_ch_modes;
191 if (ucontrol->value.enumerated.item[0] == spec->cur_ch_mode &&
192 ! codec->in_resume)
193 return 0;
194
195 spec->cur_ch_mode = ucontrol->value.enumerated.item[0];
196 spec->multiout.max_channels = stac922x_channel_modes[spec->cur_ch_mode];
197
198 return 1;
199}
163 200
164static snd_kcontrol_new_t stac9200_mixer[] = { 201static snd_kcontrol_new_t stac9200_mixer[] = {
165 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 202 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
@@ -174,13 +211,12 @@ static snd_kcontrol_new_t stac9200_mixer[] = {
174 }, 211 },
175 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), 212 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
176 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), 213 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
177 HDA_CODEC_VOLUME("Input Mux Volume", 0x0c, 0, HDA_OUTPUT), 214 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
178 { } /* end */ 215 { } /* end */
179}; 216};
180 217
218/* This needs to be generated dynamically based on sequence */
181static snd_kcontrol_new_t stac922x_mixer[] = { 219static snd_kcontrol_new_t stac922x_mixer[] = {
182 HDA_CODEC_VOLUME("PCM Playback Volume", 0x2, 0x0, HDA_OUTPUT),
183 HDA_CODEC_MUTE("PCM Playback Switch", 0x2, 0x0, HDA_OUTPUT),
184 { 220 {
185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
186 .name = "Input Source", 222 .name = "Input Source",
@@ -195,14 +231,38 @@ static snd_kcontrol_new_t stac922x_mixer[] = {
195 { } /* end */ 231 { } /* end */
196}; 232};
197 233
234static snd_kcontrol_new_t stac922x_ch_mode_mixer[] = {
235 {
236 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
237 .name = "Channel Mode",
238 .info = stac922x_ch_mode_info,
239 .get = stac922x_ch_mode_get,
240 .put = stac922x_ch_mode_put,
241 },
242 { } /* end */
243};
244
198static int stac92xx_build_controls(struct hda_codec *codec) 245static int stac92xx_build_controls(struct hda_codec *codec)
199{ 246{
200 struct sigmatel_spec *spec = codec->spec; 247 struct sigmatel_spec *spec = codec->spec;
201 int err; 248 int err;
249 int i;
202 250
203 err = snd_hda_add_new_ctls(codec, spec->mixer); 251 err = snd_hda_add_new_ctls(codec, spec->mixer);
204 if (err < 0) 252 if (err < 0)
205 return err; 253 return err;
254
255 for (i = 0; i < spec->num_mixers; i++) {
256 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
257 if (err < 0)
258 return err;
259 }
260
261 if (spec->surr_switch) {
262 err = snd_hda_add_new_ctls(codec, stac922x_ch_mode_mixer);
263 if (err < 0)
264 return err;
265 }
206 if (spec->multiout.dig_out_nid) { 266 if (spec->multiout.dig_out_nid) {
207 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 267 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
208 if (err < 0) 268 if (err < 0)
@@ -222,9 +282,9 @@ static unsigned int stac9200_pin_configs[8] = {
222 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, 282 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
223}; 283};
224 284
225static unsigned int stac922x_pin_configs[14] = { 285static unsigned int stac922x_pin_configs[10] = {
226 0x40000100, 0x40000100, 0x40000100, 0x01114010, 286 0x01014010, 0x01014011, 0x01014012, 0x0221401f,
227 0x01813122, 0x40000100, 0x01447010, 0x01c47010, 287 0x01813122, 0x01014014, 0x01441030, 0x01c41030,
228 0x40000100, 0x40000100, 288 0x40000100, 0x40000100,
229}; 289};
230 290
@@ -255,180 +315,66 @@ static void stac92xx_set_config_regs(struct hda_codec *codec)
255} 315}
256#endif 316#endif
257 317
258static int stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, unsigned int value)
259{
260 unsigned int pin_ctl;
261
262 pin_ctl = snd_hda_codec_read(codec, nid, 0,
263 AC_VERB_GET_PIN_WIDGET_CONTROL,
264 0x00);
265 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
266 pin_ctl | value);
267
268 return 0;
269}
270
271static int stac92xx_set_vref(struct hda_codec *codec, hda_nid_t nid)
272{
273 unsigned int vref_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) >> AC_PINCAP_VREF_SHIFT;
274 unsigned int vref_ctl = AC_PINCTL_VREF_HIZ;
275
276 if (vref_caps & AC_PINCAP_VREF_100)
277 vref_ctl = AC_PINCTL_VREF_100;
278 else if (vref_caps & AC_PINCAP_VREF_80)
279 vref_ctl = AC_PINCTL_VREF_80;
280 else if (vref_caps & AC_PINCAP_VREF_50)
281 vref_ctl = AC_PINCTL_VREF_50;
282 else if (vref_caps & AC_PINCAP_VREF_GRD)
283 vref_ctl = AC_PINCTL_VREF_GRD;
284
285 stac92xx_set_pinctl(codec, nid, vref_ctl);
286
287 return 0;
288}
289
290/* 318/*
291 * retrieve the default device type from the default config value 319 * Analog playback callbacks
292 */ 320 */
293#define get_defcfg_type(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 321static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
294#define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 322 struct hda_codec *codec,
295 323 snd_pcm_substream_t *substream)
296static int stac92xx_config_pin(struct hda_codec *codec, hda_nid_t nid, unsigned int pin_cfg)
297{ 324{
298 struct sigmatel_spec *spec = codec->spec; 325 struct sigmatel_spec *spec = codec->spec;
299 u32 location = get_defcfg_location(pin_cfg); 326 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
300 char *label;
301 const char *type = NULL;
302 int ainput = 0;
303
304 switch(get_defcfg_type(pin_cfg)) {
305 case AC_JACK_HP_OUT:
306 /* Enable HP amp */
307 stac92xx_set_pinctl(codec, nid, AC_PINCTL_HP_EN);
308 /* Fall through */
309 case AC_JACK_SPDIF_OUT:
310 case AC_JACK_LINE_OUT:
311 case AC_JACK_SPEAKER:
312 /* Enable output */
313 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
314 break;
315 case AC_JACK_SPDIF_IN:
316 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
317 break;
318 case AC_JACK_MIC_IN:
319 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
320 type = "Front Mic";
321 else
322 type = "Mic";
323 ainput = 1;
324 /* Set vref */
325 stac92xx_set_vref(codec, nid);
326 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
327 break;
328 case AC_JACK_CD:
329 type = "CD";
330 ainput = 1;
331 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
332 break;
333 case AC_JACK_LINE_IN:
334 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
335 type = "Front Line";
336 else
337 type = "Line";
338 ainput = 1;
339 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
340 break;
341 case AC_JACK_AUX:
342 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
343 type = "Front Aux";
344 else
345 type = "Aux";
346 ainput = 1;
347 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
348 break;
349 }
350
351 if (ainput) {
352 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
353 int i, j, num_cons, index = -1;
354 if (!type)
355 type = "Input";
356 label = spec->input_labels[spec->input_mux.num_items];
357 strcpy(label, type);
358 spec->input_mux.items[spec->input_mux.num_items].label = label;
359 for (i=0; i<spec->num_muxes; i++) {
360 num_cons = snd_hda_get_connections(codec, spec->mux_nids[i], con_lst, HDA_MAX_NUM_INPUTS);
361 for (j=0; j<num_cons; j++)
362 if (con_lst[j] == nid) {
363 index = j;
364 break;
365 }
366 if (index >= 0)
367 break;
368 }
369 spec->input_mux.items[spec->input_mux.num_items].index = index;
370 spec->input_mux.num_items++;
371 }
372
373 return 0;
374} 327}
375 328
376static int stac92xx_config_pins(struct hda_codec *codec) 329/*
330 * set up the i/o for analog out
331 * when the digital out is available, copy the front out to digital out, too.
332 */
333static int stac92xx_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout,
334 unsigned int stream_tag,
335 unsigned int format,
336 snd_pcm_substream_t *substream)
377{ 337{
378 struct sigmatel_spec *spec = codec->spec; 338 hda_nid_t *nids = mout->dac_nids;
339 int chs = substream->runtime->channels;
379 int i; 340 int i;
380 unsigned int pin_cfg;
381 341
382 for (i=0; i < spec->num_pins; i++) { 342 down(&codec->spdif_mutex);
383 /* Default to disabled */ 343 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
384 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 344 if (chs == 2 &&
385 AC_VERB_SET_PIN_WIDGET_CONTROL, 345 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) &&
386 0x00); 346 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) {
387 347 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
388 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, 348 /* setup digital receiver */
389 AC_VERB_GET_CONFIG_DEFAULT, 349 snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
390 0x00); 350 stream_tag, 0, format);
391 if (((pin_cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) == AC_JACK_PORT_NONE) 351 } else {
392 continue; /* Move on */ 352 mout->dig_out_used = 0;
393 353 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
394 stac92xx_config_pin(codec, spec->pin_nids[i], pin_cfg); 354 }
395 } 355 }
396 356 up(&codec->spdif_mutex);
397 return 0; 357
398} 358 /* front */
399 359 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format);
400static int stac92xx_init(struct hda_codec *codec) 360 if (mout->hp_nid)
401{ 361 /* headphone out will just decode front left/right (stereo) */
402 struct sigmatel_spec *spec = codec->spec; 362 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format);
403 int i; 363 /* surrounds */
404 364 if (mout->max_channels > 2)
405 for (i=0; i < spec->num_pstates; i++) 365 for (i = 1; i < mout->num_dacs; i++) {
406 snd_hda_codec_write(codec, spec->pstate_nids[i], 0, 366 if ((mout->max_channels == 6) && (i == 3))
407 AC_VERB_SET_POWER_STATE, 0x00); 367 break;
408 368 if (chs >= (i + 1) * 2) /* independent out */
409 mdelay(100); 369 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2,
410 370 format);
411 snd_hda_sequence_write(codec, spec->init); 371 else /* copy front */
412 372 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0,
413#ifdef STAC_TEST 373 format);
414 stac92xx_set_config_regs(codec); 374 }
415#endif
416
417 stac92xx_config_pins(codec);
418
419 return 0; 375 return 0;
420} 376}
421 377
422/*
423 * Analog playback callbacks
424 */
425static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
426 struct hda_codec *codec,
427 snd_pcm_substream_t *substream)
428{
429 struct sigmatel_spec *spec = codec->spec;
430 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
431}
432 378
433static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 379static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
434 struct hda_codec *codec, 380 struct hda_codec *codec,
@@ -437,7 +383,7 @@ static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
437 snd_pcm_substream_t *substream) 383 snd_pcm_substream_t *substream)
438{ 384{
439 struct sigmatel_spec *spec = codec->spec; 385 struct sigmatel_spec *spec = codec->spec;
440 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, 386 return stac92xx_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
441 format, substream); 387 format, substream);
442} 388}
443 389
@@ -516,7 +462,7 @@ static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
516static struct hda_pcm_stream stac92xx_pcm_analog_playback = { 462static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
517 .substreams = 1, 463 .substreams = 1,
518 .channels_min = 2, 464 .channels_min = 2,
519 .channels_max = 2, 465 .channels_max = 8,
520 .nid = 0x02, /* NID to query formats and rates */ 466 .nid = 0x02, /* NID to query formats and rates */
521 .ops = { 467 .ops = {
522 .open = stac92xx_playback_pcm_open, 468 .open = stac92xx_playback_pcm_open,
@@ -544,11 +490,9 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
544 codec->num_pcms = 1; 490 codec->num_pcms = 1;
545 codec->pcm_info = info; 491 codec->pcm_info = info;
546 492
547 info->name = "STAC92xx"; 493 info->name = "STAC92xx Analog";
548 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; 494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
549 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->playback_nid;
550 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; 495 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
551 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->capture_nid;
552 496
553 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
554 codec->num_pcms++; 498 codec->num_pcms++;
@@ -567,21 +511,413 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
567 return 0; 511 return 0;
568} 512}
569 513
514enum {
515 STAC_CTL_WIDGET_VOL,
516 STAC_CTL_WIDGET_MUTE,
517};
518
519static snd_kcontrol_new_t stac92xx_control_templates[] = {
520 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
521 HDA_CODEC_MUTE(NULL, 0, 0, 0),
522};
523
524/* add dynamic controls */
525static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
526{
527 snd_kcontrol_new_t *knew;
528
529 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
530 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
531
532 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
533 if (! knew)
534 return -ENOMEM;
535 if (spec->kctl_alloc) {
536 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
537 kfree(spec->kctl_alloc);
538 }
539 spec->kctl_alloc = knew;
540 spec->num_kctl_alloc = num;
541 }
542
543 knew = &spec->kctl_alloc[spec->num_kctl_used];
544 *knew = stac92xx_control_templates[type];
545 knew->name = kstrdup(name, GFP_KERNEL);
546 if (! knew->name)
547 return -ENOMEM;
548 knew->private_value = val;
549 spec->num_kctl_used++;
550 return 0;
551}
552
553/* fill in the dac_nids table from the parsed pin configuration */
554static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
555{
556 struct sigmatel_spec *spec = codec->spec;
557 hda_nid_t nid;
558 int i;
559
560 /* check the pins hardwired to audio widget */
561 for (i = 0; i < cfg->line_outs; i++) {
562 nid = cfg->line_out_pins[i];
563 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
565 }
566
567 spec->multiout.num_dacs = cfg->line_outs;
568
569 return 0;
570}
571
572/* add playback controls from the parsed DAC table */
573static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg)
574{
575 char name[32];
576 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
577 hda_nid_t nid;
578 int i, err;
579
580 for (i = 0; i < cfg->line_outs; i++) {
581 if (! spec->multiout.dac_nids[i])
582 continue;
583
584 nid = spec->multiout.dac_nids[i];
585
586 if (i == 2) {
587 /* Center/LFE */
588 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
589 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
590 return err;
591 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
592 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
593 return err;
594 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
595 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
596 return err;
597 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
598 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
599 return err;
600 } else {
601 sprintf(name, "%s Playback Volume", chname[i]);
602 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
603 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
604 return err;
605 sprintf(name, "%s Playback Switch", chname[i]);
606 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
607 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
608 return err;
609 }
610 }
611
612 return 0;
613}
614
615/* add playback controls for HP output */
616static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
617{
618 struct sigmatel_spec *spec = codec->spec;
619 hda_nid_t pin = cfg->hp_pin;
620 hda_nid_t nid;
621 int i, err;
622 unsigned int wid_caps;
623
624 if (! pin)
625 return 0;
626
627 wid_caps = snd_hda_param_read(codec, pin, AC_PAR_AUDIO_WIDGET_CAP);
628 if (wid_caps & AC_WCAP_UNSOL_CAP)
629 /* Enable unsolicited responses on the HP widget */
630 snd_hda_codec_write(codec, pin, 0,
631 AC_VERB_SET_UNSOLICITED_ENABLE,
632 STAC_UNSOL_ENABLE);
633
634 nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
635 for (i = 0; i < cfg->line_outs; i++) {
636 if (! spec->multiout.dac_nids[i])
637 continue;
638 if (spec->multiout.dac_nids[i] == nid)
639 return 0;
640 }
641
642 spec->multiout.hp_nid = nid;
643
644 /* control HP volume/switch on the output mixer amp */
645 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
646 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
647 return err;
648 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
649 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
650 return err;
651
652 return 0;
653}
654
655/* create playback/capture controls for input pins */
656static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
657{
658 struct sigmatel_spec *spec = codec->spec;
659 static char *labels[AUTO_PIN_LAST] = {
660 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
661 };
662 struct hda_input_mux *imux = &spec->private_imux;
663 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
664 int i, j, k;
665
666 for (i = 0; i < AUTO_PIN_LAST; i++) {
667 int index = -1;
668 if (cfg->input_pins[i]) {
669 imux->items[imux->num_items].label = labels[i];
670
671 for (j=0; j<spec->num_muxes; j++) {
672 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
673 for (k=0; k<num_cons; k++)
674 if (con_lst[k] == cfg->input_pins[i]) {
675 index = k;
676 break;
677 }
678 if (index >= 0)
679 break;
680 }
681 imux->items[imux->num_items].index = index;
682 imux->num_items++;
683 }
684 }
685
686 return 0;
687}
688
689static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
690
691{
692 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
693}
694
695static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
696{
697 struct sigmatel_spec *spec = codec->spec;
698 int i;
699
700 for (i = 0; i < spec->autocfg.line_outs; i++) {
701 hda_nid_t nid = spec->autocfg.line_out_pins[i];
702 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
703 }
704}
705
706static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
707{
708 struct sigmatel_spec *spec = codec->spec;
709 hda_nid_t pin;
710
711 pin = spec->autocfg.hp_pin;
712 if (pin) /* connect to front */
713 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
714}
715
716static int stac922x_parse_auto_config(struct hda_codec *codec)
717{
718 struct sigmatel_spec *spec = codec->spec;
719 int err;
720
721 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
722 return err;
723 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
724 return err;
725 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
726 return 0; /* can't find valid pin config */
727
728 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
729 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
730 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
731 return err;
732
733 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
734 if (spec->multiout.max_channels > 2) {
735 spec->surr_switch = 1;
736 spec->cur_ch_mode = 1;
737 spec->num_ch_modes = 2;
738 if (spec->multiout.max_channels == 8) {
739 spec->cur_ch_mode++;
740 spec->num_ch_modes++;
741 }
742 }
743
744 if (spec->autocfg.dig_out_pin) {
745 spec->multiout.dig_out_nid = 0x08;
746 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
747 }
748 if (spec->autocfg.dig_in_pin) {
749 spec->dig_in_nid = 0x09;
750 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
751 }
752
753 if (spec->kctl_alloc)
754 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
755
756 spec->input_mux = &spec->private_imux;
757
758 return 1;
759}
760
761static int stac9200_parse_auto_config(struct hda_codec *codec)
762{
763 struct sigmatel_spec *spec = codec->spec;
764 int err;
765
766 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
767 return err;
768
769 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
770 return err;
771
772 if (spec->autocfg.dig_out_pin) {
773 spec->multiout.dig_out_nid = 0x05;
774 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
775 }
776 if (spec->autocfg.dig_in_pin) {
777 spec->dig_in_nid = 0x04;
778 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
779 }
780
781 if (spec->kctl_alloc)
782 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
783
784 spec->input_mux = &spec->private_imux;
785
786 return 1;
787}
788
789static int stac92xx_init_pstate(struct hda_codec *codec)
790{
791 hda_nid_t nid, nid_start;
792 int nodes;
793
794 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_POWER_STATE, 0x00);
795
796 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
797 for (nid = nid_start; nid < nodes + nid_start; nid++) {
798 unsigned int wid_caps = snd_hda_param_read(codec, nid,
799 AC_PAR_AUDIO_WIDGET_CAP);
800 if (wid_caps & AC_WCAP_POWER)
801 snd_hda_codec_write(codec, nid, 0,
802 AC_VERB_SET_POWER_STATE, 0x00);
803 }
804
805 mdelay(100);
806
807 return 0;
808}
809
810static int stac92xx_init(struct hda_codec *codec)
811{
812 struct sigmatel_spec *spec = codec->spec;
813
814 stac92xx_init_pstate(codec);
815
816 snd_hda_sequence_write(codec, spec->init);
817
818 stac92xx_auto_init_multi_out(codec);
819 stac92xx_auto_init_hp_out(codec);
820
821 return 0;
822}
823
570static void stac92xx_free(struct hda_codec *codec) 824static void stac92xx_free(struct hda_codec *codec)
571{ 825{
572 kfree(codec->spec); 826 struct sigmatel_spec *spec = codec->spec;
827 int i;
828
829 if (! spec)
830 return;
831
832 if (spec->kctl_alloc) {
833 for (i = 0; i < spec->num_kctl_used; i++)
834 kfree(spec->kctl_alloc[i].name);
835 kfree(spec->kctl_alloc);
836 }
837
838 kfree(spec);
839}
840
841static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
842 unsigned int flag)
843{
844 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
845 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
846 snd_hda_codec_write(codec, nid, 0,
847 AC_VERB_SET_PIN_WIDGET_CONTROL,
848 pin_ctl | flag);
849}
850
851static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
852 unsigned int flag)
853{
854 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
855 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
856 snd_hda_codec_write(codec, nid, 0,
857 AC_VERB_SET_PIN_WIDGET_CONTROL,
858 pin_ctl & ~flag);
859}
860
861static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
862{
863 struct sigmatel_spec *spec = codec->spec;
864 struct auto_pin_cfg *cfg = &spec->autocfg;
865 int i, presence;
866
867 if ((res >> 26) != STAC_HP_EVENT)
868 return;
869
870 presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
871 AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
872
873 if (presence) {
874 /* disable lineouts, enable hp */
875 for (i = 0; i < cfg->line_outs; i++)
876 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
877 AC_PINCTL_OUT_EN);
878 stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
879 } else {
880 /* enable lineouts, disable hp */
881 for (i = 0; i < cfg->line_outs; i++)
882 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
883 AC_PINCTL_OUT_EN);
884 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
885 }
886}
887
888#ifdef CONFIG_PM
889static int stac92xx_resume(struct hda_codec *codec)
890{
891 struct sigmatel_spec *spec = codec->spec;
892 int i;
893
894 stac92xx_init(codec);
895 for (i = 0; i < spec->num_mixers; i++)
896 snd_hda_resume_ctls(codec, spec->mixers[i]);
897 if (spec->multiout.dig_out_nid)
898 snd_hda_resume_spdif_out(codec);
899 if (spec->dig_in_nid)
900 snd_hda_resume_spdif_in(codec);
901
902 return 0;
573} 903}
904#endif
574 905
575static struct hda_codec_ops stac92xx_patch_ops = { 906static struct hda_codec_ops stac92xx_patch_ops = {
576 .build_controls = stac92xx_build_controls, 907 .build_controls = stac92xx_build_controls,
577 .build_pcms = stac92xx_build_pcms, 908 .build_pcms = stac92xx_build_pcms,
578 .init = stac92xx_init, 909 .init = stac92xx_init,
579 .free = stac92xx_free, 910 .free = stac92xx_free,
911 .unsol_event = stac92xx_unsol_event,
912#ifdef CONFIG_PM
913 .resume = stac92xx_resume,
914#endif
580}; 915};
581 916
582static int patch_stac9200(struct hda_codec *codec) 917static int patch_stac9200(struct hda_codec *codec)
583{ 918{
584 struct sigmatel_spec *spec; 919 struct sigmatel_spec *spec;
920 int err;
585 921
586 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 922 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
587 if (spec == NULL) 923 if (spec == NULL)
@@ -589,26 +925,27 @@ static int patch_stac9200(struct hda_codec *codec)
589 925
590 codec->spec = spec; 926 codec->spec = spec;
591 927
928#ifdef STAC_TEST
929 spec->pin_nids = stac9200_pin_nids;
930 spec->num_pins = 8;
931 spec->pin_configs = stac9200_pin_configs;
932 stac92xx_set_config_regs(codec);
933#endif
592 spec->multiout.max_channels = 2; 934 spec->multiout.max_channels = 2;
593 spec->multiout.num_dacs = 1; 935 spec->multiout.num_dacs = 1;
594 spec->multiout.dac_nids = stac9200_dac_nids; 936 spec->multiout.dac_nids = stac9200_dac_nids;
595 spec->multiout.dig_out_nid = 0x05;
596 spec->dig_in_nid = 0x04;
597 spec->adc_nids = stac9200_adc_nids; 937 spec->adc_nids = stac9200_adc_nids;
598 spec->mux_nids = stac9200_mux_nids; 938 spec->mux_nids = stac9200_mux_nids;
599 spec->num_muxes = 1; 939 spec->num_muxes = 1;
600 spec->input_mux.num_items = 0; 940
601 spec->pstate_nids = stac9200_pstate_nids; 941 spec->init = stac9200_core_init;
602 spec->num_pstates = 3;
603 spec->pin_nids = stac9200_pin_nids;
604#ifdef STAC_TEST
605 spec->pin_configs = stac9200_pin_configs;
606#endif
607 spec->num_pins = 8;
608 spec->init = stac9200_ch2_init;
609 spec->mixer = stac9200_mixer; 942 spec->mixer = stac9200_mixer;
610 spec->playback_nid = 0x02; 943
611 spec->capture_nid = 0x03; 944 err = stac9200_parse_auto_config(codec);
945 if (err < 0) {
946 stac92xx_free(codec);
947 return err;
948 }
612 949
613 codec->patch_ops = stac92xx_patch_ops; 950 codec->patch_ops = stac92xx_patch_ops;
614 951
@@ -618,6 +955,7 @@ static int patch_stac9200(struct hda_codec *codec)
618static int patch_stac922x(struct hda_codec *codec) 955static int patch_stac922x(struct hda_codec *codec)
619{ 956{
620 struct sigmatel_spec *spec; 957 struct sigmatel_spec *spec;
958 int err;
621 959
622 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 960 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
623 if (spec == NULL) 961 if (spec == NULL)
@@ -625,26 +963,26 @@ static int patch_stac922x(struct hda_codec *codec)
625 963
626 codec->spec = spec; 964 codec->spec = spec;
627 965
628 spec->multiout.max_channels = 2;
629 spec->multiout.num_dacs = 4;
630 spec->multiout.dac_nids = stac922x_dac_nids;
631 spec->multiout.dig_out_nid = 0x08;
632 spec->dig_in_nid = 0x09;
633 spec->adc_nids = stac922x_adc_nids;
634 spec->mux_nids = stac922x_mux_nids;
635 spec->num_muxes = 2;
636 spec->input_mux.num_items = 0;
637 spec->pstate_nids = stac922x_pstate_nids;
638 spec->num_pstates = 8;
639 spec->pin_nids = stac922x_pin_nids;
640#ifdef STAC_TEST 966#ifdef STAC_TEST
967 spec->num_pins = 10;
968 spec->pin_nids = stac922x_pin_nids;
641 spec->pin_configs = stac922x_pin_configs; 969 spec->pin_configs = stac922x_pin_configs;
970 stac92xx_set_config_regs(codec);
642#endif 971#endif
643 spec->num_pins = 10; 972 spec->adc_nids = stac922x_adc_nids;
644 spec->init = stac922x_ch2_init; 973 spec->mux_nids = stac922x_mux_nids;
974 spec->num_muxes = 2;
975
976 spec->init = stac922x_core_init;
645 spec->mixer = stac922x_mixer; 977 spec->mixer = stac922x_mixer;
646 spec->playback_nid = 0x02; 978
647 spec->capture_nid = 0x06; 979 spec->multiout.dac_nids = spec->dac_nids;
980
981 err = stac922x_parse_auto_config(codec);
982 if (err < 0) {
983 stac92xx_free(codec);
984 return err;
985 }
648 986
649 codec->patch_ops = stac92xx_patch_ops; 987 codec->patch_ops = stac92xx_patch_ops;
650 988
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 28ac005c21b5..d7af3e474432 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -424,6 +424,7 @@ struct _snd_intel8x0 {
424 unsigned xbox: 1; /* workaround for Xbox AC'97 detection */ 424 unsigned xbox: 1; /* workaround for Xbox AC'97 detection */
425 425
426 int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */ 426 int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
427 unsigned int sdm_saved; /* SDM reg value */
427 428
428 ac97_bus_t *ac97_bus; 429 ac97_bus_t *ac97_bus;
429 ac97_t *ac97[3]; 430 ac97_t *ac97[3];
@@ -2373,6 +2374,9 @@ static int intel8x0_suspend(snd_card_t *card, pm_message_t state)
2373 for (i = 0; i < 3; i++) 2374 for (i = 0; i < 3; i++)
2374 if (chip->ac97[i]) 2375 if (chip->ac97[i])
2375 snd_ac97_suspend(chip->ac97[i]); 2376 snd_ac97_suspend(chip->ac97[i]);
2377 if (chip->device_type == DEVICE_INTEL_ICH4)
2378 chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
2379
2376 if (chip->irq >= 0) 2380 if (chip->irq >= 0)
2377 free_irq(chip->irq, (void *)chip); 2381 free_irq(chip->irq, (void *)chip);
2378 pci_disable_device(chip->pci); 2382 pci_disable_device(chip->pci);
@@ -2390,6 +2394,16 @@ static int intel8x0_resume(snd_card_t *card)
2390 synchronize_irq(chip->irq); 2394 synchronize_irq(chip->irq);
2391 snd_intel8x0_chip_init(chip, 1); 2395 snd_intel8x0_chip_init(chip, 1);
2392 2396
2397 /* re-initialize mixer stuff */
2398 if (chip->device_type == DEVICE_INTEL_ICH4) {
2399 /* enable separate SDINs for ICH4 */
2400 iputbyte(chip, ICHREG(SDM), chip->sdm_saved);
2401 /* use slot 10/11 for SPDIF */
2402 iputdword(chip, ICHREG(GLOB_CNT),
2403 (igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_PCM_SPDIF_MASK) |
2404 ICH_PCM_SPDIF_1011);
2405 }
2406
2393 /* refill nocache */ 2407 /* refill nocache */
2394 if (chip->fix_nocache) 2408 if (chip->fix_nocache)
2395 fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 1); 2409 fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 1);
@@ -2455,8 +2469,7 @@ static void __devinit intel8x0_measure_ac97_clock(intel8x0_t *chip)
2455 } 2469 }
2456 do_gettimeofday(&start_time); 2470 do_gettimeofday(&start_time);
2457 spin_unlock_irq(&chip->reg_lock); 2471 spin_unlock_irq(&chip->reg_lock);
2458 set_current_state(TASK_UNINTERRUPTIBLE); 2472 msleep(50);
2459 schedule_timeout(HZ / 20);
2460 spin_lock_irq(&chip->reg_lock); 2473 spin_lock_irq(&chip->reg_lock);
2461 /* check the position */ 2474 /* check the position */
2462 pos = ichdev->fragsize1; 2475 pos = ichdev->fragsize1;
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 52c585901c54..39b5e7db1543 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -1050,11 +1050,6 @@ static struct m3_hv_quirk m3_hv_quirk_list[] = {
1050 * lowlevel functions 1050 * lowlevel functions
1051 */ 1051 */
1052 1052
1053#define big_mdelay(msec) do {\
1054 set_current_state(TASK_UNINTERRUPTIBLE);\
1055 schedule_timeout(((msec) * HZ) / 1000);\
1056} while (0)
1057
1058static inline void snd_m3_outw(m3_t *chip, u16 value, unsigned long reg) 1053static inline void snd_m3_outw(m3_t *chip, u16 value, unsigned long reg)
1059{ 1054{
1060 outw(value, chip->iobase + reg); 1055 outw(value, chip->iobase + reg);
@@ -1096,7 +1091,7 @@ static void snd_m3_assp_write(m3_t *chip, u16 region, u16 index, u16 data)
1096static void snd_m3_assp_halt(m3_t *chip) 1091static void snd_m3_assp_halt(m3_t *chip)
1097{ 1092{
1098 chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK; 1093 chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK;
1099 big_mdelay(10); 1094 msleep(10);
1100 snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); 1095 snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B);
1101} 1096}
1102 1097
@@ -2108,9 +2103,9 @@ static void snd_m3_ac97_reset(m3_t *chip)
2108 */ 2103 */
2109 tmp = inw(io + RING_BUS_CTRL_A); 2104 tmp = inw(io + RING_BUS_CTRL_A);
2110 outw(RAC_SDFS_ENABLE|LAC_SDFS_ENABLE, io + RING_BUS_CTRL_A); 2105 outw(RAC_SDFS_ENABLE|LAC_SDFS_ENABLE, io + RING_BUS_CTRL_A);
2111 big_mdelay(20); 2106 msleep(20);
2112 outw(tmp, io + RING_BUS_CTRL_A); 2107 outw(tmp, io + RING_BUS_CTRL_A);
2113 big_mdelay(50); 2108 msleep(50);
2114#endif 2109#endif
2115} 2110}
2116 2111
@@ -2525,9 +2520,13 @@ static void
2525snd_m3_enable_ints(m3_t *chip) 2520snd_m3_enable_ints(m3_t *chip)
2526{ 2521{
2527 unsigned long io = chip->iobase; 2522 unsigned long io = chip->iobase;
2523 unsigned short val;
2528 2524
2529 /* TODO: MPU401 not supported yet */ 2525 /* TODO: MPU401 not supported yet */
2530 outw(ASSP_INT_ENABLE | HV_INT_ENABLE /*| MPU401_INT_ENABLE*/, io + HOST_INT_CTRL); 2526 val = ASSP_INT_ENABLE /*| MPU401_INT_ENABLE*/;
2527 if (chip->hv_quirk && (chip->hv_quirk->config & HV_CTRL_ENABLE))
2528 val |= HV_INT_ENABLE;
2529 outw(val, io + HOST_INT_CTRL);
2531 outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE, 2530 outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE,
2532 io + ASSP_CONTROL_C); 2531 io + ASSP_CONTROL_C);
2533} 2532}
@@ -2589,7 +2588,7 @@ static int m3_suspend(snd_card_t *card, pm_message_t state)
2589 snd_pcm_suspend_all(chip->pcm); 2588 snd_pcm_suspend_all(chip->pcm);
2590 snd_ac97_suspend(chip->ac97); 2589 snd_ac97_suspend(chip->ac97);
2591 2590
2592 big_mdelay(10); /* give the assp a chance to idle.. */ 2591 msleep(10); /* give the assp a chance to idle.. */
2593 2592
2594 snd_m3_assp_halt(chip); 2593 snd_m3_assp_halt(chip);
2595 2594
@@ -2697,6 +2696,8 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2697 } 2696 }
2698 2697
2699 spin_lock_init(&chip->reg_lock); 2698 spin_lock_init(&chip->reg_lock);
2699 spin_lock_init(&chip->ac97_lock);
2700
2700 switch (pci->device) { 2701 switch (pci->device) {
2701 case PCI_DEVICE_ID_ESS_ALLEGRO: 2702 case PCI_DEVICE_ID_ESS_ALLEGRO:
2702 case PCI_DEVICE_ID_ESS_ALLEGRO_1: 2703 case PCI_DEVICE_ID_ESS_ALLEGRO_1:
@@ -2765,6 +2766,8 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2765 snd_m3_assp_init(chip); 2766 snd_m3_assp_init(chip);
2766 snd_m3_amp_enable(chip, 1); 2767 snd_m3_amp_enable(chip, 1);
2767 2768
2769 tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip);
2770
2768 if (request_irq(pci->irq, snd_m3_interrupt, SA_INTERRUPT|SA_SHIRQ, 2771 if (request_irq(pci->irq, snd_m3_interrupt, SA_INTERRUPT|SA_SHIRQ,
2769 card->driver, (void *)chip)) { 2772 card->driver, (void *)chip)) {
2770 snd_printk("unable to grab IRQ %d\n", pci->irq); 2773 snd_printk("unable to grab IRQ %d\n", pci->irq);
@@ -2786,9 +2789,6 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2786 return err; 2789 return err;
2787 } 2790 }
2788 2791
2789 spin_lock_init(&chip->ac97_lock);
2790 tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip);
2791
2792 if ((err = snd_m3_mixer(chip)) < 0) 2792 if ((err = snd_m3_mixer(chip)) < 0)
2793 return err; 2793 return err;
2794 2794
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 082c0d0f73d2..6c868d913634 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -445,9 +445,9 @@ static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd)
445 445
446static int mixart_sync_nonblock_events(mixart_mgr_t *mgr) 446static int mixart_sync_nonblock_events(mixart_mgr_t *mgr)
447{ 447{
448 int timeout = HZ; 448 unsigned long timeout = jiffies + HZ;
449 while (atomic_read(&mgr->msg_processed) > 0) { 449 while (atomic_read(&mgr->msg_processed) > 0) {
450 if (! timeout--) { 450 if (time_after(jiffies, timeout)) {
451 snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n"); 451 snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
452 return -EBUSY; 452 return -EBUSY;
453 } 453 }
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index a673cc438b91..796621de5009 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -445,6 +445,7 @@ struct _hdsp {
445 u32 control2_register; /* cached value */ 445 u32 control2_register; /* cached value */
446 u32 creg_spdif; 446 u32 creg_spdif;
447 u32 creg_spdif_stream; 447 u32 creg_spdif_stream;
448 int clock_source_locked;
448 char *card_name; /* digiface/multiface */ 449 char *card_name; /* digiface/multiface */
449 HDSP_IO_Type io_type; /* ditto, but for code use */ 450 HDSP_IO_Type io_type; /* ditto, but for code use */
450 unsigned short firmware_rev; 451 unsigned short firmware_rev;
@@ -678,8 +679,7 @@ static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) {
678 } 679 }
679 680
680 if ((1000 / HZ) < 3000) { 681 if ((1000 / HZ) < 3000) {
681 set_current_state(TASK_UNINTERRUPTIBLE); 682 ssleep(3);
682 schedule_timeout((3000 * HZ + 999) / 1000);
683 } else { 683 } else {
684 mdelay(3000); 684 mdelay(3000);
685 } 685 }
@@ -2095,6 +2095,34 @@ static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_val
2095 return change; 2095 return change;
2096} 2096}
2097 2097
2098static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
2099{
2100 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2101 uinfo->count = 1;
2102 uinfo->value.integer.min = 0;
2103 uinfo->value.integer.max = 1;
2104 return 0;
2105}
2106
2107static int snd_hdsp_get_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
2108{
2109 hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
2110
2111 ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
2112 return 0;
2113}
2114
2115static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
2116{
2117 hdsp_t *hdsp = snd_kcontrol_chip(kcontrol);
2118 int change;
2119
2120 change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked;
2121 if (change)
2122 hdsp->clock_source_locked = ucontrol->value.integer.value[0];
2123 return change;
2124}
2125
2098#define HDSP_DA_GAIN(xname, xindex) \ 2126#define HDSP_DA_GAIN(xname, xindex) \
2099{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2127{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
2100 .name = xname, \ 2128 .name = xname, \
@@ -3117,6 +3145,15 @@ HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0),
3117HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0), 3145HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
3118/* 'Sample Clock Source' complies with the alsa control naming scheme */ 3146/* 'Sample Clock Source' complies with the alsa control naming scheme */
3119HDSP_CLOCK_SOURCE("Sample Clock Source", 0), 3147HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
3148{
3149 /* FIXME: should be PCM or MIXER? */
3150 /* .iface = SNDRV_CTL_ELEM_IFACE_PCM, */
3151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3152 .name = "Sample Clock Source Locking",
3153 .info = snd_hdsp_info_clock_source_lock,
3154 .get = snd_hdsp_get_clock_source_lock,
3155 .put = snd_hdsp_put_clock_source_lock,
3156},
3120HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0), 3157HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
3121HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0), 3158HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0),
3122HDSP_AUTOSYNC_REF("AutoSync Reference", 0), 3159HDSP_AUTOSYNC_REF("AutoSync Reference", 0),
@@ -3349,6 +3386,7 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
3349 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode); 3386 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
3350 3387
3351 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); 3388 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
3389 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
3352 3390
3353 snd_iprintf(buffer, "\n"); 3391 snd_iprintf(buffer, "\n");
3354 3392
@@ -3853,13 +3891,14 @@ static int snd_hdsp_hw_params(snd_pcm_substream_t *substream,
3853 */ 3891 */
3854 3892
3855 spin_lock_irq(&hdsp->lock); 3893 spin_lock_irq(&hdsp->lock);
3856 if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { 3894 if (! hdsp->clock_source_locked) {
3857 spin_unlock_irq(&hdsp->lock); 3895 if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) {
3858 _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); 3896 spin_unlock_irq(&hdsp->lock);
3859 return err; 3897 _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
3860 } else { 3898 return err;
3861 spin_unlock_irq(&hdsp->lock); 3899 }
3862 } 3900 }
3901 spin_unlock_irq(&hdsp->lock);
3863 3902
3864 if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) { 3903 if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) {
3865 _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); 3904 _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
@@ -4284,13 +4323,17 @@ static int snd_hdsp_playback_open(snd_pcm_substream_t *substream)
4284 4323
4285 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 4324 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
4286 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes); 4325 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes);
4287 if (hdsp->io_type == H9632) { 4326 if (hdsp->clock_source_locked) {
4288 runtime->hw.channels_min = hdsp->qs_out_channels; 4327 runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate;
4289 runtime->hw.channels_max = hdsp->ss_out_channels; 4328 } else if (hdsp->io_type == H9632) {
4290 runtime->hw.rate_max = 192000; 4329 runtime->hw.rate_max = 192000;
4291 runtime->hw.rates = SNDRV_PCM_RATE_KNOT; 4330 runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
4292 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates); 4331 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates);
4293 } 4332 }
4333 if (hdsp->io_type == H9632) {
4334 runtime->hw.channels_min = hdsp->qs_out_channels;
4335 runtime->hw.channels_max = hdsp->ss_out_channels;
4336 }
4294 4337
4295 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4338 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4296 snd_hdsp_hw_rule_out_channels, hdsp, 4339 snd_hdsp_hw_rule_out_channels, hdsp,
@@ -5036,8 +5079,7 @@ static int __devinit snd_hdsp_create(snd_card_t *card,
5036 if (!is_9652 && !is_9632) { 5079 if (!is_9652 && !is_9632) {
5037 /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */ 5080 /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
5038 if ((1000 / HZ) < 2000) { 5081 if ((1000 / HZ) < 2000) {
5039 set_current_state(TASK_UNINTERRUPTIBLE); 5082 ssleep(2);
5040 schedule_timeout((2000 * HZ + 999) / 1000);
5041 } else { 5083 } else {
5042 mdelay(2000); 5084 mdelay(2000);
5043 } 5085 }
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index a09b0fb49e81..29d89bfba0a4 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -472,6 +472,7 @@ void snd_trident_write_voice_regs(trident_t * trident,
472 break; 472 break;
473 default: 473 default:
474 snd_BUG(); 474 snd_BUG();
475 return;
475 } 476 }
476 477
477 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); 478 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR));
@@ -3152,8 +3153,7 @@ static int snd_trident_gameport_open(struct gameport *gameport, int mode)
3152 switch (mode) { 3153 switch (mode) {
3153 case GAMEPORT_MODE_COOKED: 3154 case GAMEPORT_MODE_COOKED:
3154 outb(GAMEPORT_MODE_ADC, TRID_REG(chip, GAMEPORT_GCR)); 3155 outb(GAMEPORT_MODE_ADC, TRID_REG(chip, GAMEPORT_GCR));
3155 set_current_state(TASK_UNINTERRUPTIBLE); 3156 msleep(20);
3156 schedule_timeout(1 + 20 * HZ / 1000); /* 20msec */
3157 return 0; 3157 return 0;
3158 case GAMEPORT_MODE_RAW: 3158 case GAMEPORT_MODE_RAW:
3159 outb(0, TRID_REG(chip, GAMEPORT_GCR)); 3159 outb(0, TRID_REG(chip, GAMEPORT_GCR));
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 42c48f0ce8e8..4889600387c8 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -547,8 +547,7 @@ static void snd_via82xx_codec_wait(ac97_t *ac97)
547 int err; 547 int err;
548 err = snd_via82xx_codec_ready(chip, ac97->num); 548 err = snd_via82xx_codec_ready(chip, ac97->num);
549 /* here we need to wait fairly for long time.. */ 549 /* here we need to wait fairly for long time.. */
550 set_current_state(TASK_UNINTERRUPTIBLE); 550 msleep(500);
551 schedule_timeout(HZ/2);
552} 551}
553 552
554static void snd_via82xx_codec_write(ac97_t *ac97, 553static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -1847,7 +1846,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip)
1847static int snd_via82xx_chip_init(via82xx_t *chip) 1846static int snd_via82xx_chip_init(via82xx_t *chip)
1848{ 1847{
1849 unsigned int val; 1848 unsigned int val;
1850 int max_count; 1849 unsigned long end_time;
1851 unsigned char pval; 1850 unsigned char pval;
1852 1851
1853#if 0 /* broken on K7M? */ 1852#if 0 /* broken on K7M? */
@@ -1889,14 +1888,14 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
1889 } 1888 }
1890 1889
1891 /* wait until codec ready */ 1890 /* wait until codec ready */
1892 max_count = ((3 * HZ) / 4) + 1; 1891 end_time = jiffies + msecs_to_jiffies(750);
1893 do { 1892 do {
1894 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); 1893 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
1895 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ 1894 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
1896 break; 1895 break;
1897 set_current_state(TASK_UNINTERRUPTIBLE); 1896 set_current_state(TASK_UNINTERRUPTIBLE);
1898 schedule_timeout(1); 1897 schedule_timeout(1);
1899 } while (--max_count > 0); 1898 } while (time_before(jiffies, end_time));
1900 1899
1901 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 1900 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
1902 snd_printk("AC'97 codec is not ready [0x%x]\n", val); 1901 snd_printk("AC'97 codec is not ready [0x%x]\n", val);
@@ -1905,7 +1904,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
1905 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | 1904 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
1906 VIA_REG_AC97_SECONDARY_VALID | 1905 VIA_REG_AC97_SECONDARY_VALID |
1907 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); 1906 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
1908 max_count = ((3 * HZ) / 4) + 1; 1907 end_time = jiffies + msecs_to_jiffies(750);
1909 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | 1908 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
1910 VIA_REG_AC97_SECONDARY_VALID | 1909 VIA_REG_AC97_SECONDARY_VALID |
1911 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); 1910 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
@@ -1916,7 +1915,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
1916 } 1915 }
1917 set_current_state(TASK_INTERRUPTIBLE); 1916 set_current_state(TASK_INTERRUPTIBLE);
1918 schedule_timeout(1); 1917 schedule_timeout(1);
1919 } while (--max_count > 0); 1918 } while (time_before(jiffies, end_time));
1920 /* This is ok, the most of motherboards have only one codec */ 1919 /* This is ok, the most of motherboards have only one codec */
1921 1920
1922 __ac97_ok2: 1921 __ac97_ok2:
@@ -2178,7 +2177,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2178 { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */ 2177 { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */
2179 { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */ 2178 { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */
2180 { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */ 2179 { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */
2181 { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_NO_VRA }, /* Twinhead mobo */ 2180 { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_SRC }, /* Twinhead laptop */
2182 { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */ 2181 { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */
2183 { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */ 2182 { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */
2184 { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */ 2183 { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */
@@ -2187,6 +2186,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2187 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ 2186 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */
2188 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ 2187 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */
2189 { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */ 2188 { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */
2189 { .subvendor = 0x4005, .subdevice = 0x4710, .action = VIA_DXS_SRC }, /* MSI K7T266 Pro2 (MS-6380 V2.0) BIOS 3.7 */
2190 { } /* terminator */ 2190 { } /* terminator */
2191 }; 2191 };
2192 struct dxs_whitelist *w; 2192 struct dxs_whitelist *w;
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 5896d289f9ac..4a9779cc9733 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -408,8 +408,7 @@ static void snd_via82xx_codec_wait(ac97_t *ac97)
408 int err; 408 int err;
409 err = snd_via82xx_codec_ready(chip, ac97->num); 409 err = snd_via82xx_codec_ready(chip, ac97->num);
410 /* here we need to wait fairly for long time.. */ 410 /* here we need to wait fairly for long time.. */
411 set_current_state(TASK_UNINTERRUPTIBLE); 411 msleep(500);
412 schedule_timeout(HZ/2);
413} 412}
414 413
415static void snd_via82xx_codec_write(ac97_t *ac97, 414static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -923,7 +922,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip)
923static int snd_via82xx_chip_init(via82xx_t *chip) 922static int snd_via82xx_chip_init(via82xx_t *chip)
924{ 923{
925 unsigned int val; 924 unsigned int val;
926 int max_count; 925 unsigned long end_time;
927 unsigned char pval; 926 unsigned char pval;
928 927
929 pci_read_config_byte(chip->pci, VIA_MC97_CTRL, &pval); 928 pci_read_config_byte(chip->pci, VIA_MC97_CTRL, &pval);
@@ -962,14 +961,14 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
962 } 961 }
963 962
964 /* wait until codec ready */ 963 /* wait until codec ready */
965 max_count = ((3 * HZ) / 4) + 1; 964 end_time = jiffies + msecs_to_jiffies(750);
966 do { 965 do {
967 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); 966 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
968 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ 967 if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
969 break; 968 break;
970 set_current_state(TASK_UNINTERRUPTIBLE); 969 set_current_state(TASK_UNINTERRUPTIBLE);
971 schedule_timeout(1); 970 schedule_timeout(1);
972 } while (--max_count > 0); 971 } while (time_before(jiffies, end_time));
973 972
974 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 973 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
975 snd_printk("AC'97 codec is not ready [0x%x]\n", val); 974 snd_printk("AC'97 codec is not ready [0x%x]\n", val);
@@ -977,7 +976,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
977 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | 976 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
978 VIA_REG_AC97_SECONDARY_VALID | 977 VIA_REG_AC97_SECONDARY_VALID |
979 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); 978 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
980 max_count = ((3 * HZ) / 4) + 1; 979 end_time = jiffies + msecs_to_jiffies(750);
981 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | 980 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
982 VIA_REG_AC97_SECONDARY_VALID | 981 VIA_REG_AC97_SECONDARY_VALID |
983 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); 982 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
@@ -988,7 +987,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
988 } 987 }
989 set_current_state(TASK_INTERRUPTIBLE); 988 set_current_state(TASK_INTERRUPTIBLE);
990 schedule_timeout(1); 989 schedule_timeout(1);
991 } while (--max_count > 0); 990 } while (time_before(jiffies, end_time));
992 /* This is ok, the most of motherboards have only one codec */ 991 /* This is ok, the most of motherboards have only one codec */
993 992
994 __ac97_ok2: 993 __ac97_ok2:
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 2ae79610ecb5..d54f88a1b525 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -84,16 +84,16 @@ static inline void snd_ymfpci_writel(ymfpci_t *chip, u32 offset, u32 val)
84 84
85static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary) 85static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary)
86{ 86{
87 signed long end_time; 87 unsigned long end_time;
88 u32 reg = secondary ? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR; 88 u32 reg = secondary ? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR;
89 89
90 end_time = (jiffies + ((3 * HZ) / 4)) + 1; 90 end_time = jiffies + msecs_to_jiffies(750);
91 do { 91 do {
92 if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0) 92 if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0)
93 return 0; 93 return 0;
94 set_current_state(TASK_UNINTERRUPTIBLE); 94 set_current_state(TASK_UNINTERRUPTIBLE);
95 schedule_timeout(1); 95 schedule_timeout(1);
96 } while (end_time - (signed long)jiffies >= 0); 96 } while (time_before(jiffies, end_time));
97 snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg)); 97 snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg));
98 return -EBUSY; 98 return -EBUSY;
99} 99}