diff options
Diffstat (limited to 'sound/pci')
46 files changed, 5900 insertions, 3707 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 748f6b7d90b7..fb5ee3cc3968 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -135,11 +135,11 @@ config SND_AW2 | |||
135 | 135 | ||
136 | 136 | ||
137 | config SND_AZT3328 | 137 | config SND_AZT3328 |
138 | tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)" | 138 | tristate "Aztech AZF3328 / PCI168" |
139 | depends on EXPERIMENTAL | ||
140 | select SND_OPL3_LIB | 139 | select SND_OPL3_LIB |
141 | select SND_MPU401_UART | 140 | select SND_MPU401_UART |
142 | select SND_PCM | 141 | select SND_PCM |
142 | select SND_RAWMIDI | ||
143 | help | 143 | help |
144 | Say Y here to include support for Aztech AZF3328 (PCI168) | 144 | Say Y here to include support for Aztech AZF3328 (PCI168) |
145 | soundcards. | 145 | soundcards. |
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index c551006e2920..b458d208720b 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c | |||
@@ -310,12 +310,16 @@ static int snd_ali_codec_ready(struct snd_ali *codec, | |||
310 | unsigned int res; | 310 | unsigned int res; |
311 | 311 | ||
312 | end_time = jiffies + msecs_to_jiffies(250); | 312 | end_time = jiffies + msecs_to_jiffies(250); |
313 | do { | 313 | |
314 | for (;;) { | ||
314 | res = snd_ali_5451_peek(codec,port); | 315 | res = snd_ali_5451_peek(codec,port); |
315 | if (!(res & 0x8000)) | 316 | if (!(res & 0x8000)) |
316 | return 0; | 317 | return 0; |
318 | if (!time_after_eq(end_time, jiffies)) | ||
319 | break; | ||
317 | schedule_timeout_uninterruptible(1); | 320 | schedule_timeout_uninterruptible(1); |
318 | } while (time_after_eq(end_time, jiffies)); | 321 | } |
322 | |||
319 | snd_ali_5451_poke(codec, port, res & ~0x8000); | 323 | snd_ali_5451_poke(codec, port, res & ~0x8000); |
320 | snd_printdd("ali_codec_ready: codec is not ready.\n "); | 324 | snd_printdd("ali_codec_ready: codec is not ready.\n "); |
321 | return -EIO; | 325 | return -EIO; |
@@ -327,15 +331,17 @@ static int snd_ali_stimer_ready(struct snd_ali *codec) | |||
327 | unsigned long dwChk1,dwChk2; | 331 | unsigned long dwChk1,dwChk2; |
328 | 332 | ||
329 | dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); | 333 | dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); |
330 | dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); | ||
331 | |||
332 | end_time = jiffies + msecs_to_jiffies(250); | 334 | end_time = jiffies + msecs_to_jiffies(250); |
333 | do { | 335 | |
336 | for (;;) { | ||
334 | dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); | 337 | dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); |
335 | if (dwChk2 != dwChk1) | 338 | if (dwChk2 != dwChk1) |
336 | return 0; | 339 | return 0; |
340 | if (!time_after_eq(end_time, jiffies)) | ||
341 | break; | ||
337 | schedule_timeout_uninterruptible(1); | 342 | schedule_timeout_uninterruptible(1); |
338 | } while (time_after_eq(end_time, jiffies)); | 343 | } |
344 | |||
339 | snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); | 345 | snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); |
340 | return -EIO; | 346 | return -EIO; |
341 | } | 347 | } |
@@ -472,45 +478,6 @@ static int snd_ali_reset_5451(struct snd_ali *codec) | |||
472 | return 0; | 478 | return 0; |
473 | } | 479 | } |
474 | 480 | ||
475 | #ifdef CODEC_RESET | ||
476 | |||
477 | static int snd_ali_reset_codec(struct snd_ali *codec) | ||
478 | { | ||
479 | struct pci_dev *pci_dev; | ||
480 | unsigned char bVal; | ||
481 | unsigned int dwVal; | ||
482 | unsigned short wCount, wReg; | ||
483 | |||
484 | pci_dev = codec->pci_m1533; | ||
485 | |||
486 | pci_read_config_dword(pci_dev, 0x7c, &dwVal); | ||
487 | pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000); | ||
488 | udelay(5000); | ||
489 | pci_read_config_dword(pci_dev, 0x7c, &dwVal); | ||
490 | pci_write_config_dword(pci_dev, 0x7c, dwVal & 0xf7ffffff); | ||
491 | udelay(5000); | ||
492 | |||
493 | bVal = inb(ALI_REG(codec,ALI_SCTRL)); | ||
494 | bVal |= 0x02; | ||
495 | outb(ALI_REG(codec,ALI_SCTRL),bVal); | ||
496 | udelay(5000); | ||
497 | bVal = inb(ALI_REG(codec,ALI_SCTRL)); | ||
498 | bVal &= 0xfd; | ||
499 | outb(ALI_REG(codec,ALI_SCTRL),bVal); | ||
500 | udelay(15000); | ||
501 | |||
502 | wCount = 200; | ||
503 | while (wCount--) { | ||
504 | wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN); | ||
505 | if ((wReg & 0x000f) == 0x000f) | ||
506 | return 0; | ||
507 | udelay(5000); | ||
508 | } | ||
509 | return -1; | ||
510 | } | ||
511 | |||
512 | #endif | ||
513 | |||
514 | /* | 481 | /* |
515 | * ALI 5451 Controller | 482 | * ALI 5451 Controller |
516 | */ | 483 | */ |
@@ -555,22 +522,6 @@ static void snd_ali_disable_address_interrupt(struct snd_ali *codec) | |||
555 | outl(gc, ALI_REG(codec, ALI_GC_CIR)); | 522 | outl(gc, ALI_REG(codec, ALI_GC_CIR)); |
556 | } | 523 | } |
557 | 524 | ||
558 | #if 0 /* not used */ | ||
559 | static void snd_ali_enable_voice_irq(struct snd_ali *codec, | ||
560 | unsigned int channel) | ||
561 | { | ||
562 | unsigned int mask; | ||
563 | struct snd_ali_channel_control *pchregs = &(codec->chregs); | ||
564 | |||
565 | snd_ali_printk("enable_voice_irq channel=%d\n",channel); | ||
566 | |||
567 | mask = 1 << (channel & 0x1f); | ||
568 | pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten)); | ||
569 | pchregs->data.ainten |= mask; | ||
570 | outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten)); | ||
571 | } | ||
572 | #endif | ||
573 | |||
574 | static void snd_ali_disable_voice_irq(struct snd_ali *codec, | 525 | static void snd_ali_disable_voice_irq(struct snd_ali *codec, |
575 | unsigned int channel) | 526 | unsigned int channel) |
576 | { | 527 | { |
@@ -671,16 +622,6 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel) | |||
671 | } | 622 | } |
672 | } | 623 | } |
673 | 624 | ||
674 | #if 0 /* not used */ | ||
675 | static void snd_ali_start_voice(struct snd_ali *codec, unsigned int channel) | ||
676 | { | ||
677 | unsigned int mask = 1 << (channel & 0x1f); | ||
678 | |||
679 | snd_ali_printk("start_voice: channel=%d\n",channel); | ||
680 | outl(mask, ALI_REG(codec,codec->chregs.regs.start)); | ||
681 | } | ||
682 | #endif | ||
683 | |||
684 | static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel) | 625 | static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel) |
685 | { | 626 | { |
686 | unsigned int mask = 1 << (channel & 0x1f); | 627 | unsigned int mask = 1 << (channel & 0x1f); |
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index f290bc56178f..8451a0169f32 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). | 2 | * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). |
3 | * Copyright (C) 2002, 2005 - 2008 by Andreas Mohr <andi AT lisas.de> | 3 | * Copyright (C) 2002, 2005 - 2009 by Andreas Mohr <andi AT lisas.de> |
4 | * | 4 | * |
5 | * Framework borrowed from Bart Hartgers's als4000.c. | 5 | * Framework borrowed from Bart Hartgers's als4000.c. |
6 | * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), | 6 | * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), |
@@ -10,6 +10,13 @@ | |||
10 | * PCI168 A/AP, sub ID 8000 | 10 | * PCI168 A/AP, sub ID 8000 |
11 | * Please give me feedback in case you try my driver with one of these!! | 11 | * Please give me feedback in case you try my driver with one of these!! |
12 | * | 12 | * |
13 | * Keywords: Windows XP Vista 168nt4-125.zip 168win95-125.zip PCI 168 download | ||
14 | * (XP/Vista do not support this card at all but every Linux distribution | ||
15 | * has very good support out of the box; | ||
16 | * just to make sure that the right people hit this and get to know that, | ||
17 | * despite the high level of Internet ignorance - as usual :-P - | ||
18 | * about very good support for this card - on Linux!) | ||
19 | * | ||
13 | * GPL LICENSE | 20 | * GPL LICENSE |
14 | * This program is free software; you can redistribute it and/or modify | 21 | * This program is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License as published by | 22 | * it under the terms of the GNU General Public License as published by |
@@ -71,10 +78,11 @@ | |||
71 | * - built-in General DirectX timer having a 20 bits counter | 78 | * - built-in General DirectX timer having a 20 bits counter |
72 | * with 1us resolution (see below!) | 79 | * with 1us resolution (see below!) |
73 | * - I2S serial output port for external DAC | 80 | * - I2S serial output port for external DAC |
81 | * [FIXME: 3.3V or 5V level? maximum rate is 66.2kHz right?] | ||
74 | * - supports 33MHz PCI spec 2.1, PCI power management 1.0, compliant with ACPI | 82 | * - supports 33MHz PCI spec 2.1, PCI power management 1.0, compliant with ACPI |
75 | * - supports hardware volume control | 83 | * - supports hardware volume control |
76 | * - single chip low cost solution (128 pin QFP) | 84 | * - single chip low cost solution (128 pin QFP) |
77 | * - supports programmable Sub-vendor and Sub-system ID | 85 | * - supports programmable Sub-vendor and Sub-system ID [24C02 SEEPROM chip] |
78 | * required for Microsoft's logo compliance (FIXME: where?) | 86 | * required for Microsoft's logo compliance (FIXME: where?) |
79 | * At least the Trident 4D Wave DX has one bit somewhere | 87 | * At least the Trident 4D Wave DX has one bit somewhere |
80 | * to enable writes to PCI subsystem VID registers, that should be it. | 88 | * to enable writes to PCI subsystem VID registers, that should be it. |
@@ -82,6 +90,7 @@ | |||
82 | * some custom data starting at 0x80. What kind of config settings | 90 | * some custom data starting at 0x80. What kind of config settings |
83 | * are located in our extended PCI space anyway?? | 91 | * are located in our extended PCI space anyway?? |
84 | * - PCI168 AP(W) card: power amplifier with 4 Watts/channel at 4 Ohms | 92 | * - PCI168 AP(W) card: power amplifier with 4 Watts/channel at 4 Ohms |
93 | * [TDA1517P chip] | ||
85 | * | 94 | * |
86 | * Note that this driver now is actually *better* than the Windows driver, | 95 | * Note that this driver now is actually *better* than the Windows driver, |
87 | * since it additionally supports the card's 1MHz DirectX timer - just try | 96 | * since it additionally supports the card's 1MHz DirectX timer - just try |
@@ -146,10 +155,15 @@ | |||
146 | * to read the Digital Enhanced Game Port. Not sure whether it is fixable. | 155 | * to read the Digital Enhanced Game Port. Not sure whether it is fixable. |
147 | * | 156 | * |
148 | * TODO | 157 | * TODO |
158 | * - use PCI_VDEVICE | ||
159 | * - verify driver status on x86_64 | ||
160 | * - test multi-card driver operation | ||
161 | * - (ab)use 1MHz DirectX timer as kernel clocksource | ||
149 | * - test MPU401 MIDI playback etc. | 162 | * - test MPU401 MIDI playback etc. |
150 | * - add more power micro-management (disable various units of the card | 163 | * - add more power micro-management (disable various units of the card |
151 | * as long as they're unused). However this requires more I/O ports which I | 164 | * as long as they're unused, to improve audio quality and save power). |
152 | * haven't figured out yet and which thus might not even exist... | 165 | * However this requires more I/O ports which I haven't figured out yet |
166 | * and which thus might not even exist... | ||
153 | * The standard suspend/resume functionality could probably make use of | 167 | * The standard suspend/resume functionality could probably make use of |
154 | * some improvement, too... | 168 | * some improvement, too... |
155 | * - figure out what all unknown port bits are responsible for | 169 | * - figure out what all unknown port bits are responsible for |
@@ -185,25 +199,46 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}"); | |||
185 | #define SUPPORT_GAMEPORT 1 | 199 | #define SUPPORT_GAMEPORT 1 |
186 | #endif | 200 | #endif |
187 | 201 | ||
202 | /* === Debug settings === | ||
203 | Further diagnostic functionality than the settings below | ||
204 | does not need to be provided, since one can easily write a bash script | ||
205 | to dump the card's I/O ports (those listed in lspci -v -v): | ||
206 | function dump() | ||
207 | { | ||
208 | local descr=$1; local addr=$2; local count=$3 | ||
209 | |||
210 | echo "${descr}: ${count} @ ${addr}:" | ||
211 | dd if=/dev/port skip=$[${addr}] count=${count} bs=1 2>/dev/null| hexdump -C | ||
212 | } | ||
213 | and then use something like | ||
214 | "dump joy200 0x200 8", "dump mpu388 0x388 4", "dump joy 0xb400 8", | ||
215 | "dump codec00 0xa800 32", "dump mixer 0xb800 64", "dump synth 0xbc00 8", | ||
216 | possibly within a "while true; do ... sleep 1; done" loop. | ||
217 | Tweaking ports could be done using | ||
218 | VALSTRING="`printf "%02x" $value`" | ||
219 | printf "\x""$VALSTRING"|dd of=/dev/port seek=$[${addr}] bs=1 2>/dev/null | ||
220 | */ | ||
221 | |||
188 | #define DEBUG_MISC 0 | 222 | #define DEBUG_MISC 0 |
189 | #define DEBUG_CALLS 0 | 223 | #define DEBUG_CALLS 0 |
190 | #define DEBUG_MIXER 0 | 224 | #define DEBUG_MIXER 0 |
191 | #define DEBUG_PLAY_REC 0 | 225 | #define DEBUG_CODEC 0 |
192 | #define DEBUG_IO 0 | 226 | #define DEBUG_IO 0 |
193 | #define DEBUG_TIMER 0 | 227 | #define DEBUG_TIMER 0 |
194 | #define DEBUG_GAME 0 | 228 | #define DEBUG_GAME 0 |
229 | #define DEBUG_PM 0 | ||
195 | #define MIXER_TESTING 0 | 230 | #define MIXER_TESTING 0 |
196 | 231 | ||
197 | #if DEBUG_MISC | 232 | #if DEBUG_MISC |
198 | #define snd_azf3328_dbgmisc(format, args...) printk(KERN_ERR format, ##args) | 233 | #define snd_azf3328_dbgmisc(format, args...) printk(KERN_DEBUG format, ##args) |
199 | #else | 234 | #else |
200 | #define snd_azf3328_dbgmisc(format, args...) | 235 | #define snd_azf3328_dbgmisc(format, args...) |
201 | #endif | 236 | #endif |
202 | 237 | ||
203 | #if DEBUG_CALLS | 238 | #if DEBUG_CALLS |
204 | #define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) | 239 | #define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) |
205 | #define snd_azf3328_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__) | 240 | #define snd_azf3328_dbgcallenter() printk(KERN_DEBUG "--> %s\n", __func__) |
206 | #define snd_azf3328_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__) | 241 | #define snd_azf3328_dbgcallleave() printk(KERN_DEBUG "<-- %s\n", __func__) |
207 | #else | 242 | #else |
208 | #define snd_azf3328_dbgcalls(format, args...) | 243 | #define snd_azf3328_dbgcalls(format, args...) |
209 | #define snd_azf3328_dbgcallenter() | 244 | #define snd_azf3328_dbgcallenter() |
@@ -216,10 +251,10 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}"); | |||
216 | #define snd_azf3328_dbgmixer(format, args...) | 251 | #define snd_azf3328_dbgmixer(format, args...) |
217 | #endif | 252 | #endif |
218 | 253 | ||
219 | #if DEBUG_PLAY_REC | 254 | #if DEBUG_CODEC |
220 | #define snd_azf3328_dbgplay(format, args...) printk(KERN_DEBUG format, ##args) | 255 | #define snd_azf3328_dbgcodec(format, args...) printk(KERN_DEBUG format, ##args) |
221 | #else | 256 | #else |
222 | #define snd_azf3328_dbgplay(format, args...) | 257 | #define snd_azf3328_dbgcodec(format, args...) |
223 | #endif | 258 | #endif |
224 | 259 | ||
225 | #if DEBUG_MISC | 260 | #if DEBUG_MISC |
@@ -234,6 +269,12 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}"); | |||
234 | #define snd_azf3328_dbggame(format, args...) | 269 | #define snd_azf3328_dbggame(format, args...) |
235 | #endif | 270 | #endif |
236 | 271 | ||
272 | #if DEBUG_PM | ||
273 | #define snd_azf3328_dbgpm(format, args...) printk(KERN_DEBUG format, ##args) | ||
274 | #else | ||
275 | #define snd_azf3328_dbgpm(format, args...) | ||
276 | #endif | ||
277 | |||
237 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 278 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
238 | module_param_array(index, int, NULL, 0444); | 279 | module_param_array(index, int, NULL, 0444); |
239 | MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard."); | 280 | MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard."); |
@@ -250,22 +291,23 @@ static int seqtimer_scaling = 128; | |||
250 | module_param(seqtimer_scaling, int, 0444); | 291 | module_param(seqtimer_scaling, int, 0444); |
251 | MODULE_PARM_DESC(seqtimer_scaling, "Set 1024000Hz sequencer timer scale factor (lockup danger!). Default 128."); | 292 | MODULE_PARM_DESC(seqtimer_scaling, "Set 1024000Hz sequencer timer scale factor (lockup danger!). Default 128."); |
252 | 293 | ||
253 | struct snd_azf3328_audio_stream { | 294 | struct snd_azf3328_codec_data { |
295 | unsigned long io_base; | ||
254 | struct snd_pcm_substream *substream; | 296 | struct snd_pcm_substream *substream; |
255 | int enabled; | 297 | bool running; |
256 | int running; | 298 | const char *name; |
257 | unsigned long portbase; | ||
258 | }; | 299 | }; |
259 | 300 | ||
260 | enum snd_azf3328_stream_index { | 301 | enum snd_azf3328_codec_type { |
261 | AZF_PLAYBACK = 0, | 302 | AZF_CODEC_PLAYBACK = 0, |
262 | AZF_CAPTURE = 1, | 303 | AZF_CODEC_CAPTURE = 1, |
304 | AZF_CODEC_I2S_OUT = 2, | ||
263 | }; | 305 | }; |
264 | 306 | ||
265 | struct snd_azf3328 { | 307 | struct snd_azf3328 { |
266 | /* often-used fields towards beginning, then grouped */ | 308 | /* often-used fields towards beginning, then grouped */ |
267 | 309 | ||
268 | unsigned long codec_io; /* usually 0xb000, size 128 */ | 310 | unsigned long ctrl_io; /* usually 0xb000, size 128 */ |
269 | unsigned long game_io; /* usually 0xb400, size 8 */ | 311 | unsigned long game_io; /* usually 0xb400, size 8 */ |
270 | unsigned long mpu_io; /* usually 0xb800, size 4 */ | 312 | unsigned long mpu_io; /* usually 0xb800, size 4 */ |
271 | unsigned long opl3_io; /* usually 0xbc00, size 8 */ | 313 | unsigned long opl3_io; /* usually 0xbc00, size 8 */ |
@@ -275,15 +317,17 @@ struct snd_azf3328 { | |||
275 | 317 | ||
276 | struct snd_timer *timer; | 318 | struct snd_timer *timer; |
277 | 319 | ||
278 | struct snd_pcm *pcm; | 320 | struct snd_pcm *pcm[3]; |
279 | struct snd_azf3328_audio_stream audio_stream[2]; | 321 | |
322 | /* playback, recording and I2S out codecs */ | ||
323 | struct snd_azf3328_codec_data codecs[3]; | ||
280 | 324 | ||
281 | struct snd_card *card; | 325 | struct snd_card *card; |
282 | struct snd_rawmidi *rmidi; | 326 | struct snd_rawmidi *rmidi; |
283 | 327 | ||
284 | #ifdef SUPPORT_GAMEPORT | 328 | #ifdef SUPPORT_GAMEPORT |
285 | struct gameport *gameport; | 329 | struct gameport *gameport; |
286 | int axes[4]; | 330 | u16 axes[4]; |
287 | #endif | 331 | #endif |
288 | 332 | ||
289 | struct pci_dev *pci; | 333 | struct pci_dev *pci; |
@@ -293,16 +337,16 @@ struct snd_azf3328 { | |||
293 | * If we need to add more registers here, then we might try to fold this | 337 | * If we need to add more registers here, then we might try to fold this |
294 | * into some transparent combined shadow register handling with | 338 | * into some transparent combined shadow register handling with |
295 | * CONFIG_PM register storage below, but that's slightly difficult. */ | 339 | * CONFIG_PM register storage below, but that's slightly difficult. */ |
296 | u16 shadow_reg_codec_6AH; | 340 | u16 shadow_reg_ctrl_6AH; |
297 | 341 | ||
298 | #ifdef CONFIG_PM | 342 | #ifdef CONFIG_PM |
299 | /* register value containers for power management | 343 | /* register value containers for power management |
300 | * Note: not always full I/O range preserved (just like Win driver!) */ | 344 | * Note: not always full I/O range preserved (similar to Win driver!) */ |
301 | u16 saved_regs_codec[AZF_IO_SIZE_CODEC_PM / 2]; | 345 | u32 saved_regs_ctrl[AZF_ALIGN(AZF_IO_SIZE_CTRL_PM) / 4]; |
302 | u16 saved_regs_game [AZF_IO_SIZE_GAME_PM / 2]; | 346 | u32 saved_regs_game[AZF_ALIGN(AZF_IO_SIZE_GAME_PM) / 4]; |
303 | u16 saved_regs_mpu [AZF_IO_SIZE_MPU_PM / 2]; | 347 | u32 saved_regs_mpu[AZF_ALIGN(AZF_IO_SIZE_MPU_PM) / 4]; |
304 | u16 saved_regs_opl3 [AZF_IO_SIZE_OPL3_PM / 2]; | 348 | u32 saved_regs_opl3[AZF_ALIGN(AZF_IO_SIZE_OPL3_PM) / 4]; |
305 | u16 saved_regs_mixer[AZF_IO_SIZE_MIXER_PM / 2]; | 349 | u32 saved_regs_mixer[AZF_ALIGN(AZF_IO_SIZE_MIXER_PM) / 4]; |
306 | #endif | 350 | #endif |
307 | }; | 351 | }; |
308 | 352 | ||
@@ -316,7 +360,7 @@ MODULE_DEVICE_TABLE(pci, snd_azf3328_ids); | |||
316 | 360 | ||
317 | 361 | ||
318 | static int | 362 | static int |
319 | snd_azf3328_io_reg_setb(unsigned reg, u8 mask, int do_set) | 363 | snd_azf3328_io_reg_setb(unsigned reg, u8 mask, bool do_set) |
320 | { | 364 | { |
321 | u8 prev = inb(reg), new; | 365 | u8 prev = inb(reg), new; |
322 | 366 | ||
@@ -331,39 +375,72 @@ snd_azf3328_io_reg_setb(unsigned reg, u8 mask, int do_set) | |||
331 | } | 375 | } |
332 | 376 | ||
333 | static inline void | 377 | static inline void |
334 | snd_azf3328_codec_outb(const struct snd_azf3328 *chip, unsigned reg, u8 value) | 378 | snd_azf3328_codec_outb(const struct snd_azf3328_codec_data *codec, |
379 | unsigned reg, | ||
380 | u8 value | ||
381 | ) | ||
335 | { | 382 | { |
336 | outb(value, chip->codec_io + reg); | 383 | outb(value, codec->io_base + reg); |
337 | } | 384 | } |
338 | 385 | ||
339 | static inline u8 | 386 | static inline u8 |
340 | snd_azf3328_codec_inb(const struct snd_azf3328 *chip, unsigned reg) | 387 | snd_azf3328_codec_inb(const struct snd_azf3328_codec_data *codec, unsigned reg) |
341 | { | 388 | { |
342 | return inb(chip->codec_io + reg); | 389 | return inb(codec->io_base + reg); |
343 | } | 390 | } |
344 | 391 | ||
345 | static inline void | 392 | static inline void |
346 | snd_azf3328_codec_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value) | 393 | snd_azf3328_codec_outw(const struct snd_azf3328_codec_data *codec, |
394 | unsigned reg, | ||
395 | u16 value | ||
396 | ) | ||
347 | { | 397 | { |
348 | outw(value, chip->codec_io + reg); | 398 | outw(value, codec->io_base + reg); |
349 | } | 399 | } |
350 | 400 | ||
351 | static inline u16 | 401 | static inline u16 |
352 | snd_azf3328_codec_inw(const struct snd_azf3328 *chip, unsigned reg) | 402 | snd_azf3328_codec_inw(const struct snd_azf3328_codec_data *codec, unsigned reg) |
353 | { | 403 | { |
354 | return inw(chip->codec_io + reg); | 404 | return inw(codec->io_base + reg); |
355 | } | 405 | } |
356 | 406 | ||
357 | static inline void | 407 | static inline void |
358 | snd_azf3328_codec_outl(const struct snd_azf3328 *chip, unsigned reg, u32 value) | 408 | snd_azf3328_codec_outl(const struct snd_azf3328_codec_data *codec, |
409 | unsigned reg, | ||
410 | u32 value | ||
411 | ) | ||
359 | { | 412 | { |
360 | outl(value, chip->codec_io + reg); | 413 | outl(value, codec->io_base + reg); |
361 | } | 414 | } |
362 | 415 | ||
363 | static inline u32 | 416 | static inline u32 |
364 | snd_azf3328_codec_inl(const struct snd_azf3328 *chip, unsigned reg) | 417 | snd_azf3328_codec_inl(const struct snd_azf3328_codec_data *codec, unsigned reg) |
418 | { | ||
419 | return inl(codec->io_base + reg); | ||
420 | } | ||
421 | |||
422 | static inline void | ||
423 | snd_azf3328_ctrl_outb(const struct snd_azf3328 *chip, unsigned reg, u8 value) | ||
424 | { | ||
425 | outb(value, chip->ctrl_io + reg); | ||
426 | } | ||
427 | |||
428 | static inline u8 | ||
429 | snd_azf3328_ctrl_inb(const struct snd_azf3328 *chip, unsigned reg) | ||
430 | { | ||
431 | return inb(chip->ctrl_io + reg); | ||
432 | } | ||
433 | |||
434 | static inline void | ||
435 | snd_azf3328_ctrl_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value) | ||
436 | { | ||
437 | outw(value, chip->ctrl_io + reg); | ||
438 | } | ||
439 | |||
440 | static inline void | ||
441 | snd_azf3328_ctrl_outl(const struct snd_azf3328 *chip, unsigned reg, u32 value) | ||
365 | { | 442 | { |
366 | return inl(chip->codec_io + reg); | 443 | outl(value, chip->ctrl_io + reg); |
367 | } | 444 | } |
368 | 445 | ||
369 | static inline void | 446 | static inline void |
@@ -404,13 +481,13 @@ snd_azf3328_mixer_inw(const struct snd_azf3328 *chip, unsigned reg) | |||
404 | 481 | ||
405 | #define AZF_MUTE_BIT 0x80 | 482 | #define AZF_MUTE_BIT 0x80 |
406 | 483 | ||
407 | static int | 484 | static bool |
408 | snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip, | 485 | snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip, |
409 | unsigned reg, int do_mute | 486 | unsigned reg, bool do_mute |
410 | ) | 487 | ) |
411 | { | 488 | { |
412 | unsigned long portbase = chip->mixer_io + reg + 1; | 489 | unsigned long portbase = chip->mixer_io + reg + 1; |
413 | int updated; | 490 | bool updated; |
414 | 491 | ||
415 | /* the mute bit is on the *second* (i.e. right) register of a | 492 | /* the mute bit is on the *second* (i.e. right) register of a |
416 | * left/right channel setting */ | 493 | * left/right channel setting */ |
@@ -569,7 +646,7 @@ snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol, | |||
569 | { | 646 | { |
570 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); | 647 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); |
571 | struct azf3328_mixer_reg reg; | 648 | struct azf3328_mixer_reg reg; |
572 | unsigned int oreg, val; | 649 | u16 oreg, val; |
573 | 650 | ||
574 | snd_azf3328_dbgcallenter(); | 651 | snd_azf3328_dbgcallenter(); |
575 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); | 652 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); |
@@ -600,7 +677,7 @@ snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol, | |||
600 | { | 677 | { |
601 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); | 678 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); |
602 | struct azf3328_mixer_reg reg; | 679 | struct azf3328_mixer_reg reg; |
603 | unsigned int oreg, nreg, val; | 680 | u16 oreg, nreg, val; |
604 | 681 | ||
605 | snd_azf3328_dbgcallenter(); | 682 | snd_azf3328_dbgcallenter(); |
606 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); | 683 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); |
@@ -709,7 +786,7 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol, | |||
709 | { | 786 | { |
710 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); | 787 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); |
711 | struct azf3328_mixer_reg reg; | 788 | struct azf3328_mixer_reg reg; |
712 | unsigned int oreg, nreg, val; | 789 | u16 oreg, nreg, val; |
713 | 790 | ||
714 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); | 791 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); |
715 | oreg = snd_azf3328_mixer_inw(chip, reg.reg); | 792 | oreg = snd_azf3328_mixer_inw(chip, reg.reg); |
@@ -867,14 +944,15 @@ snd_azf3328_hw_free(struct snd_pcm_substream *substream) | |||
867 | 944 | ||
868 | static void | 945 | static void |
869 | snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | 946 | snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, |
870 | unsigned reg, | 947 | enum snd_azf3328_codec_type codec_type, |
871 | enum azf_freq_t bitrate, | 948 | enum azf_freq_t bitrate, |
872 | unsigned int format_width, | 949 | unsigned int format_width, |
873 | unsigned int channels | 950 | unsigned int channels |
874 | ) | 951 | ) |
875 | { | 952 | { |
876 | u16 val = 0xff00; | ||
877 | unsigned long flags; | 953 | unsigned long flags; |
954 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
955 | u16 val = 0xff00; | ||
878 | 956 | ||
879 | snd_azf3328_dbgcallenter(); | 957 | snd_azf3328_dbgcallenter(); |
880 | switch (bitrate) { | 958 | switch (bitrate) { |
@@ -917,7 +995,7 @@ snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | |||
917 | spin_lock_irqsave(&chip->reg_lock, flags); | 995 | spin_lock_irqsave(&chip->reg_lock, flags); |
918 | 996 | ||
919 | /* set bitrate/format */ | 997 | /* set bitrate/format */ |
920 | snd_azf3328_codec_outw(chip, reg, val); | 998 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_SOUNDFORMAT, val); |
921 | 999 | ||
922 | /* changing the bitrate/format settings switches off the | 1000 | /* changing the bitrate/format settings switches off the |
923 | * audio output with an annoying click in case of 8/16bit format change | 1001 | * audio output with an annoying click in case of 8/16bit format change |
@@ -926,11 +1004,11 @@ snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | |||
926 | * (FIXME: yes, it works, but what exactly am I doing here?? :) | 1004 | * (FIXME: yes, it works, but what exactly am I doing here?? :) |
927 | * FIXME: does this have some side effects for full-duplex | 1005 | * FIXME: does this have some side effects for full-duplex |
928 | * or other dramatic side effects? */ | 1006 | * or other dramatic side effects? */ |
929 | if (reg == IDX_IO_PLAY_SOUNDFORMAT) /* only do it for playback */ | 1007 | if (codec_type == AZF_CODEC_PLAYBACK) /* only do it for playback */ |
930 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1008 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
931 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS) | | 1009 | snd_azf3328_codec_inw(codec, IDX_IO_CODEC_DMA_FLAGS) | |
932 | DMA_PLAY_SOMETHING1 | | 1010 | DMA_RUN_SOMETHING1 | |
933 | DMA_PLAY_SOMETHING2 | | 1011 | DMA_RUN_SOMETHING2 | |
934 | SOMETHING_ALMOST_ALWAYS_SET | | 1012 | SOMETHING_ALMOST_ALWAYS_SET | |
935 | DMA_EPILOGUE_SOMETHING | | 1013 | DMA_EPILOGUE_SOMETHING | |
936 | DMA_SOMETHING_ELSE | 1014 | DMA_SOMETHING_ELSE |
@@ -942,112 +1020,134 @@ snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | |||
942 | 1020 | ||
943 | static inline void | 1021 | static inline void |
944 | snd_azf3328_codec_setfmt_lowpower(struct snd_azf3328 *chip, | 1022 | snd_azf3328_codec_setfmt_lowpower(struct snd_azf3328 *chip, |
945 | unsigned reg | 1023 | enum snd_azf3328_codec_type codec_type |
946 | ) | 1024 | ) |
947 | { | 1025 | { |
948 | /* choose lowest frequency for low power consumption. | 1026 | /* choose lowest frequency for low power consumption. |
949 | * While this will cause louder noise due to rather coarse frequency, | 1027 | * While this will cause louder noise due to rather coarse frequency, |
950 | * it should never matter since output should always | 1028 | * it should never matter since output should always |
951 | * get disabled properly when idle anyway. */ | 1029 | * get disabled properly when idle anyway. */ |
952 | snd_azf3328_codec_setfmt(chip, reg, AZF_FREQ_4000, 8, 1); | 1030 | snd_azf3328_codec_setfmt(chip, codec_type, AZF_FREQ_4000, 8, 1); |
953 | } | 1031 | } |
954 | 1032 | ||
955 | static void | 1033 | static void |
956 | snd_azf3328_codec_reg_6AH_update(struct snd_azf3328 *chip, | 1034 | snd_azf3328_ctrl_reg_6AH_update(struct snd_azf3328 *chip, |
957 | unsigned bitmask, | 1035 | unsigned bitmask, |
958 | int enable | 1036 | bool enable |
959 | ) | 1037 | ) |
960 | { | 1038 | { |
961 | if (enable) | 1039 | bool do_mask = !enable; |
962 | chip->shadow_reg_codec_6AH &= ~bitmask; | 1040 | if (do_mask) |
1041 | chip->shadow_reg_ctrl_6AH |= bitmask; | ||
963 | else | 1042 | else |
964 | chip->shadow_reg_codec_6AH |= bitmask; | 1043 | chip->shadow_reg_ctrl_6AH &= ~bitmask; |
965 | snd_azf3328_dbgplay("6AH_update mask 0x%04x enable %d: val 0x%04x\n", | 1044 | snd_azf3328_dbgcodec("6AH_update mask 0x%04x do_mask %d: val 0x%04x\n", |
966 | bitmask, enable, chip->shadow_reg_codec_6AH); | 1045 | bitmask, do_mask, chip->shadow_reg_ctrl_6AH); |
967 | snd_azf3328_codec_outw(chip, IDX_IO_6AH, chip->shadow_reg_codec_6AH); | 1046 | snd_azf3328_ctrl_outw(chip, IDX_IO_6AH, chip->shadow_reg_ctrl_6AH); |
968 | } | 1047 | } |
969 | 1048 | ||
970 | static inline void | 1049 | static inline void |
971 | snd_azf3328_codec_enable(struct snd_azf3328 *chip, int enable) | 1050 | snd_azf3328_ctrl_enable_codecs(struct snd_azf3328 *chip, bool enable) |
972 | { | 1051 | { |
973 | snd_azf3328_dbgplay("codec_enable %d\n", enable); | 1052 | snd_azf3328_dbgcodec("codec_enable %d\n", enable); |
974 | /* no idea what exactly is being done here, but I strongly assume it's | 1053 | /* no idea what exactly is being done here, but I strongly assume it's |
975 | * PM related */ | 1054 | * PM related */ |
976 | snd_azf3328_codec_reg_6AH_update( | 1055 | snd_azf3328_ctrl_reg_6AH_update( |
977 | chip, IO_6A_PAUSE_PLAYBACK_BIT8, enable | 1056 | chip, IO_6A_PAUSE_PLAYBACK_BIT8, enable |
978 | ); | 1057 | ); |
979 | } | 1058 | } |
980 | 1059 | ||
981 | static void | 1060 | static void |
982 | snd_azf3328_codec_activity(struct snd_azf3328 *chip, | 1061 | snd_azf3328_ctrl_codec_activity(struct snd_azf3328 *chip, |
983 | enum snd_azf3328_stream_index stream_type, | 1062 | enum snd_azf3328_codec_type codec_type, |
984 | int enable | 1063 | bool enable |
985 | ) | 1064 | ) |
986 | { | 1065 | { |
987 | int need_change = (chip->audio_stream[stream_type].running != enable); | 1066 | struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; |
1067 | bool need_change = (codec->running != enable); | ||
988 | 1068 | ||
989 | snd_azf3328_dbgplay( | 1069 | snd_azf3328_dbgcodec( |
990 | "codec_activity: type %d, enable %d, need_change %d\n", | 1070 | "codec_activity: %s codec, enable %d, need_change %d\n", |
991 | stream_type, enable, need_change | 1071 | codec->name, enable, need_change |
992 | ); | 1072 | ); |
993 | if (need_change) { | 1073 | if (need_change) { |
994 | enum snd_azf3328_stream_index other = | 1074 | static const struct { |
995 | (stream_type == AZF_PLAYBACK) ? | 1075 | enum snd_azf3328_codec_type other1; |
996 | AZF_CAPTURE : AZF_PLAYBACK; | 1076 | enum snd_azf3328_codec_type other2; |
997 | /* small check to prevent shutting down the other party | 1077 | } peer_codecs[3] = |
998 | * in case it's active */ | 1078 | { { AZF_CODEC_CAPTURE, AZF_CODEC_I2S_OUT }, |
999 | if ((enable) || !(chip->audio_stream[other].running)) | 1079 | { AZF_CODEC_PLAYBACK, AZF_CODEC_I2S_OUT }, |
1000 | snd_azf3328_codec_enable(chip, enable); | 1080 | { AZF_CODEC_PLAYBACK, AZF_CODEC_CAPTURE } }; |
1081 | bool call_function; | ||
1082 | |||
1083 | if (enable) | ||
1084 | /* if enable codec, call enable_codecs func | ||
1085 | to enable codec supply... */ | ||
1086 | call_function = 1; | ||
1087 | else { | ||
1088 | /* ...otherwise call enable_codecs func | ||
1089 | (which globally shuts down operation of codecs) | ||
1090 | only in case the other codecs are currently | ||
1091 | not active either! */ | ||
1092 | call_function = | ||
1093 | ((!chip->codecs[peer_codecs[codec_type].other1] | ||
1094 | .running) | ||
1095 | && (!chip->codecs[peer_codecs[codec_type].other2] | ||
1096 | .running)); | ||
1097 | } | ||
1098 | if (call_function) | ||
1099 | snd_azf3328_ctrl_enable_codecs(chip, enable); | ||
1001 | 1100 | ||
1002 | /* ...and adjust clock, too | 1101 | /* ...and adjust clock, too |
1003 | * (reduce noise and power consumption) */ | 1102 | * (reduce noise and power consumption) */ |
1004 | if (!enable) | 1103 | if (!enable) |
1005 | snd_azf3328_codec_setfmt_lowpower( | 1104 | snd_azf3328_codec_setfmt_lowpower( |
1006 | chip, | 1105 | chip, |
1007 | chip->audio_stream[stream_type].portbase | 1106 | codec_type |
1008 | + IDX_IO_PLAY_SOUNDFORMAT | ||
1009 | ); | 1107 | ); |
1108 | codec->running = enable; | ||
1010 | } | 1109 | } |
1011 | chip->audio_stream[stream_type].running = enable; | ||
1012 | } | 1110 | } |
1013 | 1111 | ||
1014 | static void | 1112 | static void |
1015 | snd_azf3328_setdmaa(struct snd_azf3328 *chip, | 1113 | snd_azf3328_codec_setdmaa(struct snd_azf3328 *chip, |
1016 | long unsigned int addr, | 1114 | enum snd_azf3328_codec_type codec_type, |
1017 | unsigned int count, | 1115 | unsigned long addr, |
1018 | unsigned int size, | 1116 | unsigned int count, |
1019 | enum snd_azf3328_stream_index stream_type | 1117 | unsigned int size |
1020 | ) | 1118 | ) |
1021 | { | 1119 | { |
1120 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
1022 | snd_azf3328_dbgcallenter(); | 1121 | snd_azf3328_dbgcallenter(); |
1023 | if (!chip->audio_stream[stream_type].running) { | 1122 | if (!codec->running) { |
1024 | /* AZF3328 uses a two buffer pointer DMA playback approach */ | 1123 | /* AZF3328 uses a two buffer pointer DMA transfer approach */ |
1025 | 1124 | ||
1026 | unsigned long flags, portbase, addr_area2; | 1125 | unsigned long flags, addr_area2; |
1027 | 1126 | ||
1028 | /* width 32bit (prevent overflow): */ | 1127 | /* width 32bit (prevent overflow): */ |
1029 | unsigned long count_areas, count_tmp; | 1128 | u32 count_areas, lengths; |
1030 | 1129 | ||
1031 | portbase = chip->audio_stream[stream_type].portbase; | ||
1032 | count_areas = size/2; | 1130 | count_areas = size/2; |
1033 | addr_area2 = addr+count_areas; | 1131 | addr_area2 = addr+count_areas; |
1034 | count_areas--; /* max. index */ | 1132 | count_areas--; /* max. index */ |
1035 | snd_azf3328_dbgplay("set DMA: buf1 %08lx[%lu], buf2 %08lx[%lu]\n", addr, count_areas, addr_area2, count_areas); | 1133 | snd_azf3328_dbgcodec("setdma: buffers %08lx[%u] / %08lx[%u]\n", |
1134 | addr, count_areas, addr_area2, count_areas); | ||
1036 | 1135 | ||
1037 | /* build combined I/O buffer length word */ | 1136 | /* build combined I/O buffer length word */ |
1038 | count_tmp = count_areas; | 1137 | lengths = (count_areas << 16) | (count_areas); |
1039 | count_areas |= (count_tmp << 16); | ||
1040 | spin_lock_irqsave(&chip->reg_lock, flags); | 1138 | spin_lock_irqsave(&chip->reg_lock, flags); |
1041 | outl(addr, portbase + IDX_IO_PLAY_DMA_START_1); | 1139 | snd_azf3328_codec_outl(codec, IDX_IO_CODEC_DMA_START_1, addr); |
1042 | outl(addr_area2, portbase + IDX_IO_PLAY_DMA_START_2); | 1140 | snd_azf3328_codec_outl(codec, IDX_IO_CODEC_DMA_START_2, |
1043 | outl(count_areas, portbase + IDX_IO_PLAY_DMA_LEN_1); | 1141 | addr_area2); |
1142 | snd_azf3328_codec_outl(codec, IDX_IO_CODEC_DMA_LENGTHS, | ||
1143 | lengths); | ||
1044 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1144 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1045 | } | 1145 | } |
1046 | snd_azf3328_dbgcallleave(); | 1146 | snd_azf3328_dbgcallleave(); |
1047 | } | 1147 | } |
1048 | 1148 | ||
1049 | static int | 1149 | static int |
1050 | snd_azf3328_playback_prepare(struct snd_pcm_substream *substream) | 1150 | snd_azf3328_codec_prepare(struct snd_pcm_substream *substream) |
1051 | { | 1151 | { |
1052 | #if 0 | 1152 | #if 0 |
1053 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1153 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
@@ -1058,157 +1158,161 @@ snd_azf3328_playback_prepare(struct snd_pcm_substream *substream) | |||
1058 | 1158 | ||
1059 | snd_azf3328_dbgcallenter(); | 1159 | snd_azf3328_dbgcallenter(); |
1060 | #if 0 | 1160 | #if 0 |
1061 | snd_azf3328_codec_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, | 1161 | snd_azf3328_codec_setfmt(chip, AZF_CODEC_..., |
1062 | runtime->rate, | 1162 | runtime->rate, |
1063 | snd_pcm_format_width(runtime->format), | 1163 | snd_pcm_format_width(runtime->format), |
1064 | runtime->channels); | 1164 | runtime->channels); |
1065 | snd_azf3328_setdmaa(chip, runtime->dma_addr, count, size, AZF_PLAYBACK); | 1165 | snd_azf3328_codec_setdmaa(chip, AZF_CODEC_..., |
1166 | runtime->dma_addr, count, size); | ||
1066 | #endif | 1167 | #endif |
1067 | snd_azf3328_dbgcallleave(); | 1168 | snd_azf3328_dbgcallleave(); |
1068 | return 0; | 1169 | return 0; |
1069 | } | 1170 | } |
1070 | 1171 | ||
1071 | static int | 1172 | static int |
1072 | snd_azf3328_capture_prepare(struct snd_pcm_substream *substream) | 1173 | snd_azf3328_codec_trigger(enum snd_azf3328_codec_type codec_type, |
1073 | { | 1174 | struct snd_pcm_substream *substream, int cmd) |
1074 | #if 0 | ||
1075 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | ||
1076 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
1077 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
1078 | unsigned int count = snd_pcm_lib_period_bytes(substream); | ||
1079 | #endif | ||
1080 | |||
1081 | snd_azf3328_dbgcallenter(); | ||
1082 | #if 0 | ||
1083 | snd_azf3328_codec_setfmt(chip, IDX_IO_REC_SOUNDFORMAT, | ||
1084 | runtime->rate, | ||
1085 | snd_pcm_format_width(runtime->format), | ||
1086 | runtime->channels); | ||
1087 | snd_azf3328_setdmaa(chip, runtime->dma_addr, count, size, AZF_CAPTURE); | ||
1088 | #endif | ||
1089 | snd_azf3328_dbgcallleave(); | ||
1090 | return 0; | ||
1091 | } | ||
1092 | |||
1093 | static int | ||
1094 | snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) | ||
1095 | { | 1175 | { |
1096 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1176 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1177 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
1097 | struct snd_pcm_runtime *runtime = substream->runtime; | 1178 | struct snd_pcm_runtime *runtime = substream->runtime; |
1098 | int result = 0; | 1179 | int result = 0; |
1099 | unsigned int status1; | 1180 | u16 flags1; |
1100 | int previously_muted; | 1181 | bool previously_muted = 0; |
1182 | bool is_playback_codec = (AZF_CODEC_PLAYBACK == codec_type); | ||
1101 | 1183 | ||
1102 | snd_azf3328_dbgcalls("snd_azf3328_playback_trigger cmd %d\n", cmd); | 1184 | snd_azf3328_dbgcalls("snd_azf3328_codec_trigger cmd %d\n", cmd); |
1103 | 1185 | ||
1104 | switch (cmd) { | 1186 | switch (cmd) { |
1105 | case SNDRV_PCM_TRIGGER_START: | 1187 | case SNDRV_PCM_TRIGGER_START: |
1106 | snd_azf3328_dbgplay("START PLAYBACK\n"); | 1188 | snd_azf3328_dbgcodec("START %s\n", codec->name); |
1107 | 1189 | ||
1108 | /* mute WaveOut (avoid clicking during setup) */ | 1190 | if (is_playback_codec) { |
1109 | previously_muted = | 1191 | /* mute WaveOut (avoid clicking during setup) */ |
1110 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); | 1192 | previously_muted = |
1193 | snd_azf3328_mixer_set_mute( | ||
1194 | chip, IDX_MIXER_WAVEOUT, 1 | ||
1195 | ); | ||
1196 | } | ||
1111 | 1197 | ||
1112 | snd_azf3328_codec_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, | 1198 | snd_azf3328_codec_setfmt(chip, codec_type, |
1113 | runtime->rate, | 1199 | runtime->rate, |
1114 | snd_pcm_format_width(runtime->format), | 1200 | snd_pcm_format_width(runtime->format), |
1115 | runtime->channels); | 1201 | runtime->channels); |
1116 | 1202 | ||
1117 | spin_lock(&chip->reg_lock); | 1203 | spin_lock(&chip->reg_lock); |
1118 | /* first, remember current value: */ | 1204 | /* first, remember current value: */ |
1119 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS); | 1205 | flags1 = snd_azf3328_codec_inw(codec, IDX_IO_CODEC_DMA_FLAGS); |
1120 | 1206 | ||
1121 | /* stop playback */ | 1207 | /* stop transfer */ |
1122 | status1 &= ~DMA_RESUME; | 1208 | flags1 &= ~DMA_RESUME; |
1123 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1209 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1124 | 1210 | ||
1125 | /* FIXME: clear interrupts or what??? */ | 1211 | /* FIXME: clear interrupts or what??? */ |
1126 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_IRQTYPE, 0xffff); | 1212 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_IRQTYPE, 0xffff); |
1127 | spin_unlock(&chip->reg_lock); | 1213 | spin_unlock(&chip->reg_lock); |
1128 | 1214 | ||
1129 | snd_azf3328_setdmaa(chip, runtime->dma_addr, | 1215 | snd_azf3328_codec_setdmaa(chip, codec_type, runtime->dma_addr, |
1130 | snd_pcm_lib_period_bytes(substream), | 1216 | snd_pcm_lib_period_bytes(substream), |
1131 | snd_pcm_lib_buffer_bytes(substream), | 1217 | snd_pcm_lib_buffer_bytes(substream) |
1132 | AZF_PLAYBACK); | 1218 | ); |
1133 | 1219 | ||
1134 | spin_lock(&chip->reg_lock); | 1220 | spin_lock(&chip->reg_lock); |
1135 | #ifdef WIN9X | 1221 | #ifdef WIN9X |
1136 | /* FIXME: enable playback/recording??? */ | 1222 | /* FIXME: enable playback/recording??? */ |
1137 | status1 |= DMA_PLAY_SOMETHING1 | DMA_PLAY_SOMETHING2; | 1223 | flags1 |= DMA_RUN_SOMETHING1 | DMA_RUN_SOMETHING2; |
1138 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1224 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1139 | 1225 | ||
1140 | /* start playback again */ | 1226 | /* start transfer again */ |
1141 | /* FIXME: what is this value (0x0010)??? */ | 1227 | /* FIXME: what is this value (0x0010)??? */ |
1142 | status1 |= DMA_RESUME | DMA_EPILOGUE_SOMETHING; | 1228 | flags1 |= DMA_RESUME | DMA_EPILOGUE_SOMETHING; |
1143 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1229 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1144 | #else /* NT4 */ | 1230 | #else /* NT4 */ |
1145 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1231 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1146 | 0x0000); | 1232 | 0x0000); |
1147 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1233 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1148 | DMA_PLAY_SOMETHING1); | 1234 | DMA_RUN_SOMETHING1); |
1149 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1235 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1150 | DMA_PLAY_SOMETHING1 | | 1236 | DMA_RUN_SOMETHING1 | |
1151 | DMA_PLAY_SOMETHING2); | 1237 | DMA_RUN_SOMETHING2); |
1152 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1238 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1153 | DMA_RESUME | | 1239 | DMA_RESUME | |
1154 | SOMETHING_ALMOST_ALWAYS_SET | | 1240 | SOMETHING_ALMOST_ALWAYS_SET | |
1155 | DMA_EPILOGUE_SOMETHING | | 1241 | DMA_EPILOGUE_SOMETHING | |
1156 | DMA_SOMETHING_ELSE); | 1242 | DMA_SOMETHING_ELSE); |
1157 | #endif | 1243 | #endif |
1158 | spin_unlock(&chip->reg_lock); | 1244 | spin_unlock(&chip->reg_lock); |
1159 | snd_azf3328_codec_activity(chip, AZF_PLAYBACK, 1); | 1245 | snd_azf3328_ctrl_codec_activity(chip, codec_type, 1); |
1160 | 1246 | ||
1161 | /* now unmute WaveOut */ | 1247 | if (is_playback_codec) { |
1162 | if (!previously_muted) | 1248 | /* now unmute WaveOut */ |
1163 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 0); | 1249 | if (!previously_muted) |
1250 | snd_azf3328_mixer_set_mute( | ||
1251 | chip, IDX_MIXER_WAVEOUT, 0 | ||
1252 | ); | ||
1253 | } | ||
1164 | 1254 | ||
1165 | snd_azf3328_dbgplay("STARTED PLAYBACK\n"); | 1255 | snd_azf3328_dbgcodec("STARTED %s\n", codec->name); |
1166 | break; | 1256 | break; |
1167 | case SNDRV_PCM_TRIGGER_RESUME: | 1257 | case SNDRV_PCM_TRIGGER_RESUME: |
1168 | snd_azf3328_dbgplay("RESUME PLAYBACK\n"); | 1258 | snd_azf3328_dbgcodec("RESUME %s\n", codec->name); |
1169 | /* resume playback if we were active */ | 1259 | /* resume codec if we were active */ |
1170 | spin_lock(&chip->reg_lock); | 1260 | spin_lock(&chip->reg_lock); |
1171 | if (chip->audio_stream[AZF_PLAYBACK].running) | 1261 | if (codec->running) |
1172 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1262 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1173 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS) | DMA_RESUME); | 1263 | snd_azf3328_codec_inw( |
1264 | codec, IDX_IO_CODEC_DMA_FLAGS | ||
1265 | ) | DMA_RESUME | ||
1266 | ); | ||
1174 | spin_unlock(&chip->reg_lock); | 1267 | spin_unlock(&chip->reg_lock); |
1175 | break; | 1268 | break; |
1176 | case SNDRV_PCM_TRIGGER_STOP: | 1269 | case SNDRV_PCM_TRIGGER_STOP: |
1177 | snd_azf3328_dbgplay("STOP PLAYBACK\n"); | 1270 | snd_azf3328_dbgcodec("STOP %s\n", codec->name); |
1178 | 1271 | ||
1179 | /* mute WaveOut (avoid clicking during setup) */ | 1272 | if (is_playback_codec) { |
1180 | previously_muted = | 1273 | /* mute WaveOut (avoid clicking during setup) */ |
1181 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); | 1274 | previously_muted = |
1275 | snd_azf3328_mixer_set_mute( | ||
1276 | chip, IDX_MIXER_WAVEOUT, 1 | ||
1277 | ); | ||
1278 | } | ||
1182 | 1279 | ||
1183 | spin_lock(&chip->reg_lock); | 1280 | spin_lock(&chip->reg_lock); |
1184 | /* first, remember current value: */ | 1281 | /* first, remember current value: */ |
1185 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS); | 1282 | flags1 = snd_azf3328_codec_inw(codec, IDX_IO_CODEC_DMA_FLAGS); |
1186 | 1283 | ||
1187 | /* stop playback */ | 1284 | /* stop transfer */ |
1188 | status1 &= ~DMA_RESUME; | 1285 | flags1 &= ~DMA_RESUME; |
1189 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1286 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1190 | 1287 | ||
1191 | /* hmm, is this really required? we're resetting the same bit | 1288 | /* hmm, is this really required? we're resetting the same bit |
1192 | * immediately thereafter... */ | 1289 | * immediately thereafter... */ |
1193 | status1 |= DMA_PLAY_SOMETHING1; | 1290 | flags1 |= DMA_RUN_SOMETHING1; |
1194 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1291 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1195 | 1292 | ||
1196 | status1 &= ~DMA_PLAY_SOMETHING1; | 1293 | flags1 &= ~DMA_RUN_SOMETHING1; |
1197 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1294 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1198 | spin_unlock(&chip->reg_lock); | 1295 | spin_unlock(&chip->reg_lock); |
1199 | snd_azf3328_codec_activity(chip, AZF_PLAYBACK, 0); | 1296 | snd_azf3328_ctrl_codec_activity(chip, codec_type, 0); |
1200 | 1297 | ||
1201 | /* now unmute WaveOut */ | 1298 | if (is_playback_codec) { |
1202 | if (!previously_muted) | 1299 | /* now unmute WaveOut */ |
1203 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 0); | 1300 | if (!previously_muted) |
1301 | snd_azf3328_mixer_set_mute( | ||
1302 | chip, IDX_MIXER_WAVEOUT, 0 | ||
1303 | ); | ||
1304 | } | ||
1204 | 1305 | ||
1205 | snd_azf3328_dbgplay("STOPPED PLAYBACK\n"); | 1306 | snd_azf3328_dbgcodec("STOPPED %s\n", codec->name); |
1206 | break; | 1307 | break; |
1207 | case SNDRV_PCM_TRIGGER_SUSPEND: | 1308 | case SNDRV_PCM_TRIGGER_SUSPEND: |
1208 | snd_azf3328_dbgplay("SUSPEND PLAYBACK\n"); | 1309 | snd_azf3328_dbgcodec("SUSPEND %s\n", codec->name); |
1209 | /* make sure playback is stopped */ | 1310 | /* make sure codec is stopped */ |
1210 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1311 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1211 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS) & ~DMA_RESUME); | 1312 | snd_azf3328_codec_inw( |
1313 | codec, IDX_IO_CODEC_DMA_FLAGS | ||
1314 | ) & ~DMA_RESUME | ||
1315 | ); | ||
1212 | break; | 1316 | break; |
1213 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1317 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
1214 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); | 1318 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); |
@@ -1217,7 +1321,7 @@ snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1217 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); | 1321 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); |
1218 | break; | 1322 | break; |
1219 | default: | 1323 | default: |
1220 | printk(KERN_ERR "FIXME: unknown trigger mode!\n"); | 1324 | snd_printk(KERN_ERR "FIXME: unknown trigger mode!\n"); |
1221 | return -EINVAL; | 1325 | return -EINVAL; |
1222 | } | 1326 | } |
1223 | 1327 | ||
@@ -1225,172 +1329,74 @@ snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1225 | return result; | 1329 | return result; |
1226 | } | 1330 | } |
1227 | 1331 | ||
1228 | /* this is just analogous to playback; I'm not quite sure whether recording | ||
1229 | * should actually be triggered like that */ | ||
1230 | static int | 1332 | static int |
1231 | snd_azf3328_capture_trigger(struct snd_pcm_substream *substream, int cmd) | 1333 | snd_azf3328_codec_playback_trigger(struct snd_pcm_substream *substream, int cmd) |
1232 | { | 1334 | { |
1233 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1335 | return snd_azf3328_codec_trigger(AZF_CODEC_PLAYBACK, substream, cmd); |
1234 | struct snd_pcm_runtime *runtime = substream->runtime; | 1336 | } |
1235 | int result = 0; | ||
1236 | unsigned int status1; | ||
1237 | |||
1238 | snd_azf3328_dbgcalls("snd_azf3328_capture_trigger cmd %d\n", cmd); | ||
1239 | |||
1240 | switch (cmd) { | ||
1241 | case SNDRV_PCM_TRIGGER_START: | ||
1242 | |||
1243 | snd_azf3328_dbgplay("START CAPTURE\n"); | ||
1244 | |||
1245 | snd_azf3328_codec_setfmt(chip, IDX_IO_REC_SOUNDFORMAT, | ||
1246 | runtime->rate, | ||
1247 | snd_pcm_format_width(runtime->format), | ||
1248 | runtime->channels); | ||
1249 | |||
1250 | spin_lock(&chip->reg_lock); | ||
1251 | /* first, remember current value: */ | ||
1252 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS); | ||
1253 | |||
1254 | /* stop recording */ | ||
1255 | status1 &= ~DMA_RESUME; | ||
1256 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1257 | |||
1258 | /* FIXME: clear interrupts or what??? */ | ||
1259 | snd_azf3328_codec_outw(chip, IDX_IO_REC_IRQTYPE, 0xffff); | ||
1260 | spin_unlock(&chip->reg_lock); | ||
1261 | |||
1262 | snd_azf3328_setdmaa(chip, runtime->dma_addr, | ||
1263 | snd_pcm_lib_period_bytes(substream), | ||
1264 | snd_pcm_lib_buffer_bytes(substream), | ||
1265 | AZF_CAPTURE); | ||
1266 | |||
1267 | spin_lock(&chip->reg_lock); | ||
1268 | #ifdef WIN9X | ||
1269 | /* FIXME: enable playback/recording??? */ | ||
1270 | status1 |= DMA_PLAY_SOMETHING1 | DMA_PLAY_SOMETHING2; | ||
1271 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1272 | |||
1273 | /* start capture again */ | ||
1274 | /* FIXME: what is this value (0x0010)??? */ | ||
1275 | status1 |= DMA_RESUME | DMA_EPILOGUE_SOMETHING; | ||
1276 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1277 | #else | ||
1278 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1279 | 0x0000); | ||
1280 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1281 | DMA_PLAY_SOMETHING1); | ||
1282 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1283 | DMA_PLAY_SOMETHING1 | | ||
1284 | DMA_PLAY_SOMETHING2); | ||
1285 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1286 | DMA_RESUME | | ||
1287 | SOMETHING_ALMOST_ALWAYS_SET | | ||
1288 | DMA_EPILOGUE_SOMETHING | | ||
1289 | DMA_SOMETHING_ELSE); | ||
1290 | #endif | ||
1291 | spin_unlock(&chip->reg_lock); | ||
1292 | snd_azf3328_codec_activity(chip, AZF_CAPTURE, 1); | ||
1293 | |||
1294 | snd_azf3328_dbgplay("STARTED CAPTURE\n"); | ||
1295 | break; | ||
1296 | case SNDRV_PCM_TRIGGER_RESUME: | ||
1297 | snd_azf3328_dbgplay("RESUME CAPTURE\n"); | ||
1298 | /* resume recording if we were active */ | ||
1299 | spin_lock(&chip->reg_lock); | ||
1300 | if (chip->audio_stream[AZF_CAPTURE].running) | ||
1301 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1302 | snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS) | DMA_RESUME); | ||
1303 | spin_unlock(&chip->reg_lock); | ||
1304 | break; | ||
1305 | case SNDRV_PCM_TRIGGER_STOP: | ||
1306 | snd_azf3328_dbgplay("STOP CAPTURE\n"); | ||
1307 | |||
1308 | spin_lock(&chip->reg_lock); | ||
1309 | /* first, remember current value: */ | ||
1310 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS); | ||
1311 | |||
1312 | /* stop recording */ | ||
1313 | status1 &= ~DMA_RESUME; | ||
1314 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1315 | |||
1316 | status1 |= DMA_PLAY_SOMETHING1; | ||
1317 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1318 | |||
1319 | status1 &= ~DMA_PLAY_SOMETHING1; | ||
1320 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1321 | spin_unlock(&chip->reg_lock); | ||
1322 | snd_azf3328_codec_activity(chip, AZF_CAPTURE, 0); | ||
1323 | 1337 | ||
1324 | snd_azf3328_dbgplay("STOPPED CAPTURE\n"); | 1338 | static int |
1325 | break; | 1339 | snd_azf3328_codec_capture_trigger(struct snd_pcm_substream *substream, int cmd) |
1326 | case SNDRV_PCM_TRIGGER_SUSPEND: | 1340 | { |
1327 | snd_azf3328_dbgplay("SUSPEND CAPTURE\n"); | 1341 | return snd_azf3328_codec_trigger(AZF_CODEC_CAPTURE, substream, cmd); |
1328 | /* make sure recording is stopped */ | 1342 | } |
1329 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1330 | snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS) & ~DMA_RESUME); | ||
1331 | break; | ||
1332 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
1333 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); | ||
1334 | break; | ||
1335 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
1336 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); | ||
1337 | break; | ||
1338 | default: | ||
1339 | printk(KERN_ERR "FIXME: unknown trigger mode!\n"); | ||
1340 | return -EINVAL; | ||
1341 | } | ||
1342 | 1343 | ||
1343 | snd_azf3328_dbgcallleave(); | 1344 | static int |
1344 | return result; | 1345 | snd_azf3328_codec_i2s_out_trigger(struct snd_pcm_substream *substream, int cmd) |
1346 | { | ||
1347 | return snd_azf3328_codec_trigger(AZF_CODEC_I2S_OUT, substream, cmd); | ||
1345 | } | 1348 | } |
1346 | 1349 | ||
1347 | static snd_pcm_uframes_t | 1350 | static snd_pcm_uframes_t |
1348 | snd_azf3328_playback_pointer(struct snd_pcm_substream *substream) | 1351 | snd_azf3328_codec_pointer(struct snd_pcm_substream *substream, |
1352 | enum snd_azf3328_codec_type codec_type | ||
1353 | ) | ||
1349 | { | 1354 | { |
1350 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1355 | const struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1356 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
1351 | unsigned long bufptr, result; | 1357 | unsigned long bufptr, result; |
1352 | snd_pcm_uframes_t frmres; | 1358 | snd_pcm_uframes_t frmres; |
1353 | 1359 | ||
1354 | #ifdef QUERY_HARDWARE | 1360 | #ifdef QUERY_HARDWARE |
1355 | bufptr = snd_azf3328_codec_inl(chip, IDX_IO_PLAY_DMA_START_1); | 1361 | bufptr = snd_azf3328_codec_inl(codec, IDX_IO_CODEC_DMA_START_1); |
1356 | #else | 1362 | #else |
1357 | bufptr = substream->runtime->dma_addr; | 1363 | bufptr = substream->runtime->dma_addr; |
1358 | #endif | 1364 | #endif |
1359 | result = snd_azf3328_codec_inl(chip, IDX_IO_PLAY_DMA_CURRPOS); | 1365 | result = snd_azf3328_codec_inl(codec, IDX_IO_CODEC_DMA_CURRPOS); |
1360 | 1366 | ||
1361 | /* calculate offset */ | 1367 | /* calculate offset */ |
1362 | result -= bufptr; | 1368 | result -= bufptr; |
1363 | frmres = bytes_to_frames( substream->runtime, result); | 1369 | frmres = bytes_to_frames( substream->runtime, result); |
1364 | snd_azf3328_dbgplay("PLAY @ 0x%8lx, frames %8ld\n", result, frmres); | 1370 | snd_azf3328_dbgcodec("%s @ 0x%8lx, frames %8ld\n", |
1371 | codec->name, result, frmres); | ||
1365 | return frmres; | 1372 | return frmres; |
1366 | } | 1373 | } |
1367 | 1374 | ||
1368 | static snd_pcm_uframes_t | 1375 | static snd_pcm_uframes_t |
1369 | snd_azf3328_capture_pointer(struct snd_pcm_substream *substream) | 1376 | snd_azf3328_codec_playback_pointer(struct snd_pcm_substream *substream) |
1370 | { | 1377 | { |
1371 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1378 | return snd_azf3328_codec_pointer(substream, AZF_CODEC_PLAYBACK); |
1372 | unsigned long bufptr, result; | 1379 | } |
1373 | snd_pcm_uframes_t frmres; | ||
1374 | 1380 | ||
1375 | #ifdef QUERY_HARDWARE | 1381 | static snd_pcm_uframes_t |
1376 | bufptr = snd_azf3328_codec_inl(chip, IDX_IO_REC_DMA_START_1); | 1382 | snd_azf3328_codec_capture_pointer(struct snd_pcm_substream *substream) |
1377 | #else | 1383 | { |
1378 | bufptr = substream->runtime->dma_addr; | 1384 | return snd_azf3328_codec_pointer(substream, AZF_CODEC_CAPTURE); |
1379 | #endif | 1385 | } |
1380 | result = snd_azf3328_codec_inl(chip, IDX_IO_REC_DMA_CURRPOS); | ||
1381 | 1386 | ||
1382 | /* calculate offset */ | 1387 | static snd_pcm_uframes_t |
1383 | result -= bufptr; | 1388 | snd_azf3328_codec_i2s_out_pointer(struct snd_pcm_substream *substream) |
1384 | frmres = bytes_to_frames( substream->runtime, result); | 1389 | { |
1385 | snd_azf3328_dbgplay("REC @ 0x%8lx, frames %8ld\n", result, frmres); | 1390 | return snd_azf3328_codec_pointer(substream, AZF_CODEC_I2S_OUT); |
1386 | return frmres; | ||
1387 | } | 1391 | } |
1388 | 1392 | ||
1389 | /******************************************************************/ | 1393 | /******************************************************************/ |
1390 | 1394 | ||
1391 | #ifdef SUPPORT_GAMEPORT | 1395 | #ifdef SUPPORT_GAMEPORT |
1392 | static inline void | 1396 | static inline void |
1393 | snd_azf3328_gameport_irq_enable(struct snd_azf3328 *chip, int enable) | 1397 | snd_azf3328_gameport_irq_enable(struct snd_azf3328 *chip, |
1398 | bool enable | ||
1399 | ) | ||
1394 | { | 1400 | { |
1395 | snd_azf3328_io_reg_setb( | 1401 | snd_azf3328_io_reg_setb( |
1396 | chip->game_io+IDX_GAME_HWCONFIG, | 1402 | chip->game_io+IDX_GAME_HWCONFIG, |
@@ -1400,7 +1406,9 @@ snd_azf3328_gameport_irq_enable(struct snd_azf3328 *chip, int enable) | |||
1400 | } | 1406 | } |
1401 | 1407 | ||
1402 | static inline void | 1408 | static inline void |
1403 | snd_azf3328_gameport_legacy_address_enable(struct snd_azf3328 *chip, int enable) | 1409 | snd_azf3328_gameport_legacy_address_enable(struct snd_azf3328 *chip, |
1410 | bool enable | ||
1411 | ) | ||
1404 | { | 1412 | { |
1405 | snd_azf3328_io_reg_setb( | 1413 | snd_azf3328_io_reg_setb( |
1406 | chip->game_io+IDX_GAME_HWCONFIG, | 1414 | chip->game_io+IDX_GAME_HWCONFIG, |
@@ -1409,10 +1417,27 @@ snd_azf3328_gameport_legacy_address_enable(struct snd_azf3328 *chip, int enable) | |||
1409 | ); | 1417 | ); |
1410 | } | 1418 | } |
1411 | 1419 | ||
1420 | static void | ||
1421 | snd_azf3328_gameport_set_counter_frequency(struct snd_azf3328 *chip, | ||
1422 | unsigned int freq_cfg | ||
1423 | ) | ||
1424 | { | ||
1425 | snd_azf3328_io_reg_setb( | ||
1426 | chip->game_io+IDX_GAME_HWCONFIG, | ||
1427 | 0x02, | ||
1428 | (freq_cfg & 1) != 0 | ||
1429 | ); | ||
1430 | snd_azf3328_io_reg_setb( | ||
1431 | chip->game_io+IDX_GAME_HWCONFIG, | ||
1432 | 0x04, | ||
1433 | (freq_cfg & 2) != 0 | ||
1434 | ); | ||
1435 | } | ||
1436 | |||
1412 | static inline void | 1437 | static inline void |
1413 | snd_azf3328_gameport_axis_circuit_enable(struct snd_azf3328 *chip, int enable) | 1438 | snd_azf3328_gameport_axis_circuit_enable(struct snd_azf3328 *chip, bool enable) |
1414 | { | 1439 | { |
1415 | snd_azf3328_codec_reg_6AH_update( | 1440 | snd_azf3328_ctrl_reg_6AH_update( |
1416 | chip, IO_6A_SOMETHING2_GAMEPORT, enable | 1441 | chip, IO_6A_SOMETHING2_GAMEPORT, enable |
1417 | ); | 1442 | ); |
1418 | } | 1443 | } |
@@ -1447,6 +1472,8 @@ snd_azf3328_gameport_open(struct gameport *gameport, int mode) | |||
1447 | break; | 1472 | break; |
1448 | } | 1473 | } |
1449 | 1474 | ||
1475 | snd_azf3328_gameport_set_counter_frequency(chip, | ||
1476 | GAME_HWCFG_ADC_COUNTER_FREQ_STD); | ||
1450 | snd_azf3328_gameport_axis_circuit_enable(chip, (res == 0)); | 1477 | snd_azf3328_gameport_axis_circuit_enable(chip, (res == 0)); |
1451 | 1478 | ||
1452 | return res; | 1479 | return res; |
@@ -1458,6 +1485,8 @@ snd_azf3328_gameport_close(struct gameport *gameport) | |||
1458 | struct snd_azf3328 *chip = gameport_get_port_data(gameport); | 1485 | struct snd_azf3328 *chip = gameport_get_port_data(gameport); |
1459 | 1486 | ||
1460 | snd_azf3328_dbggame("gameport_close\n"); | 1487 | snd_azf3328_dbggame("gameport_close\n"); |
1488 | snd_azf3328_gameport_set_counter_frequency(chip, | ||
1489 | GAME_HWCFG_ADC_COUNTER_FREQ_1_200); | ||
1461 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); | 1490 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); |
1462 | } | 1491 | } |
1463 | 1492 | ||
@@ -1491,7 +1520,7 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport, | |||
1491 | 1520 | ||
1492 | val = snd_azf3328_game_inb(chip, IDX_GAME_AXES_CONFIG); | 1521 | val = snd_azf3328_game_inb(chip, IDX_GAME_AXES_CONFIG); |
1493 | if (val & GAME_AXES_SAMPLING_READY) { | 1522 | if (val & GAME_AXES_SAMPLING_READY) { |
1494 | for (i = 0; i < 4; ++i) { | 1523 | for (i = 0; i < ARRAY_SIZE(chip->axes); ++i) { |
1495 | /* configure the axis to read */ | 1524 | /* configure the axis to read */ |
1496 | val = (i << 4) | 0x0f; | 1525 | val = (i << 4) | 0x0f; |
1497 | snd_azf3328_game_outb(chip, IDX_GAME_AXES_CONFIG, val); | 1526 | snd_azf3328_game_outb(chip, IDX_GAME_AXES_CONFIG, val); |
@@ -1514,7 +1543,7 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport, | |||
1514 | snd_azf3328_game_outw(chip, IDX_GAME_AXIS_VALUE, 0xffff); | 1543 | snd_azf3328_game_outw(chip, IDX_GAME_AXIS_VALUE, 0xffff); |
1515 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1544 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1516 | 1545 | ||
1517 | for (i = 0; i < 4; i++) { | 1546 | for (i = 0; i < ARRAY_SIZE(chip->axes); i++) { |
1518 | axes[i] = chip->axes[i]; | 1547 | axes[i] = chip->axes[i]; |
1519 | if (axes[i] == 0xffff) | 1548 | if (axes[i] == 0xffff) |
1520 | axes[i] = -1; | 1549 | axes[i] = -1; |
@@ -1552,6 +1581,8 @@ snd_azf3328_gameport(struct snd_azf3328 *chip, int dev) | |||
1552 | /* DISABLE legacy address: we don't need it! */ | 1581 | /* DISABLE legacy address: we don't need it! */ |
1553 | snd_azf3328_gameport_legacy_address_enable(chip, 0); | 1582 | snd_azf3328_gameport_legacy_address_enable(chip, 0); |
1554 | 1583 | ||
1584 | snd_azf3328_gameport_set_counter_frequency(chip, | ||
1585 | GAME_HWCFG_ADC_COUNTER_FREQ_1_200); | ||
1555 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); | 1586 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); |
1556 | 1587 | ||
1557 | gameport_register_port(chip->gameport); | 1588 | gameport_register_port(chip->gameport); |
@@ -1585,40 +1616,77 @@ snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip) | |||
1585 | static inline void | 1616 | static inline void |
1586 | snd_azf3328_irq_log_unknown_type(u8 which) | 1617 | snd_azf3328_irq_log_unknown_type(u8 which) |
1587 | { | 1618 | { |
1588 | snd_azf3328_dbgplay( | 1619 | snd_azf3328_dbgcodec( |
1589 | "azt3328: unknown IRQ type (%x) occurred, please report!\n", | 1620 | "azt3328: unknown IRQ type (%x) occurred, please report!\n", |
1590 | which | 1621 | which |
1591 | ); | 1622 | ); |
1592 | } | 1623 | } |
1593 | 1624 | ||
1625 | static inline void | ||
1626 | snd_azf3328_codec_interrupt(struct snd_azf3328 *chip, u8 status) | ||
1627 | { | ||
1628 | u8 which; | ||
1629 | enum snd_azf3328_codec_type codec_type; | ||
1630 | const struct snd_azf3328_codec_data *codec; | ||
1631 | |||
1632 | for (codec_type = AZF_CODEC_PLAYBACK; | ||
1633 | codec_type <= AZF_CODEC_I2S_OUT; | ||
1634 | ++codec_type) { | ||
1635 | |||
1636 | /* skip codec if there's no interrupt for it */ | ||
1637 | if (!(status & (1 << codec_type))) | ||
1638 | continue; | ||
1639 | |||
1640 | codec = &chip->codecs[codec_type]; | ||
1641 | |||
1642 | spin_lock(&chip->reg_lock); | ||
1643 | which = snd_azf3328_codec_inb(codec, IDX_IO_CODEC_IRQTYPE); | ||
1644 | /* ack all IRQ types immediately */ | ||
1645 | snd_azf3328_codec_outb(codec, IDX_IO_CODEC_IRQTYPE, which); | ||
1646 | spin_unlock(&chip->reg_lock); | ||
1647 | |||
1648 | if ((chip->pcm[codec_type]) && (codec->substream)) { | ||
1649 | snd_pcm_period_elapsed(codec->substream); | ||
1650 | snd_azf3328_dbgcodec("%s period done (#%x), @ %x\n", | ||
1651 | codec->name, | ||
1652 | which, | ||
1653 | snd_azf3328_codec_inl( | ||
1654 | codec, IDX_IO_CODEC_DMA_CURRPOS | ||
1655 | ) | ||
1656 | ); | ||
1657 | } else | ||
1658 | printk(KERN_WARNING "azt3328: irq handler problem!\n"); | ||
1659 | if (which & IRQ_SOMETHING) | ||
1660 | snd_azf3328_irq_log_unknown_type(which); | ||
1661 | } | ||
1662 | } | ||
1663 | |||
1594 | static irqreturn_t | 1664 | static irqreturn_t |
1595 | snd_azf3328_interrupt(int irq, void *dev_id) | 1665 | snd_azf3328_interrupt(int irq, void *dev_id) |
1596 | { | 1666 | { |
1597 | struct snd_azf3328 *chip = dev_id; | 1667 | struct snd_azf3328 *chip = dev_id; |
1598 | u8 status, which; | 1668 | u8 status; |
1599 | #if DEBUG_PLAY_REC | 1669 | #if DEBUG_CODEC |
1600 | static unsigned long irq_count; | 1670 | static unsigned long irq_count; |
1601 | #endif | 1671 | #endif |
1602 | 1672 | ||
1603 | status = snd_azf3328_codec_inb(chip, IDX_IO_IRQSTATUS); | 1673 | status = snd_azf3328_ctrl_inb(chip, IDX_IO_IRQSTATUS); |
1604 | 1674 | ||
1605 | /* fast path out, to ease interrupt sharing */ | 1675 | /* fast path out, to ease interrupt sharing */ |
1606 | if (!(status & | 1676 | if (!(status & |
1607 | (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_GAMEPORT|IRQ_MPU401|IRQ_TIMER) | 1677 | (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT |
1678 | |IRQ_GAMEPORT|IRQ_MPU401|IRQ_TIMER) | ||
1608 | )) | 1679 | )) |
1609 | return IRQ_NONE; /* must be interrupt for another device */ | 1680 | return IRQ_NONE; /* must be interrupt for another device */ |
1610 | 1681 | ||
1611 | snd_azf3328_dbgplay( | 1682 | snd_azf3328_dbgcodec( |
1612 | "irq_count %ld! IDX_IO_PLAY_FLAGS %04x, " | 1683 | "irq_count %ld! IDX_IO_IRQSTATUS %04x\n", |
1613 | "IDX_IO_PLAY_IRQTYPE %04x, IDX_IO_IRQSTATUS %04x\n", | ||
1614 | irq_count++ /* debug-only */, | 1684 | irq_count++ /* debug-only */, |
1615 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS), | ||
1616 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_IRQTYPE), | ||
1617 | status | 1685 | status |
1618 | ); | 1686 | ); |
1619 | 1687 | ||
1620 | if (status & IRQ_TIMER) { | 1688 | if (status & IRQ_TIMER) { |
1621 | /* snd_azf3328_dbgplay("timer %ld\n", | 1689 | /* snd_azf3328_dbgcodec("timer %ld\n", |
1622 | snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE) | 1690 | snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE) |
1623 | & TIMER_VALUE_MASK | 1691 | & TIMER_VALUE_MASK |
1624 | ); */ | 1692 | ); */ |
@@ -1626,71 +1694,36 @@ snd_azf3328_interrupt(int irq, void *dev_id) | |||
1626 | snd_timer_interrupt(chip->timer, chip->timer->sticks); | 1694 | snd_timer_interrupt(chip->timer, chip->timer->sticks); |
1627 | /* ACK timer */ | 1695 | /* ACK timer */ |
1628 | spin_lock(&chip->reg_lock); | 1696 | spin_lock(&chip->reg_lock); |
1629 | snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07); | 1697 | snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07); |
1630 | spin_unlock(&chip->reg_lock); | 1698 | spin_unlock(&chip->reg_lock); |
1631 | snd_azf3328_dbgplay("azt3328: timer IRQ\n"); | 1699 | snd_azf3328_dbgcodec("azt3328: timer IRQ\n"); |
1632 | } | 1700 | } |
1633 | if (status & IRQ_PLAYBACK) { | ||
1634 | spin_lock(&chip->reg_lock); | ||
1635 | which = snd_azf3328_codec_inb(chip, IDX_IO_PLAY_IRQTYPE); | ||
1636 | /* ack all IRQ types immediately */ | ||
1637 | snd_azf3328_codec_outb(chip, IDX_IO_PLAY_IRQTYPE, which); | ||
1638 | spin_unlock(&chip->reg_lock); | ||
1639 | 1701 | ||
1640 | if (chip->pcm && chip->audio_stream[AZF_PLAYBACK].substream) { | 1702 | if (status & (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT)) |
1641 | snd_pcm_period_elapsed( | 1703 | snd_azf3328_codec_interrupt(chip, status); |
1642 | chip->audio_stream[AZF_PLAYBACK].substream | ||
1643 | ); | ||
1644 | snd_azf3328_dbgplay("PLAY period done (#%x), @ %x\n", | ||
1645 | which, | ||
1646 | snd_azf3328_codec_inl( | ||
1647 | chip, IDX_IO_PLAY_DMA_CURRPOS | ||
1648 | ) | ||
1649 | ); | ||
1650 | } else | ||
1651 | printk(KERN_WARNING "azt3328: irq handler problem!\n"); | ||
1652 | if (which & IRQ_PLAY_SOMETHING) | ||
1653 | snd_azf3328_irq_log_unknown_type(which); | ||
1654 | } | ||
1655 | if (status & IRQ_RECORDING) { | ||
1656 | spin_lock(&chip->reg_lock); | ||
1657 | which = snd_azf3328_codec_inb(chip, IDX_IO_REC_IRQTYPE); | ||
1658 | /* ack all IRQ types immediately */ | ||
1659 | snd_azf3328_codec_outb(chip, IDX_IO_REC_IRQTYPE, which); | ||
1660 | spin_unlock(&chip->reg_lock); | ||
1661 | 1704 | ||
1662 | if (chip->pcm && chip->audio_stream[AZF_CAPTURE].substream) { | ||
1663 | snd_pcm_period_elapsed( | ||
1664 | chip->audio_stream[AZF_CAPTURE].substream | ||
1665 | ); | ||
1666 | snd_azf3328_dbgplay("REC period done (#%x), @ %x\n", | ||
1667 | which, | ||
1668 | snd_azf3328_codec_inl( | ||
1669 | chip, IDX_IO_REC_DMA_CURRPOS | ||
1670 | ) | ||
1671 | ); | ||
1672 | } else | ||
1673 | printk(KERN_WARNING "azt3328: irq handler problem!\n"); | ||
1674 | if (which & IRQ_REC_SOMETHING) | ||
1675 | snd_azf3328_irq_log_unknown_type(which); | ||
1676 | } | ||
1677 | if (status & IRQ_GAMEPORT) | 1705 | if (status & IRQ_GAMEPORT) |
1678 | snd_azf3328_gameport_interrupt(chip); | 1706 | snd_azf3328_gameport_interrupt(chip); |
1707 | |||
1679 | /* MPU401 has less critical IRQ requirements | 1708 | /* MPU401 has less critical IRQ requirements |
1680 | * than timer and playback/recording, right? */ | 1709 | * than timer and playback/recording, right? */ |
1681 | if (status & IRQ_MPU401) { | 1710 | if (status & IRQ_MPU401) { |
1682 | snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); | 1711 | snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); |
1683 | 1712 | ||
1684 | /* hmm, do we have to ack the IRQ here somehow? | 1713 | /* hmm, do we have to ack the IRQ here somehow? |
1685 | * If so, then I don't know how... */ | 1714 | * If so, then I don't know how yet... */ |
1686 | snd_azf3328_dbgplay("azt3328: MPU401 IRQ\n"); | 1715 | snd_azf3328_dbgcodec("azt3328: MPU401 IRQ\n"); |
1687 | } | 1716 | } |
1688 | return IRQ_HANDLED; | 1717 | return IRQ_HANDLED; |
1689 | } | 1718 | } |
1690 | 1719 | ||
1691 | /*****************************************************************/ | 1720 | /*****************************************************************/ |
1692 | 1721 | ||
1693 | static const struct snd_pcm_hardware snd_azf3328_playback = | 1722 | /* as long as we think we have identical snd_pcm_hardware parameters |
1723 | for playback, capture and i2s out, we can use the same physical struct | ||
1724 | since the struct is simply being copied into a member. | ||
1725 | */ | ||
1726 | static const struct snd_pcm_hardware snd_azf3328_hardware = | ||
1694 | { | 1727 | { |
1695 | /* FIXME!! Correct? */ | 1728 | /* FIXME!! Correct? */ |
1696 | .info = SNDRV_PCM_INFO_MMAP | | 1729 | .info = SNDRV_PCM_INFO_MMAP | |
@@ -1718,31 +1751,6 @@ static const struct snd_pcm_hardware snd_azf3328_playback = | |||
1718 | .fifo_size = 0, | 1751 | .fifo_size = 0, |
1719 | }; | 1752 | }; |
1720 | 1753 | ||
1721 | static const struct snd_pcm_hardware snd_azf3328_capture = | ||
1722 | { | ||
1723 | /* FIXME */ | ||
1724 | .info = SNDRV_PCM_INFO_MMAP | | ||
1725 | SNDRV_PCM_INFO_INTERLEAVED | | ||
1726 | SNDRV_PCM_INFO_MMAP_VALID, | ||
1727 | .formats = SNDRV_PCM_FMTBIT_S8 | | ||
1728 | SNDRV_PCM_FMTBIT_U8 | | ||
1729 | SNDRV_PCM_FMTBIT_S16_LE | | ||
1730 | SNDRV_PCM_FMTBIT_U16_LE, | ||
1731 | .rates = SNDRV_PCM_RATE_5512 | | ||
1732 | SNDRV_PCM_RATE_8000_48000 | | ||
1733 | SNDRV_PCM_RATE_KNOT, | ||
1734 | .rate_min = AZF_FREQ_4000, | ||
1735 | .rate_max = AZF_FREQ_66200, | ||
1736 | .channels_min = 1, | ||
1737 | .channels_max = 2, | ||
1738 | .buffer_bytes_max = 65536, | ||
1739 | .period_bytes_min = 64, | ||
1740 | .period_bytes_max = 65536, | ||
1741 | .periods_min = 1, | ||
1742 | .periods_max = 1024, | ||
1743 | .fifo_size = 0, | ||
1744 | }; | ||
1745 | |||
1746 | 1754 | ||
1747 | static unsigned int snd_azf3328_fixed_rates[] = { | 1755 | static unsigned int snd_azf3328_fixed_rates[] = { |
1748 | AZF_FREQ_4000, | 1756 | AZF_FREQ_4000, |
@@ -1770,14 +1778,19 @@ static struct snd_pcm_hw_constraint_list snd_azf3328_hw_constraints_rates = { | |||
1770 | /*****************************************************************/ | 1778 | /*****************************************************************/ |
1771 | 1779 | ||
1772 | static int | 1780 | static int |
1773 | snd_azf3328_playback_open(struct snd_pcm_substream *substream) | 1781 | snd_azf3328_pcm_open(struct snd_pcm_substream *substream, |
1782 | enum snd_azf3328_codec_type codec_type | ||
1783 | ) | ||
1774 | { | 1784 | { |
1775 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1785 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1776 | struct snd_pcm_runtime *runtime = substream->runtime; | 1786 | struct snd_pcm_runtime *runtime = substream->runtime; |
1777 | 1787 | ||
1778 | snd_azf3328_dbgcallenter(); | 1788 | snd_azf3328_dbgcallenter(); |
1779 | chip->audio_stream[AZF_PLAYBACK].substream = substream; | 1789 | chip->codecs[codec_type].substream = substream; |
1780 | runtime->hw = snd_azf3328_playback; | 1790 | |
1791 | /* same parameters for all our codecs - at least we think so... */ | ||
1792 | runtime->hw = snd_azf3328_hardware; | ||
1793 | |||
1781 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 1794 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
1782 | &snd_azf3328_hw_constraints_rates); | 1795 | &snd_azf3328_hw_constraints_rates); |
1783 | snd_azf3328_dbgcallleave(); | 1796 | snd_azf3328_dbgcallleave(); |
@@ -1785,40 +1798,52 @@ snd_azf3328_playback_open(struct snd_pcm_substream *substream) | |||
1785 | } | 1798 | } |
1786 | 1799 | ||
1787 | static int | 1800 | static int |
1801 | snd_azf3328_playback_open(struct snd_pcm_substream *substream) | ||
1802 | { | ||
1803 | return snd_azf3328_pcm_open(substream, AZF_CODEC_PLAYBACK); | ||
1804 | } | ||
1805 | |||
1806 | static int | ||
1788 | snd_azf3328_capture_open(struct snd_pcm_substream *substream) | 1807 | snd_azf3328_capture_open(struct snd_pcm_substream *substream) |
1789 | { | 1808 | { |
1790 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1809 | return snd_azf3328_pcm_open(substream, AZF_CODEC_CAPTURE); |
1791 | struct snd_pcm_runtime *runtime = substream->runtime; | 1810 | } |
1792 | 1811 | ||
1793 | snd_azf3328_dbgcallenter(); | 1812 | static int |
1794 | chip->audio_stream[AZF_CAPTURE].substream = substream; | 1813 | snd_azf3328_i2s_out_open(struct snd_pcm_substream *substream) |
1795 | runtime->hw = snd_azf3328_capture; | 1814 | { |
1796 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 1815 | return snd_azf3328_pcm_open(substream, AZF_CODEC_I2S_OUT); |
1797 | &snd_azf3328_hw_constraints_rates); | ||
1798 | snd_azf3328_dbgcallleave(); | ||
1799 | return 0; | ||
1800 | } | 1816 | } |
1801 | 1817 | ||
1802 | static int | 1818 | static int |
1803 | snd_azf3328_playback_close(struct snd_pcm_substream *substream) | 1819 | snd_azf3328_pcm_close(struct snd_pcm_substream *substream, |
1820 | enum snd_azf3328_codec_type codec_type | ||
1821 | ) | ||
1804 | { | 1822 | { |
1805 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1823 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1806 | 1824 | ||
1807 | snd_azf3328_dbgcallenter(); | 1825 | snd_azf3328_dbgcallenter(); |
1808 | chip->audio_stream[AZF_PLAYBACK].substream = NULL; | 1826 | chip->codecs[codec_type].substream = NULL; |
1809 | snd_azf3328_dbgcallleave(); | 1827 | snd_azf3328_dbgcallleave(); |
1810 | return 0; | 1828 | return 0; |
1811 | } | 1829 | } |
1812 | 1830 | ||
1813 | static int | 1831 | static int |
1832 | snd_azf3328_playback_close(struct snd_pcm_substream *substream) | ||
1833 | { | ||
1834 | return snd_azf3328_pcm_close(substream, AZF_CODEC_PLAYBACK); | ||
1835 | } | ||
1836 | |||
1837 | static int | ||
1814 | snd_azf3328_capture_close(struct snd_pcm_substream *substream) | 1838 | snd_azf3328_capture_close(struct snd_pcm_substream *substream) |
1815 | { | 1839 | { |
1816 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1840 | return snd_azf3328_pcm_close(substream, AZF_CODEC_CAPTURE); |
1841 | } | ||
1817 | 1842 | ||
1818 | snd_azf3328_dbgcallenter(); | 1843 | static int |
1819 | chip->audio_stream[AZF_CAPTURE].substream = NULL; | 1844 | snd_azf3328_i2s_out_close(struct snd_pcm_substream *substream) |
1820 | snd_azf3328_dbgcallleave(); | 1845 | { |
1821 | return 0; | 1846 | return snd_azf3328_pcm_close(substream, AZF_CODEC_I2S_OUT); |
1822 | } | 1847 | } |
1823 | 1848 | ||
1824 | /******************************************************************/ | 1849 | /******************************************************************/ |
@@ -1829,9 +1854,9 @@ static struct snd_pcm_ops snd_azf3328_playback_ops = { | |||
1829 | .ioctl = snd_pcm_lib_ioctl, | 1854 | .ioctl = snd_pcm_lib_ioctl, |
1830 | .hw_params = snd_azf3328_hw_params, | 1855 | .hw_params = snd_azf3328_hw_params, |
1831 | .hw_free = snd_azf3328_hw_free, | 1856 | .hw_free = snd_azf3328_hw_free, |
1832 | .prepare = snd_azf3328_playback_prepare, | 1857 | .prepare = snd_azf3328_codec_prepare, |
1833 | .trigger = snd_azf3328_playback_trigger, | 1858 | .trigger = snd_azf3328_codec_playback_trigger, |
1834 | .pointer = snd_azf3328_playback_pointer | 1859 | .pointer = snd_azf3328_codec_playback_pointer |
1835 | }; | 1860 | }; |
1836 | 1861 | ||
1837 | static struct snd_pcm_ops snd_azf3328_capture_ops = { | 1862 | static struct snd_pcm_ops snd_azf3328_capture_ops = { |
@@ -1840,30 +1865,67 @@ static struct snd_pcm_ops snd_azf3328_capture_ops = { | |||
1840 | .ioctl = snd_pcm_lib_ioctl, | 1865 | .ioctl = snd_pcm_lib_ioctl, |
1841 | .hw_params = snd_azf3328_hw_params, | 1866 | .hw_params = snd_azf3328_hw_params, |
1842 | .hw_free = snd_azf3328_hw_free, | 1867 | .hw_free = snd_azf3328_hw_free, |
1843 | .prepare = snd_azf3328_capture_prepare, | 1868 | .prepare = snd_azf3328_codec_prepare, |
1844 | .trigger = snd_azf3328_capture_trigger, | 1869 | .trigger = snd_azf3328_codec_capture_trigger, |
1845 | .pointer = snd_azf3328_capture_pointer | 1870 | .pointer = snd_azf3328_codec_capture_pointer |
1871 | }; | ||
1872 | |||
1873 | static struct snd_pcm_ops snd_azf3328_i2s_out_ops = { | ||
1874 | .open = snd_azf3328_i2s_out_open, | ||
1875 | .close = snd_azf3328_i2s_out_close, | ||
1876 | .ioctl = snd_pcm_lib_ioctl, | ||
1877 | .hw_params = snd_azf3328_hw_params, | ||
1878 | .hw_free = snd_azf3328_hw_free, | ||
1879 | .prepare = snd_azf3328_codec_prepare, | ||
1880 | .trigger = snd_azf3328_codec_i2s_out_trigger, | ||
1881 | .pointer = snd_azf3328_codec_i2s_out_pointer | ||
1846 | }; | 1882 | }; |
1847 | 1883 | ||
1848 | static int __devinit | 1884 | static int __devinit |
1849 | snd_azf3328_pcm(struct snd_azf3328 *chip, int device) | 1885 | snd_azf3328_pcm(struct snd_azf3328 *chip) |
1850 | { | 1886 | { |
1887 | enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */ | ||
1888 | |||
1851 | struct snd_pcm *pcm; | 1889 | struct snd_pcm *pcm; |
1852 | int err; | 1890 | int err; |
1853 | 1891 | ||
1854 | snd_azf3328_dbgcallenter(); | 1892 | snd_azf3328_dbgcallenter(); |
1855 | if ((err = snd_pcm_new(chip->card, "AZF3328 DSP", device, 1, 1, &pcm)) < 0) | 1893 | |
1894 | err = snd_pcm_new(chip->card, "AZF3328 DSP", AZF_PCMDEV_STD, | ||
1895 | 1, 1, &pcm); | ||
1896 | if (err < 0) | ||
1856 | return err; | 1897 | return err; |
1857 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_azf3328_playback_ops); | 1898 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
1858 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_azf3328_capture_ops); | 1899 | &snd_azf3328_playback_ops); |
1900 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
1901 | &snd_azf3328_capture_ops); | ||
1859 | 1902 | ||
1860 | pcm->private_data = chip; | 1903 | pcm->private_data = chip; |
1861 | pcm->info_flags = 0; | 1904 | pcm->info_flags = 0; |
1862 | strcpy(pcm->name, chip->card->shortname); | 1905 | strcpy(pcm->name, chip->card->shortname); |
1863 | chip->pcm = pcm; | 1906 | /* same pcm object for playback/capture (see snd_pcm_new() above) */ |
1907 | chip->pcm[AZF_CODEC_PLAYBACK] = pcm; | ||
1908 | chip->pcm[AZF_CODEC_CAPTURE] = pcm; | ||
1864 | 1909 | ||
1865 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 1910 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
1866 | snd_dma_pci_data(chip->pci), 64*1024, 64*1024); | 1911 | snd_dma_pci_data(chip->pci), |
1912 | 64*1024, 64*1024); | ||
1913 | |||
1914 | err = snd_pcm_new(chip->card, "AZF3328 I2S OUT", AZF_PCMDEV_I2S_OUT, | ||
1915 | 1, 0, &pcm); | ||
1916 | if (err < 0) | ||
1917 | return err; | ||
1918 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | ||
1919 | &snd_azf3328_i2s_out_ops); | ||
1920 | |||
1921 | pcm->private_data = chip; | ||
1922 | pcm->info_flags = 0; | ||
1923 | strcpy(pcm->name, chip->card->shortname); | ||
1924 | chip->pcm[AZF_CODEC_I2S_OUT] = pcm; | ||
1925 | |||
1926 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
1927 | snd_dma_pci_data(chip->pci), | ||
1928 | 64*1024, 64*1024); | ||
1867 | 1929 | ||
1868 | snd_azf3328_dbgcallleave(); | 1930 | snd_azf3328_dbgcallleave(); |
1869 | return 0; | 1931 | return 0; |
@@ -1902,7 +1964,7 @@ snd_azf3328_timer_start(struct snd_timer *timer) | |||
1902 | snd_azf3328_dbgtimer("setting timer countdown value %d, add COUNTDOWN|IRQ\n", delay); | 1964 | snd_azf3328_dbgtimer("setting timer countdown value %d, add COUNTDOWN|IRQ\n", delay); |
1903 | delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE; | 1965 | delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE; |
1904 | spin_lock_irqsave(&chip->reg_lock, flags); | 1966 | spin_lock_irqsave(&chip->reg_lock, flags); |
1905 | snd_azf3328_codec_outl(chip, IDX_IO_TIMER_VALUE, delay); | 1967 | snd_azf3328_ctrl_outl(chip, IDX_IO_TIMER_VALUE, delay); |
1906 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1968 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1907 | snd_azf3328_dbgcallleave(); | 1969 | snd_azf3328_dbgcallleave(); |
1908 | return 0; | 1970 | return 0; |
@@ -1919,7 +1981,7 @@ snd_azf3328_timer_stop(struct snd_timer *timer) | |||
1919 | spin_lock_irqsave(&chip->reg_lock, flags); | 1981 | spin_lock_irqsave(&chip->reg_lock, flags); |
1920 | /* disable timer countdown and interrupt */ | 1982 | /* disable timer countdown and interrupt */ |
1921 | /* FIXME: should we write TIMER_IRQ_ACK here? */ | 1983 | /* FIXME: should we write TIMER_IRQ_ACK here? */ |
1922 | snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0); | 1984 | snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0); |
1923 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1985 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1924 | snd_azf3328_dbgcallleave(); | 1986 | snd_azf3328_dbgcallleave(); |
1925 | return 0; | 1987 | return 0; |
@@ -2035,7 +2097,7 @@ snd_azf3328_test_bit(unsigned unsigned reg, int bit) | |||
2035 | 2097 | ||
2036 | outb(val, reg); | 2098 | outb(val, reg); |
2037 | 2099 | ||
2038 | printk(KERN_ERR "reg %04x bit %d: %02x %02x %02x\n", | 2100 | printk(KERN_DEBUG "reg %04x bit %d: %02x %02x %02x\n", |
2039 | reg, bit, val, valoff, valon | 2101 | reg, bit, val, valoff, valon |
2040 | ); | 2102 | ); |
2041 | } | 2103 | } |
@@ -2048,9 +2110,9 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) | |||
2048 | u16 tmp; | 2110 | u16 tmp; |
2049 | 2111 | ||
2050 | snd_azf3328_dbgmisc( | 2112 | snd_azf3328_dbgmisc( |
2051 | "codec_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, " | 2113 | "ctrl_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, " |
2052 | "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n", | 2114 | "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n", |
2053 | chip->codec_io, chip->game_io, chip->mpu_io, | 2115 | chip->ctrl_io, chip->game_io, chip->mpu_io, |
2054 | chip->opl3_io, chip->mixer_io, chip->irq | 2116 | chip->opl3_io, chip->mixer_io, chip->irq |
2055 | ); | 2117 | ); |
2056 | 2118 | ||
@@ -2083,9 +2145,9 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) | |||
2083 | inb(0x38c + tmp) | 2145 | inb(0x38c + tmp) |
2084 | ); | 2146 | ); |
2085 | 2147 | ||
2086 | for (tmp = 0; tmp < AZF_IO_SIZE_CODEC; tmp += 2) | 2148 | for (tmp = 0; tmp < AZF_IO_SIZE_CTRL; tmp += 2) |
2087 | snd_azf3328_dbgmisc("codec 0x%02x: 0x%04x\n", | 2149 | snd_azf3328_dbgmisc("ctrl 0x%02x: 0x%04x\n", |
2088 | tmp, snd_azf3328_codec_inw(chip, tmp) | 2150 | tmp, snd_azf3328_ctrl_inw(chip, tmp) |
2089 | ); | 2151 | ); |
2090 | 2152 | ||
2091 | for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2) | 2153 | for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2) |
@@ -2106,7 +2168,8 @@ snd_azf3328_create(struct snd_card *card, | |||
2106 | static struct snd_device_ops ops = { | 2168 | static struct snd_device_ops ops = { |
2107 | .dev_free = snd_azf3328_dev_free, | 2169 | .dev_free = snd_azf3328_dev_free, |
2108 | }; | 2170 | }; |
2109 | u16 tmp; | 2171 | u8 dma_init; |
2172 | enum snd_azf3328_codec_type codec_type; | ||
2110 | 2173 | ||
2111 | *rchip = NULL; | 2174 | *rchip = NULL; |
2112 | 2175 | ||
@@ -2138,14 +2201,21 @@ snd_azf3328_create(struct snd_card *card, | |||
2138 | if (err < 0) | 2201 | if (err < 0) |
2139 | goto out_err; | 2202 | goto out_err; |
2140 | 2203 | ||
2141 | chip->codec_io = pci_resource_start(pci, 0); | 2204 | chip->ctrl_io = pci_resource_start(pci, 0); |
2142 | chip->game_io = pci_resource_start(pci, 1); | 2205 | chip->game_io = pci_resource_start(pci, 1); |
2143 | chip->mpu_io = pci_resource_start(pci, 2); | 2206 | chip->mpu_io = pci_resource_start(pci, 2); |
2144 | chip->opl3_io = pci_resource_start(pci, 3); | 2207 | chip->opl3_io = pci_resource_start(pci, 3); |
2145 | chip->mixer_io = pci_resource_start(pci, 4); | 2208 | chip->mixer_io = pci_resource_start(pci, 4); |
2146 | 2209 | ||
2147 | chip->audio_stream[AZF_PLAYBACK].portbase = chip->codec_io + 0x00; | 2210 | chip->codecs[AZF_CODEC_PLAYBACK].io_base = |
2148 | chip->audio_stream[AZF_CAPTURE].portbase = chip->codec_io + 0x20; | 2211 | chip->ctrl_io + AZF_IO_OFFS_CODEC_PLAYBACK; |
2212 | chip->codecs[AZF_CODEC_PLAYBACK].name = "PLAYBACK"; | ||
2213 | chip->codecs[AZF_CODEC_CAPTURE].io_base = | ||
2214 | chip->ctrl_io + AZF_IO_OFFS_CODEC_CAPTURE; | ||
2215 | chip->codecs[AZF_CODEC_CAPTURE].name = "CAPTURE"; | ||
2216 | chip->codecs[AZF_CODEC_I2S_OUT].io_base = | ||
2217 | chip->ctrl_io + AZF_IO_OFFS_CODEC_I2S_OUT; | ||
2218 | chip->codecs[AZF_CODEC_I2S_OUT].name = "I2S_OUT"; | ||
2149 | 2219 | ||
2150 | if (request_irq(pci->irq, snd_azf3328_interrupt, | 2220 | if (request_irq(pci->irq, snd_azf3328_interrupt, |
2151 | IRQF_SHARED, card->shortname, chip)) { | 2221 | IRQF_SHARED, card->shortname, chip)) { |
@@ -2168,20 +2238,25 @@ snd_azf3328_create(struct snd_card *card, | |||
2168 | if (err < 0) | 2238 | if (err < 0) |
2169 | goto out_err; | 2239 | goto out_err; |
2170 | 2240 | ||
2171 | /* shutdown codecs to save power */ | 2241 | /* standard codec init stuff */ |
2172 | /* have snd_azf3328_codec_activity() act properly */ | 2242 | /* default DMA init value */ |
2173 | chip->audio_stream[AZF_PLAYBACK].running = 1; | 2243 | dma_init = DMA_RUN_SOMETHING2|DMA_EPILOGUE_SOMETHING|DMA_SOMETHING_ELSE; |
2174 | snd_azf3328_codec_activity(chip, AZF_PLAYBACK, 0); | ||
2175 | 2244 | ||
2176 | /* standard chip init stuff */ | 2245 | for (codec_type = AZF_CODEC_PLAYBACK; |
2177 | /* default IRQ init value */ | 2246 | codec_type <= AZF_CODEC_I2S_OUT; ++codec_type) { |
2178 | tmp = DMA_PLAY_SOMETHING2|DMA_EPILOGUE_SOMETHING|DMA_SOMETHING_ELSE; | 2247 | struct snd_azf3328_codec_data *codec = |
2248 | &chip->codecs[codec_type]; | ||
2179 | 2249 | ||
2180 | spin_lock_irq(&chip->reg_lock); | 2250 | /* shutdown codecs to save power */ |
2181 | snd_azf3328_codec_outb(chip, IDX_IO_PLAY_FLAGS, tmp); | 2251 | /* have ...ctrl_codec_activity() act properly */ |
2182 | snd_azf3328_codec_outb(chip, IDX_IO_REC_FLAGS, tmp); | 2252 | codec->running = 1; |
2183 | snd_azf3328_codec_outb(chip, IDX_IO_SOMETHING_FLAGS, tmp); | 2253 | snd_azf3328_ctrl_codec_activity(chip, codec_type, 0); |
2184 | spin_unlock_irq(&chip->reg_lock); | 2254 | |
2255 | spin_lock_irq(&chip->reg_lock); | ||
2256 | snd_azf3328_codec_outb(codec, IDX_IO_CODEC_DMA_FLAGS, | ||
2257 | dma_init); | ||
2258 | spin_unlock_irq(&chip->reg_lock); | ||
2259 | } | ||
2185 | 2260 | ||
2186 | snd_card_set_dev(card, &pci->dev); | 2261 | snd_card_set_dev(card, &pci->dev); |
2187 | 2262 | ||
@@ -2229,8 +2304,11 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2229 | 2304 | ||
2230 | card->private_data = chip; | 2305 | card->private_data = chip; |
2231 | 2306 | ||
2307 | /* chose to use MPU401_HW_AZT2320 ID instead of MPU401_HW_MPU401, | ||
2308 | since our hardware ought to be similar, thus use same ID. */ | ||
2232 | err = snd_mpu401_uart_new( | 2309 | err = snd_mpu401_uart_new( |
2233 | card, 0, MPU401_HW_MPU401, chip->mpu_io, MPU401_INFO_INTEGRATED, | 2310 | card, 0, |
2311 | MPU401_HW_AZT2320, chip->mpu_io, MPU401_INFO_INTEGRATED, | ||
2234 | pci->irq, 0, &chip->rmidi | 2312 | pci->irq, 0, &chip->rmidi |
2235 | ); | 2313 | ); |
2236 | if (err < 0) { | 2314 | if (err < 0) { |
@@ -2244,7 +2322,7 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2244 | if (err < 0) | 2322 | if (err < 0) |
2245 | goto out_err; | 2323 | goto out_err; |
2246 | 2324 | ||
2247 | err = snd_azf3328_pcm(chip, 0); | 2325 | err = snd_azf3328_pcm(chip); |
2248 | if (err < 0) | 2326 | if (err < 0) |
2249 | goto out_err; | 2327 | goto out_err; |
2250 | 2328 | ||
@@ -2266,14 +2344,14 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2266 | opl3->private_data = chip; | 2344 | opl3->private_data = chip; |
2267 | 2345 | ||
2268 | sprintf(card->longname, "%s at 0x%lx, irq %i", | 2346 | sprintf(card->longname, "%s at 0x%lx, irq %i", |
2269 | card->shortname, chip->codec_io, chip->irq); | 2347 | card->shortname, chip->ctrl_io, chip->irq); |
2270 | 2348 | ||
2271 | err = snd_card_register(card); | 2349 | err = snd_card_register(card); |
2272 | if (err < 0) | 2350 | if (err < 0) |
2273 | goto out_err; | 2351 | goto out_err; |
2274 | 2352 | ||
2275 | #ifdef MODULE | 2353 | #ifdef MODULE |
2276 | printk( | 2354 | printk(KERN_INFO |
2277 | "azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n" | 2355 | "azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n" |
2278 | "azt3328: Hardware was completely undocumented, unfortunately.\n" | 2356 | "azt3328: Hardware was completely undocumented, unfortunately.\n" |
2279 | "azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" | 2357 | "azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" |
@@ -2308,36 +2386,52 @@ snd_azf3328_remove(struct pci_dev *pci) | |||
2308 | } | 2386 | } |
2309 | 2387 | ||
2310 | #ifdef CONFIG_PM | 2388 | #ifdef CONFIG_PM |
2389 | static inline void | ||
2390 | snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs) | ||
2391 | { | ||
2392 | unsigned reg; | ||
2393 | |||
2394 | for (reg = 0; reg < count; ++reg) { | ||
2395 | *saved_regs = inl(io_addr); | ||
2396 | snd_azf3328_dbgpm("suspend: io 0x%04lx: 0x%08x\n", | ||
2397 | io_addr, *saved_regs); | ||
2398 | ++saved_regs; | ||
2399 | io_addr += sizeof(*saved_regs); | ||
2400 | } | ||
2401 | } | ||
2402 | |||
2311 | static int | 2403 | static int |
2312 | snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) | 2404 | snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) |
2313 | { | 2405 | { |
2314 | struct snd_card *card = pci_get_drvdata(pci); | 2406 | struct snd_card *card = pci_get_drvdata(pci); |
2315 | struct snd_azf3328 *chip = card->private_data; | 2407 | struct snd_azf3328 *chip = card->private_data; |
2316 | unsigned reg; | 2408 | u16 *saved_regs_ctrl_u16; |
2317 | 2409 | ||
2318 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | 2410 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
2319 | 2411 | ||
2320 | snd_pcm_suspend_all(chip->pcm); | 2412 | snd_pcm_suspend_all(chip->pcm[AZF_CODEC_PLAYBACK]); |
2413 | snd_pcm_suspend_all(chip->pcm[AZF_CODEC_I2S_OUT]); | ||
2321 | 2414 | ||
2322 | for (reg = 0; reg < AZF_IO_SIZE_MIXER_PM / 2; ++reg) | 2415 | snd_azf3328_suspend_regs(chip->mixer_io, |
2323 | chip->saved_regs_mixer[reg] = inw(chip->mixer_io + reg * 2); | 2416 | ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer); |
2324 | 2417 | ||
2325 | /* make sure to disable master volume etc. to prevent looping sound */ | 2418 | /* make sure to disable master volume etc. to prevent looping sound */ |
2326 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_PLAY_MASTER, 1); | 2419 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_PLAY_MASTER, 1); |
2327 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); | 2420 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); |
2328 | 2421 | ||
2329 | for (reg = 0; reg < AZF_IO_SIZE_CODEC_PM / 2; ++reg) | 2422 | snd_azf3328_suspend_regs(chip->ctrl_io, |
2330 | chip->saved_regs_codec[reg] = inw(chip->codec_io + reg * 2); | 2423 | ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl); |
2331 | 2424 | ||
2332 | /* manually store the one currently relevant write-only reg, too */ | 2425 | /* manually store the one currently relevant write-only reg, too */ |
2333 | chip->saved_regs_codec[IDX_IO_6AH / 2] = chip->shadow_reg_codec_6AH; | 2426 | saved_regs_ctrl_u16 = (u16 *)chip->saved_regs_ctrl; |
2427 | saved_regs_ctrl_u16[IDX_IO_6AH / 2] = chip->shadow_reg_ctrl_6AH; | ||
2334 | 2428 | ||
2335 | for (reg = 0; reg < AZF_IO_SIZE_GAME_PM / 2; ++reg) | 2429 | snd_azf3328_suspend_regs(chip->game_io, |
2336 | chip->saved_regs_game[reg] = inw(chip->game_io + reg * 2); | 2430 | ARRAY_SIZE(chip->saved_regs_game), chip->saved_regs_game); |
2337 | for (reg = 0; reg < AZF_IO_SIZE_MPU_PM / 2; ++reg) | 2431 | snd_azf3328_suspend_regs(chip->mpu_io, |
2338 | chip->saved_regs_mpu[reg] = inw(chip->mpu_io + reg * 2); | 2432 | ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu); |
2339 | for (reg = 0; reg < AZF_IO_SIZE_OPL3_PM / 2; ++reg) | 2433 | snd_azf3328_suspend_regs(chip->opl3_io, |
2340 | chip->saved_regs_opl3[reg] = inw(chip->opl3_io + reg * 2); | 2434 | ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3); |
2341 | 2435 | ||
2342 | pci_disable_device(pci); | 2436 | pci_disable_device(pci); |
2343 | pci_save_state(pci); | 2437 | pci_save_state(pci); |
@@ -2345,12 +2439,28 @@ snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) | |||
2345 | return 0; | 2439 | return 0; |
2346 | } | 2440 | } |
2347 | 2441 | ||
2442 | static inline void | ||
2443 | snd_azf3328_resume_regs(const u32 *saved_regs, | ||
2444 | unsigned long io_addr, | ||
2445 | unsigned count | ||
2446 | ) | ||
2447 | { | ||
2448 | unsigned reg; | ||
2449 | |||
2450 | for (reg = 0; reg < count; ++reg) { | ||
2451 | outl(*saved_regs, io_addr); | ||
2452 | snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n", | ||
2453 | io_addr, *saved_regs, inl(io_addr)); | ||
2454 | ++saved_regs; | ||
2455 | io_addr += sizeof(*saved_regs); | ||
2456 | } | ||
2457 | } | ||
2458 | |||
2348 | static int | 2459 | static int |
2349 | snd_azf3328_resume(struct pci_dev *pci) | 2460 | snd_azf3328_resume(struct pci_dev *pci) |
2350 | { | 2461 | { |
2351 | struct snd_card *card = pci_get_drvdata(pci); | 2462 | struct snd_card *card = pci_get_drvdata(pci); |
2352 | struct snd_azf3328 *chip = card->private_data; | 2463 | const struct snd_azf3328 *chip = card->private_data; |
2353 | unsigned reg; | ||
2354 | 2464 | ||
2355 | pci_set_power_state(pci, PCI_D0); | 2465 | pci_set_power_state(pci, PCI_D0); |
2356 | pci_restore_state(pci); | 2466 | pci_restore_state(pci); |
@@ -2362,16 +2472,24 @@ snd_azf3328_resume(struct pci_dev *pci) | |||
2362 | } | 2472 | } |
2363 | pci_set_master(pci); | 2473 | pci_set_master(pci); |
2364 | 2474 | ||
2365 | for (reg = 0; reg < AZF_IO_SIZE_GAME_PM / 2; ++reg) | 2475 | snd_azf3328_resume_regs(chip->saved_regs_game, chip->game_io, |
2366 | outw(chip->saved_regs_game[reg], chip->game_io + reg * 2); | 2476 | ARRAY_SIZE(chip->saved_regs_game)); |
2367 | for (reg = 0; reg < AZF_IO_SIZE_MPU_PM / 2; ++reg) | 2477 | snd_azf3328_resume_regs(chip->saved_regs_mpu, chip->mpu_io, |
2368 | outw(chip->saved_regs_mpu[reg], chip->mpu_io + reg * 2); | 2478 | ARRAY_SIZE(chip->saved_regs_mpu)); |
2369 | for (reg = 0; reg < AZF_IO_SIZE_OPL3_PM / 2; ++reg) | 2479 | snd_azf3328_resume_regs(chip->saved_regs_opl3, chip->opl3_io, |
2370 | outw(chip->saved_regs_opl3[reg], chip->opl3_io + reg * 2); | 2480 | ARRAY_SIZE(chip->saved_regs_opl3)); |
2371 | for (reg = 0; reg < AZF_IO_SIZE_MIXER_PM / 2; ++reg) | 2481 | |
2372 | outw(chip->saved_regs_mixer[reg], chip->mixer_io + reg * 2); | 2482 | snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io, |
2373 | for (reg = 0; reg < AZF_IO_SIZE_CODEC_PM / 2; ++reg) | 2483 | ARRAY_SIZE(chip->saved_regs_mixer)); |
2374 | outw(chip->saved_regs_codec[reg], chip->codec_io + reg * 2); | 2484 | |
2485 | /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02) | ||
2486 | and IDX_MIXER_RESET (offset 0x00) get touched at the same time, | ||
2487 | resulting in a mixer reset condition persisting until _after_ | ||
2488 | master vol was restored. Thus master vol needs an extra restore. */ | ||
2489 | outw(((u16 *)chip->saved_regs_mixer)[1], chip->mixer_io + 2); | ||
2490 | |||
2491 | snd_azf3328_resume_regs(chip->saved_regs_ctrl, chip->ctrl_io, | ||
2492 | ARRAY_SIZE(chip->saved_regs_ctrl)); | ||
2375 | 2493 | ||
2376 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | 2494 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
2377 | return 0; | 2495 | return 0; |
diff --git a/sound/pci/azt3328.h b/sound/pci/azt3328.h index 974e05122f00..6f46b97650cc 100644 --- a/sound/pci/azt3328.h +++ b/sound/pci/azt3328.h | |||
@@ -6,50 +6,59 @@ | |||
6 | 6 | ||
7 | /*** main I/O area port indices ***/ | 7 | /*** main I/O area port indices ***/ |
8 | /* (only 0x70 of 0x80 bytes saved/restored by Windows driver) */ | 8 | /* (only 0x70 of 0x80 bytes saved/restored by Windows driver) */ |
9 | #define AZF_IO_SIZE_CODEC 0x80 | 9 | #define AZF_IO_SIZE_CTRL 0x80 |
10 | #define AZF_IO_SIZE_CODEC_PM 0x70 | 10 | #define AZF_IO_SIZE_CTRL_PM 0x70 |
11 | 11 | ||
12 | /* the driver initialisation suggests a layout of 4 main areas: | 12 | /* the driver initialisation suggests a layout of 4 areas |
13 | * from 0x00 (playback), from 0x20 (recording) and from 0x40 (maybe MPU401??). | 13 | * within the main card control I/O: |
14 | * from 0x00 (playback codec), from 0x20 (recording codec) | ||
15 | * and from 0x40 (most certainly I2S out codec). | ||
14 | * And another area from 0x60 to 0x6f (DirectX timer, IRQ management, | 16 | * And another area from 0x60 to 0x6f (DirectX timer, IRQ management, |
15 | * power management etc.???). */ | 17 | * power management etc.???). */ |
16 | 18 | ||
17 | /** playback area **/ | 19 | #define AZF_IO_OFFS_CODEC_PLAYBACK 0x00 |
18 | #define IDX_IO_PLAY_FLAGS 0x00 /* PU:0x0000 */ | 20 | #define AZF_IO_OFFS_CODEC_CAPTURE 0x20 |
21 | #define AZF_IO_OFFS_CODEC_I2S_OUT 0x40 | ||
22 | |||
23 | #define IDX_IO_CODEC_DMA_FLAGS 0x00 /* PU:0x0000 */ | ||
19 | /* able to reactivate output after output muting due to 8/16bit | 24 | /* able to reactivate output after output muting due to 8/16bit |
20 | * output change, just like 0x0002. | 25 | * output change, just like 0x0002. |
21 | * 0x0001 is the only bit that's able to start the DMA counter */ | 26 | * 0x0001 is the only bit that's able to start the DMA counter */ |
22 | #define DMA_RESUME 0x0001 /* paused if cleared ? */ | 27 | #define DMA_RESUME 0x0001 /* paused if cleared? */ |
23 | /* 0x0002 *temporarily* set during DMA stopping. hmm | 28 | /* 0x0002 *temporarily* set during DMA stopping. hmm |
24 | * both 0x0002 and 0x0004 set in playback setup. */ | 29 | * both 0x0002 and 0x0004 set in playback setup. */ |
25 | /* able to reactivate output after output muting due to 8/16bit | 30 | /* able to reactivate output after output muting due to 8/16bit |
26 | * output change, just like 0x0001. */ | 31 | * output change, just like 0x0001. */ |
27 | #define DMA_PLAY_SOMETHING1 0x0002 /* \ alternated (toggled) */ | 32 | #define DMA_RUN_SOMETHING1 0x0002 /* \ alternated (toggled) */ |
28 | /* 0x0004: NOT able to reactivate output */ | 33 | /* 0x0004: NOT able to reactivate output */ |
29 | #define DMA_PLAY_SOMETHING2 0x0004 /* / bits */ | 34 | #define DMA_RUN_SOMETHING2 0x0004 /* / bits */ |
30 | #define SOMETHING_ALMOST_ALWAYS_SET 0x0008 /* ???; can be modified */ | 35 | #define SOMETHING_ALMOST_ALWAYS_SET 0x0008 /* ???; can be modified */ |
31 | #define DMA_EPILOGUE_SOMETHING 0x0010 | 36 | #define DMA_EPILOGUE_SOMETHING 0x0010 |
32 | #define DMA_SOMETHING_ELSE 0x0020 /* ??? */ | 37 | #define DMA_SOMETHING_ELSE 0x0020 /* ??? */ |
33 | #define SOMETHING_UNMODIFIABLE 0xffc0 /* unused ? not modifiable */ | 38 | #define SOMETHING_UNMODIFIABLE 0xffc0 /* unused? not modifiable */ |
34 | #define IDX_IO_PLAY_IRQTYPE 0x02 /* PU:0x0001 */ | 39 | #define IDX_IO_CODEC_IRQTYPE 0x02 /* PU:0x0001 */ |
35 | /* write back to flags in case flags are set, in order to ACK IRQ in handler | 40 | /* write back to flags in case flags are set, in order to ACK IRQ in handler |
36 | * (bit 1 of port 0x64 indicates interrupt for one of these three types) | 41 | * (bit 1 of port 0x64 indicates interrupt for one of these three types) |
37 | * sometimes in this case it just writes 0xffff to globally ACK all IRQs | 42 | * sometimes in this case it just writes 0xffff to globally ACK all IRQs |
38 | * settings written are not reflected when reading back, though. | 43 | * settings written are not reflected when reading back, though. |
39 | * seems to be IRQ, too (frequently used: port |= 0x07 !), but who knows ? */ | 44 | * seems to be IRQ, too (frequently used: port |= 0x07 !), but who knows? */ |
40 | #define IRQ_PLAY_SOMETHING 0x0001 /* something & ACK */ | 45 | #define IRQ_SOMETHING 0x0001 /* something & ACK */ |
41 | #define IRQ_FINISHED_PLAYBUF_1 0x0002 /* 1st dmabuf finished & ACK */ | 46 | #define IRQ_FINISHED_DMABUF_1 0x0002 /* 1st dmabuf finished & ACK */ |
42 | #define IRQ_FINISHED_PLAYBUF_2 0x0004 /* 2nd dmabuf finished & ACK */ | 47 | #define IRQ_FINISHED_DMABUF_2 0x0004 /* 2nd dmabuf finished & ACK */ |
43 | #define IRQMASK_SOME_STATUS_1 0x0008 /* \ related bits */ | 48 | #define IRQMASK_SOME_STATUS_1 0x0008 /* \ related bits */ |
44 | #define IRQMASK_SOME_STATUS_2 0x0010 /* / (checked together in loop) */ | 49 | #define IRQMASK_SOME_STATUS_2 0x0010 /* / (checked together in loop) */ |
45 | #define IRQMASK_UNMODIFIABLE 0xffe0 /* unused ? not modifiable */ | 50 | #define IRQMASK_UNMODIFIABLE 0xffe0 /* unused? not modifiable */ |
46 | #define IDX_IO_PLAY_DMA_START_1 0x04 /* start address of 1st DMA play area, PU:0x00000000 */ | 51 | /* start address of 1st DMA transfer area, PU:0x00000000 */ |
47 | #define IDX_IO_PLAY_DMA_START_2 0x08 /* start address of 2nd DMA play area, PU:0x00000000 */ | 52 | #define IDX_IO_CODEC_DMA_START_1 0x04 |
48 | #define IDX_IO_PLAY_DMA_LEN_1 0x0c /* length of 1st DMA play area, PU:0x0000 */ | 53 | /* start address of 2nd DMA transfer area, PU:0x00000000 */ |
49 | #define IDX_IO_PLAY_DMA_LEN_2 0x0e /* length of 2nd DMA play area, PU:0x0000 */ | 54 | #define IDX_IO_CODEC_DMA_START_2 0x08 |
50 | #define IDX_IO_PLAY_DMA_CURRPOS 0x10 /* current DMA position, PU:0x00000000 */ | 55 | /* both lengths of DMA transfer areas, PU:0x00000000 |
51 | #define IDX_IO_PLAY_DMA_CURROFS 0x14 /* offset within current DMA play area, PU:0x0000 */ | 56 | length1: offset 0x0c, length2: offset 0x0e */ |
52 | #define IDX_IO_PLAY_SOUNDFORMAT 0x16 /* PU:0x0010 */ | 57 | #define IDX_IO_CODEC_DMA_LENGTHS 0x0c |
58 | #define IDX_IO_CODEC_DMA_CURRPOS 0x10 /* current DMA position, PU:0x00000000 */ | ||
59 | /* offset within current DMA transfer area, PU:0x0000 */ | ||
60 | #define IDX_IO_CODEC_DMA_CURROFS 0x14 | ||
61 | #define IDX_IO_CODEC_SOUNDFORMAT 0x16 /* PU:0x0010 */ | ||
53 | /* all unspecified bits can't be modified */ | 62 | /* all unspecified bits can't be modified */ |
54 | #define SOUNDFORMAT_FREQUENCY_MASK 0x000f | 63 | #define SOUNDFORMAT_FREQUENCY_MASK 0x000f |
55 | #define SOUNDFORMAT_XTAL1 0x00 | 64 | #define SOUNDFORMAT_XTAL1 0x00 |
@@ -76,6 +85,7 @@ | |||
76 | #define SOUNDFORMAT_FLAG_16BIT 0x0010 | 85 | #define SOUNDFORMAT_FLAG_16BIT 0x0010 |
77 | #define SOUNDFORMAT_FLAG_2CHANNELS 0x0020 | 86 | #define SOUNDFORMAT_FLAG_2CHANNELS 0x0020 |
78 | 87 | ||
88 | |||
79 | /* define frequency helpers, for maximum value safety */ | 89 | /* define frequency helpers, for maximum value safety */ |
80 | enum azf_freq_t { | 90 | enum azf_freq_t { |
81 | #define AZF_FREQ(rate) AZF_FREQ_##rate = rate | 91 | #define AZF_FREQ(rate) AZF_FREQ_##rate = rate |
@@ -96,29 +106,6 @@ enum azf_freq_t { | |||
96 | #undef AZF_FREQ | 106 | #undef AZF_FREQ |
97 | }; | 107 | }; |
98 | 108 | ||
99 | /** recording area (see also: playback bit flag definitions) **/ | ||
100 | #define IDX_IO_REC_FLAGS 0x20 /* ??, PU:0x0000 */ | ||
101 | #define IDX_IO_REC_IRQTYPE 0x22 /* ??, PU:0x0000 */ | ||
102 | #define IRQ_REC_SOMETHING 0x0001 /* something & ACK */ | ||
103 | #define IRQ_FINISHED_RECBUF_1 0x0002 /* 1st dmabuf finished & ACK */ | ||
104 | #define IRQ_FINISHED_RECBUF_2 0x0004 /* 2nd dmabuf finished & ACK */ | ||
105 | /* hmm, maybe these are just the corresponding *recording* flags ? | ||
106 | * but OTOH they are most likely at port 0x22 instead */ | ||
107 | #define IRQMASK_SOME_STATUS_1 0x0008 /* \ related bits */ | ||
108 | #define IRQMASK_SOME_STATUS_2 0x0010 /* / (checked together in loop) */ | ||
109 | #define IDX_IO_REC_DMA_START_1 0x24 /* PU:0x00000000 */ | ||
110 | #define IDX_IO_REC_DMA_START_2 0x28 /* PU:0x00000000 */ | ||
111 | #define IDX_IO_REC_DMA_LEN_1 0x2c /* PU:0x0000 */ | ||
112 | #define IDX_IO_REC_DMA_LEN_2 0x2e /* PU:0x0000 */ | ||
113 | #define IDX_IO_REC_DMA_CURRPOS 0x30 /* PU:0x00000000 */ | ||
114 | #define IDX_IO_REC_DMA_CURROFS 0x34 /* PU:0x00000000 */ | ||
115 | #define IDX_IO_REC_SOUNDFORMAT 0x36 /* PU:0x0000 */ | ||
116 | |||
117 | /** hmm, what is this I/O area for? MPU401?? or external DAC via I2S?? (after playback, recording, ???, timer) **/ | ||
118 | #define IDX_IO_SOMETHING_FLAGS 0x40 /* gets set to 0x34 just like port 0x0 and 0x20 on card init, PU:0x0000 */ | ||
119 | /* general */ | ||
120 | #define IDX_IO_42H 0x42 /* PU:0x0001 */ | ||
121 | |||
122 | /** DirectX timer, main interrupt area (FIXME: and something else?) **/ | 109 | /** DirectX timer, main interrupt area (FIXME: and something else?) **/ |
123 | #define IDX_IO_TIMER_VALUE 0x60 /* found this timer area by pure luck :-) */ | 110 | #define IDX_IO_TIMER_VALUE 0x60 /* found this timer area by pure luck :-) */ |
124 | /* timer countdown value; triggers IRQ when timer is finished */ | 111 | /* timer countdown value; triggers IRQ when timer is finished */ |
@@ -133,17 +120,19 @@ enum azf_freq_t { | |||
133 | #define IDX_IO_IRQSTATUS 0x64 | 120 | #define IDX_IO_IRQSTATUS 0x64 |
134 | /* some IRQ bit in here might also be used to signal a power-management timer | 121 | /* some IRQ bit in here might also be used to signal a power-management timer |
135 | * timeout, to request shutdown of the chip (e.g. AD1815JS has such a thing). | 122 | * timeout, to request shutdown of the chip (e.g. AD1815JS has such a thing). |
136 | * Some OPL3 hardware (e.g. in LM4560) has some special timer hardware which | 123 | * OPL3 hardware contains several timers which confusingly in most cases |
137 | * can trigger an OPL3 timer IRQ, so maybe there's such a thing as well... */ | 124 | * are NOT routed to an IRQ, but some designs (e.g. LM4560) DO support that, |
125 | * so I wouldn't be surprised at all to discover that AZF3328 | ||
126 | * supports that thing as well... */ | ||
138 | 127 | ||
139 | #define IRQ_PLAYBACK 0x0001 | 128 | #define IRQ_PLAYBACK 0x0001 |
140 | #define IRQ_RECORDING 0x0002 | 129 | #define IRQ_RECORDING 0x0002 |
141 | #define IRQ_UNKNOWN1 0x0004 /* most probably I2S port */ | 130 | #define IRQ_I2S_OUT 0x0004 /* this IS I2S, right!? (untested) */ |
142 | #define IRQ_GAMEPORT 0x0008 /* Interrupt of Digital(ly) Enhanced Game Port */ | 131 | #define IRQ_GAMEPORT 0x0008 /* Interrupt of Digital(ly) Enhanced Game Port */ |
143 | #define IRQ_MPU401 0x0010 | 132 | #define IRQ_MPU401 0x0010 |
144 | #define IRQ_TIMER 0x0020 /* DirectX timer */ | 133 | #define IRQ_TIMER 0x0020 /* DirectX timer */ |
145 | #define IRQ_UNKNOWN2 0x0040 /* probably unused, or possibly I2S port? */ | 134 | #define IRQ_UNKNOWN2 0x0040 /* probably unused, or possibly OPL3 timer? */ |
146 | #define IRQ_UNKNOWN3 0x0080 /* probably unused, or possibly I2S port? */ | 135 | #define IRQ_UNKNOWN3 0x0080 /* probably unused, or possibly OPL3 timer? */ |
147 | #define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ | 136 | #define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ |
148 | /* this is set to e.g. 0x3ff or 0x300, and writable; | 137 | /* this is set to e.g. 0x3ff or 0x300, and writable; |
149 | * maybe some buffer limit, but I couldn't find out more, PU:0x00ff: */ | 138 | * maybe some buffer limit, but I couldn't find out more, PU:0x00ff: */ |
@@ -206,7 +195,7 @@ enum azf_freq_t { | |||
206 | /*** Gameport area port indices ***/ | 195 | /*** Gameport area port indices ***/ |
207 | /* (only 0x06 of 0x08 bytes saved/restored by Windows driver) */ | 196 | /* (only 0x06 of 0x08 bytes saved/restored by Windows driver) */ |
208 | #define AZF_IO_SIZE_GAME 0x08 | 197 | #define AZF_IO_SIZE_GAME 0x08 |
209 | #define AZF_IO_SIZE_GAME_PM 0x06 | 198 | #define AZF_IO_SIZE_GAME_PM 0x06 |
210 | 199 | ||
211 | enum { | 200 | enum { |
212 | AZF_GAME_LEGACY_IO_PORT = 0x200 | 201 | AZF_GAME_LEGACY_IO_PORT = 0x200 |
@@ -272,6 +261,12 @@ enum { | |||
272 | * 11 --> 1/200: */ | 261 | * 11 --> 1/200: */ |
273 | #define GAME_HWCFG_ADC_COUNTER_FREQ_MASK 0x06 | 262 | #define GAME_HWCFG_ADC_COUNTER_FREQ_MASK 0x06 |
274 | 263 | ||
264 | /* FIXME: these values might be reversed... */ | ||
265 | #define GAME_HWCFG_ADC_COUNTER_FREQ_STD 0 | ||
266 | #define GAME_HWCFG_ADC_COUNTER_FREQ_1_2 1 | ||
267 | #define GAME_HWCFG_ADC_COUNTER_FREQ_1_20 2 | ||
268 | #define GAME_HWCFG_ADC_COUNTER_FREQ_1_200 3 | ||
269 | |||
275 | /* enable gameport legacy I/O address (0x200) | 270 | /* enable gameport legacy I/O address (0x200) |
276 | * I was unable to locate any configurability for a different address: */ | 271 | * I was unable to locate any configurability for a different address: */ |
277 | #define GAME_HWCFG_LEGACY_ADDRESS_ENABLE 0x08 | 272 | #define GAME_HWCFG_LEGACY_ADDRESS_ENABLE 0x08 |
@@ -281,6 +276,7 @@ enum { | |||
281 | #define AZF_IO_SIZE_MPU_PM 0x04 | 276 | #define AZF_IO_SIZE_MPU_PM 0x04 |
282 | 277 | ||
283 | /*** OPL3 synth ***/ | 278 | /*** OPL3 synth ***/ |
279 | /* (only 0x06 of 0x08 bytes saved/restored by Windows driver) */ | ||
284 | #define AZF_IO_SIZE_OPL3 0x08 | 280 | #define AZF_IO_SIZE_OPL3 0x08 |
285 | #define AZF_IO_SIZE_OPL3_PM 0x06 | 281 | #define AZF_IO_SIZE_OPL3_PM 0x06 |
286 | /* hmm, given that a standard OPL3 has 4 registers only, | 282 | /* hmm, given that a standard OPL3 has 4 registers only, |
@@ -340,4 +336,7 @@ enum { | |||
340 | #define SET_CHAN_LEFT 1 | 336 | #define SET_CHAN_LEFT 1 |
341 | #define SET_CHAN_RIGHT 2 | 337 | #define SET_CHAN_RIGHT 2 |
342 | 338 | ||
339 | /* helper macro to align I/O port ranges to 32bit I/O width */ | ||
340 | #define AZF_ALIGN(x) (((x) + 3) & (~3)) | ||
341 | |||
343 | #endif /* __SOUND_AZT3328_H */ | 342 | #endif /* __SOUND_AZT3328_H */ |
diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h index 4eb55aa33612..b5189495d58a 100644 --- a/sound/pci/cs46xx/cs46xx_lib.h +++ b/sound/pci/cs46xx/cs46xx_lib.h | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | #ifdef CONFIG_SND_CS46XX_NEW_DSP | 37 | #ifdef CONFIG_SND_CS46XX_NEW_DSP |
38 | #define CS46XX_MIN_PERIOD_SIZE 1 | 38 | #define CS46XX_MIN_PERIOD_SIZE 64 |
39 | #define CS46XX_MAX_PERIOD_SIZE 1024*1024 | 39 | #define CS46XX_MAX_PERIOD_SIZE 1024*1024 |
40 | #else | 40 | #else |
41 | #define CS46XX_MIN_PERIOD_SIZE 2048 | 41 | #define CS46XX_MIN_PERIOD_SIZE 2048 |
diff --git a/sound/pci/ctxfi/ct20k2reg.h b/sound/pci/ctxfi/ct20k2reg.h index 2d07986f57cc..e0394e3996e8 100644 --- a/sound/pci/ctxfi/ct20k2reg.h +++ b/sound/pci/ctxfi/ct20k2reg.h | |||
@@ -11,9 +11,12 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | /* Timer Registers */ | 13 | /* Timer Registers */ |
14 | #define TIMER_TIMR 0x1B7004 | 14 | #define WC 0x1b7000 |
15 | #define INTERRUPT_GIP 0x1B7010 | 15 | #define TIMR 0x1b7004 |
16 | #define INTERRUPT_GIE 0x1B7014 | 16 | # define TIMR_IE (1<<15) |
17 | # define TIMR_IP (1<<14) | ||
18 | #define GIP 0x1b7010 | ||
19 | #define GIE 0x1b7014 | ||
17 | 20 | ||
18 | /* I2C Registers */ | 21 | /* I2C Registers */ |
19 | #define I2C_IF_ADDRESS 0x1B9000 | 22 | #define I2C_IF_ADDRESS 0x1B9000 |
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c index a7f4a671f7b7..fee35cfc0c7f 100644 --- a/sound/pci/ctxfi/ctamixer.c +++ b/sound/pci/ctxfi/ctamixer.c | |||
@@ -63,7 +63,7 @@ static int amixer_set_input(struct amixer *amixer, struct rsc *rsc) | |||
63 | hw = amixer->rsc.hw; | 63 | hw = amixer->rsc.hw; |
64 | hw->amixer_set_mode(amixer->rsc.ctrl_blk, AMIXER_Y_IMMEDIATE); | 64 | hw->amixer_set_mode(amixer->rsc.ctrl_blk, AMIXER_Y_IMMEDIATE); |
65 | amixer->input = rsc; | 65 | amixer->input = rsc; |
66 | if (NULL == rsc) | 66 | if (!rsc) |
67 | hw->amixer_set_x(amixer->rsc.ctrl_blk, BLANK_SLOT); | 67 | hw->amixer_set_x(amixer->rsc.ctrl_blk, BLANK_SLOT); |
68 | else | 68 | else |
69 | hw->amixer_set_x(amixer->rsc.ctrl_blk, | 69 | hw->amixer_set_x(amixer->rsc.ctrl_blk, |
@@ -99,7 +99,7 @@ static int amixer_set_sum(struct amixer *amixer, struct sum *sum) | |||
99 | 99 | ||
100 | hw = amixer->rsc.hw; | 100 | hw = amixer->rsc.hw; |
101 | amixer->sum = sum; | 101 | amixer->sum = sum; |
102 | if (NULL == sum) { | 102 | if (!sum) { |
103 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 0); | 103 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 0); |
104 | } else { | 104 | } else { |
105 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 1); | 105 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 1); |
@@ -124,20 +124,20 @@ static int amixer_commit_write(struct amixer *amixer) | |||
124 | 124 | ||
125 | /* Program master and conjugate resources */ | 125 | /* Program master and conjugate resources */ |
126 | amixer->rsc.ops->master(&amixer->rsc); | 126 | amixer->rsc.ops->master(&amixer->rsc); |
127 | if (NULL != input) | 127 | if (input) |
128 | input->ops->master(input); | 128 | input->ops->master(input); |
129 | 129 | ||
130 | if (NULL != sum) | 130 | if (sum) |
131 | sum->rsc.ops->master(&sum->rsc); | 131 | sum->rsc.ops->master(&sum->rsc); |
132 | 132 | ||
133 | for (i = 0; i < amixer->rsc.msr; i++) { | 133 | for (i = 0; i < amixer->rsc.msr; i++) { |
134 | hw->amixer_set_dirty_all(amixer->rsc.ctrl_blk); | 134 | hw->amixer_set_dirty_all(amixer->rsc.ctrl_blk); |
135 | if (NULL != input) { | 135 | if (input) { |
136 | hw->amixer_set_x(amixer->rsc.ctrl_blk, | 136 | hw->amixer_set_x(amixer->rsc.ctrl_blk, |
137 | input->ops->output_slot(input)); | 137 | input->ops->output_slot(input)); |
138 | input->ops->next_conj(input); | 138 | input->ops->next_conj(input); |
139 | } | 139 | } |
140 | if (NULL != sum) { | 140 | if (sum) { |
141 | hw->amixer_set_sadr(amixer->rsc.ctrl_blk, | 141 | hw->amixer_set_sadr(amixer->rsc.ctrl_blk, |
142 | sum->rsc.ops->index(&sum->rsc)); | 142 | sum->rsc.ops->index(&sum->rsc)); |
143 | sum->rsc.ops->next_conj(&sum->rsc); | 143 | sum->rsc.ops->next_conj(&sum->rsc); |
@@ -147,10 +147,10 @@ static int amixer_commit_write(struct amixer *amixer) | |||
147 | amixer->rsc.ops->next_conj(&amixer->rsc); | 147 | amixer->rsc.ops->next_conj(&amixer->rsc); |
148 | } | 148 | } |
149 | amixer->rsc.ops->master(&amixer->rsc); | 149 | amixer->rsc.ops->master(&amixer->rsc); |
150 | if (NULL != input) | 150 | if (input) |
151 | input->ops->master(input); | 151 | input->ops->master(input); |
152 | 152 | ||
153 | if (NULL != sum) | 153 | if (sum) |
154 | sum->rsc.ops->master(&sum->rsc); | 154 | sum->rsc.ops->master(&sum->rsc); |
155 | 155 | ||
156 | return 0; | 156 | return 0; |
@@ -303,7 +303,7 @@ int amixer_mgr_create(void *hw, struct amixer_mgr **ramixer_mgr) | |||
303 | 303 | ||
304 | *ramixer_mgr = NULL; | 304 | *ramixer_mgr = NULL; |
305 | amixer_mgr = kzalloc(sizeof(*amixer_mgr), GFP_KERNEL); | 305 | amixer_mgr = kzalloc(sizeof(*amixer_mgr), GFP_KERNEL); |
306 | if (NULL == amixer_mgr) | 306 | if (!amixer_mgr) |
307 | return -ENOMEM; | 307 | return -ENOMEM; |
308 | 308 | ||
309 | err = rsc_mgr_init(&amixer_mgr->mgr, AMIXER, AMIXER_RESOURCE_NUM, hw); | 309 | err = rsc_mgr_init(&amixer_mgr->mgr, AMIXER, AMIXER_RESOURCE_NUM, hw); |
@@ -456,7 +456,7 @@ int sum_mgr_create(void *hw, struct sum_mgr **rsum_mgr) | |||
456 | 456 | ||
457 | *rsum_mgr = NULL; | 457 | *rsum_mgr = NULL; |
458 | sum_mgr = kzalloc(sizeof(*sum_mgr), GFP_KERNEL); | 458 | sum_mgr = kzalloc(sizeof(*sum_mgr), GFP_KERNEL); |
459 | if (NULL == sum_mgr) | 459 | if (!sum_mgr) |
460 | return -ENOMEM; | 460 | return -ENOMEM; |
461 | 461 | ||
462 | err = rsc_mgr_init(&sum_mgr->mgr, SUM, SUM_RESOURCE_NUM, hw); | 462 | err = rsc_mgr_init(&sum_mgr->mgr, SUM, SUM_RESOURCE_NUM, hw); |
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index a49c76647307..b1b3a644f738 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -136,7 +136,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
136 | struct snd_pcm_runtime *runtime; | 136 | struct snd_pcm_runtime *runtime; |
137 | struct ct_vm *vm; | 137 | struct ct_vm *vm; |
138 | 138 | ||
139 | if (NULL == apcm->substream) | 139 | if (!apcm->substream) |
140 | return 0; | 140 | return 0; |
141 | 141 | ||
142 | runtime = apcm->substream->runtime; | 142 | runtime = apcm->substream->runtime; |
@@ -144,7 +144,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
144 | 144 | ||
145 | apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); | 145 | apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); |
146 | 146 | ||
147 | if (NULL == apcm->vm_block) | 147 | if (!apcm->vm_block) |
148 | return -ENOENT; | 148 | return -ENOENT; |
149 | 149 | ||
150 | return 0; | 150 | return 0; |
@@ -154,7 +154,7 @@ static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
154 | { | 154 | { |
155 | struct ct_vm *vm; | 155 | struct ct_vm *vm; |
156 | 156 | ||
157 | if (NULL == apcm->vm_block) | 157 | if (!apcm->vm_block) |
158 | return; | 158 | return; |
159 | 159 | ||
160 | vm = atc->vm; | 160 | vm = atc->vm; |
@@ -231,16 +231,16 @@ atc_get_pitch(unsigned int input_rate, unsigned int output_rate) | |||
231 | 231 | ||
232 | static int select_rom(unsigned int pitch) | 232 | static int select_rom(unsigned int pitch) |
233 | { | 233 | { |
234 | if ((pitch > 0x00428f5c) && (pitch < 0x01b851ec)) { | 234 | if (pitch > 0x00428f5c && pitch < 0x01b851ec) { |
235 | /* 0.26 <= pitch <= 1.72 */ | 235 | /* 0.26 <= pitch <= 1.72 */ |
236 | return 1; | 236 | return 1; |
237 | } else if ((0x01d66666 == pitch) || (0x01d66667 == pitch)) { | 237 | } else if (pitch == 0x01d66666 || pitch == 0x01d66667) { |
238 | /* pitch == 1.8375 */ | 238 | /* pitch == 1.8375 */ |
239 | return 2; | 239 | return 2; |
240 | } else if (0x02000000 == pitch) { | 240 | } else if (pitch == 0x02000000) { |
241 | /* pitch == 2 */ | 241 | /* pitch == 2 */ |
242 | return 3; | 242 | return 3; |
243 | } else if ((pitch >= 0x0) && (pitch <= 0x08000000)) { | 243 | } else if (pitch >= 0x0 && pitch <= 0x08000000) { |
244 | /* 0 <= pitch <= 8 */ | 244 | /* 0 <= pitch <= 8 */ |
245 | return 0; | 245 | return 0; |
246 | } else { | 246 | } else { |
@@ -283,7 +283,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
283 | /* Get AMIXER resource */ | 283 | /* Get AMIXER resource */ |
284 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; | 284 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; |
285 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 285 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); |
286 | if (NULL == apcm->amixers) { | 286 | if (!apcm->amixers) { |
287 | err = -ENOMEM; | 287 | err = -ENOMEM; |
288 | goto error1; | 288 | goto error1; |
289 | } | 289 | } |
@@ -311,7 +311,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
311 | INIT_VOL, atc->pcm[i+device*2]); | 311 | INIT_VOL, atc->pcm[i+device*2]); |
312 | mutex_unlock(&atc->atc_mutex); | 312 | mutex_unlock(&atc->atc_mutex); |
313 | src = src->ops->next_interleave(src); | 313 | src = src->ops->next_interleave(src); |
314 | if (NULL == src) | 314 | if (!src) |
315 | src = apcm->src; | 315 | src = apcm->src; |
316 | } | 316 | } |
317 | 317 | ||
@@ -334,7 +334,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
334 | struct srcimp *srcimp; | 334 | struct srcimp *srcimp; |
335 | int i; | 335 | int i; |
336 | 336 | ||
337 | if (NULL != apcm->srcimps) { | 337 | if (apcm->srcimps) { |
338 | for (i = 0; i < apcm->n_srcimp; i++) { | 338 | for (i = 0; i < apcm->n_srcimp; i++) { |
339 | srcimp = apcm->srcimps[i]; | 339 | srcimp = apcm->srcimps[i]; |
340 | srcimp->ops->unmap(srcimp); | 340 | srcimp->ops->unmap(srcimp); |
@@ -345,7 +345,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
345 | apcm->srcimps = NULL; | 345 | apcm->srcimps = NULL; |
346 | } | 346 | } |
347 | 347 | ||
348 | if (NULL != apcm->srccs) { | 348 | if (apcm->srccs) { |
349 | for (i = 0; i < apcm->n_srcc; i++) { | 349 | for (i = 0; i < apcm->n_srcc; i++) { |
350 | src_mgr->put_src(src_mgr, apcm->srccs[i]); | 350 | src_mgr->put_src(src_mgr, apcm->srccs[i]); |
351 | apcm->srccs[i] = NULL; | 351 | apcm->srccs[i] = NULL; |
@@ -354,7 +354,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
354 | apcm->srccs = NULL; | 354 | apcm->srccs = NULL; |
355 | } | 355 | } |
356 | 356 | ||
357 | if (NULL != apcm->amixers) { | 357 | if (apcm->amixers) { |
358 | for (i = 0; i < apcm->n_amixer; i++) { | 358 | for (i = 0; i < apcm->n_amixer; i++) { |
359 | amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); | 359 | amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); |
360 | apcm->amixers[i] = NULL; | 360 | apcm->amixers[i] = NULL; |
@@ -363,17 +363,17 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
363 | apcm->amixers = NULL; | 363 | apcm->amixers = NULL; |
364 | } | 364 | } |
365 | 365 | ||
366 | if (NULL != apcm->mono) { | 366 | if (apcm->mono) { |
367 | sum_mgr->put_sum(sum_mgr, apcm->mono); | 367 | sum_mgr->put_sum(sum_mgr, apcm->mono); |
368 | apcm->mono = NULL; | 368 | apcm->mono = NULL; |
369 | } | 369 | } |
370 | 370 | ||
371 | if (NULL != apcm->src) { | 371 | if (apcm->src) { |
372 | src_mgr->put_src(src_mgr, apcm->src); | 372 | src_mgr->put_src(src_mgr, apcm->src); |
373 | apcm->src = NULL; | 373 | apcm->src = NULL; |
374 | } | 374 | } |
375 | 375 | ||
376 | if (NULL != apcm->vm_block) { | 376 | if (apcm->vm_block) { |
377 | /* Undo device virtual mem map */ | 377 | /* Undo device virtual mem map */ |
378 | ct_unmap_audio_buffer(atc, apcm); | 378 | ct_unmap_audio_buffer(atc, apcm); |
379 | apcm->vm_block = NULL; | 379 | apcm->vm_block = NULL; |
@@ -419,7 +419,7 @@ static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
419 | src->ops->set_state(src, SRC_STATE_OFF); | 419 | src->ops->set_state(src, SRC_STATE_OFF); |
420 | src->ops->commit_write(src); | 420 | src->ops->commit_write(src); |
421 | 421 | ||
422 | if (NULL != apcm->srccs) { | 422 | if (apcm->srccs) { |
423 | for (i = 0; i < apcm->n_srcc; i++) { | 423 | for (i = 0; i < apcm->n_srcc; i++) { |
424 | src = apcm->srccs[i]; | 424 | src = apcm->srccs[i]; |
425 | src->ops->set_bm(src, 0); | 425 | src->ops->set_bm(src, 0); |
@@ -544,18 +544,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
544 | 544 | ||
545 | if (n_srcc) { | 545 | if (n_srcc) { |
546 | apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL); | 546 | apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL); |
547 | if (NULL == apcm->srccs) | 547 | if (!apcm->srccs) |
548 | return -ENOMEM; | 548 | return -ENOMEM; |
549 | } | 549 | } |
550 | if (n_amixer) { | 550 | if (n_amixer) { |
551 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 551 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); |
552 | if (NULL == apcm->amixers) { | 552 | if (!apcm->amixers) { |
553 | err = -ENOMEM; | 553 | err = -ENOMEM; |
554 | goto error1; | 554 | goto error1; |
555 | } | 555 | } |
556 | } | 556 | } |
557 | apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL); | 557 | apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL); |
558 | if (NULL == apcm->srcimps) { | 558 | if (!apcm->srcimps) { |
559 | err = -ENOMEM; | 559 | err = -ENOMEM; |
560 | goto error1; | 560 | goto error1; |
561 | } | 561 | } |
@@ -818,7 +818,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc, | |||
818 | /* Get AMIXER resource */ | 818 | /* Get AMIXER resource */ |
819 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; | 819 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; |
820 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 820 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); |
821 | if (NULL == apcm->amixers) { | 821 | if (!apcm->amixers) { |
822 | err = -ENOMEM; | 822 | err = -ENOMEM; |
823 | goto error1; | 823 | goto error1; |
824 | } | 824 | } |
@@ -919,7 +919,7 @@ spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
919 | amixer = apcm->amixers[i]; | 919 | amixer = apcm->amixers[i]; |
920 | amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); | 920 | amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); |
921 | src = src->ops->next_interleave(src); | 921 | src = src->ops->next_interleave(src); |
922 | if (NULL == src) | 922 | if (!src) |
923 | src = apcm->src; | 923 | src = apcm->src; |
924 | } | 924 | } |
925 | /* Connect to SPDIFOO */ | 925 | /* Connect to SPDIFOO */ |
@@ -1121,7 +1121,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1121 | struct ct_mixer *mixer = NULL; | 1121 | struct ct_mixer *mixer = NULL; |
1122 | 1122 | ||
1123 | /* disconnect internal mixer objects */ | 1123 | /* disconnect internal mixer objects */ |
1124 | if (NULL != atc->mixer) { | 1124 | if (atc->mixer) { |
1125 | mixer = atc->mixer; | 1125 | mixer = atc->mixer; |
1126 | mixer->set_input_left(mixer, MIX_LINE_IN, NULL); | 1126 | mixer->set_input_left(mixer, MIX_LINE_IN, NULL); |
1127 | mixer->set_input_right(mixer, MIX_LINE_IN, NULL); | 1127 | mixer->set_input_right(mixer, MIX_LINE_IN, NULL); |
@@ -1131,7 +1131,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1131 | mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); | 1131 | mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | if (NULL != atc->daios) { | 1134 | if (atc->daios) { |
1135 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; | 1135 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; |
1136 | for (i = 0; i < atc->n_daio; i++) { | 1136 | for (i = 0; i < atc->n_daio; i++) { |
1137 | daio = atc->daios[i]; | 1137 | daio = atc->daios[i]; |
@@ -1149,7 +1149,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1149 | atc->daios = NULL; | 1149 | atc->daios = NULL; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | if (NULL != atc->pcm) { | 1152 | if (atc->pcm) { |
1153 | sum_mgr = atc->rsc_mgrs[SUM]; | 1153 | sum_mgr = atc->rsc_mgrs[SUM]; |
1154 | for (i = 0; i < atc->n_pcm; i++) | 1154 | for (i = 0; i < atc->n_pcm; i++) |
1155 | sum_mgr->put_sum(sum_mgr, atc->pcm[i]); | 1155 | sum_mgr->put_sum(sum_mgr, atc->pcm[i]); |
@@ -1158,7 +1158,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1158 | atc->pcm = NULL; | 1158 | atc->pcm = NULL; |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | if (NULL != atc->srcs) { | 1161 | if (atc->srcs) { |
1162 | src_mgr = atc->rsc_mgrs[SRC]; | 1162 | src_mgr = atc->rsc_mgrs[SRC]; |
1163 | for (i = 0; i < atc->n_src; i++) | 1163 | for (i = 0; i < atc->n_src; i++) |
1164 | src_mgr->put_src(src_mgr, atc->srcs[i]); | 1164 | src_mgr->put_src(src_mgr, atc->srcs[i]); |
@@ -1167,7 +1167,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1167 | atc->srcs = NULL; | 1167 | atc->srcs = NULL; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | if (NULL != atc->srcimps) { | 1170 | if (atc->srcimps) { |
1171 | srcimp_mgr = atc->rsc_mgrs[SRCIMP]; | 1171 | srcimp_mgr = atc->rsc_mgrs[SRCIMP]; |
1172 | for (i = 0; i < atc->n_srcimp; i++) { | 1172 | for (i = 0; i < atc->n_srcimp; i++) { |
1173 | srcimp = atc->srcimps[i]; | 1173 | srcimp = atc->srcimps[i]; |
@@ -1185,7 +1185,7 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
1185 | { | 1185 | { |
1186 | int i = 0; | 1186 | int i = 0; |
1187 | 1187 | ||
1188 | if (NULL == atc) | 1188 | if (!atc) |
1189 | return 0; | 1189 | return 0; |
1190 | 1190 | ||
1191 | if (atc->timer) { | 1191 | if (atc->timer) { |
@@ -1196,21 +1196,20 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
1196 | atc_release_resources(atc); | 1196 | atc_release_resources(atc); |
1197 | 1197 | ||
1198 | /* Destroy internal mixer objects */ | 1198 | /* Destroy internal mixer objects */ |
1199 | if (NULL != atc->mixer) | 1199 | if (atc->mixer) |
1200 | ct_mixer_destroy(atc->mixer); | 1200 | ct_mixer_destroy(atc->mixer); |
1201 | 1201 | ||
1202 | for (i = 0; i < NUM_RSCTYP; i++) { | 1202 | for (i = 0; i < NUM_RSCTYP; i++) { |
1203 | if ((NULL != rsc_mgr_funcs[i].destroy) && | 1203 | if (rsc_mgr_funcs[i].destroy && atc->rsc_mgrs[i]) |
1204 | (NULL != atc->rsc_mgrs[i])) | ||
1205 | rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); | 1204 | rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); |
1206 | 1205 | ||
1207 | } | 1206 | } |
1208 | 1207 | ||
1209 | if (NULL != atc->hw) | 1208 | if (atc->hw) |
1210 | destroy_hw_obj((struct hw *)atc->hw); | 1209 | destroy_hw_obj((struct hw *)atc->hw); |
1211 | 1210 | ||
1212 | /* Destroy device virtual memory manager object */ | 1211 | /* Destroy device virtual memory manager object */ |
1213 | if (NULL != atc->vm) { | 1212 | if (atc->vm) { |
1214 | ct_vm_destroy(atc->vm); | 1213 | ct_vm_destroy(atc->vm); |
1215 | atc->vm = NULL; | 1214 | atc->vm = NULL; |
1216 | } | 1215 | } |
@@ -1275,7 +1274,7 @@ int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc) | |||
1275 | alsa_dev_funcs[MIXER].public_name = atc->chip_name; | 1274 | alsa_dev_funcs[MIXER].public_name = atc->chip_name; |
1276 | 1275 | ||
1277 | for (i = 0; i < NUM_CTALSADEVS; i++) { | 1276 | for (i = 0; i < NUM_CTALSADEVS; i++) { |
1278 | if (NULL == alsa_dev_funcs[i].create) | 1277 | if (!alsa_dev_funcs[i].create) |
1279 | continue; | 1278 | continue; |
1280 | 1279 | ||
1281 | err = alsa_dev_funcs[i].create(atc, i, | 1280 | err = alsa_dev_funcs[i].create(atc, i, |
@@ -1312,7 +1311,7 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc) | |||
1312 | return err; | 1311 | return err; |
1313 | 1312 | ||
1314 | for (i = 0; i < NUM_RSCTYP; i++) { | 1313 | for (i = 0; i < NUM_RSCTYP; i++) { |
1315 | if (NULL == rsc_mgr_funcs[i].create) | 1314 | if (!rsc_mgr_funcs[i].create) |
1316 | continue; | 1315 | continue; |
1317 | 1316 | ||
1318 | err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); | 1317 | err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); |
@@ -1339,19 +1338,19 @@ static int atc_get_resources(struct ct_atc *atc) | |||
1339 | int err, i; | 1338 | int err, i; |
1340 | 1339 | ||
1341 | atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); | 1340 | atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); |
1342 | if (NULL == atc->daios) | 1341 | if (!atc->daios) |
1343 | return -ENOMEM; | 1342 | return -ENOMEM; |
1344 | 1343 | ||
1345 | atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); | 1344 | atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); |
1346 | if (NULL == atc->srcs) | 1345 | if (!atc->srcs) |
1347 | return -ENOMEM; | 1346 | return -ENOMEM; |
1348 | 1347 | ||
1349 | atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); | 1348 | atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); |
1350 | if (NULL == atc->srcimps) | 1349 | if (!atc->srcimps) |
1351 | return -ENOMEM; | 1350 | return -ENOMEM; |
1352 | 1351 | ||
1353 | atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL); | 1352 | atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL); |
1354 | if (NULL == atc->pcm) | 1353 | if (!atc->pcm) |
1355 | return -ENOMEM; | 1354 | return -ENOMEM; |
1356 | 1355 | ||
1357 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; | 1356 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; |
@@ -1648,7 +1647,7 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | |||
1648 | *ratc = NULL; | 1647 | *ratc = NULL; |
1649 | 1648 | ||
1650 | atc = kzalloc(sizeof(*atc), GFP_KERNEL); | 1649 | atc = kzalloc(sizeof(*atc), GFP_KERNEL); |
1651 | if (NULL == atc) | 1650 | if (!atc) |
1652 | return -ENOMEM; | 1651 | return -ENOMEM; |
1653 | 1652 | ||
1654 | /* Set operations */ | 1653 | /* Set operations */ |
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index deb6cfa73600..af56eb949bde 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c | |||
@@ -173,7 +173,7 @@ static int dao_set_left_input(struct dao *dao, struct rsc *input) | |||
173 | int i; | 173 | int i; |
174 | 174 | ||
175 | entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL); | 175 | entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL); |
176 | if (NULL == entry) | 176 | if (!entry) |
177 | return -ENOMEM; | 177 | return -ENOMEM; |
178 | 178 | ||
179 | /* Program master and conjugate resources */ | 179 | /* Program master and conjugate resources */ |
@@ -201,7 +201,7 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input) | |||
201 | int i; | 201 | int i; |
202 | 202 | ||
203 | entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL); | 203 | entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL); |
204 | if (NULL == entry) | 204 | if (!entry) |
205 | return -ENOMEM; | 205 | return -ENOMEM; |
206 | 206 | ||
207 | /* Program master and conjugate resources */ | 207 | /* Program master and conjugate resources */ |
@@ -228,7 +228,7 @@ static int dao_clear_left_input(struct dao *dao) | |||
228 | struct daio *daio = &dao->daio; | 228 | struct daio *daio = &dao->daio; |
229 | int i; | 229 | int i; |
230 | 230 | ||
231 | if (NULL == dao->imappers[0]) | 231 | if (!dao->imappers[0]) |
232 | return 0; | 232 | return 0; |
233 | 233 | ||
234 | entry = dao->imappers[0]; | 234 | entry = dao->imappers[0]; |
@@ -252,7 +252,7 @@ static int dao_clear_right_input(struct dao *dao) | |||
252 | struct daio *daio = &dao->daio; | 252 | struct daio *daio = &dao->daio; |
253 | int i; | 253 | int i; |
254 | 254 | ||
255 | if (NULL == dao->imappers[daio->rscl.msr]) | 255 | if (!dao->imappers[daio->rscl.msr]) |
256 | return 0; | 256 | return 0; |
257 | 257 | ||
258 | entry = dao->imappers[daio->rscl.msr]; | 258 | entry = dao->imappers[daio->rscl.msr]; |
@@ -408,7 +408,7 @@ static int dao_rsc_init(struct dao *dao, | |||
408 | return err; | 408 | return err; |
409 | 409 | ||
410 | dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); | 410 | dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); |
411 | if (NULL == dao->imappers) { | 411 | if (!dao->imappers) { |
412 | err = -ENOMEM; | 412 | err = -ENOMEM; |
413 | goto error1; | 413 | goto error1; |
414 | } | 414 | } |
@@ -442,11 +442,11 @@ error1: | |||
442 | 442 | ||
443 | static int dao_rsc_uninit(struct dao *dao) | 443 | static int dao_rsc_uninit(struct dao *dao) |
444 | { | 444 | { |
445 | if (NULL != dao->imappers) { | 445 | if (dao->imappers) { |
446 | if (NULL != dao->imappers[0]) | 446 | if (dao->imappers[0]) |
447 | dao_clear_left_input(dao); | 447 | dao_clear_left_input(dao); |
448 | 448 | ||
449 | if (NULL != dao->imappers[dao->daio.rscl.msr]) | 449 | if (dao->imappers[dao->daio.rscl.msr]) |
450 | dao_clear_right_input(dao); | 450 | dao_clear_right_input(dao); |
451 | 451 | ||
452 | kfree(dao->imappers); | 452 | kfree(dao->imappers); |
@@ -555,7 +555,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, | |||
555 | /* Allocate mem for daio resource */ | 555 | /* Allocate mem for daio resource */ |
556 | if (desc->type <= DAIO_OUT_MAX) { | 556 | if (desc->type <= DAIO_OUT_MAX) { |
557 | dao = kzalloc(sizeof(*dao), GFP_KERNEL); | 557 | dao = kzalloc(sizeof(*dao), GFP_KERNEL); |
558 | if (NULL == dao) { | 558 | if (!dao) { |
559 | err = -ENOMEM; | 559 | err = -ENOMEM; |
560 | goto error; | 560 | goto error; |
561 | } | 561 | } |
@@ -566,7 +566,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, | |||
566 | *rdaio = &dao->daio; | 566 | *rdaio = &dao->daio; |
567 | } else { | 567 | } else { |
568 | dai = kzalloc(sizeof(*dai), GFP_KERNEL); | 568 | dai = kzalloc(sizeof(*dai), GFP_KERNEL); |
569 | if (NULL == dai) { | 569 | if (!dai) { |
570 | err = -ENOMEM; | 570 | err = -ENOMEM; |
571 | goto error; | 571 | goto error; |
572 | } | 572 | } |
@@ -583,9 +583,9 @@ static int get_daio_rsc(struct daio_mgr *mgr, | |||
583 | return 0; | 583 | return 0; |
584 | 584 | ||
585 | error: | 585 | error: |
586 | if (NULL != dao) | 586 | if (dao) |
587 | kfree(dao); | 587 | kfree(dao); |
588 | else if (NULL != dai) | 588 | else if (dai) |
589 | kfree(dai); | 589 | kfree(dai); |
590 | 590 | ||
591 | spin_lock_irqsave(&mgr->mgr_lock, flags); | 591 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
@@ -663,7 +663,7 @@ static int daio_imap_add(struct daio_mgr *mgr, struct imapper *entry) | |||
663 | int err; | 663 | int err; |
664 | 664 | ||
665 | spin_lock_irqsave(&mgr->imap_lock, flags); | 665 | spin_lock_irqsave(&mgr->imap_lock, flags); |
666 | if ((0 == entry->addr) && (mgr->init_imap_added)) { | 666 | if (!entry->addr && mgr->init_imap_added) { |
667 | input_mapper_delete(&mgr->imappers, mgr->init_imap, | 667 | input_mapper_delete(&mgr->imappers, mgr->init_imap, |
668 | daio_map_op, mgr); | 668 | daio_map_op, mgr); |
669 | mgr->init_imap_added = 0; | 669 | mgr->init_imap_added = 0; |
@@ -707,7 +707,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr) | |||
707 | 707 | ||
708 | *rdaio_mgr = NULL; | 708 | *rdaio_mgr = NULL; |
709 | daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL); | 709 | daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL); |
710 | if (NULL == daio_mgr) | 710 | if (!daio_mgr) |
711 | return -ENOMEM; | 711 | return -ENOMEM; |
712 | 712 | ||
713 | err = rsc_mgr_init(&daio_mgr->mgr, DAIO, DAIO_RESOURCE_NUM, hw); | 713 | err = rsc_mgr_init(&daio_mgr->mgr, DAIO, DAIO_RESOURCE_NUM, hw); |
@@ -718,7 +718,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr) | |||
718 | spin_lock_init(&daio_mgr->imap_lock); | 718 | spin_lock_init(&daio_mgr->imap_lock); |
719 | INIT_LIST_HEAD(&daio_mgr->imappers); | 719 | INIT_LIST_HEAD(&daio_mgr->imappers); |
720 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | 720 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
721 | if (NULL == entry) { | 721 | if (!entry) { |
722 | err = -ENOMEM; | 722 | err = -ENOMEM; |
723 | goto error2; | 723 | goto error2; |
724 | } | 724 | } |
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index ad3e1d144464..0cf400f879f9 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c | |||
@@ -168,7 +168,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) | |||
168 | 168 | ||
169 | *rblk = NULL; | 169 | *rblk = NULL; |
170 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 170 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
171 | if (NULL == blk) | 171 | if (!blk) |
172 | return -ENOMEM; | 172 | return -ENOMEM; |
173 | 173 | ||
174 | *rblk = blk; | 174 | *rblk = blk; |
@@ -494,7 +494,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) | |||
494 | 494 | ||
495 | *rblk = NULL; | 495 | *rblk = NULL; |
496 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 496 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
497 | if (NULL == blk) | 497 | if (!blk) |
498 | return -ENOMEM; | 498 | return -ENOMEM; |
499 | 499 | ||
500 | *rblk = blk; | 500 | *rblk = blk; |
@@ -515,7 +515,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) | |||
515 | 515 | ||
516 | *rblk = NULL; | 516 | *rblk = NULL; |
517 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 517 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
518 | if (NULL == blk) | 518 | if (!blk) |
519 | return -ENOMEM; | 519 | return -ENOMEM; |
520 | 520 | ||
521 | *rblk = blk; | 521 | *rblk = blk; |
@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) | |||
702 | 702 | ||
703 | *rblk = NULL; | 703 | *rblk = NULL; |
704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
705 | if (NULL == blk) | 705 | if (!blk) |
706 | return -ENOMEM; | 706 | return -ENOMEM; |
707 | 707 | ||
708 | *rblk = blk; | 708 | *rblk = blk; |
@@ -723,7 +723,7 @@ static int amixer_mgr_get_ctrl_blk(void **rblk) | |||
723 | 723 | ||
724 | *rblk = NULL; | 724 | *rblk = NULL; |
725 | /*blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 725 | /*blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
726 | if (NULL == blk) | 726 | if (!blk) |
727 | return -ENOMEM; | 727 | return -ENOMEM; |
728 | 728 | ||
729 | *rblk = blk;*/ | 729 | *rblk = blk;*/ |
@@ -909,7 +909,7 @@ static int dai_get_ctrl_blk(void **rblk) | |||
909 | 909 | ||
910 | *rblk = NULL; | 910 | *rblk = NULL; |
911 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 911 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
912 | if (NULL == blk) | 912 | if (!blk) |
913 | return -ENOMEM; | 913 | return -ENOMEM; |
914 | 914 | ||
915 | *rblk = blk; | 915 | *rblk = blk; |
@@ -958,7 +958,7 @@ static int dao_get_ctrl_blk(void **rblk) | |||
958 | 958 | ||
959 | *rblk = NULL; | 959 | *rblk = NULL; |
960 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 960 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
961 | if (NULL == blk) | 961 | if (!blk) |
962 | return -ENOMEM; | 962 | return -ENOMEM; |
963 | 963 | ||
964 | *rblk = blk; | 964 | *rblk = blk; |
@@ -1152,7 +1152,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) | |||
1152 | 1152 | ||
1153 | *rblk = NULL; | 1153 | *rblk = NULL; |
1154 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 1154 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
1155 | if (NULL == blk) | 1155 | if (!blk) |
1156 | return -ENOMEM; | 1156 | return -ENOMEM; |
1157 | 1157 | ||
1158 | blk->i2sctl = hw_read_20kx(hw, I2SCTL); | 1158 | blk->i2sctl = hw_read_20kx(hw, I2SCTL); |
@@ -1808,7 +1808,7 @@ static int uaa_to_xfi(struct pci_dev *pci) | |||
1808 | /* By default, Hendrix card UAA Bar0 should be using memory... */ | 1808 | /* By default, Hendrix card UAA Bar0 should be using memory... */ |
1809 | io_base = pci_resource_start(pci, 0); | 1809 | io_base = pci_resource_start(pci, 0); |
1810 | mem_base = ioremap(io_base, pci_resource_len(pci, 0)); | 1810 | mem_base = ioremap(io_base, pci_resource_len(pci, 0)); |
1811 | if (NULL == mem_base) | 1811 | if (!mem_base) |
1812 | return -ENOENT; | 1812 | return -ENOENT; |
1813 | 1813 | ||
1814 | /* Read current mode from Mode Change Register */ | 1814 | /* Read current mode from Mode Change Register */ |
@@ -1977,7 +1977,7 @@ static int hw_card_shutdown(struct hw *hw) | |||
1977 | 1977 | ||
1978 | hw->irq = -1; | 1978 | hw->irq = -1; |
1979 | 1979 | ||
1980 | if (NULL != ((void *)hw->mem_base)) | 1980 | if (hw->mem_base) |
1981 | iounmap((void *)hw->mem_base); | 1981 | iounmap((void *)hw->mem_base); |
1982 | 1982 | ||
1983 | hw->mem_base = (unsigned long)NULL; | 1983 | hw->mem_base = (unsigned long)NULL; |
@@ -2274,7 +2274,7 @@ int __devinit create_20k1_hw_obj(struct hw **rhw) | |||
2274 | 2274 | ||
2275 | *rhw = NULL; | 2275 | *rhw = NULL; |
2276 | hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL); | 2276 | hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL); |
2277 | if (NULL == hw20k1) | 2277 | if (!hw20k1) |
2278 | return -ENOMEM; | 2278 | return -ENOMEM; |
2279 | 2279 | ||
2280 | spin_lock_init(&hw20k1->reg_20k1_lock); | 2280 | spin_lock_init(&hw20k1->reg_20k1_lock); |
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index dec46d04b041..b6b11bfe7574 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c | |||
@@ -166,7 +166,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) | |||
166 | 166 | ||
167 | *rblk = NULL; | 167 | *rblk = NULL; |
168 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 168 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
169 | if (NULL == blk) | 169 | if (!blk) |
170 | return -ENOMEM; | 170 | return -ENOMEM; |
171 | 171 | ||
172 | *rblk = blk; | 172 | *rblk = blk; |
@@ -492,7 +492,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) | |||
492 | 492 | ||
493 | *rblk = NULL; | 493 | *rblk = NULL; |
494 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 494 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
495 | if (NULL == blk) | 495 | if (!blk) |
496 | return -ENOMEM; | 496 | return -ENOMEM; |
497 | 497 | ||
498 | *rblk = blk; | 498 | *rblk = blk; |
@@ -513,7 +513,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) | |||
513 | 513 | ||
514 | *rblk = NULL; | 514 | *rblk = NULL; |
515 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 515 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
516 | if (NULL == blk) | 516 | if (!blk) |
517 | return -ENOMEM; | 517 | return -ENOMEM; |
518 | 518 | ||
519 | *rblk = blk; | 519 | *rblk = blk; |
@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) | |||
702 | 702 | ||
703 | *rblk = NULL; | 703 | *rblk = NULL; |
704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
705 | if (NULL == blk) | 705 | if (!blk) |
706 | return -ENOMEM; | 706 | return -ENOMEM; |
707 | 707 | ||
708 | *rblk = blk; | 708 | *rblk = blk; |
@@ -891,7 +891,7 @@ static int dai_get_ctrl_blk(void **rblk) | |||
891 | 891 | ||
892 | *rblk = NULL; | 892 | *rblk = NULL; |
893 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 893 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
894 | if (NULL == blk) | 894 | if (!blk) |
895 | return -ENOMEM; | 895 | return -ENOMEM; |
896 | 896 | ||
897 | *rblk = blk; | 897 | *rblk = blk; |
@@ -941,7 +941,7 @@ static int dao_get_ctrl_blk(void **rblk) | |||
941 | 941 | ||
942 | *rblk = NULL; | 942 | *rblk = NULL; |
943 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 943 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
944 | if (NULL == blk) | 944 | if (!blk) |
945 | return -ENOMEM; | 945 | return -ENOMEM; |
946 | 946 | ||
947 | *rblk = blk; | 947 | *rblk = blk; |
@@ -1092,7 +1092,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) | |||
1092 | 1092 | ||
1093 | *rblk = NULL; | 1093 | *rblk = NULL; |
1094 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 1094 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
1095 | if (NULL == blk) | 1095 | if (!blk) |
1096 | return -ENOMEM; | 1096 | return -ENOMEM; |
1097 | 1097 | ||
1098 | for (i = 0; i < 8; i++) { | 1098 | for (i = 0; i < 8; i++) { |
@@ -1112,6 +1112,26 @@ static int daio_mgr_put_ctrl_blk(void *blk) | |||
1112 | return 0; | 1112 | return 0; |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | /* Timer interrupt */ | ||
1116 | static int set_timer_irq(struct hw *hw, int enable) | ||
1117 | { | ||
1118 | hw_write_20kx(hw, GIE, enable ? IT_INT : 0); | ||
1119 | return 0; | ||
1120 | } | ||
1121 | |||
1122 | static int set_timer_tick(struct hw *hw, unsigned int ticks) | ||
1123 | { | ||
1124 | if (ticks) | ||
1125 | ticks |= TIMR_IE | TIMR_IP; | ||
1126 | hw_write_20kx(hw, TIMR, ticks); | ||
1127 | return 0; | ||
1128 | } | ||
1129 | |||
1130 | static unsigned int get_wc(struct hw *hw) | ||
1131 | { | ||
1132 | return hw_read_20kx(hw, WC); | ||
1133 | } | ||
1134 | |||
1115 | /* Card hardware initialization block */ | 1135 | /* Card hardware initialization block */ |
1116 | struct dac_conf { | 1136 | struct dac_conf { |
1117 | unsigned int msr; /* master sample rate in rsrs */ | 1137 | unsigned int msr; /* master sample rate in rsrs */ |
@@ -1841,6 +1861,22 @@ static int hw_have_digit_io_switch(struct hw *hw) | |||
1841 | return 0; | 1861 | return 0; |
1842 | } | 1862 | } |
1843 | 1863 | ||
1864 | static irqreturn_t ct_20k2_interrupt(int irq, void *dev_id) | ||
1865 | { | ||
1866 | struct hw *hw = dev_id; | ||
1867 | unsigned int status; | ||
1868 | |||
1869 | status = hw_read_20kx(hw, GIP); | ||
1870 | if (!status) | ||
1871 | return IRQ_NONE; | ||
1872 | |||
1873 | if (hw->irq_callback) | ||
1874 | hw->irq_callback(hw->irq_callback_data, status); | ||
1875 | |||
1876 | hw_write_20kx(hw, GIP, status); | ||
1877 | return IRQ_HANDLED; | ||
1878 | } | ||
1879 | |||
1844 | static int hw_card_start(struct hw *hw) | 1880 | static int hw_card_start(struct hw *hw) |
1845 | { | 1881 | { |
1846 | int err = 0; | 1882 | int err = 0; |
@@ -1868,7 +1904,7 @@ static int hw_card_start(struct hw *hw) | |||
1868 | hw->io_base = pci_resource_start(hw->pci, 2); | 1904 | hw->io_base = pci_resource_start(hw->pci, 2); |
1869 | hw->mem_base = (unsigned long)ioremap(hw->io_base, | 1905 | hw->mem_base = (unsigned long)ioremap(hw->io_base, |
1870 | pci_resource_len(hw->pci, 2)); | 1906 | pci_resource_len(hw->pci, 2)); |
1871 | if (NULL == (void *)hw->mem_base) { | 1907 | if (!hw->mem_base) { |
1872 | err = -ENOENT; | 1908 | err = -ENOENT; |
1873 | goto error2; | 1909 | goto error2; |
1874 | } | 1910 | } |
@@ -1879,12 +1915,15 @@ static int hw_card_start(struct hw *hw) | |||
1879 | set_field(&gctl, GCTL_UAA, 0); | 1915 | set_field(&gctl, GCTL_UAA, 0); |
1880 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); | 1916 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); |
1881 | 1917 | ||
1882 | /*if ((err = request_irq(pci->irq, ct_atc_interrupt, IRQF_SHARED, | 1918 | if (hw->irq < 0) { |
1883 | atc->chip_details->nm_card, hw))) { | 1919 | err = request_irq(pci->irq, ct_20k2_interrupt, IRQF_SHARED, |
1884 | goto error3; | 1920 | "ctxfi", hw); |
1921 | if (err < 0) { | ||
1922 | printk(KERN_ERR "XFi: Cannot get irq %d\n", pci->irq); | ||
1923 | goto error2; | ||
1924 | } | ||
1925 | hw->irq = pci->irq; | ||
1885 | } | 1926 | } |
1886 | hw->irq = pci->irq; | ||
1887 | */ | ||
1888 | 1927 | ||
1889 | pci_set_master(pci); | 1928 | pci_set_master(pci); |
1890 | 1929 | ||
@@ -1923,7 +1962,7 @@ static int hw_card_shutdown(struct hw *hw) | |||
1923 | 1962 | ||
1924 | hw->irq = -1; | 1963 | hw->irq = -1; |
1925 | 1964 | ||
1926 | if (NULL != ((void *)hw->mem_base)) | 1965 | if (hw->mem_base) |
1927 | iounmap((void *)hw->mem_base); | 1966 | iounmap((void *)hw->mem_base); |
1928 | 1967 | ||
1929 | hw->mem_base = (unsigned long)NULL; | 1968 | hw->mem_base = (unsigned long)NULL; |
@@ -1972,7 +2011,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
1972 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); | 2011 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); |
1973 | 2012 | ||
1974 | /* Reset all global pending interrupts */ | 2013 | /* Reset all global pending interrupts */ |
1975 | hw_write_20kx(hw, INTERRUPT_GIE, 0); | 2014 | hw_write_20kx(hw, GIE, 0); |
1976 | /* Reset all SRC pending interrupts */ | 2015 | /* Reset all SRC pending interrupts */ |
1977 | hw_write_20kx(hw, SRC_IP, 0); | 2016 | hw_write_20kx(hw, SRC_IP, 0); |
1978 | 2017 | ||
@@ -2149,6 +2188,10 @@ static struct hw ct20k2_preset __devinitdata = { | |||
2149 | .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, | 2188 | .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, |
2150 | .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, | 2189 | .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, |
2151 | .daio_mgr_commit_write = daio_mgr_commit_write, | 2190 | .daio_mgr_commit_write = daio_mgr_commit_write, |
2191 | |||
2192 | .set_timer_irq = set_timer_irq, | ||
2193 | .set_timer_tick = set_timer_tick, | ||
2194 | .get_wc = get_wc, | ||
2152 | }; | 2195 | }; |
2153 | 2196 | ||
2154 | int __devinit create_20k2_hw_obj(struct hw **rhw) | 2197 | int __devinit create_20k2_hw_obj(struct hw **rhw) |
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index f26d7cd9db9f..15c1e7271ea8 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c | |||
@@ -654,7 +654,7 @@ ct_mixer_kcontrol_new(struct ct_mixer *mixer, struct snd_kcontrol_new *new) | |||
654 | int err; | 654 | int err; |
655 | 655 | ||
656 | kctl = snd_ctl_new1(new, mixer->atc); | 656 | kctl = snd_ctl_new1(new, mixer->atc); |
657 | if (NULL == kctl) | 657 | if (!kctl) |
658 | return -ENOMEM; | 658 | return -ENOMEM; |
659 | 659 | ||
660 | if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface) | 660 | if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface) |
@@ -837,17 +837,17 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer) | |||
837 | *rmixer = NULL; | 837 | *rmixer = NULL; |
838 | /* Allocate mem for mixer obj */ | 838 | /* Allocate mem for mixer obj */ |
839 | mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); | 839 | mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); |
840 | if (NULL == mixer) | 840 | if (!mixer) |
841 | return -ENOMEM; | 841 | return -ENOMEM; |
842 | 842 | ||
843 | mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM), | 843 | mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM), |
844 | GFP_KERNEL); | 844 | GFP_KERNEL); |
845 | if (NULL == mixer->amixers) { | 845 | if (!mixer->amixers) { |
846 | err = -ENOMEM; | 846 | err = -ENOMEM; |
847 | goto error1; | 847 | goto error1; |
848 | } | 848 | } |
849 | mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL); | 849 | mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL); |
850 | if (NULL == mixer->sums) { | 850 | if (!mixer->sums) { |
851 | err = -ENOMEM; | 851 | err = -ENOMEM; |
852 | goto error2; | 852 | goto error2; |
853 | } | 853 | } |
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 60ea23180acb..d0dc227fbdd3 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c | |||
@@ -97,7 +97,7 @@ static void ct_atc_pcm_interrupt(struct ct_atc_pcm *atc_pcm) | |||
97 | { | 97 | { |
98 | struct ct_atc_pcm *apcm = atc_pcm; | 98 | struct ct_atc_pcm *apcm = atc_pcm; |
99 | 99 | ||
100 | if (NULL == apcm->substream) | 100 | if (!apcm->substream) |
101 | return; | 101 | return; |
102 | 102 | ||
103 | snd_pcm_period_elapsed(apcm->substream); | 103 | snd_pcm_period_elapsed(apcm->substream); |
@@ -123,7 +123,7 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream) | |||
123 | int err; | 123 | int err; |
124 | 124 | ||
125 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); | 125 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); |
126 | if (NULL == apcm) | 126 | if (!apcm) |
127 | return -ENOMEM; | 127 | return -ENOMEM; |
128 | 128 | ||
129 | apcm->substream = substream; | 129 | apcm->substream = substream; |
@@ -271,7 +271,7 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream) | |||
271 | int err; | 271 | int err; |
272 | 272 | ||
273 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); | 273 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); |
274 | if (NULL == apcm) | 274 | if (!apcm) |
275 | return -ENOMEM; | 275 | return -ENOMEM; |
276 | 276 | ||
277 | apcm->started = 0; | 277 | apcm->started = 0; |
diff --git a/sound/pci/ctxfi/ctresource.c b/sound/pci/ctxfi/ctresource.c index 889c495bb7d1..7dfaf67344d4 100644 --- a/sound/pci/ctxfi/ctresource.c +++ b/sound/pci/ctxfi/ctresource.c | |||
@@ -144,7 +144,7 @@ int rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, void *hw) | |||
144 | rsc->msr = msr; | 144 | rsc->msr = msr; |
145 | rsc->hw = hw; | 145 | rsc->hw = hw; |
146 | rsc->ops = &rsc_generic_ops; | 146 | rsc->ops = &rsc_generic_ops; |
147 | if (NULL == hw) { | 147 | if (!hw) { |
148 | rsc->ctrl_blk = NULL; | 148 | rsc->ctrl_blk = NULL; |
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
@@ -216,7 +216,7 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type, | |||
216 | mgr->type = NUM_RSCTYP; | 216 | mgr->type = NUM_RSCTYP; |
217 | 217 | ||
218 | mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL); | 218 | mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL); |
219 | if (NULL == mgr->rscs) | 219 | if (!mgr->rscs) |
220 | return -ENOMEM; | 220 | return -ENOMEM; |
221 | 221 | ||
222 | switch (type) { | 222 | switch (type) { |
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c index df43a5cd3938..c749fa720889 100644 --- a/sound/pci/ctxfi/ctsrc.c +++ b/sound/pci/ctxfi/ctsrc.c | |||
@@ -441,7 +441,7 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc) | |||
441 | else | 441 | else |
442 | src = kzalloc(sizeof(*src), GFP_KERNEL); | 442 | src = kzalloc(sizeof(*src), GFP_KERNEL); |
443 | 443 | ||
444 | if (NULL == src) { | 444 | if (!src) { |
445 | err = -ENOMEM; | 445 | err = -ENOMEM; |
446 | goto error1; | 446 | goto error1; |
447 | } | 447 | } |
@@ -550,7 +550,7 @@ int src_mgr_create(void *hw, struct src_mgr **rsrc_mgr) | |||
550 | 550 | ||
551 | *rsrc_mgr = NULL; | 551 | *rsrc_mgr = NULL; |
552 | src_mgr = kzalloc(sizeof(*src_mgr), GFP_KERNEL); | 552 | src_mgr = kzalloc(sizeof(*src_mgr), GFP_KERNEL); |
553 | if (NULL == src_mgr) | 553 | if (!src_mgr) |
554 | return -ENOMEM; | 554 | return -ENOMEM; |
555 | 555 | ||
556 | err = rsc_mgr_init(&src_mgr->mgr, SRC, SRC_RESOURCE_NUM, hw); | 556 | err = rsc_mgr_init(&src_mgr->mgr, SRC, SRC_RESOURCE_NUM, hw); |
@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp, | |||
679 | /* Reserve memory for imapper nodes */ | 679 | /* Reserve memory for imapper nodes */ |
680 | srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr, | 680 | srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr, |
681 | GFP_KERNEL); | 681 | GFP_KERNEL); |
682 | if (NULL == srcimp->imappers) { | 682 | if (!srcimp->imappers) { |
683 | err = -ENOMEM; | 683 | err = -ENOMEM; |
684 | goto error1; | 684 | goto error1; |
685 | } | 685 | } |
@@ -833,7 +833,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr) | |||
833 | 833 | ||
834 | *rsrcimp_mgr = NULL; | 834 | *rsrcimp_mgr = NULL; |
835 | srcimp_mgr = kzalloc(sizeof(*srcimp_mgr), GFP_KERNEL); | 835 | srcimp_mgr = kzalloc(sizeof(*srcimp_mgr), GFP_KERNEL); |
836 | if (NULL == srcimp_mgr) | 836 | if (!srcimp_mgr) |
837 | return -ENOMEM; | 837 | return -ENOMEM; |
838 | 838 | ||
839 | err = rsc_mgr_init(&srcimp_mgr->mgr, SRCIMP, SRCIMP_RESOURCE_NUM, hw); | 839 | err = rsc_mgr_init(&srcimp_mgr->mgr, SRCIMP, SRCIMP_RESOURCE_NUM, hw); |
@@ -844,7 +844,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr) | |||
844 | spin_lock_init(&srcimp_mgr->imap_lock); | 844 | spin_lock_init(&srcimp_mgr->imap_lock); |
845 | INIT_LIST_HEAD(&srcimp_mgr->imappers); | 845 | INIT_LIST_HEAD(&srcimp_mgr->imappers); |
846 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | 846 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
847 | if (NULL == entry) { | 847 | if (!entry) { |
848 | err = -ENOMEM; | 848 | err = -ENOMEM; |
849 | goto error2; | 849 | goto error2; |
850 | } | 850 | } |
diff --git a/sound/pci/ctxfi/ctvmem.c b/sound/pci/ctxfi/ctvmem.c index 67665a7e43c6..6b78752e9503 100644 --- a/sound/pci/ctxfi/ctvmem.c +++ b/sound/pci/ctxfi/ctvmem.c | |||
@@ -60,7 +60,7 @@ get_vm_block(struct ct_vm *vm, unsigned int size) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | block = kzalloc(sizeof(*block), GFP_KERNEL); | 62 | block = kzalloc(sizeof(*block), GFP_KERNEL); |
63 | if (NULL == block) | 63 | if (!block) |
64 | goto out; | 64 | goto out; |
65 | 65 | ||
66 | block->addr = entry->addr; | 66 | block->addr = entry->addr; |
@@ -181,7 +181,7 @@ int ct_vm_create(struct ct_vm **rvm) | |||
181 | *rvm = NULL; | 181 | *rvm = NULL; |
182 | 182 | ||
183 | vm = kzalloc(sizeof(*vm), GFP_KERNEL); | 183 | vm = kzalloc(sizeof(*vm), GFP_KERNEL); |
184 | if (NULL == vm) | 184 | if (!vm) |
185 | return -ENOMEM; | 185 | return -ENOMEM; |
186 | 186 | ||
187 | mutex_init(&vm->lock); | 187 | mutex_init(&vm->lock); |
@@ -189,7 +189,7 @@ int ct_vm_create(struct ct_vm **rvm) | |||
189 | /* Allocate page table pages */ | 189 | /* Allocate page table pages */ |
190 | for (i = 0; i < CT_PTP_NUM; i++) { | 190 | for (i = 0; i < CT_PTP_NUM; i++) { |
191 | vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL); | 191 | vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL); |
192 | if (NULL == vm->ptp[i]) | 192 | if (!vm->ptp[i]) |
193 | break; | 193 | break; |
194 | } | 194 | } |
195 | if (!i) { | 195 | if (!i) { |
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 04438f1d682d..55545e0818b5 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -46,6 +46,20 @@ config SND_HDA_INPUT_JACK | |||
46 | Say Y here to enable the jack plugging notification via | 46 | Say Y here to enable the jack plugging notification via |
47 | input layer. | 47 | input layer. |
48 | 48 | ||
49 | config SND_HDA_PATCH_LOADER | ||
50 | bool "Support initialization patch loading for HD-audio" | ||
51 | depends on EXPERIMENTAL | ||
52 | select FW_LOADER | ||
53 | select SND_HDA_HWDEP | ||
54 | select SND_HDA_RECONFIG | ||
55 | help | ||
56 | Say Y here to allow the HD-audio driver to load a pseudo | ||
57 | firmware file ("patch") for overriding the BIOS setup at | ||
58 | start up. The "patch" file can be specified via patch module | ||
59 | option, such as patch=hda-init. | ||
60 | |||
61 | This option turns on hwdep and reconfig features automatically. | ||
62 | |||
49 | config SND_HDA_CODEC_REALTEK | 63 | config SND_HDA_CODEC_REALTEK |
50 | bool "Build Realtek HD-audio codec support" | 64 | bool "Build Realtek HD-audio codec support" |
51 | default y | 65 | default y |
@@ -134,6 +148,19 @@ config SND_HDA_ELD | |||
134 | def_bool y | 148 | def_bool y |
135 | depends on SND_HDA_CODEC_INTELHDMI | 149 | depends on SND_HDA_CODEC_INTELHDMI |
136 | 150 | ||
151 | config SND_HDA_CODEC_CIRRUS | ||
152 | bool "Build Cirrus Logic codec support" | ||
153 | depends on SND_HDA_INTEL | ||
154 | default y | ||
155 | help | ||
156 | Say Y here to include Cirrus Logic codec support in | ||
157 | snd-hda-intel driver, such as CS4206. | ||
158 | |||
159 | When the HD-audio driver is built as a module, the codec | ||
160 | support code is also built as another module, | ||
161 | snd-hda-codec-cirrus. | ||
162 | This module is automatically loaded at probing. | ||
163 | |||
137 | config SND_HDA_CODEC_CONEXANT | 164 | config SND_HDA_CODEC_CONEXANT |
138 | bool "Build Conexant HD-audio codec support" | 165 | bool "Build Conexant HD-audio codec support" |
139 | default y | 166 | default y |
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index e3081d4586cc..315a1c4f8998 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile | |||
@@ -13,6 +13,7 @@ snd-hda-codec-analog-objs := patch_analog.o | |||
13 | snd-hda-codec-idt-objs := patch_sigmatel.o | 13 | snd-hda-codec-idt-objs := patch_sigmatel.o |
14 | snd-hda-codec-si3054-objs := patch_si3054.o | 14 | snd-hda-codec-si3054-objs := patch_si3054.o |
15 | snd-hda-codec-atihdmi-objs := patch_atihdmi.o | 15 | snd-hda-codec-atihdmi-objs := patch_atihdmi.o |
16 | snd-hda-codec-cirrus-objs := patch_cirrus.o | ||
16 | snd-hda-codec-ca0110-objs := patch_ca0110.o | 17 | snd-hda-codec-ca0110-objs := patch_ca0110.o |
17 | snd-hda-codec-conexant-objs := patch_conexant.o | 18 | snd-hda-codec-conexant-objs := patch_conexant.o |
18 | snd-hda-codec-via-objs := patch_via.o | 19 | snd-hda-codec-via-objs := patch_via.o |
@@ -41,6 +42,9 @@ endif | |||
41 | ifdef CONFIG_SND_HDA_CODEC_ATIHDMI | 42 | ifdef CONFIG_SND_HDA_CODEC_ATIHDMI |
42 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o | 43 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o |
43 | endif | 44 | endif |
45 | ifdef CONFIG_SND_HDA_CODEC_CIRRUS | ||
46 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-cirrus.o | ||
47 | endif | ||
44 | ifdef CONFIG_SND_HDA_CODEC_CA0110 | 48 | ifdef CONFIG_SND_HDA_CODEC_CA0110 |
45 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0110.o | 49 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0110.o |
46 | endif | 50 | endif |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index b0275a050870..3f51a981e604 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <sound/core.h> | 25 | #include <sound/core.h> |
26 | #include "hda_beep.h" | 26 | #include "hda_beep.h" |
27 | #include "hda_local.h" | ||
27 | 28 | ||
28 | enum { | 29 | enum { |
29 | DIGBEEP_HZ_STEP = 46875, /* 46.875 Hz */ | 30 | DIGBEEP_HZ_STEP = 46875, /* 46.875 Hz */ |
@@ -118,6 +119,9 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
118 | struct hda_beep *beep; | 119 | struct hda_beep *beep; |
119 | int err; | 120 | int err; |
120 | 121 | ||
122 | if (!snd_hda_get_bool_hint(codec, "beep")) | ||
123 | return 0; /* disabled explicitly */ | ||
124 | |||
121 | beep = kzalloc(sizeof(*beep), GFP_KERNEL); | 125 | beep = kzalloc(sizeof(*beep), GFP_KERNEL); |
122 | if (beep == NULL) | 126 | if (beep == NULL) |
123 | return -ENOMEM; | 127 | return -ENOMEM; |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index c7df01b72cac..af989f660cca 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -44,6 +44,7 @@ struct hda_vendor_id { | |||
44 | /* codec vendor labels */ | 44 | /* codec vendor labels */ |
45 | static struct hda_vendor_id hda_vendor_ids[] = { | 45 | static struct hda_vendor_id hda_vendor_ids[] = { |
46 | { 0x1002, "ATI" }, | 46 | { 0x1002, "ATI" }, |
47 | { 0x1013, "Cirrus Logic" }, | ||
47 | { 0x1057, "Motorola" }, | 48 | { 0x1057, "Motorola" }, |
48 | { 0x1095, "Silicon Image" }, | 49 | { 0x1095, "Silicon Image" }, |
49 | { 0x10de, "Nvidia" }, | 50 | { 0x10de, "Nvidia" }, |
@@ -150,7 +151,14 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, | |||
150 | { | 151 | { |
151 | u32 val; | 152 | u32 val; |
152 | 153 | ||
153 | val = (u32)(codec->addr & 0x0f) << 28; | 154 | if ((codec->addr & ~0xf) || (direct & ~1) || (nid & ~0x7f) || |
155 | (verb & ~0xfff) || (parm & ~0xffff)) { | ||
156 | printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x:%x\n", | ||
157 | codec->addr, direct, nid, verb, parm); | ||
158 | return ~0; | ||
159 | } | ||
160 | |||
161 | val = (u32)codec->addr << 28; | ||
154 | val |= (u32)direct << 27; | 162 | val |= (u32)direct << 27; |
155 | val |= (u32)nid << 20; | 163 | val |= (u32)nid << 20; |
156 | val |= verb << 8; | 164 | val |= verb << 8; |
@@ -167,6 +175,9 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, | |||
167 | struct hda_bus *bus = codec->bus; | 175 | struct hda_bus *bus = codec->bus; |
168 | int err; | 176 | int err; |
169 | 177 | ||
178 | if (cmd == ~0) | ||
179 | return -1; | ||
180 | |||
170 | if (res) | 181 | if (res) |
171 | *res = -1; | 182 | *res = -1; |
172 | again: | 183 | again: |
@@ -291,11 +302,20 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, | |||
291 | unsigned int parm; | 302 | unsigned int parm; |
292 | int i, conn_len, conns; | 303 | int i, conn_len, conns; |
293 | unsigned int shift, num_elems, mask; | 304 | unsigned int shift, num_elems, mask; |
305 | unsigned int wcaps; | ||
294 | hda_nid_t prev_nid; | 306 | hda_nid_t prev_nid; |
295 | 307 | ||
296 | if (snd_BUG_ON(!conn_list || max_conns <= 0)) | 308 | if (snd_BUG_ON(!conn_list || max_conns <= 0)) |
297 | return -EINVAL; | 309 | return -EINVAL; |
298 | 310 | ||
311 | wcaps = get_wcaps(codec, nid); | ||
312 | if (!(wcaps & AC_WCAP_CONN_LIST) && | ||
313 | get_wcaps_type(wcaps) != AC_WID_VOL_KNB) { | ||
314 | snd_printk(KERN_WARNING "hda_codec: " | ||
315 | "connection list not available for 0x%x\n", nid); | ||
316 | return -EINVAL; | ||
317 | } | ||
318 | |||
299 | parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN); | 319 | parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN); |
300 | if (parm & AC_CLIST_LONG) { | 320 | if (parm & AC_CLIST_LONG) { |
301 | /* long form */ | 321 | /* long form */ |
@@ -316,6 +336,8 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, | |||
316 | /* single connection */ | 336 | /* single connection */ |
317 | parm = snd_hda_codec_read(codec, nid, 0, | 337 | parm = snd_hda_codec_read(codec, nid, 0, |
318 | AC_VERB_GET_CONNECT_LIST, 0); | 338 | AC_VERB_GET_CONNECT_LIST, 0); |
339 | if (parm == -1 && codec->bus->rirb_error) | ||
340 | return -EIO; | ||
319 | conn_list[0] = parm & mask; | 341 | conn_list[0] = parm & mask; |
320 | return 1; | 342 | return 1; |
321 | } | 343 | } |
@@ -327,9 +349,12 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, | |||
327 | int range_val; | 349 | int range_val; |
328 | hda_nid_t val, n; | 350 | hda_nid_t val, n; |
329 | 351 | ||
330 | if (i % num_elems == 0) | 352 | if (i % num_elems == 0) { |
331 | parm = snd_hda_codec_read(codec, nid, 0, | 353 | parm = snd_hda_codec_read(codec, nid, 0, |
332 | AC_VERB_GET_CONNECT_LIST, i); | 354 | AC_VERB_GET_CONNECT_LIST, i); |
355 | if (parm == -1 && codec->bus->rirb_error) | ||
356 | return -EIO; | ||
357 | } | ||
333 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ | 358 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ |
334 | val = parm & mask; | 359 | val = parm & mask; |
335 | if (val == 0) { | 360 | if (val == 0) { |
@@ -727,8 +752,7 @@ static int read_pin_defaults(struct hda_codec *codec) | |||
727 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 752 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
728 | struct hda_pincfg *pin; | 753 | struct hda_pincfg *pin; |
729 | unsigned int wcaps = get_wcaps(codec, nid); | 754 | unsigned int wcaps = get_wcaps(codec, nid); |
730 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> | 755 | unsigned int wid_type = get_wcaps_type(wcaps); |
731 | AC_WCAP_TYPE_SHIFT; | ||
732 | if (wid_type != AC_WID_PIN) | 756 | if (wid_type != AC_WID_PIN) |
733 | continue; | 757 | continue; |
734 | pin = snd_array_new(&codec->init_pins); | 758 | pin = snd_array_new(&codec->init_pins); |
@@ -891,7 +915,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
891 | * Returns 0 if successful, or a negative error code. | 915 | * Returns 0 if successful, or a negative error code. |
892 | */ | 916 | */ |
893 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 917 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
894 | int do_init, struct hda_codec **codecp) | 918 | struct hda_codec **codecp) |
895 | { | 919 | { |
896 | struct hda_codec *codec; | 920 | struct hda_codec *codec; |
897 | char component[31]; | 921 | char component[31]; |
@@ -984,11 +1008,6 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
984 | codec->afg ? codec->afg : codec->mfg, | 1008 | codec->afg ? codec->afg : codec->mfg, |
985 | AC_PWRST_D0); | 1009 | AC_PWRST_D0); |
986 | 1010 | ||
987 | if (do_init) { | ||
988 | err = snd_hda_codec_configure(codec); | ||
989 | if (err < 0) | ||
990 | goto error; | ||
991 | } | ||
992 | snd_hda_codec_proc_new(codec); | 1011 | snd_hda_codec_proc_new(codec); |
993 | 1012 | ||
994 | snd_hda_create_hwdep(codec); | 1013 | snd_hda_create_hwdep(codec); |
@@ -1042,6 +1061,7 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1042 | err = init_unsol_queue(codec->bus); | 1061 | err = init_unsol_queue(codec->bus); |
1043 | return err; | 1062 | return err; |
1044 | } | 1063 | } |
1064 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); | ||
1045 | 1065 | ||
1046 | /** | 1066 | /** |
1047 | * snd_hda_codec_setup_stream - set up the codec for streaming | 1067 | * snd_hda_codec_setup_stream - set up the codec for streaming |
@@ -2356,16 +2376,20 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
2356 | hda_nid_t nid; | 2376 | hda_nid_t nid; |
2357 | int i; | 2377 | int i; |
2358 | 2378 | ||
2359 | snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE, | 2379 | /* this delay seems necessary to avoid click noise at power-down */ |
2380 | if (power_state == AC_PWRST_D3) | ||
2381 | msleep(100); | ||
2382 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, | ||
2360 | power_state); | 2383 | power_state); |
2361 | msleep(10); /* partial workaround for "azx_get_response timeout" */ | 2384 | /* partial workaround for "azx_get_response timeout" */ |
2385 | if (power_state == AC_PWRST_D0) | ||
2386 | msleep(10); | ||
2362 | 2387 | ||
2363 | nid = codec->start_nid; | 2388 | nid = codec->start_nid; |
2364 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 2389 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
2365 | unsigned int wcaps = get_wcaps(codec, nid); | 2390 | unsigned int wcaps = get_wcaps(codec, nid); |
2366 | if (wcaps & AC_WCAP_POWER) { | 2391 | if (wcaps & AC_WCAP_POWER) { |
2367 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> | 2392 | unsigned int wid_type = get_wcaps_type(wcaps); |
2368 | AC_WCAP_TYPE_SHIFT; | ||
2369 | if (power_state == AC_PWRST_D3 && | 2393 | if (power_state == AC_PWRST_D3 && |
2370 | wid_type == AC_WID_PIN) { | 2394 | wid_type == AC_WID_PIN) { |
2371 | unsigned int pincap; | 2395 | unsigned int pincap; |
@@ -2573,7 +2597,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, | |||
2573 | case 20: | 2597 | case 20: |
2574 | case 24: | 2598 | case 24: |
2575 | case 32: | 2599 | case 32: |
2576 | if (maxbps >= 32) | 2600 | if (maxbps >= 32 || format == SNDRV_PCM_FORMAT_FLOAT_LE) |
2577 | val |= 0x40; | 2601 | val |= 0x40; |
2578 | else if (maxbps >= 24) | 2602 | else if (maxbps >= 24) |
2579 | val |= 0x30; | 2603 | val |= 0x30; |
@@ -2700,11 +2724,12 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, | |||
2700 | bps = 20; | 2724 | bps = 20; |
2701 | } | 2725 | } |
2702 | } | 2726 | } |
2703 | else if (streams == AC_SUPFMT_FLOAT32) { | 2727 | if (streams & AC_SUPFMT_FLOAT32) { |
2704 | /* should be exclusive */ | ||
2705 | formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; | 2728 | formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; |
2706 | bps = 32; | 2729 | if (!bps) |
2707 | } else if (streams == AC_SUPFMT_AC3) { | 2730 | bps = 32; |
2731 | } | ||
2732 | if (streams == AC_SUPFMT_AC3) { | ||
2708 | /* should be exclusive */ | 2733 | /* should be exclusive */ |
2709 | /* temporary hack: we have still no proper support | 2734 | /* temporary hack: we have still no proper support |
2710 | * for the direct AC3 stream... | 2735 | * for the direct AC3 stream... |
@@ -3102,7 +3127,7 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec, | |||
3102 | tbl = q; | 3127 | tbl = q; |
3103 | 3128 | ||
3104 | if (tbl->value >= 0 && tbl->value < num_configs) { | 3129 | if (tbl->value >= 0 && tbl->value < num_configs) { |
3105 | #ifdef CONFIG_SND_DEBUG_DETECT | 3130 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
3106 | char tmp[10]; | 3131 | char tmp[10]; |
3107 | const char *model = NULL; | 3132 | const char *model = NULL; |
3108 | if (models) | 3133 | if (models) |
@@ -3655,8 +3680,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, | |||
3655 | end_nid = codec->start_nid + codec->num_nodes; | 3680 | end_nid = codec->start_nid + codec->num_nodes; |
3656 | for (nid = codec->start_nid; nid < end_nid; nid++) { | 3681 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
3657 | unsigned int wid_caps = get_wcaps(codec, nid); | 3682 | unsigned int wid_caps = get_wcaps(codec, nid); |
3658 | unsigned int wid_type = | 3683 | unsigned int wid_type = get_wcaps_type(wid_caps); |
3659 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
3660 | unsigned int def_conf; | 3684 | unsigned int def_conf; |
3661 | short assoc, loc; | 3685 | short assoc, loc; |
3662 | 3686 | ||
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 1b75f28ed092..99552fb5f756 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -830,7 +830,8 @@ enum { | |||
830 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, | 830 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, |
831 | struct hda_bus **busp); | 831 | struct hda_bus **busp); |
832 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 832 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
833 | int do_init, struct hda_codec **codecp); | 833 | struct hda_codec **codecp); |
834 | int snd_hda_codec_configure(struct hda_codec *codec); | ||
834 | 835 | ||
835 | /* | 836 | /* |
836 | * low level functions | 837 | * low level functions |
@@ -938,6 +939,13 @@ static inline void snd_hda_power_down(struct hda_codec *codec) {} | |||
938 | #define snd_hda_codec_needs_resume(codec) 1 | 939 | #define snd_hda_codec_needs_resume(codec) 1 |
939 | #endif | 940 | #endif |
940 | 941 | ||
942 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
943 | /* | ||
944 | * patch firmware | ||
945 | */ | ||
946 | int snd_hda_load_patch(struct hda_bus *bus, const char *patch); | ||
947 | #endif | ||
948 | |||
941 | /* | 949 | /* |
942 | * Codec modularization | 950 | * Codec modularization |
943 | */ | 951 | */ |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 1d5797a96682..b36f6c5a92df 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -121,11 +121,17 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid | |||
121 | if (node == NULL) | 121 | if (node == NULL) |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | node->nid = nid; | 123 | node->nid = nid; |
124 | nconns = snd_hda_get_connections(codec, nid, conn_list, | 124 | node->wid_caps = get_wcaps(codec, nid); |
125 | HDA_MAX_CONNECTIONS); | 125 | node->type = get_wcaps_type(node->wid_caps); |
126 | if (nconns < 0) { | 126 | if (node->wid_caps & AC_WCAP_CONN_LIST) { |
127 | kfree(node); | 127 | nconns = snd_hda_get_connections(codec, nid, conn_list, |
128 | return nconns; | 128 | HDA_MAX_CONNECTIONS); |
129 | if (nconns < 0) { | ||
130 | kfree(node); | ||
131 | return nconns; | ||
132 | } | ||
133 | } else { | ||
134 | nconns = 0; | ||
129 | } | 135 | } |
130 | if (nconns <= ARRAY_SIZE(node->slist)) | 136 | if (nconns <= ARRAY_SIZE(node->slist)) |
131 | node->conn_list = node->slist; | 137 | node->conn_list = node->slist; |
@@ -140,8 +146,6 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid | |||
140 | } | 146 | } |
141 | memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t)); | 147 | memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t)); |
142 | node->nconns = nconns; | 148 | node->nconns = nconns; |
143 | node->wid_caps = get_wcaps(codec, nid); | ||
144 | node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
145 | 149 | ||
146 | if (node->type == AC_WID_PIN) { | 150 | if (node->type == AC_WID_PIN) { |
147 | node->pin_caps = snd_hda_query_pin_caps(codec, node->nid); | 151 | node->pin_caps = snd_hda_query_pin_caps(codec, node->nid); |
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 6812fbe80fa4..cc24e6721d74 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/compat.h> | 24 | #include <linux/compat.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/ctype.h> | 26 | #include <linux/ctype.h> |
27 | #include <linux/firmware.h> | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include "hda_codec.h" | 29 | #include "hda_codec.h" |
29 | #include "hda_local.h" | 30 | #include "hda_local.h" |
@@ -312,12 +313,8 @@ static ssize_t init_verbs_show(struct device *dev, | |||
312 | return len; | 313 | return len; |
313 | } | 314 | } |
314 | 315 | ||
315 | static ssize_t init_verbs_store(struct device *dev, | 316 | static int parse_init_verbs(struct hda_codec *codec, const char *buf) |
316 | struct device_attribute *attr, | ||
317 | const char *buf, size_t count) | ||
318 | { | 317 | { |
319 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
320 | struct hda_codec *codec = hwdep->private_data; | ||
321 | struct hda_verb *v; | 318 | struct hda_verb *v; |
322 | int nid, verb, param; | 319 | int nid, verb, param; |
323 | 320 | ||
@@ -331,6 +328,18 @@ static ssize_t init_verbs_store(struct device *dev, | |||
331 | v->nid = nid; | 328 | v->nid = nid; |
332 | v->verb = verb; | 329 | v->verb = verb; |
333 | v->param = param; | 330 | v->param = param; |
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static ssize_t init_verbs_store(struct device *dev, | ||
335 | struct device_attribute *attr, | ||
336 | const char *buf, size_t count) | ||
337 | { | ||
338 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
339 | struct hda_codec *codec = hwdep->private_data; | ||
340 | int err = parse_init_verbs(codec, buf); | ||
341 | if (err < 0) | ||
342 | return err; | ||
334 | return count; | 343 | return count; |
335 | } | 344 | } |
336 | 345 | ||
@@ -376,19 +385,15 @@ static void remove_trail_spaces(char *str) | |||
376 | 385 | ||
377 | #define MAX_HINTS 1024 | 386 | #define MAX_HINTS 1024 |
378 | 387 | ||
379 | static ssize_t hints_store(struct device *dev, | 388 | static int parse_hints(struct hda_codec *codec, const char *buf) |
380 | struct device_attribute *attr, | ||
381 | const char *buf, size_t count) | ||
382 | { | 389 | { |
383 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
384 | struct hda_codec *codec = hwdep->private_data; | ||
385 | char *key, *val; | 390 | char *key, *val; |
386 | struct hda_hint *hint; | 391 | struct hda_hint *hint; |
387 | 392 | ||
388 | while (isspace(*buf)) | 393 | while (isspace(*buf)) |
389 | buf++; | 394 | buf++; |
390 | if (!*buf || *buf == '#' || *buf == '\n') | 395 | if (!*buf || *buf == '#' || *buf == '\n') |
391 | return count; | 396 | return 0; |
392 | if (*buf == '=') | 397 | if (*buf == '=') |
393 | return -EINVAL; | 398 | return -EINVAL; |
394 | key = kstrndup_noeol(buf, 1024); | 399 | key = kstrndup_noeol(buf, 1024); |
@@ -411,7 +416,7 @@ static ssize_t hints_store(struct device *dev, | |||
411 | kfree(hint->key); | 416 | kfree(hint->key); |
412 | hint->key = key; | 417 | hint->key = key; |
413 | hint->val = val; | 418 | hint->val = val; |
414 | return count; | 419 | return 0; |
415 | } | 420 | } |
416 | /* allocate a new hint entry */ | 421 | /* allocate a new hint entry */ |
417 | if (codec->hints.used >= MAX_HINTS) | 422 | if (codec->hints.used >= MAX_HINTS) |
@@ -424,6 +429,18 @@ static ssize_t hints_store(struct device *dev, | |||
424 | } | 429 | } |
425 | hint->key = key; | 430 | hint->key = key; |
426 | hint->val = val; | 431 | hint->val = val; |
432 | return 0; | ||
433 | } | ||
434 | |||
435 | static ssize_t hints_store(struct device *dev, | ||
436 | struct device_attribute *attr, | ||
437 | const char *buf, size_t count) | ||
438 | { | ||
439 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
440 | struct hda_codec *codec = hwdep->private_data; | ||
441 | int err = parse_hints(codec, buf); | ||
442 | if (err < 0) | ||
443 | return err; | ||
427 | return count; | 444 | return count; |
428 | } | 445 | } |
429 | 446 | ||
@@ -469,20 +486,24 @@ static ssize_t driver_pin_configs_show(struct device *dev, | |||
469 | 486 | ||
470 | #define MAX_PIN_CONFIGS 32 | 487 | #define MAX_PIN_CONFIGS 32 |
471 | 488 | ||
472 | static ssize_t user_pin_configs_store(struct device *dev, | 489 | static int parse_user_pin_configs(struct hda_codec *codec, const char *buf) |
473 | struct device_attribute *attr, | ||
474 | const char *buf, size_t count) | ||
475 | { | 490 | { |
476 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
477 | struct hda_codec *codec = hwdep->private_data; | ||
478 | int nid, cfg; | 491 | int nid, cfg; |
479 | int err; | ||
480 | 492 | ||
481 | if (sscanf(buf, "%i %i", &nid, &cfg) != 2) | 493 | if (sscanf(buf, "%i %i", &nid, &cfg) != 2) |
482 | return -EINVAL; | 494 | return -EINVAL; |
483 | if (!nid) | 495 | if (!nid) |
484 | return -EINVAL; | 496 | return -EINVAL; |
485 | err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg); | 497 | return snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg); |
498 | } | ||
499 | |||
500 | static ssize_t user_pin_configs_store(struct device *dev, | ||
501 | struct device_attribute *attr, | ||
502 | const char *buf, size_t count) | ||
503 | { | ||
504 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
505 | struct hda_codec *codec = hwdep->private_data; | ||
506 | int err = parse_user_pin_configs(codec, buf); | ||
486 | if (err < 0) | 507 | if (err < 0) |
487 | return err; | 508 | return err; |
488 | return count; | 509 | return count; |
@@ -553,3 +574,180 @@ int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key) | |||
553 | EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint); | 574 | EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint); |
554 | 575 | ||
555 | #endif /* CONFIG_SND_HDA_RECONFIG */ | 576 | #endif /* CONFIG_SND_HDA_RECONFIG */ |
577 | |||
578 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
579 | |||
580 | /* parser mode */ | ||
581 | enum { | ||
582 | LINE_MODE_NONE, | ||
583 | LINE_MODE_CODEC, | ||
584 | LINE_MODE_MODEL, | ||
585 | LINE_MODE_PINCFG, | ||
586 | LINE_MODE_VERB, | ||
587 | LINE_MODE_HINT, | ||
588 | NUM_LINE_MODES, | ||
589 | }; | ||
590 | |||
591 | static inline int strmatch(const char *a, const char *b) | ||
592 | { | ||
593 | return strnicmp(a, b, strlen(b)) == 0; | ||
594 | } | ||
595 | |||
596 | /* parse the contents after the line "[codec]" | ||
597 | * accept only the line with three numbers, and assign the current codec | ||
598 | */ | ||
599 | static void parse_codec_mode(char *buf, struct hda_bus *bus, | ||
600 | struct hda_codec **codecp) | ||
601 | { | ||
602 | unsigned int vendorid, subid, caddr; | ||
603 | struct hda_codec *codec; | ||
604 | |||
605 | *codecp = NULL; | ||
606 | if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) { | ||
607 | list_for_each_entry(codec, &bus->codec_list, list) { | ||
608 | if (codec->addr == caddr) { | ||
609 | *codecp = codec; | ||
610 | break; | ||
611 | } | ||
612 | } | ||
613 | } | ||
614 | } | ||
615 | |||
616 | /* parse the contents after the other command tags, [pincfg], [verb], | ||
617 | * [hint] and [model] | ||
618 | * just pass to the sysfs helper (only when any codec was specified) | ||
619 | */ | ||
620 | static void parse_pincfg_mode(char *buf, struct hda_bus *bus, | ||
621 | struct hda_codec **codecp) | ||
622 | { | ||
623 | if (!*codecp) | ||
624 | return; | ||
625 | parse_user_pin_configs(*codecp, buf); | ||
626 | } | ||
627 | |||
628 | static void parse_verb_mode(char *buf, struct hda_bus *bus, | ||
629 | struct hda_codec **codecp) | ||
630 | { | ||
631 | if (!*codecp) | ||
632 | return; | ||
633 | parse_init_verbs(*codecp, buf); | ||
634 | } | ||
635 | |||
636 | static void parse_hint_mode(char *buf, struct hda_bus *bus, | ||
637 | struct hda_codec **codecp) | ||
638 | { | ||
639 | if (!*codecp) | ||
640 | return; | ||
641 | parse_hints(*codecp, buf); | ||
642 | } | ||
643 | |||
644 | static void parse_model_mode(char *buf, struct hda_bus *bus, | ||
645 | struct hda_codec **codecp) | ||
646 | { | ||
647 | if (!*codecp) | ||
648 | return; | ||
649 | kfree((*codecp)->modelname); | ||
650 | (*codecp)->modelname = kstrdup(buf, GFP_KERNEL); | ||
651 | } | ||
652 | |||
653 | struct hda_patch_item { | ||
654 | const char *tag; | ||
655 | void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc); | ||
656 | }; | ||
657 | |||
658 | static struct hda_patch_item patch_items[NUM_LINE_MODES] = { | ||
659 | [LINE_MODE_CODEC] = { "[codec]", parse_codec_mode }, | ||
660 | [LINE_MODE_MODEL] = { "[model]", parse_model_mode }, | ||
661 | [LINE_MODE_VERB] = { "[verb]", parse_verb_mode }, | ||
662 | [LINE_MODE_PINCFG] = { "[pincfg]", parse_pincfg_mode }, | ||
663 | [LINE_MODE_HINT] = { "[hint]", parse_hint_mode }, | ||
664 | }; | ||
665 | |||
666 | /* check the line starting with '[' -- change the parser mode accodingly */ | ||
667 | static int parse_line_mode(char *buf, struct hda_bus *bus) | ||
668 | { | ||
669 | int i; | ||
670 | for (i = 0; i < ARRAY_SIZE(patch_items); i++) { | ||
671 | if (!patch_items[i].tag) | ||
672 | continue; | ||
673 | if (strmatch(buf, patch_items[i].tag)) | ||
674 | return i; | ||
675 | } | ||
676 | return LINE_MODE_NONE; | ||
677 | } | ||
678 | |||
679 | /* copy one line from the buffer in fw, and update the fields in fw | ||
680 | * return zero if it reaches to the end of the buffer, or non-zero | ||
681 | * if successfully copied a line | ||
682 | * | ||
683 | * the spaces at the beginning and the end of the line are stripped | ||
684 | */ | ||
685 | static int get_line_from_fw(char *buf, int size, struct firmware *fw) | ||
686 | { | ||
687 | int len; | ||
688 | const char *p = fw->data; | ||
689 | while (isspace(*p) && fw->size) { | ||
690 | p++; | ||
691 | fw->size--; | ||
692 | } | ||
693 | if (!fw->size) | ||
694 | return 0; | ||
695 | if (size < fw->size) | ||
696 | size = fw->size; | ||
697 | |||
698 | for (len = 0; len < fw->size; len++) { | ||
699 | if (!*p) | ||
700 | break; | ||
701 | if (*p == '\n') { | ||
702 | p++; | ||
703 | len++; | ||
704 | break; | ||
705 | } | ||
706 | if (len < size) | ||
707 | *buf++ = *p++; | ||
708 | } | ||
709 | *buf = 0; | ||
710 | fw->size -= len; | ||
711 | fw->data = p; | ||
712 | remove_trail_spaces(buf); | ||
713 | return 1; | ||
714 | } | ||
715 | |||
716 | /* | ||
717 | * load a "patch" firmware file and parse it | ||
718 | */ | ||
719 | int snd_hda_load_patch(struct hda_bus *bus, const char *patch) | ||
720 | { | ||
721 | int err; | ||
722 | const struct firmware *fw; | ||
723 | struct firmware tmp; | ||
724 | char buf[128]; | ||
725 | struct hda_codec *codec; | ||
726 | int line_mode; | ||
727 | struct device *dev = bus->card->dev; | ||
728 | |||
729 | if (snd_BUG_ON(!dev)) | ||
730 | return -ENODEV; | ||
731 | err = request_firmware(&fw, patch, dev); | ||
732 | if (err < 0) { | ||
733 | printk(KERN_ERR "hda-codec: Cannot load the patch '%s'\n", | ||
734 | patch); | ||
735 | return err; | ||
736 | } | ||
737 | |||
738 | tmp = *fw; | ||
739 | line_mode = LINE_MODE_NONE; | ||
740 | codec = NULL; | ||
741 | while (get_line_from_fw(buf, sizeof(buf) - 1, &tmp)) { | ||
742 | if (!*buf || *buf == '#' || *buf == '\n') | ||
743 | continue; | ||
744 | if (*buf == '[') | ||
745 | line_mode = parse_line_mode(buf, bus); | ||
746 | else if (patch_items[line_mode].parser) | ||
747 | patch_items[line_mode].parser(buf, bus, &codec); | ||
748 | } | ||
749 | release_firmware(fw); | ||
750 | return 0; | ||
751 | } | ||
752 | EXPORT_SYMBOL_HDA(snd_hda_load_patch); | ||
753 | #endif /* CONFIG_SND_HDA_PATCH_LOADER */ | ||
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 175f07a381ba..20a66f85f0a4 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -61,6 +61,9 @@ static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; | |||
61 | static int probe_only[SNDRV_CARDS]; | 61 | static int probe_only[SNDRV_CARDS]; |
62 | static int single_cmd; | 62 | static int single_cmd; |
63 | static int enable_msi; | 63 | static int enable_msi; |
64 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
65 | static char *patch[SNDRV_CARDS]; | ||
66 | #endif | ||
64 | 67 | ||
65 | module_param_array(index, int, NULL, 0444); | 68 | module_param_array(index, int, NULL, 0444); |
66 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); | 69 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); |
@@ -84,6 +87,10 @@ MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " | |||
84 | "(for debugging only)."); | 87 | "(for debugging only)."); |
85 | module_param(enable_msi, int, 0444); | 88 | module_param(enable_msi, int, 0444); |
86 | MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); | 89 | MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); |
90 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
91 | module_param_array(patch, charp, NULL, 0444); | ||
92 | MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface."); | ||
93 | #endif | ||
87 | 94 | ||
88 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 95 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
89 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; | 96 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; |
@@ -1331,8 +1338,7 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { | |||
1331 | [AZX_DRIVER_TERA] = 1, | 1338 | [AZX_DRIVER_TERA] = 1, |
1332 | }; | 1339 | }; |
1333 | 1340 | ||
1334 | static int __devinit azx_codec_create(struct azx *chip, const char *model, | 1341 | static int __devinit azx_codec_create(struct azx *chip, const char *model) |
1335 | int no_init) | ||
1336 | { | 1342 | { |
1337 | struct hda_bus_template bus_temp; | 1343 | struct hda_bus_template bus_temp; |
1338 | int c, codecs, err; | 1344 | int c, codecs, err; |
@@ -1391,7 +1397,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1391 | for (c = 0; c < max_slots; c++) { | 1397 | for (c = 0; c < max_slots; c++) { |
1392 | if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { | 1398 | if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { |
1393 | struct hda_codec *codec; | 1399 | struct hda_codec *codec; |
1394 | err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); | 1400 | err = snd_hda_codec_new(chip->bus, c, &codec); |
1395 | if (err < 0) | 1401 | if (err < 0) |
1396 | continue; | 1402 | continue; |
1397 | codecs++; | 1403 | codecs++; |
@@ -1401,7 +1407,16 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1401 | snd_printk(KERN_ERR SFX "no codecs initialized\n"); | 1407 | snd_printk(KERN_ERR SFX "no codecs initialized\n"); |
1402 | return -ENXIO; | 1408 | return -ENXIO; |
1403 | } | 1409 | } |
1410 | return 0; | ||
1411 | } | ||
1404 | 1412 | ||
1413 | /* configure each codec instance */ | ||
1414 | static int __devinit azx_codec_configure(struct azx *chip) | ||
1415 | { | ||
1416 | struct hda_codec *codec; | ||
1417 | list_for_each_entry(codec, &chip->bus->codec_list, list) { | ||
1418 | snd_hda_codec_configure(codec); | ||
1419 | } | ||
1405 | return 0; | 1420 | return 0; |
1406 | } | 1421 | } |
1407 | 1422 | ||
@@ -2284,6 +2299,30 @@ static void __devinit check_probe_mask(struct azx *chip, int dev) | |||
2284 | } | 2299 | } |
2285 | } | 2300 | } |
2286 | 2301 | ||
2302 | /* | ||
2303 | * white-list for enable_msi | ||
2304 | */ | ||
2305 | static struct snd_pci_quirk msi_white_list[] __devinitdata = { | ||
2306 | SND_PCI_QUIRK(0x103c, 0x3607, "HP Compa CQ40", 1), | ||
2307 | {} | ||
2308 | }; | ||
2309 | |||
2310 | static void __devinit check_msi(struct azx *chip) | ||
2311 | { | ||
2312 | const struct snd_pci_quirk *q; | ||
2313 | |||
2314 | chip->msi = enable_msi; | ||
2315 | if (chip->msi) | ||
2316 | return; | ||
2317 | q = snd_pci_quirk_lookup(chip->pci, msi_white_list); | ||
2318 | if (q) { | ||
2319 | printk(KERN_INFO | ||
2320 | "hda_intel: msi for device %04x:%04x set to %d\n", | ||
2321 | q->subvendor, q->subdevice, q->value); | ||
2322 | chip->msi = q->value; | ||
2323 | } | ||
2324 | } | ||
2325 | |||
2287 | 2326 | ||
2288 | /* | 2327 | /* |
2289 | * constructor | 2328 | * constructor |
@@ -2318,7 +2357,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2318 | chip->pci = pci; | 2357 | chip->pci = pci; |
2319 | chip->irq = -1; | 2358 | chip->irq = -1; |
2320 | chip->driver_type = driver_type; | 2359 | chip->driver_type = driver_type; |
2321 | chip->msi = enable_msi; | 2360 | check_msi(chip); |
2322 | chip->dev_index = dev; | 2361 | chip->dev_index = dev; |
2323 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); | 2362 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); |
2324 | 2363 | ||
@@ -2526,15 +2565,32 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2526 | return err; | 2565 | return err; |
2527 | } | 2566 | } |
2528 | 2567 | ||
2568 | /* set this here since it's referred in snd_hda_load_patch() */ | ||
2569 | snd_card_set_dev(card, &pci->dev); | ||
2570 | |||
2529 | err = azx_create(card, pci, dev, pci_id->driver_data, &chip); | 2571 | err = azx_create(card, pci, dev, pci_id->driver_data, &chip); |
2530 | if (err < 0) | 2572 | if (err < 0) |
2531 | goto out_free; | 2573 | goto out_free; |
2532 | card->private_data = chip; | 2574 | card->private_data = chip; |
2533 | 2575 | ||
2534 | /* create codec instances */ | 2576 | /* create codec instances */ |
2535 | err = azx_codec_create(chip, model[dev], probe_only[dev]); | 2577 | err = azx_codec_create(chip, model[dev]); |
2536 | if (err < 0) | 2578 | if (err < 0) |
2537 | goto out_free; | 2579 | goto out_free; |
2580 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
2581 | if (patch[dev]) { | ||
2582 | snd_printk(KERN_ERR SFX "Applying patch firmware '%s'\n", | ||
2583 | patch[dev]); | ||
2584 | err = snd_hda_load_patch(chip->bus, patch[dev]); | ||
2585 | if (err < 0) | ||
2586 | goto out_free; | ||
2587 | } | ||
2588 | #endif | ||
2589 | if (!probe_only[dev]) { | ||
2590 | err = azx_codec_configure(chip); | ||
2591 | if (err < 0) | ||
2592 | goto out_free; | ||
2593 | } | ||
2538 | 2594 | ||
2539 | /* create PCM streams */ | 2595 | /* create PCM streams */ |
2540 | err = snd_hda_build_pcms(chip->bus); | 2596 | err = snd_hda_build_pcms(chip->bus); |
@@ -2546,8 +2602,6 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2546 | if (err < 0) | 2602 | if (err < 0) |
2547 | goto out_free; | 2603 | goto out_free; |
2548 | 2604 | ||
2549 | snd_card_set_dev(card, &pci->dev); | ||
2550 | |||
2551 | err = snd_card_register(card); | 2605 | err = snd_card_register(card); |
2552 | if (err < 0) | 2606 | if (err < 0) |
2553 | goto out_free; | 2607 | goto out_free; |
@@ -2649,11 +2703,15 @@ static struct pci_device_id azx_ids[] = { | |||
2649 | /* this entry seems still valid -- i.e. without emu20kx chip */ | 2703 | /* this entry seems still valid -- i.e. without emu20kx chip */ |
2650 | { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, | 2704 | { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, |
2651 | #endif | 2705 | #endif |
2652 | /* AMD Generic, PCI class code and Vendor ID for HD Audio */ | 2706 | /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */ |
2653 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), | 2707 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), |
2654 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, | 2708 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, |
2655 | .class_mask = 0xffffff, | 2709 | .class_mask = 0xffffff, |
2656 | .driver_data = AZX_DRIVER_GENERIC }, | 2710 | .driver_data = AZX_DRIVER_GENERIC }, |
2711 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_ANY_ID), | ||
2712 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, | ||
2713 | .class_mask = 0xffffff, | ||
2714 | .driver_data = AZX_DRIVER_GENERIC }, | ||
2657 | { 0, } | 2715 | { 0, } |
2658 | }; | 2716 | }; |
2659 | MODULE_DEVICE_TABLE(pci, azx_ids); | 2717 | MODULE_DEVICE_TABLE(pci, azx_ids); |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 83349013b4df..5f1dcc59002b 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -99,7 +99,6 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, | |||
99 | int snd_hda_add_vmaster(struct hda_codec *codec, char *name, | 99 | int snd_hda_add_vmaster(struct hda_codec *codec, char *name, |
100 | unsigned int *tlv, const char **slaves); | 100 | unsigned int *tlv, const char **slaves); |
101 | int snd_hda_codec_reset(struct hda_codec *codec); | 101 | int snd_hda_codec_reset(struct hda_codec *codec); |
102 | int snd_hda_codec_configure(struct hda_codec *codec); | ||
103 | 102 | ||
104 | /* amp value bits */ | 103 | /* amp value bits */ |
105 | #define HDA_AMP_MUTE 0x80 | 104 | #define HDA_AMP_MUTE 0x80 |
@@ -408,6 +407,19 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) | |||
408 | return codec->wcaps[nid - codec->start_nid]; | 407 | return codec->wcaps[nid - codec->start_nid]; |
409 | } | 408 | } |
410 | 409 | ||
410 | /* get the widget type from widget capability bits */ | ||
411 | #define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT) | ||
412 | |||
413 | static inline unsigned int get_wcaps_channels(u32 wcaps) | ||
414 | { | ||
415 | unsigned int chans; | ||
416 | |||
417 | chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13; | ||
418 | chans = ((chans << 1) | 1) + 1; | ||
419 | |||
420 | return chans; | ||
421 | } | ||
422 | |||
411 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); | 423 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); |
412 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, | 424 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, |
413 | unsigned int caps); | 425 | unsigned int caps); |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 418c5d1badaa..95f24e4729f8 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -508,17 +508,14 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
508 | unsigned int wid_caps = | 508 | unsigned int wid_caps = |
509 | snd_hda_param_read(codec, nid, | 509 | snd_hda_param_read(codec, nid, |
510 | AC_PAR_AUDIO_WIDGET_CAP); | 510 | AC_PAR_AUDIO_WIDGET_CAP); |
511 | unsigned int wid_type = | 511 | unsigned int wid_type = get_wcaps_type(wid_caps); |
512 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
513 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | 512 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
514 | int conn_len = 0; | 513 | int conn_len = 0; |
515 | 514 | ||
516 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, | 515 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, |
517 | get_wid_type_name(wid_type), wid_caps); | 516 | get_wid_type_name(wid_type), wid_caps); |
518 | if (wid_caps & AC_WCAP_STEREO) { | 517 | if (wid_caps & AC_WCAP_STEREO) { |
519 | unsigned int chans; | 518 | unsigned int chans = get_wcaps_channels(wid_caps); |
520 | chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13; | ||
521 | chans = ((chans << 1) | 1) + 1; | ||
522 | if (chans == 2) | 519 | if (chans == 2) |
523 | snd_iprintf(buffer, " Stereo"); | 520 | snd_iprintf(buffer, " Stereo"); |
524 | else | 521 | else |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 3da85caf8af1..215e72a87113 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -2982,7 +2982,8 @@ static int patch_ad1988(struct hda_codec *codec) | |||
2982 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, | 2982 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, |
2983 | ad1988_models, ad1988_cfg_tbl); | 2983 | ad1988_models, ad1988_cfg_tbl); |
2984 | if (board_config < 0) { | 2984 | if (board_config < 0) { |
2985 | printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); | 2985 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
2986 | codec->chip_name); | ||
2986 | board_config = AD1988_AUTO; | 2987 | board_config = AD1988_AUTO; |
2987 | } | 2988 | } |
2988 | 2989 | ||
@@ -3702,19 +3703,29 @@ static struct hda_amp_list ad1884a_loopbacks[] = { | |||
3702 | * Port F: Internal speakers | 3703 | * Port F: Internal speakers |
3703 | */ | 3704 | */ |
3704 | 3705 | ||
3705 | static struct hda_input_mux ad1884a_laptop_capture_source = { | 3706 | static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol, |
3706 | .num_items = 4, | 3707 | struct snd_ctl_elem_value *ucontrol) |
3707 | .items = { | 3708 | { |
3708 | { "Mic", 0x0 }, /* port-B */ | 3709 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
3709 | { "Internal Mic", 0x1 }, /* port-C */ | 3710 | int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
3710 | { "Dock Mic", 0x4 }, /* port-E */ | 3711 | int mute = (!ucontrol->value.integer.value[0] && |
3711 | { "Mix", 0x3 }, | 3712 | !ucontrol->value.integer.value[1]); |
3712 | }, | 3713 | /* toggle GPIO1 according to the mute state */ |
3713 | }; | 3714 | snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
3715 | mute ? 0x02 : 0x0); | ||
3716 | return ret; | ||
3717 | } | ||
3714 | 3718 | ||
3715 | static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { | 3719 | static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { |
3716 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), | 3720 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
3717 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), | 3721 | { |
3722 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
3723 | .name = "Master Playback Switch", | ||
3724 | .info = snd_hda_mixer_amp_switch_info, | ||
3725 | .get = snd_hda_mixer_amp_switch_get, | ||
3726 | .put = ad1884a_mobile_master_sw_put, | ||
3727 | .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
3728 | }, | ||
3718 | HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT), | 3729 | HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
3719 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), | 3730 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
3720 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), | 3731 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
@@ -3729,36 +3740,9 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { | |||
3729 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), | 3740 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), |
3730 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), | 3741 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
3731 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), | 3742 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
3732 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), | ||
3733 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), | ||
3734 | { | ||
3735 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
3736 | /* The multiple "Capture Source" controls confuse alsamixer | ||
3737 | * So call somewhat different.. | ||
3738 | */ | ||
3739 | /* .name = "Capture Source", */ | ||
3740 | .name = "Input Source", | ||
3741 | .count = 2, | ||
3742 | .info = ad198x_mux_enum_info, | ||
3743 | .get = ad198x_mux_enum_get, | ||
3744 | .put = ad198x_mux_enum_put, | ||
3745 | }, | ||
3746 | { } /* end */ | 3743 | { } /* end */ |
3747 | }; | 3744 | }; |
3748 | 3745 | ||
3749 | static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol, | ||
3750 | struct snd_ctl_elem_value *ucontrol) | ||
3751 | { | ||
3752 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3753 | int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); | ||
3754 | int mute = (!ucontrol->value.integer.value[0] && | ||
3755 | !ucontrol->value.integer.value[1]); | ||
3756 | /* toggle GPIO1 according to the mute state */ | ||
3757 | snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | ||
3758 | mute ? 0x02 : 0x0); | ||
3759 | return ret; | ||
3760 | } | ||
3761 | |||
3762 | static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { | 3746 | static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { |
3763 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), | 3747 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
3764 | /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ | 3748 | /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ |
@@ -3828,6 +3812,63 @@ static int ad1884a_hp_init(struct hda_codec *codec) | |||
3828 | return 0; | 3812 | return 0; |
3829 | } | 3813 | } |
3830 | 3814 | ||
3815 | /* mute internal speaker if HP or docking HP is plugged */ | ||
3816 | static void ad1884a_laptop_automute(struct hda_codec *codec) | ||
3817 | { | ||
3818 | unsigned int present; | ||
3819 | |||
3820 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0); | ||
3821 | present &= AC_PINSENSE_PRESENCE; | ||
3822 | if (!present) { | ||
3823 | present = snd_hda_codec_read(codec, 0x12, 0, | ||
3824 | AC_VERB_GET_PIN_SENSE, 0); | ||
3825 | present &= AC_PINSENSE_PRESENCE; | ||
3826 | } | ||
3827 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
3828 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
3829 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, | ||
3830 | present ? 0x00 : 0x02); | ||
3831 | } | ||
3832 | |||
3833 | /* switch to external mic if plugged */ | ||
3834 | static void ad1884a_laptop_automic(struct hda_codec *codec) | ||
3835 | { | ||
3836 | unsigned int idx; | ||
3837 | |||
3838 | if (snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) & | ||
3839 | AC_PINSENSE_PRESENCE) | ||
3840 | idx = 0; | ||
3841 | else if (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) & | ||
3842 | AC_PINSENSE_PRESENCE) | ||
3843 | idx = 4; | ||
3844 | else | ||
3845 | idx = 1; | ||
3846 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, idx); | ||
3847 | } | ||
3848 | |||
3849 | /* unsolicited event for HP jack sensing */ | ||
3850 | static void ad1884a_laptop_unsol_event(struct hda_codec *codec, | ||
3851 | unsigned int res) | ||
3852 | { | ||
3853 | switch (res >> 26) { | ||
3854 | case AD1884A_HP_EVENT: | ||
3855 | ad1884a_laptop_automute(codec); | ||
3856 | break; | ||
3857 | case AD1884A_MIC_EVENT: | ||
3858 | ad1884a_laptop_automic(codec); | ||
3859 | break; | ||
3860 | } | ||
3861 | } | ||
3862 | |||
3863 | /* initialize jack-sensing, too */ | ||
3864 | static int ad1884a_laptop_init(struct hda_codec *codec) | ||
3865 | { | ||
3866 | ad198x_init(codec); | ||
3867 | ad1884a_laptop_automute(codec); | ||
3868 | ad1884a_laptop_automic(codec); | ||
3869 | return 0; | ||
3870 | } | ||
3871 | |||
3831 | /* additional verbs for laptop model */ | 3872 | /* additional verbs for laptop model */ |
3832 | static struct hda_verb ad1884a_laptop_verbs[] = { | 3873 | static struct hda_verb ad1884a_laptop_verbs[] = { |
3833 | /* Port-A (HP) pin - always unmuted */ | 3874 | /* Port-A (HP) pin - always unmuted */ |
@@ -3835,18 +3876,28 @@ static struct hda_verb ad1884a_laptop_verbs[] = { | |||
3835 | /* Port-F (int speaker) mixer - route only from analog mixer */ | 3876 | /* Port-F (int speaker) mixer - route only from analog mixer */ |
3836 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 3877 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3837 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 3878 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
3838 | /* Port-F pin */ | 3879 | /* Port-F (int speaker) pin */ |
3839 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 3880 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3840 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | 3881 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3882 | /* required for compaq 6530s/6531s speaker output */ | ||
3883 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
3841 | /* Port-C pin - internal mic-in */ | 3884 | /* Port-C pin - internal mic-in */ |
3842 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 3885 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
3843 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ | 3886 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
3844 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ | 3887 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
3888 | /* Port-D (docking line-out) pin - default unmuted */ | ||
3889 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
3845 | /* analog mix */ | 3890 | /* analog mix */ |
3846 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | 3891 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
3847 | /* unsolicited event for pin-sense */ | 3892 | /* unsolicited event for pin-sense */ |
3848 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, | 3893 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
3894 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, | ||
3849 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, | 3895 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
3896 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, | ||
3897 | /* allow to touch GPIO1 (for mute control) */ | ||
3898 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | ||
3899 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | ||
3900 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */ | ||
3850 | { } /* end */ | 3901 | { } /* end */ |
3851 | }; | 3902 | }; |
3852 | 3903 | ||
@@ -4006,6 +4057,7 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = { | |||
4006 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP), | 4057 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP), |
4007 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP), | 4058 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP), |
4008 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), | 4059 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), |
4060 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE), | ||
4009 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), | 4061 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), |
4010 | {} | 4062 | {} |
4011 | }; | 4063 | }; |
@@ -4055,9 +4107,8 @@ static int patch_ad1884a(struct hda_codec *codec) | |||
4055 | spec->mixers[0] = ad1884a_laptop_mixers; | 4107 | spec->mixers[0] = ad1884a_laptop_mixers; |
4056 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; | 4108 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; |
4057 | spec->multiout.dig_out_nid = 0; | 4109 | spec->multiout.dig_out_nid = 0; |
4058 | spec->input_mux = &ad1884a_laptop_capture_source; | 4110 | codec->patch_ops.unsol_event = ad1884a_laptop_unsol_event; |
4059 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; | 4111 | codec->patch_ops.init = ad1884a_laptop_init; |
4060 | codec->patch_ops.init = ad1884a_hp_init; | ||
4061 | /* set the upper-limit for mixer amp to 0dB for avoiding the | 4112 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
4062 | * possible damage by overloading | 4113 | * possible damage by overloading |
4063 | */ | 4114 | */ |
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c index 233e4778bba9..fb684f00156b 100644 --- a/sound/pci/hda/patch_atihdmi.c +++ b/sound/pci/hda/patch_atihdmi.c | |||
@@ -141,8 +141,7 @@ static int atihdmi_build_pcms(struct hda_codec *codec) | |||
141 | /* FIXME: we must check ELD and change the PCM parameters dynamically | 141 | /* FIXME: we must check ELD and change the PCM parameters dynamically |
142 | */ | 142 | */ |
143 | chans = get_wcaps(codec, CVT_NID); | 143 | chans = get_wcaps(codec, CVT_NID); |
144 | chans = (chans & AC_WCAP_CHAN_CNT_EXT) >> 13; | 144 | chans = get_wcaps_channels(chans); |
145 | chans = ((chans << 1) | 1) + 1; | ||
146 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; | 145 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; |
147 | 146 | ||
148 | return 0; | 147 | return 0; |
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index 019ca7cb56d7..d08353d3bb7f 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c | |||
@@ -459,8 +459,7 @@ static void parse_input(struct hda_codec *codec) | |||
459 | nid = codec->start_nid; | 459 | nid = codec->start_nid; |
460 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 460 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
461 | unsigned int wcaps = get_wcaps(codec, nid); | 461 | unsigned int wcaps = get_wcaps(codec, nid); |
462 | unsigned int type = (wcaps & AC_WCAP_TYPE) >> | 462 | unsigned int type = get_wcaps_type(wcaps); |
463 | AC_WCAP_TYPE_SHIFT; | ||
464 | if (type != AC_WID_AUD_IN) | 463 | if (type != AC_WID_AUD_IN) |
465 | continue; | 464 | continue; |
466 | if (snd_hda_get_connections(codec, nid, &pin, 1) != 1) | 465 | if (snd_hda_get_connections(codec, nid, &pin, 1) != 1) |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c new file mode 100644 index 000000000000..8ba306856d38 --- /dev/null +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -0,0 +1,1194 @@ | |||
1 | /* | ||
2 | * HD audio interface patch for Cirrus Logic CS420x chip | ||
3 | * | ||
4 | * Copyright (c) 2009 Takashi Iwai <tiwai@suse.de> | ||
5 | * | ||
6 | * This driver is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This driver is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/init.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <sound/core.h> | ||
26 | #include "hda_codec.h" | ||
27 | #include "hda_local.h" | ||
28 | |||
29 | /* | ||
30 | */ | ||
31 | |||
32 | struct cs_spec { | ||
33 | int board_config; | ||
34 | struct auto_pin_cfg autocfg; | ||
35 | struct hda_multi_out multiout; | ||
36 | struct snd_kcontrol *vmaster_sw; | ||
37 | struct snd_kcontrol *vmaster_vol; | ||
38 | |||
39 | hda_nid_t dac_nid[AUTO_CFG_MAX_OUTS]; | ||
40 | hda_nid_t slave_dig_outs[2]; | ||
41 | |||
42 | unsigned int input_idx[AUTO_PIN_LAST]; | ||
43 | unsigned int capsrc_idx[AUTO_PIN_LAST]; | ||
44 | hda_nid_t adc_nid[AUTO_PIN_LAST]; | ||
45 | unsigned int adc_idx[AUTO_PIN_LAST]; | ||
46 | unsigned int num_inputs; | ||
47 | unsigned int cur_input; | ||
48 | unsigned int automic_idx; | ||
49 | hda_nid_t cur_adc; | ||
50 | unsigned int cur_adc_stream_tag; | ||
51 | unsigned int cur_adc_format; | ||
52 | hda_nid_t dig_in; | ||
53 | |||
54 | struct hda_bind_ctls *capture_bind[2]; | ||
55 | |||
56 | unsigned int gpio_mask; | ||
57 | unsigned int gpio_dir; | ||
58 | unsigned int gpio_data; | ||
59 | |||
60 | struct hda_pcm pcm_rec[2]; /* PCM information */ | ||
61 | |||
62 | unsigned int hp_detect:1; | ||
63 | unsigned int mic_detect:1; | ||
64 | }; | ||
65 | |||
66 | /* available models */ | ||
67 | enum { | ||
68 | CS420X_MBP55, | ||
69 | CS420X_AUTO, | ||
70 | CS420X_MODELS | ||
71 | }; | ||
72 | |||
73 | /* Vendor-specific processing widget */ | ||
74 | #define CS420X_VENDOR_NID 0x11 | ||
75 | #define CS_DIG_OUT1_PIN_NID 0x10 | ||
76 | #define CS_DIG_OUT2_PIN_NID 0x15 | ||
77 | #define CS_DMIC1_PIN_NID 0x12 | ||
78 | #define CS_DMIC2_PIN_NID 0x0e | ||
79 | |||
80 | /* coef indices */ | ||
81 | #define IDX_SPDIF_STAT 0x0000 | ||
82 | #define IDX_SPDIF_CTL 0x0001 | ||
83 | #define IDX_ADC_CFG 0x0002 | ||
84 | /* SZC bitmask, 4 modes below: | ||
85 | * 0 = immediate, | ||
86 | * 1 = digital immediate, analog zero-cross | ||
87 | * 2 = digtail & analog soft-ramp | ||
88 | * 3 = digital soft-ramp, analog zero-cross | ||
89 | */ | ||
90 | #define CS_COEF_ADC_SZC_MASK (3 << 0) | ||
91 | #define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */ | ||
92 | #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */ | ||
93 | /* PGA mode: 0 = differential, 1 = signle-ended */ | ||
94 | #define CS_COEF_ADC_MIC_PGA_MODE (1 << 5) /* PGA setup for mic */ | ||
95 | #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */ | ||
96 | #define IDX_DAC_CFG 0x0003 | ||
97 | /* SZC bitmask, 4 modes below: | ||
98 | * 0 = Immediate | ||
99 | * 1 = zero-cross | ||
100 | * 2 = soft-ramp | ||
101 | * 3 = soft-ramp on zero-cross | ||
102 | */ | ||
103 | #define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */ | ||
104 | #define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */ | ||
105 | #define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */ | ||
106 | |||
107 | #define IDX_BEEP_CFG 0x0004 | ||
108 | /* 0x0008 - test reg key */ | ||
109 | /* 0x0009 - 0x0014 -> 12 test regs */ | ||
110 | /* 0x0015 - visibility reg */ | ||
111 | |||
112 | |||
113 | static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx) | ||
114 | { | ||
115 | snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, | ||
116 | AC_VERB_SET_COEF_INDEX, idx); | ||
117 | return snd_hda_codec_read(codec, CS420X_VENDOR_NID, 0, | ||
118 | AC_VERB_GET_PROC_COEF, 0); | ||
119 | } | ||
120 | |||
121 | static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, | ||
122 | unsigned int coef) | ||
123 | { | ||
124 | snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, | ||
125 | AC_VERB_SET_COEF_INDEX, idx); | ||
126 | snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, | ||
127 | AC_VERB_SET_PROC_COEF, coef); | ||
128 | } | ||
129 | |||
130 | |||
131 | #define HP_EVENT 1 | ||
132 | #define MIC_EVENT 2 | ||
133 | |||
134 | /* | ||
135 | * PCM callbacks | ||
136 | */ | ||
137 | static int cs_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
138 | struct hda_codec *codec, | ||
139 | struct snd_pcm_substream *substream) | ||
140 | { | ||
141 | struct cs_spec *spec = codec->spec; | ||
142 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, | ||
143 | hinfo); | ||
144 | } | ||
145 | |||
146 | static int cs_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
147 | struct hda_codec *codec, | ||
148 | unsigned int stream_tag, | ||
149 | unsigned int format, | ||
150 | struct snd_pcm_substream *substream) | ||
151 | { | ||
152 | struct cs_spec *spec = codec->spec; | ||
153 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | ||
154 | stream_tag, format, substream); | ||
155 | } | ||
156 | |||
157 | static int cs_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
158 | struct hda_codec *codec, | ||
159 | struct snd_pcm_substream *substream) | ||
160 | { | ||
161 | struct cs_spec *spec = codec->spec; | ||
162 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Digital out | ||
167 | */ | ||
168 | static int cs_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
169 | struct hda_codec *codec, | ||
170 | struct snd_pcm_substream *substream) | ||
171 | { | ||
172 | struct cs_spec *spec = codec->spec; | ||
173 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | ||
174 | } | ||
175 | |||
176 | static int cs_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | ||
177 | struct hda_codec *codec, | ||
178 | struct snd_pcm_substream *substream) | ||
179 | { | ||
180 | struct cs_spec *spec = codec->spec; | ||
181 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | ||
182 | } | ||
183 | |||
184 | static int cs_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
185 | struct hda_codec *codec, | ||
186 | unsigned int stream_tag, | ||
187 | unsigned int format, | ||
188 | struct snd_pcm_substream *substream) | ||
189 | { | ||
190 | struct cs_spec *spec = codec->spec; | ||
191 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, | ||
192 | format, substream); | ||
193 | } | ||
194 | |||
195 | static int cs_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
196 | struct hda_codec *codec, | ||
197 | struct snd_pcm_substream *substream) | ||
198 | { | ||
199 | struct cs_spec *spec = codec->spec; | ||
200 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * Analog capture | ||
205 | */ | ||
206 | static int cs_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
207 | struct hda_codec *codec, | ||
208 | unsigned int stream_tag, | ||
209 | unsigned int format, | ||
210 | struct snd_pcm_substream *substream) | ||
211 | { | ||
212 | struct cs_spec *spec = codec->spec; | ||
213 | spec->cur_adc = spec->adc_nid[spec->cur_input]; | ||
214 | spec->cur_adc_stream_tag = stream_tag; | ||
215 | spec->cur_adc_format = format; | ||
216 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int cs_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
221 | struct hda_codec *codec, | ||
222 | struct snd_pcm_substream *substream) | ||
223 | { | ||
224 | struct cs_spec *spec = codec->spec; | ||
225 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); | ||
226 | spec->cur_adc = 0; | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | /* | ||
231 | */ | ||
232 | static struct hda_pcm_stream cs_pcm_analog_playback = { | ||
233 | .substreams = 1, | ||
234 | .channels_min = 2, | ||
235 | .channels_max = 2, | ||
236 | .ops = { | ||
237 | .open = cs_playback_pcm_open, | ||
238 | .prepare = cs_playback_pcm_prepare, | ||
239 | .cleanup = cs_playback_pcm_cleanup | ||
240 | }, | ||
241 | }; | ||
242 | |||
243 | static struct hda_pcm_stream cs_pcm_analog_capture = { | ||
244 | .substreams = 1, | ||
245 | .channels_min = 2, | ||
246 | .channels_max = 2, | ||
247 | .ops = { | ||
248 | .prepare = cs_capture_pcm_prepare, | ||
249 | .cleanup = cs_capture_pcm_cleanup | ||
250 | }, | ||
251 | }; | ||
252 | |||
253 | static struct hda_pcm_stream cs_pcm_digital_playback = { | ||
254 | .substreams = 1, | ||
255 | .channels_min = 2, | ||
256 | .channels_max = 2, | ||
257 | .ops = { | ||
258 | .open = cs_dig_playback_pcm_open, | ||
259 | .close = cs_dig_playback_pcm_close, | ||
260 | .prepare = cs_dig_playback_pcm_prepare, | ||
261 | .cleanup = cs_dig_playback_pcm_cleanup | ||
262 | }, | ||
263 | }; | ||
264 | |||
265 | static struct hda_pcm_stream cs_pcm_digital_capture = { | ||
266 | .substreams = 1, | ||
267 | .channels_min = 2, | ||
268 | .channels_max = 2, | ||
269 | }; | ||
270 | |||
271 | static int cs_build_pcms(struct hda_codec *codec) | ||
272 | { | ||
273 | struct cs_spec *spec = codec->spec; | ||
274 | struct hda_pcm *info = spec->pcm_rec; | ||
275 | |||
276 | codec->pcm_info = info; | ||
277 | codec->num_pcms = 0; | ||
278 | |||
279 | info->name = "Cirrus Analog"; | ||
280 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cs_pcm_analog_playback; | ||
281 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dac_nid[0]; | ||
282 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = | ||
283 | spec->multiout.max_channels; | ||
284 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = cs_pcm_analog_capture; | ||
285 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | ||
286 | spec->adc_nid[spec->cur_input]; | ||
287 | codec->num_pcms++; | ||
288 | |||
289 | if (!spec->multiout.dig_out_nid && !spec->dig_in) | ||
290 | return 0; | ||
291 | |||
292 | info++; | ||
293 | info->name = "Cirrus Digital"; | ||
294 | info->pcm_type = spec->autocfg.dig_out_type[0]; | ||
295 | if (!info->pcm_type) | ||
296 | info->pcm_type = HDA_PCM_TYPE_SPDIF; | ||
297 | if (spec->multiout.dig_out_nid) { | ||
298 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | ||
299 | cs_pcm_digital_playback; | ||
300 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | ||
301 | spec->multiout.dig_out_nid; | ||
302 | } | ||
303 | if (spec->dig_in) { | ||
304 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | ||
305 | cs_pcm_digital_capture; | ||
306 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in; | ||
307 | } | ||
308 | codec->num_pcms++; | ||
309 | |||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | /* | ||
314 | * parse codec topology | ||
315 | */ | ||
316 | |||
317 | static hda_nid_t get_dac(struct hda_codec *codec, hda_nid_t pin) | ||
318 | { | ||
319 | hda_nid_t dac; | ||
320 | if (!pin) | ||
321 | return 0; | ||
322 | if (snd_hda_get_connections(codec, pin, &dac, 1) != 1) | ||
323 | return 0; | ||
324 | return dac; | ||
325 | } | ||
326 | |||
327 | static int is_ext_mic(struct hda_codec *codec, unsigned int idx) | ||
328 | { | ||
329 | struct cs_spec *spec = codec->spec; | ||
330 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
331 | hda_nid_t pin = cfg->input_pins[idx]; | ||
332 | unsigned int val = snd_hda_query_pin_caps(codec, pin); | ||
333 | if (!(val & AC_PINCAP_PRES_DETECT)) | ||
334 | return 0; | ||
335 | val = snd_hda_codec_get_pincfg(codec, pin); | ||
336 | return (get_defcfg_connect(val) == AC_JACK_PORT_COMPLEX); | ||
337 | } | ||
338 | |||
339 | static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, | ||
340 | unsigned int *idxp) | ||
341 | { | ||
342 | int i; | ||
343 | hda_nid_t nid; | ||
344 | |||
345 | nid = codec->start_nid; | ||
346 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
347 | hda_nid_t pins[2]; | ||
348 | unsigned int type; | ||
349 | int j, nums; | ||
350 | type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) | ||
351 | >> AC_WCAP_TYPE_SHIFT; | ||
352 | if (type != AC_WID_AUD_IN) | ||
353 | continue; | ||
354 | nums = snd_hda_get_connections(codec, nid, pins, | ||
355 | ARRAY_SIZE(pins)); | ||
356 | if (nums <= 0) | ||
357 | continue; | ||
358 | for (j = 0; j < nums; j++) { | ||
359 | if (pins[j] == pin) { | ||
360 | *idxp = j; | ||
361 | return nid; | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | static int is_active_pin(struct hda_codec *codec, hda_nid_t nid) | ||
369 | { | ||
370 | unsigned int val; | ||
371 | val = snd_hda_codec_get_pincfg(codec, nid); | ||
372 | return (get_defcfg_connect(val) != AC_JACK_PORT_NONE); | ||
373 | } | ||
374 | |||
375 | static int parse_output(struct hda_codec *codec) | ||
376 | { | ||
377 | struct cs_spec *spec = codec->spec; | ||
378 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
379 | int i, extra_nids; | ||
380 | hda_nid_t dac; | ||
381 | |||
382 | for (i = 0; i < cfg->line_outs; i++) { | ||
383 | dac = get_dac(codec, cfg->line_out_pins[i]); | ||
384 | if (!dac) | ||
385 | break; | ||
386 | spec->dac_nid[i] = dac; | ||
387 | } | ||
388 | spec->multiout.num_dacs = i; | ||
389 | spec->multiout.dac_nids = spec->dac_nid; | ||
390 | spec->multiout.max_channels = i * 2; | ||
391 | |||
392 | /* add HP and speakers */ | ||
393 | extra_nids = 0; | ||
394 | for (i = 0; i < cfg->hp_outs; i++) { | ||
395 | dac = get_dac(codec, cfg->hp_pins[i]); | ||
396 | if (!dac) | ||
397 | break; | ||
398 | if (!i) | ||
399 | spec->multiout.hp_nid = dac; | ||
400 | else | ||
401 | spec->multiout.extra_out_nid[extra_nids++] = dac; | ||
402 | } | ||
403 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
404 | dac = get_dac(codec, cfg->speaker_pins[i]); | ||
405 | if (!dac) | ||
406 | break; | ||
407 | spec->multiout.extra_out_nid[extra_nids++] = dac; | ||
408 | } | ||
409 | |||
410 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | ||
411 | cfg->speaker_outs = cfg->line_outs; | ||
412 | memcpy(cfg->speaker_pins, cfg->line_out_pins, | ||
413 | sizeof(cfg->speaker_pins)); | ||
414 | cfg->line_outs = 0; | ||
415 | } | ||
416 | |||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static int parse_input(struct hda_codec *codec) | ||
421 | { | ||
422 | struct cs_spec *spec = codec->spec; | ||
423 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
424 | int i; | ||
425 | |||
426 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
427 | hda_nid_t pin = cfg->input_pins[i]; | ||
428 | if (!pin) | ||
429 | continue; | ||
430 | spec->input_idx[spec->num_inputs] = i; | ||
431 | spec->capsrc_idx[i] = spec->num_inputs++; | ||
432 | spec->cur_input = i; | ||
433 | spec->adc_nid[i] = get_adc(codec, pin, &spec->adc_idx[i]); | ||
434 | } | ||
435 | if (!spec->num_inputs) | ||
436 | return 0; | ||
437 | |||
438 | /* check whether the automatic mic switch is available */ | ||
439 | if (spec->num_inputs == 2 && | ||
440 | spec->adc_nid[AUTO_PIN_MIC] && spec->adc_nid[AUTO_PIN_FRONT_MIC]) { | ||
441 | if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_FRONT_MIC])) { | ||
442 | if (!is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { | ||
443 | spec->mic_detect = 1; | ||
444 | spec->automic_idx = AUTO_PIN_FRONT_MIC; | ||
445 | } | ||
446 | } else { | ||
447 | if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { | ||
448 | spec->mic_detect = 1; | ||
449 | spec->automic_idx = AUTO_PIN_MIC; | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | |||
457 | static int parse_digital_output(struct hda_codec *codec) | ||
458 | { | ||
459 | struct cs_spec *spec = codec->spec; | ||
460 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
461 | hda_nid_t nid; | ||
462 | |||
463 | if (!cfg->dig_outs) | ||
464 | return 0; | ||
465 | if (snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) < 1) | ||
466 | return 0; | ||
467 | spec->multiout.dig_out_nid = nid; | ||
468 | spec->multiout.share_spdif = 1; | ||
469 | if (cfg->dig_outs > 1 && | ||
470 | snd_hda_get_connections(codec, cfg->dig_out_pins[1], &nid, 1) > 0) { | ||
471 | spec->slave_dig_outs[0] = nid; | ||
472 | codec->slave_dig_outs = spec->slave_dig_outs; | ||
473 | } | ||
474 | return 0; | ||
475 | } | ||
476 | |||
477 | static int parse_digital_input(struct hda_codec *codec) | ||
478 | { | ||
479 | struct cs_spec *spec = codec->spec; | ||
480 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
481 | int idx; | ||
482 | |||
483 | if (cfg->dig_in_pin) | ||
484 | spec->dig_in = get_adc(codec, cfg->dig_in_pin, &idx); | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | * create mixer controls | ||
490 | */ | ||
491 | |||
492 | static const char *dir_sfx[2] = { "Playback", "Capture" }; | ||
493 | |||
494 | static int add_mute(struct hda_codec *codec, const char *name, int index, | ||
495 | unsigned int pval, int dir, struct snd_kcontrol **kctlp) | ||
496 | { | ||
497 | char tmp[44]; | ||
498 | struct snd_kcontrol_new knew = | ||
499 | HDA_CODEC_MUTE_IDX(tmp, index, 0, 0, HDA_OUTPUT); | ||
500 | knew.private_value = pval; | ||
501 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); | ||
502 | *kctlp = snd_ctl_new1(&knew, codec); | ||
503 | return snd_hda_ctl_add(codec, *kctlp); | ||
504 | } | ||
505 | |||
506 | static int add_volume(struct hda_codec *codec, const char *name, | ||
507 | int index, unsigned int pval, int dir, | ||
508 | struct snd_kcontrol **kctlp) | ||
509 | { | ||
510 | char tmp[32]; | ||
511 | struct snd_kcontrol_new knew = | ||
512 | HDA_CODEC_VOLUME_IDX(tmp, index, 0, 0, HDA_OUTPUT); | ||
513 | knew.private_value = pval; | ||
514 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); | ||
515 | *kctlp = snd_ctl_new1(&knew, codec); | ||
516 | return snd_hda_ctl_add(codec, *kctlp); | ||
517 | } | ||
518 | |||
519 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) | ||
520 | { | ||
521 | unsigned int caps; | ||
522 | |||
523 | /* set the upper-limit for mixer amp to 0dB */ | ||
524 | caps = query_amp_caps(codec, dac, HDA_OUTPUT); | ||
525 | caps &= ~(0x7f << AC_AMPCAP_NUM_STEPS_SHIFT); | ||
526 | caps |= ((caps >> AC_AMPCAP_OFFSET_SHIFT) & 0x7f) | ||
527 | << AC_AMPCAP_NUM_STEPS_SHIFT; | ||
528 | snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps); | ||
529 | } | ||
530 | |||
531 | static int add_vmaster(struct hda_codec *codec, hda_nid_t dac) | ||
532 | { | ||
533 | struct cs_spec *spec = codec->spec; | ||
534 | unsigned int tlv[4]; | ||
535 | int err; | ||
536 | |||
537 | spec->vmaster_sw = | ||
538 | snd_ctl_make_virtual_master("Master Playback Switch", NULL); | ||
539 | err = snd_hda_ctl_add(codec, spec->vmaster_sw); | ||
540 | if (err < 0) | ||
541 | return err; | ||
542 | |||
543 | snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv); | ||
544 | spec->vmaster_vol = | ||
545 | snd_ctl_make_virtual_master("Master Playback Volume", tlv); | ||
546 | err = snd_hda_ctl_add(codec, spec->vmaster_vol); | ||
547 | if (err < 0) | ||
548 | return err; | ||
549 | return 0; | ||
550 | } | ||
551 | |||
552 | static int add_output(struct hda_codec *codec, hda_nid_t dac, int idx, | ||
553 | int num_ctls, int type) | ||
554 | { | ||
555 | struct cs_spec *spec = codec->spec; | ||
556 | const char *name; | ||
557 | int err, index; | ||
558 | struct snd_kcontrol *kctl; | ||
559 | static char *speakers[] = { | ||
560 | "Front Speaker", "Surround Speaker", "Bass Speaker" | ||
561 | }; | ||
562 | static char *line_outs[] = { | ||
563 | "Front Line-Out", "Surround Line-Out", "Bass Line-Out" | ||
564 | }; | ||
565 | |||
566 | fix_volume_caps(codec, dac); | ||
567 | if (!spec->vmaster_sw) { | ||
568 | err = add_vmaster(codec, dac); | ||
569 | if (err < 0) | ||
570 | return err; | ||
571 | } | ||
572 | |||
573 | index = 0; | ||
574 | switch (type) { | ||
575 | case AUTO_PIN_HP_OUT: | ||
576 | name = "Headphone"; | ||
577 | index = idx; | ||
578 | break; | ||
579 | case AUTO_PIN_SPEAKER_OUT: | ||
580 | if (num_ctls > 1) | ||
581 | name = speakers[idx]; | ||
582 | else | ||
583 | name = "Speaker"; | ||
584 | break; | ||
585 | default: | ||
586 | if (num_ctls > 1) | ||
587 | name = line_outs[idx]; | ||
588 | else | ||
589 | name = "Line-Out"; | ||
590 | break; | ||
591 | } | ||
592 | |||
593 | err = add_mute(codec, name, index, | ||
594 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); | ||
595 | if (err < 0) | ||
596 | return err; | ||
597 | err = snd_ctl_add_slave(spec->vmaster_sw, kctl); | ||
598 | if (err < 0) | ||
599 | return err; | ||
600 | |||
601 | err = add_volume(codec, name, index, | ||
602 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); | ||
603 | if (err < 0) | ||
604 | return err; | ||
605 | err = snd_ctl_add_slave(spec->vmaster_vol, kctl); | ||
606 | if (err < 0) | ||
607 | return err; | ||
608 | |||
609 | return 0; | ||
610 | } | ||
611 | |||
612 | static int build_output(struct hda_codec *codec) | ||
613 | { | ||
614 | struct cs_spec *spec = codec->spec; | ||
615 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
616 | int i, err; | ||
617 | |||
618 | for (i = 0; i < cfg->line_outs; i++) { | ||
619 | err = add_output(codec, get_dac(codec, cfg->line_out_pins[i]), | ||
620 | i, cfg->line_outs, cfg->line_out_type); | ||
621 | if (err < 0) | ||
622 | return err; | ||
623 | } | ||
624 | for (i = 0; i < cfg->hp_outs; i++) { | ||
625 | err = add_output(codec, get_dac(codec, cfg->hp_pins[i]), | ||
626 | i, cfg->hp_outs, AUTO_PIN_HP_OUT); | ||
627 | if (err < 0) | ||
628 | return err; | ||
629 | } | ||
630 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
631 | err = add_output(codec, get_dac(codec, cfg->speaker_pins[i]), | ||
632 | i, cfg->speaker_outs, AUTO_PIN_SPEAKER_OUT); | ||
633 | if (err < 0) | ||
634 | return err; | ||
635 | } | ||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | /* | ||
640 | */ | ||
641 | |||
642 | static struct snd_kcontrol_new cs_capture_ctls[] = { | ||
643 | HDA_BIND_SW("Capture Switch", 0), | ||
644 | HDA_BIND_VOL("Capture Volume", 0), | ||
645 | }; | ||
646 | |||
647 | static int change_cur_input(struct hda_codec *codec, unsigned int idx, | ||
648 | int force) | ||
649 | { | ||
650 | struct cs_spec *spec = codec->spec; | ||
651 | |||
652 | if (spec->cur_input == idx && !force) | ||
653 | return 0; | ||
654 | if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { | ||
655 | /* stream is running, let's swap the current ADC */ | ||
656 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); | ||
657 | spec->cur_adc = spec->adc_nid[idx]; | ||
658 | snd_hda_codec_setup_stream(codec, spec->cur_adc, | ||
659 | spec->cur_adc_stream_tag, 0, | ||
660 | spec->cur_adc_format); | ||
661 | } | ||
662 | snd_hda_codec_write(codec, spec->cur_adc, 0, | ||
663 | AC_VERB_SET_CONNECT_SEL, | ||
664 | spec->adc_idx[idx]); | ||
665 | spec->cur_input = idx; | ||
666 | return 1; | ||
667 | } | ||
668 | |||
669 | static int cs_capture_source_info(struct snd_kcontrol *kcontrol, | ||
670 | struct snd_ctl_elem_info *uinfo) | ||
671 | { | ||
672 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
673 | struct cs_spec *spec = codec->spec; | ||
674 | unsigned int idx; | ||
675 | |||
676 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
677 | uinfo->count = 1; | ||
678 | uinfo->value.enumerated.items = spec->num_inputs; | ||
679 | if (uinfo->value.enumerated.item >= spec->num_inputs) | ||
680 | uinfo->value.enumerated.item = spec->num_inputs - 1; | ||
681 | idx = spec->input_idx[uinfo->value.enumerated.item]; | ||
682 | strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]); | ||
683 | return 0; | ||
684 | } | ||
685 | |||
686 | static int cs_capture_source_get(struct snd_kcontrol *kcontrol, | ||
687 | struct snd_ctl_elem_value *ucontrol) | ||
688 | { | ||
689 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
690 | struct cs_spec *spec = codec->spec; | ||
691 | ucontrol->value.enumerated.item[0] = spec->capsrc_idx[spec->cur_input]; | ||
692 | return 0; | ||
693 | } | ||
694 | |||
695 | static int cs_capture_source_put(struct snd_kcontrol *kcontrol, | ||
696 | struct snd_ctl_elem_value *ucontrol) | ||
697 | { | ||
698 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
699 | struct cs_spec *spec = codec->spec; | ||
700 | unsigned int idx = ucontrol->value.enumerated.item[0]; | ||
701 | |||
702 | if (idx >= spec->num_inputs) | ||
703 | return -EINVAL; | ||
704 | idx = spec->input_idx[idx]; | ||
705 | return change_cur_input(codec, idx, 0); | ||
706 | } | ||
707 | |||
708 | static struct snd_kcontrol_new cs_capture_source = { | ||
709 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
710 | .name = "Capture Source", | ||
711 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
712 | .info = cs_capture_source_info, | ||
713 | .get = cs_capture_source_get, | ||
714 | .put = cs_capture_source_put, | ||
715 | }; | ||
716 | |||
717 | static struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec, | ||
718 | struct hda_ctl_ops *ops) | ||
719 | { | ||
720 | struct cs_spec *spec = codec->spec; | ||
721 | struct hda_bind_ctls *bind; | ||
722 | int i, n; | ||
723 | |||
724 | bind = kzalloc(sizeof(*bind) + sizeof(long) * (spec->num_inputs + 1), | ||
725 | GFP_KERNEL); | ||
726 | if (!bind) | ||
727 | return NULL; | ||
728 | bind->ops = ops; | ||
729 | n = 0; | ||
730 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
731 | if (!spec->adc_nid[i]) | ||
732 | continue; | ||
733 | bind->values[n++] = | ||
734 | HDA_COMPOSE_AMP_VAL(spec->adc_nid[i], 3, | ||
735 | spec->adc_idx[i], HDA_INPUT); | ||
736 | } | ||
737 | return bind; | ||
738 | } | ||
739 | |||
740 | static int build_input(struct hda_codec *codec) | ||
741 | { | ||
742 | struct cs_spec *spec = codec->spec; | ||
743 | int i, err; | ||
744 | |||
745 | if (!spec->num_inputs) | ||
746 | return 0; | ||
747 | |||
748 | /* make bind-capture */ | ||
749 | spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw); | ||
750 | spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); | ||
751 | for (i = 0; i < 2; i++) { | ||
752 | struct snd_kcontrol *kctl; | ||
753 | if (!spec->capture_bind[i]) | ||
754 | return -ENOMEM; | ||
755 | kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); | ||
756 | if (!kctl) | ||
757 | return -ENOMEM; | ||
758 | kctl->private_value = (long)spec->capture_bind[i]; | ||
759 | err = snd_hda_ctl_add(codec, kctl); | ||
760 | if (err < 0) | ||
761 | return err; | ||
762 | } | ||
763 | |||
764 | if (spec->num_inputs > 1 && !spec->mic_detect) { | ||
765 | err = snd_hda_ctl_add(codec, | ||
766 | snd_ctl_new1(&cs_capture_source, codec)); | ||
767 | if (err < 0) | ||
768 | return err; | ||
769 | } | ||
770 | |||
771 | return 0; | ||
772 | } | ||
773 | |||
774 | /* | ||
775 | */ | ||
776 | |||
777 | static int build_digital_output(struct hda_codec *codec) | ||
778 | { | ||
779 | struct cs_spec *spec = codec->spec; | ||
780 | int err; | ||
781 | |||
782 | if (!spec->multiout.dig_out_nid) | ||
783 | return 0; | ||
784 | |||
785 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | ||
786 | if (err < 0) | ||
787 | return err; | ||
788 | err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); | ||
789 | if (err < 0) | ||
790 | return err; | ||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | static int build_digital_input(struct hda_codec *codec) | ||
795 | { | ||
796 | struct cs_spec *spec = codec->spec; | ||
797 | if (spec->dig_in) | ||
798 | return snd_hda_create_spdif_in_ctls(codec, spec->dig_in); | ||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | /* | ||
803 | * auto-mute and auto-mic switching | ||
804 | */ | ||
805 | |||
806 | static void cs_automute(struct hda_codec *codec) | ||
807 | { | ||
808 | struct cs_spec *spec = codec->spec; | ||
809 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
810 | unsigned int caps, present, hp_present; | ||
811 | hda_nid_t nid; | ||
812 | int i; | ||
813 | |||
814 | hp_present = 0; | ||
815 | for (i = 0; i < cfg->hp_outs; i++) { | ||
816 | nid = cfg->hp_pins[i]; | ||
817 | caps = snd_hda_query_pin_caps(codec, nid); | ||
818 | if (!(caps & AC_PINCAP_PRES_DETECT)) | ||
819 | continue; | ||
820 | if (caps & AC_PINCAP_TRIG_REQ) | ||
821 | snd_hda_codec_read(codec, nid, 0, | ||
822 | AC_VERB_SET_PIN_SENSE, 0); | ||
823 | present = snd_hda_codec_read(codec, nid, 0, | ||
824 | AC_VERB_GET_PIN_SENSE, 0); | ||
825 | hp_present |= (present & AC_PINSENSE_PRESENCE) != 0; | ||
826 | if (hp_present) | ||
827 | break; | ||
828 | } | ||
829 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
830 | nid = cfg->speaker_pins[i]; | ||
831 | snd_hda_codec_write(codec, nid, 0, | ||
832 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
833 | hp_present ? 0 : PIN_OUT); | ||
834 | } | ||
835 | if (spec->board_config == CS420X_MBP55) { | ||
836 | unsigned int gpio = hp_present ? 0x02 : 0x08; | ||
837 | snd_hda_codec_write(codec, 0x01, 0, | ||
838 | AC_VERB_SET_GPIO_DATA, gpio); | ||
839 | } | ||
840 | } | ||
841 | |||
842 | static void cs_automic(struct hda_codec *codec) | ||
843 | { | ||
844 | struct cs_spec *spec = codec->spec; | ||
845 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
846 | hda_nid_t nid; | ||
847 | unsigned int caps, present; | ||
848 | |||
849 | nid = cfg->input_pins[spec->automic_idx]; | ||
850 | caps = snd_hda_query_pin_caps(codec, nid); | ||
851 | if (caps & AC_PINCAP_TRIG_REQ) | ||
852 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
853 | present = snd_hda_codec_read(codec, nid, 0, | ||
854 | AC_VERB_GET_PIN_SENSE, 0); | ||
855 | if (present & AC_PINSENSE_PRESENCE) | ||
856 | change_cur_input(codec, spec->automic_idx, 0); | ||
857 | else { | ||
858 | unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? | ||
859 | AUTO_PIN_FRONT_MIC : AUTO_PIN_MIC; | ||
860 | change_cur_input(codec, imic, 0); | ||
861 | } | ||
862 | } | ||
863 | |||
864 | /* | ||
865 | */ | ||
866 | |||
867 | static void init_output(struct hda_codec *codec) | ||
868 | { | ||
869 | struct cs_spec *spec = codec->spec; | ||
870 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
871 | int i; | ||
872 | |||
873 | /* mute first */ | ||
874 | for (i = 0; i < spec->multiout.num_dacs; i++) | ||
875 | snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0, | ||
876 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | ||
877 | if (spec->multiout.hp_nid) | ||
878 | snd_hda_codec_write(codec, spec->multiout.hp_nid, 0, | ||
879 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | ||
880 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { | ||
881 | if (!spec->multiout.extra_out_nid[i]) | ||
882 | break; | ||
883 | snd_hda_codec_write(codec, spec->multiout.extra_out_nid[i], 0, | ||
884 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | ||
885 | } | ||
886 | |||
887 | /* set appropriate pin controls */ | ||
888 | for (i = 0; i < cfg->line_outs; i++) | ||
889 | snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, | ||
890 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
891 | for (i = 0; i < cfg->hp_outs; i++) { | ||
892 | hda_nid_t nid = cfg->hp_pins[i]; | ||
893 | snd_hda_codec_write(codec, nid, 0, | ||
894 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
895 | if (!cfg->speaker_outs) | ||
896 | continue; | ||
897 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { | ||
898 | snd_hda_codec_write(codec, nid, 0, | ||
899 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
900 | AC_USRSP_EN | HP_EVENT); | ||
901 | spec->hp_detect = 1; | ||
902 | } | ||
903 | } | ||
904 | for (i = 0; i < cfg->speaker_outs; i++) | ||
905 | snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, | ||
906 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
907 | if (spec->hp_detect) | ||
908 | cs_automute(codec); | ||
909 | } | ||
910 | |||
911 | static void init_input(struct hda_codec *codec) | ||
912 | { | ||
913 | struct cs_spec *spec = codec->spec; | ||
914 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
915 | unsigned int coef; | ||
916 | int i; | ||
917 | |||
918 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
919 | unsigned int ctl; | ||
920 | hda_nid_t pin = cfg->input_pins[i]; | ||
921 | if (!pin || !spec->adc_nid[i]) | ||
922 | continue; | ||
923 | /* set appropriate pin control and mute first */ | ||
924 | ctl = PIN_IN; | ||
925 | if (i <= AUTO_PIN_FRONT_MIC) { | ||
926 | unsigned int caps = snd_hda_query_pin_caps(codec, pin); | ||
927 | caps >>= AC_PINCAP_VREF_SHIFT; | ||
928 | if (caps & AC_PINCAP_VREF_80) | ||
929 | ctl = PIN_VREF80; | ||
930 | } | ||
931 | snd_hda_codec_write(codec, pin, 0, | ||
932 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); | ||
933 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, | ||
934 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
935 | AMP_IN_MUTE(spec->adc_idx[i])); | ||
936 | if (spec->mic_detect && spec->automic_idx == i) | ||
937 | snd_hda_codec_write(codec, pin, 0, | ||
938 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
939 | AC_USRSP_EN | MIC_EVENT); | ||
940 | } | ||
941 | change_cur_input(codec, spec->cur_input, 1); | ||
942 | if (spec->mic_detect) | ||
943 | cs_automic(codec); | ||
944 | |||
945 | coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ | ||
946 | if (is_active_pin(codec, CS_DMIC2_PIN_NID)) | ||
947 | coef |= 0x0500; /* DMIC2 enable 2 channels, disable GPIO1 */ | ||
948 | if (is_active_pin(codec, CS_DMIC1_PIN_NID)) | ||
949 | coef |= 0x1800; /* DMIC1 enable 2 channels, disable GPIO0 | ||
950 | * No effect if SPDIF_OUT2 is slected in | ||
951 | * IDX_SPDIF_CTL. | ||
952 | */ | ||
953 | cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); | ||
954 | } | ||
955 | |||
956 | static struct hda_verb cs_coef_init_verbs[] = { | ||
957 | {0x11, AC_VERB_SET_PROC_STATE, 1}, | ||
958 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG}, | ||
959 | {0x11, AC_VERB_SET_PROC_COEF, | ||
960 | (0x002a /* DAC1/2/3 SZCMode Soft Ramp */ | ||
961 | | 0x0040 /* Mute DACs on FIFO error */ | ||
962 | | 0x1000 /* Enable DACs High Pass Filter */ | ||
963 | | 0x0400 /* Disable Coefficient Auto increment */ | ||
964 | )}, | ||
965 | /* Beep */ | ||
966 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG}, | ||
967 | {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */ | ||
968 | |||
969 | {} /* terminator */ | ||
970 | }; | ||
971 | |||
972 | /* SPDIF setup */ | ||
973 | static void init_digital(struct hda_codec *codec) | ||
974 | { | ||
975 | unsigned int coef; | ||
976 | |||
977 | coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */ | ||
978 | coef |= 0x0008; /* Replace with mute on error */ | ||
979 | if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID)) | ||
980 | coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2 | ||
981 | * SPDIF_OUT2 is shared with GPIO1 and | ||
982 | * DMIC_SDA2. | ||
983 | */ | ||
984 | cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); | ||
985 | } | ||
986 | |||
987 | static int cs_init(struct hda_codec *codec) | ||
988 | { | ||
989 | struct cs_spec *spec = codec->spec; | ||
990 | |||
991 | snd_hda_sequence_write(codec, cs_coef_init_verbs); | ||
992 | |||
993 | if (spec->gpio_mask) { | ||
994 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, | ||
995 | spec->gpio_mask); | ||
996 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, | ||
997 | spec->gpio_dir); | ||
998 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | ||
999 | spec->gpio_data); | ||
1000 | } | ||
1001 | |||
1002 | init_output(codec); | ||
1003 | init_input(codec); | ||
1004 | init_digital(codec); | ||
1005 | return 0; | ||
1006 | } | ||
1007 | |||
1008 | static int cs_build_controls(struct hda_codec *codec) | ||
1009 | { | ||
1010 | int err; | ||
1011 | |||
1012 | err = build_output(codec); | ||
1013 | if (err < 0) | ||
1014 | return err; | ||
1015 | err = build_input(codec); | ||
1016 | if (err < 0) | ||
1017 | return err; | ||
1018 | err = build_digital_output(codec); | ||
1019 | if (err < 0) | ||
1020 | return err; | ||
1021 | err = build_digital_input(codec); | ||
1022 | if (err < 0) | ||
1023 | return err; | ||
1024 | return cs_init(codec); | ||
1025 | } | ||
1026 | |||
1027 | static void cs_free(struct hda_codec *codec) | ||
1028 | { | ||
1029 | struct cs_spec *spec = codec->spec; | ||
1030 | kfree(spec->capture_bind[0]); | ||
1031 | kfree(spec->capture_bind[1]); | ||
1032 | kfree(codec->spec); | ||
1033 | } | ||
1034 | |||
1035 | static void cs_unsol_event(struct hda_codec *codec, unsigned int res) | ||
1036 | { | ||
1037 | switch ((res >> 26) & 0x7f) { | ||
1038 | case HP_EVENT: | ||
1039 | cs_automute(codec); | ||
1040 | break; | ||
1041 | case MIC_EVENT: | ||
1042 | cs_automic(codec); | ||
1043 | break; | ||
1044 | } | ||
1045 | } | ||
1046 | |||
1047 | static struct hda_codec_ops cs_patch_ops = { | ||
1048 | .build_controls = cs_build_controls, | ||
1049 | .build_pcms = cs_build_pcms, | ||
1050 | .init = cs_init, | ||
1051 | .free = cs_free, | ||
1052 | .unsol_event = cs_unsol_event, | ||
1053 | }; | ||
1054 | |||
1055 | static int cs_parse_auto_config(struct hda_codec *codec) | ||
1056 | { | ||
1057 | struct cs_spec *spec = codec->spec; | ||
1058 | int err; | ||
1059 | |||
1060 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
1061 | if (err < 0) | ||
1062 | return err; | ||
1063 | |||
1064 | err = parse_output(codec); | ||
1065 | if (err < 0) | ||
1066 | return err; | ||
1067 | err = parse_input(codec); | ||
1068 | if (err < 0) | ||
1069 | return err; | ||
1070 | err = parse_digital_output(codec); | ||
1071 | if (err < 0) | ||
1072 | return err; | ||
1073 | err = parse_digital_input(codec); | ||
1074 | if (err < 0) | ||
1075 | return err; | ||
1076 | return 0; | ||
1077 | } | ||
1078 | |||
1079 | static const char *cs420x_models[CS420X_MODELS] = { | ||
1080 | [CS420X_MBP55] = "mbp55", | ||
1081 | [CS420X_AUTO] = "auto", | ||
1082 | }; | ||
1083 | |||
1084 | |||
1085 | static struct snd_pci_quirk cs420x_cfg_tbl[] = { | ||
1086 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), | ||
1087 | {} /* terminator */ | ||
1088 | }; | ||
1089 | |||
1090 | struct cs_pincfg { | ||
1091 | hda_nid_t nid; | ||
1092 | u32 val; | ||
1093 | }; | ||
1094 | |||
1095 | static struct cs_pincfg mbp55_pincfgs[] = { | ||
1096 | { 0x09, 0x012b4030 }, | ||
1097 | { 0x0a, 0x90100121 }, | ||
1098 | { 0x0b, 0x90100120 }, | ||
1099 | { 0x0c, 0x400000f0 }, | ||
1100 | { 0x0d, 0x90a00110 }, | ||
1101 | { 0x0e, 0x400000f0 }, | ||
1102 | { 0x0f, 0x400000f0 }, | ||
1103 | { 0x10, 0x014be040 }, | ||
1104 | { 0x12, 0x400000f0 }, | ||
1105 | { 0x15, 0x400000f0 }, | ||
1106 | {} /* terminator */ | ||
1107 | }; | ||
1108 | |||
1109 | static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { | ||
1110 | [CS420X_MBP55] = mbp55_pincfgs, | ||
1111 | }; | ||
1112 | |||
1113 | static void fix_pincfg(struct hda_codec *codec, int model) | ||
1114 | { | ||
1115 | const struct cs_pincfg *cfg = cs_pincfgs[model]; | ||
1116 | if (!cfg) | ||
1117 | return; | ||
1118 | for (; cfg->nid; cfg++) | ||
1119 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | ||
1120 | } | ||
1121 | |||
1122 | |||
1123 | static int patch_cs420x(struct hda_codec *codec) | ||
1124 | { | ||
1125 | struct cs_spec *spec; | ||
1126 | int err; | ||
1127 | |||
1128 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
1129 | if (!spec) | ||
1130 | return -ENOMEM; | ||
1131 | codec->spec = spec; | ||
1132 | |||
1133 | spec->board_config = | ||
1134 | snd_hda_check_board_config(codec, CS420X_MODELS, | ||
1135 | cs420x_models, cs420x_cfg_tbl); | ||
1136 | if (spec->board_config >= 0) | ||
1137 | fix_pincfg(codec, spec->board_config); | ||
1138 | |||
1139 | switch (spec->board_config) { | ||
1140 | case CS420X_MBP55: | ||
1141 | /* GPIO1 = headphones */ | ||
1142 | /* GPIO3 = speakers */ | ||
1143 | spec->gpio_mask = 0x0a; | ||
1144 | spec->gpio_dir = 0x0a; | ||
1145 | break; | ||
1146 | } | ||
1147 | |||
1148 | err = cs_parse_auto_config(codec); | ||
1149 | if (err < 0) | ||
1150 | goto error; | ||
1151 | |||
1152 | codec->patch_ops = cs_patch_ops; | ||
1153 | |||
1154 | return 0; | ||
1155 | |||
1156 | error: | ||
1157 | kfree(codec->spec); | ||
1158 | codec->spec = NULL; | ||
1159 | return err; | ||
1160 | } | ||
1161 | |||
1162 | |||
1163 | /* | ||
1164 | * patch entries | ||
1165 | */ | ||
1166 | static struct hda_codec_preset snd_hda_preset_cirrus[] = { | ||
1167 | { .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x }, | ||
1168 | { .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x }, | ||
1169 | {} /* terminator */ | ||
1170 | }; | ||
1171 | |||
1172 | MODULE_ALIAS("snd-hda-codec-id:10134206"); | ||
1173 | MODULE_ALIAS("snd-hda-codec-id:10134207"); | ||
1174 | |||
1175 | MODULE_LICENSE("GPL"); | ||
1176 | MODULE_DESCRIPTION("Cirrus Logic HD-audio codec"); | ||
1177 | |||
1178 | static struct hda_codec_preset_list cirrus_list = { | ||
1179 | .preset = snd_hda_preset_cirrus, | ||
1180 | .owner = THIS_MODULE, | ||
1181 | }; | ||
1182 | |||
1183 | static int __init patch_cirrus_init(void) | ||
1184 | { | ||
1185 | return snd_hda_add_codec_preset(&cirrus_list); | ||
1186 | } | ||
1187 | |||
1188 | static void __exit patch_cirrus_exit(void) | ||
1189 | { | ||
1190 | snd_hda_delete_codec_preset(&cirrus_list); | ||
1191 | } | ||
1192 | |||
1193 | module_init(patch_cirrus_init) | ||
1194 | module_exit(patch_cirrus_exit) | ||
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index c921264bbd71..780e1a72114a 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
@@ -635,7 +635,8 @@ static int patch_cmi9880(struct hda_codec *codec) | |||
635 | cmi9880_models, | 635 | cmi9880_models, |
636 | cmi9880_cfg_tbl); | 636 | cmi9880_cfg_tbl); |
637 | if (spec->board_config < 0) { | 637 | if (spec->board_config < 0) { |
638 | snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); | 638 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
639 | codec->chip_name); | ||
639 | spec->board_config = CMI_AUTO; /* try everything */ | 640 | spec->board_config = CMI_AUTO; /* try everything */ |
640 | } | 641 | } |
641 | 642 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index ac868c59f9e3..9d899eda44d7 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -108,6 +108,8 @@ struct conexant_spec { | |||
108 | struct hda_input_mux private_imux; | 108 | struct hda_input_mux private_imux; |
109 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 109 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
110 | 110 | ||
111 | unsigned int dell_automute; | ||
112 | unsigned int port_d_mode; | ||
111 | }; | 113 | }; |
112 | 114 | ||
113 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | 115 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
@@ -1908,6 +1910,480 @@ static int patch_cxt5051(struct hda_codec *codec) | |||
1908 | return 0; | 1910 | return 0; |
1909 | } | 1911 | } |
1910 | 1912 | ||
1913 | /* Conexant 5066 specific */ | ||
1914 | |||
1915 | static hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; | ||
1916 | static hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; | ||
1917 | static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; | ||
1918 | #define CXT5066_SPDIF_OUT 0x21 | ||
1919 | |||
1920 | static struct hda_channel_mode cxt5066_modes[1] = { | ||
1921 | { 2, NULL }, | ||
1922 | }; | ||
1923 | |||
1924 | static void cxt5066_update_speaker(struct hda_codec *codec) | ||
1925 | { | ||
1926 | struct conexant_spec *spec = codec->spec; | ||
1927 | unsigned int pinctl; | ||
1928 | |||
1929 | snd_printdd("CXT5066: update speaker, hp_present=%d\n", | ||
1930 | spec->hp_present); | ||
1931 | |||
1932 | /* Port A (HP) */ | ||
1933 | pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0; | ||
1934 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1935 | pinctl); | ||
1936 | |||
1937 | /* Port D (HP/LO) */ | ||
1938 | pinctl = ((spec->hp_present & 2) && spec->cur_eapd) | ||
1939 | ? spec->port_d_mode : 0; | ||
1940 | snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1941 | pinctl); | ||
1942 | |||
1943 | /* CLASS_D AMP */ | ||
1944 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | ||
1945 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1946 | pinctl); | ||
1947 | |||
1948 | if (spec->dell_automute) { | ||
1949 | /* DELL AIO Port Rule: PortA > PortD > IntSpk */ | ||
1950 | pinctl = (!(spec->hp_present & 1) && spec->cur_eapd) | ||
1951 | ? PIN_OUT : 0; | ||
1952 | snd_hda_codec_write(codec, 0x1c, 0, | ||
1953 | AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); | ||
1954 | } | ||
1955 | } | ||
1956 | |||
1957 | /* turn on/off EAPD (+ mute HP) as a master switch */ | ||
1958 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | ||
1959 | struct snd_ctl_elem_value *ucontrol) | ||
1960 | { | ||
1961 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1962 | |||
1963 | if (!cxt_eapd_put(kcontrol, ucontrol)) | ||
1964 | return 0; | ||
1965 | |||
1966 | cxt5066_update_speaker(codec); | ||
1967 | return 1; | ||
1968 | } | ||
1969 | |||
1970 | /* toggle input of built-in and mic jack appropriately */ | ||
1971 | static void cxt5066_automic(struct hda_codec *codec) | ||
1972 | { | ||
1973 | static struct hda_verb ext_mic_present[] = { | ||
1974 | /* enable external mic, port B */ | ||
1975 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1976 | |||
1977 | /* switch to external mic input */ | ||
1978 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | ||
1979 | |||
1980 | /* disable internal mic, port C */ | ||
1981 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
1982 | {} | ||
1983 | }; | ||
1984 | static struct hda_verb ext_mic_absent[] = { | ||
1985 | /* enable internal mic, port C */ | ||
1986 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1987 | |||
1988 | /* switch to internal mic input */ | ||
1989 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, | ||
1990 | |||
1991 | /* disable external mic, port B */ | ||
1992 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
1993 | {} | ||
1994 | }; | ||
1995 | unsigned int present; | ||
1996 | |||
1997 | present = snd_hda_codec_read(codec, 0x1a, 0, | ||
1998 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1999 | if (present) { | ||
2000 | snd_printdd("CXT5066: external microphone detected\n"); | ||
2001 | snd_hda_sequence_write(codec, ext_mic_present); | ||
2002 | } else { | ||
2003 | snd_printdd("CXT5066: external microphone absent\n"); | ||
2004 | snd_hda_sequence_write(codec, ext_mic_absent); | ||
2005 | } | ||
2006 | } | ||
2007 | |||
2008 | /* mute internal speaker if HP is plugged */ | ||
2009 | static void cxt5066_hp_automute(struct hda_codec *codec) | ||
2010 | { | ||
2011 | struct conexant_spec *spec = codec->spec; | ||
2012 | unsigned int portA, portD; | ||
2013 | |||
2014 | /* Port A */ | ||
2015 | portA = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
2016 | & AC_PINSENSE_PRESENCE; | ||
2017 | |||
2018 | /* Port D */ | ||
2019 | portD = (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
2020 | & AC_PINSENSE_PRESENCE) << 1; | ||
2021 | |||
2022 | spec->hp_present = !!(portA | portD); | ||
2023 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", | ||
2024 | portA, portD, spec->hp_present); | ||
2025 | cxt5066_update_speaker(codec); | ||
2026 | } | ||
2027 | |||
2028 | /* unsolicited event for jack sensing */ | ||
2029 | static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) | ||
2030 | { | ||
2031 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); | ||
2032 | switch (res >> 26) { | ||
2033 | case CONEXANT_HP_EVENT: | ||
2034 | cxt5066_hp_automute(codec); | ||
2035 | break; | ||
2036 | case CONEXANT_MIC_EVENT: | ||
2037 | cxt5066_automic(codec); | ||
2038 | break; | ||
2039 | } | ||
2040 | } | ||
2041 | |||
2042 | static const struct hda_input_mux cxt5066_analog_mic_boost = { | ||
2043 | .num_items = 5, | ||
2044 | .items = { | ||
2045 | { "0dB", 0 }, | ||
2046 | { "10dB", 1 }, | ||
2047 | { "20dB", 2 }, | ||
2048 | { "30dB", 3 }, | ||
2049 | { "40dB", 4 }, | ||
2050 | }, | ||
2051 | }; | ||
2052 | |||
2053 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, | ||
2054 | struct snd_ctl_elem_info *uinfo) | ||
2055 | { | ||
2056 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); | ||
2057 | } | ||
2058 | |||
2059 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | ||
2060 | struct snd_ctl_elem_value *ucontrol) | ||
2061 | { | ||
2062 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2063 | int val; | ||
2064 | |||
2065 | val = snd_hda_codec_read(codec, 0x17, 0, | ||
2066 | AC_VERB_GET_AMP_GAIN_MUTE, AC_AMP_GET_OUTPUT); | ||
2067 | |||
2068 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; | ||
2069 | return 0; | ||
2070 | } | ||
2071 | |||
2072 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | ||
2073 | struct snd_ctl_elem_value *ucontrol) | ||
2074 | { | ||
2075 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2076 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | ||
2077 | unsigned int idx; | ||
2078 | |||
2079 | if (!imux->num_items) | ||
2080 | return 0; | ||
2081 | idx = ucontrol->value.enumerated.item[0]; | ||
2082 | if (idx >= imux->num_items) | ||
2083 | idx = imux->num_items - 1; | ||
2084 | |||
2085 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
2086 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
2087 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | ||
2088 | imux->items[idx].index); | ||
2089 | |||
2090 | return 1; | ||
2091 | } | ||
2092 | |||
2093 | static struct hda_input_mux cxt5066_capture_source = { | ||
2094 | .num_items = 4, | ||
2095 | .items = { | ||
2096 | { "Mic B", 0 }, | ||
2097 | { "Mic C", 1 }, | ||
2098 | { "Mic E", 2 }, | ||
2099 | { "Mic F", 3 }, | ||
2100 | }, | ||
2101 | }; | ||
2102 | |||
2103 | static struct hda_bind_ctls cxt5066_bind_capture_vol_others = { | ||
2104 | .ops = &snd_hda_bind_vol, | ||
2105 | .values = { | ||
2106 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | ||
2107 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | ||
2108 | 0 | ||
2109 | }, | ||
2110 | }; | ||
2111 | |||
2112 | static struct hda_bind_ctls cxt5066_bind_capture_sw_others = { | ||
2113 | .ops = &snd_hda_bind_sw, | ||
2114 | .values = { | ||
2115 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | ||
2116 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | ||
2117 | 0 | ||
2118 | }, | ||
2119 | }; | ||
2120 | |||
2121 | static struct snd_kcontrol_new cxt5066_mixer_master[] = { | ||
2122 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), | ||
2123 | {} | ||
2124 | }; | ||
2125 | |||
2126 | static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { | ||
2127 | { | ||
2128 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2129 | .name = "Master Playback Volume", | ||
2130 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
2131 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | | ||
2132 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, | ||
2133 | .info = snd_hda_mixer_amp_volume_info, | ||
2134 | .get = snd_hda_mixer_amp_volume_get, | ||
2135 | .put = snd_hda_mixer_amp_volume_put, | ||
2136 | .tlv = { .c = snd_hda_mixer_amp_tlv }, | ||
2137 | /* offset by 28 volume steps to limit minimum gain to -46dB */ | ||
2138 | .private_value = | ||
2139 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), | ||
2140 | }, | ||
2141 | {} | ||
2142 | }; | ||
2143 | |||
2144 | static struct snd_kcontrol_new cxt5066_mixers[] = { | ||
2145 | { | ||
2146 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2147 | .name = "Master Playback Switch", | ||
2148 | .info = cxt_eapd_info, | ||
2149 | .get = cxt_eapd_get, | ||
2150 | .put = cxt5066_hp_master_sw_put, | ||
2151 | .private_value = 0x1d, | ||
2152 | }, | ||
2153 | |||
2154 | { | ||
2155 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2156 | .name = "Analog Mic Boost Capture Enum", | ||
2157 | .info = cxt5066_mic_boost_mux_enum_info, | ||
2158 | .get = cxt5066_mic_boost_mux_enum_get, | ||
2159 | .put = cxt5066_mic_boost_mux_enum_put, | ||
2160 | }, | ||
2161 | |||
2162 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | ||
2163 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), | ||
2164 | {} | ||
2165 | }; | ||
2166 | |||
2167 | static struct hda_verb cxt5066_init_verbs[] = { | ||
2168 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ | ||
2169 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | ||
2170 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | ||
2171 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | ||
2172 | |||
2173 | /* Speakers */ | ||
2174 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2175 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2176 | |||
2177 | /* HP, Amp */ | ||
2178 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2179 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2180 | |||
2181 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2182 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2183 | |||
2184 | /* DAC1 */ | ||
2185 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2186 | |||
2187 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | ||
2188 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | ||
2189 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2190 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | ||
2191 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2192 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
2193 | |||
2194 | /* no digital microphone support yet */ | ||
2195 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2196 | |||
2197 | /* Audio input selector */ | ||
2198 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | ||
2199 | |||
2200 | /* SPDIF route: PCM */ | ||
2201 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
2202 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
2203 | |||
2204 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2205 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2206 | |||
2207 | /* EAPD */ | ||
2208 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
2209 | |||
2210 | /* not handling these yet */ | ||
2211 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2212 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2213 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2214 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2215 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2216 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2217 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2218 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2219 | { } /* end */ | ||
2220 | }; | ||
2221 | |||
2222 | static struct hda_verb cxt5066_init_verbs_olpc[] = { | ||
2223 | /* Port A: headphones */ | ||
2224 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2225 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2226 | |||
2227 | /* Port B: external microphone */ | ||
2228 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
2229 | |||
2230 | /* Port C: internal microphone */ | ||
2231 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
2232 | |||
2233 | /* Port D: unused */ | ||
2234 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2235 | |||
2236 | /* Port E: unused, but has primary EAPD */ | ||
2237 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2238 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
2239 | |||
2240 | /* Port F: unused */ | ||
2241 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2242 | |||
2243 | /* Port G: internal speakers */ | ||
2244 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2245 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2246 | |||
2247 | /* DAC1 */ | ||
2248 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2249 | |||
2250 | /* DAC2: unused */ | ||
2251 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
2252 | |||
2253 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | ||
2254 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2255 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2256 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2257 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2258 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2259 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2260 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2261 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2262 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2263 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2264 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2265 | |||
2266 | /* Disable digital microphone port */ | ||
2267 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2268 | |||
2269 | /* Audio input selectors */ | ||
2270 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | ||
2271 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
2272 | |||
2273 | /* Disable SPDIF */ | ||
2274 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2275 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2276 | |||
2277 | /* enable unsolicited events for Port A and B */ | ||
2278 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | ||
2279 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | ||
2280 | { } /* end */ | ||
2281 | }; | ||
2282 | |||
2283 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { | ||
2284 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2285 | { } /* end */ | ||
2286 | }; | ||
2287 | |||
2288 | /* initialize jack-sensing, too */ | ||
2289 | static int cxt5066_init(struct hda_codec *codec) | ||
2290 | { | ||
2291 | snd_printdd("CXT5066: init\n"); | ||
2292 | conexant_init(codec); | ||
2293 | if (codec->patch_ops.unsol_event) { | ||
2294 | cxt5066_hp_automute(codec); | ||
2295 | cxt5066_automic(codec); | ||
2296 | } | ||
2297 | return 0; | ||
2298 | } | ||
2299 | |||
2300 | enum { | ||
2301 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ | ||
2302 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ | ||
2303 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ | ||
2304 | CXT5066_MODELS | ||
2305 | }; | ||
2306 | |||
2307 | static const char *cxt5066_models[CXT5066_MODELS] = { | ||
2308 | [CXT5066_LAPTOP] = "laptop", | ||
2309 | [CXT5066_DELL_LAPTOP] = "dell-laptop", | ||
2310 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", | ||
2311 | }; | ||
2312 | |||
2313 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | ||
2314 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", | ||
2315 | CXT5066_LAPTOP), | ||
2316 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", | ||
2317 | CXT5066_DELL_LAPTOP), | ||
2318 | {} | ||
2319 | }; | ||
2320 | |||
2321 | static int patch_cxt5066(struct hda_codec *codec) | ||
2322 | { | ||
2323 | struct conexant_spec *spec; | ||
2324 | int board_config; | ||
2325 | |||
2326 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
2327 | if (!spec) | ||
2328 | return -ENOMEM; | ||
2329 | codec->spec = spec; | ||
2330 | |||
2331 | codec->patch_ops = conexant_patch_ops; | ||
2332 | codec->patch_ops.init = cxt5066_init; | ||
2333 | |||
2334 | spec->dell_automute = 0; | ||
2335 | spec->multiout.max_channels = 2; | ||
2336 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); | ||
2337 | spec->multiout.dac_nids = cxt5066_dac_nids; | ||
2338 | spec->multiout.dig_out_nid = CXT5066_SPDIF_OUT; | ||
2339 | spec->num_adc_nids = 1; | ||
2340 | spec->adc_nids = cxt5066_adc_nids; | ||
2341 | spec->capsrc_nids = cxt5066_capsrc_nids; | ||
2342 | spec->input_mux = &cxt5066_capture_source; | ||
2343 | |||
2344 | spec->port_d_mode = PIN_HP; | ||
2345 | |||
2346 | spec->num_init_verbs = 1; | ||
2347 | spec->init_verbs[0] = cxt5066_init_verbs; | ||
2348 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); | ||
2349 | spec->channel_mode = cxt5066_modes; | ||
2350 | spec->cur_adc = 0; | ||
2351 | spec->cur_adc_idx = 0; | ||
2352 | |||
2353 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, | ||
2354 | cxt5066_models, cxt5066_cfg_tbl); | ||
2355 | switch (board_config) { | ||
2356 | default: | ||
2357 | case CXT5066_LAPTOP: | ||
2358 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | ||
2359 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2360 | break; | ||
2361 | case CXT5066_DELL_LAPTOP: | ||
2362 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | ||
2363 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2364 | |||
2365 | spec->port_d_mode = PIN_OUT; | ||
2366 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; | ||
2367 | spec->num_init_verbs++; | ||
2368 | spec->dell_automute = 1; | ||
2369 | break; | ||
2370 | case CXT5066_OLPC_XO_1_5: | ||
2371 | codec->patch_ops.unsol_event = cxt5066_unsol_event; | ||
2372 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; | ||
2373 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | ||
2374 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2375 | spec->port_d_mode = 0; | ||
2376 | |||
2377 | /* no S/PDIF out */ | ||
2378 | spec->multiout.dig_out_nid = 0; | ||
2379 | |||
2380 | /* input source automatically selected */ | ||
2381 | spec->input_mux = NULL; | ||
2382 | break; | ||
2383 | } | ||
2384 | |||
2385 | return 0; | ||
2386 | } | ||
1911 | 2387 | ||
1912 | /* | 2388 | /* |
1913 | */ | 2389 | */ |
@@ -1919,12 +2395,15 @@ static struct hda_codec_preset snd_hda_preset_conexant[] = { | |||
1919 | .patch = patch_cxt5047 }, | 2395 | .patch = patch_cxt5047 }, |
1920 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", | 2396 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
1921 | .patch = patch_cxt5051 }, | 2397 | .patch = patch_cxt5051 }, |
2398 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", | ||
2399 | .patch = patch_cxt5066 }, | ||
1922 | {} /* terminator */ | 2400 | {} /* terminator */ |
1923 | }; | 2401 | }; |
1924 | 2402 | ||
1925 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); | 2403 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); |
1926 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); | 2404 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); |
1927 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); | 2405 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); |
2406 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); | ||
1928 | 2407 | ||
1929 | MODULE_LICENSE("GPL"); | 2408 | MODULE_LICENSE("GPL"); |
1930 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | 2409 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index fcc77fec4487..01a18ed475ac 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c | |||
@@ -33,8 +33,8 @@ | |||
33 | #include "hda_codec.h" | 33 | #include "hda_codec.h" |
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | 35 | ||
36 | #define CVT_NID 0x02 /* audio converter */ | 36 | static hda_nid_t cvt_nid; /* audio converter */ |
37 | #define PIN_NID 0x03 /* HDMI output pin */ | 37 | static hda_nid_t pin_nid; /* HDMI output pin */ |
38 | 38 | ||
39 | #define INTEL_HDMI_EVENT_TAG 0x08 | 39 | #define INTEL_HDMI_EVENT_TAG 0x08 |
40 | 40 | ||
@@ -44,30 +44,6 @@ struct intel_hdmi_spec { | |||
44 | struct hdmi_eld sink_eld; | 44 | struct hdmi_eld sink_eld; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static struct hda_verb pinout_enable_verb[] = { | ||
48 | {PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
49 | {} /* terminator */ | ||
50 | }; | ||
51 | |||
52 | static struct hda_verb unsolicited_response_verb[] = { | ||
53 | {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | | ||
54 | INTEL_HDMI_EVENT_TAG}, | ||
55 | {} | ||
56 | }; | ||
57 | |||
58 | static struct hda_verb def_chan_map[] = { | ||
59 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x00}, | ||
60 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x11}, | ||
61 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x22}, | ||
62 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x33}, | ||
63 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x44}, | ||
64 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x55}, | ||
65 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x66}, | ||
66 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x77}, | ||
67 | {} | ||
68 | }; | ||
69 | |||
70 | |||
71 | struct hdmi_audio_infoframe { | 47 | struct hdmi_audio_infoframe { |
72 | u8 type; /* 0x84 */ | 48 | u8 type; /* 0x84 */ |
73 | u8 ver; /* 0x01 */ | 49 | u8 ver; /* 0x01 */ |
@@ -244,11 +220,12 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid, | |||
244 | static void hdmi_enable_output(struct hda_codec *codec) | 220 | static void hdmi_enable_output(struct hda_codec *codec) |
245 | { | 221 | { |
246 | /* Unmute */ | 222 | /* Unmute */ |
247 | if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) | 223 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) |
248 | snd_hda_codec_write(codec, PIN_NID, 0, | 224 | snd_hda_codec_write(codec, pin_nid, 0, |
249 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | 225 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
250 | /* Enable pin out */ | 226 | /* Enable pin out */ |
251 | snd_hda_sequence_write(codec, pinout_enable_verb); | 227 | snd_hda_codec_write(codec, pin_nid, 0, |
228 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
252 | } | 229 | } |
253 | 230 | ||
254 | /* | 231 | /* |
@@ -256,8 +233,8 @@ static void hdmi_enable_output(struct hda_codec *codec) | |||
256 | */ | 233 | */ |
257 | static void hdmi_start_infoframe_trans(struct hda_codec *codec) | 234 | static void hdmi_start_infoframe_trans(struct hda_codec *codec) |
258 | { | 235 | { |
259 | hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); | 236 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
260 | snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT, | 237 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
261 | AC_DIPXMIT_BEST); | 238 | AC_DIPXMIT_BEST); |
262 | } | 239 | } |
263 | 240 | ||
@@ -266,20 +243,20 @@ static void hdmi_start_infoframe_trans(struct hda_codec *codec) | |||
266 | */ | 243 | */ |
267 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec) | 244 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec) |
268 | { | 245 | { |
269 | hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); | 246 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
270 | snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT, | 247 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
271 | AC_DIPXMIT_DISABLE); | 248 | AC_DIPXMIT_DISABLE); |
272 | } | 249 | } |
273 | 250 | ||
274 | static int hdmi_get_channel_count(struct hda_codec *codec) | 251 | static int hdmi_get_channel_count(struct hda_codec *codec) |
275 | { | 252 | { |
276 | return 1 + snd_hda_codec_read(codec, CVT_NID, 0, | 253 | return 1 + snd_hda_codec_read(codec, cvt_nid, 0, |
277 | AC_VERB_GET_CVT_CHAN_COUNT, 0); | 254 | AC_VERB_GET_CVT_CHAN_COUNT, 0); |
278 | } | 255 | } |
279 | 256 | ||
280 | static void hdmi_set_channel_count(struct hda_codec *codec, int chs) | 257 | static void hdmi_set_channel_count(struct hda_codec *codec, int chs) |
281 | { | 258 | { |
282 | snd_hda_codec_write(codec, CVT_NID, 0, | 259 | snd_hda_codec_write(codec, cvt_nid, 0, |
283 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | 260 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); |
284 | 261 | ||
285 | if (chs != hdmi_get_channel_count(codec)) | 262 | if (chs != hdmi_get_channel_count(codec)) |
@@ -294,7 +271,7 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec) | |||
294 | int slot; | 271 | int slot; |
295 | 272 | ||
296 | for (i = 0; i < 8; i++) { | 273 | for (i = 0; i < 8; i++) { |
297 | slot = snd_hda_codec_read(codec, CVT_NID, 0, | 274 | slot = snd_hda_codec_read(codec, cvt_nid, 0, |
298 | AC_VERB_GET_HDMI_CHAN_SLOT, i); | 275 | AC_VERB_GET_HDMI_CHAN_SLOT, i); |
299 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", | 276 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", |
300 | slot >> 4, slot & 0x7); | 277 | slot >> 4, slot & 0x7); |
@@ -307,7 +284,7 @@ static void hdmi_parse_eld(struct hda_codec *codec) | |||
307 | struct intel_hdmi_spec *spec = codec->spec; | 284 | struct intel_hdmi_spec *spec = codec->spec; |
308 | struct hdmi_eld *eld = &spec->sink_eld; | 285 | struct hdmi_eld *eld = &spec->sink_eld; |
309 | 286 | ||
310 | if (!snd_hdmi_get_eld(eld, codec, PIN_NID)) | 287 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) |
311 | snd_hdmi_show_eld(eld); | 288 | snd_hdmi_show_eld(eld); |
312 | } | 289 | } |
313 | 290 | ||
@@ -322,11 +299,11 @@ static void hdmi_debug_dip_size(struct hda_codec *codec) | |||
322 | int i; | 299 | int i; |
323 | int size; | 300 | int size; |
324 | 301 | ||
325 | size = snd_hdmi_get_eld_size(codec, PIN_NID); | 302 | size = snd_hdmi_get_eld_size(codec, pin_nid); |
326 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); | 303 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); |
327 | 304 | ||
328 | for (i = 0; i < 8; i++) { | 305 | for (i = 0; i < 8; i++) { |
329 | size = snd_hda_codec_read(codec, PIN_NID, 0, | 306 | size = snd_hda_codec_read(codec, pin_nid, 0, |
330 | AC_VERB_GET_HDMI_DIP_SIZE, i); | 307 | AC_VERB_GET_HDMI_DIP_SIZE, i); |
331 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); | 308 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); |
332 | } | 309 | } |
@@ -340,15 +317,15 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec) | |||
340 | int size; | 317 | int size; |
341 | int pi, bi; | 318 | int pi, bi; |
342 | for (i = 0; i < 8; i++) { | 319 | for (i = 0; i < 8; i++) { |
343 | size = snd_hda_codec_read(codec, PIN_NID, 0, | 320 | size = snd_hda_codec_read(codec, pin_nid, 0, |
344 | AC_VERB_GET_HDMI_DIP_SIZE, i); | 321 | AC_VERB_GET_HDMI_DIP_SIZE, i); |
345 | if (size == 0) | 322 | if (size == 0) |
346 | continue; | 323 | continue; |
347 | 324 | ||
348 | hdmi_set_dip_index(codec, PIN_NID, i, 0x0); | 325 | hdmi_set_dip_index(codec, pin_nid, i, 0x0); |
349 | for (j = 1; j < 1000; j++) { | 326 | for (j = 1; j < 1000; j++) { |
350 | hdmi_write_dip_byte(codec, PIN_NID, 0x0); | 327 | hdmi_write_dip_byte(codec, pin_nid, 0x0); |
351 | hdmi_get_dip_index(codec, PIN_NID, &pi, &bi); | 328 | hdmi_get_dip_index(codec, pin_nid, &pi, &bi); |
352 | if (pi != i) | 329 | if (pi != i) |
353 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", | 330 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", |
354 | bi, pi, i); | 331 | bi, pi, i); |
@@ -376,9 +353,9 @@ static void hdmi_fill_audio_infoframe(struct hda_codec *codec, | |||
376 | sum += params[i]; | 353 | sum += params[i]; |
377 | ai->checksum = - sum; | 354 | ai->checksum = - sum; |
378 | 355 | ||
379 | hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); | 356 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
380 | for (i = 0; i < sizeof(ai); i++) | 357 | for (i = 0; i < sizeof(ai); i++) |
381 | hdmi_write_dip_byte(codec, PIN_NID, params[i]); | 358 | hdmi_write_dip_byte(codec, pin_nid, params[i]); |
382 | } | 359 | } |
383 | 360 | ||
384 | /* | 361 | /* |
@@ -465,6 +442,8 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec, | |||
465 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, | 442 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, |
466 | struct hdmi_audio_infoframe *ai) | 443 | struct hdmi_audio_infoframe *ai) |
467 | { | 444 | { |
445 | int i; | ||
446 | |||
468 | if (!ai->CA) | 447 | if (!ai->CA) |
469 | return; | 448 | return; |
470 | 449 | ||
@@ -473,7 +452,11 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec, | |||
473 | * ALSA sequence is front/surr/clfe/side? | 452 | * ALSA sequence is front/surr/clfe/side? |
474 | */ | 453 | */ |
475 | 454 | ||
476 | snd_hda_sequence_write(codec, def_chan_map); | 455 | for (i = 0; i < 8; i++) |
456 | snd_hda_codec_write(codec, cvt_nid, 0, | ||
457 | AC_VERB_SET_HDMI_CHAN_SLOT, | ||
458 | (i << 4) | i); | ||
459 | |||
477 | hdmi_debug_channel_mapping(codec); | 460 | hdmi_debug_channel_mapping(codec); |
478 | } | 461 | } |
479 | 462 | ||
@@ -597,7 +580,6 @@ static struct hda_pcm_stream intel_hdmi_pcm_playback = { | |||
597 | .substreams = 1, | 580 | .substreams = 1, |
598 | .channels_min = 2, | 581 | .channels_min = 2, |
599 | .channels_max = 8, | 582 | .channels_max = 8, |
600 | .nid = CVT_NID, /* NID to query formats and rates and setup streams */ | ||
601 | .ops = { | 583 | .ops = { |
602 | .open = intel_hdmi_playback_pcm_open, | 584 | .open = intel_hdmi_playback_pcm_open, |
603 | .close = intel_hdmi_playback_pcm_close, | 585 | .close = intel_hdmi_playback_pcm_close, |
@@ -613,6 +595,9 @@ static int intel_hdmi_build_pcms(struct hda_codec *codec) | |||
613 | codec->num_pcms = 1; | 595 | codec->num_pcms = 1; |
614 | codec->pcm_info = info; | 596 | codec->pcm_info = info; |
615 | 597 | ||
598 | /* NID to query formats and rates and setup streams */ | ||
599 | intel_hdmi_pcm_playback.nid = cvt_nid; | ||
600 | |||
616 | info->name = "INTEL HDMI"; | 601 | info->name = "INTEL HDMI"; |
617 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 602 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
618 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = intel_hdmi_pcm_playback; | 603 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = intel_hdmi_pcm_playback; |
@@ -636,8 +621,9 @@ static int intel_hdmi_init(struct hda_codec *codec) | |||
636 | { | 621 | { |
637 | hdmi_enable_output(codec); | 622 | hdmi_enable_output(codec); |
638 | 623 | ||
639 | snd_hda_sequence_write(codec, unsolicited_response_verb); | 624 | snd_hda_codec_write(codec, pin_nid, 0, |
640 | 625 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
626 | AC_USRSP_EN | INTEL_HDMI_EVENT_TAG); | ||
641 | return 0; | 627 | return 0; |
642 | } | 628 | } |
643 | 629 | ||
@@ -657,7 +643,7 @@ static struct hda_codec_ops intel_hdmi_patch_ops = { | |||
657 | .unsol_event = intel_hdmi_unsol_event, | 643 | .unsol_event = intel_hdmi_unsol_event, |
658 | }; | 644 | }; |
659 | 645 | ||
660 | static int patch_intel_hdmi(struct hda_codec *codec) | 646 | static int do_patch_intel_hdmi(struct hda_codec *codec) |
661 | { | 647 | { |
662 | struct intel_hdmi_spec *spec; | 648 | struct intel_hdmi_spec *spec; |
663 | 649 | ||
@@ -667,7 +653,7 @@ static int patch_intel_hdmi(struct hda_codec *codec) | |||
667 | 653 | ||
668 | spec->multiout.num_dacs = 0; /* no analog */ | 654 | spec->multiout.num_dacs = 0; /* no analog */ |
669 | spec->multiout.max_channels = 8; | 655 | spec->multiout.max_channels = 8; |
670 | spec->multiout.dig_out_nid = CVT_NID; | 656 | spec->multiout.dig_out_nid = cvt_nid; |
671 | 657 | ||
672 | codec->spec = spec; | 658 | codec->spec = spec; |
673 | codec->patch_ops = intel_hdmi_patch_ops; | 659 | codec->patch_ops = intel_hdmi_patch_ops; |
@@ -679,12 +665,27 @@ static int patch_intel_hdmi(struct hda_codec *codec) | |||
679 | return 0; | 665 | return 0; |
680 | } | 666 | } |
681 | 667 | ||
668 | static int patch_intel_hdmi(struct hda_codec *codec) | ||
669 | { | ||
670 | cvt_nid = 0x02; | ||
671 | pin_nid = 0x03; | ||
672 | return do_patch_intel_hdmi(codec); | ||
673 | } | ||
674 | |||
675 | static int patch_intel_hdmi_ibexpeak(struct hda_codec *codec) | ||
676 | { | ||
677 | cvt_nid = 0x02; | ||
678 | pin_nid = 0x04; | ||
679 | return do_patch_intel_hdmi(codec); | ||
680 | } | ||
681 | |||
682 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { | 682 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { |
683 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, | 683 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, |
684 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, | 684 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, |
685 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, | 685 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, |
686 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, | 686 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, |
687 | { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi }, | 687 | { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi }, |
688 | { .id = 0x80860054, .name = "Q57 DEVIBX", .patch = patch_intel_hdmi_ibexpeak }, | ||
688 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, | 689 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, |
689 | {} /* terminator */ | 690 | {} /* terminator */ |
690 | }; | 691 | }; |
@@ -694,6 +695,7 @@ MODULE_ALIAS("snd-hda-codec-id:80862801"); | |||
694 | MODULE_ALIAS("snd-hda-codec-id:80862802"); | 695 | MODULE_ALIAS("snd-hda-codec-id:80862802"); |
695 | MODULE_ALIAS("snd-hda-codec-id:80862803"); | 696 | MODULE_ALIAS("snd-hda-codec-id:80862803"); |
696 | MODULE_ALIAS("snd-hda-codec-id:80862804"); | 697 | MODULE_ALIAS("snd-hda-codec-id:80862804"); |
698 | MODULE_ALIAS("snd-hda-codec-id:80860054"); | ||
697 | MODULE_ALIAS("snd-hda-codec-id:10951392"); | 699 | MODULE_ALIAS("snd-hda-codec-id:10951392"); |
698 | 700 | ||
699 | MODULE_LICENSE("GPL"); | 701 | MODULE_LICENSE("GPL"); |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index f5792e2eea82..c8435c9a97f9 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -377,6 +377,7 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) | |||
377 | */ | 377 | */ |
378 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | 378 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { |
379 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 379 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
380 | { .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
380 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 381 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
381 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, | 382 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, |
382 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, | 383 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
@@ -385,6 +386,7 @@ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | |||
385 | }; | 386 | }; |
386 | 387 | ||
387 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); | 388 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); |
389 | MODULE_ALIAS("snd-hda-codec-id:10de0003"); | ||
388 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); | 390 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); |
389 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); | 391 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); |
390 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); | 392 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index fea976793ae5..7ed47f66ddd1 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -208,12 +208,6 @@ enum { | |||
208 | ALC885_MBP3, | 208 | ALC885_MBP3, |
209 | ALC885_MB5, | 209 | ALC885_MB5, |
210 | ALC885_IMAC24, | 210 | ALC885_IMAC24, |
211 | ALC882_AUTO, | ||
212 | ALC882_MODEL_LAST, | ||
213 | }; | ||
214 | |||
215 | /* ALC883 models */ | ||
216 | enum { | ||
217 | ALC883_3ST_2ch_DIG, | 211 | ALC883_3ST_2ch_DIG, |
218 | ALC883_3ST_6ch_DIG, | 212 | ALC883_3ST_6ch_DIG, |
219 | ALC883_3ST_6ch, | 213 | ALC883_3ST_6ch, |
@@ -226,6 +220,7 @@ enum { | |||
226 | ALC888_ACER_ASPIRE_4930G, | 220 | ALC888_ACER_ASPIRE_4930G, |
227 | ALC888_ACER_ASPIRE_6530G, | 221 | ALC888_ACER_ASPIRE_6530G, |
228 | ALC888_ACER_ASPIRE_8930G, | 222 | ALC888_ACER_ASPIRE_8930G, |
223 | ALC888_ACER_ASPIRE_7730G, | ||
229 | ALC883_MEDION, | 224 | ALC883_MEDION, |
230 | ALC883_MEDION_MD2, | 225 | ALC883_MEDION_MD2, |
231 | ALC883_LAPTOP_EAPD, | 226 | ALC883_LAPTOP_EAPD, |
@@ -237,17 +232,20 @@ enum { | |||
237 | ALC888_3ST_HP, | 232 | ALC888_3ST_HP, |
238 | ALC888_6ST_DELL, | 233 | ALC888_6ST_DELL, |
239 | ALC883_MITAC, | 234 | ALC883_MITAC, |
235 | ALC883_CLEVO_M540R, | ||
240 | ALC883_CLEVO_M720, | 236 | ALC883_CLEVO_M720, |
241 | ALC883_FUJITSU_PI2515, | 237 | ALC883_FUJITSU_PI2515, |
242 | ALC888_FUJITSU_XA3530, | 238 | ALC888_FUJITSU_XA3530, |
243 | ALC883_3ST_6ch_INTEL, | 239 | ALC883_3ST_6ch_INTEL, |
240 | ALC889A_INTEL, | ||
241 | ALC889_INTEL, | ||
244 | ALC888_ASUS_M90V, | 242 | ALC888_ASUS_M90V, |
245 | ALC888_ASUS_EEE1601, | 243 | ALC888_ASUS_EEE1601, |
246 | ALC889A_MB31, | 244 | ALC889A_MB31, |
247 | ALC1200_ASUS_P5Q, | 245 | ALC1200_ASUS_P5Q, |
248 | ALC883_SONY_VAIO_TT, | 246 | ALC883_SONY_VAIO_TT, |
249 | ALC883_AUTO, | 247 | ALC882_AUTO, |
250 | ALC883_MODEL_LAST, | 248 | ALC882_MODEL_LAST, |
251 | }; | 249 | }; |
252 | 250 | ||
253 | /* for GPIO Poll */ | 251 | /* for GPIO Poll */ |
@@ -262,6 +260,14 @@ enum { | |||
262 | ALC_INIT_GPIO3, | 260 | ALC_INIT_GPIO3, |
263 | }; | 261 | }; |
264 | 262 | ||
263 | struct alc_mic_route { | ||
264 | hda_nid_t pin; | ||
265 | unsigned char mux_idx; | ||
266 | unsigned char amix_idx; | ||
267 | }; | ||
268 | |||
269 | #define MUX_IDX_UNDEF ((unsigned char)-1) | ||
270 | |||
265 | struct alc_spec { | 271 | struct alc_spec { |
266 | /* codec parameterization */ | 272 | /* codec parameterization */ |
267 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ | 273 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
@@ -304,6 +310,8 @@ struct alc_spec { | |||
304 | unsigned int num_mux_defs; | 310 | unsigned int num_mux_defs; |
305 | const struct hda_input_mux *input_mux; | 311 | const struct hda_input_mux *input_mux; |
306 | unsigned int cur_mux[3]; | 312 | unsigned int cur_mux[3]; |
313 | struct alc_mic_route ext_mic; | ||
314 | struct alc_mic_route int_mic; | ||
307 | 315 | ||
308 | /* channel model */ | 316 | /* channel model */ |
309 | const struct hda_channel_mode *channel_mode; | 317 | const struct hda_channel_mode *channel_mode; |
@@ -320,6 +328,8 @@ struct alc_spec { | |||
320 | struct snd_array kctls; | 328 | struct snd_array kctls; |
321 | struct hda_input_mux private_imux[3]; | 329 | struct hda_input_mux private_imux[3]; |
322 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 330 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
331 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; | ||
332 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; | ||
323 | 333 | ||
324 | /* hooks */ | 334 | /* hooks */ |
325 | void (*init_hook)(struct hda_codec *codec); | 335 | void (*init_hook)(struct hda_codec *codec); |
@@ -329,6 +339,7 @@ struct alc_spec { | |||
329 | unsigned int sense_updated: 1; | 339 | unsigned int sense_updated: 1; |
330 | unsigned int jack_present: 1; | 340 | unsigned int jack_present: 1; |
331 | unsigned int master_sw: 1; | 341 | unsigned int master_sw: 1; |
342 | unsigned int auto_mic:1; | ||
332 | 343 | ||
333 | /* other flags */ | 344 | /* other flags */ |
334 | unsigned int no_analog :1; /* digital I/O only */ | 345 | unsigned int no_analog :1; /* digital I/O only */ |
@@ -370,6 +381,7 @@ struct alc_config_preset { | |||
370 | unsigned int num_mux_defs; | 381 | unsigned int num_mux_defs; |
371 | const struct hda_input_mux *input_mux; | 382 | const struct hda_input_mux *input_mux; |
372 | void (*unsol_event)(struct hda_codec *, unsigned int); | 383 | void (*unsol_event)(struct hda_codec *, unsigned int); |
384 | void (*setup)(struct hda_codec *); | ||
373 | void (*init_hook)(struct hda_codec *); | 385 | void (*init_hook)(struct hda_codec *); |
374 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 386 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
375 | struct hda_amp_list *loopbacks; | 387 | struct hda_amp_list *loopbacks; |
@@ -417,7 +429,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
417 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; | 429 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
418 | imux = &spec->input_mux[mux_idx]; | 430 | imux = &spec->input_mux[mux_idx]; |
419 | 431 | ||
420 | type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 432 | type = get_wcaps_type(get_wcaps(codec, nid)); |
421 | if (type == AC_WID_AUD_MIX) { | 433 | if (type == AC_WID_AUD_MIX) { |
422 | /* Matrix-mixer style (e.g. ALC882) */ | 434 | /* Matrix-mixer style (e.g. ALC882) */ |
423 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | 435 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
@@ -842,9 +854,10 @@ static void print_realtek_coef(struct snd_info_buffer *buffer, | |||
842 | /* | 854 | /* |
843 | * set up from the preset table | 855 | * set up from the preset table |
844 | */ | 856 | */ |
845 | static void setup_preset(struct alc_spec *spec, | 857 | static void setup_preset(struct hda_codec *codec, |
846 | const struct alc_config_preset *preset) | 858 | const struct alc_config_preset *preset) |
847 | { | 859 | { |
860 | struct alc_spec *spec = codec->spec; | ||
848 | int i; | 861 | int i; |
849 | 862 | ||
850 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | 863 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) |
@@ -886,6 +899,9 @@ static void setup_preset(struct alc_spec *spec, | |||
886 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 899 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
887 | spec->loopback.amplist = preset->loopbacks; | 900 | spec->loopback.amplist = preset->loopbacks; |
888 | #endif | 901 | #endif |
902 | |||
903 | if (preset->setup) | ||
904 | preset->setup(codec); | ||
889 | } | 905 | } |
890 | 906 | ||
891 | /* Enable GPIO mask and set output */ | 907 | /* Enable GPIO mask and set output */ |
@@ -965,30 +981,64 @@ static void alc_automute_pin(struct hda_codec *codec) | |||
965 | } | 981 | } |
966 | } | 982 | } |
967 | 983 | ||
968 | #if 0 /* it's broken in some cases -- temporarily disabled */ | 984 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
985 | hda_nid_t nid) | ||
986 | { | ||
987 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | ||
988 | int i, nums; | ||
989 | |||
990 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | ||
991 | for (i = 0; i < nums; i++) | ||
992 | if (conn[i] == nid) | ||
993 | return i; | ||
994 | return -1; | ||
995 | } | ||
996 | |||
969 | static void alc_mic_automute(struct hda_codec *codec) | 997 | static void alc_mic_automute(struct hda_codec *codec) |
970 | { | 998 | { |
971 | struct alc_spec *spec = codec->spec; | 999 | struct alc_spec *spec = codec->spec; |
972 | unsigned int present; | 1000 | struct alc_mic_route *dead, *alive; |
973 | unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | 1001 | unsigned int present, type; |
974 | unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | 1002 | hda_nid_t cap_nid; |
975 | unsigned int mix_nid = spec->capsrc_nids[0]; | 1003 | |
976 | unsigned int capsrc_idx_mic, capsrc_idx_fmic; | 1004 | if (!spec->auto_mic) |
977 | 1005 | return; | |
978 | capsrc_idx_mic = mic_nid - 0x18; | 1006 | if (!spec->int_mic.pin || !spec->ext_mic.pin) |
979 | capsrc_idx_fmic = fmic_nid - 0x18; | 1007 | return; |
980 | present = snd_hda_codec_read(codec, mic_nid, 0, | 1008 | if (snd_BUG_ON(!spec->adc_nids)) |
981 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1009 | return; |
982 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 1010 | |
983 | 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); | 1011 | cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; |
984 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 1012 | |
985 | 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); | 1013 | present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0, |
986 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, | 1014 | AC_VERB_GET_PIN_SENSE, 0); |
987 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 1015 | present &= AC_PINSENSE_PRESENCE; |
1016 | if (present) { | ||
1017 | alive = &spec->ext_mic; | ||
1018 | dead = &spec->int_mic; | ||
1019 | } else { | ||
1020 | alive = &spec->int_mic; | ||
1021 | dead = &spec->ext_mic; | ||
1022 | } | ||
1023 | |||
1024 | type = get_wcaps_type(get_wcaps(codec, cap_nid)); | ||
1025 | if (type == AC_WID_AUD_MIX) { | ||
1026 | /* Matrix-mixer style (e.g. ALC882) */ | ||
1027 | snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT, | ||
1028 | alive->mux_idx, | ||
1029 | HDA_AMP_MUTE, 0); | ||
1030 | snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT, | ||
1031 | dead->mux_idx, | ||
1032 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
1033 | } else { | ||
1034 | /* MUX style (e.g. ALC880) */ | ||
1035 | snd_hda_codec_write_cache(codec, cap_nid, 0, | ||
1036 | AC_VERB_SET_CONNECT_SEL, | ||
1037 | alive->mux_idx); | ||
1038 | } | ||
1039 | |||
1040 | /* FIXME: analog mixer */ | ||
988 | } | 1041 | } |
989 | #else | ||
990 | #define alc_mic_automute(codec) do {} while(0) /* NOP */ | ||
991 | #endif /* disabled */ | ||
992 | 1042 | ||
993 | /* unsolicited event for HP jack sensing */ | 1043 | /* unsolicited event for HP jack sensing */ |
994 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | 1044 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
@@ -1031,6 +1081,16 @@ static void alc888_coef_init(struct hda_codec *codec) | |||
1031 | AC_VERB_SET_PROC_COEF, 0x3030); | 1081 | AC_VERB_SET_PROC_COEF, 0x3030); |
1032 | } | 1082 | } |
1033 | 1083 | ||
1084 | static void alc889_coef_init(struct hda_codec *codec) | ||
1085 | { | ||
1086 | unsigned int tmp; | ||
1087 | |||
1088 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | ||
1089 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | ||
1090 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | ||
1091 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); | ||
1092 | } | ||
1093 | |||
1034 | static void alc_auto_init_amp(struct hda_codec *codec, int type) | 1094 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
1035 | { | 1095 | { |
1036 | unsigned int tmp; | 1096 | unsigned int tmp; |
@@ -1088,15 +1148,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) | |||
1088 | case 0x10ec0885: | 1148 | case 0x10ec0885: |
1089 | case 0x10ec0887: | 1149 | case 0x10ec0887: |
1090 | case 0x10ec0889: | 1150 | case 0x10ec0889: |
1091 | snd_hda_codec_write(codec, 0x20, 0, | 1151 | alc889_coef_init(codec); |
1092 | AC_VERB_SET_COEF_INDEX, 7); | ||
1093 | tmp = snd_hda_codec_read(codec, 0x20, 0, | ||
1094 | AC_VERB_GET_PROC_COEF, 0); | ||
1095 | snd_hda_codec_write(codec, 0x20, 0, | ||
1096 | AC_VERB_SET_COEF_INDEX, 7); | ||
1097 | snd_hda_codec_write(codec, 0x20, 0, | ||
1098 | AC_VERB_SET_PROC_COEF, | ||
1099 | tmp | 0x2010); | ||
1100 | break; | 1152 | break; |
1101 | case 0x10ec0888: | 1153 | case 0x10ec0888: |
1102 | alc888_coef_init(codec); | 1154 | alc888_coef_init(codec); |
@@ -1142,6 +1194,55 @@ static void alc_init_auto_hp(struct hda_codec *codec) | |||
1142 | spec->unsol_event = alc_sku_unsol_event; | 1194 | spec->unsol_event = alc_sku_unsol_event; |
1143 | } | 1195 | } |
1144 | 1196 | ||
1197 | static void alc_init_auto_mic(struct hda_codec *codec) | ||
1198 | { | ||
1199 | struct alc_spec *spec = codec->spec; | ||
1200 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
1201 | hda_nid_t fixed, ext; | ||
1202 | int i; | ||
1203 | |||
1204 | /* there must be only two mic inputs exclusively */ | ||
1205 | for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) | ||
1206 | if (cfg->input_pins[i]) | ||
1207 | return; | ||
1208 | |||
1209 | fixed = ext = 0; | ||
1210 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) { | ||
1211 | hda_nid_t nid = cfg->input_pins[i]; | ||
1212 | unsigned int defcfg; | ||
1213 | if (!nid) | ||
1214 | return; | ||
1215 | defcfg = snd_hda_codec_get_pincfg(codec, nid); | ||
1216 | switch (get_defcfg_connect(defcfg)) { | ||
1217 | case AC_JACK_PORT_FIXED: | ||
1218 | if (fixed) | ||
1219 | return; /* already occupied */ | ||
1220 | fixed = nid; | ||
1221 | break; | ||
1222 | case AC_JACK_PORT_COMPLEX: | ||
1223 | if (ext) | ||
1224 | return; /* already occupied */ | ||
1225 | ext = nid; | ||
1226 | break; | ||
1227 | default: | ||
1228 | return; /* invalid entry */ | ||
1229 | } | ||
1230 | } | ||
1231 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | ||
1232 | return; /* no unsol support */ | ||
1233 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n", | ||
1234 | ext, fixed); | ||
1235 | spec->ext_mic.pin = ext; | ||
1236 | spec->int_mic.pin = fixed; | ||
1237 | spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */ | ||
1238 | spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */ | ||
1239 | spec->auto_mic = 1; | ||
1240 | snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0, | ||
1241 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1242 | AC_USRSP_EN | ALC880_MIC_EVENT); | ||
1243 | spec->unsol_event = alc_sku_unsol_event; | ||
1244 | } | ||
1245 | |||
1145 | /* check subsystem ID and set up device-specific initialization; | 1246 | /* check subsystem ID and set up device-specific initialization; |
1146 | * return 1 if initialized, 0 if invalid SSID | 1247 | * return 1 if initialized, 0 if invalid SSID |
1147 | */ | 1248 | */ |
@@ -1243,6 +1344,7 @@ do_sku: | |||
1243 | } | 1344 | } |
1244 | 1345 | ||
1245 | alc_init_auto_hp(codec); | 1346 | alc_init_auto_hp(codec); |
1347 | alc_init_auto_mic(codec); | ||
1246 | return 1; | 1348 | return 1; |
1247 | } | 1349 | } |
1248 | 1350 | ||
@@ -1255,6 +1357,7 @@ static void alc_ssid_check(struct hda_codec *codec, | |||
1255 | "Enable default setup for auto mode as fallback\n"); | 1357 | "Enable default setup for auto mode as fallback\n"); |
1256 | spec->init_amp = ALC_INIT_DEFAULT; | 1358 | spec->init_amp = ALC_INIT_DEFAULT; |
1257 | alc_init_auto_hp(codec); | 1359 | alc_init_auto_hp(codec); |
1360 | alc_init_auto_mic(codec); | ||
1258 | } | 1361 | } |
1259 | } | 1362 | } |
1260 | 1363 | ||
@@ -1436,7 +1539,25 @@ static void alc_automute_amp_unsol_event(struct hda_codec *codec, | |||
1436 | alc_automute_amp(codec); | 1539 | alc_automute_amp(codec); |
1437 | } | 1540 | } |
1438 | 1541 | ||
1439 | static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) | 1542 | static void alc889_automute_setup(struct hda_codec *codec) |
1543 | { | ||
1544 | struct alc_spec *spec = codec->spec; | ||
1545 | |||
1546 | spec->autocfg.hp_pins[0] = 0x15; | ||
1547 | spec->autocfg.speaker_pins[0] = 0x14; | ||
1548 | spec->autocfg.speaker_pins[1] = 0x16; | ||
1549 | spec->autocfg.speaker_pins[2] = 0x17; | ||
1550 | spec->autocfg.speaker_pins[3] = 0x19; | ||
1551 | spec->autocfg.speaker_pins[4] = 0x1a; | ||
1552 | } | ||
1553 | |||
1554 | static void alc889_intel_init_hook(struct hda_codec *codec) | ||
1555 | { | ||
1556 | alc889_coef_init(codec); | ||
1557 | alc_automute_amp(codec); | ||
1558 | } | ||
1559 | |||
1560 | static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec) | ||
1440 | { | 1561 | { |
1441 | struct alc_spec *spec = codec->spec; | 1562 | struct alc_spec *spec = codec->spec; |
1442 | 1563 | ||
@@ -1444,7 +1565,6 @@ static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) | |||
1444 | spec->autocfg.hp_pins[1] = 0x1b; /* hp */ | 1565 | spec->autocfg.hp_pins[1] = 0x1b; /* hp */ |
1445 | spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ | 1566 | spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ |
1446 | spec->autocfg.speaker_pins[1] = 0x15; /* bass */ | 1567 | spec->autocfg.speaker_pins[1] = 0x15; /* bass */ |
1447 | alc_automute_amp(codec); | ||
1448 | } | 1568 | } |
1449 | 1569 | ||
1450 | /* | 1570 | /* |
@@ -1643,16 +1763,15 @@ static struct snd_kcontrol_new alc888_base_mixer[] = { | |||
1643 | { } /* end */ | 1763 | { } /* end */ |
1644 | }; | 1764 | }; |
1645 | 1765 | ||
1646 | static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) | 1766 | static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) |
1647 | { | 1767 | { |
1648 | struct alc_spec *spec = codec->spec; | 1768 | struct alc_spec *spec = codec->spec; |
1649 | 1769 | ||
1650 | spec->autocfg.hp_pins[0] = 0x15; | 1770 | spec->autocfg.hp_pins[0] = 0x15; |
1651 | spec->autocfg.speaker_pins[0] = 0x14; | 1771 | spec->autocfg.speaker_pins[0] = 0x14; |
1652 | alc_automute_amp(codec); | ||
1653 | } | 1772 | } |
1654 | 1773 | ||
1655 | static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec) | 1774 | static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) |
1656 | { | 1775 | { |
1657 | struct alc_spec *spec = codec->spec; | 1776 | struct alc_spec *spec = codec->spec; |
1658 | 1777 | ||
@@ -1660,10 +1779,9 @@ static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec) | |||
1660 | spec->autocfg.speaker_pins[0] = 0x14; | 1779 | spec->autocfg.speaker_pins[0] = 0x14; |
1661 | spec->autocfg.speaker_pins[1] = 0x16; | 1780 | spec->autocfg.speaker_pins[1] = 0x16; |
1662 | spec->autocfg.speaker_pins[2] = 0x17; | 1781 | spec->autocfg.speaker_pins[2] = 0x17; |
1663 | alc_automute_amp(codec); | ||
1664 | } | 1782 | } |
1665 | 1783 | ||
1666 | static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) | 1784 | static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) |
1667 | { | 1785 | { |
1668 | struct alc_spec *spec = codec->spec; | 1786 | struct alc_spec *spec = codec->spec; |
1669 | 1787 | ||
@@ -1671,7 +1789,6 @@ static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) | |||
1671 | spec->autocfg.speaker_pins[0] = 0x14; | 1789 | spec->autocfg.speaker_pins[0] = 0x14; |
1672 | spec->autocfg.speaker_pins[1] = 0x16; | 1790 | spec->autocfg.speaker_pins[1] = 0x16; |
1673 | spec->autocfg.speaker_pins[2] = 0x1b; | 1791 | spec->autocfg.speaker_pins[2] = 0x1b; |
1674 | alc_automute_amp(codec); | ||
1675 | } | 1792 | } |
1676 | 1793 | ||
1677 | /* | 1794 | /* |
@@ -2651,13 +2768,17 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |||
2651 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 2768 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
2652 | } | 2769 | } |
2653 | 2770 | ||
2654 | static void alc880_uniwill_init_hook(struct hda_codec *codec) | 2771 | static void alc880_uniwill_setup(struct hda_codec *codec) |
2655 | { | 2772 | { |
2656 | struct alc_spec *spec = codec->spec; | 2773 | struct alc_spec *spec = codec->spec; |
2657 | 2774 | ||
2658 | spec->autocfg.hp_pins[0] = 0x14; | 2775 | spec->autocfg.hp_pins[0] = 0x14; |
2659 | spec->autocfg.speaker_pins[0] = 0x15; | 2776 | spec->autocfg.speaker_pins[0] = 0x15; |
2660 | spec->autocfg.speaker_pins[0] = 0x16; | 2777 | spec->autocfg.speaker_pins[0] = 0x16; |
2778 | } | ||
2779 | |||
2780 | static void alc880_uniwill_init_hook(struct hda_codec *codec) | ||
2781 | { | ||
2661 | alc_automute_amp(codec); | 2782 | alc_automute_amp(codec); |
2662 | alc880_uniwill_mic_automute(codec); | 2783 | alc880_uniwill_mic_automute(codec); |
2663 | } | 2784 | } |
@@ -2678,13 +2799,12 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |||
2678 | } | 2799 | } |
2679 | } | 2800 | } |
2680 | 2801 | ||
2681 | static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) | 2802 | static void alc880_uniwill_p53_setup(struct hda_codec *codec) |
2682 | { | 2803 | { |
2683 | struct alc_spec *spec = codec->spec; | 2804 | struct alc_spec *spec = codec->spec; |
2684 | 2805 | ||
2685 | spec->autocfg.hp_pins[0] = 0x14; | 2806 | spec->autocfg.hp_pins[0] = 0x14; |
2686 | spec->autocfg.speaker_pins[0] = 0x15; | 2807 | spec->autocfg.speaker_pins[0] = 0x15; |
2687 | alc_automute_amp(codec); | ||
2688 | } | 2808 | } |
2689 | 2809 | ||
2690 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | 2810 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) |
@@ -2947,13 +3067,12 @@ static struct hda_verb alc880_lg_init_verbs[] = { | |||
2947 | }; | 3067 | }; |
2948 | 3068 | ||
2949 | /* toggle speaker-output according to the hp-jack state */ | 3069 | /* toggle speaker-output according to the hp-jack state */ |
2950 | static void alc880_lg_init_hook(struct hda_codec *codec) | 3070 | static void alc880_lg_setup(struct hda_codec *codec) |
2951 | { | 3071 | { |
2952 | struct alc_spec *spec = codec->spec; | 3072 | struct alc_spec *spec = codec->spec; |
2953 | 3073 | ||
2954 | spec->autocfg.hp_pins[0] = 0x1b; | 3074 | spec->autocfg.hp_pins[0] = 0x1b; |
2955 | spec->autocfg.speaker_pins[0] = 0x17; | 3075 | spec->autocfg.speaker_pins[0] = 0x17; |
2956 | alc_automute_amp(codec); | ||
2957 | } | 3076 | } |
2958 | 3077 | ||
2959 | /* | 3078 | /* |
@@ -3032,13 +3151,12 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = { | |||
3032 | }; | 3151 | }; |
3033 | 3152 | ||
3034 | /* toggle speaker-output according to the hp-jack state */ | 3153 | /* toggle speaker-output according to the hp-jack state */ |
3035 | static void alc880_lg_lw_init_hook(struct hda_codec *codec) | 3154 | static void alc880_lg_lw_setup(struct hda_codec *codec) |
3036 | { | 3155 | { |
3037 | struct alc_spec *spec = codec->spec; | 3156 | struct alc_spec *spec = codec->spec; |
3038 | 3157 | ||
3039 | spec->autocfg.hp_pins[0] = 0x1b; | 3158 | spec->autocfg.hp_pins[0] = 0x1b; |
3040 | spec->autocfg.speaker_pins[0] = 0x14; | 3159 | spec->autocfg.speaker_pins[0] = 0x14; |
3041 | alc_automute_amp(codec); | ||
3042 | } | 3160 | } |
3043 | 3161 | ||
3044 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { | 3162 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
@@ -3104,13 +3222,12 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |||
3104 | alc880_medion_rim_automute(codec); | 3222 | alc880_medion_rim_automute(codec); |
3105 | } | 3223 | } |
3106 | 3224 | ||
3107 | static void alc880_medion_rim_init_hook(struct hda_codec *codec) | 3225 | static void alc880_medion_rim_setup(struct hda_codec *codec) |
3108 | { | 3226 | { |
3109 | struct alc_spec *spec = codec->spec; | 3227 | struct alc_spec *spec = codec->spec; |
3110 | 3228 | ||
3111 | spec->autocfg.hp_pins[0] = 0x14; | 3229 | spec->autocfg.hp_pins[0] = 0x14; |
3112 | spec->autocfg.speaker_pins[0] = 0x1b; | 3230 | spec->autocfg.speaker_pins[0] = 0x1b; |
3113 | alc880_medion_rim_automute(codec); | ||
3114 | } | 3231 | } |
3115 | 3232 | ||
3116 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3233 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -3977,7 +4094,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
3977 | .channel_mode = alc880_2_jack_modes, | 4094 | .channel_mode = alc880_2_jack_modes, |
3978 | .input_mux = &alc880_f1734_capture_source, | 4095 | .input_mux = &alc880_f1734_capture_source, |
3979 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4096 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3980 | .init_hook = alc880_uniwill_p53_init_hook, | 4097 | .setup = alc880_uniwill_p53_setup, |
4098 | .init_hook = alc_automute_amp, | ||
3981 | }, | 4099 | }, |
3982 | [ALC880_ASUS] = { | 4100 | [ALC880_ASUS] = { |
3983 | .mixers = { alc880_asus_mixer }, | 4101 | .mixers = { alc880_asus_mixer }, |
@@ -4054,6 +4172,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
4054 | .need_dac_fix = 1, | 4172 | .need_dac_fix = 1, |
4055 | .input_mux = &alc880_capture_source, | 4173 | .input_mux = &alc880_capture_source, |
4056 | .unsol_event = alc880_uniwill_unsol_event, | 4174 | .unsol_event = alc880_uniwill_unsol_event, |
4175 | .setup = alc880_uniwill_setup, | ||
4057 | .init_hook = alc880_uniwill_init_hook, | 4176 | .init_hook = alc880_uniwill_init_hook, |
4058 | }, | 4177 | }, |
4059 | [ALC880_UNIWILL_P53] = { | 4178 | [ALC880_UNIWILL_P53] = { |
@@ -4066,7 +4185,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4066 | .channel_mode = alc880_threestack_modes, | 4185 | .channel_mode = alc880_threestack_modes, |
4067 | .input_mux = &alc880_capture_source, | 4186 | .input_mux = &alc880_capture_source, |
4068 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4187 | .unsol_event = alc880_uniwill_p53_unsol_event, |
4069 | .init_hook = alc880_uniwill_p53_init_hook, | 4188 | .setup = alc880_uniwill_p53_setup, |
4189 | .init_hook = alc_automute_amp, | ||
4070 | }, | 4190 | }, |
4071 | [ALC880_FUJITSU] = { | 4191 | [ALC880_FUJITSU] = { |
4072 | .mixers = { alc880_fujitsu_mixer }, | 4192 | .mixers = { alc880_fujitsu_mixer }, |
@@ -4080,7 +4200,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4080 | .channel_mode = alc880_2_jack_modes, | 4200 | .channel_mode = alc880_2_jack_modes, |
4081 | .input_mux = &alc880_capture_source, | 4201 | .input_mux = &alc880_capture_source, |
4082 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4202 | .unsol_event = alc880_uniwill_p53_unsol_event, |
4083 | .init_hook = alc880_uniwill_p53_init_hook, | 4203 | .setup = alc880_uniwill_p53_setup, |
4204 | .init_hook = alc_automute_amp, | ||
4084 | }, | 4205 | }, |
4085 | [ALC880_CLEVO] = { | 4206 | [ALC880_CLEVO] = { |
4086 | .mixers = { alc880_three_stack_mixer }, | 4207 | .mixers = { alc880_three_stack_mixer }, |
@@ -4106,7 +4227,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4106 | .need_dac_fix = 1, | 4227 | .need_dac_fix = 1, |
4107 | .input_mux = &alc880_lg_capture_source, | 4228 | .input_mux = &alc880_lg_capture_source, |
4108 | .unsol_event = alc_automute_amp_unsol_event, | 4229 | .unsol_event = alc_automute_amp_unsol_event, |
4109 | .init_hook = alc880_lg_init_hook, | 4230 | .setup = alc880_lg_setup, |
4231 | .init_hook = alc_automute_amp, | ||
4110 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4232 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4111 | .loopbacks = alc880_lg_loopbacks, | 4233 | .loopbacks = alc880_lg_loopbacks, |
4112 | #endif | 4234 | #endif |
@@ -4122,7 +4244,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4122 | .channel_mode = alc880_lg_lw_modes, | 4244 | .channel_mode = alc880_lg_lw_modes, |
4123 | .input_mux = &alc880_lg_lw_capture_source, | 4245 | .input_mux = &alc880_lg_lw_capture_source, |
4124 | .unsol_event = alc_automute_amp_unsol_event, | 4246 | .unsol_event = alc_automute_amp_unsol_event, |
4125 | .init_hook = alc880_lg_lw_init_hook, | 4247 | .setup = alc880_lg_lw_setup, |
4248 | .init_hook = alc_automute_amp, | ||
4126 | }, | 4249 | }, |
4127 | [ALC880_MEDION_RIM] = { | 4250 | [ALC880_MEDION_RIM] = { |
4128 | .mixers = { alc880_medion_rim_mixer }, | 4251 | .mixers = { alc880_medion_rim_mixer }, |
@@ -4136,7 +4259,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4136 | .channel_mode = alc880_2_jack_modes, | 4259 | .channel_mode = alc880_2_jack_modes, |
4137 | .input_mux = &alc880_medion_rim_capture_source, | 4260 | .input_mux = &alc880_medion_rim_capture_source, |
4138 | .unsol_event = alc880_medion_rim_unsol_event, | 4261 | .unsol_event = alc880_medion_rim_unsol_event, |
4139 | .init_hook = alc880_medion_rim_init_hook, | 4262 | .setup = alc880_medion_rim_setup, |
4263 | .init_hook = alc880_medion_rim_automute, | ||
4140 | }, | 4264 | }, |
4141 | #ifdef CONFIG_SND_DEBUG | 4265 | #ifdef CONFIG_SND_DEBUG |
4142 | [ALC880_TEST] = { | 4266 | [ALC880_TEST] = { |
@@ -4189,8 +4313,6 @@ static int add_control(struct alc_spec *spec, int type, const char *name, | |||
4189 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | 4313 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
4190 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | 4314 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
4191 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | 4315 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) |
4192 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | ||
4193 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | ||
4194 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | 4316 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) |
4195 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | 4317 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) |
4196 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | 4318 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) |
@@ -4278,13 +4400,19 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4278 | if (err < 0) | 4400 | if (err < 0) |
4279 | return err; | 4401 | return err; |
4280 | } else { | 4402 | } else { |
4281 | sprintf(name, "%s Playback Volume", chname[i]); | 4403 | const char *pfx; |
4404 | if (cfg->line_outs == 1 && | ||
4405 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
4406 | pfx = "Speaker"; | ||
4407 | else | ||
4408 | pfx = chname[i]; | ||
4409 | sprintf(name, "%s Playback Volume", pfx); | ||
4282 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 4410 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4283 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 4411 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
4284 | HDA_OUTPUT)); | 4412 | HDA_OUTPUT)); |
4285 | if (err < 0) | 4413 | if (err < 0) |
4286 | return err; | 4414 | return err; |
4287 | sprintf(name, "%s Playback Switch", chname[i]); | 4415 | sprintf(name, "%s Playback Switch", pfx); |
4288 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | 4416 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4289 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | 4417 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
4290 | HDA_INPUT)); | 4418 | HDA_INPUT)); |
@@ -4358,31 +4486,61 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, | |||
4358 | return 0; | 4486 | return 0; |
4359 | } | 4487 | } |
4360 | 4488 | ||
4489 | static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) | ||
4490 | { | ||
4491 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | ||
4492 | return (pincap & AC_PINCAP_IN) != 0; | ||
4493 | } | ||
4494 | |||
4361 | /* create playback/capture controls for input pins */ | 4495 | /* create playback/capture controls for input pins */ |
4362 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, | 4496 | static int alc_auto_create_input_ctls(struct hda_codec *codec, |
4363 | const struct auto_pin_cfg *cfg) | 4497 | const struct auto_pin_cfg *cfg, |
4498 | hda_nid_t mixer, | ||
4499 | hda_nid_t cap1, hda_nid_t cap2) | ||
4364 | { | 4500 | { |
4501 | struct alc_spec *spec = codec->spec; | ||
4365 | struct hda_input_mux *imux = &spec->private_imux[0]; | 4502 | struct hda_input_mux *imux = &spec->private_imux[0]; |
4366 | int i, err, idx; | 4503 | int i, err, idx; |
4367 | 4504 | ||
4368 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 4505 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
4369 | if (alc880_is_input_pin(cfg->input_pins[i])) { | 4506 | hda_nid_t pin; |
4370 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | 4507 | |
4371 | err = new_analog_input(spec, cfg->input_pins[i], | 4508 | pin = cfg->input_pins[i]; |
4372 | auto_pin_cfg_labels[i], | 4509 | if (!alc_is_input_pin(codec, pin)) |
4373 | idx, 0x0b); | 4510 | continue; |
4374 | if (err < 0) | 4511 | |
4375 | return err; | 4512 | if (mixer) { |
4513 | idx = get_connection_index(codec, mixer, pin); | ||
4514 | if (idx >= 0) { | ||
4515 | err = new_analog_input(spec, pin, | ||
4516 | auto_pin_cfg_labels[i], | ||
4517 | idx, mixer); | ||
4518 | if (err < 0) | ||
4519 | return err; | ||
4520 | } | ||
4521 | } | ||
4522 | |||
4523 | if (!cap1) | ||
4524 | continue; | ||
4525 | idx = get_connection_index(codec, cap1, pin); | ||
4526 | if (idx < 0 && cap2) | ||
4527 | idx = get_connection_index(codec, cap2, pin); | ||
4528 | if (idx >= 0) { | ||
4376 | imux->items[imux->num_items].label = | 4529 | imux->items[imux->num_items].label = |
4377 | auto_pin_cfg_labels[i]; | 4530 | auto_pin_cfg_labels[i]; |
4378 | imux->items[imux->num_items].index = | 4531 | imux->items[imux->num_items].index = idx; |
4379 | alc880_input_pin_idx(cfg->input_pins[i]); | ||
4380 | imux->num_items++; | 4532 | imux->num_items++; |
4381 | } | 4533 | } |
4382 | } | 4534 | } |
4383 | return 0; | 4535 | return 0; |
4384 | } | 4536 | } |
4385 | 4537 | ||
4538 | static int alc880_auto_create_input_ctls(struct hda_codec *codec, | ||
4539 | const struct auto_pin_cfg *cfg) | ||
4540 | { | ||
4541 | return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09); | ||
4542 | } | ||
4543 | |||
4386 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, | 4544 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
4387 | unsigned int pin_type) | 4545 | unsigned int pin_type) |
4388 | { | 4546 | { |
@@ -4448,7 +4606,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec) | |||
4448 | 4606 | ||
4449 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 4607 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
4450 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 4608 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
4451 | if (alc880_is_input_pin(nid)) { | 4609 | if (alc_is_input_pin(codec, nid)) { |
4452 | alc_set_input_pin(codec, nid, i); | 4610 | alc_set_input_pin(codec, nid, i); |
4453 | if (nid != ALC880_PIN_CD_NID && | 4611 | if (nid != ALC880_PIN_CD_NID && |
4454 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 4612 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
@@ -4491,7 +4649,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4491 | "Headphone"); | 4649 | "Headphone"); |
4492 | if (err < 0) | 4650 | if (err < 0) |
4493 | return err; | 4651 | return err; |
4494 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | 4652 | err = alc880_auto_create_input_ctls(codec, &spec->autocfg); |
4495 | if (err < 0) | 4653 | if (err < 0) |
4496 | return err; | 4654 | return err; |
4497 | 4655 | ||
@@ -4505,12 +4663,6 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4505 | &dig_nid, 1); | 4663 | &dig_nid, 1); |
4506 | if (err < 0) | 4664 | if (err < 0) |
4507 | continue; | 4665 | continue; |
4508 | if (dig_nid > 0x7f) { | ||
4509 | printk(KERN_ERR "alc880_auto: invalid dig_nid " | ||
4510 | "connection 0x%x for NID 0x%x\n", dig_nid, | ||
4511 | spec->autocfg.dig_out_pins[i]); | ||
4512 | continue; | ||
4513 | } | ||
4514 | if (!i) | 4666 | if (!i) |
4515 | spec->multiout.dig_out_nid = dig_nid; | 4667 | spec->multiout.dig_out_nid = dig_nid; |
4516 | else { | 4668 | else { |
@@ -4547,8 +4699,42 @@ static void alc880_auto_init(struct hda_codec *codec) | |||
4547 | alc_inithook(codec); | 4699 | alc_inithook(codec); |
4548 | } | 4700 | } |
4549 | 4701 | ||
4550 | static void set_capture_mixer(struct alc_spec *spec) | 4702 | /* check the ADC/MUX contains all input pins; some ADC/MUX contains only |
4703 | * one of two digital mic pins, e.g. on ALC272 | ||
4704 | */ | ||
4705 | static void fixup_automic_adc(struct hda_codec *codec) | ||
4551 | { | 4706 | { |
4707 | struct alc_spec *spec = codec->spec; | ||
4708 | int i; | ||
4709 | |||
4710 | for (i = 0; i < spec->num_adc_nids; i++) { | ||
4711 | hda_nid_t cap = spec->capsrc_nids ? | ||
4712 | spec->capsrc_nids[i] : spec->adc_nids[i]; | ||
4713 | int iidx, eidx; | ||
4714 | |||
4715 | iidx = get_connection_index(codec, cap, spec->int_mic.pin); | ||
4716 | if (iidx < 0) | ||
4717 | continue; | ||
4718 | eidx = get_connection_index(codec, cap, spec->ext_mic.pin); | ||
4719 | if (eidx < 0) | ||
4720 | continue; | ||
4721 | spec->int_mic.mux_idx = iidx; | ||
4722 | spec->ext_mic.mux_idx = eidx; | ||
4723 | if (spec->capsrc_nids) | ||
4724 | spec->capsrc_nids += i; | ||
4725 | spec->adc_nids += i; | ||
4726 | spec->num_adc_nids = 1; | ||
4727 | return; | ||
4728 | } | ||
4729 | snd_printd(KERN_INFO "hda_codec: %s: " | ||
4730 | "No ADC/MUX containing both 0x%x and 0x%x pins\n", | ||
4731 | codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin); | ||
4732 | spec->auto_mic = 0; /* disable auto-mic to be sure */ | ||
4733 | } | ||
4734 | |||
4735 | static void set_capture_mixer(struct hda_codec *codec) | ||
4736 | { | ||
4737 | struct alc_spec *spec = codec->spec; | ||
4552 | static struct snd_kcontrol_new *caps[2][3] = { | 4738 | static struct snd_kcontrol_new *caps[2][3] = { |
4553 | { alc_capture_mixer_nosrc1, | 4739 | { alc_capture_mixer_nosrc1, |
4554 | alc_capture_mixer_nosrc2, | 4740 | alc_capture_mixer_nosrc2, |
@@ -4559,7 +4745,10 @@ static void set_capture_mixer(struct alc_spec *spec) | |||
4559 | }; | 4745 | }; |
4560 | if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { | 4746 | if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { |
4561 | int mux; | 4747 | int mux; |
4562 | if (spec->input_mux && spec->input_mux->num_items > 1) | 4748 | if (spec->auto_mic) { |
4749 | mux = 0; | ||
4750 | fixup_automic_adc(codec); | ||
4751 | } else if (spec->input_mux && spec->input_mux->num_items > 1) | ||
4563 | mux = 1; | 4752 | mux = 1; |
4564 | else | 4753 | else |
4565 | mux = 0; | 4754 | mux = 0; |
@@ -4590,8 +4779,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
4590 | alc880_models, | 4779 | alc880_models, |
4591 | alc880_cfg_tbl); | 4780 | alc880_cfg_tbl); |
4592 | if (board_config < 0) { | 4781 | if (board_config < 0) { |
4593 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 4782 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4594 | "trying auto-probe from BIOS...\n", codec->chip_name); | 4783 | codec->chip_name); |
4595 | board_config = ALC880_AUTO; | 4784 | board_config = ALC880_AUTO; |
4596 | } | 4785 | } |
4597 | 4786 | ||
@@ -4616,7 +4805,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4616 | } | 4805 | } |
4617 | 4806 | ||
4618 | if (board_config != ALC880_AUTO) | 4807 | if (board_config != ALC880_AUTO) |
4619 | setup_preset(spec, &alc880_presets[board_config]); | 4808 | setup_preset(codec, &alc880_presets[board_config]); |
4620 | 4809 | ||
4621 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | 4810 | spec->stream_analog_playback = &alc880_pcm_analog_playback; |
4622 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | 4811 | spec->stream_analog_capture = &alc880_pcm_analog_capture; |
@@ -4629,7 +4818,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4629 | /* check whether NID 0x07 is valid */ | 4818 | /* check whether NID 0x07 is valid */ |
4630 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); | 4819 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
4631 | /* get type */ | 4820 | /* get type */ |
4632 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 4821 | wcap = get_wcaps_type(wcap); |
4633 | if (wcap != AC_WID_AUD_IN) { | 4822 | if (wcap != AC_WID_AUD_IN) { |
4634 | spec->adc_nids = alc880_adc_nids_alt; | 4823 | spec->adc_nids = alc880_adc_nids_alt; |
4635 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | 4824 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); |
@@ -4638,7 +4827,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4638 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | 4827 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); |
4639 | } | 4828 | } |
4640 | } | 4829 | } |
4641 | set_capture_mixer(spec); | 4830 | set_capture_mixer(codec); |
4642 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 4831 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
4643 | 4832 | ||
4644 | spec->vmaster_nid = 0x0c; | 4833 | spec->vmaster_nid = 0x0c; |
@@ -5830,7 +6019,14 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
5830 | 6019 | ||
5831 | nid = cfg->line_out_pins[0]; | 6020 | nid = cfg->line_out_pins[0]; |
5832 | if (nid) { | 6021 | if (nid) { |
5833 | err = alc260_add_playback_controls(spec, nid, "Front", &vols); | 6022 | const char *pfx; |
6023 | if (!cfg->speaker_pins[0] && !cfg->hp_pins[0]) | ||
6024 | pfx = "Master"; | ||
6025 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
6026 | pfx = "Speaker"; | ||
6027 | else | ||
6028 | pfx = "Front"; | ||
6029 | err = alc260_add_playback_controls(spec, nid, pfx, &vols); | ||
5834 | if (err < 0) | 6030 | if (err < 0) |
5835 | return err; | 6031 | return err; |
5836 | } | 6032 | } |
@@ -5853,39 +6049,10 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
5853 | } | 6049 | } |
5854 | 6050 | ||
5855 | /* create playback/capture controls for input pins */ | 6051 | /* create playback/capture controls for input pins */ |
5856 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | 6052 | static int alc260_auto_create_input_ctls(struct hda_codec *codec, |
5857 | const struct auto_pin_cfg *cfg) | 6053 | const struct auto_pin_cfg *cfg) |
5858 | { | 6054 | { |
5859 | struct hda_input_mux *imux = &spec->private_imux[0]; | 6055 | return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05); |
5860 | int i, err, idx; | ||
5861 | |||
5862 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
5863 | if (cfg->input_pins[i] >= 0x12) { | ||
5864 | idx = cfg->input_pins[i] - 0x12; | ||
5865 | err = new_analog_input(spec, cfg->input_pins[i], | ||
5866 | auto_pin_cfg_labels[i], idx, | ||
5867 | 0x07); | ||
5868 | if (err < 0) | ||
5869 | return err; | ||
5870 | imux->items[imux->num_items].label = | ||
5871 | auto_pin_cfg_labels[i]; | ||
5872 | imux->items[imux->num_items].index = idx; | ||
5873 | imux->num_items++; | ||
5874 | } | ||
5875 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ | ||
5876 | idx = cfg->input_pins[i] - 0x09; | ||
5877 | err = new_analog_input(spec, cfg->input_pins[i], | ||
5878 | auto_pin_cfg_labels[i], idx, | ||
5879 | 0x07); | ||
5880 | if (err < 0) | ||
5881 | return err; | ||
5882 | imux->items[imux->num_items].label = | ||
5883 | auto_pin_cfg_labels[i]; | ||
5884 | imux->items[imux->num_items].index = idx; | ||
5885 | imux->num_items++; | ||
5886 | } | ||
5887 | } | ||
5888 | return 0; | ||
5889 | } | 6056 | } |
5890 | 6057 | ||
5891 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | 6058 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, |
@@ -5999,7 +6166,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec) | |||
5999 | return err; | 6166 | return err; |
6000 | if (!spec->kctls.list) | 6167 | if (!spec->kctls.list) |
6001 | return 0; /* can't find valid BIOS pin config */ | 6168 | return 0; /* can't find valid BIOS pin config */ |
6002 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); | 6169 | err = alc260_auto_create_input_ctls(codec, &spec->autocfg); |
6003 | if (err < 0) | 6170 | if (err < 0) |
6004 | return err; | 6171 | return err; |
6005 | 6172 | ||
@@ -6234,8 +6401,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6234 | alc260_models, | 6401 | alc260_models, |
6235 | alc260_cfg_tbl); | 6402 | alc260_cfg_tbl); |
6236 | if (board_config < 0) { | 6403 | if (board_config < 0) { |
6237 | snd_printd(KERN_INFO "hda_codec: Unknown model for %s, " | 6404 | snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
6238 | "trying auto-probe from BIOS...\n", | ||
6239 | codec->chip_name); | 6405 | codec->chip_name); |
6240 | board_config = ALC260_AUTO; | 6406 | board_config = ALC260_AUTO; |
6241 | } | 6407 | } |
@@ -6261,7 +6427,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6261 | } | 6427 | } |
6262 | 6428 | ||
6263 | if (board_config != ALC260_AUTO) | 6429 | if (board_config != ALC260_AUTO) |
6264 | setup_preset(spec, &alc260_presets[board_config]); | 6430 | setup_preset(codec, &alc260_presets[board_config]); |
6265 | 6431 | ||
6266 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | 6432 | spec->stream_analog_playback = &alc260_pcm_analog_playback; |
6267 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | 6433 | spec->stream_analog_capture = &alc260_pcm_analog_capture; |
@@ -6272,7 +6438,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6272 | if (!spec->adc_nids && spec->input_mux) { | 6438 | if (!spec->adc_nids && spec->input_mux) { |
6273 | /* check whether NID 0x04 is valid */ | 6439 | /* check whether NID 0x04 is valid */ |
6274 | unsigned int wcap = get_wcaps(codec, 0x04); | 6440 | unsigned int wcap = get_wcaps(codec, 0x04); |
6275 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 6441 | wcap = get_wcaps_type(wcap); |
6276 | /* get type */ | 6442 | /* get type */ |
6277 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | 6443 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
6278 | spec->adc_nids = alc260_adc_nids_alt; | 6444 | spec->adc_nids = alc260_adc_nids_alt; |
@@ -6282,7 +6448,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6282 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | 6448 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); |
6283 | } | 6449 | } |
6284 | } | 6450 | } |
6285 | set_capture_mixer(spec); | 6451 | set_capture_mixer(codec); |
6286 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); | 6452 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
6287 | 6453 | ||
6288 | spec->vmaster_nid = 0x08; | 6454 | spec->vmaster_nid = 0x08; |
@@ -6301,7 +6467,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6301 | 6467 | ||
6302 | 6468 | ||
6303 | /* | 6469 | /* |
6304 | * ALC882 support | 6470 | * ALC882/883/885/888/889 support |
6305 | * | 6471 | * |
6306 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | 6472 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
6307 | * configuration. Each pin widget can choose any input DACs and a mixer. | 6473 | * configuration. Each pin widget can choose any input DACs and a mixer. |
@@ -6313,22 +6479,35 @@ static int patch_alc260(struct hda_codec *codec) | |||
6313 | */ | 6479 | */ |
6314 | #define ALC882_DIGOUT_NID 0x06 | 6480 | #define ALC882_DIGOUT_NID 0x06 |
6315 | #define ALC882_DIGIN_NID 0x0a | 6481 | #define ALC882_DIGIN_NID 0x0a |
6482 | #define ALC883_DIGOUT_NID ALC882_DIGOUT_NID | ||
6483 | #define ALC883_DIGIN_NID ALC882_DIGIN_NID | ||
6484 | #define ALC1200_DIGOUT_NID 0x10 | ||
6485 | |||
6316 | 6486 | ||
6317 | static struct hda_channel_mode alc882_ch_modes[1] = { | 6487 | static struct hda_channel_mode alc882_ch_modes[1] = { |
6318 | { 8, NULL } | 6488 | { 8, NULL } |
6319 | }; | 6489 | }; |
6320 | 6490 | ||
6491 | /* DACs */ | ||
6321 | static hda_nid_t alc882_dac_nids[4] = { | 6492 | static hda_nid_t alc882_dac_nids[4] = { |
6322 | /* front, rear, clfe, rear_surr */ | 6493 | /* front, rear, clfe, rear_surr */ |
6323 | 0x02, 0x03, 0x04, 0x05 | 6494 | 0x02, 0x03, 0x04, 0x05 |
6324 | }; | 6495 | }; |
6496 | #define alc883_dac_nids alc882_dac_nids | ||
6325 | 6497 | ||
6326 | /* identical with ALC880 */ | 6498 | /* ADCs */ |
6327 | #define alc882_adc_nids alc880_adc_nids | 6499 | #define alc882_adc_nids alc880_adc_nids |
6328 | #define alc882_adc_nids_alt alc880_adc_nids_alt | 6500 | #define alc882_adc_nids_alt alc880_adc_nids_alt |
6501 | #define alc883_adc_nids alc882_adc_nids_alt | ||
6502 | static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 }; | ||
6503 | static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 }; | ||
6504 | #define alc889_adc_nids alc880_adc_nids | ||
6329 | 6505 | ||
6330 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; | 6506 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
6331 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | 6507 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; |
6508 | #define alc883_capsrc_nids alc882_capsrc_nids_alt | ||
6509 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; | ||
6510 | #define alc889_capsrc_nids alc882_capsrc_nids | ||
6332 | 6511 | ||
6333 | /* input MUX */ | 6512 | /* input MUX */ |
6334 | /* FIXME: should be a matrix-type input source selection */ | 6513 | /* FIXME: should be a matrix-type input source selection */ |
@@ -6343,6 +6522,17 @@ static struct hda_input_mux alc882_capture_source = { | |||
6343 | }, | 6522 | }, |
6344 | }; | 6523 | }; |
6345 | 6524 | ||
6525 | #define alc883_capture_source alc882_capture_source | ||
6526 | |||
6527 | static struct hda_input_mux alc889_capture_source = { | ||
6528 | .num_items = 3, | ||
6529 | .items = { | ||
6530 | { "Front Mic", 0x0 }, | ||
6531 | { "Mic", 0x3 }, | ||
6532 | { "Line", 0x2 }, | ||
6533 | }, | ||
6534 | }; | ||
6535 | |||
6346 | static struct hda_input_mux mb5_capture_source = { | 6536 | static struct hda_input_mux mb5_capture_source = { |
6347 | .num_items = 3, | 6537 | .num_items = 3, |
6348 | .items = { | 6538 | .items = { |
@@ -6352,6 +6542,77 @@ static struct hda_input_mux mb5_capture_source = { | |||
6352 | }, | 6542 | }, |
6353 | }; | 6543 | }; |
6354 | 6544 | ||
6545 | static struct hda_input_mux alc883_3stack_6ch_intel = { | ||
6546 | .num_items = 4, | ||
6547 | .items = { | ||
6548 | { "Mic", 0x1 }, | ||
6549 | { "Front Mic", 0x0 }, | ||
6550 | { "Line", 0x2 }, | ||
6551 | { "CD", 0x4 }, | ||
6552 | }, | ||
6553 | }; | ||
6554 | |||
6555 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | ||
6556 | .num_items = 2, | ||
6557 | .items = { | ||
6558 | { "Mic", 0x1 }, | ||
6559 | { "Line", 0x2 }, | ||
6560 | }, | ||
6561 | }; | ||
6562 | |||
6563 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { | ||
6564 | .num_items = 4, | ||
6565 | .items = { | ||
6566 | { "Mic", 0x0 }, | ||
6567 | { "iMic", 0x1 }, | ||
6568 | { "Line", 0x2 }, | ||
6569 | { "CD", 0x4 }, | ||
6570 | }, | ||
6571 | }; | ||
6572 | |||
6573 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { | ||
6574 | .num_items = 2, | ||
6575 | .items = { | ||
6576 | { "Mic", 0x0 }, | ||
6577 | { "Int Mic", 0x1 }, | ||
6578 | }, | ||
6579 | }; | ||
6580 | |||
6581 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { | ||
6582 | .num_items = 3, | ||
6583 | .items = { | ||
6584 | { "Mic", 0x0 }, | ||
6585 | { "Front Mic", 0x1 }, | ||
6586 | { "Line", 0x4 }, | ||
6587 | }, | ||
6588 | }; | ||
6589 | |||
6590 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | ||
6591 | .num_items = 2, | ||
6592 | .items = { | ||
6593 | { "Mic", 0x0 }, | ||
6594 | { "Line", 0x2 }, | ||
6595 | }, | ||
6596 | }; | ||
6597 | |||
6598 | static struct hda_input_mux alc889A_mb31_capture_source = { | ||
6599 | .num_items = 2, | ||
6600 | .items = { | ||
6601 | { "Mic", 0x0 }, | ||
6602 | /* Front Mic (0x01) unused */ | ||
6603 | { "Line", 0x2 }, | ||
6604 | /* Line 2 (0x03) unused */ | ||
6605 | /* CD (0x04) unsused? */ | ||
6606 | }, | ||
6607 | }; | ||
6608 | |||
6609 | /* | ||
6610 | * 2ch mode | ||
6611 | */ | ||
6612 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | ||
6613 | { 2, NULL } | ||
6614 | }; | ||
6615 | |||
6355 | /* | 6616 | /* |
6356 | * 2ch mode | 6617 | * 2ch mode |
6357 | */ | 6618 | */ |
@@ -6364,6 +6625,18 @@ static struct hda_verb alc882_3ST_ch2_init[] = { | |||
6364 | }; | 6625 | }; |
6365 | 6626 | ||
6366 | /* | 6627 | /* |
6628 | * 4ch mode | ||
6629 | */ | ||
6630 | static struct hda_verb alc882_3ST_ch4_init[] = { | ||
6631 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6632 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6633 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6634 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6635 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6636 | { } /* end */ | ||
6637 | }; | ||
6638 | |||
6639 | /* | ||
6367 | * 6ch mode | 6640 | * 6ch mode |
6368 | */ | 6641 | */ |
6369 | static struct hda_verb alc882_3ST_ch6_init[] = { | 6642 | static struct hda_verb alc882_3ST_ch6_init[] = { |
@@ -6376,11 +6649,60 @@ static struct hda_verb alc882_3ST_ch6_init[] = { | |||
6376 | { } /* end */ | 6649 | { } /* end */ |
6377 | }; | 6650 | }; |
6378 | 6651 | ||
6379 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | 6652 | static struct hda_channel_mode alc882_3ST_6ch_modes[3] = { |
6380 | { 2, alc882_3ST_ch2_init }, | 6653 | { 2, alc882_3ST_ch2_init }, |
6654 | { 4, alc882_3ST_ch4_init }, | ||
6381 | { 6, alc882_3ST_ch6_init }, | 6655 | { 6, alc882_3ST_ch6_init }, |
6382 | }; | 6656 | }; |
6383 | 6657 | ||
6658 | #define alc883_3ST_6ch_modes alc882_3ST_6ch_modes | ||
6659 | |||
6660 | /* | ||
6661 | * 2ch mode | ||
6662 | */ | ||
6663 | static struct hda_verb alc883_3ST_ch2_clevo_init[] = { | ||
6664 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | ||
6665 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6666 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6667 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6668 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6669 | { } /* end */ | ||
6670 | }; | ||
6671 | |||
6672 | /* | ||
6673 | * 4ch mode | ||
6674 | */ | ||
6675 | static struct hda_verb alc883_3ST_ch4_clevo_init[] = { | ||
6676 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6677 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6678 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6679 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6680 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6681 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6682 | { } /* end */ | ||
6683 | }; | ||
6684 | |||
6685 | /* | ||
6686 | * 6ch mode | ||
6687 | */ | ||
6688 | static struct hda_verb alc883_3ST_ch6_clevo_init[] = { | ||
6689 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6690 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6691 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6692 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6693 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6694 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6695 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6696 | { } /* end */ | ||
6697 | }; | ||
6698 | |||
6699 | static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = { | ||
6700 | { 2, alc883_3ST_ch2_clevo_init }, | ||
6701 | { 4, alc883_3ST_ch4_clevo_init }, | ||
6702 | { 6, alc883_3ST_ch6_clevo_init }, | ||
6703 | }; | ||
6704 | |||
6705 | |||
6384 | /* | 6706 | /* |
6385 | * 6ch mode | 6707 | * 6ch mode |
6386 | */ | 6708 | */ |
@@ -6423,9 +6745,9 @@ static struct hda_verb alc885_mbp_ch2_init[] = { | |||
6423 | }; | 6745 | }; |
6424 | 6746 | ||
6425 | /* | 6747 | /* |
6426 | * 6ch mode | 6748 | * 4ch mode |
6427 | */ | 6749 | */ |
6428 | static struct hda_verb alc885_mbp_ch6_init[] = { | 6750 | static struct hda_verb alc885_mbp_ch4_init[] = { |
6429 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | 6751 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
6430 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 6752 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
6431 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | 6753 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
@@ -6434,9 +6756,9 @@ static struct hda_verb alc885_mbp_ch6_init[] = { | |||
6434 | { } /* end */ | 6756 | { } /* end */ |
6435 | }; | 6757 | }; |
6436 | 6758 | ||
6437 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | 6759 | static struct hda_channel_mode alc885_mbp_4ch_modes[2] = { |
6438 | { 2, alc885_mbp_ch2_init }, | 6760 | { 2, alc885_mbp_ch2_init }, |
6439 | { 6, alc885_mbp_ch6_init }, | 6761 | { 4, alc885_mbp_ch4_init }, |
6440 | }; | 6762 | }; |
6441 | 6763 | ||
6442 | /* | 6764 | /* |
@@ -6468,6 +6790,189 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = { | |||
6468 | { 6, alc885_mb5_ch6_init }, | 6790 | { 6, alc885_mb5_ch6_init }, |
6469 | }; | 6791 | }; |
6470 | 6792 | ||
6793 | |||
6794 | /* | ||
6795 | * 2ch mode | ||
6796 | */ | ||
6797 | static struct hda_verb alc883_4ST_ch2_init[] = { | ||
6798 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6799 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6800 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6801 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6802 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6803 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6804 | { } /* end */ | ||
6805 | }; | ||
6806 | |||
6807 | /* | ||
6808 | * 4ch mode | ||
6809 | */ | ||
6810 | static struct hda_verb alc883_4ST_ch4_init[] = { | ||
6811 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6812 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6813 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6814 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6815 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6816 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6817 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6818 | { } /* end */ | ||
6819 | }; | ||
6820 | |||
6821 | /* | ||
6822 | * 6ch mode | ||
6823 | */ | ||
6824 | static struct hda_verb alc883_4ST_ch6_init[] = { | ||
6825 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6826 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6827 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6828 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6829 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6830 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6831 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6832 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6833 | { } /* end */ | ||
6834 | }; | ||
6835 | |||
6836 | /* | ||
6837 | * 8ch mode | ||
6838 | */ | ||
6839 | static struct hda_verb alc883_4ST_ch8_init[] = { | ||
6840 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6841 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6842 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6843 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6844 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6845 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6846 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6847 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6848 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6849 | { } /* end */ | ||
6850 | }; | ||
6851 | |||
6852 | static struct hda_channel_mode alc883_4ST_8ch_modes[4] = { | ||
6853 | { 2, alc883_4ST_ch2_init }, | ||
6854 | { 4, alc883_4ST_ch4_init }, | ||
6855 | { 6, alc883_4ST_ch6_init }, | ||
6856 | { 8, alc883_4ST_ch8_init }, | ||
6857 | }; | ||
6858 | |||
6859 | |||
6860 | /* | ||
6861 | * 2ch mode | ||
6862 | */ | ||
6863 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | ||
6864 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6865 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6866 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6867 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6868 | { } /* end */ | ||
6869 | }; | ||
6870 | |||
6871 | /* | ||
6872 | * 4ch mode | ||
6873 | */ | ||
6874 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | ||
6875 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6876 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6877 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6878 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6879 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6880 | { } /* end */ | ||
6881 | }; | ||
6882 | |||
6883 | /* | ||
6884 | * 6ch mode | ||
6885 | */ | ||
6886 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | ||
6887 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6888 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6889 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6890 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6891 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6892 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6893 | { } /* end */ | ||
6894 | }; | ||
6895 | |||
6896 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | ||
6897 | { 2, alc883_3ST_ch2_intel_init }, | ||
6898 | { 4, alc883_3ST_ch4_intel_init }, | ||
6899 | { 6, alc883_3ST_ch6_intel_init }, | ||
6900 | }; | ||
6901 | |||
6902 | /* | ||
6903 | * 2ch mode | ||
6904 | */ | ||
6905 | static struct hda_verb alc889_ch2_intel_init[] = { | ||
6906 | { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6907 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6908 | { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6909 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6910 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6911 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6912 | { } /* end */ | ||
6913 | }; | ||
6914 | |||
6915 | /* | ||
6916 | * 6ch mode | ||
6917 | */ | ||
6918 | static struct hda_verb alc889_ch6_intel_init[] = { | ||
6919 | { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6920 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6921 | { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6922 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6923 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6924 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6925 | { } /* end */ | ||
6926 | }; | ||
6927 | |||
6928 | /* | ||
6929 | * 8ch mode | ||
6930 | */ | ||
6931 | static struct hda_verb alc889_ch8_intel_init[] = { | ||
6932 | { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6933 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6934 | { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6935 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6936 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6937 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6938 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6939 | { } /* end */ | ||
6940 | }; | ||
6941 | |||
6942 | static struct hda_channel_mode alc889_8ch_intel_modes[3] = { | ||
6943 | { 2, alc889_ch2_intel_init }, | ||
6944 | { 6, alc889_ch6_intel_init }, | ||
6945 | { 8, alc889_ch8_intel_init }, | ||
6946 | }; | ||
6947 | |||
6948 | /* | ||
6949 | * 6ch mode | ||
6950 | */ | ||
6951 | static struct hda_verb alc883_sixstack_ch6_init[] = { | ||
6952 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | ||
6953 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6954 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6955 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6956 | { } /* end */ | ||
6957 | }; | ||
6958 | |||
6959 | /* | ||
6960 | * 8ch mode | ||
6961 | */ | ||
6962 | static struct hda_verb alc883_sixstack_ch8_init[] = { | ||
6963 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6964 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6965 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6966 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6967 | { } /* end */ | ||
6968 | }; | ||
6969 | |||
6970 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | ||
6971 | { 6, alc883_sixstack_ch6_init }, | ||
6972 | { 8, alc883_sixstack_ch8_init }, | ||
6973 | }; | ||
6974 | |||
6975 | |||
6471 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | 6976 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6472 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | 6977 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
6473 | */ | 6978 | */ |
@@ -6497,10 +7002,11 @@ static struct snd_kcontrol_new alc882_base_mixer[] = { | |||
6497 | }; | 7002 | }; |
6498 | 7003 | ||
6499 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { | 7004 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
6500 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | 7005 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
6501 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | 7006 | HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT), |
6502 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | 7007 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT), |
6503 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | 7008 | HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT), |
7009 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | ||
6504 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 7010 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6505 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | 7011 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
6506 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), | 7012 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
@@ -6603,7 +7109,7 @@ static struct snd_kcontrol_new alc882_chmode_mixer[] = { | |||
6603 | { } /* end */ | 7109 | { } /* end */ |
6604 | }; | 7110 | }; |
6605 | 7111 | ||
6606 | static struct hda_verb alc882_init_verbs[] = { | 7112 | static struct hda_verb alc882_base_init_verbs[] = { |
6607 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 7113 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
6608 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7114 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6609 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7115 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
@@ -6621,6 +7127,13 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6621 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7127 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6622 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7128 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
6623 | 7129 | ||
7130 | /* mute analog input loopbacks */ | ||
7131 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7132 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7133 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7134 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7135 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7136 | |||
6624 | /* Front Pin: output 0 (0x0c) */ | 7137 | /* Front Pin: output 0 (0x0c) */ |
6625 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 7138 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
6626 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 7139 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
@@ -6655,11 +7168,6 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6655 | 7168 | ||
6656 | /* FIXME: use matrix-type input source selection */ | 7169 | /* FIXME: use matrix-type input source selection */ |
6657 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 7170 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
6658 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
6659 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
6660 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
6661 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
6662 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
6663 | /* Input mixer2 */ | 7171 | /* Input mixer2 */ |
6664 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7172 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6665 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | 7173 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
@@ -6670,9 +7178,6 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6670 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | 7178 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
6671 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | 7179 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
6672 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | 7180 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
6673 | /* ADC1: mute amp left and right */ | ||
6674 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
6675 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
6676 | /* ADC2: mute amp left and right */ | 7181 | /* ADC2: mute amp left and right */ |
6677 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7182 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6678 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7183 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -6683,6 +7188,18 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6683 | { } | 7188 | { } |
6684 | }; | 7189 | }; |
6685 | 7190 | ||
7191 | static struct hda_verb alc882_adc1_init_verbs[] = { | ||
7192 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
7193 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7194 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7195 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7196 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7197 | /* ADC1: mute amp left and right */ | ||
7198 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7199 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7200 | { } | ||
7201 | }; | ||
7202 | |||
6686 | static struct hda_verb alc882_eapd_verbs[] = { | 7203 | static struct hda_verb alc882_eapd_verbs[] = { |
6687 | /* change to EAPD mode */ | 7204 | /* change to EAPD mode */ |
6688 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | 7205 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
@@ -6690,6 +7207,110 @@ static struct hda_verb alc882_eapd_verbs[] = { | |||
6690 | { } | 7207 | { } |
6691 | }; | 7208 | }; |
6692 | 7209 | ||
7210 | static struct hda_verb alc889_eapd_verbs[] = { | ||
7211 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | ||
7212 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | ||
7213 | { } | ||
7214 | }; | ||
7215 | |||
7216 | static struct hda_verb alc_hp15_unsol_verbs[] = { | ||
7217 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
7218 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
7219 | {} | ||
7220 | }; | ||
7221 | |||
7222 | static struct hda_verb alc885_init_verbs[] = { | ||
7223 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | ||
7224 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7225 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7226 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7227 | /* Rear mixer */ | ||
7228 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7229 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7230 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7231 | /* CLFE mixer */ | ||
7232 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7233 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7234 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7235 | /* Side mixer */ | ||
7236 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7237 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7238 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7239 | |||
7240 | /* mute analog input loopbacks */ | ||
7241 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7242 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7243 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7244 | |||
7245 | /* Front HP Pin: output 0 (0x0c) */ | ||
7246 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
7247 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7248 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7249 | /* Front Pin: output 0 (0x0c) */ | ||
7250 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7251 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7252 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7253 | /* Rear Pin: output 1 (0x0d) */ | ||
7254 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7255 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7256 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
7257 | /* CLFE Pin: output 2 (0x0e) */ | ||
7258 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7259 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7260 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
7261 | /* Side Pin: output 3 (0x0f) */ | ||
7262 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7263 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7264 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
7265 | /* Mic (rear) pin: input vref at 80% */ | ||
7266 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
7267 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7268 | /* Front Mic pin: input vref at 80% */ | ||
7269 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
7270 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7271 | /* Line In pin: input */ | ||
7272 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
7273 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7274 | |||
7275 | /* Mixer elements: 0x18, , 0x1a, 0x1b */ | ||
7276 | /* Input mixer1 */ | ||
7277 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | ||
7278 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7279 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7280 | /* Input mixer2 */ | ||
7281 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7282 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7283 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7284 | /* Input mixer3 */ | ||
7285 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
7286 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7287 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7288 | /* ADC2: mute amp left and right */ | ||
7289 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7290 | /* ADC3: mute amp left and right */ | ||
7291 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7292 | |||
7293 | { } | ||
7294 | }; | ||
7295 | |||
7296 | static struct hda_verb alc885_init_input_verbs[] = { | ||
7297 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7298 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
7299 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | ||
7300 | { } | ||
7301 | }; | ||
7302 | |||
7303 | |||
7304 | /* Unmute Selector 24h and set the default input to front mic */ | ||
7305 | static struct hda_verb alc889_init_input_verbs[] = { | ||
7306 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7307 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7308 | { } | ||
7309 | }; | ||
7310 | |||
7311 | |||
7312 | #define alc883_init_verbs alc882_base_init_verbs | ||
7313 | |||
6693 | /* Mac Pro test */ | 7314 | /* Mac Pro test */ |
6694 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | 7315 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { |
6695 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7316 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
@@ -6814,14 +7435,18 @@ static struct hda_verb alc885_mbp3_init_verbs[] = { | |||
6814 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7435 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6815 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7436 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6816 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7437 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7438 | /* HP mixer */ | ||
7439 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7440 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7441 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
6817 | /* Front Pin: output 0 (0x0c) */ | 7442 | /* Front Pin: output 0 (0x0c) */ |
6818 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 7443 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
6819 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 7444 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
6820 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7445 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
6821 | /* HP Pin: output 0 (0x0d) */ | 7446 | /* HP Pin: output 0 (0x0e) */ |
6822 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | 7447 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, |
6823 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | 7448 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
6824 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7449 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, |
6825 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 7450 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
6826 | /* Mic (rear) pin: input vref at 80% */ | 7451 | /* Mic (rear) pin: input vref at 80% */ |
6827 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 7452 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
@@ -6893,23 +7518,21 @@ static struct hda_verb alc885_imac24_init_verbs[] = { | |||
6893 | }; | 7518 | }; |
6894 | 7519 | ||
6895 | /* Toggle speaker-output according to the hp-jack state */ | 7520 | /* Toggle speaker-output according to the hp-jack state */ |
6896 | static void alc885_imac24_automute_init_hook(struct hda_codec *codec) | 7521 | static void alc885_imac24_setup(struct hda_codec *codec) |
6897 | { | 7522 | { |
6898 | struct alc_spec *spec = codec->spec; | 7523 | struct alc_spec *spec = codec->spec; |
6899 | 7524 | ||
6900 | spec->autocfg.hp_pins[0] = 0x14; | 7525 | spec->autocfg.hp_pins[0] = 0x14; |
6901 | spec->autocfg.speaker_pins[0] = 0x18; | 7526 | spec->autocfg.speaker_pins[0] = 0x18; |
6902 | spec->autocfg.speaker_pins[1] = 0x1a; | 7527 | spec->autocfg.speaker_pins[1] = 0x1a; |
6903 | alc_automute_amp(codec); | ||
6904 | } | 7528 | } |
6905 | 7529 | ||
6906 | static void alc885_mbp3_init_hook(struct hda_codec *codec) | 7530 | static void alc885_mbp3_setup(struct hda_codec *codec) |
6907 | { | 7531 | { |
6908 | struct alc_spec *spec = codec->spec; | 7532 | struct alc_spec *spec = codec->spec; |
6909 | 7533 | ||
6910 | spec->autocfg.hp_pins[0] = 0x15; | 7534 | spec->autocfg.hp_pins[0] = 0x15; |
6911 | spec->autocfg.speaker_pins[0] = 0x14; | 7535 | spec->autocfg.speaker_pins[0] = 0x14; |
6912 | alc_automute_amp(codec); | ||
6913 | } | 7536 | } |
6914 | 7537 | ||
6915 | 7538 | ||
@@ -6937,13 +7560,12 @@ static void alc882_targa_automute(struct hda_codec *codec) | |||
6937 | spec->jack_present ? 1 : 3); | 7560 | spec->jack_present ? 1 : 3); |
6938 | } | 7561 | } |
6939 | 7562 | ||
6940 | static void alc882_targa_init_hook(struct hda_codec *codec) | 7563 | static void alc882_targa_setup(struct hda_codec *codec) |
6941 | { | 7564 | { |
6942 | struct alc_spec *spec = codec->spec; | 7565 | struct alc_spec *spec = codec->spec; |
6943 | 7566 | ||
6944 | spec->autocfg.hp_pins[0] = 0x14; | 7567 | spec->autocfg.hp_pins[0] = 0x14; |
6945 | spec->autocfg.speaker_pins[0] = 0x1b; | 7568 | spec->autocfg.speaker_pins[0] = 0x1b; |
6946 | alc882_targa_automute(codec); | ||
6947 | } | 7569 | } |
6948 | 7570 | ||
6949 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | 7571 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) |
@@ -7031,18 +7653,16 @@ static void alc885_macpro_init_hook(struct hda_codec *codec) | |||
7031 | static void alc885_imac24_init_hook(struct hda_codec *codec) | 7653 | static void alc885_imac24_init_hook(struct hda_codec *codec) |
7032 | { | 7654 | { |
7033 | alc885_macpro_init_hook(codec); | 7655 | alc885_macpro_init_hook(codec); |
7034 | alc885_imac24_automute_init_hook(codec); | 7656 | alc_automute_amp(codec); |
7035 | } | 7657 | } |
7036 | 7658 | ||
7037 | /* | 7659 | /* |
7038 | * generic initialization of ADC, input mixers and output mixers | 7660 | * generic initialization of ADC, input mixers and output mixers |
7039 | */ | 7661 | */ |
7040 | static struct hda_verb alc882_auto_init_verbs[] = { | 7662 | static struct hda_verb alc883_auto_init_verbs[] = { |
7041 | /* | 7663 | /* |
7042 | * Unmute ADC0-2 and set the default input to mic-in | 7664 | * Unmute ADC0-2 and set the default input to mic-in |
7043 | */ | 7665 | */ |
7044 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7045 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7046 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7666 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7047 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7667 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7048 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7668 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -7083,11 +7703,6 @@ static struct hda_verb alc882_auto_init_verbs[] = { | |||
7083 | 7703 | ||
7084 | /* FIXME: use matrix-type input source selection */ | 7704 | /* FIXME: use matrix-type input source selection */ |
7085 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 7705 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
7086 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
7087 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | ||
7088 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | ||
7089 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | ||
7090 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
7091 | /* Input mixer2 */ | 7706 | /* Input mixer2 */ |
7092 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 7707 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
7093 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | 7708 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
@@ -7102,820 +7717,6 @@ static struct hda_verb alc882_auto_init_verbs[] = { | |||
7102 | { } | 7717 | { } |
7103 | }; | 7718 | }; |
7104 | 7719 | ||
7105 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
7106 | #define alc882_loopbacks alc880_loopbacks | ||
7107 | #endif | ||
7108 | |||
7109 | /* pcm configuration: identical with ALC880 */ | ||
7110 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | ||
7111 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | ||
7112 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | ||
7113 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | ||
7114 | |||
7115 | /* | ||
7116 | * configuration and preset | ||
7117 | */ | ||
7118 | static const char *alc882_models[ALC882_MODEL_LAST] = { | ||
7119 | [ALC882_3ST_DIG] = "3stack-dig", | ||
7120 | [ALC882_6ST_DIG] = "6stack-dig", | ||
7121 | [ALC882_ARIMA] = "arima", | ||
7122 | [ALC882_W2JC] = "w2jc", | ||
7123 | [ALC882_TARGA] = "targa", | ||
7124 | [ALC882_ASUS_A7J] = "asus-a7j", | ||
7125 | [ALC882_ASUS_A7M] = "asus-a7m", | ||
7126 | [ALC885_MACPRO] = "macpro", | ||
7127 | [ALC885_MB5] = "mb5", | ||
7128 | [ALC885_MBP3] = "mbp3", | ||
7129 | [ALC885_IMAC24] = "imac24", | ||
7130 | [ALC882_AUTO] = "auto", | ||
7131 | }; | ||
7132 | |||
7133 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | ||
7134 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | ||
7135 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), | ||
7136 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), | ||
7137 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), | ||
7138 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), | ||
7139 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), | ||
7140 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), | ||
7141 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), | ||
7142 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), | ||
7143 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ | ||
7144 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | ||
7145 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | ||
7146 | {} | ||
7147 | }; | ||
7148 | |||
7149 | static struct alc_config_preset alc882_presets[] = { | ||
7150 | [ALC882_3ST_DIG] = { | ||
7151 | .mixers = { alc882_base_mixer }, | ||
7152 | .init_verbs = { alc882_init_verbs }, | ||
7153 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7154 | .dac_nids = alc882_dac_nids, | ||
7155 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7156 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7157 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
7158 | .channel_mode = alc882_ch_modes, | ||
7159 | .need_dac_fix = 1, | ||
7160 | .input_mux = &alc882_capture_source, | ||
7161 | }, | ||
7162 | [ALC882_6ST_DIG] = { | ||
7163 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
7164 | .init_verbs = { alc882_init_verbs }, | ||
7165 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7166 | .dac_nids = alc882_dac_nids, | ||
7167 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7168 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7169 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
7170 | .channel_mode = alc882_sixstack_modes, | ||
7171 | .input_mux = &alc882_capture_source, | ||
7172 | }, | ||
7173 | [ALC882_ARIMA] = { | ||
7174 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
7175 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | ||
7176 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7177 | .dac_nids = alc882_dac_nids, | ||
7178 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
7179 | .channel_mode = alc882_sixstack_modes, | ||
7180 | .input_mux = &alc882_capture_source, | ||
7181 | }, | ||
7182 | [ALC882_W2JC] = { | ||
7183 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | ||
7184 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | ||
7185 | alc880_gpio1_init_verbs }, | ||
7186 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7187 | .dac_nids = alc882_dac_nids, | ||
7188 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
7189 | .channel_mode = alc880_threestack_modes, | ||
7190 | .need_dac_fix = 1, | ||
7191 | .input_mux = &alc882_capture_source, | ||
7192 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7193 | }, | ||
7194 | [ALC885_MBP3] = { | ||
7195 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | ||
7196 | .init_verbs = { alc885_mbp3_init_verbs, | ||
7197 | alc880_gpio1_init_verbs }, | ||
7198 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7199 | .dac_nids = alc882_dac_nids, | ||
7200 | .channel_mode = alc885_mbp_6ch_modes, | ||
7201 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | ||
7202 | .input_mux = &alc882_capture_source, | ||
7203 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7204 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7205 | .unsol_event = alc_automute_amp_unsol_event, | ||
7206 | .init_hook = alc885_mbp3_init_hook, | ||
7207 | }, | ||
7208 | [ALC885_MB5] = { | ||
7209 | .mixers = { alc885_mb5_mixer, alc882_chmode_mixer }, | ||
7210 | .init_verbs = { alc885_mb5_init_verbs, | ||
7211 | alc880_gpio1_init_verbs }, | ||
7212 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7213 | .dac_nids = alc882_dac_nids, | ||
7214 | .channel_mode = alc885_mb5_6ch_modes, | ||
7215 | .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes), | ||
7216 | .input_mux = &mb5_capture_source, | ||
7217 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7218 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7219 | }, | ||
7220 | [ALC885_MACPRO] = { | ||
7221 | .mixers = { alc882_macpro_mixer }, | ||
7222 | .init_verbs = { alc882_macpro_init_verbs }, | ||
7223 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7224 | .dac_nids = alc882_dac_nids, | ||
7225 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7226 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7227 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
7228 | .channel_mode = alc882_ch_modes, | ||
7229 | .input_mux = &alc882_capture_source, | ||
7230 | .init_hook = alc885_macpro_init_hook, | ||
7231 | }, | ||
7232 | [ALC885_IMAC24] = { | ||
7233 | .mixers = { alc885_imac24_mixer }, | ||
7234 | .init_verbs = { alc885_imac24_init_verbs }, | ||
7235 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7236 | .dac_nids = alc882_dac_nids, | ||
7237 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7238 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7239 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
7240 | .channel_mode = alc882_ch_modes, | ||
7241 | .input_mux = &alc882_capture_source, | ||
7242 | .unsol_event = alc_automute_amp_unsol_event, | ||
7243 | .init_hook = alc885_imac24_init_hook, | ||
7244 | }, | ||
7245 | [ALC882_TARGA] = { | ||
7246 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, | ||
7247 | .init_verbs = { alc882_init_verbs, alc880_gpio3_init_verbs, | ||
7248 | alc882_targa_verbs}, | ||
7249 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7250 | .dac_nids = alc882_dac_nids, | ||
7251 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7252 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
7253 | .adc_nids = alc882_adc_nids, | ||
7254 | .capsrc_nids = alc882_capsrc_nids, | ||
7255 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
7256 | .channel_mode = alc882_3ST_6ch_modes, | ||
7257 | .need_dac_fix = 1, | ||
7258 | .input_mux = &alc882_capture_source, | ||
7259 | .unsol_event = alc882_targa_unsol_event, | ||
7260 | .init_hook = alc882_targa_init_hook, | ||
7261 | }, | ||
7262 | [ALC882_ASUS_A7J] = { | ||
7263 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, | ||
7264 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | ||
7265 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7266 | .dac_nids = alc882_dac_nids, | ||
7267 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7268 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
7269 | .adc_nids = alc882_adc_nids, | ||
7270 | .capsrc_nids = alc882_capsrc_nids, | ||
7271 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
7272 | .channel_mode = alc882_3ST_6ch_modes, | ||
7273 | .need_dac_fix = 1, | ||
7274 | .input_mux = &alc882_capture_source, | ||
7275 | }, | ||
7276 | [ALC882_ASUS_A7M] = { | ||
7277 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | ||
7278 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | ||
7279 | alc880_gpio1_init_verbs, | ||
7280 | alc882_asus_a7m_verbs }, | ||
7281 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7282 | .dac_nids = alc882_dac_nids, | ||
7283 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7284 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
7285 | .channel_mode = alc880_threestack_modes, | ||
7286 | .need_dac_fix = 1, | ||
7287 | .input_mux = &alc882_capture_source, | ||
7288 | }, | ||
7289 | }; | ||
7290 | |||
7291 | |||
7292 | /* | ||
7293 | * Pin config fixes | ||
7294 | */ | ||
7295 | enum { | ||
7296 | PINFIX_ABIT_AW9D_MAX | ||
7297 | }; | ||
7298 | |||
7299 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | ||
7300 | { 0x15, 0x01080104 }, /* side */ | ||
7301 | { 0x16, 0x01011012 }, /* rear */ | ||
7302 | { 0x17, 0x01016011 }, /* clfe */ | ||
7303 | { } | ||
7304 | }; | ||
7305 | |||
7306 | static const struct alc_pincfg *alc882_pin_fixes[] = { | ||
7307 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | ||
7308 | }; | ||
7309 | |||
7310 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | ||
7311 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | ||
7312 | {} | ||
7313 | }; | ||
7314 | |||
7315 | /* | ||
7316 | * BIOS auto configuration | ||
7317 | */ | ||
7318 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | ||
7319 | hda_nid_t nid, int pin_type, | ||
7320 | int dac_idx) | ||
7321 | { | ||
7322 | /* set as output */ | ||
7323 | struct alc_spec *spec = codec->spec; | ||
7324 | int idx; | ||
7325 | |||
7326 | alc_set_pin_output(codec, nid, pin_type); | ||
7327 | if (spec->multiout.dac_nids[dac_idx] == 0x25) | ||
7328 | idx = 4; | ||
7329 | else | ||
7330 | idx = spec->multiout.dac_nids[dac_idx] - 2; | ||
7331 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | ||
7332 | |||
7333 | } | ||
7334 | |||
7335 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | ||
7336 | { | ||
7337 | struct alc_spec *spec = codec->spec; | ||
7338 | int i; | ||
7339 | |||
7340 | for (i = 0; i <= HDA_SIDE; i++) { | ||
7341 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | ||
7342 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | ||
7343 | if (nid) | ||
7344 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, | ||
7345 | i); | ||
7346 | } | ||
7347 | } | ||
7348 | |||
7349 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | ||
7350 | { | ||
7351 | struct alc_spec *spec = codec->spec; | ||
7352 | hda_nid_t pin; | ||
7353 | |||
7354 | pin = spec->autocfg.hp_pins[0]; | ||
7355 | if (pin) /* connect to front */ | ||
7356 | /* use dac 0 */ | ||
7357 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | ||
7358 | pin = spec->autocfg.speaker_pins[0]; | ||
7359 | if (pin) | ||
7360 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | ||
7361 | } | ||
7362 | |||
7363 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | ||
7364 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | ||
7365 | |||
7366 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | ||
7367 | { | ||
7368 | struct alc_spec *spec = codec->spec; | ||
7369 | int i; | ||
7370 | |||
7371 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
7372 | hda_nid_t nid = spec->autocfg.input_pins[i]; | ||
7373 | if (!nid) | ||
7374 | continue; | ||
7375 | alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/); | ||
7376 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | ||
7377 | snd_hda_codec_write(codec, nid, 0, | ||
7378 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
7379 | AMP_OUT_MUTE); | ||
7380 | } | ||
7381 | } | ||
7382 | |||
7383 | static void alc882_auto_init_input_src(struct hda_codec *codec) | ||
7384 | { | ||
7385 | struct alc_spec *spec = codec->spec; | ||
7386 | int c; | ||
7387 | |||
7388 | for (c = 0; c < spec->num_adc_nids; c++) { | ||
7389 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | ||
7390 | hda_nid_t nid = spec->capsrc_nids[c]; | ||
7391 | unsigned int mux_idx; | ||
7392 | const struct hda_input_mux *imux; | ||
7393 | int conns, mute, idx, item; | ||
7394 | |||
7395 | conns = snd_hda_get_connections(codec, nid, conn_list, | ||
7396 | ARRAY_SIZE(conn_list)); | ||
7397 | if (conns < 0) | ||
7398 | continue; | ||
7399 | mux_idx = c >= spec->num_mux_defs ? 0 : c; | ||
7400 | imux = &spec->input_mux[mux_idx]; | ||
7401 | for (idx = 0; idx < conns; idx++) { | ||
7402 | /* if the current connection is the selected one, | ||
7403 | * unmute it as default - otherwise mute it | ||
7404 | */ | ||
7405 | mute = AMP_IN_MUTE(idx); | ||
7406 | for (item = 0; item < imux->num_items; item++) { | ||
7407 | if (imux->items[item].index == idx) { | ||
7408 | if (spec->cur_mux[c] == item) | ||
7409 | mute = AMP_IN_UNMUTE(idx); | ||
7410 | break; | ||
7411 | } | ||
7412 | } | ||
7413 | /* check if we have a selector or mixer | ||
7414 | * we could check for the widget type instead, but | ||
7415 | * just check for Amp-In presence (in case of mixer | ||
7416 | * without amp-in there is something wrong, this | ||
7417 | * function shouldn't be used or capsrc nid is wrong) | ||
7418 | */ | ||
7419 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | ||
7420 | snd_hda_codec_write(codec, nid, 0, | ||
7421 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
7422 | mute); | ||
7423 | else if (mute != AMP_IN_MUTE(idx)) | ||
7424 | snd_hda_codec_write(codec, nid, 0, | ||
7425 | AC_VERB_SET_CONNECT_SEL, | ||
7426 | idx); | ||
7427 | } | ||
7428 | } | ||
7429 | } | ||
7430 | |||
7431 | /* add mic boosts if needed */ | ||
7432 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | ||
7433 | { | ||
7434 | struct alc_spec *spec = codec->spec; | ||
7435 | int err; | ||
7436 | hda_nid_t nid; | ||
7437 | |||
7438 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | ||
7439 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
7440 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
7441 | "Mic Boost", | ||
7442 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
7443 | if (err < 0) | ||
7444 | return err; | ||
7445 | } | ||
7446 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | ||
7447 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
7448 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
7449 | "Front Mic Boost", | ||
7450 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
7451 | if (err < 0) | ||
7452 | return err; | ||
7453 | } | ||
7454 | return 0; | ||
7455 | } | ||
7456 | |||
7457 | /* almost identical with ALC880 parser... */ | ||
7458 | static int alc882_parse_auto_config(struct hda_codec *codec) | ||
7459 | { | ||
7460 | struct alc_spec *spec = codec->spec; | ||
7461 | int err = alc880_parse_auto_config(codec); | ||
7462 | |||
7463 | if (err < 0) | ||
7464 | return err; | ||
7465 | else if (!err) | ||
7466 | return 0; /* no config found */ | ||
7467 | |||
7468 | err = alc_auto_add_mic_boost(codec); | ||
7469 | if (err < 0) | ||
7470 | return err; | ||
7471 | |||
7472 | /* hack - override the init verbs */ | ||
7473 | spec->init_verbs[0] = alc882_auto_init_verbs; | ||
7474 | |||
7475 | return 1; /* config found */ | ||
7476 | } | ||
7477 | |||
7478 | /* additional initialization for auto-configuration model */ | ||
7479 | static void alc882_auto_init(struct hda_codec *codec) | ||
7480 | { | ||
7481 | struct alc_spec *spec = codec->spec; | ||
7482 | alc882_auto_init_multi_out(codec); | ||
7483 | alc882_auto_init_hp_out(codec); | ||
7484 | alc882_auto_init_analog_input(codec); | ||
7485 | alc882_auto_init_input_src(codec); | ||
7486 | if (spec->unsol_event) | ||
7487 | alc_inithook(codec); | ||
7488 | } | ||
7489 | |||
7490 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ | ||
7491 | |||
7492 | static int patch_alc882(struct hda_codec *codec) | ||
7493 | { | ||
7494 | struct alc_spec *spec; | ||
7495 | int err, board_config; | ||
7496 | |||
7497 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
7498 | if (spec == NULL) | ||
7499 | return -ENOMEM; | ||
7500 | |||
7501 | codec->spec = spec; | ||
7502 | |||
7503 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, | ||
7504 | alc882_models, | ||
7505 | alc882_cfg_tbl); | ||
7506 | |||
7507 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | ||
7508 | /* Pick up systems that don't supply PCI SSID */ | ||
7509 | switch (codec->subsystem_id) { | ||
7510 | case 0x106b0c00: /* Mac Pro */ | ||
7511 | board_config = ALC885_MACPRO; | ||
7512 | break; | ||
7513 | case 0x106b1000: /* iMac 24 */ | ||
7514 | case 0x106b2800: /* AppleTV */ | ||
7515 | case 0x106b3e00: /* iMac 24 Aluminium */ | ||
7516 | board_config = ALC885_IMAC24; | ||
7517 | break; | ||
7518 | case 0x106b00a0: /* MacBookPro3,1 - Another revision */ | ||
7519 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ | ||
7520 | case 0x106b00a4: /* MacbookPro4,1 */ | ||
7521 | case 0x106b2c00: /* Macbook Pro rev3 */ | ||
7522 | /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */ | ||
7523 | case 0x106b3800: /* MacbookPro4,1 - latter revision */ | ||
7524 | board_config = ALC885_MBP3; | ||
7525 | break; | ||
7526 | case 0x106b3f00: /* Macbook 5,1 */ | ||
7527 | case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense | ||
7528 | * seems not working, so apparently | ||
7529 | * no perfect solution yet | ||
7530 | */ | ||
7531 | board_config = ALC885_MB5; | ||
7532 | break; | ||
7533 | default: | ||
7534 | /* ALC889A is handled better as ALC888-compatible */ | ||
7535 | if (codec->revision_id == 0x100101 || | ||
7536 | codec->revision_id == 0x100103) { | ||
7537 | alc_free(codec); | ||
7538 | return patch_alc883(codec); | ||
7539 | } | ||
7540 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | ||
7541 | "trying auto-probe from BIOS...\n", | ||
7542 | codec->chip_name); | ||
7543 | board_config = ALC882_AUTO; | ||
7544 | } | ||
7545 | } | ||
7546 | |||
7547 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); | ||
7548 | |||
7549 | if (board_config == ALC882_AUTO) { | ||
7550 | /* automatic parse from the BIOS config */ | ||
7551 | err = alc882_parse_auto_config(codec); | ||
7552 | if (err < 0) { | ||
7553 | alc_free(codec); | ||
7554 | return err; | ||
7555 | } else if (!err) { | ||
7556 | printk(KERN_INFO | ||
7557 | "hda_codec: Cannot set up configuration " | ||
7558 | "from BIOS. Using base mode...\n"); | ||
7559 | board_config = ALC882_3ST_DIG; | ||
7560 | } | ||
7561 | } | ||
7562 | |||
7563 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
7564 | if (err < 0) { | ||
7565 | alc_free(codec); | ||
7566 | return err; | ||
7567 | } | ||
7568 | |||
7569 | if (board_config != ALC882_AUTO) | ||
7570 | setup_preset(spec, &alc882_presets[board_config]); | ||
7571 | |||
7572 | spec->stream_analog_playback = &alc882_pcm_analog_playback; | ||
7573 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | ||
7574 | /* FIXME: setup DAC5 */ | ||
7575 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | ||
7576 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | ||
7577 | |||
7578 | spec->stream_digital_playback = &alc882_pcm_digital_playback; | ||
7579 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | ||
7580 | |||
7581 | if (!spec->adc_nids && spec->input_mux) { | ||
7582 | /* check whether NID 0x07 is valid */ | ||
7583 | unsigned int wcap = get_wcaps(codec, 0x07); | ||
7584 | /* get type */ | ||
7585 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
7586 | if (wcap != AC_WID_AUD_IN) { | ||
7587 | spec->adc_nids = alc882_adc_nids_alt; | ||
7588 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | ||
7589 | spec->capsrc_nids = alc882_capsrc_nids_alt; | ||
7590 | } else { | ||
7591 | spec->adc_nids = alc882_adc_nids; | ||
7592 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | ||
7593 | spec->capsrc_nids = alc882_capsrc_nids; | ||
7594 | } | ||
7595 | } | ||
7596 | set_capture_mixer(spec); | ||
7597 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | ||
7598 | |||
7599 | spec->vmaster_nid = 0x0c; | ||
7600 | |||
7601 | codec->patch_ops = alc_patch_ops; | ||
7602 | if (board_config == ALC882_AUTO) | ||
7603 | spec->init_hook = alc882_auto_init; | ||
7604 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
7605 | if (!spec->loopback.amplist) | ||
7606 | spec->loopback.amplist = alc882_loopbacks; | ||
7607 | #endif | ||
7608 | codec->proc_widget_hook = print_realtek_coef; | ||
7609 | |||
7610 | return 0; | ||
7611 | } | ||
7612 | |||
7613 | /* | ||
7614 | * ALC883 support | ||
7615 | * | ||
7616 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | ||
7617 | * configuration. Each pin widget can choose any input DACs and a mixer. | ||
7618 | * Each ADC is connected from a mixer of all inputs. This makes possible | ||
7619 | * 6-channel independent captures. | ||
7620 | * | ||
7621 | * In addition, an independent DAC for the multi-playback (not used in this | ||
7622 | * driver yet). | ||
7623 | */ | ||
7624 | #define ALC883_DIGOUT_NID 0x06 | ||
7625 | #define ALC883_DIGIN_NID 0x0a | ||
7626 | |||
7627 | #define ALC1200_DIGOUT_NID 0x10 | ||
7628 | |||
7629 | static hda_nid_t alc883_dac_nids[4] = { | ||
7630 | /* front, rear, clfe, rear_surr */ | ||
7631 | 0x02, 0x03, 0x04, 0x05 | ||
7632 | }; | ||
7633 | |||
7634 | static hda_nid_t alc883_adc_nids[2] = { | ||
7635 | /* ADC1-2 */ | ||
7636 | 0x08, 0x09, | ||
7637 | }; | ||
7638 | |||
7639 | static hda_nid_t alc883_adc_nids_alt[1] = { | ||
7640 | /* ADC1 */ | ||
7641 | 0x08, | ||
7642 | }; | ||
7643 | |||
7644 | static hda_nid_t alc883_adc_nids_rev[2] = { | ||
7645 | /* ADC2-1 */ | ||
7646 | 0x09, 0x08 | ||
7647 | }; | ||
7648 | |||
7649 | #define alc889_adc_nids alc880_adc_nids | ||
7650 | |||
7651 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; | ||
7652 | |||
7653 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; | ||
7654 | |||
7655 | #define alc889_capsrc_nids alc882_capsrc_nids | ||
7656 | |||
7657 | /* input MUX */ | ||
7658 | /* FIXME: should be a matrix-type input source selection */ | ||
7659 | |||
7660 | static struct hda_input_mux alc883_capture_source = { | ||
7661 | .num_items = 4, | ||
7662 | .items = { | ||
7663 | { "Mic", 0x0 }, | ||
7664 | { "Front Mic", 0x1 }, | ||
7665 | { "Line", 0x2 }, | ||
7666 | { "CD", 0x4 }, | ||
7667 | }, | ||
7668 | }; | ||
7669 | |||
7670 | static struct hda_input_mux alc883_3stack_6ch_intel = { | ||
7671 | .num_items = 4, | ||
7672 | .items = { | ||
7673 | { "Mic", 0x1 }, | ||
7674 | { "Front Mic", 0x0 }, | ||
7675 | { "Line", 0x2 }, | ||
7676 | { "CD", 0x4 }, | ||
7677 | }, | ||
7678 | }; | ||
7679 | |||
7680 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | ||
7681 | .num_items = 2, | ||
7682 | .items = { | ||
7683 | { "Mic", 0x1 }, | ||
7684 | { "Line", 0x2 }, | ||
7685 | }, | ||
7686 | }; | ||
7687 | |||
7688 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { | ||
7689 | .num_items = 4, | ||
7690 | .items = { | ||
7691 | { "Mic", 0x0 }, | ||
7692 | { "iMic", 0x1 }, | ||
7693 | { "Line", 0x2 }, | ||
7694 | { "CD", 0x4 }, | ||
7695 | }, | ||
7696 | }; | ||
7697 | |||
7698 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { | ||
7699 | .num_items = 2, | ||
7700 | .items = { | ||
7701 | { "Mic", 0x0 }, | ||
7702 | { "Int Mic", 0x1 }, | ||
7703 | }, | ||
7704 | }; | ||
7705 | |||
7706 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { | ||
7707 | .num_items = 3, | ||
7708 | .items = { | ||
7709 | { "Mic", 0x0 }, | ||
7710 | { "Front Mic", 0x1 }, | ||
7711 | { "Line", 0x4 }, | ||
7712 | }, | ||
7713 | }; | ||
7714 | |||
7715 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | ||
7716 | .num_items = 2, | ||
7717 | .items = { | ||
7718 | { "Mic", 0x0 }, | ||
7719 | { "Line", 0x2 }, | ||
7720 | }, | ||
7721 | }; | ||
7722 | |||
7723 | static struct hda_input_mux alc889A_mb31_capture_source = { | ||
7724 | .num_items = 2, | ||
7725 | .items = { | ||
7726 | { "Mic", 0x0 }, | ||
7727 | /* Front Mic (0x01) unused */ | ||
7728 | { "Line", 0x2 }, | ||
7729 | /* Line 2 (0x03) unused */ | ||
7730 | /* CD (0x04) unsused? */ | ||
7731 | }, | ||
7732 | }; | ||
7733 | |||
7734 | /* | ||
7735 | * 2ch mode | ||
7736 | */ | ||
7737 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | ||
7738 | { 2, NULL } | ||
7739 | }; | ||
7740 | |||
7741 | /* | ||
7742 | * 2ch mode | ||
7743 | */ | ||
7744 | static struct hda_verb alc883_3ST_ch2_init[] = { | ||
7745 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7746 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7747 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7748 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7749 | { } /* end */ | ||
7750 | }; | ||
7751 | |||
7752 | /* | ||
7753 | * 4ch mode | ||
7754 | */ | ||
7755 | static struct hda_verb alc883_3ST_ch4_init[] = { | ||
7756 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7757 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7758 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7759 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7760 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7761 | { } /* end */ | ||
7762 | }; | ||
7763 | |||
7764 | /* | ||
7765 | * 6ch mode | ||
7766 | */ | ||
7767 | static struct hda_verb alc883_3ST_ch6_init[] = { | ||
7768 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7769 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7770 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7771 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7772 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7773 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7774 | { } /* end */ | ||
7775 | }; | ||
7776 | |||
7777 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { | ||
7778 | { 2, alc883_3ST_ch2_init }, | ||
7779 | { 4, alc883_3ST_ch4_init }, | ||
7780 | { 6, alc883_3ST_ch6_init }, | ||
7781 | }; | ||
7782 | |||
7783 | |||
7784 | /* | ||
7785 | * 2ch mode | ||
7786 | */ | ||
7787 | static struct hda_verb alc883_4ST_ch2_init[] = { | ||
7788 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7789 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7790 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7791 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7792 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7793 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7794 | { } /* end */ | ||
7795 | }; | ||
7796 | |||
7797 | /* | ||
7798 | * 4ch mode | ||
7799 | */ | ||
7800 | static struct hda_verb alc883_4ST_ch4_init[] = { | ||
7801 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7802 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7803 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7804 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7805 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7806 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7807 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7808 | { } /* end */ | ||
7809 | }; | ||
7810 | |||
7811 | /* | ||
7812 | * 6ch mode | ||
7813 | */ | ||
7814 | static struct hda_verb alc883_4ST_ch6_init[] = { | ||
7815 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7816 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7817 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7818 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7819 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7820 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7821 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7822 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7823 | { } /* end */ | ||
7824 | }; | ||
7825 | |||
7826 | /* | ||
7827 | * 8ch mode | ||
7828 | */ | ||
7829 | static struct hda_verb alc883_4ST_ch8_init[] = { | ||
7830 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7831 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7832 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
7833 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7834 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7835 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7836 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7837 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7838 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7839 | { } /* end */ | ||
7840 | }; | ||
7841 | |||
7842 | static struct hda_channel_mode alc883_4ST_8ch_modes[4] = { | ||
7843 | { 2, alc883_4ST_ch2_init }, | ||
7844 | { 4, alc883_4ST_ch4_init }, | ||
7845 | { 6, alc883_4ST_ch6_init }, | ||
7846 | { 8, alc883_4ST_ch8_init }, | ||
7847 | }; | ||
7848 | |||
7849 | |||
7850 | /* | ||
7851 | * 2ch mode | ||
7852 | */ | ||
7853 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | ||
7854 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7855 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7856 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7857 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7858 | { } /* end */ | ||
7859 | }; | ||
7860 | |||
7861 | /* | ||
7862 | * 4ch mode | ||
7863 | */ | ||
7864 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | ||
7865 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7866 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7867 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7868 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7869 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7870 | { } /* end */ | ||
7871 | }; | ||
7872 | |||
7873 | /* | ||
7874 | * 6ch mode | ||
7875 | */ | ||
7876 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | ||
7877 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7878 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7879 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7880 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7881 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7882 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7883 | { } /* end */ | ||
7884 | }; | ||
7885 | |||
7886 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | ||
7887 | { 2, alc883_3ST_ch2_intel_init }, | ||
7888 | { 4, alc883_3ST_ch4_intel_init }, | ||
7889 | { 6, alc883_3ST_ch6_intel_init }, | ||
7890 | }; | ||
7891 | |||
7892 | /* | ||
7893 | * 6ch mode | ||
7894 | */ | ||
7895 | static struct hda_verb alc883_sixstack_ch6_init[] = { | ||
7896 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | ||
7897 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7898 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7899 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7900 | { } /* end */ | ||
7901 | }; | ||
7902 | |||
7903 | /* | ||
7904 | * 8ch mode | ||
7905 | */ | ||
7906 | static struct hda_verb alc883_sixstack_ch8_init[] = { | ||
7907 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7908 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7909 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7910 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7911 | { } /* end */ | ||
7912 | }; | ||
7913 | |||
7914 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | ||
7915 | { 6, alc883_sixstack_ch6_init }, | ||
7916 | { 8, alc883_sixstack_ch8_init }, | ||
7917 | }; | ||
7918 | |||
7919 | /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ | 7720 | /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ |
7920 | static struct hda_verb alc889A_mb31_ch2_init[] = { | 7721 | static struct hda_verb alc889A_mb31_ch2_init[] = { |
7921 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ | 7722 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ |
@@ -7966,34 +7767,7 @@ static struct hda_verb alc883_medion_eapd_verbs[] = { | |||
7966 | { } | 7767 | { } |
7967 | }; | 7768 | }; |
7968 | 7769 | ||
7969 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | 7770 | #define alc883_base_mixer alc882_base_mixer |
7970 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | ||
7971 | */ | ||
7972 | |||
7973 | static struct snd_kcontrol_new alc883_base_mixer[] = { | ||
7974 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
7975 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
7976 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
7977 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
7978 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | ||
7979 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
7980 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
7981 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
7982 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | ||
7983 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | ||
7984 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
7985 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
7986 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
7987 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
7988 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
7989 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
7990 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
7991 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
7992 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
7993 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | ||
7994 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
7995 | { } /* end */ | ||
7996 | }; | ||
7997 | 7771 | ||
7998 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { | 7772 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7999 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7773 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
@@ -8104,6 +7878,30 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { | |||
8104 | { } /* end */ | 7878 | { } /* end */ |
8105 | }; | 7879 | }; |
8106 | 7880 | ||
7881 | static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = { | ||
7882 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
7883 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
7884 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
7885 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
7886 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | ||
7887 | HDA_OUTPUT), | ||
7888 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
7889 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
7890 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
7891 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | ||
7892 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT), | ||
7893 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
7894 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
7895 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
7896 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | ||
7897 | HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT), | ||
7898 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | ||
7899 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
7900 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | ||
7901 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
7902 | { } /* end */ | ||
7903 | }; | ||
7904 | |||
8107 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { | 7905 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
8108 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7906 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8109 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | 7907 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
@@ -8344,93 +8142,14 @@ static struct snd_kcontrol_new alc883_chmode_mixer[] = { | |||
8344 | { } /* end */ | 8142 | { } /* end */ |
8345 | }; | 8143 | }; |
8346 | 8144 | ||
8347 | static struct hda_verb alc883_init_verbs[] = { | ||
8348 | /* ADC1: mute amp left and right */ | ||
8349 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8350 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8351 | /* ADC2: mute amp left and right */ | ||
8352 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8353 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8354 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | ||
8355 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8356 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8357 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8358 | /* Rear mixer */ | ||
8359 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8360 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8361 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8362 | /* CLFE mixer */ | ||
8363 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8364 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8365 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8366 | /* Side mixer */ | ||
8367 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8368 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8369 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8370 | |||
8371 | /* mute analog input loopbacks */ | ||
8372 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8373 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8374 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8375 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
8376 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8377 | |||
8378 | /* Front Pin: output 0 (0x0c) */ | ||
8379 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8380 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8381 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8382 | /* Rear Pin: output 1 (0x0d) */ | ||
8383 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8384 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8385 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
8386 | /* CLFE Pin: output 2 (0x0e) */ | ||
8387 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8388 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8389 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
8390 | /* Side Pin: output 3 (0x0f) */ | ||
8391 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8392 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8393 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
8394 | /* Mic (rear) pin: input vref at 80% */ | ||
8395 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
8396 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
8397 | /* Front Mic pin: input vref at 80% */ | ||
8398 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
8399 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
8400 | /* Line In pin: input */ | ||
8401 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
8402 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
8403 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | ||
8404 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
8405 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8406 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8407 | /* CD pin widget for input */ | ||
8408 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
8409 | |||
8410 | /* FIXME: use matrix-type input source selection */ | ||
8411 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | ||
8412 | /* Input mixer2 */ | ||
8413 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8414 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8415 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8416 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8417 | /* Input mixer3 */ | ||
8418 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8419 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8420 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8421 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8422 | { } | ||
8423 | }; | ||
8424 | |||
8425 | /* toggle speaker-output according to the hp-jack state */ | 8145 | /* toggle speaker-output according to the hp-jack state */ |
8426 | static void alc883_mitac_init_hook(struct hda_codec *codec) | 8146 | static void alc883_mitac_setup(struct hda_codec *codec) |
8427 | { | 8147 | { |
8428 | struct alc_spec *spec = codec->spec; | 8148 | struct alc_spec *spec = codec->spec; |
8429 | 8149 | ||
8430 | spec->autocfg.hp_pins[0] = 0x15; | 8150 | spec->autocfg.hp_pins[0] = 0x15; |
8431 | spec->autocfg.speaker_pins[0] = 0x14; | 8151 | spec->autocfg.speaker_pins[0] = 0x14; |
8432 | spec->autocfg.speaker_pins[1] = 0x17; | 8152 | spec->autocfg.speaker_pins[1] = 0x17; |
8433 | alc_automute_amp(codec); | ||
8434 | } | 8153 | } |
8435 | 8154 | ||
8436 | /* auto-toggle front mic */ | 8155 | /* auto-toggle front mic */ |
@@ -8462,6 +8181,22 @@ static struct hda_verb alc883_mitac_verbs[] = { | |||
8462 | { } /* end */ | 8181 | { } /* end */ |
8463 | }; | 8182 | }; |
8464 | 8183 | ||
8184 | static struct hda_verb alc883_clevo_m540r_verbs[] = { | ||
8185 | /* HP */ | ||
8186 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8187 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
8188 | /* Int speaker */ | ||
8189 | /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/ | ||
8190 | |||
8191 | /* enable unsolicited event */ | ||
8192 | /* | ||
8193 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
8194 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | ||
8195 | */ | ||
8196 | |||
8197 | { } /* end */ | ||
8198 | }; | ||
8199 | |||
8465 | static struct hda_verb alc883_clevo_m720_verbs[] = { | 8200 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
8466 | /* HP */ | 8201 | /* HP */ |
8467 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 8202 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -8585,7 +8320,7 @@ static struct hda_verb alc883_vaiott_verbs[] = { | |||
8585 | { } /* end */ | 8320 | { } /* end */ |
8586 | }; | 8321 | }; |
8587 | 8322 | ||
8588 | static void alc888_3st_hp_init_hook(struct hda_codec *codec) | 8323 | static void alc888_3st_hp_setup(struct hda_codec *codec) |
8589 | { | 8324 | { |
8590 | struct alc_spec *spec = codec->spec; | 8325 | struct alc_spec *spec = codec->spec; |
8591 | 8326 | ||
@@ -8593,7 +8328,6 @@ static void alc888_3st_hp_init_hook(struct hda_codec *codec) | |||
8593 | spec->autocfg.speaker_pins[0] = 0x14; | 8328 | spec->autocfg.speaker_pins[0] = 0x14; |
8594 | spec->autocfg.speaker_pins[1] = 0x16; | 8329 | spec->autocfg.speaker_pins[1] = 0x16; |
8595 | spec->autocfg.speaker_pins[2] = 0x18; | 8330 | spec->autocfg.speaker_pins[2] = 0x18; |
8596 | alc_automute_amp(codec); | ||
8597 | } | 8331 | } |
8598 | 8332 | ||
8599 | static struct hda_verb alc888_3st_hp_verbs[] = { | 8333 | static struct hda_verb alc888_3st_hp_verbs[] = { |
@@ -8690,13 +8424,12 @@ static struct hda_verb alc883_medion_md2_verbs[] = { | |||
8690 | }; | 8424 | }; |
8691 | 8425 | ||
8692 | /* toggle speaker-output according to the hp-jack state */ | 8426 | /* toggle speaker-output according to the hp-jack state */ |
8693 | static void alc883_medion_md2_init_hook(struct hda_codec *codec) | 8427 | static void alc883_medion_md2_setup(struct hda_codec *codec) |
8694 | { | 8428 | { |
8695 | struct alc_spec *spec = codec->spec; | 8429 | struct alc_spec *spec = codec->spec; |
8696 | 8430 | ||
8697 | spec->autocfg.hp_pins[0] = 0x14; | 8431 | spec->autocfg.hp_pins[0] = 0x14; |
8698 | spec->autocfg.speaker_pins[0] = 0x15; | 8432 | spec->autocfg.speaker_pins[0] = 0x15; |
8699 | alc_automute_amp(codec); | ||
8700 | } | 8433 | } |
8701 | 8434 | ||
8702 | /* toggle speaker-output according to the hp-jack state */ | 8435 | /* toggle speaker-output according to the hp-jack state */ |
@@ -8713,12 +8446,16 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8713 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8446 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8714 | } | 8447 | } |
8715 | 8448 | ||
8716 | static void alc883_clevo_m720_init_hook(struct hda_codec *codec) | 8449 | static void alc883_clevo_m720_setup(struct hda_codec *codec) |
8717 | { | 8450 | { |
8718 | struct alc_spec *spec = codec->spec; | 8451 | struct alc_spec *spec = codec->spec; |
8719 | 8452 | ||
8720 | spec->autocfg.hp_pins[0] = 0x15; | 8453 | spec->autocfg.hp_pins[0] = 0x15; |
8721 | spec->autocfg.speaker_pins[0] = 0x14; | 8454 | spec->autocfg.speaker_pins[0] = 0x14; |
8455 | } | ||
8456 | |||
8457 | static void alc883_clevo_m720_init_hook(struct hda_codec *codec) | ||
8458 | { | ||
8722 | alc_automute_amp(codec); | 8459 | alc_automute_amp(codec); |
8723 | alc883_clevo_m720_mic_automute(codec); | 8460 | alc883_clevo_m720_mic_automute(codec); |
8724 | } | 8461 | } |
@@ -8737,22 +8474,20 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |||
8737 | } | 8474 | } |
8738 | 8475 | ||
8739 | /* toggle speaker-output according to the hp-jack state */ | 8476 | /* toggle speaker-output according to the hp-jack state */ |
8740 | static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) | 8477 | static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec) |
8741 | { | 8478 | { |
8742 | struct alc_spec *spec = codec->spec; | 8479 | struct alc_spec *spec = codec->spec; |
8743 | 8480 | ||
8744 | spec->autocfg.hp_pins[0] = 0x14; | 8481 | spec->autocfg.hp_pins[0] = 0x14; |
8745 | spec->autocfg.speaker_pins[0] = 0x15; | 8482 | spec->autocfg.speaker_pins[0] = 0x15; |
8746 | alc_automute_amp(codec); | ||
8747 | } | 8483 | } |
8748 | 8484 | ||
8749 | static void alc883_haier_w66_init_hook(struct hda_codec *codec) | 8485 | static void alc883_haier_w66_setup(struct hda_codec *codec) |
8750 | { | 8486 | { |
8751 | struct alc_spec *spec = codec->spec; | 8487 | struct alc_spec *spec = codec->spec; |
8752 | 8488 | ||
8753 | spec->autocfg.hp_pins[0] = 0x1b; | 8489 | spec->autocfg.hp_pins[0] = 0x1b; |
8754 | spec->autocfg.speaker_pins[0] = 0x14; | 8490 | spec->autocfg.speaker_pins[0] = 0x14; |
8755 | alc_automute_amp(codec); | ||
8756 | } | 8491 | } |
8757 | 8492 | ||
8758 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | 8493 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
@@ -8791,14 +8526,13 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |||
8791 | } | 8526 | } |
8792 | 8527 | ||
8793 | /* toggle speaker-output according to the hp-jack state */ | 8528 | /* toggle speaker-output according to the hp-jack state */ |
8794 | static void alc883_acer_aspire_init_hook(struct hda_codec *codec) | 8529 | static void alc883_acer_aspire_setup(struct hda_codec *codec) |
8795 | { | 8530 | { |
8796 | struct alc_spec *spec = codec->spec; | 8531 | struct alc_spec *spec = codec->spec; |
8797 | 8532 | ||
8798 | spec->autocfg.hp_pins[0] = 0x14; | 8533 | spec->autocfg.hp_pins[0] = 0x14; |
8799 | spec->autocfg.speaker_pins[0] = 0x15; | 8534 | spec->autocfg.speaker_pins[0] = 0x15; |
8800 | spec->autocfg.speaker_pins[1] = 0x16; | 8535 | spec->autocfg.speaker_pins[1] = 0x16; |
8801 | alc_automute_amp(codec); | ||
8802 | } | 8536 | } |
8803 | 8537 | ||
8804 | static struct hda_verb alc883_acer_eapd_verbs[] = { | 8538 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
@@ -8819,7 +8553,14 @@ static struct hda_verb alc883_acer_eapd_verbs[] = { | |||
8819 | { } | 8553 | { } |
8820 | }; | 8554 | }; |
8821 | 8555 | ||
8822 | static void alc888_6st_dell_init_hook(struct hda_codec *codec) | 8556 | static struct hda_verb alc888_acer_aspire_7730G_verbs[] = { |
8557 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8558 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
8559 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
8560 | { } /* end */ | ||
8561 | }; | ||
8562 | |||
8563 | static void alc888_6st_dell_setup(struct hda_codec *codec) | ||
8823 | { | 8564 | { |
8824 | struct alc_spec *spec = codec->spec; | 8565 | struct alc_spec *spec = codec->spec; |
8825 | 8566 | ||
@@ -8828,10 +8569,9 @@ static void alc888_6st_dell_init_hook(struct hda_codec *codec) | |||
8828 | spec->autocfg.speaker_pins[1] = 0x15; | 8569 | spec->autocfg.speaker_pins[1] = 0x15; |
8829 | spec->autocfg.speaker_pins[2] = 0x16; | 8570 | spec->autocfg.speaker_pins[2] = 0x16; |
8830 | spec->autocfg.speaker_pins[3] = 0x17; | 8571 | spec->autocfg.speaker_pins[3] = 0x17; |
8831 | alc_automute_amp(codec); | ||
8832 | } | 8572 | } |
8833 | 8573 | ||
8834 | static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) | 8574 | static void alc888_lenovo_sky_setup(struct hda_codec *codec) |
8835 | { | 8575 | { |
8836 | struct alc_spec *spec = codec->spec; | 8576 | struct alc_spec *spec = codec->spec; |
8837 | 8577 | ||
@@ -8841,82 +8581,17 @@ static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) | |||
8841 | spec->autocfg.speaker_pins[2] = 0x16; | 8581 | spec->autocfg.speaker_pins[2] = 0x16; |
8842 | spec->autocfg.speaker_pins[3] = 0x17; | 8582 | spec->autocfg.speaker_pins[3] = 0x17; |
8843 | spec->autocfg.speaker_pins[4] = 0x1a; | 8583 | spec->autocfg.speaker_pins[4] = 0x1a; |
8844 | alc_automute_amp(codec); | ||
8845 | } | 8584 | } |
8846 | 8585 | ||
8847 | static void alc883_vaiott_init_hook(struct hda_codec *codec) | 8586 | static void alc883_vaiott_setup(struct hda_codec *codec) |
8848 | { | 8587 | { |
8849 | struct alc_spec *spec = codec->spec; | 8588 | struct alc_spec *spec = codec->spec; |
8850 | 8589 | ||
8851 | spec->autocfg.hp_pins[0] = 0x15; | 8590 | spec->autocfg.hp_pins[0] = 0x15; |
8852 | spec->autocfg.speaker_pins[0] = 0x14; | 8591 | spec->autocfg.speaker_pins[0] = 0x14; |
8853 | spec->autocfg.speaker_pins[1] = 0x17; | 8592 | spec->autocfg.speaker_pins[1] = 0x17; |
8854 | alc_automute_amp(codec); | ||
8855 | } | 8593 | } |
8856 | 8594 | ||
8857 | /* | ||
8858 | * generic initialization of ADC, input mixers and output mixers | ||
8859 | */ | ||
8860 | static struct hda_verb alc883_auto_init_verbs[] = { | ||
8861 | /* | ||
8862 | * Unmute ADC0-2 and set the default input to mic-in | ||
8863 | */ | ||
8864 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8865 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8866 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8867 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8868 | |||
8869 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
8870 | * mixer widget | ||
8871 | * Note: PASD motherboards uses the Line In 2 as the input for | ||
8872 | * front panel mic (mic 2) | ||
8873 | */ | ||
8874 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | ||
8875 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8876 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8877 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8878 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
8879 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8880 | |||
8881 | /* | ||
8882 | * Set up output mixers (0x0c - 0x0f) | ||
8883 | */ | ||
8884 | /* set vol=0 to output mixers */ | ||
8885 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8886 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8887 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8888 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8889 | /* set up input amps for analog loopback */ | ||
8890 | /* Amp Indices: DAC = 0, mixer = 1 */ | ||
8891 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8892 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8893 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8894 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8895 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8896 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8897 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8898 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8899 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8900 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8901 | |||
8902 | /* FIXME: use matrix-type input source selection */ | ||
8903 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | ||
8904 | /* Input mixer1 */ | ||
8905 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8906 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8907 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
8908 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ | ||
8909 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | ||
8910 | /* Input mixer2 */ | ||
8911 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8912 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8913 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
8914 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ | ||
8915 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | ||
8916 | |||
8917 | { } | ||
8918 | }; | ||
8919 | |||
8920 | static struct hda_verb alc888_asus_m90v_verbs[] = { | 8595 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8921 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 8596 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8922 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 8597 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
@@ -8927,19 +8602,7 @@ static struct hda_verb alc888_asus_m90v_verbs[] = { | |||
8927 | { } /* end */ | 8602 | { } /* end */ |
8928 | }; | 8603 | }; |
8929 | 8604 | ||
8930 | static void alc883_nb_mic_automute(struct hda_codec *codec) | 8605 | static void alc883_mode2_setup(struct hda_codec *codec) |
8931 | { | ||
8932 | unsigned int present; | ||
8933 | |||
8934 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
8935 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8936 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
8937 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
8938 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
8939 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
8940 | } | ||
8941 | |||
8942 | static void alc883_M90V_init_hook(struct hda_codec *codec) | ||
8943 | { | 8606 | { |
8944 | struct alc_spec *spec = codec->spec; | 8607 | struct alc_spec *spec = codec->spec; |
8945 | 8608 | ||
@@ -8947,26 +8610,11 @@ static void alc883_M90V_init_hook(struct hda_codec *codec) | |||
8947 | spec->autocfg.speaker_pins[0] = 0x14; | 8610 | spec->autocfg.speaker_pins[0] = 0x14; |
8948 | spec->autocfg.speaker_pins[1] = 0x15; | 8611 | spec->autocfg.speaker_pins[1] = 0x15; |
8949 | spec->autocfg.speaker_pins[2] = 0x16; | 8612 | spec->autocfg.speaker_pins[2] = 0x16; |
8950 | alc_automute_pin(codec); | 8613 | spec->ext_mic.pin = 0x18; |
8951 | } | 8614 | spec->int_mic.pin = 0x19; |
8952 | 8615 | spec->ext_mic.mux_idx = 0; | |
8953 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | 8616 | spec->int_mic.mux_idx = 1; |
8954 | unsigned int res) | 8617 | spec->auto_mic = 1; |
8955 | { | ||
8956 | switch (res >> 26) { | ||
8957 | case ALC880_MIC_EVENT: | ||
8958 | alc883_nb_mic_automute(codec); | ||
8959 | break; | ||
8960 | default: | ||
8961 | alc_sku_unsol_event(codec, res); | ||
8962 | break; | ||
8963 | } | ||
8964 | } | ||
8965 | |||
8966 | static void alc883_mode2_inithook(struct hda_codec *codec) | ||
8967 | { | ||
8968 | alc883_M90V_init_hook(codec); | ||
8969 | alc883_nb_mic_automute(codec); | ||
8970 | } | 8618 | } |
8971 | 8619 | ||
8972 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | 8620 | static struct hda_verb alc888_asus_eee1601_verbs[] = { |
@@ -9027,25 +8675,44 @@ static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res) | |||
9027 | alc889A_mb31_automute(codec); | 8675 | alc889A_mb31_automute(codec); |
9028 | } | 8676 | } |
9029 | 8677 | ||
8678 | |||
9030 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 8679 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9031 | #define alc883_loopbacks alc880_loopbacks | 8680 | #define alc882_loopbacks alc880_loopbacks |
9032 | #endif | 8681 | #endif |
9033 | 8682 | ||
9034 | /* pcm configuration: identical with ALC880 */ | 8683 | /* pcm configuration: identical with ALC880 */ |
9035 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | 8684 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback |
9036 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | 8685 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture |
9037 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture | 8686 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback |
9038 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback | 8687 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture |
9039 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | 8688 | |
8689 | static hda_nid_t alc883_slave_dig_outs[] = { | ||
8690 | ALC1200_DIGOUT_NID, 0, | ||
8691 | }; | ||
8692 | |||
8693 | static hda_nid_t alc1200_slave_dig_outs[] = { | ||
8694 | ALC883_DIGOUT_NID, 0, | ||
8695 | }; | ||
9040 | 8696 | ||
9041 | /* | 8697 | /* |
9042 | * configuration and preset | 8698 | * configuration and preset |
9043 | */ | 8699 | */ |
9044 | static const char *alc883_models[ALC883_MODEL_LAST] = { | 8700 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
9045 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | 8701 | [ALC882_3ST_DIG] = "3stack-dig", |
8702 | [ALC882_6ST_DIG] = "6stack-dig", | ||
8703 | [ALC882_ARIMA] = "arima", | ||
8704 | [ALC882_W2JC] = "w2jc", | ||
8705 | [ALC882_TARGA] = "targa", | ||
8706 | [ALC882_ASUS_A7J] = "asus-a7j", | ||
8707 | [ALC882_ASUS_A7M] = "asus-a7m", | ||
8708 | [ALC885_MACPRO] = "macpro", | ||
8709 | [ALC885_MB5] = "mb5", | ||
8710 | [ALC885_MBP3] = "mbp3", | ||
8711 | [ALC885_IMAC24] = "imac24", | ||
8712 | [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig", | ||
9046 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | 8713 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", |
9047 | [ALC883_3ST_6ch] = "3stack-6ch", | 8714 | [ALC883_3ST_6ch] = "3stack-6ch", |
9048 | [ALC883_6ST_DIG] = "6stack-dig", | 8715 | [ALC883_6ST_DIG] = "alc883-6stack-dig", |
9049 | [ALC883_TARGA_DIG] = "targa-dig", | 8716 | [ALC883_TARGA_DIG] = "targa-dig", |
9050 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | 8717 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", |
9051 | [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", | 8718 | [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", |
@@ -9054,6 +8721,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = { | |||
9054 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", | 8721 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", |
9055 | [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g", | 8722 | [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g", |
9056 | [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", | 8723 | [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", |
8724 | [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g", | ||
9057 | [ALC883_MEDION] = "medion", | 8725 | [ALC883_MEDION] = "medion", |
9058 | [ALC883_MEDION_MD2] = "medion-md2", | 8726 | [ALC883_MEDION_MD2] = "medion-md2", |
9059 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", | 8727 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
@@ -9065,18 +8733,22 @@ static const char *alc883_models[ALC883_MODEL_LAST] = { | |||
9065 | [ALC888_3ST_HP] = "3stack-hp", | 8733 | [ALC888_3ST_HP] = "3stack-hp", |
9066 | [ALC888_6ST_DELL] = "6stack-dell", | 8734 | [ALC888_6ST_DELL] = "6stack-dell", |
9067 | [ALC883_MITAC] = "mitac", | 8735 | [ALC883_MITAC] = "mitac", |
8736 | [ALC883_CLEVO_M540R] = "clevo-m540r", | ||
9068 | [ALC883_CLEVO_M720] = "clevo-m720", | 8737 | [ALC883_CLEVO_M720] = "clevo-m720", |
9069 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", | 8738 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
9070 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", | 8739 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", |
9071 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", | 8740 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
8741 | [ALC889A_INTEL] = "intel-alc889a", | ||
8742 | [ALC889_INTEL] = "intel-x58", | ||
9072 | [ALC1200_ASUS_P5Q] = "asus-p5q", | 8743 | [ALC1200_ASUS_P5Q] = "asus-p5q", |
9073 | [ALC889A_MB31] = "mb31", | 8744 | [ALC889A_MB31] = "mb31", |
9074 | [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", | 8745 | [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", |
9075 | [ALC883_AUTO] = "auto", | 8746 | [ALC882_AUTO] = "auto", |
9076 | }; | 8747 | }; |
9077 | 8748 | ||
9078 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | 8749 | static struct snd_pci_quirk alc882_cfg_tbl[] = { |
9079 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | 8750 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), |
8751 | |||
9080 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), | 8752 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
9081 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), | 8753 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), |
9082 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), | 8754 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), |
@@ -9091,40 +8763,56 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9091 | ALC888_ACER_ASPIRE_8930G), | 8763 | ALC888_ACER_ASPIRE_8930G), |
9092 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", | 8764 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
9093 | ALC888_ACER_ASPIRE_8930G), | 8765 | ALC888_ACER_ASPIRE_8930G), |
9094 | SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), | 8766 | SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO), |
9095 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), | 8767 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO), |
9096 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", | 8768 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
9097 | ALC888_ACER_ASPIRE_6530G), | 8769 | ALC888_ACER_ASPIRE_6530G), |
9098 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", | 8770 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
9099 | ALC888_ACER_ASPIRE_6530G), | 8771 | ALC888_ACER_ASPIRE_6530G), |
8772 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", | ||
8773 | ALC888_ACER_ASPIRE_7730G), | ||
9100 | /* default Acer -- disabled as it causes more problems. | 8774 | /* default Acer -- disabled as it causes more problems. |
9101 | * model=auto should work fine now | 8775 | * model=auto should work fine now |
9102 | */ | 8776 | */ |
9103 | /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ | 8777 | /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ |
8778 | |||
9104 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), | 8779 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
8780 | |||
9105 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), | 8781 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
9106 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), | 8782 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
9107 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | 8783 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), |
9108 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), | 8784 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
9109 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), | 8785 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), |
9110 | SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), | 8786 | SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), |
8787 | |||
8788 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), | ||
8789 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), | ||
8790 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), | ||
9111 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), | 8791 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
8792 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), | ||
8793 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), | ||
8794 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), | ||
9112 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), | 8795 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
9113 | SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), | 8796 | SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), |
9114 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), | 8797 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), |
9115 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), | 8798 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), |
8799 | |||
8800 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT), | ||
9116 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), | 8801 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
9117 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), | 8802 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
9118 | SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), | 8803 | SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), |
9119 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), | 8804 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
9120 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | 8805 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), |
9121 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), | 8806 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
9122 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), | 8807 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
9123 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), | 8808 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
8809 | |||
9124 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), | 8810 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
9125 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), | 8811 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
9126 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), | 8812 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
8813 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ | ||
9127 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), | 8814 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
8815 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | ||
9128 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), | 8816 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
9129 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), | 8817 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
9130 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), | 8818 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
@@ -9133,6 +8821,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9133 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | 8821 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), |
9134 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), | 8822 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
9135 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), | 8823 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
8824 | SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG), | ||
9136 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), | 8825 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
9137 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | 8826 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), |
9138 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | 8827 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), |
@@ -9146,11 +8835,15 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9146 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | 8835 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), |
9147 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), | 8836 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), |
9148 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), | 8837 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
8838 | SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG), | ||
8839 | |||
9149 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), | 8840 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
9150 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), | 8841 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
9151 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | 8842 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), |
8843 | SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R), | ||
9152 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), | 8844 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), |
9153 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), | 8845 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
8846 | /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */ | ||
9154 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), | 8847 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
9155 | SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", | 8848 | SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", |
9156 | ALC883_FUJITSU_PI2515), | 8849 | ALC883_FUJITSU_PI2515), |
@@ -9165,24 +8858,186 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9165 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), | 8858 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), |
9166 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), | 8859 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
9167 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), | 8860 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
8861 | |||
9168 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), | 8862 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
9169 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | 8863 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), |
9170 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), | 8864 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), |
9171 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), | 8865 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL), |
8866 | SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL), | ||
8867 | SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL), | ||
9172 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | 8868 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9173 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT), | ||
9174 | {} | ||
9175 | }; | ||
9176 | 8869 | ||
9177 | static hda_nid_t alc883_slave_dig_outs[] = { | 8870 | {} |
9178 | ALC1200_DIGOUT_NID, 0, | ||
9179 | }; | 8871 | }; |
9180 | 8872 | ||
9181 | static hda_nid_t alc1200_slave_dig_outs[] = { | 8873 | /* codec SSID table for Intel Mac */ |
9182 | ALC883_DIGOUT_NID, 0, | 8874 | static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { |
8875 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3), | ||
8876 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3), | ||
8877 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3), | ||
8878 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO), | ||
8879 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24), | ||
8880 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), | ||
8881 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), | ||
8882 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), | ||
8883 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), | ||
8884 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), | ||
8885 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), | ||
8886 | /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently | ||
8887 | * no perfect solution yet | ||
8888 | */ | ||
8889 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5), | ||
8890 | {} /* terminator */ | ||
9183 | }; | 8891 | }; |
9184 | 8892 | ||
9185 | static struct alc_config_preset alc883_presets[] = { | 8893 | static struct alc_config_preset alc882_presets[] = { |
8894 | [ALC882_3ST_DIG] = { | ||
8895 | .mixers = { alc882_base_mixer }, | ||
8896 | .init_verbs = { alc882_base_init_verbs, | ||
8897 | alc882_adc1_init_verbs }, | ||
8898 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8899 | .dac_nids = alc882_dac_nids, | ||
8900 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8901 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8902 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
8903 | .channel_mode = alc882_ch_modes, | ||
8904 | .need_dac_fix = 1, | ||
8905 | .input_mux = &alc882_capture_source, | ||
8906 | }, | ||
8907 | [ALC882_6ST_DIG] = { | ||
8908 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
8909 | .init_verbs = { alc882_base_init_verbs, | ||
8910 | alc882_adc1_init_verbs }, | ||
8911 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8912 | .dac_nids = alc882_dac_nids, | ||
8913 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8914 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8915 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
8916 | .channel_mode = alc882_sixstack_modes, | ||
8917 | .input_mux = &alc882_capture_source, | ||
8918 | }, | ||
8919 | [ALC882_ARIMA] = { | ||
8920 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
8921 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
8922 | alc882_eapd_verbs }, | ||
8923 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8924 | .dac_nids = alc882_dac_nids, | ||
8925 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
8926 | .channel_mode = alc882_sixstack_modes, | ||
8927 | .input_mux = &alc882_capture_source, | ||
8928 | }, | ||
8929 | [ALC882_W2JC] = { | ||
8930 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | ||
8931 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
8932 | alc882_eapd_verbs, alc880_gpio1_init_verbs }, | ||
8933 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8934 | .dac_nids = alc882_dac_nids, | ||
8935 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
8936 | .channel_mode = alc880_threestack_modes, | ||
8937 | .need_dac_fix = 1, | ||
8938 | .input_mux = &alc882_capture_source, | ||
8939 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8940 | }, | ||
8941 | [ALC885_MBP3] = { | ||
8942 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | ||
8943 | .init_verbs = { alc885_mbp3_init_verbs, | ||
8944 | alc880_gpio1_init_verbs }, | ||
8945 | .num_dacs = 2, | ||
8946 | .dac_nids = alc882_dac_nids, | ||
8947 | .hp_nid = 0x04, | ||
8948 | .channel_mode = alc885_mbp_4ch_modes, | ||
8949 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes), | ||
8950 | .input_mux = &alc882_capture_source, | ||
8951 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8952 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8953 | .unsol_event = alc_automute_amp_unsol_event, | ||
8954 | .setup = alc885_mbp3_setup, | ||
8955 | .init_hook = alc_automute_amp, | ||
8956 | }, | ||
8957 | [ALC885_MB5] = { | ||
8958 | .mixers = { alc885_mb5_mixer, alc882_chmode_mixer }, | ||
8959 | .init_verbs = { alc885_mb5_init_verbs, | ||
8960 | alc880_gpio1_init_verbs }, | ||
8961 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8962 | .dac_nids = alc882_dac_nids, | ||
8963 | .channel_mode = alc885_mb5_6ch_modes, | ||
8964 | .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes), | ||
8965 | .input_mux = &mb5_capture_source, | ||
8966 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8967 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8968 | }, | ||
8969 | [ALC885_MACPRO] = { | ||
8970 | .mixers = { alc882_macpro_mixer }, | ||
8971 | .init_verbs = { alc882_macpro_init_verbs }, | ||
8972 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8973 | .dac_nids = alc882_dac_nids, | ||
8974 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8975 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8976 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
8977 | .channel_mode = alc882_ch_modes, | ||
8978 | .input_mux = &alc882_capture_source, | ||
8979 | .init_hook = alc885_macpro_init_hook, | ||
8980 | }, | ||
8981 | [ALC885_IMAC24] = { | ||
8982 | .mixers = { alc885_imac24_mixer }, | ||
8983 | .init_verbs = { alc885_imac24_init_verbs }, | ||
8984 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8985 | .dac_nids = alc882_dac_nids, | ||
8986 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8987 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8988 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
8989 | .channel_mode = alc882_ch_modes, | ||
8990 | .input_mux = &alc882_capture_source, | ||
8991 | .unsol_event = alc_automute_amp_unsol_event, | ||
8992 | .setup = alc885_imac24_setup, | ||
8993 | .init_hook = alc885_imac24_init_hook, | ||
8994 | }, | ||
8995 | [ALC882_TARGA] = { | ||
8996 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, | ||
8997 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
8998 | alc880_gpio3_init_verbs, alc882_targa_verbs}, | ||
8999 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9000 | .dac_nids = alc882_dac_nids, | ||
9001 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9002 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
9003 | .adc_nids = alc882_adc_nids, | ||
9004 | .capsrc_nids = alc882_capsrc_nids, | ||
9005 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
9006 | .channel_mode = alc882_3ST_6ch_modes, | ||
9007 | .need_dac_fix = 1, | ||
9008 | .input_mux = &alc882_capture_source, | ||
9009 | .unsol_event = alc882_targa_unsol_event, | ||
9010 | .setup = alc882_targa_setup, | ||
9011 | .init_hook = alc882_targa_automute, | ||
9012 | }, | ||
9013 | [ALC882_ASUS_A7J] = { | ||
9014 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, | ||
9015 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
9016 | alc882_asus_a7j_verbs}, | ||
9017 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9018 | .dac_nids = alc882_dac_nids, | ||
9019 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9020 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
9021 | .adc_nids = alc882_adc_nids, | ||
9022 | .capsrc_nids = alc882_capsrc_nids, | ||
9023 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
9024 | .channel_mode = alc882_3ST_6ch_modes, | ||
9025 | .need_dac_fix = 1, | ||
9026 | .input_mux = &alc882_capture_source, | ||
9027 | }, | ||
9028 | [ALC882_ASUS_A7M] = { | ||
9029 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | ||
9030 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
9031 | alc882_eapd_verbs, alc880_gpio1_init_verbs, | ||
9032 | alc882_asus_a7m_verbs }, | ||
9033 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9034 | .dac_nids = alc882_dac_nids, | ||
9035 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9036 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
9037 | .channel_mode = alc880_threestack_modes, | ||
9038 | .need_dac_fix = 1, | ||
9039 | .input_mux = &alc882_capture_source, | ||
9040 | }, | ||
9186 | [ALC883_3ST_2ch_DIG] = { | 9041 | [ALC883_3ST_2ch_DIG] = { |
9187 | .mixers = { alc883_3ST_2ch_mixer }, | 9042 | .mixers = { alc883_3ST_2ch_mixer }, |
9188 | .init_verbs = { alc883_init_verbs }, | 9043 | .init_verbs = { alc883_init_verbs }, |
@@ -9229,6 +9084,46 @@ static struct alc_config_preset alc883_presets[] = { | |||
9229 | .need_dac_fix = 1, | 9084 | .need_dac_fix = 1, |
9230 | .input_mux = &alc883_3stack_6ch_intel, | 9085 | .input_mux = &alc883_3stack_6ch_intel, |
9231 | }, | 9086 | }, |
9087 | [ALC889A_INTEL] = { | ||
9088 | .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer }, | ||
9089 | .init_verbs = { alc885_init_verbs, alc885_init_input_verbs, | ||
9090 | alc_hp15_unsol_verbs }, | ||
9091 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9092 | .dac_nids = alc883_dac_nids, | ||
9093 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | ||
9094 | .adc_nids = alc889_adc_nids, | ||
9095 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9096 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9097 | .slave_dig_outs = alc883_slave_dig_outs, | ||
9098 | .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes), | ||
9099 | .channel_mode = alc889_8ch_intel_modes, | ||
9100 | .capsrc_nids = alc889_capsrc_nids, | ||
9101 | .input_mux = &alc889_capture_source, | ||
9102 | .setup = alc889_automute_setup, | ||
9103 | .init_hook = alc_automute_amp, | ||
9104 | .unsol_event = alc_automute_amp_unsol_event, | ||
9105 | .need_dac_fix = 1, | ||
9106 | }, | ||
9107 | [ALC889_INTEL] = { | ||
9108 | .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer }, | ||
9109 | .init_verbs = { alc885_init_verbs, alc889_init_input_verbs, | ||
9110 | alc889_eapd_verbs, alc_hp15_unsol_verbs}, | ||
9111 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9112 | .dac_nids = alc883_dac_nids, | ||
9113 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | ||
9114 | .adc_nids = alc889_adc_nids, | ||
9115 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9116 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9117 | .slave_dig_outs = alc883_slave_dig_outs, | ||
9118 | .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes), | ||
9119 | .channel_mode = alc889_8ch_intel_modes, | ||
9120 | .capsrc_nids = alc889_capsrc_nids, | ||
9121 | .input_mux = &alc889_capture_source, | ||
9122 | .setup = alc889_automute_setup, | ||
9123 | .init_hook = alc889_intel_init_hook, | ||
9124 | .unsol_event = alc_automute_amp_unsol_event, | ||
9125 | .need_dac_fix = 1, | ||
9126 | }, | ||
9232 | [ALC883_6ST_DIG] = { | 9127 | [ALC883_6ST_DIG] = { |
9233 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9128 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
9234 | .init_verbs = { alc883_init_verbs }, | 9129 | .init_verbs = { alc883_init_verbs }, |
@@ -9252,7 +9147,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9252 | .need_dac_fix = 1, | 9147 | .need_dac_fix = 1, |
9253 | .input_mux = &alc883_capture_source, | 9148 | .input_mux = &alc883_capture_source, |
9254 | .unsol_event = alc883_targa_unsol_event, | 9149 | .unsol_event = alc883_targa_unsol_event, |
9255 | .init_hook = alc883_targa_init_hook, | 9150 | .setup = alc882_targa_setup, |
9151 | .init_hook = alc882_targa_automute, | ||
9256 | }, | 9152 | }, |
9257 | [ALC883_TARGA_2ch_DIG] = { | 9153 | [ALC883_TARGA_2ch_DIG] = { |
9258 | .mixers = { alc883_targa_2ch_mixer}, | 9154 | .mixers = { alc883_targa_2ch_mixer}, |
@@ -9267,7 +9163,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9267 | .channel_mode = alc883_3ST_2ch_modes, | 9163 | .channel_mode = alc883_3ST_2ch_modes, |
9268 | .input_mux = &alc883_capture_source, | 9164 | .input_mux = &alc883_capture_source, |
9269 | .unsol_event = alc883_targa_unsol_event, | 9165 | .unsol_event = alc883_targa_unsol_event, |
9270 | .init_hook = alc883_targa_init_hook, | 9166 | .setup = alc882_targa_setup, |
9167 | .init_hook = alc882_targa_automute, | ||
9271 | }, | 9168 | }, |
9272 | [ALC883_TARGA_8ch_DIG] = { | 9169 | [ALC883_TARGA_8ch_DIG] = { |
9273 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9170 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
@@ -9285,7 +9182,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9285 | .need_dac_fix = 1, | 9182 | .need_dac_fix = 1, |
9286 | .input_mux = &alc883_capture_source, | 9183 | .input_mux = &alc883_capture_source, |
9287 | .unsol_event = alc883_targa_unsol_event, | 9184 | .unsol_event = alc883_targa_unsol_event, |
9288 | .init_hook = alc883_targa_init_hook, | 9185 | .setup = alc882_targa_setup, |
9186 | .init_hook = alc882_targa_automute, | ||
9289 | }, | 9187 | }, |
9290 | [ALC883_ACER] = { | 9188 | [ALC883_ACER] = { |
9291 | .mixers = { alc883_base_mixer }, | 9189 | .mixers = { alc883_base_mixer }, |
@@ -9311,7 +9209,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9311 | .channel_mode = alc883_3ST_2ch_modes, | 9209 | .channel_mode = alc883_3ST_2ch_modes, |
9312 | .input_mux = &alc883_capture_source, | 9210 | .input_mux = &alc883_capture_source, |
9313 | .unsol_event = alc_automute_amp_unsol_event, | 9211 | .unsol_event = alc_automute_amp_unsol_event, |
9314 | .init_hook = alc883_acer_aspire_init_hook, | 9212 | .setup = alc883_acer_aspire_setup, |
9213 | .init_hook = alc_automute_amp, | ||
9315 | }, | 9214 | }, |
9316 | [ALC888_ACER_ASPIRE_4930G] = { | 9215 | [ALC888_ACER_ASPIRE_4930G] = { |
9317 | .mixers = { alc888_base_mixer, | 9216 | .mixers = { alc888_base_mixer, |
@@ -9331,7 +9230,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9331 | ARRAY_SIZE(alc888_2_capture_sources), | 9230 | ARRAY_SIZE(alc888_2_capture_sources), |
9332 | .input_mux = alc888_2_capture_sources, | 9231 | .input_mux = alc888_2_capture_sources, |
9333 | .unsol_event = alc_automute_amp_unsol_event, | 9232 | .unsol_event = alc_automute_amp_unsol_event, |
9334 | .init_hook = alc888_acer_aspire_4930g_init_hook, | 9233 | .setup = alc888_acer_aspire_4930g_setup, |
9234 | .init_hook = alc_automute_amp, | ||
9335 | }, | 9235 | }, |
9336 | [ALC888_ACER_ASPIRE_6530G] = { | 9236 | [ALC888_ACER_ASPIRE_6530G] = { |
9337 | .mixers = { alc888_acer_aspire_6530_mixer }, | 9237 | .mixers = { alc888_acer_aspire_6530_mixer }, |
@@ -9349,7 +9249,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9349 | ARRAY_SIZE(alc888_2_capture_sources), | 9249 | ARRAY_SIZE(alc888_2_capture_sources), |
9350 | .input_mux = alc888_acer_aspire_6530_sources, | 9250 | .input_mux = alc888_acer_aspire_6530_sources, |
9351 | .unsol_event = alc_automute_amp_unsol_event, | 9251 | .unsol_event = alc_automute_amp_unsol_event, |
9352 | .init_hook = alc888_acer_aspire_6530g_init_hook, | 9252 | .setup = alc888_acer_aspire_6530g_setup, |
9253 | .init_hook = alc_automute_amp, | ||
9353 | }, | 9254 | }, |
9354 | [ALC888_ACER_ASPIRE_8930G] = { | 9255 | [ALC888_ACER_ASPIRE_8930G] = { |
9355 | .mixers = { alc888_base_mixer, | 9256 | .mixers = { alc888_base_mixer, |
@@ -9370,7 +9271,28 @@ static struct alc_config_preset alc883_presets[] = { | |||
9370 | ARRAY_SIZE(alc889_capture_sources), | 9271 | ARRAY_SIZE(alc889_capture_sources), |
9371 | .input_mux = alc889_capture_sources, | 9272 | .input_mux = alc889_capture_sources, |
9372 | .unsol_event = alc_automute_amp_unsol_event, | 9273 | .unsol_event = alc_automute_amp_unsol_event, |
9373 | .init_hook = alc889_acer_aspire_8930g_init_hook, | 9274 | .setup = alc889_acer_aspire_8930g_setup, |
9275 | .init_hook = alc_automute_amp, | ||
9276 | }, | ||
9277 | [ALC888_ACER_ASPIRE_7730G] = { | ||
9278 | .mixers = { alc883_3ST_6ch_mixer, | ||
9279 | alc883_chmode_mixer }, | ||
9280 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | ||
9281 | alc888_acer_aspire_7730G_verbs }, | ||
9282 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9283 | .dac_nids = alc883_dac_nids, | ||
9284 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | ||
9285 | .adc_nids = alc883_adc_nids_rev, | ||
9286 | .capsrc_nids = alc883_capsrc_nids_rev, | ||
9287 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9288 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | ||
9289 | .channel_mode = alc883_3ST_6ch_modes, | ||
9290 | .need_dac_fix = 1, | ||
9291 | .const_channel_count = 6, | ||
9292 | .input_mux = &alc883_capture_source, | ||
9293 | .unsol_event = alc_automute_amp_unsol_event, | ||
9294 | .setup = alc888_acer_aspire_6530g_setup, | ||
9295 | .init_hook = alc_automute_amp, | ||
9374 | }, | 9296 | }, |
9375 | [ALC883_MEDION] = { | 9297 | [ALC883_MEDION] = { |
9376 | .mixers = { alc883_fivestack_mixer, | 9298 | .mixers = { alc883_fivestack_mixer, |
@@ -9395,7 +9317,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9395 | .channel_mode = alc883_3ST_2ch_modes, | 9317 | .channel_mode = alc883_3ST_2ch_modes, |
9396 | .input_mux = &alc883_capture_source, | 9318 | .input_mux = &alc883_capture_source, |
9397 | .unsol_event = alc_automute_amp_unsol_event, | 9319 | .unsol_event = alc_automute_amp_unsol_event, |
9398 | .init_hook = alc883_medion_md2_init_hook, | 9320 | .setup = alc883_medion_md2_setup, |
9321 | .init_hook = alc_automute_amp, | ||
9399 | }, | 9322 | }, |
9400 | [ALC883_LAPTOP_EAPD] = { | 9323 | [ALC883_LAPTOP_EAPD] = { |
9401 | .mixers = { alc883_base_mixer }, | 9324 | .mixers = { alc883_base_mixer }, |
@@ -9406,6 +9329,21 @@ static struct alc_config_preset alc883_presets[] = { | |||
9406 | .channel_mode = alc883_3ST_2ch_modes, | 9329 | .channel_mode = alc883_3ST_2ch_modes, |
9407 | .input_mux = &alc883_capture_source, | 9330 | .input_mux = &alc883_capture_source, |
9408 | }, | 9331 | }, |
9332 | [ALC883_CLEVO_M540R] = { | ||
9333 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | ||
9334 | .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs }, | ||
9335 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9336 | .dac_nids = alc883_dac_nids, | ||
9337 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9338 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9339 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes), | ||
9340 | .channel_mode = alc883_3ST_6ch_clevo_modes, | ||
9341 | .need_dac_fix = 1, | ||
9342 | .input_mux = &alc883_capture_source, | ||
9343 | /* This machine has the hardware HP auto-muting, thus | ||
9344 | * we need no software mute via unsol event | ||
9345 | */ | ||
9346 | }, | ||
9409 | [ALC883_CLEVO_M720] = { | 9347 | [ALC883_CLEVO_M720] = { |
9410 | .mixers = { alc883_clevo_m720_mixer }, | 9348 | .mixers = { alc883_clevo_m720_mixer }, |
9411 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | 9349 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, |
@@ -9416,6 +9354,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
9416 | .channel_mode = alc883_3ST_2ch_modes, | 9354 | .channel_mode = alc883_3ST_2ch_modes, |
9417 | .input_mux = &alc883_capture_source, | 9355 | .input_mux = &alc883_capture_source, |
9418 | .unsol_event = alc883_clevo_m720_unsol_event, | 9356 | .unsol_event = alc883_clevo_m720_unsol_event, |
9357 | .setup = alc883_clevo_m720_setup, | ||
9419 | .init_hook = alc883_clevo_m720_init_hook, | 9358 | .init_hook = alc883_clevo_m720_init_hook, |
9420 | }, | 9359 | }, |
9421 | [ALC883_LENOVO_101E_2ch] = { | 9360 | [ALC883_LENOVO_101E_2ch] = { |
@@ -9441,7 +9380,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9441 | .need_dac_fix = 1, | 9380 | .need_dac_fix = 1, |
9442 | .input_mux = &alc883_lenovo_nb0763_capture_source, | 9381 | .input_mux = &alc883_lenovo_nb0763_capture_source, |
9443 | .unsol_event = alc_automute_amp_unsol_event, | 9382 | .unsol_event = alc_automute_amp_unsol_event, |
9444 | .init_hook = alc883_medion_md2_init_hook, | 9383 | .setup = alc883_medion_md2_setup, |
9384 | .init_hook = alc_automute_amp, | ||
9445 | }, | 9385 | }, |
9446 | [ALC888_LENOVO_MS7195_DIG] = { | 9386 | [ALC888_LENOVO_MS7195_DIG] = { |
9447 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9387 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9466,7 +9406,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9466 | .channel_mode = alc883_3ST_2ch_modes, | 9406 | .channel_mode = alc883_3ST_2ch_modes, |
9467 | .input_mux = &alc883_capture_source, | 9407 | .input_mux = &alc883_capture_source, |
9468 | .unsol_event = alc_automute_amp_unsol_event, | 9408 | .unsol_event = alc_automute_amp_unsol_event, |
9469 | .init_hook = alc883_haier_w66_init_hook, | 9409 | .setup = alc883_haier_w66_setup, |
9410 | .init_hook = alc_automute_amp, | ||
9470 | }, | 9411 | }, |
9471 | [ALC888_3ST_HP] = { | 9412 | [ALC888_3ST_HP] = { |
9472 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9413 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9478,7 +9419,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9478 | .need_dac_fix = 1, | 9419 | .need_dac_fix = 1, |
9479 | .input_mux = &alc883_capture_source, | 9420 | .input_mux = &alc883_capture_source, |
9480 | .unsol_event = alc_automute_amp_unsol_event, | 9421 | .unsol_event = alc_automute_amp_unsol_event, |
9481 | .init_hook = alc888_3st_hp_init_hook, | 9422 | .setup = alc888_3st_hp_setup, |
9423 | .init_hook = alc_automute_amp, | ||
9482 | }, | 9424 | }, |
9483 | [ALC888_6ST_DELL] = { | 9425 | [ALC888_6ST_DELL] = { |
9484 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9426 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
@@ -9491,7 +9433,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9491 | .channel_mode = alc883_sixstack_modes, | 9433 | .channel_mode = alc883_sixstack_modes, |
9492 | .input_mux = &alc883_capture_source, | 9434 | .input_mux = &alc883_capture_source, |
9493 | .unsol_event = alc_automute_amp_unsol_event, | 9435 | .unsol_event = alc_automute_amp_unsol_event, |
9494 | .init_hook = alc888_6st_dell_init_hook, | 9436 | .setup = alc888_6st_dell_setup, |
9437 | .init_hook = alc_automute_amp, | ||
9495 | }, | 9438 | }, |
9496 | [ALC883_MITAC] = { | 9439 | [ALC883_MITAC] = { |
9497 | .mixers = { alc883_mitac_mixer }, | 9440 | .mixers = { alc883_mitac_mixer }, |
@@ -9502,7 +9445,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9502 | .channel_mode = alc883_3ST_2ch_modes, | 9445 | .channel_mode = alc883_3ST_2ch_modes, |
9503 | .input_mux = &alc883_capture_source, | 9446 | .input_mux = &alc883_capture_source, |
9504 | .unsol_event = alc_automute_amp_unsol_event, | 9447 | .unsol_event = alc_automute_amp_unsol_event, |
9505 | .init_hook = alc883_mitac_init_hook, | 9448 | .setup = alc883_mitac_setup, |
9449 | .init_hook = alc_automute_amp, | ||
9506 | }, | 9450 | }, |
9507 | [ALC883_FUJITSU_PI2515] = { | 9451 | [ALC883_FUJITSU_PI2515] = { |
9508 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | 9452 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, |
@@ -9515,7 +9459,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9515 | .channel_mode = alc883_3ST_2ch_modes, | 9459 | .channel_mode = alc883_3ST_2ch_modes, |
9516 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | 9460 | .input_mux = &alc883_fujitsu_pi2515_capture_source, |
9517 | .unsol_event = alc_automute_amp_unsol_event, | 9461 | .unsol_event = alc_automute_amp_unsol_event, |
9518 | .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, | 9462 | .setup = alc883_2ch_fujitsu_pi2515_setup, |
9463 | .init_hook = alc_automute_amp, | ||
9519 | }, | 9464 | }, |
9520 | [ALC888_FUJITSU_XA3530] = { | 9465 | [ALC888_FUJITSU_XA3530] = { |
9521 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | 9466 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, |
@@ -9533,7 +9478,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9533 | ARRAY_SIZE(alc888_2_capture_sources), | 9478 | ARRAY_SIZE(alc888_2_capture_sources), |
9534 | .input_mux = alc888_2_capture_sources, | 9479 | .input_mux = alc888_2_capture_sources, |
9535 | .unsol_event = alc_automute_amp_unsol_event, | 9480 | .unsol_event = alc_automute_amp_unsol_event, |
9536 | .init_hook = alc888_fujitsu_xa3530_init_hook, | 9481 | .setup = alc888_fujitsu_xa3530_setup, |
9482 | .init_hook = alc_automute_amp, | ||
9537 | }, | 9483 | }, |
9538 | [ALC888_LENOVO_SKY] = { | 9484 | [ALC888_LENOVO_SKY] = { |
9539 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | 9485 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, |
@@ -9546,7 +9492,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9546 | .need_dac_fix = 1, | 9492 | .need_dac_fix = 1, |
9547 | .input_mux = &alc883_lenovo_sky_capture_source, | 9493 | .input_mux = &alc883_lenovo_sky_capture_source, |
9548 | .unsol_event = alc_automute_amp_unsol_event, | 9494 | .unsol_event = alc_automute_amp_unsol_event, |
9549 | .init_hook = alc888_lenovo_sky_init_hook, | 9495 | .setup = alc888_lenovo_sky_setup, |
9496 | .init_hook = alc_automute_amp, | ||
9550 | }, | 9497 | }, |
9551 | [ALC888_ASUS_M90V] = { | 9498 | [ALC888_ASUS_M90V] = { |
9552 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9499 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9559,8 +9506,9 @@ static struct alc_config_preset alc883_presets[] = { | |||
9559 | .channel_mode = alc883_3ST_6ch_modes, | 9506 | .channel_mode = alc883_3ST_6ch_modes, |
9560 | .need_dac_fix = 1, | 9507 | .need_dac_fix = 1, |
9561 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | 9508 | .input_mux = &alc883_fujitsu_pi2515_capture_source, |
9562 | .unsol_event = alc883_mode2_unsol_event, | 9509 | .unsol_event = alc_sku_unsol_event, |
9563 | .init_hook = alc883_mode2_inithook, | 9510 | .setup = alc883_mode2_setup, |
9511 | .init_hook = alc_inithook, | ||
9564 | }, | 9512 | }, |
9565 | [ALC888_ASUS_EEE1601] = { | 9513 | [ALC888_ASUS_EEE1601] = { |
9566 | .mixers = { alc883_asus_eee1601_mixer }, | 9514 | .mixers = { alc883_asus_eee1601_mixer }, |
@@ -9613,15 +9561,45 @@ static struct alc_config_preset alc883_presets[] = { | |||
9613 | .channel_mode = alc883_3ST_2ch_modes, | 9561 | .channel_mode = alc883_3ST_2ch_modes, |
9614 | .input_mux = &alc883_capture_source, | 9562 | .input_mux = &alc883_capture_source, |
9615 | .unsol_event = alc_automute_amp_unsol_event, | 9563 | .unsol_event = alc_automute_amp_unsol_event, |
9616 | .init_hook = alc883_vaiott_init_hook, | 9564 | .setup = alc883_vaiott_setup, |
9565 | .init_hook = alc_automute_amp, | ||
9617 | }, | 9566 | }, |
9618 | }; | 9567 | }; |
9619 | 9568 | ||
9620 | 9569 | ||
9621 | /* | 9570 | /* |
9571 | * Pin config fixes | ||
9572 | */ | ||
9573 | enum { | ||
9574 | PINFIX_ABIT_AW9D_MAX | ||
9575 | }; | ||
9576 | |||
9577 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | ||
9578 | { 0x15, 0x01080104 }, /* side */ | ||
9579 | { 0x16, 0x01011012 }, /* rear */ | ||
9580 | { 0x17, 0x01016011 }, /* clfe */ | ||
9581 | { } | ||
9582 | }; | ||
9583 | |||
9584 | static const struct alc_pincfg *alc882_pin_fixes[] = { | ||
9585 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | ||
9586 | }; | ||
9587 | |||
9588 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | ||
9589 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | ||
9590 | {} | ||
9591 | }; | ||
9592 | |||
9593 | /* | ||
9622 | * BIOS auto configuration | 9594 | * BIOS auto configuration |
9623 | */ | 9595 | */ |
9624 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | 9596 | static int alc882_auto_create_input_ctls(struct hda_codec *codec, |
9597 | const struct auto_pin_cfg *cfg) | ||
9598 | { | ||
9599 | return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22); | ||
9600 | } | ||
9601 | |||
9602 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | ||
9625 | hda_nid_t nid, int pin_type, | 9603 | hda_nid_t nid, int pin_type, |
9626 | int dac_idx) | 9604 | int dac_idx) |
9627 | { | 9605 | { |
@@ -9638,7 +9616,7 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |||
9638 | 9616 | ||
9639 | } | 9617 | } |
9640 | 9618 | ||
9641 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | 9619 | static void alc882_auto_init_multi_out(struct hda_codec *codec) |
9642 | { | 9620 | { |
9643 | struct alc_spec *spec = codec->spec; | 9621 | struct alc_spec *spec = codec->spec; |
9644 | int i; | 9622 | int i; |
@@ -9647,12 +9625,12 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec) | |||
9647 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 9625 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
9648 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 9626 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9649 | if (nid) | 9627 | if (nid) |
9650 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, | 9628 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
9651 | i); | 9629 | i); |
9652 | } | 9630 | } |
9653 | } | 9631 | } |
9654 | 9632 | ||
9655 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | 9633 | static void alc882_auto_init_hp_out(struct hda_codec *codec) |
9656 | { | 9634 | { |
9657 | struct alc_spec *spec = codec->spec; | 9635 | struct alc_spec *spec = codec->spec; |
9658 | hda_nid_t pin; | 9636 | hda_nid_t pin; |
@@ -9660,91 +9638,191 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec) | |||
9660 | pin = spec->autocfg.hp_pins[0]; | 9638 | pin = spec->autocfg.hp_pins[0]; |
9661 | if (pin) /* connect to front */ | 9639 | if (pin) /* connect to front */ |
9662 | /* use dac 0 */ | 9640 | /* use dac 0 */ |
9663 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | 9641 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
9664 | pin = spec->autocfg.speaker_pins[0]; | 9642 | pin = spec->autocfg.speaker_pins[0]; |
9665 | if (pin) | 9643 | if (pin) |
9666 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | 9644 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
9667 | } | 9645 | } |
9668 | 9646 | ||
9669 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | 9647 | static void alc882_auto_init_analog_input(struct hda_codec *codec) |
9670 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | ||
9671 | |||
9672 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | ||
9673 | { | 9648 | { |
9674 | struct alc_spec *spec = codec->spec; | 9649 | struct alc_spec *spec = codec->spec; |
9675 | int i; | 9650 | int i; |
9676 | 9651 | ||
9677 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 9652 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
9678 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 9653 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
9679 | if (alc883_is_input_pin(nid)) { | 9654 | if (!nid) |
9680 | alc_set_input_pin(codec, nid, i); | 9655 | continue; |
9681 | if (nid != ALC883_PIN_CD_NID && | 9656 | alc_set_input_pin(codec, nid, i); |
9682 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 9657 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
9658 | snd_hda_codec_write(codec, nid, 0, | ||
9659 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
9660 | AMP_OUT_MUTE); | ||
9661 | } | ||
9662 | } | ||
9663 | |||
9664 | static void alc882_auto_init_input_src(struct hda_codec *codec) | ||
9665 | { | ||
9666 | struct alc_spec *spec = codec->spec; | ||
9667 | int c; | ||
9668 | |||
9669 | for (c = 0; c < spec->num_adc_nids; c++) { | ||
9670 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | ||
9671 | hda_nid_t nid = spec->capsrc_nids[c]; | ||
9672 | unsigned int mux_idx; | ||
9673 | const struct hda_input_mux *imux; | ||
9674 | int conns, mute, idx, item; | ||
9675 | |||
9676 | conns = snd_hda_get_connections(codec, nid, conn_list, | ||
9677 | ARRAY_SIZE(conn_list)); | ||
9678 | if (conns < 0) | ||
9679 | continue; | ||
9680 | mux_idx = c >= spec->num_mux_defs ? 0 : c; | ||
9681 | imux = &spec->input_mux[mux_idx]; | ||
9682 | for (idx = 0; idx < conns; idx++) { | ||
9683 | /* if the current connection is the selected one, | ||
9684 | * unmute it as default - otherwise mute it | ||
9685 | */ | ||
9686 | mute = AMP_IN_MUTE(idx); | ||
9687 | for (item = 0; item < imux->num_items; item++) { | ||
9688 | if (imux->items[item].index == idx) { | ||
9689 | if (spec->cur_mux[c] == item) | ||
9690 | mute = AMP_IN_UNMUTE(idx); | ||
9691 | break; | ||
9692 | } | ||
9693 | } | ||
9694 | /* check if we have a selector or mixer | ||
9695 | * we could check for the widget type instead, but | ||
9696 | * just check for Amp-In presence (in case of mixer | ||
9697 | * without amp-in there is something wrong, this | ||
9698 | * function shouldn't be used or capsrc nid is wrong) | ||
9699 | */ | ||
9700 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | ||
9683 | snd_hda_codec_write(codec, nid, 0, | 9701 | snd_hda_codec_write(codec, nid, 0, |
9684 | AC_VERB_SET_AMP_GAIN_MUTE, | 9702 | AC_VERB_SET_AMP_GAIN_MUTE, |
9685 | AMP_OUT_MUTE); | 9703 | mute); |
9704 | else if (mute != AMP_IN_MUTE(idx)) | ||
9705 | snd_hda_codec_write(codec, nid, 0, | ||
9706 | AC_VERB_SET_CONNECT_SEL, | ||
9707 | idx); | ||
9686 | } | 9708 | } |
9687 | } | 9709 | } |
9688 | } | 9710 | } |
9689 | 9711 | ||
9690 | #define alc883_auto_init_input_src alc882_auto_init_input_src | 9712 | /* add mic boosts if needed */ |
9713 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | ||
9714 | { | ||
9715 | struct alc_spec *spec = codec->spec; | ||
9716 | int err; | ||
9717 | hda_nid_t nid; | ||
9718 | |||
9719 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | ||
9720 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
9721 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
9722 | "Mic Boost", | ||
9723 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
9724 | if (err < 0) | ||
9725 | return err; | ||
9726 | } | ||
9727 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | ||
9728 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
9729 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
9730 | "Front Mic Boost", | ||
9731 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
9732 | if (err < 0) | ||
9733 | return err; | ||
9734 | } | ||
9735 | return 0; | ||
9736 | } | ||
9691 | 9737 | ||
9692 | /* almost identical with ALC880 parser... */ | 9738 | /* almost identical with ALC880 parser... */ |
9693 | static int alc883_parse_auto_config(struct hda_codec *codec) | 9739 | static int alc882_parse_auto_config(struct hda_codec *codec) |
9694 | { | 9740 | { |
9695 | struct alc_spec *spec = codec->spec; | 9741 | struct alc_spec *spec = codec->spec; |
9696 | int err = alc880_parse_auto_config(codec); | 9742 | static hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
9697 | struct auto_pin_cfg *cfg = &spec->autocfg; | 9743 | int i, err; |
9698 | int i; | ||
9699 | 9744 | ||
9745 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | ||
9746 | alc882_ignore); | ||
9700 | if (err < 0) | 9747 | if (err < 0) |
9701 | return err; | 9748 | return err; |
9702 | else if (!err) | 9749 | if (!spec->autocfg.line_outs) |
9703 | return 0; /* no config found */ | 9750 | return 0; /* can't find valid BIOS pin config */ |
9704 | 9751 | ||
9705 | err = alc_auto_add_mic_boost(codec); | 9752 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
9753 | if (err < 0) | ||
9754 | return err; | ||
9755 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | ||
9756 | if (err < 0) | ||
9757 | return err; | ||
9758 | err = alc880_auto_create_extra_out(spec, | ||
9759 | spec->autocfg.speaker_pins[0], | ||
9760 | "Speaker"); | ||
9761 | if (err < 0) | ||
9762 | return err; | ||
9763 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | ||
9764 | "Headphone"); | ||
9765 | if (err < 0) | ||
9766 | return err; | ||
9767 | err = alc882_auto_create_input_ctls(codec, &spec->autocfg); | ||
9706 | if (err < 0) | 9768 | if (err < 0) |
9707 | return err; | 9769 | return err; |
9708 | 9770 | ||
9709 | /* hack - override the init verbs */ | 9771 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
9710 | spec->init_verbs[0] = alc883_auto_init_verbs; | ||
9711 | 9772 | ||
9712 | /* setup input_mux for ALC889 */ | 9773 | /* check multiple SPDIF-out (for recent codecs) */ |
9713 | if (codec->vendor_id == 0x10ec0889) { | 9774 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
9714 | /* digital-mic input pin is excluded in alc880_auto_create..() | 9775 | hda_nid_t dig_nid; |
9715 | * because it's under 0x18 | 9776 | err = snd_hda_get_connections(codec, |
9716 | */ | 9777 | spec->autocfg.dig_out_pins[i], |
9717 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | 9778 | &dig_nid, 1); |
9718 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | 9779 | if (err < 0) |
9719 | struct hda_input_mux *imux = &spec->private_imux[0]; | 9780 | continue; |
9720 | for (i = 1; i < 3; i++) | 9781 | if (!i) |
9721 | memcpy(&spec->private_imux[i], | 9782 | spec->multiout.dig_out_nid = dig_nid; |
9722 | &spec->private_imux[0], | 9783 | else { |
9723 | sizeof(spec->private_imux[0])); | 9784 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
9724 | imux->items[imux->num_items].label = "Int DMic"; | 9785 | spec->slave_dig_outs[i - 1] = dig_nid; |
9725 | imux->items[imux->num_items].index = 0x0b; | 9786 | if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1) |
9726 | imux->num_items++; | 9787 | break; |
9727 | spec->num_mux_defs = 3; | ||
9728 | spec->input_mux = spec->private_imux; | ||
9729 | } | 9788 | } |
9730 | } | 9789 | } |
9790 | if (spec->autocfg.dig_in_pin) | ||
9791 | spec->dig_in_nid = ALC880_DIGIN_NID; | ||
9792 | |||
9793 | if (spec->kctls.list) | ||
9794 | add_mixer(spec, spec->kctls.list); | ||
9795 | |||
9796 | add_verb(spec, alc883_auto_init_verbs); | ||
9797 | /* if ADC 0x07 is available, initialize it, too */ | ||
9798 | if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN) | ||
9799 | add_verb(spec, alc882_adc1_init_verbs); | ||
9800 | |||
9801 | spec->num_mux_defs = 1; | ||
9802 | spec->input_mux = &spec->private_imux[0]; | ||
9803 | |||
9804 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
9805 | |||
9806 | err = alc_auto_add_mic_boost(codec); | ||
9807 | if (err < 0) | ||
9808 | return err; | ||
9731 | 9809 | ||
9732 | return 1; /* config found */ | 9810 | return 1; /* config found */ |
9733 | } | 9811 | } |
9734 | 9812 | ||
9735 | /* additional initialization for auto-configuration model */ | 9813 | /* additional initialization for auto-configuration model */ |
9736 | static void alc883_auto_init(struct hda_codec *codec) | 9814 | static void alc882_auto_init(struct hda_codec *codec) |
9737 | { | 9815 | { |
9738 | struct alc_spec *spec = codec->spec; | 9816 | struct alc_spec *spec = codec->spec; |
9739 | alc883_auto_init_multi_out(codec); | 9817 | alc882_auto_init_multi_out(codec); |
9740 | alc883_auto_init_hp_out(codec); | 9818 | alc882_auto_init_hp_out(codec); |
9741 | alc883_auto_init_analog_input(codec); | 9819 | alc882_auto_init_analog_input(codec); |
9742 | alc883_auto_init_input_src(codec); | 9820 | alc882_auto_init_input_src(codec); |
9743 | if (spec->unsol_event) | 9821 | if (spec->unsol_event) |
9744 | alc_inithook(codec); | 9822 | alc_inithook(codec); |
9745 | } | 9823 | } |
9746 | 9824 | ||
9747 | static int patch_alc883(struct hda_codec *codec) | 9825 | static int patch_alc882(struct hda_codec *codec) |
9748 | { | 9826 | { |
9749 | struct alc_spec *spec; | 9827 | struct alc_spec *spec; |
9750 | int err, board_config; | 9828 | int err, board_config; |
@@ -9755,28 +9833,35 @@ static int patch_alc883(struct hda_codec *codec) | |||
9755 | 9833 | ||
9756 | codec->spec = spec; | 9834 | codec->spec = spec; |
9757 | 9835 | ||
9758 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); | 9836 | switch (codec->vendor_id) { |
9837 | case 0x10ec0882: | ||
9838 | case 0x10ec0885: | ||
9839 | break; | ||
9840 | default: | ||
9841 | /* ALC883 and variants */ | ||
9842 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); | ||
9843 | break; | ||
9844 | } | ||
9759 | 9845 | ||
9760 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, | 9846 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
9761 | alc883_models, | 9847 | alc882_models, |
9762 | alc883_cfg_tbl); | 9848 | alc882_cfg_tbl); |
9763 | if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { | 9849 | |
9764 | /* Pick up systems that don't supply PCI SSID */ | 9850 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) |
9765 | switch (codec->subsystem_id) { | 9851 | board_config = snd_hda_check_board_codec_sid_config(codec, |
9766 | case 0x106b3600: /* Macbook 3.1 */ | 9852 | ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl); |
9767 | board_config = ALC889A_MB31; | 9853 | |
9768 | break; | 9854 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { |
9769 | default: | 9855 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
9770 | printk(KERN_INFO | 9856 | codec->chip_name); |
9771 | "hda_codec: Unknown model for %s, trying " | 9857 | board_config = ALC882_AUTO; |
9772 | "auto-probe from BIOS...\n", codec->chip_name); | ||
9773 | board_config = ALC883_AUTO; | ||
9774 | } | ||
9775 | } | 9858 | } |
9776 | 9859 | ||
9777 | if (board_config == ALC883_AUTO) { | 9860 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
9861 | |||
9862 | if (board_config == ALC882_AUTO) { | ||
9778 | /* automatic parse from the BIOS config */ | 9863 | /* automatic parse from the BIOS config */ |
9779 | err = alc883_parse_auto_config(codec); | 9864 | err = alc882_parse_auto_config(codec); |
9780 | if (err < 0) { | 9865 | if (err < 0) { |
9781 | alc_free(codec); | 9866 | alc_free(codec); |
9782 | return err; | 9867 | return err; |
@@ -9784,7 +9869,7 @@ static int patch_alc883(struct hda_codec *codec) | |||
9784 | printk(KERN_INFO | 9869 | printk(KERN_INFO |
9785 | "hda_codec: Cannot set up configuration " | 9870 | "hda_codec: Cannot set up configuration " |
9786 | "from BIOS. Using base mode...\n"); | 9871 | "from BIOS. Using base mode...\n"); |
9787 | board_config = ALC883_3ST_2ch_DIG; | 9872 | board_config = ALC882_3ST_DIG; |
9788 | } | 9873 | } |
9789 | } | 9874 | } |
9790 | 9875 | ||
@@ -9794,63 +9879,61 @@ static int patch_alc883(struct hda_codec *codec) | |||
9794 | return err; | 9879 | return err; |
9795 | } | 9880 | } |
9796 | 9881 | ||
9797 | if (board_config != ALC883_AUTO) | 9882 | if (board_config != ALC882_AUTO) |
9798 | setup_preset(spec, &alc883_presets[board_config]); | 9883 | setup_preset(codec, &alc882_presets[board_config]); |
9799 | 9884 | ||
9800 | switch (codec->vendor_id) { | 9885 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
9801 | case 0x10ec0888: | 9886 | spec->stream_analog_capture = &alc882_pcm_analog_capture; |
9802 | if (!spec->num_adc_nids) { | 9887 | /* FIXME: setup DAC5 */ |
9803 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | 9888 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ |
9804 | spec->adc_nids = alc883_adc_nids; | 9889 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
9805 | } | 9890 | |
9806 | if (!spec->capsrc_nids) | 9891 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
9807 | spec->capsrc_nids = alc883_capsrc_nids; | 9892 | spec->stream_digital_capture = &alc882_pcm_digital_capture; |
9893 | |||
9894 | if (codec->vendor_id == 0x10ec0888) | ||
9808 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ | 9895 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ |
9809 | break; | 9896 | |
9810 | case 0x10ec0889: | 9897 | if (!spec->adc_nids && spec->input_mux) { |
9811 | if (!spec->num_adc_nids) { | 9898 | int i; |
9812 | spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); | 9899 | spec->num_adc_nids = 0; |
9813 | spec->adc_nids = alc889_adc_nids; | 9900 | for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) { |
9814 | } | 9901 | hda_nid_t cap; |
9815 | if (!spec->capsrc_nids) | 9902 | hda_nid_t nid = alc882_adc_nids[i]; |
9816 | spec->capsrc_nids = alc889_capsrc_nids; | 9903 | unsigned int wcap = get_wcaps(codec, nid); |
9817 | break; | 9904 | /* get type */ |
9818 | default: | 9905 | wcap = get_wcaps_type(wcap); |
9819 | if (!spec->num_adc_nids) { | 9906 | if (wcap != AC_WID_AUD_IN) |
9820 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | 9907 | continue; |
9821 | spec->adc_nids = alc883_adc_nids; | 9908 | spec->private_adc_nids[spec->num_adc_nids] = nid; |
9909 | err = snd_hda_get_connections(codec, nid, &cap, 1); | ||
9910 | if (err < 0) | ||
9911 | continue; | ||
9912 | spec->private_capsrc_nids[spec->num_adc_nids] = cap; | ||
9913 | spec->num_adc_nids++; | ||
9822 | } | 9914 | } |
9823 | if (!spec->capsrc_nids) | 9915 | spec->adc_nids = spec->private_adc_nids; |
9824 | spec->capsrc_nids = alc883_capsrc_nids; | 9916 | spec->capsrc_nids = spec->private_capsrc_nids; |
9825 | break; | ||
9826 | } | 9917 | } |
9827 | 9918 | ||
9828 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | 9919 | set_capture_mixer(codec); |
9829 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | ||
9830 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; | ||
9831 | |||
9832 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | ||
9833 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | ||
9834 | |||
9835 | if (!spec->cap_mixer) | ||
9836 | set_capture_mixer(spec); | ||
9837 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 9920 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
9838 | 9921 | ||
9839 | spec->vmaster_nid = 0x0c; | 9922 | spec->vmaster_nid = 0x0c; |
9840 | 9923 | ||
9841 | codec->patch_ops = alc_patch_ops; | 9924 | codec->patch_ops = alc_patch_ops; |
9842 | if (board_config == ALC883_AUTO) | 9925 | if (board_config == ALC882_AUTO) |
9843 | spec->init_hook = alc883_auto_init; | 9926 | spec->init_hook = alc882_auto_init; |
9844 | |||
9845 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 9927 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9846 | if (!spec->loopback.amplist) | 9928 | if (!spec->loopback.amplist) |
9847 | spec->loopback.amplist = alc883_loopbacks; | 9929 | spec->loopback.amplist = alc882_loopbacks; |
9848 | #endif | 9930 | #endif |
9849 | codec->proc_widget_hook = print_realtek_coef; | 9931 | codec->proc_widget_hook = print_realtek_coef; |
9850 | 9932 | ||
9851 | return 0; | 9933 | return 0; |
9852 | } | 9934 | } |
9853 | 9935 | ||
9936 | |||
9854 | /* | 9937 | /* |
9855 | * ALC262 support | 9938 | * ALC262 support |
9856 | */ | 9939 | */ |
@@ -10026,13 +10109,12 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |||
10026 | }; | 10109 | }; |
10027 | 10110 | ||
10028 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 10111 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10029 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | 10112 | static void alc262_hp_t5735_setup(struct hda_codec *codec) |
10030 | { | 10113 | { |
10031 | struct alc_spec *spec = codec->spec; | 10114 | struct alc_spec *spec = codec->spec; |
10032 | 10115 | ||
10033 | spec->autocfg.hp_pins[0] = 0x15; | 10116 | spec->autocfg.hp_pins[0] = 0x15; |
10034 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ | 10117 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ |
10035 | alc_automute_amp(codec); | ||
10036 | } | 10118 | } |
10037 | 10119 | ||
10038 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | 10120 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { |
@@ -10189,22 +10271,20 @@ static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res) | |||
10189 | alc262_hippo_automute(codec); | 10271 | alc262_hippo_automute(codec); |
10190 | } | 10272 | } |
10191 | 10273 | ||
10192 | static void alc262_hippo_init_hook(struct hda_codec *codec) | 10274 | static void alc262_hippo_setup(struct hda_codec *codec) |
10193 | { | 10275 | { |
10194 | struct alc_spec *spec = codec->spec; | 10276 | struct alc_spec *spec = codec->spec; |
10195 | 10277 | ||
10196 | spec->autocfg.hp_pins[0] = 0x15; | 10278 | spec->autocfg.hp_pins[0] = 0x15; |
10197 | spec->autocfg.speaker_pins[0] = 0x14; | 10279 | spec->autocfg.speaker_pins[0] = 0x14; |
10198 | alc262_hippo_automute(codec); | ||
10199 | } | 10280 | } |
10200 | 10281 | ||
10201 | static void alc262_hippo1_init_hook(struct hda_codec *codec) | 10282 | static void alc262_hippo1_setup(struct hda_codec *codec) |
10202 | { | 10283 | { |
10203 | struct alc_spec *spec = codec->spec; | 10284 | struct alc_spec *spec = codec->spec; |
10204 | 10285 | ||
10205 | spec->autocfg.hp_pins[0] = 0x1b; | 10286 | spec->autocfg.hp_pins[0] = 0x1b; |
10206 | spec->autocfg.speaker_pins[0] = 0x14; | 10287 | spec->autocfg.speaker_pins[0] = 0x14; |
10207 | alc262_hippo_automute(codec); | ||
10208 | } | 10288 | } |
10209 | 10289 | ||
10210 | 10290 | ||
@@ -10261,13 +10341,12 @@ static struct hda_verb alc262_tyan_verbs[] = { | |||
10261 | }; | 10341 | }; |
10262 | 10342 | ||
10263 | /* unsolicited event for HP jack sensing */ | 10343 | /* unsolicited event for HP jack sensing */ |
10264 | static void alc262_tyan_init_hook(struct hda_codec *codec) | 10344 | static void alc262_tyan_setup(struct hda_codec *codec) |
10265 | { | 10345 | { |
10266 | struct alc_spec *spec = codec->spec; | 10346 | struct alc_spec *spec = codec->spec; |
10267 | 10347 | ||
10268 | spec->autocfg.hp_pins[0] = 0x1b; | 10348 | spec->autocfg.hp_pins[0] = 0x1b; |
10269 | spec->autocfg.speaker_pins[0] = 0x15; | 10349 | spec->autocfg.speaker_pins[0] = 0x15; |
10270 | alc_automute_amp(codec); | ||
10271 | } | 10350 | } |
10272 | 10351 | ||
10273 | 10352 | ||
@@ -10359,12 +10438,6 @@ static struct hda_verb alc262_eapd_verbs[] = { | |||
10359 | { } | 10438 | { } |
10360 | }; | 10439 | }; |
10361 | 10440 | ||
10362 | static struct hda_verb alc262_hippo_unsol_verbs[] = { | ||
10363 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
10364 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
10365 | {} | ||
10366 | }; | ||
10367 | |||
10368 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | 10441 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { |
10369 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | 10442 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
10370 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | 10443 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -10385,14 +10458,6 @@ static struct hda_verb alc262_sony_unsol_verbs[] = { | |||
10385 | {} | 10458 | {} |
10386 | }; | 10459 | }; |
10387 | 10460 | ||
10388 | static struct hda_input_mux alc262_dmic_capture_source = { | ||
10389 | .num_items = 2, | ||
10390 | .items = { | ||
10391 | { "Int DMic", 0x9 }, | ||
10392 | { "Mic", 0x0 }, | ||
10393 | }, | ||
10394 | }; | ||
10395 | |||
10396 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | 10461 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { |
10397 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 10462 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
10398 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 10463 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
@@ -10414,35 +10479,17 @@ static struct hda_verb alc262_toshiba_s06_verbs[] = { | |||
10414 | {} | 10479 | {} |
10415 | }; | 10480 | }; |
10416 | 10481 | ||
10417 | static void alc262_dmic_automute(struct hda_codec *codec) | 10482 | static void alc262_toshiba_s06_setup(struct hda_codec *codec) |
10418 | { | ||
10419 | unsigned int present; | ||
10420 | |||
10421 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
10422 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
10423 | snd_hda_codec_write(codec, 0x22, 0, | ||
10424 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | ||
10425 | } | ||
10426 | |||
10427 | |||
10428 | /* unsolicited event for HP jack sensing */ | ||
10429 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | ||
10430 | unsigned int res) | ||
10431 | { | ||
10432 | if ((res >> 26) == ALC880_MIC_EVENT) | ||
10433 | alc262_dmic_automute(codec); | ||
10434 | else | ||
10435 | alc_sku_unsol_event(codec, res); | ||
10436 | } | ||
10437 | |||
10438 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | ||
10439 | { | 10483 | { |
10440 | struct alc_spec *spec = codec->spec; | 10484 | struct alc_spec *spec = codec->spec; |
10441 | 10485 | ||
10442 | spec->autocfg.hp_pins[0] = 0x15; | 10486 | spec->autocfg.hp_pins[0] = 0x15; |
10443 | spec->autocfg.speaker_pins[0] = 0x14; | 10487 | spec->autocfg.speaker_pins[0] = 0x14; |
10444 | alc_automute_pin(codec); | 10488 | spec->ext_mic.pin = 0x18; |
10445 | alc262_dmic_automute(codec); | 10489 | spec->ext_mic.mux_idx = 0; |
10490 | spec->int_mic.pin = 0x12; | ||
10491 | spec->int_mic.mux_idx = 9; | ||
10492 | spec->auto_mic = 1; | ||
10446 | } | 10493 | } |
10447 | 10494 | ||
10448 | /* | 10495 | /* |
@@ -10860,104 +10907,111 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |||
10860 | { } /* end */ | 10907 | { } /* end */ |
10861 | }; | 10908 | }; |
10862 | 10909 | ||
10910 | /* We use two mixers depending on the output pin; 0x16 is a mono output | ||
10911 | * and thus it's bound with a different mixer. | ||
10912 | * This function returns which mixer amp should be used. | ||
10913 | */ | ||
10914 | static int alc262_check_volbit(hda_nid_t nid) | ||
10915 | { | ||
10916 | if (!nid) | ||
10917 | return 0; | ||
10918 | else if (nid == 0x16) | ||
10919 | return 2; | ||
10920 | else | ||
10921 | return 1; | ||
10922 | } | ||
10923 | |||
10924 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
10925 | const char *pfx, int *vbits) | ||
10926 | { | ||
10927 | char name[32]; | ||
10928 | unsigned long val; | ||
10929 | int vbit; | ||
10930 | |||
10931 | vbit = alc262_check_volbit(nid); | ||
10932 | if (!vbit) | ||
10933 | return 0; | ||
10934 | if (*vbits & vbit) /* a volume control for this mixer already there */ | ||
10935 | return 0; | ||
10936 | *vbits |= vbit; | ||
10937 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | ||
10938 | if (vbit == 2) | ||
10939 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | ||
10940 | else | ||
10941 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | ||
10942 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, val); | ||
10943 | } | ||
10944 | |||
10945 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
10946 | const char *pfx) | ||
10947 | { | ||
10948 | char name[32]; | ||
10949 | unsigned long val; | ||
10950 | |||
10951 | if (!nid) | ||
10952 | return 0; | ||
10953 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
10954 | if (nid == 0x16) | ||
10955 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | ||
10956 | else | ||
10957 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | ||
10958 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val); | ||
10959 | } | ||
10960 | |||
10863 | /* add playback controls from the parsed DAC table */ | 10961 | /* add playback controls from the parsed DAC table */ |
10864 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, | 10962 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
10865 | const struct auto_pin_cfg *cfg) | 10963 | const struct auto_pin_cfg *cfg) |
10866 | { | 10964 | { |
10867 | hda_nid_t nid; | 10965 | const char *pfx; |
10966 | int vbits; | ||
10868 | int err; | 10967 | int err; |
10869 | 10968 | ||
10870 | spec->multiout.num_dacs = 1; /* only use one dac */ | 10969 | spec->multiout.num_dacs = 1; /* only use one dac */ |
10871 | spec->multiout.dac_nids = spec->private_dac_nids; | 10970 | spec->multiout.dac_nids = spec->private_dac_nids; |
10872 | spec->multiout.dac_nids[0] = 2; | 10971 | spec->multiout.dac_nids[0] = 2; |
10873 | 10972 | ||
10874 | nid = cfg->line_out_pins[0]; | 10973 | if (!cfg->speaker_pins[0] && !cfg->hp_pins[0]) |
10875 | if (nid) { | 10974 | pfx = "Master"; |
10876 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 10975 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
10877 | "Front Playback Volume", | 10976 | pfx = "Speaker"; |
10878 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | 10977 | else |
10879 | if (err < 0) | 10978 | pfx = "Front"; |
10880 | return err; | 10979 | err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx); |
10881 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 10980 | if (err < 0) |
10882 | "Front Playback Switch", | 10981 | return err; |
10883 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 10982 | err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker"); |
10884 | if (err < 0) | 10983 | if (err < 0) |
10885 | return err; | 10984 | return err; |
10886 | } | 10985 | err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone"); |
10887 | 10986 | if (err < 0) | |
10888 | nid = cfg->speaker_pins[0]; | 10987 | return err; |
10889 | if (nid) { | ||
10890 | if (nid == 0x16) { | ||
10891 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
10892 | "Speaker Playback Volume", | ||
10893 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | ||
10894 | HDA_OUTPUT)); | ||
10895 | if (err < 0) | ||
10896 | return err; | ||
10897 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10898 | "Speaker Playback Switch", | ||
10899 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
10900 | HDA_OUTPUT)); | ||
10901 | if (err < 0) | ||
10902 | return err; | ||
10903 | } else { | ||
10904 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10905 | "Speaker Playback Switch", | ||
10906 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
10907 | HDA_OUTPUT)); | ||
10908 | if (err < 0) | ||
10909 | return err; | ||
10910 | } | ||
10911 | } | ||
10912 | nid = cfg->hp_pins[0]; | ||
10913 | if (nid) { | ||
10914 | /* spec->multiout.hp_nid = 2; */ | ||
10915 | if (nid == 0x16) { | ||
10916 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
10917 | "Headphone Playback Volume", | ||
10918 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | ||
10919 | HDA_OUTPUT)); | ||
10920 | if (err < 0) | ||
10921 | return err; | ||
10922 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10923 | "Headphone Playback Switch", | ||
10924 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
10925 | HDA_OUTPUT)); | ||
10926 | if (err < 0) | ||
10927 | return err; | ||
10928 | } else { | ||
10929 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10930 | "Headphone Playback Switch", | ||
10931 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
10932 | HDA_OUTPUT)); | ||
10933 | if (err < 0) | ||
10934 | return err; | ||
10935 | } | ||
10936 | } | ||
10937 | return 0; | ||
10938 | } | ||
10939 | |||
10940 | static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec, | ||
10941 | const struct auto_pin_cfg *cfg) | ||
10942 | { | ||
10943 | int err; | ||
10944 | 10988 | ||
10945 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | 10989 | vbits = alc262_check_volbit(cfg->line_out_pins[0]) | |
10990 | alc262_check_volbit(cfg->speaker_pins[0]) | | ||
10991 | alc262_check_volbit(cfg->hp_pins[0]); | ||
10992 | if (vbits == 1 || vbits == 2) | ||
10993 | pfx = "Master"; /* only one mixer is used */ | ||
10994 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
10995 | pfx = "Speaker"; | ||
10996 | else | ||
10997 | pfx = "Front"; | ||
10998 | vbits = 0; | ||
10999 | err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits); | ||
11000 | if (err < 0) | ||
11001 | return err; | ||
11002 | err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker", | ||
11003 | &vbits); | ||
11004 | if (err < 0) | ||
11005 | return err; | ||
11006 | err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone", | ||
11007 | &vbits); | ||
10946 | if (err < 0) | 11008 | if (err < 0) |
10947 | return err; | 11009 | return err; |
10948 | /* digital-mic input pin is excluded in alc880_auto_create..() | ||
10949 | * because it's under 0x18 | ||
10950 | */ | ||
10951 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | ||
10952 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | ||
10953 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
10954 | imux->items[imux->num_items].label = "Int Mic"; | ||
10955 | imux->items[imux->num_items].index = 0x09; | ||
10956 | imux->num_items++; | ||
10957 | } | ||
10958 | return 0; | 11010 | return 0; |
10959 | } | 11011 | } |
10960 | 11012 | ||
11013 | #define alc262_auto_create_input_ctls \ | ||
11014 | alc880_auto_create_input_ctls | ||
10961 | 11015 | ||
10962 | /* | 11016 | /* |
10963 | * generic initialization of ADC, input mixers and output mixers | 11017 | * generic initialization of ADC, input mixers and output mixers |
@@ -11275,7 +11329,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec) | |||
11275 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); | 11329 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
11276 | if (err < 0) | 11330 | if (err < 0) |
11277 | return err; | 11331 | return err; |
11278 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | 11332 | err = alc262_auto_create_input_ctls(codec, &spec->autocfg); |
11279 | if (err < 0) | 11333 | if (err < 0) |
11280 | return err; | 11334 | return err; |
11281 | 11335 | ||
@@ -11406,7 +11460,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11406 | }, | 11460 | }, |
11407 | [ALC262_HIPPO] = { | 11461 | [ALC262_HIPPO] = { |
11408 | .mixers = { alc262_hippo_mixer }, | 11462 | .mixers = { alc262_hippo_mixer }, |
11409 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | 11463 | .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs}, |
11410 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11464 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
11411 | .dac_nids = alc262_dac_nids, | 11465 | .dac_nids = alc262_dac_nids, |
11412 | .hp_nid = 0x03, | 11466 | .hp_nid = 0x03, |
@@ -11415,7 +11469,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11415 | .channel_mode = alc262_modes, | 11469 | .channel_mode = alc262_modes, |
11416 | .input_mux = &alc262_capture_source, | 11470 | .input_mux = &alc262_capture_source, |
11417 | .unsol_event = alc262_hippo_unsol_event, | 11471 | .unsol_event = alc262_hippo_unsol_event, |
11418 | .init_hook = alc262_hippo_init_hook, | 11472 | .setup = alc262_hippo_setup, |
11473 | .init_hook = alc262_hippo_automute, | ||
11419 | }, | 11474 | }, |
11420 | [ALC262_HIPPO_1] = { | 11475 | [ALC262_HIPPO_1] = { |
11421 | .mixers = { alc262_hippo1_mixer }, | 11476 | .mixers = { alc262_hippo1_mixer }, |
@@ -11428,7 +11483,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11428 | .channel_mode = alc262_modes, | 11483 | .channel_mode = alc262_modes, |
11429 | .input_mux = &alc262_capture_source, | 11484 | .input_mux = &alc262_capture_source, |
11430 | .unsol_event = alc262_hippo_unsol_event, | 11485 | .unsol_event = alc262_hippo_unsol_event, |
11431 | .init_hook = alc262_hippo1_init_hook, | 11486 | .setup = alc262_hippo1_setup, |
11487 | .init_hook = alc262_hippo_automute, | ||
11432 | }, | 11488 | }, |
11433 | [ALC262_FUJITSU] = { | 11489 | [ALC262_FUJITSU] = { |
11434 | .mixers = { alc262_fujitsu_mixer }, | 11490 | .mixers = { alc262_fujitsu_mixer }, |
@@ -11491,7 +11547,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11491 | .channel_mode = alc262_modes, | 11547 | .channel_mode = alc262_modes, |
11492 | .input_mux = &alc262_capture_source, | 11548 | .input_mux = &alc262_capture_source, |
11493 | .unsol_event = alc_automute_amp_unsol_event, | 11549 | .unsol_event = alc_automute_amp_unsol_event, |
11494 | .init_hook = alc262_hp_t5735_init_hook, | 11550 | .setup = alc262_hp_t5735_setup, |
11551 | .init_hook = alc_automute_amp, | ||
11495 | }, | 11552 | }, |
11496 | [ALC262_HP_RP5700] = { | 11553 | [ALC262_HP_RP5700] = { |
11497 | .mixers = { alc262_hp_rp5700_mixer }, | 11554 | .mixers = { alc262_hp_rp5700_mixer }, |
@@ -11522,11 +11579,13 @@ static struct alc_config_preset alc262_presets[] = { | |||
11522 | .channel_mode = alc262_modes, | 11579 | .channel_mode = alc262_modes, |
11523 | .input_mux = &alc262_capture_source, | 11580 | .input_mux = &alc262_capture_source, |
11524 | .unsol_event = alc262_hippo_unsol_event, | 11581 | .unsol_event = alc262_hippo_unsol_event, |
11525 | .init_hook = alc262_hippo_init_hook, | 11582 | .setup = alc262_hippo_setup, |
11583 | .init_hook = alc262_hippo_automute, | ||
11526 | }, | 11584 | }, |
11527 | [ALC262_BENQ_T31] = { | 11585 | [ALC262_BENQ_T31] = { |
11528 | .mixers = { alc262_benq_t31_mixer }, | 11586 | .mixers = { alc262_benq_t31_mixer }, |
11529 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | 11587 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, |
11588 | alc_hp15_unsol_verbs }, | ||
11530 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11589 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
11531 | .dac_nids = alc262_dac_nids, | 11590 | .dac_nids = alc262_dac_nids, |
11532 | .hp_nid = 0x03, | 11591 | .hp_nid = 0x03, |
@@ -11534,7 +11593,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11534 | .channel_mode = alc262_modes, | 11593 | .channel_mode = alc262_modes, |
11535 | .input_mux = &alc262_capture_source, | 11594 | .input_mux = &alc262_capture_source, |
11536 | .unsol_event = alc262_hippo_unsol_event, | 11595 | .unsol_event = alc262_hippo_unsol_event, |
11537 | .init_hook = alc262_hippo_init_hook, | 11596 | .setup = alc262_hippo_setup, |
11597 | .init_hook = alc262_hippo_automute, | ||
11538 | }, | 11598 | }, |
11539 | [ALC262_ULTRA] = { | 11599 | [ALC262_ULTRA] = { |
11540 | .mixers = { alc262_ultra_mixer }, | 11600 | .mixers = { alc262_ultra_mixer }, |
@@ -11586,9 +11646,9 @@ static struct alc_config_preset alc262_presets[] = { | |||
11586 | .dig_out_nid = ALC262_DIGOUT_NID, | 11646 | .dig_out_nid = ALC262_DIGOUT_NID, |
11587 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11647 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11588 | .channel_mode = alc262_modes, | 11648 | .channel_mode = alc262_modes, |
11589 | .input_mux = &alc262_dmic_capture_source, | 11649 | .unsol_event = alc_sku_unsol_event, |
11590 | .unsol_event = alc262_toshiba_s06_unsol_event, | 11650 | .setup = alc262_toshiba_s06_setup, |
11591 | .init_hook = alc262_toshiba_s06_init_hook, | 11651 | .init_hook = alc_inithook, |
11592 | }, | 11652 | }, |
11593 | [ALC262_TOSHIBA_RX1] = { | 11653 | [ALC262_TOSHIBA_RX1] = { |
11594 | .mixers = { alc262_toshiba_rx1_mixer }, | 11654 | .mixers = { alc262_toshiba_rx1_mixer }, |
@@ -11600,7 +11660,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11600 | .channel_mode = alc262_modes, | 11660 | .channel_mode = alc262_modes, |
11601 | .input_mux = &alc262_capture_source, | 11661 | .input_mux = &alc262_capture_source, |
11602 | .unsol_event = alc262_hippo_unsol_event, | 11662 | .unsol_event = alc262_hippo_unsol_event, |
11603 | .init_hook = alc262_hippo_init_hook, | 11663 | .setup = alc262_hippo_setup, |
11664 | .init_hook = alc262_hippo_automute, | ||
11604 | }, | 11665 | }, |
11605 | [ALC262_TYAN] = { | 11666 | [ALC262_TYAN] = { |
11606 | .mixers = { alc262_tyan_mixer }, | 11667 | .mixers = { alc262_tyan_mixer }, |
@@ -11613,7 +11674,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11613 | .channel_mode = alc262_modes, | 11674 | .channel_mode = alc262_modes, |
11614 | .input_mux = &alc262_capture_source, | 11675 | .input_mux = &alc262_capture_source, |
11615 | .unsol_event = alc_automute_amp_unsol_event, | 11676 | .unsol_event = alc_automute_amp_unsol_event, |
11616 | .init_hook = alc262_tyan_init_hook, | 11677 | .setup = alc262_tyan_setup, |
11678 | .init_hook = alc_automute_amp, | ||
11617 | }, | 11679 | }, |
11618 | }; | 11680 | }; |
11619 | 11681 | ||
@@ -11648,8 +11710,8 @@ static int patch_alc262(struct hda_codec *codec) | |||
11648 | alc262_cfg_tbl); | 11710 | alc262_cfg_tbl); |
11649 | 11711 | ||
11650 | if (board_config < 0) { | 11712 | if (board_config < 0) { |
11651 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 11713 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
11652 | "trying auto-probe from BIOS...\n", codec->chip_name); | 11714 | codec->chip_name); |
11653 | board_config = ALC262_AUTO; | 11715 | board_config = ALC262_AUTO; |
11654 | } | 11716 | } |
11655 | 11717 | ||
@@ -11676,7 +11738,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
11676 | } | 11738 | } |
11677 | 11739 | ||
11678 | if (board_config != ALC262_AUTO) | 11740 | if (board_config != ALC262_AUTO) |
11679 | setup_preset(spec, &alc262_presets[board_config]); | 11741 | setup_preset(codec, &alc262_presets[board_config]); |
11680 | 11742 | ||
11681 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | 11743 | spec->stream_analog_playback = &alc262_pcm_analog_playback; |
11682 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | 11744 | spec->stream_analog_capture = &alc262_pcm_analog_capture; |
@@ -11702,7 +11764,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
11702 | unsigned int wcap = get_wcaps(codec, 0x07); | 11764 | unsigned int wcap = get_wcaps(codec, 0x07); |
11703 | 11765 | ||
11704 | /* get type */ | 11766 | /* get type */ |
11705 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 11767 | wcap = get_wcaps_type(wcap); |
11706 | if (wcap != AC_WID_AUD_IN) { | 11768 | if (wcap != AC_WID_AUD_IN) { |
11707 | spec->adc_nids = alc262_adc_nids_alt; | 11769 | spec->adc_nids = alc262_adc_nids_alt; |
11708 | spec->num_adc_nids = | 11770 | spec->num_adc_nids = |
@@ -11717,7 +11779,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
11717 | } | 11779 | } |
11718 | } | 11780 | } |
11719 | if (!spec->cap_mixer && !spec->no_analog) | 11781 | if (!spec->cap_mixer && !spec->no_analog) |
11720 | set_capture_mixer(spec); | 11782 | set_capture_mixer(codec); |
11721 | if (!spec->no_analog) | 11783 | if (!spec->no_analog) |
11722 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 11784 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
11723 | 11785 | ||
@@ -11809,14 +11871,6 @@ static struct hda_verb alc268_toshiba_verbs[] = { | |||
11809 | { } /* end */ | 11871 | { } /* end */ |
11810 | }; | 11872 | }; |
11811 | 11873 | ||
11812 | static struct hda_input_mux alc268_acer_lc_capture_source = { | ||
11813 | .num_items = 2, | ||
11814 | .items = { | ||
11815 | { "i-Mic", 0x6 }, | ||
11816 | { "E-Mic", 0x0 }, | ||
11817 | }, | ||
11818 | }; | ||
11819 | |||
11820 | /* Acer specific */ | 11874 | /* Acer specific */ |
11821 | /* bind volumes of both NID 0x02 and 0x03 */ | 11875 | /* bind volumes of both NID 0x02 and 0x03 */ |
11822 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { | 11876 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
@@ -11935,7 +11989,8 @@ static struct hda_verb alc268_acer_verbs[] = { | |||
11935 | 11989 | ||
11936 | /* unsolicited event for HP jack sensing */ | 11990 | /* unsolicited event for HP jack sensing */ |
11937 | #define alc268_toshiba_unsol_event alc262_hippo_unsol_event | 11991 | #define alc268_toshiba_unsol_event alc262_hippo_unsol_event |
11938 | #define alc268_toshiba_init_hook alc262_hippo_init_hook | 11992 | #define alc268_toshiba_setup alc262_hippo_setup |
11993 | #define alc268_toshiba_automute alc262_hippo_automute | ||
11939 | 11994 | ||
11940 | static void alc268_acer_unsol_event(struct hda_codec *codec, | 11995 | static void alc268_acer_unsol_event(struct hda_codec *codec, |
11941 | unsigned int res) | 11996 | unsigned int res) |
@@ -11965,30 +12020,33 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |||
11965 | AMP_IN_MUTE(0), bits); | 12020 | AMP_IN_MUTE(0), bits); |
11966 | } | 12021 | } |
11967 | 12022 | ||
11968 | |||
11969 | static void alc268_acer_mic_automute(struct hda_codec *codec) | ||
11970 | { | ||
11971 | unsigned int present; | ||
11972 | |||
11973 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
11974 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
11975 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | ||
11976 | present ? 0x0 : 0x6); | ||
11977 | } | ||
11978 | |||
11979 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | 12023 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, |
11980 | unsigned int res) | 12024 | unsigned int res) |
11981 | { | 12025 | { |
11982 | if ((res >> 26) == ALC880_HP_EVENT) | 12026 | switch (res >> 26) { |
12027 | case ALC880_HP_EVENT: | ||
11983 | alc268_aspire_one_speaker_automute(codec); | 12028 | alc268_aspire_one_speaker_automute(codec); |
11984 | if ((res >> 26) == ALC880_MIC_EVENT) | 12029 | break; |
11985 | alc268_acer_mic_automute(codec); | 12030 | case ALC880_MIC_EVENT: |
12031 | alc_mic_automute(codec); | ||
12032 | break; | ||
12033 | } | ||
12034 | } | ||
12035 | |||
12036 | static void alc268_acer_lc_setup(struct hda_codec *codec) | ||
12037 | { | ||
12038 | struct alc_spec *spec = codec->spec; | ||
12039 | spec->ext_mic.pin = 0x18; | ||
12040 | spec->ext_mic.mux_idx = 0; | ||
12041 | spec->int_mic.pin = 0x12; | ||
12042 | spec->int_mic.mux_idx = 6; | ||
12043 | spec->auto_mic = 1; | ||
11986 | } | 12044 | } |
11987 | 12045 | ||
11988 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | 12046 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) |
11989 | { | 12047 | { |
11990 | alc268_aspire_one_speaker_automute(codec); | 12048 | alc268_aspire_one_speaker_automute(codec); |
11991 | alc268_acer_mic_automute(codec); | 12049 | alc_mic_automute(codec); |
11992 | } | 12050 | } |
11993 | 12051 | ||
11994 | static struct snd_kcontrol_new alc268_dell_mixer[] = { | 12052 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
@@ -12006,17 +12064,22 @@ static struct hda_verb alc268_dell_verbs[] = { | |||
12006 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 12064 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
12007 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 12065 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
12008 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 12066 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
12067 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | ||
12009 | { } | 12068 | { } |
12010 | }; | 12069 | }; |
12011 | 12070 | ||
12012 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 12071 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
12013 | static void alc268_dell_init_hook(struct hda_codec *codec) | 12072 | static void alc268_dell_setup(struct hda_codec *codec) |
12014 | { | 12073 | { |
12015 | struct alc_spec *spec = codec->spec; | 12074 | struct alc_spec *spec = codec->spec; |
12016 | 12075 | ||
12017 | spec->autocfg.hp_pins[0] = 0x15; | 12076 | spec->autocfg.hp_pins[0] = 0x15; |
12018 | spec->autocfg.speaker_pins[0] = 0x14; | 12077 | spec->autocfg.speaker_pins[0] = 0x14; |
12019 | alc_automute_pin(codec); | 12078 | spec->ext_mic.pin = 0x18; |
12079 | spec->ext_mic.mux_idx = 0; | ||
12080 | spec->int_mic.pin = 0x19; | ||
12081 | spec->int_mic.mux_idx = 1; | ||
12082 | spec->auto_mic = 1; | ||
12020 | } | 12083 | } |
12021 | 12084 | ||
12022 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { | 12085 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
@@ -12037,38 +12100,16 @@ static struct hda_verb alc267_quanta_il1_verbs[] = { | |||
12037 | { } | 12100 | { } |
12038 | }; | 12101 | }; |
12039 | 12102 | ||
12040 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | 12103 | static void alc267_quanta_il1_setup(struct hda_codec *codec) |
12041 | { | ||
12042 | unsigned int present; | ||
12043 | |||
12044 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
12045 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
12046 | snd_hda_codec_write(codec, 0x23, 0, | ||
12047 | AC_VERB_SET_CONNECT_SEL, | ||
12048 | present ? 0x00 : 0x01); | ||
12049 | } | ||
12050 | |||
12051 | static void alc267_quanta_il1_init_hook(struct hda_codec *codec) | ||
12052 | { | 12104 | { |
12053 | struct alc_spec *spec = codec->spec; | 12105 | struct alc_spec *spec = codec->spec; |
12054 | |||
12055 | spec->autocfg.hp_pins[0] = 0x15; | 12106 | spec->autocfg.hp_pins[0] = 0x15; |
12056 | spec->autocfg.speaker_pins[0] = 0x14; | 12107 | spec->autocfg.speaker_pins[0] = 0x14; |
12057 | alc_automute_pin(codec); | 12108 | spec->ext_mic.pin = 0x18; |
12058 | alc267_quanta_il1_mic_automute(codec); | 12109 | spec->ext_mic.mux_idx = 0; |
12059 | } | 12110 | spec->int_mic.pin = 0x19; |
12060 | 12111 | spec->int_mic.mux_idx = 1; | |
12061 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | 12112 | spec->auto_mic = 1; |
12062 | unsigned int res) | ||
12063 | { | ||
12064 | switch (res >> 26) { | ||
12065 | case ALC880_MIC_EVENT: | ||
12066 | alc267_quanta_il1_mic_automute(codec); | ||
12067 | break; | ||
12068 | default: | ||
12069 | alc_sku_unsol_event(codec, res); | ||
12070 | break; | ||
12071 | } | ||
12072 | } | 12113 | } |
12073 | 12114 | ||
12074 | /* | 12115 | /* |
@@ -12148,21 +12189,16 @@ static struct hda_verb alc268_volume_init_verbs[] = { | |||
12148 | { } | 12189 | { } |
12149 | }; | 12190 | }; |
12150 | 12191 | ||
12192 | static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = { | ||
12193 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | ||
12194 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | ||
12195 | { } /* end */ | ||
12196 | }; | ||
12197 | |||
12151 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | 12198 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { |
12152 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | 12199 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
12153 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | 12200 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), |
12154 | { | 12201 | _DEFINE_CAPSRC(1), |
12155 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
12156 | /* The multiple "Capture Source" controls confuse alsamixer | ||
12157 | * So call somewhat different.. | ||
12158 | */ | ||
12159 | /* .name = "Capture Source", */ | ||
12160 | .name = "Input Source", | ||
12161 | .count = 1, | ||
12162 | .info = alc_mux_enum_info, | ||
12163 | .get = alc_mux_enum_get, | ||
12164 | .put = alc_mux_enum_put, | ||
12165 | }, | ||
12166 | { } /* end */ | 12202 | { } /* end */ |
12167 | }; | 12203 | }; |
12168 | 12204 | ||
@@ -12171,18 +12207,7 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = { | |||
12171 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | 12207 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), |
12172 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | 12208 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), |
12173 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | 12209 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), |
12174 | { | 12210 | _DEFINE_CAPSRC(2), |
12175 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
12176 | /* The multiple "Capture Source" controls confuse alsamixer | ||
12177 | * So call somewhat different.. | ||
12178 | */ | ||
12179 | /* .name = "Capture Source", */ | ||
12180 | .name = "Input Source", | ||
12181 | .count = 2, | ||
12182 | .info = alc_mux_enum_info, | ||
12183 | .get = alc_mux_enum_get, | ||
12184 | .put = alc_mux_enum_put, | ||
12185 | }, | ||
12186 | { } /* end */ | 12211 | { } /* end */ |
12187 | }; | 12212 | }; |
12188 | 12213 | ||
@@ -12269,26 +12294,38 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12269 | const char *ctlname, int idx) | 12294 | const char *ctlname, int idx) |
12270 | { | 12295 | { |
12271 | char name[32]; | 12296 | char name[32]; |
12297 | hda_nid_t dac; | ||
12272 | int err; | 12298 | int err; |
12273 | 12299 | ||
12274 | sprintf(name, "%s Playback Volume", ctlname); | 12300 | sprintf(name, "%s Playback Volume", ctlname); |
12275 | if (nid == 0x14) { | 12301 | switch (nid) { |
12276 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12302 | case 0x14: |
12277 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | 12303 | case 0x16: |
12278 | HDA_OUTPUT)); | 12304 | dac = 0x02; |
12279 | if (err < 0) | 12305 | break; |
12280 | return err; | 12306 | case 0x15: |
12281 | } else if (nid == 0x15) { | 12307 | dac = 0x03; |
12308 | break; | ||
12309 | default: | ||
12310 | return 0; | ||
12311 | } | ||
12312 | if (spec->multiout.dac_nids[0] != dac && | ||
12313 | spec->multiout.dac_nids[1] != dac) { | ||
12282 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12314 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
12283 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | 12315 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, |
12284 | HDA_OUTPUT)); | 12316 | HDA_OUTPUT)); |
12285 | if (err < 0) | 12317 | if (err < 0) |
12286 | return err; | 12318 | return err; |
12287 | } else | 12319 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
12288 | return -1; | 12320 | } |
12321 | |||
12289 | sprintf(name, "%s Playback Switch", ctlname); | 12322 | sprintf(name, "%s Playback Switch", ctlname); |
12290 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12323 | if (nid != 0x16) |
12324 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
12291 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | 12325 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); |
12326 | else /* mono */ | ||
12327 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
12328 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); | ||
12292 | if (err < 0) | 12329 | if (err < 0) |
12293 | return err; | 12330 | return err; |
12294 | return 0; | 12331 | return 0; |
@@ -12301,14 +12338,19 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12301 | hda_nid_t nid; | 12338 | hda_nid_t nid; |
12302 | int err; | 12339 | int err; |
12303 | 12340 | ||
12304 | spec->multiout.num_dacs = 2; /* only use one dac */ | ||
12305 | spec->multiout.dac_nids = spec->private_dac_nids; | 12341 | spec->multiout.dac_nids = spec->private_dac_nids; |
12306 | spec->multiout.dac_nids[0] = 2; | ||
12307 | spec->multiout.dac_nids[1] = 3; | ||
12308 | 12342 | ||
12309 | nid = cfg->line_out_pins[0]; | 12343 | nid = cfg->line_out_pins[0]; |
12310 | if (nid) | 12344 | if (nid) { |
12311 | alc268_new_analog_output(spec, nid, "Front", 0); | 12345 | const char *name; |
12346 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
12347 | name = "Speaker"; | ||
12348 | else | ||
12349 | name = "Front"; | ||
12350 | err = alc268_new_analog_output(spec, nid, name, 0); | ||
12351 | if (err < 0) | ||
12352 | return err; | ||
12353 | } | ||
12312 | 12354 | ||
12313 | nid = cfg->speaker_pins[0]; | 12355 | nid = cfg->speaker_pins[0]; |
12314 | if (nid == 0x1d) { | 12356 | if (nid == 0x1d) { |
@@ -12317,16 +12359,23 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12317 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | 12359 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
12318 | if (err < 0) | 12360 | if (err < 0) |
12319 | return err; | 12361 | return err; |
12362 | } else { | ||
12363 | err = alc268_new_analog_output(spec, nid, "Speaker", 0); | ||
12364 | if (err < 0) | ||
12365 | return err; | ||
12320 | } | 12366 | } |
12321 | nid = cfg->hp_pins[0]; | 12367 | nid = cfg->hp_pins[0]; |
12322 | if (nid) | 12368 | if (nid) { |
12323 | alc268_new_analog_output(spec, nid, "Headphone", 0); | 12369 | err = alc268_new_analog_output(spec, nid, "Headphone", 0); |
12370 | if (err < 0) | ||
12371 | return err; | ||
12372 | } | ||
12324 | 12373 | ||
12325 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | 12374 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; |
12326 | if (nid == 0x16) { | 12375 | if (nid == 0x16) { |
12327 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 12376 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
12328 | "Mono Playback Switch", | 12377 | "Mono Playback Switch", |
12329 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | 12378 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); |
12330 | if (err < 0) | 12379 | if (err < 0) |
12331 | return err; | 12380 | return err; |
12332 | } | 12381 | } |
@@ -12334,38 +12383,46 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12334 | } | 12383 | } |
12335 | 12384 | ||
12336 | /* create playback/capture controls for input pins */ | 12385 | /* create playback/capture controls for input pins */ |
12337 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | 12386 | static int alc268_auto_create_input_ctls(struct hda_codec *codec, |
12338 | const struct auto_pin_cfg *cfg) | 12387 | const struct auto_pin_cfg *cfg) |
12339 | { | 12388 | { |
12340 | struct hda_input_mux *imux = &spec->private_imux[0]; | 12389 | return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24); |
12341 | int i, idx1; | 12390 | } |
12342 | 12391 | ||
12343 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 12392 | static void alc268_auto_set_output_and_unmute(struct hda_codec *codec, |
12344 | switch(cfg->input_pins[i]) { | 12393 | hda_nid_t nid, int pin_type) |
12345 | case 0x18: | 12394 | { |
12346 | idx1 = 0; /* Mic 1 */ | 12395 | int idx; |
12347 | break; | 12396 | |
12348 | case 0x19: | 12397 | alc_set_pin_output(codec, nid, pin_type); |
12349 | idx1 = 1; /* Mic 2 */ | 12398 | if (nid == 0x14 || nid == 0x16) |
12350 | break; | 12399 | idx = 0; |
12351 | case 0x1a: | 12400 | else |
12352 | idx1 = 2; /* Line In */ | 12401 | idx = 1; |
12353 | break; | 12402 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
12354 | case 0x1c: | 12403 | } |
12355 | idx1 = 3; /* CD */ | 12404 | |
12356 | break; | 12405 | static void alc268_auto_init_multi_out(struct hda_codec *codec) |
12357 | case 0x12: | 12406 | { |
12358 | case 0x13: | 12407 | struct alc_spec *spec = codec->spec; |
12359 | idx1 = 6; /* digital mics */ | 12408 | hda_nid_t nid = spec->autocfg.line_out_pins[0]; |
12360 | break; | 12409 | if (nid) { |
12361 | default: | 12410 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
12362 | continue; | 12411 | alc268_auto_set_output_and_unmute(codec, nid, pin_type); |
12363 | } | ||
12364 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | ||
12365 | imux->items[imux->num_items].index = idx1; | ||
12366 | imux->num_items++; | ||
12367 | } | 12412 | } |
12368 | return 0; | 12413 | } |
12414 | |||
12415 | static void alc268_auto_init_hp_out(struct hda_codec *codec) | ||
12416 | { | ||
12417 | struct alc_spec *spec = codec->spec; | ||
12418 | hda_nid_t pin; | ||
12419 | |||
12420 | pin = spec->autocfg.hp_pins[0]; | ||
12421 | if (pin) | ||
12422 | alc268_auto_set_output_and_unmute(codec, pin, PIN_HP); | ||
12423 | pin = spec->autocfg.speaker_pins[0]; | ||
12424 | if (pin) | ||
12425 | alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT); | ||
12369 | } | 12426 | } |
12370 | 12427 | ||
12371 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | 12428 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) |
@@ -12376,9 +12433,10 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |||
12376 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | 12433 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; |
12377 | unsigned int dac_vol1, dac_vol2; | 12434 | unsigned int dac_vol1, dac_vol2; |
12378 | 12435 | ||
12379 | if (speaker_nid) { | 12436 | if (line_nid == 0x1d || speaker_nid == 0x1d) { |
12380 | snd_hda_codec_write(codec, speaker_nid, 0, | 12437 | snd_hda_codec_write(codec, speaker_nid, 0, |
12381 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | 12438 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
12439 | /* mute mixer inputs from 0x1d */ | ||
12382 | snd_hda_codec_write(codec, 0x0f, 0, | 12440 | snd_hda_codec_write(codec, 0x0f, 0, |
12383 | AC_VERB_SET_AMP_GAIN_MUTE, | 12441 | AC_VERB_SET_AMP_GAIN_MUTE, |
12384 | AMP_IN_UNMUTE(1)); | 12442 | AMP_IN_UNMUTE(1)); |
@@ -12386,6 +12444,7 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |||
12386 | AC_VERB_SET_AMP_GAIN_MUTE, | 12444 | AC_VERB_SET_AMP_GAIN_MUTE, |
12387 | AMP_IN_UNMUTE(1)); | 12445 | AMP_IN_UNMUTE(1)); |
12388 | } else { | 12446 | } else { |
12447 | /* unmute mixer inputs from 0x1d */ | ||
12389 | snd_hda_codec_write(codec, 0x0f, 0, | 12448 | snd_hda_codec_write(codec, 0x0f, 0, |
12390 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | 12449 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); |
12391 | snd_hda_codec_write(codec, 0x10, 0, | 12450 | snd_hda_codec_write(codec, 0x10, 0, |
@@ -12442,7 +12501,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
12442 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | 12501 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); |
12443 | if (err < 0) | 12502 | if (err < 0) |
12444 | return err; | 12503 | return err; |
12445 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | 12504 | err = alc268_auto_create_input_ctls(codec, &spec->autocfg); |
12446 | if (err < 0) | 12505 | if (err < 0) |
12447 | return err; | 12506 | return err; |
12448 | 12507 | ||
@@ -12461,7 +12520,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
12461 | add_mixer(spec, alc268_beep_mixer); | 12520 | add_mixer(spec, alc268_beep_mixer); |
12462 | 12521 | ||
12463 | add_verb(spec, alc268_volume_init_verbs); | 12522 | add_verb(spec, alc268_volume_init_verbs); |
12464 | spec->num_mux_defs = 1; | 12523 | spec->num_mux_defs = 2; |
12465 | spec->input_mux = &spec->private_imux[0]; | 12524 | spec->input_mux = &spec->private_imux[0]; |
12466 | 12525 | ||
12467 | err = alc_auto_add_mic_boost(codec); | 12526 | err = alc_auto_add_mic_boost(codec); |
@@ -12473,8 +12532,6 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
12473 | return 1; | 12532 | return 1; |
12474 | } | 12533 | } |
12475 | 12534 | ||
12476 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | ||
12477 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | ||
12478 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | 12535 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input |
12479 | 12536 | ||
12480 | /* init callback for auto-configuration model -- overriding the default init */ | 12537 | /* init callback for auto-configuration model -- overriding the default init */ |
@@ -12517,12 +12574,13 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { | |||
12517 | ALC268_ACER_ASPIRE_ONE), | 12574 | ALC268_ACER_ASPIRE_ONE), |
12518 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), | 12575 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
12519 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), | 12576 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), |
12577 | /* almost compatible with toshiba but with optional digital outs; | ||
12578 | * auto-probing seems working fine | ||
12579 | */ | ||
12520 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", | 12580 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", |
12521 | ALC268_TOSHIBA), | 12581 | ALC268_AUTO), |
12522 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | 12582 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
12523 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), | 12583 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
12524 | SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05", | ||
12525 | ALC268_TOSHIBA), | ||
12526 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), | 12584 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
12527 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), | 12585 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
12528 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), | 12586 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
@@ -12530,9 +12588,19 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { | |||
12530 | {} | 12588 | {} |
12531 | }; | 12589 | }; |
12532 | 12590 | ||
12591 | /* Toshiba laptops have no unique PCI SSID but only codec SSID */ | ||
12592 | static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = { | ||
12593 | SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO), | ||
12594 | SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO), | ||
12595 | SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05", | ||
12596 | ALC268_TOSHIBA), | ||
12597 | {} | ||
12598 | }; | ||
12599 | |||
12533 | static struct alc_config_preset alc268_presets[] = { | 12600 | static struct alc_config_preset alc268_presets[] = { |
12534 | [ALC267_QUANTA_IL1] = { | 12601 | [ALC267_QUANTA_IL1] = { |
12535 | .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, | 12602 | .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer, |
12603 | alc268_capture_nosrc_mixer }, | ||
12536 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12604 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12537 | alc267_quanta_il1_verbs }, | 12605 | alc267_quanta_il1_verbs }, |
12538 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | 12606 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
@@ -12542,9 +12610,9 @@ static struct alc_config_preset alc268_presets[] = { | |||
12542 | .hp_nid = 0x03, | 12610 | .hp_nid = 0x03, |
12543 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12611 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12544 | .channel_mode = alc268_modes, | 12612 | .channel_mode = alc268_modes, |
12545 | .input_mux = &alc268_capture_source, | 12613 | .unsol_event = alc_sku_unsol_event, |
12546 | .unsol_event = alc267_quanta_il1_unsol_event, | 12614 | .setup = alc267_quanta_il1_setup, |
12547 | .init_hook = alc267_quanta_il1_init_hook, | 12615 | .init_hook = alc_inithook, |
12548 | }, | 12616 | }, |
12549 | [ALC268_3ST] = { | 12617 | [ALC268_3ST] = { |
12550 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 12618 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
@@ -12576,10 +12644,11 @@ static struct alc_config_preset alc268_presets[] = { | |||
12576 | .channel_mode = alc268_modes, | 12644 | .channel_mode = alc268_modes, |
12577 | .input_mux = &alc268_capture_source, | 12645 | .input_mux = &alc268_capture_source, |
12578 | .unsol_event = alc268_toshiba_unsol_event, | 12646 | .unsol_event = alc268_toshiba_unsol_event, |
12579 | .init_hook = alc268_toshiba_init_hook, | 12647 | .setup = alc268_toshiba_setup, |
12648 | .init_hook = alc268_toshiba_automute, | ||
12580 | }, | 12649 | }, |
12581 | [ALC268_ACER] = { | 12650 | [ALC268_ACER] = { |
12582 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, | 12651 | .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer, |
12583 | alc268_beep_mixer }, | 12652 | alc268_beep_mixer }, |
12584 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12653 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12585 | alc268_acer_verbs }, | 12654 | alc268_acer_verbs }, |
@@ -12615,7 +12684,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12615 | [ALC268_ACER_ASPIRE_ONE] = { | 12684 | [ALC268_ACER_ASPIRE_ONE] = { |
12616 | .mixers = { alc268_acer_aspire_one_mixer, | 12685 | .mixers = { alc268_acer_aspire_one_mixer, |
12617 | alc268_beep_mixer, | 12686 | alc268_beep_mixer, |
12618 | alc268_capture_alt_mixer }, | 12687 | alc268_capture_nosrc_mixer }, |
12619 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12688 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12620 | alc268_acer_aspire_one_verbs }, | 12689 | alc268_acer_aspire_one_verbs }, |
12621 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | 12690 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
@@ -12626,22 +12695,26 @@ static struct alc_config_preset alc268_presets[] = { | |||
12626 | .hp_nid = 0x03, | 12695 | .hp_nid = 0x03, |
12627 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12696 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12628 | .channel_mode = alc268_modes, | 12697 | .channel_mode = alc268_modes, |
12629 | .input_mux = &alc268_acer_lc_capture_source, | ||
12630 | .unsol_event = alc268_acer_lc_unsol_event, | 12698 | .unsol_event = alc268_acer_lc_unsol_event, |
12699 | .setup = alc268_acer_lc_setup, | ||
12631 | .init_hook = alc268_acer_lc_init_hook, | 12700 | .init_hook = alc268_acer_lc_init_hook, |
12632 | }, | 12701 | }, |
12633 | [ALC268_DELL] = { | 12702 | [ALC268_DELL] = { |
12634 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, | 12703 | .mixers = { alc268_dell_mixer, alc268_beep_mixer, |
12704 | alc268_capture_nosrc_mixer }, | ||
12635 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12705 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12636 | alc268_dell_verbs }, | 12706 | alc268_dell_verbs }, |
12637 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | 12707 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
12638 | .dac_nids = alc268_dac_nids, | 12708 | .dac_nids = alc268_dac_nids, |
12709 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | ||
12710 | .adc_nids = alc268_adc_nids_alt, | ||
12711 | .capsrc_nids = alc268_capsrc_nids, | ||
12639 | .hp_nid = 0x02, | 12712 | .hp_nid = 0x02, |
12640 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12713 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12641 | .channel_mode = alc268_modes, | 12714 | .channel_mode = alc268_modes, |
12642 | .unsol_event = alc_sku_unsol_event, | 12715 | .unsol_event = alc_sku_unsol_event, |
12643 | .init_hook = alc268_dell_init_hook, | 12716 | .setup = alc268_dell_setup, |
12644 | .input_mux = &alc268_capture_source, | 12717 | .init_hook = alc_inithook, |
12645 | }, | 12718 | }, |
12646 | [ALC268_ZEPTO] = { | 12719 | [ALC268_ZEPTO] = { |
12647 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 12720 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
@@ -12658,8 +12731,8 @@ static struct alc_config_preset alc268_presets[] = { | |||
12658 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12731 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12659 | .channel_mode = alc268_modes, | 12732 | .channel_mode = alc268_modes, |
12660 | .input_mux = &alc268_capture_source, | 12733 | .input_mux = &alc268_capture_source, |
12661 | .unsol_event = alc268_toshiba_unsol_event, | 12734 | .setup = alc268_toshiba_setup, |
12662 | .init_hook = alc268_toshiba_init_hook | 12735 | .init_hook = alc268_toshiba_automute, |
12663 | }, | 12736 | }, |
12664 | #ifdef CONFIG_SND_DEBUG | 12737 | #ifdef CONFIG_SND_DEBUG |
12665 | [ALC268_TEST] = { | 12738 | [ALC268_TEST] = { |
@@ -12696,9 +12769,13 @@ static int patch_alc268(struct hda_codec *codec) | |||
12696 | alc268_models, | 12769 | alc268_models, |
12697 | alc268_cfg_tbl); | 12770 | alc268_cfg_tbl); |
12698 | 12771 | ||
12772 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) | ||
12773 | board_config = snd_hda_check_board_codec_sid_config(codec, | ||
12774 | ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl); | ||
12775 | |||
12699 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | 12776 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { |
12700 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 12777 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
12701 | "trying auto-probe from BIOS...\n", codec->chip_name); | 12778 | codec->chip_name); |
12702 | board_config = ALC268_AUTO; | 12779 | board_config = ALC268_AUTO; |
12703 | } | 12780 | } |
12704 | 12781 | ||
@@ -12717,7 +12794,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
12717 | } | 12794 | } |
12718 | 12795 | ||
12719 | if (board_config != ALC268_AUTO) | 12796 | if (board_config != ALC268_AUTO) |
12720 | setup_preset(spec, &alc268_presets[board_config]); | 12797 | setup_preset(codec, &alc268_presets[board_config]); |
12721 | 12798 | ||
12722 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | 12799 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
12723 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | 12800 | spec->stream_analog_capture = &alc268_pcm_analog_capture; |
@@ -12754,11 +12831,15 @@ static int patch_alc268(struct hda_codec *codec) | |||
12754 | int i; | 12831 | int i; |
12755 | 12832 | ||
12756 | /* get type */ | 12833 | /* get type */ |
12757 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 12834 | wcap = get_wcaps_type(wcap); |
12758 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | 12835 | if (spec->auto_mic || |
12836 | wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | ||
12759 | spec->adc_nids = alc268_adc_nids_alt; | 12837 | spec->adc_nids = alc268_adc_nids_alt; |
12760 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | 12838 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); |
12761 | add_mixer(spec, alc268_capture_alt_mixer); | 12839 | if (spec->auto_mic || spec->input_mux->num_items == 1) |
12840 | add_mixer(spec, alc268_capture_nosrc_mixer); | ||
12841 | else | ||
12842 | add_mixer(spec, alc268_capture_alt_mixer); | ||
12762 | } else { | 12843 | } else { |
12763 | spec->adc_nids = alc268_adc_nids; | 12844 | spec->adc_nids = alc268_adc_nids; |
12764 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | 12845 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); |
@@ -12769,6 +12850,8 @@ static int patch_alc268(struct hda_codec *codec) | |||
12769 | for (i = 0; i < spec->num_adc_nids; i++) | 12850 | for (i = 0; i < spec->num_adc_nids; i++) |
12770 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | 12851 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], |
12771 | 0, AC_VERB_SET_CONNECT_SEL, | 12852 | 0, AC_VERB_SET_CONNECT_SEL, |
12853 | i < spec->num_mux_defs ? | ||
12854 | spec->input_mux[i].items[0].index : | ||
12772 | spec->input_mux->items[0].index); | 12855 | spec->input_mux->items[0].index); |
12773 | } | 12856 | } |
12774 | 12857 | ||
@@ -12803,22 +12886,6 @@ static hda_nid_t alc269_capsrc_nids[1] = { | |||
12803 | * not a mux! | 12886 | * not a mux! |
12804 | */ | 12887 | */ |
12805 | 12888 | ||
12806 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { | ||
12807 | .num_items = 2, | ||
12808 | .items = { | ||
12809 | { "i-Mic", 0x5 }, | ||
12810 | { "e-Mic", 0x0 }, | ||
12811 | }, | ||
12812 | }; | ||
12813 | |||
12814 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | ||
12815 | .num_items = 2, | ||
12816 | .items = { | ||
12817 | { "i-Mic", 0x1 }, | ||
12818 | { "e-Mic", 0x0 }, | ||
12819 | }, | ||
12820 | }; | ||
12821 | |||
12822 | #define alc269_modes alc260_modes | 12889 | #define alc269_modes alc260_modes |
12823 | #define alc269_capture_source alc880_lg_lw_capture_source | 12890 | #define alc269_capture_source alc880_lg_lw_capture_source |
12824 | 12891 | ||
@@ -12980,16 +13047,6 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |||
12980 | AC_VERB_SET_PROC_COEF, 0x480); | 13047 | AC_VERB_SET_PROC_COEF, 0x480); |
12981 | } | 13048 | } |
12982 | 13049 | ||
12983 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) | ||
12984 | { | ||
12985 | unsigned int present; | ||
12986 | |||
12987 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
12988 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
12989 | snd_hda_codec_write(codec, 0x23, 0, | ||
12990 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | ||
12991 | } | ||
12992 | |||
12993 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) | 13050 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) |
12994 | { | 13051 | { |
12995 | unsigned int present_laptop; | 13052 | unsigned int present_laptop; |
@@ -13016,10 +13073,14 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) | |||
13016 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, | 13073 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
13017 | unsigned int res) | 13074 | unsigned int res) |
13018 | { | 13075 | { |
13019 | if ((res >> 26) == ALC880_HP_EVENT) | 13076 | switch (res >> 26) { |
13077 | case ALC880_HP_EVENT: | ||
13020 | alc269_quanta_fl1_speaker_automute(codec); | 13078 | alc269_quanta_fl1_speaker_automute(codec); |
13021 | if ((res >> 26) == ALC880_MIC_EVENT) | 13079 | break; |
13022 | alc269_quanta_fl1_mic_automute(codec); | 13080 | case ALC880_MIC_EVENT: |
13081 | alc_mic_automute(codec); | ||
13082 | break; | ||
13083 | } | ||
13023 | } | 13084 | } |
13024 | 13085 | ||
13025 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, | 13086 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, |
@@ -13031,10 +13092,20 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec, | |||
13031 | alc269_lifebook_mic_autoswitch(codec); | 13092 | alc269_lifebook_mic_autoswitch(codec); |
13032 | } | 13093 | } |
13033 | 13094 | ||
13095 | static void alc269_quanta_fl1_setup(struct hda_codec *codec) | ||
13096 | { | ||
13097 | struct alc_spec *spec = codec->spec; | ||
13098 | spec->ext_mic.pin = 0x18; | ||
13099 | spec->ext_mic.mux_idx = 0; | ||
13100 | spec->int_mic.pin = 0x19; | ||
13101 | spec->int_mic.mux_idx = 1; | ||
13102 | spec->auto_mic = 1; | ||
13103 | } | ||
13104 | |||
13034 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) | 13105 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
13035 | { | 13106 | { |
13036 | alc269_quanta_fl1_speaker_automute(codec); | 13107 | alc269_quanta_fl1_speaker_automute(codec); |
13037 | alc269_quanta_fl1_mic_automute(codec); | 13108 | alc_mic_automute(codec); |
13038 | } | 13109 | } |
13039 | 13110 | ||
13040 | static void alc269_lifebook_init_hook(struct hda_codec *codec) | 13111 | static void alc269_lifebook_init_hook(struct hda_codec *codec) |
@@ -13079,60 +13150,44 @@ static void alc269_speaker_automute(struct hda_codec *codec) | |||
13079 | AMP_IN_MUTE(0), bits); | 13150 | AMP_IN_MUTE(0), bits); |
13080 | } | 13151 | } |
13081 | 13152 | ||
13082 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | ||
13083 | { | ||
13084 | unsigned int present; | ||
13085 | |||
13086 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
13087 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13088 | snd_hda_codec_write(codec, 0x23, 0, | ||
13089 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | ||
13090 | } | ||
13091 | |||
13092 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | ||
13093 | { | ||
13094 | unsigned int present; | ||
13095 | |||
13096 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
13097 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13098 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
13099 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
13100 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
13101 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
13102 | } | ||
13103 | |||
13104 | /* unsolicited event for HP jack sensing */ | 13153 | /* unsolicited event for HP jack sensing */ |
13105 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | 13154 | static void alc269_eeepc_unsol_event(struct hda_codec *codec, |
13106 | unsigned int res) | 13155 | unsigned int res) |
13107 | { | 13156 | { |
13108 | if ((res >> 26) == ALC880_HP_EVENT) | 13157 | switch (res >> 26) { |
13158 | case ALC880_HP_EVENT: | ||
13109 | alc269_speaker_automute(codec); | 13159 | alc269_speaker_automute(codec); |
13110 | 13160 | break; | |
13111 | if ((res >> 26) == ALC880_MIC_EVENT) | 13161 | case ALC880_MIC_EVENT: |
13112 | alc269_eeepc_dmic_automute(codec); | 13162 | alc_mic_automute(codec); |
13163 | break; | ||
13164 | } | ||
13113 | } | 13165 | } |
13114 | 13166 | ||
13115 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | 13167 | static void alc269_eeepc_dmic_setup(struct hda_codec *codec) |
13116 | { | 13168 | { |
13117 | alc269_speaker_automute(codec); | 13169 | struct alc_spec *spec = codec->spec; |
13118 | alc269_eeepc_dmic_automute(codec); | 13170 | spec->ext_mic.pin = 0x18; |
13171 | spec->ext_mic.mux_idx = 0; | ||
13172 | spec->int_mic.pin = 0x12; | ||
13173 | spec->int_mic.mux_idx = 5; | ||
13174 | spec->auto_mic = 1; | ||
13119 | } | 13175 | } |
13120 | 13176 | ||
13121 | /* unsolicited event for HP jack sensing */ | 13177 | static void alc269_eeepc_amic_setup(struct hda_codec *codec) |
13122 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | ||
13123 | unsigned int res) | ||
13124 | { | 13178 | { |
13125 | if ((res >> 26) == ALC880_HP_EVENT) | 13179 | struct alc_spec *spec = codec->spec; |
13126 | alc269_speaker_automute(codec); | 13180 | spec->ext_mic.pin = 0x18; |
13127 | 13181 | spec->ext_mic.mux_idx = 0; | |
13128 | if ((res >> 26) == ALC880_MIC_EVENT) | 13182 | spec->int_mic.pin = 0x19; |
13129 | alc269_eeepc_amic_automute(codec); | 13183 | spec->int_mic.mux_idx = 1; |
13184 | spec->auto_mic = 1; | ||
13130 | } | 13185 | } |
13131 | 13186 | ||
13132 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | 13187 | static void alc269_eeepc_inithook(struct hda_codec *codec) |
13133 | { | 13188 | { |
13134 | alc269_speaker_automute(codec); | 13189 | alc269_speaker_automute(codec); |
13135 | alc269_eeepc_amic_automute(codec); | 13190 | alc_mic_automute(codec); |
13136 | } | 13191 | } |
13137 | 13192 | ||
13138 | /* | 13193 | /* |
@@ -13205,89 +13260,10 @@ static struct hda_verb alc269_init_verbs[] = { | |||
13205 | { } | 13260 | { } |
13206 | }; | 13261 | }; |
13207 | 13262 | ||
13208 | /* add playback controls from the parsed DAC table */ | 13263 | #define alc269_auto_create_multi_out_ctls \ |
13209 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | 13264 | alc268_auto_create_multi_out_ctls |
13210 | const struct auto_pin_cfg *cfg) | 13265 | #define alc269_auto_create_input_ctls \ |
13211 | { | 13266 | alc268_auto_create_input_ctls |
13212 | hda_nid_t nid; | ||
13213 | int err; | ||
13214 | |||
13215 | spec->multiout.num_dacs = 1; /* only use one dac */ | ||
13216 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
13217 | spec->multiout.dac_nids[0] = 2; | ||
13218 | |||
13219 | nid = cfg->line_out_pins[0]; | ||
13220 | if (nid) { | ||
13221 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
13222 | "Front Playback Volume", | ||
13223 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | ||
13224 | if (err < 0) | ||
13225 | return err; | ||
13226 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13227 | "Front Playback Switch", | ||
13228 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | ||
13229 | if (err < 0) | ||
13230 | return err; | ||
13231 | } | ||
13232 | |||
13233 | nid = cfg->speaker_pins[0]; | ||
13234 | if (nid) { | ||
13235 | if (!cfg->line_out_pins[0]) { | ||
13236 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
13237 | "Speaker Playback Volume", | ||
13238 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | ||
13239 | HDA_OUTPUT)); | ||
13240 | if (err < 0) | ||
13241 | return err; | ||
13242 | } | ||
13243 | if (nid == 0x16) { | ||
13244 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13245 | "Speaker Playback Switch", | ||
13246 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
13247 | HDA_OUTPUT)); | ||
13248 | if (err < 0) | ||
13249 | return err; | ||
13250 | } else { | ||
13251 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13252 | "Speaker Playback Switch", | ||
13253 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
13254 | HDA_OUTPUT)); | ||
13255 | if (err < 0) | ||
13256 | return err; | ||
13257 | } | ||
13258 | } | ||
13259 | nid = cfg->hp_pins[0]; | ||
13260 | if (nid) { | ||
13261 | /* spec->multiout.hp_nid = 2; */ | ||
13262 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | ||
13263 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
13264 | "Headphone Playback Volume", | ||
13265 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | ||
13266 | HDA_OUTPUT)); | ||
13267 | if (err < 0) | ||
13268 | return err; | ||
13269 | } | ||
13270 | if (nid == 0x16) { | ||
13271 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13272 | "Headphone Playback Switch", | ||
13273 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
13274 | HDA_OUTPUT)); | ||
13275 | if (err < 0) | ||
13276 | return err; | ||
13277 | } else { | ||
13278 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13279 | "Headphone Playback Switch", | ||
13280 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
13281 | HDA_OUTPUT)); | ||
13282 | if (err < 0) | ||
13283 | return err; | ||
13284 | } | ||
13285 | } | ||
13286 | return 0; | ||
13287 | } | ||
13288 | |||
13289 | #define alc269_auto_create_analog_input_ctls \ | ||
13290 | alc262_auto_create_analog_input_ctls | ||
13291 | 13267 | ||
13292 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 13268 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13293 | #define alc269_loopbacks alc880_loopbacks | 13269 | #define alc269_loopbacks alc880_loopbacks |
@@ -13337,7 +13313,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13337 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | 13313 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); |
13338 | if (err < 0) | 13314 | if (err < 0) |
13339 | return err; | 13315 | return err; |
13340 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | 13316 | err = alc269_auto_create_input_ctls(codec, &spec->autocfg); |
13341 | if (err < 0) | 13317 | if (err < 0) |
13342 | return err; | 13318 | return err; |
13343 | 13319 | ||
@@ -13362,15 +13338,15 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13362 | return err; | 13338 | return err; |
13363 | 13339 | ||
13364 | if (!spec->cap_mixer && !spec->no_analog) | 13340 | if (!spec->cap_mixer && !spec->no_analog) |
13365 | set_capture_mixer(spec); | 13341 | set_capture_mixer(codec); |
13366 | 13342 | ||
13367 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | 13343 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); |
13368 | 13344 | ||
13369 | return 1; | 13345 | return 1; |
13370 | } | 13346 | } |
13371 | 13347 | ||
13372 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | 13348 | #define alc269_auto_init_multi_out alc268_auto_init_multi_out |
13373 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | 13349 | #define alc269_auto_init_hp_out alc268_auto_init_hp_out |
13374 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | 13350 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input |
13375 | 13351 | ||
13376 | 13352 | ||
@@ -13438,6 +13414,7 @@ static struct alc_config_preset alc269_presets[] = { | |||
13438 | .channel_mode = alc269_modes, | 13414 | .channel_mode = alc269_modes, |
13439 | .input_mux = &alc269_capture_source, | 13415 | .input_mux = &alc269_capture_source, |
13440 | .unsol_event = alc269_quanta_fl1_unsol_event, | 13416 | .unsol_event = alc269_quanta_fl1_unsol_event, |
13417 | .setup = alc269_quanta_fl1_setup, | ||
13441 | .init_hook = alc269_quanta_fl1_init_hook, | 13418 | .init_hook = alc269_quanta_fl1_init_hook, |
13442 | }, | 13419 | }, |
13443 | [ALC269_ASUS_EEEPC_P703] = { | 13420 | [ALC269_ASUS_EEEPC_P703] = { |
@@ -13450,9 +13427,9 @@ static struct alc_config_preset alc269_presets[] = { | |||
13450 | .hp_nid = 0x03, | 13427 | .hp_nid = 0x03, |
13451 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 13428 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13452 | .channel_mode = alc269_modes, | 13429 | .channel_mode = alc269_modes, |
13453 | .input_mux = &alc269_eeepc_amic_capture_source, | 13430 | .unsol_event = alc269_eeepc_unsol_event, |
13454 | .unsol_event = alc269_eeepc_amic_unsol_event, | 13431 | .setup = alc269_eeepc_amic_setup, |
13455 | .init_hook = alc269_eeepc_amic_inithook, | 13432 | .init_hook = alc269_eeepc_inithook, |
13456 | }, | 13433 | }, |
13457 | [ALC269_ASUS_EEEPC_P901] = { | 13434 | [ALC269_ASUS_EEEPC_P901] = { |
13458 | .mixers = { alc269_eeepc_mixer }, | 13435 | .mixers = { alc269_eeepc_mixer }, |
@@ -13464,9 +13441,9 @@ static struct alc_config_preset alc269_presets[] = { | |||
13464 | .hp_nid = 0x03, | 13441 | .hp_nid = 0x03, |
13465 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 13442 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13466 | .channel_mode = alc269_modes, | 13443 | .channel_mode = alc269_modes, |
13467 | .input_mux = &alc269_eeepc_dmic_capture_source, | 13444 | .unsol_event = alc269_eeepc_unsol_event, |
13468 | .unsol_event = alc269_eeepc_dmic_unsol_event, | 13445 | .setup = alc269_eeepc_dmic_setup, |
13469 | .init_hook = alc269_eeepc_dmic_inithook, | 13446 | .init_hook = alc269_eeepc_inithook, |
13470 | }, | 13447 | }, |
13471 | [ALC269_FUJITSU] = { | 13448 | [ALC269_FUJITSU] = { |
13472 | .mixers = { alc269_fujitsu_mixer }, | 13449 | .mixers = { alc269_fujitsu_mixer }, |
@@ -13478,9 +13455,9 @@ static struct alc_config_preset alc269_presets[] = { | |||
13478 | .hp_nid = 0x03, | 13455 | .hp_nid = 0x03, |
13479 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 13456 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13480 | .channel_mode = alc269_modes, | 13457 | .channel_mode = alc269_modes, |
13481 | .input_mux = &alc269_eeepc_dmic_capture_source, | 13458 | .unsol_event = alc269_eeepc_unsol_event, |
13482 | .unsol_event = alc269_eeepc_dmic_unsol_event, | 13459 | .setup = alc269_eeepc_dmic_setup, |
13483 | .init_hook = alc269_eeepc_dmic_inithook, | 13460 | .init_hook = alc269_eeepc_inithook, |
13484 | }, | 13461 | }, |
13485 | [ALC269_LIFEBOOK] = { | 13462 | [ALC269_LIFEBOOK] = { |
13486 | .mixers = { alc269_lifebook_mixer }, | 13463 | .mixers = { alc269_lifebook_mixer }, |
@@ -13515,8 +13492,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
13515 | alc269_cfg_tbl); | 13492 | alc269_cfg_tbl); |
13516 | 13493 | ||
13517 | if (board_config < 0) { | 13494 | if (board_config < 0) { |
13518 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 13495 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
13519 | "trying auto-probe from BIOS...\n", codec->chip_name); | 13496 | codec->chip_name); |
13520 | board_config = ALC269_AUTO; | 13497 | board_config = ALC269_AUTO; |
13521 | } | 13498 | } |
13522 | 13499 | ||
@@ -13541,7 +13518,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
13541 | } | 13518 | } |
13542 | 13519 | ||
13543 | if (board_config != ALC269_AUTO) | 13520 | if (board_config != ALC269_AUTO) |
13544 | setup_preset(spec, &alc269_presets[board_config]); | 13521 | setup_preset(codec, &alc269_presets[board_config]); |
13545 | 13522 | ||
13546 | if (codec->subsystem_id == 0x17aa3bf8) { | 13523 | if (codec->subsystem_id == 0x17aa3bf8) { |
13547 | /* Due to a hardware problem on Lenovo Ideadpad, we need to | 13524 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
@@ -13560,7 +13537,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
13560 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | 13537 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); |
13561 | spec->capsrc_nids = alc269_capsrc_nids; | 13538 | spec->capsrc_nids = alc269_capsrc_nids; |
13562 | if (!spec->cap_mixer) | 13539 | if (!spec->cap_mixer) |
13563 | set_capture_mixer(spec); | 13540 | set_capture_mixer(codec); |
13564 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 13541 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
13565 | 13542 | ||
13566 | spec->vmaster_nid = 0x02; | 13543 | spec->vmaster_nid = 0x02; |
@@ -14110,23 +14087,23 @@ static struct hda_verb alc861_auto_init_verbs[] = { | |||
14110 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 14087 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
14111 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | 14088 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, |
14112 | 14089 | ||
14113 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14090 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14114 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14091 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14115 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14092 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14116 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14093 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14117 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14094 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14118 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14095 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14119 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14096 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14120 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14097 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14121 | 14098 | ||
14122 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 14099 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14123 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 14100 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14124 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 14101 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
14125 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | 14102 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
14126 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 14103 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14127 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 14104 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14128 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 14105 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
14129 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | 14106 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
14130 | 14107 | ||
14131 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ | 14108 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
14132 | 14109 | ||
@@ -14198,64 +14175,96 @@ static struct hda_input_mux alc861_capture_source = { | |||
14198 | }, | 14175 | }, |
14199 | }; | 14176 | }; |
14200 | 14177 | ||
14178 | static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin) | ||
14179 | { | ||
14180 | struct alc_spec *spec = codec->spec; | ||
14181 | hda_nid_t mix, srcs[5]; | ||
14182 | int i, j, num; | ||
14183 | |||
14184 | if (snd_hda_get_connections(codec, pin, &mix, 1) != 1) | ||
14185 | return 0; | ||
14186 | num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs)); | ||
14187 | if (num < 0) | ||
14188 | return 0; | ||
14189 | for (i = 0; i < num; i++) { | ||
14190 | unsigned int type; | ||
14191 | type = get_wcaps_type(get_wcaps(codec, srcs[i])); | ||
14192 | if (type != AC_WID_AUD_OUT) | ||
14193 | continue; | ||
14194 | for (j = 0; j < spec->multiout.num_dacs; j++) | ||
14195 | if (spec->multiout.dac_nids[j] == srcs[i]) | ||
14196 | break; | ||
14197 | if (j >= spec->multiout.num_dacs) | ||
14198 | return srcs[i]; | ||
14199 | } | ||
14200 | return 0; | ||
14201 | } | ||
14202 | |||
14201 | /* fill in the dac_nids table from the parsed pin configuration */ | 14203 | /* fill in the dac_nids table from the parsed pin configuration */ |
14202 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, | 14204 | static int alc861_auto_fill_dac_nids(struct hda_codec *codec, |
14203 | const struct auto_pin_cfg *cfg) | 14205 | const struct auto_pin_cfg *cfg) |
14204 | { | 14206 | { |
14207 | struct alc_spec *spec = codec->spec; | ||
14205 | int i; | 14208 | int i; |
14206 | hda_nid_t nid; | 14209 | hda_nid_t nid, dac; |
14207 | 14210 | ||
14208 | spec->multiout.dac_nids = spec->private_dac_nids; | 14211 | spec->multiout.dac_nids = spec->private_dac_nids; |
14209 | for (i = 0; i < cfg->line_outs; i++) { | 14212 | for (i = 0; i < cfg->line_outs; i++) { |
14210 | nid = cfg->line_out_pins[i]; | 14213 | nid = cfg->line_out_pins[i]; |
14211 | if (nid) { | 14214 | dac = alc861_look_for_dac(codec, nid); |
14212 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | 14215 | if (!dac) |
14213 | continue; | 14216 | continue; |
14214 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | 14217 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
14215 | } | ||
14216 | } | 14218 | } |
14217 | spec->multiout.num_dacs = cfg->line_outs; | ||
14218 | return 0; | 14219 | return 0; |
14219 | } | 14220 | } |
14220 | 14221 | ||
14222 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, | ||
14223 | hda_nid_t nid, unsigned int chs) | ||
14224 | { | ||
14225 | char name[32]; | ||
14226 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
14227 | return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name, | ||
14228 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | ||
14229 | } | ||
14230 | |||
14221 | /* add playback controls from the parsed DAC table */ | 14231 | /* add playback controls from the parsed DAC table */ |
14222 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | 14232 | static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec, |
14223 | const struct auto_pin_cfg *cfg) | 14233 | const struct auto_pin_cfg *cfg) |
14224 | { | 14234 | { |
14225 | char name[32]; | 14235 | struct alc_spec *spec = codec->spec; |
14226 | static const char *chname[4] = { | 14236 | static const char *chname[4] = { |
14227 | "Front", "Surround", NULL /*CLFE*/, "Side" | 14237 | "Front", "Surround", NULL /*CLFE*/, "Side" |
14228 | }; | 14238 | }; |
14229 | hda_nid_t nid; | 14239 | hda_nid_t nid; |
14230 | int i, idx, err; | 14240 | int i, err; |
14241 | |||
14242 | if (cfg->line_outs == 1) { | ||
14243 | const char *pfx = NULL; | ||
14244 | if (!cfg->hp_outs) | ||
14245 | pfx = "Master"; | ||
14246 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
14247 | pfx = "Speaker"; | ||
14248 | if (pfx) { | ||
14249 | nid = spec->multiout.dac_nids[0]; | ||
14250 | return alc861_create_out_sw(codec, pfx, nid, 3); | ||
14251 | } | ||
14252 | } | ||
14231 | 14253 | ||
14232 | for (i = 0; i < cfg->line_outs; i++) { | 14254 | for (i = 0; i < cfg->line_outs; i++) { |
14233 | nid = spec->multiout.dac_nids[i]; | 14255 | nid = spec->multiout.dac_nids[i]; |
14234 | if (!nid) | 14256 | if (!nid) |
14235 | continue; | 14257 | continue; |
14236 | if (nid == 0x05) { | 14258 | if (i == 2) { |
14237 | /* Center/LFE */ | 14259 | /* Center/LFE */ |
14238 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 14260 | err = alc861_create_out_sw(codec, "Center", nid, 1); |
14239 | "Center Playback Switch", | ||
14240 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | ||
14241 | HDA_OUTPUT)); | ||
14242 | if (err < 0) | 14261 | if (err < 0) |
14243 | return err; | 14262 | return err; |
14244 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 14263 | err = alc861_create_out_sw(codec, "LFE", nid, 2); |
14245 | "LFE Playback Switch", | ||
14246 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
14247 | HDA_OUTPUT)); | ||
14248 | if (err < 0) | 14264 | if (err < 0) |
14249 | return err; | 14265 | return err; |
14250 | } else { | 14266 | } else { |
14251 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; | 14267 | err = alc861_create_out_sw(codec, chname[i], nid, 3); |
14252 | idx++) | ||
14253 | if (nid == alc861_dac_nids[idx]) | ||
14254 | break; | ||
14255 | sprintf(name, "%s Playback Switch", chname[idx]); | ||
14256 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
14257 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
14258 | HDA_OUTPUT)); | ||
14259 | if (err < 0) | 14268 | if (err < 0) |
14260 | return err; | 14269 | return err; |
14261 | } | 14270 | } |
@@ -14263,8 +14272,9 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
14263 | return 0; | 14272 | return 0; |
14264 | } | 14273 | } |
14265 | 14274 | ||
14266 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | 14275 | static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin) |
14267 | { | 14276 | { |
14277 | struct alc_spec *spec = codec->spec; | ||
14268 | int err; | 14278 | int err; |
14269 | hda_nid_t nid; | 14279 | hda_nid_t nid; |
14270 | 14280 | ||
@@ -14272,70 +14282,49 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |||
14272 | return 0; | 14282 | return 0; |
14273 | 14283 | ||
14274 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | 14284 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { |
14275 | nid = 0x03; | 14285 | nid = alc861_look_for_dac(codec, pin); |
14276 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 14286 | if (nid) { |
14277 | "Headphone Playback Switch", | 14287 | err = alc861_create_out_sw(codec, "Headphone", nid, 3); |
14278 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 14288 | if (err < 0) |
14279 | if (err < 0) | 14289 | return err; |
14280 | return err; | 14290 | spec->multiout.hp_nid = nid; |
14281 | spec->multiout.hp_nid = nid; | 14291 | } |
14282 | } | 14292 | } |
14283 | return 0; | 14293 | return 0; |
14284 | } | 14294 | } |
14285 | 14295 | ||
14286 | /* create playback/capture controls for input pins */ | 14296 | /* create playback/capture controls for input pins */ |
14287 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, | 14297 | static int alc861_auto_create_input_ctls(struct hda_codec *codec, |
14288 | const struct auto_pin_cfg *cfg) | 14298 | const struct auto_pin_cfg *cfg) |
14289 | { | 14299 | { |
14290 | struct hda_input_mux *imux = &spec->private_imux[0]; | 14300 | return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0); |
14291 | int i, err, idx, idx1; | ||
14292 | |||
14293 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
14294 | switch (cfg->input_pins[i]) { | ||
14295 | case 0x0c: | ||
14296 | idx1 = 1; | ||
14297 | idx = 2; /* Line In */ | ||
14298 | break; | ||
14299 | case 0x0f: | ||
14300 | idx1 = 2; | ||
14301 | idx = 2; /* Line In */ | ||
14302 | break; | ||
14303 | case 0x0d: | ||
14304 | idx1 = 0; | ||
14305 | idx = 1; /* Mic In */ | ||
14306 | break; | ||
14307 | case 0x10: | ||
14308 | idx1 = 3; | ||
14309 | idx = 1; /* Mic In */ | ||
14310 | break; | ||
14311 | case 0x11: | ||
14312 | idx1 = 4; | ||
14313 | idx = 0; /* CD */ | ||
14314 | break; | ||
14315 | default: | ||
14316 | continue; | ||
14317 | } | ||
14318 | |||
14319 | err = new_analog_input(spec, cfg->input_pins[i], | ||
14320 | auto_pin_cfg_labels[i], idx, 0x15); | ||
14321 | if (err < 0) | ||
14322 | return err; | ||
14323 | |||
14324 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | ||
14325 | imux->items[imux->num_items].index = idx1; | ||
14326 | imux->num_items++; | ||
14327 | } | ||
14328 | return 0; | ||
14329 | } | 14301 | } |
14330 | 14302 | ||
14331 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, | 14303 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
14332 | hda_nid_t nid, | 14304 | hda_nid_t nid, |
14333 | int pin_type, int dac_idx) | 14305 | int pin_type, hda_nid_t dac) |
14334 | { | 14306 | { |
14307 | hda_nid_t mix, srcs[5]; | ||
14308 | int i, num; | ||
14309 | |||
14335 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 14310 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
14336 | pin_type); | 14311 | pin_type); |
14337 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 14312 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
14338 | AMP_OUT_UNMUTE); | 14313 | AMP_OUT_UNMUTE); |
14314 | if (snd_hda_get_connections(codec, nid, &mix, 1) != 1) | ||
14315 | return; | ||
14316 | num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs)); | ||
14317 | if (num < 0) | ||
14318 | return; | ||
14319 | for (i = 0; i < num; i++) { | ||
14320 | unsigned int mute; | ||
14321 | if (srcs[i] == dac || srcs[i] == 0x15) | ||
14322 | mute = AMP_IN_UNMUTE(i); | ||
14323 | else | ||
14324 | mute = AMP_IN_MUTE(i); | ||
14325 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
14326 | mute); | ||
14327 | } | ||
14339 | } | 14328 | } |
14340 | 14329 | ||
14341 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | 14330 | static void alc861_auto_init_multi_out(struct hda_codec *codec) |
@@ -14358,12 +14347,13 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec) | |||
14358 | hda_nid_t pin; | 14347 | hda_nid_t pin; |
14359 | 14348 | ||
14360 | pin = spec->autocfg.hp_pins[0]; | 14349 | pin = spec->autocfg.hp_pins[0]; |
14361 | if (pin) /* connect to front */ | 14350 | if (pin) |
14362 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, | 14351 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
14363 | spec->multiout.dac_nids[0]); | 14352 | spec->multiout.hp_nid); |
14364 | pin = spec->autocfg.speaker_pins[0]; | 14353 | pin = spec->autocfg.speaker_pins[0]; |
14365 | if (pin) | 14354 | if (pin) |
14366 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | 14355 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, |
14356 | spec->multiout.dac_nids[0]); | ||
14367 | } | 14357 | } |
14368 | 14358 | ||
14369 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | 14359 | static void alc861_auto_init_analog_input(struct hda_codec *codec) |
@@ -14395,16 +14385,16 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
14395 | if (!spec->autocfg.line_outs) | 14385 | if (!spec->autocfg.line_outs) |
14396 | return 0; /* can't find valid BIOS pin config */ | 14386 | return 0; /* can't find valid BIOS pin config */ |
14397 | 14387 | ||
14398 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); | 14388 | err = alc861_auto_fill_dac_nids(codec, &spec->autocfg); |
14399 | if (err < 0) | 14389 | if (err < 0) |
14400 | return err; | 14390 | return err; |
14401 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | 14391 | err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg); |
14402 | if (err < 0) | 14392 | if (err < 0) |
14403 | return err; | 14393 | return err; |
14404 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | 14394 | err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]); |
14405 | if (err < 0) | 14395 | if (err < 0) |
14406 | return err; | 14396 | return err; |
14407 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | 14397 | err = alc861_auto_create_input_ctls(codec, &spec->autocfg); |
14408 | if (err < 0) | 14398 | if (err < 0) |
14409 | return err; | 14399 | return err; |
14410 | 14400 | ||
@@ -14423,7 +14413,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
14423 | 14413 | ||
14424 | spec->adc_nids = alc861_adc_nids; | 14414 | spec->adc_nids = alc861_adc_nids; |
14425 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | 14415 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
14426 | set_capture_mixer(spec); | 14416 | set_capture_mixer(codec); |
14427 | 14417 | ||
14428 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); | 14418 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); |
14429 | 14419 | ||
@@ -14616,8 +14606,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
14616 | alc861_cfg_tbl); | 14606 | alc861_cfg_tbl); |
14617 | 14607 | ||
14618 | if (board_config < 0) { | 14608 | if (board_config < 0) { |
14619 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 14609 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
14620 | "trying auto-probe from BIOS...\n", codec->chip_name); | 14610 | codec->chip_name); |
14621 | board_config = ALC861_AUTO; | 14611 | board_config = ALC861_AUTO; |
14622 | } | 14612 | } |
14623 | 14613 | ||
@@ -14642,7 +14632,7 @@ static int patch_alc861(struct hda_codec *codec) | |||
14642 | } | 14632 | } |
14643 | 14633 | ||
14644 | if (board_config != ALC861_AUTO) | 14634 | if (board_config != ALC861_AUTO) |
14645 | setup_preset(spec, &alc861_presets[board_config]); | 14635 | setup_preset(codec, &alc861_presets[board_config]); |
14646 | 14636 | ||
14647 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | 14637 | spec->stream_analog_playback = &alc861_pcm_analog_playback; |
14648 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | 14638 | spec->stream_analog_capture = &alc861_pcm_analog_capture; |
@@ -15045,12 +15035,15 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |||
15045 | HDA_AMP_MUTE, bits); | 15035 | HDA_AMP_MUTE, bits); |
15046 | } | 15036 | } |
15047 | 15037 | ||
15048 | static void alc861vd_lenovo_init_hook(struct hda_codec *codec) | 15038 | static void alc861vd_lenovo_setup(struct hda_codec *codec) |
15049 | { | 15039 | { |
15050 | struct alc_spec *spec = codec->spec; | 15040 | struct alc_spec *spec = codec->spec; |
15051 | |||
15052 | spec->autocfg.hp_pins[0] = 0x1b; | 15041 | spec->autocfg.hp_pins[0] = 0x1b; |
15053 | spec->autocfg.speaker_pins[0] = 0x14; | 15042 | spec->autocfg.speaker_pins[0] = 0x14; |
15043 | } | ||
15044 | |||
15045 | static void alc861vd_lenovo_init_hook(struct hda_codec *codec) | ||
15046 | { | ||
15054 | alc_automute_amp(codec); | 15047 | alc_automute_amp(codec); |
15055 | alc861vd_lenovo_mic_automute(codec); | 15048 | alc861vd_lenovo_mic_automute(codec); |
15056 | } | 15049 | } |
@@ -15114,13 +15107,12 @@ static struct hda_verb alc861vd_dallas_verbs[] = { | |||
15114 | }; | 15107 | }; |
15115 | 15108 | ||
15116 | /* toggle speaker-output according to the hp-jack state */ | 15109 | /* toggle speaker-output according to the hp-jack state */ |
15117 | static void alc861vd_dallas_init_hook(struct hda_codec *codec) | 15110 | static void alc861vd_dallas_setup(struct hda_codec *codec) |
15118 | { | 15111 | { |
15119 | struct alc_spec *spec = codec->spec; | 15112 | struct alc_spec *spec = codec->spec; |
15120 | 15113 | ||
15121 | spec->autocfg.hp_pins[0] = 0x15; | 15114 | spec->autocfg.hp_pins[0] = 0x15; |
15122 | spec->autocfg.speaker_pins[0] = 0x14; | 15115 | spec->autocfg.speaker_pins[0] = 0x14; |
15123 | alc_automute_amp(codec); | ||
15124 | } | 15116 | } |
15125 | 15117 | ||
15126 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 15118 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -15234,6 +15226,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15234 | .channel_mode = alc861vd_3stack_2ch_modes, | 15226 | .channel_mode = alc861vd_3stack_2ch_modes, |
15235 | .input_mux = &alc861vd_capture_source, | 15227 | .input_mux = &alc861vd_capture_source, |
15236 | .unsol_event = alc861vd_lenovo_unsol_event, | 15228 | .unsol_event = alc861vd_lenovo_unsol_event, |
15229 | .setup = alc861vd_lenovo_setup, | ||
15237 | .init_hook = alc861vd_lenovo_init_hook, | 15230 | .init_hook = alc861vd_lenovo_init_hook, |
15238 | }, | 15231 | }, |
15239 | [ALC861VD_DALLAS] = { | 15232 | [ALC861VD_DALLAS] = { |
@@ -15245,7 +15238,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15245 | .channel_mode = alc861vd_3stack_2ch_modes, | 15238 | .channel_mode = alc861vd_3stack_2ch_modes, |
15246 | .input_mux = &alc861vd_dallas_capture_source, | 15239 | .input_mux = &alc861vd_dallas_capture_source, |
15247 | .unsol_event = alc_automute_amp_unsol_event, | 15240 | .unsol_event = alc_automute_amp_unsol_event, |
15248 | .init_hook = alc861vd_dallas_init_hook, | 15241 | .setup = alc861vd_dallas_setup, |
15242 | .init_hook = alc_automute_amp, | ||
15249 | }, | 15243 | }, |
15250 | [ALC861VD_HP] = { | 15244 | [ALC861VD_HP] = { |
15251 | .mixers = { alc861vd_hp_mixer }, | 15245 | .mixers = { alc861vd_hp_mixer }, |
@@ -15257,7 +15251,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15257 | .channel_mode = alc861vd_3stack_2ch_modes, | 15251 | .channel_mode = alc861vd_3stack_2ch_modes, |
15258 | .input_mux = &alc861vd_hp_capture_source, | 15252 | .input_mux = &alc861vd_hp_capture_source, |
15259 | .unsol_event = alc_automute_amp_unsol_event, | 15253 | .unsol_event = alc_automute_amp_unsol_event, |
15260 | .init_hook = alc861vd_dallas_init_hook, | 15254 | .setup = alc861vd_dallas_setup, |
15255 | .init_hook = alc_automute_amp, | ||
15261 | }, | 15256 | }, |
15262 | [ALC660VD_ASUS_V1S] = { | 15257 | [ALC660VD_ASUS_V1S] = { |
15263 | .mixers = { alc861vd_lenovo_mixer }, | 15258 | .mixers = { alc861vd_lenovo_mixer }, |
@@ -15272,6 +15267,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15272 | .channel_mode = alc861vd_3stack_2ch_modes, | 15267 | .channel_mode = alc861vd_3stack_2ch_modes, |
15273 | .input_mux = &alc861vd_capture_source, | 15268 | .input_mux = &alc861vd_capture_source, |
15274 | .unsol_event = alc861vd_lenovo_unsol_event, | 15269 | .unsol_event = alc861vd_lenovo_unsol_event, |
15270 | .setup = alc861vd_lenovo_setup, | ||
15275 | .init_hook = alc861vd_lenovo_init_hook, | 15271 | .init_hook = alc861vd_lenovo_init_hook, |
15276 | }, | 15272 | }, |
15277 | }; | 15273 | }; |
@@ -15279,6 +15275,13 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15279 | /* | 15275 | /* |
15280 | * BIOS auto configuration | 15276 | * BIOS auto configuration |
15281 | */ | 15277 | */ |
15278 | static int alc861vd_auto_create_input_ctls(struct hda_codec *codec, | ||
15279 | const struct auto_pin_cfg *cfg) | ||
15280 | { | ||
15281 | return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0); | ||
15282 | } | ||
15283 | |||
15284 | |||
15282 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | 15285 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, |
15283 | hda_nid_t nid, int pin_type, int dac_idx) | 15286 | hda_nid_t nid, int pin_type, int dac_idx) |
15284 | { | 15287 | { |
@@ -15313,7 +15316,6 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |||
15313 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | 15316 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
15314 | } | 15317 | } |
15315 | 15318 | ||
15316 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | ||
15317 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | 15319 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID |
15318 | 15320 | ||
15319 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | 15321 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) |
@@ -15323,7 +15325,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |||
15323 | 15325 | ||
15324 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 15326 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
15325 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 15327 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
15326 | if (alc861vd_is_input_pin(nid)) { | 15328 | if (alc_is_input_pin(codec, nid)) { |
15327 | alc_set_input_pin(codec, nid, i); | 15329 | alc_set_input_pin(codec, nid, i); |
15328 | if (nid != ALC861VD_PIN_CD_NID && | 15330 | if (nid != ALC861VD_PIN_CD_NID && |
15329 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 15331 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
@@ -15387,13 +15389,25 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15387 | if (err < 0) | 15389 | if (err < 0) |
15388 | return err; | 15390 | return err; |
15389 | } else { | 15391 | } else { |
15390 | sprintf(name, "%s Playback Volume", chname[i]); | 15392 | const char *pfx; |
15393 | if (cfg->line_outs == 1 && | ||
15394 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | ||
15395 | if (!cfg->hp_pins) | ||
15396 | pfx = "Speaker"; | ||
15397 | else | ||
15398 | pfx = "PCM"; | ||
15399 | } else | ||
15400 | pfx = chname[i]; | ||
15401 | sprintf(name, "%s Playback Volume", pfx); | ||
15391 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 15402 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
15392 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | 15403 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, |
15393 | HDA_OUTPUT)); | 15404 | HDA_OUTPUT)); |
15394 | if (err < 0) | 15405 | if (err < 0) |
15395 | return err; | 15406 | return err; |
15396 | sprintf(name, "%s Playback Switch", chname[i]); | 15407 | if (cfg->line_outs == 1 && |
15408 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
15409 | pfx = "Speaker"; | ||
15410 | sprintf(name, "%s Playback Switch", pfx); | ||
15397 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | 15411 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
15398 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, | 15412 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
15399 | HDA_INPUT)); | 15413 | HDA_INPUT)); |
@@ -15486,7 +15500,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec) | |||
15486 | "Headphone"); | 15500 | "Headphone"); |
15487 | if (err < 0) | 15501 | if (err < 0) |
15488 | return err; | 15502 | return err; |
15489 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | 15503 | err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg); |
15490 | if (err < 0) | 15504 | if (err < 0) |
15491 | return err; | 15505 | return err; |
15492 | 15506 | ||
@@ -15540,8 +15554,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15540 | alc861vd_cfg_tbl); | 15554 | alc861vd_cfg_tbl); |
15541 | 15555 | ||
15542 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | 15556 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { |
15543 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 15557 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
15544 | "trying auto-probe from BIOS...\n", codec->chip_name); | 15558 | codec->chip_name); |
15545 | board_config = ALC861VD_AUTO; | 15559 | board_config = ALC861VD_AUTO; |
15546 | } | 15560 | } |
15547 | 15561 | ||
@@ -15566,7 +15580,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15566 | } | 15580 | } |
15567 | 15581 | ||
15568 | if (board_config != ALC861VD_AUTO) | 15582 | if (board_config != ALC861VD_AUTO) |
15569 | setup_preset(spec, &alc861vd_presets[board_config]); | 15583 | setup_preset(codec, &alc861vd_presets[board_config]); |
15570 | 15584 | ||
15571 | if (codec->vendor_id == 0x10ec0660) { | 15585 | if (codec->vendor_id == 0x10ec0660) { |
15572 | /* always turn on EAPD */ | 15586 | /* always turn on EAPD */ |
@@ -15586,7 +15600,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15586 | if (!spec->capsrc_nids) | 15600 | if (!spec->capsrc_nids) |
15587 | spec->capsrc_nids = alc861vd_capsrc_nids; | 15601 | spec->capsrc_nids = alc861vd_capsrc_nids; |
15588 | 15602 | ||
15589 | set_capture_mixer(spec); | 15603 | set_capture_mixer(codec); |
15590 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 15604 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
15591 | 15605 | ||
15592 | spec->vmaster_nid = 0x02; | 15606 | spec->vmaster_nid = 0x02; |
@@ -15627,9 +15641,9 @@ static hda_nid_t alc272_dac_nids[2] = { | |||
15627 | 0x02, 0x03 | 15641 | 0x02, 0x03 |
15628 | }; | 15642 | }; |
15629 | 15643 | ||
15630 | static hda_nid_t alc662_adc_nids[1] = { | 15644 | static hda_nid_t alc662_adc_nids[2] = { |
15631 | /* ADC1-2 */ | 15645 | /* ADC1-2 */ |
15632 | 0x09, | 15646 | 0x09, 0x08 |
15633 | }; | 15647 | }; |
15634 | 15648 | ||
15635 | static hda_nid_t alc272_adc_nids[1] = { | 15649 | static hda_nid_t alc272_adc_nids[1] = { |
@@ -15637,7 +15651,7 @@ static hda_nid_t alc272_adc_nids[1] = { | |||
15637 | 0x08, | 15651 | 0x08, |
15638 | }; | 15652 | }; |
15639 | 15653 | ||
15640 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; | 15654 | static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 }; |
15641 | static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; | 15655 | static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; |
15642 | 15656 | ||
15643 | 15657 | ||
@@ -15661,14 +15675,6 @@ static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |||
15661 | }, | 15675 | }, |
15662 | }; | 15676 | }; |
15663 | 15677 | ||
15664 | static struct hda_input_mux alc662_eeepc_capture_source = { | ||
15665 | .num_items = 2, | ||
15666 | .items = { | ||
15667 | { "i-Mic", 0x1 }, | ||
15668 | { "e-Mic", 0x0 }, | ||
15669 | }, | ||
15670 | }; | ||
15671 | |||
15672 | static struct hda_input_mux alc663_capture_source = { | 15678 | static struct hda_input_mux alc663_capture_source = { |
15673 | .num_items = 3, | 15679 | .num_items = 3, |
15674 | .items = { | 15680 | .items = { |
@@ -15678,23 +15684,7 @@ static struct hda_input_mux alc663_capture_source = { | |||
15678 | }, | 15684 | }, |
15679 | }; | 15685 | }; |
15680 | 15686 | ||
15681 | static struct hda_input_mux alc663_m51va_capture_source = { | 15687 | #if 0 /* set to 1 for testing other input sources below */ |
15682 | .num_items = 2, | ||
15683 | .items = { | ||
15684 | { "Ext-Mic", 0x0 }, | ||
15685 | { "D-Mic", 0x9 }, | ||
15686 | }, | ||
15687 | }; | ||
15688 | |||
15689 | #if 1 /* set to 0 for testing other input sources below */ | ||
15690 | static struct hda_input_mux alc272_nc10_capture_source = { | ||
15691 | .num_items = 2, | ||
15692 | .items = { | ||
15693 | { "Autoselect Mic", 0x0 }, | ||
15694 | { "Internal Mic", 0x1 }, | ||
15695 | }, | ||
15696 | }; | ||
15697 | #else | ||
15698 | static struct hda_input_mux alc272_nc10_capture_source = { | 15688 | static struct hda_input_mux alc272_nc10_capture_source = { |
15699 | .num_items = 16, | 15689 | .num_items = 16, |
15700 | .items = { | 15690 | .items = { |
@@ -16363,47 +16353,44 @@ static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |||
16363 | alc662_lenovo_101e_ispeaker_automute(codec); | 16353 | alc662_lenovo_101e_ispeaker_automute(codec); |
16364 | } | 16354 | } |
16365 | 16355 | ||
16366 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) | ||
16367 | { | ||
16368 | unsigned int present; | ||
16369 | |||
16370 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
16371 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
16372 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16373 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16374 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16375 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16376 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16377 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
16378 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16379 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
16380 | } | ||
16381 | |||
16382 | /* unsolicited event for HP jack sensing */ | 16356 | /* unsolicited event for HP jack sensing */ |
16383 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | 16357 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, |
16384 | unsigned int res) | 16358 | unsigned int res) |
16385 | { | 16359 | { |
16386 | if ((res >> 26) == ALC880_MIC_EVENT) | 16360 | if ((res >> 26) == ALC880_MIC_EVENT) |
16387 | alc662_eeepc_mic_automute(codec); | 16361 | alc_mic_automute(codec); |
16388 | else | 16362 | else |
16389 | alc262_hippo_unsol_event(codec, res); | 16363 | alc262_hippo_unsol_event(codec, res); |
16390 | } | 16364 | } |
16391 | 16365 | ||
16366 | static void alc662_eeepc_setup(struct hda_codec *codec) | ||
16367 | { | ||
16368 | struct alc_spec *spec = codec->spec; | ||
16369 | |||
16370 | alc262_hippo1_setup(codec); | ||
16371 | spec->ext_mic.pin = 0x18; | ||
16372 | spec->ext_mic.mux_idx = 0; | ||
16373 | spec->int_mic.pin = 0x19; | ||
16374 | spec->int_mic.mux_idx = 1; | ||
16375 | spec->auto_mic = 1; | ||
16376 | } | ||
16377 | |||
16392 | static void alc662_eeepc_inithook(struct hda_codec *codec) | 16378 | static void alc662_eeepc_inithook(struct hda_codec *codec) |
16393 | { | 16379 | { |
16394 | alc262_hippo1_init_hook(codec); | 16380 | alc262_hippo_automute(codec); |
16395 | alc662_eeepc_mic_automute(codec); | 16381 | alc_mic_automute(codec); |
16396 | } | 16382 | } |
16397 | 16383 | ||
16398 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | 16384 | static void alc662_eeepc_ep20_setup(struct hda_codec *codec) |
16399 | { | 16385 | { |
16400 | struct alc_spec *spec = codec->spec; | 16386 | struct alc_spec *spec = codec->spec; |
16401 | 16387 | ||
16402 | spec->autocfg.hp_pins[0] = 0x14; | 16388 | spec->autocfg.hp_pins[0] = 0x14; |
16403 | spec->autocfg.speaker_pins[0] = 0x1b; | 16389 | spec->autocfg.speaker_pins[0] = 0x1b; |
16404 | alc262_hippo_master_update(codec); | ||
16405 | } | 16390 | } |
16406 | 16391 | ||
16392 | #define alc662_eeepc_ep20_inithook alc262_hippo_master_update | ||
16393 | |||
16407 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) | 16394 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
16408 | { | 16395 | { |
16409 | unsigned int present; | 16396 | unsigned int present; |
@@ -16514,23 +16501,6 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |||
16514 | } | 16501 | } |
16515 | } | 16502 | } |
16516 | 16503 | ||
16517 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | ||
16518 | { | ||
16519 | unsigned int present; | ||
16520 | |||
16521 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
16522 | AC_VERB_GET_PIN_SENSE, 0) | ||
16523 | & AC_PINSENSE_PRESENCE; | ||
16524 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16525 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16526 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16527 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16528 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16529 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); | ||
16530 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16531 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); | ||
16532 | } | ||
16533 | |||
16534 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | 16504 | static void alc663_m51va_unsol_event(struct hda_codec *codec, |
16535 | unsigned int res) | 16505 | unsigned int res) |
16536 | { | 16506 | { |
@@ -16539,36 +16509,32 @@ static void alc663_m51va_unsol_event(struct hda_codec *codec, | |||
16539 | alc663_m51va_speaker_automute(codec); | 16509 | alc663_m51va_speaker_automute(codec); |
16540 | break; | 16510 | break; |
16541 | case ALC880_MIC_EVENT: | 16511 | case ALC880_MIC_EVENT: |
16542 | alc663_m51va_mic_automute(codec); | 16512 | alc_mic_automute(codec); |
16543 | break; | 16513 | break; |
16544 | } | 16514 | } |
16545 | } | 16515 | } |
16546 | 16516 | ||
16517 | static void alc663_m51va_setup(struct hda_codec *codec) | ||
16518 | { | ||
16519 | struct alc_spec *spec = codec->spec; | ||
16520 | spec->ext_mic.pin = 0x18; | ||
16521 | spec->ext_mic.mux_idx = 0; | ||
16522 | spec->int_mic.pin = 0x12; | ||
16523 | spec->int_mic.mux_idx = 1; | ||
16524 | spec->auto_mic = 1; | ||
16525 | } | ||
16526 | |||
16547 | static void alc663_m51va_inithook(struct hda_codec *codec) | 16527 | static void alc663_m51va_inithook(struct hda_codec *codec) |
16548 | { | 16528 | { |
16549 | alc663_m51va_speaker_automute(codec); | 16529 | alc663_m51va_speaker_automute(codec); |
16550 | alc663_m51va_mic_automute(codec); | 16530 | alc_mic_automute(codec); |
16551 | } | 16531 | } |
16552 | 16532 | ||
16553 | /* ***************** Mode1 ******************************/ | 16533 | /* ***************** Mode1 ******************************/ |
16554 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | 16534 | #define alc663_mode1_unsol_event alc663_m51va_unsol_event |
16555 | unsigned int res) | 16535 | #define alc663_mode1_setup alc663_m51va_setup |
16556 | { | 16536 | #define alc663_mode1_inithook alc663_m51va_inithook |
16557 | switch (res >> 26) { | ||
16558 | case ALC880_HP_EVENT: | ||
16559 | alc663_m51va_speaker_automute(codec); | ||
16560 | break; | ||
16561 | case ALC880_MIC_EVENT: | ||
16562 | alc662_eeepc_mic_automute(codec); | ||
16563 | break; | ||
16564 | } | ||
16565 | } | ||
16566 | 16537 | ||
16567 | static void alc663_mode1_inithook(struct hda_codec *codec) | ||
16568 | { | ||
16569 | alc663_m51va_speaker_automute(codec); | ||
16570 | alc662_eeepc_mic_automute(codec); | ||
16571 | } | ||
16572 | /* ***************** Mode2 ******************************/ | 16538 | /* ***************** Mode2 ******************************/ |
16573 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | 16539 | static void alc662_mode2_unsol_event(struct hda_codec *codec, |
16574 | unsigned int res) | 16540 | unsigned int res) |
@@ -16578,15 +16544,17 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec, | |||
16578 | alc662_f5z_speaker_automute(codec); | 16544 | alc662_f5z_speaker_automute(codec); |
16579 | break; | 16545 | break; |
16580 | case ALC880_MIC_EVENT: | 16546 | case ALC880_MIC_EVENT: |
16581 | alc662_eeepc_mic_automute(codec); | 16547 | alc_mic_automute(codec); |
16582 | break; | 16548 | break; |
16583 | } | 16549 | } |
16584 | } | 16550 | } |
16585 | 16551 | ||
16552 | #define alc662_mode2_setup alc663_m51va_setup | ||
16553 | |||
16586 | static void alc662_mode2_inithook(struct hda_codec *codec) | 16554 | static void alc662_mode2_inithook(struct hda_codec *codec) |
16587 | { | 16555 | { |
16588 | alc662_f5z_speaker_automute(codec); | 16556 | alc662_f5z_speaker_automute(codec); |
16589 | alc662_eeepc_mic_automute(codec); | 16557 | alc_mic_automute(codec); |
16590 | } | 16558 | } |
16591 | /* ***************** Mode3 ******************************/ | 16559 | /* ***************** Mode3 ******************************/ |
16592 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | 16560 | static void alc663_mode3_unsol_event(struct hda_codec *codec, |
@@ -16597,15 +16565,17 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec, | |||
16597 | alc663_two_hp_m1_speaker_automute(codec); | 16565 | alc663_two_hp_m1_speaker_automute(codec); |
16598 | break; | 16566 | break; |
16599 | case ALC880_MIC_EVENT: | 16567 | case ALC880_MIC_EVENT: |
16600 | alc662_eeepc_mic_automute(codec); | 16568 | alc_mic_automute(codec); |
16601 | break; | 16569 | break; |
16602 | } | 16570 | } |
16603 | } | 16571 | } |
16604 | 16572 | ||
16573 | #define alc663_mode3_setup alc663_m51va_setup | ||
16574 | |||
16605 | static void alc663_mode3_inithook(struct hda_codec *codec) | 16575 | static void alc663_mode3_inithook(struct hda_codec *codec) |
16606 | { | 16576 | { |
16607 | alc663_two_hp_m1_speaker_automute(codec); | 16577 | alc663_two_hp_m1_speaker_automute(codec); |
16608 | alc662_eeepc_mic_automute(codec); | 16578 | alc_mic_automute(codec); |
16609 | } | 16579 | } |
16610 | /* ***************** Mode4 ******************************/ | 16580 | /* ***************** Mode4 ******************************/ |
16611 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | 16581 | static void alc663_mode4_unsol_event(struct hda_codec *codec, |
@@ -16616,15 +16586,17 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec, | |||
16616 | alc663_21jd_two_speaker_automute(codec); | 16586 | alc663_21jd_two_speaker_automute(codec); |
16617 | break; | 16587 | break; |
16618 | case ALC880_MIC_EVENT: | 16588 | case ALC880_MIC_EVENT: |
16619 | alc662_eeepc_mic_automute(codec); | 16589 | alc_mic_automute(codec); |
16620 | break; | 16590 | break; |
16621 | } | 16591 | } |
16622 | } | 16592 | } |
16623 | 16593 | ||
16594 | #define alc663_mode4_setup alc663_m51va_setup | ||
16595 | |||
16624 | static void alc663_mode4_inithook(struct hda_codec *codec) | 16596 | static void alc663_mode4_inithook(struct hda_codec *codec) |
16625 | { | 16597 | { |
16626 | alc663_21jd_two_speaker_automute(codec); | 16598 | alc663_21jd_two_speaker_automute(codec); |
16627 | alc662_eeepc_mic_automute(codec); | 16599 | alc_mic_automute(codec); |
16628 | } | 16600 | } |
16629 | /* ***************** Mode5 ******************************/ | 16601 | /* ***************** Mode5 ******************************/ |
16630 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | 16602 | static void alc663_mode5_unsol_event(struct hda_codec *codec, |
@@ -16635,15 +16607,17 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec, | |||
16635 | alc663_15jd_two_speaker_automute(codec); | 16607 | alc663_15jd_two_speaker_automute(codec); |
16636 | break; | 16608 | break; |
16637 | case ALC880_MIC_EVENT: | 16609 | case ALC880_MIC_EVENT: |
16638 | alc662_eeepc_mic_automute(codec); | 16610 | alc_mic_automute(codec); |
16639 | break; | 16611 | break; |
16640 | } | 16612 | } |
16641 | } | 16613 | } |
16642 | 16614 | ||
16615 | #define alc663_mode5_setup alc663_m51va_setup | ||
16616 | |||
16643 | static void alc663_mode5_inithook(struct hda_codec *codec) | 16617 | static void alc663_mode5_inithook(struct hda_codec *codec) |
16644 | { | 16618 | { |
16645 | alc663_15jd_two_speaker_automute(codec); | 16619 | alc663_15jd_two_speaker_automute(codec); |
16646 | alc662_eeepc_mic_automute(codec); | 16620 | alc_mic_automute(codec); |
16647 | } | 16621 | } |
16648 | /* ***************** Mode6 ******************************/ | 16622 | /* ***************** Mode6 ******************************/ |
16649 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | 16623 | static void alc663_mode6_unsol_event(struct hda_codec *codec, |
@@ -16654,15 +16628,17 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec, | |||
16654 | alc663_two_hp_m2_speaker_automute(codec); | 16628 | alc663_two_hp_m2_speaker_automute(codec); |
16655 | break; | 16629 | break; |
16656 | case ALC880_MIC_EVENT: | 16630 | case ALC880_MIC_EVENT: |
16657 | alc662_eeepc_mic_automute(codec); | 16631 | alc_mic_automute(codec); |
16658 | break; | 16632 | break; |
16659 | } | 16633 | } |
16660 | } | 16634 | } |
16661 | 16635 | ||
16636 | #define alc663_mode6_setup alc663_m51va_setup | ||
16637 | |||
16662 | static void alc663_mode6_inithook(struct hda_codec *codec) | 16638 | static void alc663_mode6_inithook(struct hda_codec *codec) |
16663 | { | 16639 | { |
16664 | alc663_two_hp_m2_speaker_automute(codec); | 16640 | alc663_two_hp_m2_speaker_automute(codec); |
16665 | alc662_eeepc_mic_automute(codec); | 16641 | alc_mic_automute(codec); |
16666 | } | 16642 | } |
16667 | 16643 | ||
16668 | static void alc663_g71v_hp_automute(struct hda_codec *codec) | 16644 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
@@ -16704,16 +16680,18 @@ static void alc663_g71v_unsol_event(struct hda_codec *codec, | |||
16704 | alc663_g71v_front_automute(codec); | 16680 | alc663_g71v_front_automute(codec); |
16705 | break; | 16681 | break; |
16706 | case ALC880_MIC_EVENT: | 16682 | case ALC880_MIC_EVENT: |
16707 | alc662_eeepc_mic_automute(codec); | 16683 | alc_mic_automute(codec); |
16708 | break; | 16684 | break; |
16709 | } | 16685 | } |
16710 | } | 16686 | } |
16711 | 16687 | ||
16688 | #define alc663_g71v_setup alc663_m51va_setup | ||
16689 | |||
16712 | static void alc663_g71v_inithook(struct hda_codec *codec) | 16690 | static void alc663_g71v_inithook(struct hda_codec *codec) |
16713 | { | 16691 | { |
16714 | alc663_g71v_front_automute(codec); | 16692 | alc663_g71v_front_automute(codec); |
16715 | alc663_g71v_hp_automute(codec); | 16693 | alc663_g71v_hp_automute(codec); |
16716 | alc662_eeepc_mic_automute(codec); | 16694 | alc_mic_automute(codec); |
16717 | } | 16695 | } |
16718 | 16696 | ||
16719 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | 16697 | static void alc663_g50v_unsol_event(struct hda_codec *codec, |
@@ -16724,15 +16702,17 @@ static void alc663_g50v_unsol_event(struct hda_codec *codec, | |||
16724 | alc663_m51va_speaker_automute(codec); | 16702 | alc663_m51va_speaker_automute(codec); |
16725 | break; | 16703 | break; |
16726 | case ALC880_MIC_EVENT: | 16704 | case ALC880_MIC_EVENT: |
16727 | alc662_eeepc_mic_automute(codec); | 16705 | alc_mic_automute(codec); |
16728 | break; | 16706 | break; |
16729 | } | 16707 | } |
16730 | } | 16708 | } |
16731 | 16709 | ||
16710 | #define alc663_g50v_setup alc663_m51va_setup | ||
16711 | |||
16732 | static void alc663_g50v_inithook(struct hda_codec *codec) | 16712 | static void alc663_g50v_inithook(struct hda_codec *codec) |
16733 | { | 16713 | { |
16734 | alc663_m51va_speaker_automute(codec); | 16714 | alc663_m51va_speaker_automute(codec); |
16735 | alc662_eeepc_mic_automute(codec); | 16715 | alc_mic_automute(codec); |
16736 | } | 16716 | } |
16737 | 16717 | ||
16738 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | 16718 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { |
@@ -16936,8 +16916,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16936 | .dac_nids = alc662_dac_nids, | 16916 | .dac_nids = alc662_dac_nids, |
16937 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16917 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16938 | .channel_mode = alc662_3ST_2ch_modes, | 16918 | .channel_mode = alc662_3ST_2ch_modes, |
16939 | .input_mux = &alc662_eeepc_capture_source, | ||
16940 | .unsol_event = alc662_eeepc_unsol_event, | 16919 | .unsol_event = alc662_eeepc_unsol_event, |
16920 | .setup = alc662_eeepc_setup, | ||
16941 | .init_hook = alc662_eeepc_inithook, | 16921 | .init_hook = alc662_eeepc_inithook, |
16942 | }, | 16922 | }, |
16943 | [ALC662_ASUS_EEEPC_EP20] = { | 16923 | [ALC662_ASUS_EEEPC_EP20] = { |
@@ -16951,6 +16931,7 @@ static struct alc_config_preset alc662_presets[] = { | |||
16951 | .channel_mode = alc662_3ST_6ch_modes, | 16931 | .channel_mode = alc662_3ST_6ch_modes, |
16952 | .input_mux = &alc662_lenovo_101e_capture_source, | 16932 | .input_mux = &alc662_lenovo_101e_capture_source, |
16953 | .unsol_event = alc662_eeepc_unsol_event, | 16933 | .unsol_event = alc662_eeepc_unsol_event, |
16934 | .setup = alc662_eeepc_ep20_setup, | ||
16954 | .init_hook = alc662_eeepc_ep20_inithook, | 16935 | .init_hook = alc662_eeepc_ep20_inithook, |
16955 | }, | 16936 | }, |
16956 | [ALC662_ECS] = { | 16937 | [ALC662_ECS] = { |
@@ -16961,8 +16942,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16961 | .dac_nids = alc662_dac_nids, | 16942 | .dac_nids = alc662_dac_nids, |
16962 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16943 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16963 | .channel_mode = alc662_3ST_2ch_modes, | 16944 | .channel_mode = alc662_3ST_2ch_modes, |
16964 | .input_mux = &alc662_eeepc_capture_source, | ||
16965 | .unsol_event = alc662_eeepc_unsol_event, | 16945 | .unsol_event = alc662_eeepc_unsol_event, |
16946 | .setup = alc662_eeepc_setup, | ||
16966 | .init_hook = alc662_eeepc_inithook, | 16947 | .init_hook = alc662_eeepc_inithook, |
16967 | }, | 16948 | }, |
16968 | [ALC663_ASUS_M51VA] = { | 16949 | [ALC663_ASUS_M51VA] = { |
@@ -16973,8 +16954,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16973 | .dig_out_nid = ALC662_DIGOUT_NID, | 16954 | .dig_out_nid = ALC662_DIGOUT_NID, |
16974 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16955 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16975 | .channel_mode = alc662_3ST_2ch_modes, | 16956 | .channel_mode = alc662_3ST_2ch_modes, |
16976 | .input_mux = &alc663_m51va_capture_source, | ||
16977 | .unsol_event = alc663_m51va_unsol_event, | 16957 | .unsol_event = alc663_m51va_unsol_event, |
16958 | .setup = alc663_m51va_setup, | ||
16978 | .init_hook = alc663_m51va_inithook, | 16959 | .init_hook = alc663_m51va_inithook, |
16979 | }, | 16960 | }, |
16980 | [ALC663_ASUS_G71V] = { | 16961 | [ALC663_ASUS_G71V] = { |
@@ -16985,8 +16966,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16985 | .dig_out_nid = ALC662_DIGOUT_NID, | 16966 | .dig_out_nid = ALC662_DIGOUT_NID, |
16986 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16967 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16987 | .channel_mode = alc662_3ST_2ch_modes, | 16968 | .channel_mode = alc662_3ST_2ch_modes, |
16988 | .input_mux = &alc662_eeepc_capture_source, | ||
16989 | .unsol_event = alc663_g71v_unsol_event, | 16969 | .unsol_event = alc663_g71v_unsol_event, |
16970 | .setup = alc663_g71v_setup, | ||
16990 | .init_hook = alc663_g71v_inithook, | 16971 | .init_hook = alc663_g71v_inithook, |
16991 | }, | 16972 | }, |
16992 | [ALC663_ASUS_H13] = { | 16973 | [ALC663_ASUS_H13] = { |
@@ -16996,7 +16977,6 @@ static struct alc_config_preset alc662_presets[] = { | |||
16996 | .dac_nids = alc662_dac_nids, | 16977 | .dac_nids = alc662_dac_nids, |
16997 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16978 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16998 | .channel_mode = alc662_3ST_2ch_modes, | 16979 | .channel_mode = alc662_3ST_2ch_modes, |
16999 | .input_mux = &alc663_m51va_capture_source, | ||
17000 | .unsol_event = alc663_m51va_unsol_event, | 16980 | .unsol_event = alc663_m51va_unsol_event, |
17001 | .init_hook = alc663_m51va_inithook, | 16981 | .init_hook = alc663_m51va_inithook, |
17002 | }, | 16982 | }, |
@@ -17010,6 +16990,7 @@ static struct alc_config_preset alc662_presets[] = { | |||
17010 | .channel_mode = alc662_3ST_6ch_modes, | 16990 | .channel_mode = alc662_3ST_6ch_modes, |
17011 | .input_mux = &alc663_capture_source, | 16991 | .input_mux = &alc663_capture_source, |
17012 | .unsol_event = alc663_g50v_unsol_event, | 16992 | .unsol_event = alc663_g50v_unsol_event, |
16993 | .setup = alc663_g50v_setup, | ||
17013 | .init_hook = alc663_g50v_inithook, | 16994 | .init_hook = alc663_g50v_inithook, |
17014 | }, | 16995 | }, |
17015 | [ALC663_ASUS_MODE1] = { | 16996 | [ALC663_ASUS_MODE1] = { |
@@ -17023,8 +17004,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17023 | .dig_out_nid = ALC662_DIGOUT_NID, | 17004 | .dig_out_nid = ALC662_DIGOUT_NID, |
17024 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17005 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17025 | .channel_mode = alc662_3ST_2ch_modes, | 17006 | .channel_mode = alc662_3ST_2ch_modes, |
17026 | .input_mux = &alc662_eeepc_capture_source, | ||
17027 | .unsol_event = alc663_mode1_unsol_event, | 17007 | .unsol_event = alc663_mode1_unsol_event, |
17008 | .setup = alc663_mode1_setup, | ||
17028 | .init_hook = alc663_mode1_inithook, | 17009 | .init_hook = alc663_mode1_inithook, |
17029 | }, | 17010 | }, |
17030 | [ALC662_ASUS_MODE2] = { | 17011 | [ALC662_ASUS_MODE2] = { |
@@ -17037,8 +17018,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17037 | .dig_out_nid = ALC662_DIGOUT_NID, | 17018 | .dig_out_nid = ALC662_DIGOUT_NID, |
17038 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17019 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17039 | .channel_mode = alc662_3ST_2ch_modes, | 17020 | .channel_mode = alc662_3ST_2ch_modes, |
17040 | .input_mux = &alc662_eeepc_capture_source, | ||
17041 | .unsol_event = alc662_mode2_unsol_event, | 17021 | .unsol_event = alc662_mode2_unsol_event, |
17022 | .setup = alc662_mode2_setup, | ||
17042 | .init_hook = alc662_mode2_inithook, | 17023 | .init_hook = alc662_mode2_inithook, |
17043 | }, | 17024 | }, |
17044 | [ALC663_ASUS_MODE3] = { | 17025 | [ALC663_ASUS_MODE3] = { |
@@ -17052,8 +17033,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17052 | .dig_out_nid = ALC662_DIGOUT_NID, | 17033 | .dig_out_nid = ALC662_DIGOUT_NID, |
17053 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17034 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17054 | .channel_mode = alc662_3ST_2ch_modes, | 17035 | .channel_mode = alc662_3ST_2ch_modes, |
17055 | .input_mux = &alc662_eeepc_capture_source, | ||
17056 | .unsol_event = alc663_mode3_unsol_event, | 17036 | .unsol_event = alc663_mode3_unsol_event, |
17037 | .setup = alc663_mode3_setup, | ||
17057 | .init_hook = alc663_mode3_inithook, | 17038 | .init_hook = alc663_mode3_inithook, |
17058 | }, | 17039 | }, |
17059 | [ALC663_ASUS_MODE4] = { | 17040 | [ALC663_ASUS_MODE4] = { |
@@ -17067,8 +17048,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17067 | .dig_out_nid = ALC662_DIGOUT_NID, | 17048 | .dig_out_nid = ALC662_DIGOUT_NID, |
17068 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17049 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17069 | .channel_mode = alc662_3ST_2ch_modes, | 17050 | .channel_mode = alc662_3ST_2ch_modes, |
17070 | .input_mux = &alc662_eeepc_capture_source, | ||
17071 | .unsol_event = alc663_mode4_unsol_event, | 17051 | .unsol_event = alc663_mode4_unsol_event, |
17052 | .setup = alc663_mode4_setup, | ||
17072 | .init_hook = alc663_mode4_inithook, | 17053 | .init_hook = alc663_mode4_inithook, |
17073 | }, | 17054 | }, |
17074 | [ALC663_ASUS_MODE5] = { | 17055 | [ALC663_ASUS_MODE5] = { |
@@ -17082,8 +17063,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17082 | .dig_out_nid = ALC662_DIGOUT_NID, | 17063 | .dig_out_nid = ALC662_DIGOUT_NID, |
17083 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17064 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17084 | .channel_mode = alc662_3ST_2ch_modes, | 17065 | .channel_mode = alc662_3ST_2ch_modes, |
17085 | .input_mux = &alc662_eeepc_capture_source, | ||
17086 | .unsol_event = alc663_mode5_unsol_event, | 17066 | .unsol_event = alc663_mode5_unsol_event, |
17067 | .setup = alc663_mode5_setup, | ||
17087 | .init_hook = alc663_mode5_inithook, | 17068 | .init_hook = alc663_mode5_inithook, |
17088 | }, | 17069 | }, |
17089 | [ALC663_ASUS_MODE6] = { | 17070 | [ALC663_ASUS_MODE6] = { |
@@ -17097,8 +17078,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17097 | .dig_out_nid = ALC662_DIGOUT_NID, | 17078 | .dig_out_nid = ALC662_DIGOUT_NID, |
17098 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17079 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17099 | .channel_mode = alc662_3ST_2ch_modes, | 17080 | .channel_mode = alc662_3ST_2ch_modes, |
17100 | .input_mux = &alc662_eeepc_capture_source, | ||
17101 | .unsol_event = alc663_mode6_unsol_event, | 17081 | .unsol_event = alc663_mode6_unsol_event, |
17082 | .setup = alc663_mode6_setup, | ||
17102 | .init_hook = alc663_mode6_inithook, | 17083 | .init_hook = alc663_mode6_inithook, |
17103 | }, | 17084 | }, |
17104 | [ALC272_DELL] = { | 17085 | [ALC272_DELL] = { |
@@ -17112,8 +17093,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17112 | .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), | 17093 | .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), |
17113 | .capsrc_nids = alc272_capsrc_nids, | 17094 | .capsrc_nids = alc272_capsrc_nids, |
17114 | .channel_mode = alc662_3ST_2ch_modes, | 17095 | .channel_mode = alc662_3ST_2ch_modes, |
17115 | .input_mux = &alc663_m51va_capture_source, | ||
17116 | .unsol_event = alc663_m51va_unsol_event, | 17096 | .unsol_event = alc663_m51va_unsol_event, |
17097 | .setup = alc663_m51va_setup, | ||
17117 | .init_hook = alc663_m51va_inithook, | 17098 | .init_hook = alc663_m51va_inithook, |
17118 | }, | 17099 | }, |
17119 | [ALC272_DELL_ZM1] = { | 17100 | [ALC272_DELL_ZM1] = { |
@@ -17124,11 +17105,11 @@ static struct alc_config_preset alc662_presets[] = { | |||
17124 | .dac_nids = alc662_dac_nids, | 17105 | .dac_nids = alc662_dac_nids, |
17125 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17106 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17126 | .adc_nids = alc662_adc_nids, | 17107 | .adc_nids = alc662_adc_nids, |
17127 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | 17108 | .num_adc_nids = 1, |
17128 | .capsrc_nids = alc662_capsrc_nids, | 17109 | .capsrc_nids = alc662_capsrc_nids, |
17129 | .channel_mode = alc662_3ST_2ch_modes, | 17110 | .channel_mode = alc662_3ST_2ch_modes, |
17130 | .input_mux = &alc663_m51va_capture_source, | ||
17131 | .unsol_event = alc663_m51va_unsol_event, | 17111 | .unsol_event = alc663_m51va_unsol_event, |
17112 | .setup = alc663_m51va_setup, | ||
17132 | .init_hook = alc663_m51va_inithook, | 17113 | .init_hook = alc663_m51va_inithook, |
17133 | }, | 17114 | }, |
17134 | [ALC272_SAMSUNG_NC10] = { | 17115 | [ALC272_SAMSUNG_NC10] = { |
@@ -17139,8 +17120,9 @@ static struct alc_config_preset alc662_presets[] = { | |||
17139 | .dac_nids = alc272_dac_nids, | 17120 | .dac_nids = alc272_dac_nids, |
17140 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17121 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17141 | .channel_mode = alc662_3ST_2ch_modes, | 17122 | .channel_mode = alc662_3ST_2ch_modes, |
17142 | .input_mux = &alc272_nc10_capture_source, | 17123 | /*.input_mux = &alc272_nc10_capture_source,*/ |
17143 | .unsol_event = alc663_mode4_unsol_event, | 17124 | .unsol_event = alc663_mode4_unsol_event, |
17125 | .setup = alc663_mode4_setup, | ||
17144 | .init_hook = alc663_mode4_inithook, | 17126 | .init_hook = alc663_mode4_inithook, |
17145 | }, | 17127 | }, |
17146 | }; | 17128 | }; |
@@ -17192,13 +17174,25 @@ static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
17192 | if (err < 0) | 17174 | if (err < 0) |
17193 | return err; | 17175 | return err; |
17194 | } else { | 17176 | } else { |
17195 | sprintf(name, "%s Playback Volume", chname[i]); | 17177 | const char *pfx; |
17178 | if (cfg->line_outs == 1 && | ||
17179 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | ||
17180 | if (!cfg->hp_pins) | ||
17181 | pfx = "Speaker"; | ||
17182 | else | ||
17183 | pfx = "PCM"; | ||
17184 | } else | ||
17185 | pfx = chname[i]; | ||
17186 | sprintf(name, "%s Playback Volume", pfx); | ||
17196 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 17187 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
17197 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 17188 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
17198 | HDA_OUTPUT)); | 17189 | HDA_OUTPUT)); |
17199 | if (err < 0) | 17190 | if (err < 0) |
17200 | return err; | 17191 | return err; |
17201 | sprintf(name, "%s Playback Switch", chname[i]); | 17192 | if (cfg->line_outs == 1 && |
17193 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
17194 | pfx = "Speaker"; | ||
17195 | sprintf(name, "%s Playback Switch", pfx); | ||
17202 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 17196 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
17203 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), | 17197 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), |
17204 | 3, 0, HDA_INPUT)); | 17198 | 3, 0, HDA_INPUT)); |
@@ -17260,62 +17254,9 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
17260 | return 0; | 17254 | return 0; |
17261 | } | 17255 | } |
17262 | 17256 | ||
17263 | /* return the index of the src widget from the connection list of the nid. | ||
17264 | * return -1 if not found | ||
17265 | */ | ||
17266 | static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid, | ||
17267 | hda_nid_t src) | ||
17268 | { | ||
17269 | hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; | ||
17270 | int i, conns; | ||
17271 | |||
17272 | conns = snd_hda_get_connections(codec, nid, conn_list, | ||
17273 | ARRAY_SIZE(conn_list)); | ||
17274 | if (conns < 0) | ||
17275 | return -1; | ||
17276 | for (i = 0; i < conns; i++) | ||
17277 | if (conn_list[i] == src) | ||
17278 | return i; | ||
17279 | return -1; | ||
17280 | } | ||
17281 | |||
17282 | static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid) | ||
17283 | { | ||
17284 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | ||
17285 | return (pincap & AC_PINCAP_IN) != 0; | ||
17286 | } | ||
17287 | |||
17288 | /* create playback/capture controls for input pins */ | 17257 | /* create playback/capture controls for input pins */ |
17289 | static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec, | 17258 | #define alc662_auto_create_input_ctls \ |
17290 | const struct auto_pin_cfg *cfg) | 17259 | alc880_auto_create_input_ctls |
17291 | { | ||
17292 | struct alc_spec *spec = codec->spec; | ||
17293 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
17294 | int i, err, idx; | ||
17295 | |||
17296 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
17297 | if (alc662_is_input_pin(codec, cfg->input_pins[i])) { | ||
17298 | idx = alc662_input_pin_idx(codec, 0x0b, | ||
17299 | cfg->input_pins[i]); | ||
17300 | if (idx >= 0) { | ||
17301 | err = new_analog_input(spec, cfg->input_pins[i], | ||
17302 | auto_pin_cfg_labels[i], | ||
17303 | idx, 0x0b); | ||
17304 | if (err < 0) | ||
17305 | return err; | ||
17306 | } | ||
17307 | idx = alc662_input_pin_idx(codec, 0x22, | ||
17308 | cfg->input_pins[i]); | ||
17309 | if (idx >= 0) { | ||
17310 | imux->items[imux->num_items].label = | ||
17311 | auto_pin_cfg_labels[i]; | ||
17312 | imux->items[imux->num_items].index = idx; | ||
17313 | imux->num_items++; | ||
17314 | } | ||
17315 | } | ||
17316 | } | ||
17317 | return 0; | ||
17318 | } | ||
17319 | 17260 | ||
17320 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | 17261 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, |
17321 | hda_nid_t nid, int pin_type, | 17262 | hda_nid_t nid, int pin_type, |
@@ -17369,7 +17310,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec) | |||
17369 | 17310 | ||
17370 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 17311 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
17371 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 17312 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
17372 | if (alc662_is_input_pin(codec, nid)) { | 17313 | if (alc_is_input_pin(codec, nid)) { |
17373 | alc_set_input_pin(codec, nid, i); | 17314 | alc_set_input_pin(codec, nid, i); |
17374 | if (nid != ALC662_PIN_CD_NID && | 17315 | if (nid != ALC662_PIN_CD_NID && |
17375 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 17316 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
@@ -17410,7 +17351,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec) | |||
17410 | "Headphone"); | 17351 | "Headphone"); |
17411 | if (err < 0) | 17352 | if (err < 0) |
17412 | return err; | 17353 | return err; |
17413 | err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg); | 17354 | err = alc662_auto_create_input_ctls(codec, &spec->autocfg); |
17414 | if (err < 0) | 17355 | if (err < 0) |
17415 | return err; | 17356 | return err; |
17416 | 17357 | ||
@@ -17467,8 +17408,8 @@ static int patch_alc662(struct hda_codec *codec) | |||
17467 | alc662_models, | 17408 | alc662_models, |
17468 | alc662_cfg_tbl); | 17409 | alc662_cfg_tbl); |
17469 | if (board_config < 0) { | 17410 | if (board_config < 0) { |
17470 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 17411 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
17471 | "trying auto-probe from BIOS...\n", codec->chip_name); | 17412 | codec->chip_name); |
17472 | board_config = ALC662_AUTO; | 17413 | board_config = ALC662_AUTO; |
17473 | } | 17414 | } |
17474 | 17415 | ||
@@ -17493,7 +17434,7 @@ static int patch_alc662(struct hda_codec *codec) | |||
17493 | } | 17434 | } |
17494 | 17435 | ||
17495 | if (board_config != ALC662_AUTO) | 17436 | if (board_config != ALC662_AUTO) |
17496 | setup_preset(spec, &alc662_presets[board_config]); | 17437 | setup_preset(codec, &alc662_presets[board_config]); |
17497 | 17438 | ||
17498 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | 17439 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
17499 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | 17440 | spec->stream_analog_capture = &alc662_pcm_analog_capture; |
@@ -17509,7 +17450,7 @@ static int patch_alc662(struct hda_codec *codec) | |||
17509 | spec->capsrc_nids = alc662_capsrc_nids; | 17450 | spec->capsrc_nids = alc662_capsrc_nids; |
17510 | 17451 | ||
17511 | if (!spec->cap_mixer) | 17452 | if (!spec->cap_mixer) |
17512 | set_capture_mixer(spec); | 17453 | set_capture_mixer(codec); |
17513 | if (codec->vendor_id == 0x10ec0662) | 17454 | if (codec->vendor_id == 0x10ec0662) |
17514 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 17455 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
17515 | else | 17456 | else |
@@ -17545,23 +17486,23 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
17545 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | 17486 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
17546 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | 17487 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
17547 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", | 17488 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
17548 | .patch = patch_alc883 }, | 17489 | .patch = patch_alc882 }, |
17549 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | 17490 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
17550 | .patch = patch_alc662 }, | 17491 | .patch = patch_alc662 }, |
17551 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, | 17492 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
17552 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, | 17493 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
17553 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, | 17494 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
17554 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, | 17495 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
17555 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", | 17496 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
17556 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | 17497 | .patch = patch_alc882 }, |
17557 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", | 17498 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
17558 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | 17499 | .patch = patch_alc882 }, |
17559 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, | 17500 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
17560 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, | 17501 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
17561 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", | 17502 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
17562 | .patch = patch_alc883 }, | 17503 | .patch = patch_alc882 }, |
17563 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, | 17504 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
17564 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, | 17505 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
17565 | {} /* terminator */ | 17506 | {} /* terminator */ |
17566 | }; | 17507 | }; |
17567 | 17508 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 456ef6ac12e4..e31e53dc6962 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -40,6 +40,8 @@ enum { | |||
40 | STAC_INSERT_EVENT, | 40 | STAC_INSERT_EVENT, |
41 | STAC_PWR_EVENT, | 41 | STAC_PWR_EVENT, |
42 | STAC_HP_EVENT, | 42 | STAC_HP_EVENT, |
43 | STAC_LO_EVENT, | ||
44 | STAC_MIC_EVENT, | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | enum { | 47 | enum { |
@@ -76,10 +78,12 @@ enum { | |||
76 | STAC_92HD73XX_AUTO, | 78 | STAC_92HD73XX_AUTO, |
77 | STAC_92HD73XX_NO_JD, /* no jack-detection */ | 79 | STAC_92HD73XX_NO_JD, /* no jack-detection */ |
78 | STAC_92HD73XX_REF, | 80 | STAC_92HD73XX_REF, |
81 | STAC_92HD73XX_INTEL, | ||
79 | STAC_DELL_M6_AMIC, | 82 | STAC_DELL_M6_AMIC, |
80 | STAC_DELL_M6_DMIC, | 83 | STAC_DELL_M6_DMIC, |
81 | STAC_DELL_M6_BOTH, | 84 | STAC_DELL_M6_BOTH, |
82 | STAC_DELL_EQ, | 85 | STAC_DELL_EQ, |
86 | STAC_ALIENWARE_M17X, | ||
83 | STAC_92HD73XX_MODELS | 87 | STAC_92HD73XX_MODELS |
84 | }; | 88 | }; |
85 | 89 | ||
@@ -176,6 +180,12 @@ struct sigmatel_jack { | |||
176 | struct snd_jack *jack; | 180 | struct snd_jack *jack; |
177 | }; | 181 | }; |
178 | 182 | ||
183 | struct sigmatel_mic_route { | ||
184 | hda_nid_t pin; | ||
185 | unsigned char mux_idx; | ||
186 | unsigned char dmux_idx; | ||
187 | }; | ||
188 | |||
179 | struct sigmatel_spec { | 189 | struct sigmatel_spec { |
180 | struct snd_kcontrol_new *mixers[4]; | 190 | struct snd_kcontrol_new *mixers[4]; |
181 | unsigned int num_mixers; | 191 | unsigned int num_mixers; |
@@ -187,6 +197,7 @@ struct sigmatel_spec { | |||
187 | unsigned int hp_detect: 1; | 197 | unsigned int hp_detect: 1; |
188 | unsigned int spdif_mute: 1; | 198 | unsigned int spdif_mute: 1; |
189 | unsigned int check_volume_offset:1; | 199 | unsigned int check_volume_offset:1; |
200 | unsigned int auto_mic:1; | ||
190 | 201 | ||
191 | /* gpio lines */ | 202 | /* gpio lines */ |
192 | unsigned int eapd_mask; | 203 | unsigned int eapd_mask; |
@@ -218,7 +229,6 @@ struct sigmatel_spec { | |||
218 | 229 | ||
219 | /* playback */ | 230 | /* playback */ |
220 | struct hda_input_mux *mono_mux; | 231 | struct hda_input_mux *mono_mux; |
221 | struct hda_input_mux *amp_mux; | ||
222 | unsigned int cur_mmux; | 232 | unsigned int cur_mmux; |
223 | struct hda_multi_out multiout; | 233 | struct hda_multi_out multiout; |
224 | hda_nid_t dac_nids[5]; | 234 | hda_nid_t dac_nids[5]; |
@@ -238,6 +248,15 @@ struct sigmatel_spec { | |||
238 | unsigned int num_dmuxes; | 248 | unsigned int num_dmuxes; |
239 | hda_nid_t *smux_nids; | 249 | hda_nid_t *smux_nids; |
240 | unsigned int num_smuxes; | 250 | unsigned int num_smuxes; |
251 | unsigned int num_analog_muxes; | ||
252 | |||
253 | unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ | ||
254 | unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ | ||
255 | unsigned int num_caps; /* number of capture volume/switch elements */ | ||
256 | |||
257 | struct sigmatel_mic_route ext_mic; | ||
258 | struct sigmatel_mic_route int_mic; | ||
259 | |||
241 | const char **spdif_labels; | 260 | const char **spdif_labels; |
242 | 261 | ||
243 | hda_nid_t dig_in_nid; | 262 | hda_nid_t dig_in_nid; |
@@ -262,7 +281,6 @@ struct sigmatel_spec { | |||
262 | unsigned int cur_smux[2]; | 281 | unsigned int cur_smux[2]; |
263 | unsigned int cur_amux; | 282 | unsigned int cur_amux; |
264 | hda_nid_t *amp_nids; | 283 | hda_nid_t *amp_nids; |
265 | unsigned int num_amps; | ||
266 | unsigned int powerdown_adcs; | 284 | unsigned int powerdown_adcs; |
267 | 285 | ||
268 | /* i/o switches */ | 286 | /* i/o switches */ |
@@ -281,7 +299,6 @@ struct sigmatel_spec { | |||
281 | struct hda_input_mux private_dimux; | 299 | struct hda_input_mux private_dimux; |
282 | struct hda_input_mux private_imux; | 300 | struct hda_input_mux private_imux; |
283 | struct hda_input_mux private_smux; | 301 | struct hda_input_mux private_smux; |
284 | struct hda_input_mux private_amp_mux; | ||
285 | struct hda_input_mux private_mono_mux; | 302 | struct hda_input_mux private_mono_mux; |
286 | }; | 303 | }; |
287 | 304 | ||
@@ -310,11 +327,6 @@ static hda_nid_t stac92hd73xx_adc_nids[2] = { | |||
310 | 0x1a, 0x1b | 327 | 0x1a, 0x1b |
311 | }; | 328 | }; |
312 | 329 | ||
313 | #define DELL_M6_AMP 2 | ||
314 | static hda_nid_t stac92hd73xx_amp_nids[3] = { | ||
315 | 0x0b, 0x0c, 0x0e | ||
316 | }; | ||
317 | |||
318 | #define STAC92HD73XX_NUM_DMICS 2 | 330 | #define STAC92HD73XX_NUM_DMICS 2 |
319 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | 331 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
320 | 0x13, 0x14, 0 | 332 | 0x13, 0x14, 0 |
@@ -322,8 +334,8 @@ static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | |||
322 | 334 | ||
323 | #define STAC92HD73_DAC_COUNT 5 | 335 | #define STAC92HD73_DAC_COUNT 5 |
324 | 336 | ||
325 | static hda_nid_t stac92hd73xx_mux_nids[4] = { | 337 | static hda_nid_t stac92hd73xx_mux_nids[2] = { |
326 | 0x28, 0x29, 0x2a, 0x2b, | 338 | 0x20, 0x21, |
327 | }; | 339 | }; |
328 | 340 | ||
329 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { | 341 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
@@ -334,14 +346,16 @@ static hda_nid_t stac92hd73xx_smux_nids[2] = { | |||
334 | 0x22, 0x23, | 346 | 0x22, 0x23, |
335 | }; | 347 | }; |
336 | 348 | ||
337 | #define STAC92HD83XXX_NUM_DMICS 2 | 349 | #define STAC92HD73XX_NUM_CAPS 2 |
338 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { | 350 | static unsigned long stac92hd73xx_capvols[] = { |
339 | 0x11, 0x12, 0 | 351 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
352 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
340 | }; | 353 | }; |
354 | #define stac92hd73xx_capsws stac92hd73xx_capvols | ||
341 | 355 | ||
342 | #define STAC92HD83_DAC_COUNT 3 | 356 | #define STAC92HD83_DAC_COUNT 3 |
343 | 357 | ||
344 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { | 358 | static hda_nid_t stac92hd83xxx_mux_nids[2] = { |
345 | 0x17, 0x18, | 359 | 0x17, 0x18, |
346 | }; | 360 | }; |
347 | 361 | ||
@@ -361,9 +375,12 @@ static unsigned int stac92hd83xxx_pwr_mapping[4] = { | |||
361 | 0x03, 0x0c, 0x20, 0x40, | 375 | 0x03, 0x0c, 0x20, 0x40, |
362 | }; | 376 | }; |
363 | 377 | ||
364 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { | 378 | #define STAC92HD83XXX_NUM_CAPS 2 |
365 | 0xc, | 379 | static unsigned long stac92hd83xxx_capvols[] = { |
380 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
381 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), | ||
366 | }; | 382 | }; |
383 | #define stac92hd83xxx_capsws stac92hd83xxx_capvols | ||
367 | 384 | ||
368 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { | 385 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
369 | 0x0a, 0x0d, 0x0f | 386 | 0x0a, 0x0d, 0x0f |
@@ -394,6 +411,13 @@ static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { | |||
394 | 0x22, 0 | 411 | 0x22, 0 |
395 | }; | 412 | }; |
396 | 413 | ||
414 | #define STAC92HD71BXX_NUM_CAPS 2 | ||
415 | static unsigned long stac92hd71bxx_capvols[] = { | ||
416 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), | ||
417 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | ||
418 | }; | ||
419 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols | ||
420 | |||
397 | static hda_nid_t stac925x_adc_nids[1] = { | 421 | static hda_nid_t stac925x_adc_nids[1] = { |
398 | 0x03, | 422 | 0x03, |
399 | }; | 423 | }; |
@@ -415,6 +439,13 @@ static hda_nid_t stac925x_dmux_nids[1] = { | |||
415 | 0x14, | 439 | 0x14, |
416 | }; | 440 | }; |
417 | 441 | ||
442 | static unsigned long stac925x_capvols[] = { | ||
443 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | ||
444 | }; | ||
445 | static unsigned long stac925x_capsws[] = { | ||
446 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | ||
447 | }; | ||
448 | |||
418 | static hda_nid_t stac922x_adc_nids[2] = { | 449 | static hda_nid_t stac922x_adc_nids[2] = { |
419 | 0x06, 0x07, | 450 | 0x06, 0x07, |
420 | }; | 451 | }; |
@@ -423,6 +454,13 @@ static hda_nid_t stac922x_mux_nids[2] = { | |||
423 | 0x12, 0x13, | 454 | 0x12, 0x13, |
424 | }; | 455 | }; |
425 | 456 | ||
457 | #define STAC922X_NUM_CAPS 2 | ||
458 | static unsigned long stac922x_capvols[] = { | ||
459 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), | ||
460 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), | ||
461 | }; | ||
462 | #define stac922x_capsws stac922x_capvols | ||
463 | |||
426 | static hda_nid_t stac927x_slave_dig_outs[2] = { | 464 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
427 | 0x1f, 0, | 465 | 0x1f, 0, |
428 | }; | 466 | }; |
@@ -452,6 +490,18 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { | |||
452 | 0x13, 0x14, 0 | 490 | 0x13, 0x14, 0 |
453 | }; | 491 | }; |
454 | 492 | ||
493 | #define STAC927X_NUM_CAPS 3 | ||
494 | static unsigned long stac927x_capvols[] = { | ||
495 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), | ||
496 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), | ||
497 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), | ||
498 | }; | ||
499 | static unsigned long stac927x_capsws[] = { | ||
500 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | ||
501 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), | ||
502 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | ||
503 | }; | ||
504 | |||
455 | static const char *stac927x_spdif_labels[5] = { | 505 | static const char *stac927x_spdif_labels[5] = { |
456 | "Digital Playback", "ADAT", "Analog Mux 1", | 506 | "Digital Playback", "ADAT", "Analog Mux 1", |
457 | "Analog Mux 2", "Analog Mux 3" | 507 | "Analog Mux 2", "Analog Mux 3" |
@@ -478,6 +528,16 @@ static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { | |||
478 | 0x17, 0x18, 0 | 528 | 0x17, 0x18, 0 |
479 | }; | 529 | }; |
480 | 530 | ||
531 | #define STAC9205_NUM_CAPS 2 | ||
532 | static unsigned long stac9205_capvols[] = { | ||
533 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), | ||
534 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), | ||
535 | }; | ||
536 | static unsigned long stac9205_capsws[] = { | ||
537 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | ||
538 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), | ||
539 | }; | ||
540 | |||
481 | static hda_nid_t stac9200_pin_nids[8] = { | 541 | static hda_nid_t stac9200_pin_nids[8] = { |
482 | 0x08, 0x09, 0x0d, 0x0e, | 542 | 0x08, 0x09, 0x0d, 0x0e, |
483 | 0x0f, 0x10, 0x11, 0x12, | 543 | 0x0f, 0x10, 0x11, 0x12, |
@@ -528,34 +588,6 @@ static hda_nid_t stac9205_pin_nids[12] = { | |||
528 | 0x21, 0x22, | 588 | 0x21, 0x22, |
529 | }; | 589 | }; |
530 | 590 | ||
531 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info | ||
532 | |||
533 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, | ||
534 | struct snd_ctl_elem_value *ucontrol) | ||
535 | { | ||
536 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
537 | struct sigmatel_spec *spec = codec->spec; | ||
538 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; | ||
539 | |||
540 | kcontrol->private_value ^= get_amp_nid(kcontrol); | ||
541 | kcontrol->private_value |= nid; | ||
542 | |||
543 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); | ||
544 | } | ||
545 | |||
546 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, | ||
547 | struct snd_ctl_elem_value *ucontrol) | ||
548 | { | ||
549 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
550 | struct sigmatel_spec *spec = codec->spec; | ||
551 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; | ||
552 | |||
553 | kcontrol->private_value ^= get_amp_nid(kcontrol); | ||
554 | kcontrol->private_value |= nid; | ||
555 | |||
556 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); | ||
557 | } | ||
558 | |||
559 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, | 591 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
560 | struct snd_ctl_elem_info *uinfo) | 592 | struct snd_ctl_elem_info *uinfo) |
561 | { | 593 | { |
@@ -692,9 +724,35 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
692 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 724 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
693 | struct sigmatel_spec *spec = codec->spec; | 725 | struct sigmatel_spec *spec = codec->spec; |
694 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 726 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
695 | 727 | const struct hda_input_mux *imux = spec->input_mux; | |
696 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | 728 | unsigned int idx, prev_idx; |
697 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); | 729 | |
730 | idx = ucontrol->value.enumerated.item[0]; | ||
731 | if (idx >= imux->num_items) | ||
732 | idx = imux->num_items - 1; | ||
733 | prev_idx = spec->cur_mux[adc_idx]; | ||
734 | if (prev_idx == idx) | ||
735 | return 0; | ||
736 | if (idx < spec->num_analog_muxes) { | ||
737 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, | ||
738 | AC_VERB_SET_CONNECT_SEL, | ||
739 | imux->items[idx].index); | ||
740 | if (prev_idx >= spec->num_analog_muxes) { | ||
741 | imux = spec->dinput_mux; | ||
742 | /* 0 = analog */ | ||
743 | snd_hda_codec_write_cache(codec, | ||
744 | spec->dmux_nids[adc_idx], 0, | ||
745 | AC_VERB_SET_CONNECT_SEL, | ||
746 | imux->items[0].index); | ||
747 | } | ||
748 | } else { | ||
749 | imux = spec->dinput_mux; | ||
750 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, | ||
751 | AC_VERB_SET_CONNECT_SEL, | ||
752 | imux->items[idx - 1].index); | ||
753 | } | ||
754 | spec->cur_mux[adc_idx] = idx; | ||
755 | return 1; | ||
698 | } | 756 | } |
699 | 757 | ||
700 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, | 758 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
@@ -725,41 +783,6 @@ static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
725 | spec->mono_nid, &spec->cur_mmux); | 783 | spec->mono_nid, &spec->cur_mmux); |
726 | } | 784 | } |
727 | 785 | ||
728 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, | ||
729 | struct snd_ctl_elem_info *uinfo) | ||
730 | { | ||
731 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
732 | struct sigmatel_spec *spec = codec->spec; | ||
733 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); | ||
734 | } | ||
735 | |||
736 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, | ||
737 | struct snd_ctl_elem_value *ucontrol) | ||
738 | { | ||
739 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
740 | struct sigmatel_spec *spec = codec->spec; | ||
741 | |||
742 | ucontrol->value.enumerated.item[0] = spec->cur_amux; | ||
743 | return 0; | ||
744 | } | ||
745 | |||
746 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, | ||
747 | struct snd_ctl_elem_value *ucontrol) | ||
748 | { | ||
749 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
750 | struct sigmatel_spec *spec = codec->spec; | ||
751 | struct snd_kcontrol *ctl = | ||
752 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); | ||
753 | if (!ctl) | ||
754 | return -EINVAL; | ||
755 | |||
756 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | | ||
757 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | ||
758 | |||
759 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, | ||
760 | 0, &spec->cur_amux); | ||
761 | } | ||
762 | |||
763 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info | 786 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
764 | 787 | ||
765 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, | 788 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
@@ -827,84 +850,16 @@ static struct hda_verb stac9200_eapd_init[] = { | |||
827 | {} | 850 | {} |
828 | }; | 851 | }; |
829 | 852 | ||
830 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { | ||
831 | /* set master volume and direct control */ | ||
832 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
833 | /* setup adcs to point to mixer */ | ||
834 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
835 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
836 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
837 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
838 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
839 | /* setup import muxs */ | ||
840 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
841 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
842 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
843 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
844 | {} | ||
845 | }; | ||
846 | |||
847 | static struct hda_verb dell_eq_core_init[] = { | 853 | static struct hda_verb dell_eq_core_init[] = { |
848 | /* set master volume to max value without distortion | 854 | /* set master volume to max value without distortion |
849 | * and direct control */ | 855 | * and direct control */ |
850 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, | 856 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
851 | /* setup adcs to point to mixer */ | ||
852 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
853 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
854 | /* setup import muxs */ | ||
855 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
856 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
857 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
858 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
859 | {} | ||
860 | }; | ||
861 | |||
862 | static struct hda_verb dell_m6_core_init[] = { | ||
863 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
864 | /* setup adcs to point to mixer */ | ||
865 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
866 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
867 | /* setup import muxs */ | ||
868 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
869 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
870 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
871 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
872 | {} | ||
873 | }; | ||
874 | |||
875 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { | ||
876 | /* set master volume and direct control */ | ||
877 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
878 | /* setup adcs to point to mixer */ | ||
879 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
880 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
881 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
882 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
883 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
884 | /* setup import muxs */ | ||
885 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
886 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
887 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
888 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
889 | {} | 857 | {} |
890 | }; | 858 | }; |
891 | 859 | ||
892 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { | 860 | static struct hda_verb stac92hd73xx_core_init[] = { |
893 | /* set master volume and direct control */ | 861 | /* set master volume and direct control */ |
894 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 862 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
895 | /* dac3 is connected to import3 mux */ | ||
896 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, | ||
897 | /* setup adcs to point to mixer */ | ||
898 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
899 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
900 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
901 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
902 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
903 | /* setup import muxs */ | ||
904 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
905 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
906 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
907 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
908 | {} | 863 | {} |
909 | }; | 864 | }; |
910 | 865 | ||
@@ -924,19 +879,6 @@ static struct hda_verb stac92hd71bxx_core_init[] = { | |||
924 | {} | 879 | {} |
925 | }; | 880 | }; |
926 | 881 | ||
927 | #define HD_DISABLE_PORTF 1 | ||
928 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { | ||
929 | /* start of config #1 */ | ||
930 | |||
931 | /* connect port 0f to audio mixer */ | ||
932 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, | ||
933 | /* start of config #2 */ | ||
934 | |||
935 | /* set master volume and direct control */ | ||
936 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
937 | {} | ||
938 | }; | ||
939 | |||
940 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { | 882 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
941 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ | 883 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
942 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 884 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
@@ -995,31 +937,6 @@ static struct hda_verb stac9205_core_init[] = { | |||
995 | .put = stac92xx_mono_mux_enum_put, \ | 937 | .put = stac92xx_mono_mux_enum_put, \ |
996 | } | 938 | } |
997 | 939 | ||
998 | #define STAC_AMP_MUX \ | ||
999 | { \ | ||
1000 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1001 | .name = "Amp Selector Capture Switch", \ | ||
1002 | .count = 1, \ | ||
1003 | .info = stac92xx_amp_mux_enum_info, \ | ||
1004 | .get = stac92xx_amp_mux_enum_get, \ | ||
1005 | .put = stac92xx_amp_mux_enum_put, \ | ||
1006 | } | ||
1007 | |||
1008 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ | ||
1009 | { \ | ||
1010 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1011 | .name = xname, \ | ||
1012 | .index = 0, \ | ||
1013 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
1014 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | ||
1015 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | ||
1016 | .info = stac92xx_amp_volume_info, \ | ||
1017 | .get = stac92xx_amp_volume_get, \ | ||
1018 | .put = stac92xx_amp_volume_put, \ | ||
1019 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ | ||
1020 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ | ||
1021 | } | ||
1022 | |||
1023 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ | 940 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
1024 | { \ | 941 | { \ |
1025 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 942 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
@@ -1050,34 +967,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = { | |||
1050 | { } /* end */ | 967 | { } /* end */ |
1051 | }; | 968 | }; |
1052 | 969 | ||
1053 | #define DELL_M6_MIXER 6 | ||
1054 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { | ||
1055 | /* start of config #1 */ | ||
1056 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | ||
1057 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | ||
1058 | |||
1059 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | ||
1060 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | ||
1061 | |||
1062 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | ||
1063 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | ||
1064 | |||
1065 | /* start of config #2 */ | ||
1066 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | ||
1067 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | ||
1068 | |||
1069 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | ||
1070 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | ||
1071 | |||
1072 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1073 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1074 | |||
1075 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1076 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1077 | |||
1078 | { } /* end */ | ||
1079 | }; | ||
1080 | |||
1081 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { | 970 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
1082 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), | 971 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
1083 | {} | 972 | {} |
@@ -1093,134 +982,14 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { | |||
1093 | {} | 982 | {} |
1094 | }; | 983 | }; |
1095 | 984 | ||
1096 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { | ||
1097 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1098 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1099 | |||
1100 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1101 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1102 | |||
1103 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | ||
1104 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | ||
1105 | |||
1106 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | ||
1107 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | ||
1108 | |||
1109 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | ||
1110 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | ||
1111 | |||
1112 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | ||
1113 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | ||
1114 | |||
1115 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | ||
1116 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | ||
1117 | { } /* end */ | ||
1118 | }; | ||
1119 | |||
1120 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { | ||
1121 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1122 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1123 | |||
1124 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1125 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1126 | |||
1127 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | ||
1128 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | ||
1129 | |||
1130 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | ||
1131 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | ||
1132 | |||
1133 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | ||
1134 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | ||
1135 | |||
1136 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | ||
1137 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | ||
1138 | |||
1139 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | ||
1140 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | ||
1141 | { } /* end */ | ||
1142 | }; | ||
1143 | |||
1144 | |||
1145 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { | ||
1146 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), | ||
1147 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), | ||
1148 | |||
1149 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), | ||
1150 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), | ||
1151 | |||
1152 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), | ||
1153 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), | ||
1154 | |||
1155 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), | ||
1156 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), | ||
1157 | |||
1158 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), | ||
1159 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), | ||
1160 | |||
1161 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), | ||
1162 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), | ||
1163 | |||
1164 | /* | ||
1165 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), | ||
1166 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), | ||
1167 | */ | ||
1168 | { } /* end */ | ||
1169 | }; | ||
1170 | |||
1171 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { | ||
1172 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1173 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1174 | |||
1175 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1176 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1177 | /* analog pc-beep replaced with digital beep support */ | ||
1178 | /* | ||
1179 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), | ||
1180 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), | ||
1181 | */ | ||
1182 | |||
1183 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), | ||
1184 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), | ||
1185 | |||
1186 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), | ||
1187 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), | ||
1188 | |||
1189 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), | ||
1190 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), | ||
1191 | |||
1192 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), | ||
1193 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), | ||
1194 | { } /* end */ | ||
1195 | }; | ||
1196 | 985 | ||
1197 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { | 986 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
1198 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) | 987 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
1199 | }; | 988 | }; |
1200 | 989 | ||
1201 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { | ||
1202 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1203 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1204 | |||
1205 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1206 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1207 | { } /* end */ | ||
1208 | }; | ||
1209 | |||
1210 | static struct snd_kcontrol_new stac925x_mixer[] = { | 990 | static struct snd_kcontrol_new stac925x_mixer[] = { |
1211 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), | 991 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
1212 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), | 992 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
1213 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), | ||
1214 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), | ||
1215 | { } /* end */ | ||
1216 | }; | ||
1217 | |||
1218 | static struct snd_kcontrol_new stac9205_mixer[] = { | ||
1219 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), | ||
1220 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), | ||
1221 | |||
1222 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), | ||
1223 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), | ||
1224 | { } /* end */ | 993 | { } /* end */ |
1225 | }; | 994 | }; |
1226 | 995 | ||
@@ -1229,29 +998,6 @@ static struct snd_kcontrol_new stac9205_loopback[] = { | |||
1229 | {} | 998 | {} |
1230 | }; | 999 | }; |
1231 | 1000 | ||
1232 | /* This needs to be generated dynamically based on sequence */ | ||
1233 | static struct snd_kcontrol_new stac922x_mixer[] = { | ||
1234 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), | ||
1235 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), | ||
1236 | |||
1237 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), | ||
1238 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), | ||
1239 | { } /* end */ | ||
1240 | }; | ||
1241 | |||
1242 | |||
1243 | static struct snd_kcontrol_new stac927x_mixer[] = { | ||
1244 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), | ||
1245 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), | ||
1246 | |||
1247 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), | ||
1248 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), | ||
1249 | |||
1250 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), | ||
1251 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), | ||
1252 | { } /* end */ | ||
1253 | }; | ||
1254 | |||
1255 | static struct snd_kcontrol_new stac927x_loopback[] = { | 1001 | static struct snd_kcontrol_new stac927x_loopback[] = { |
1256 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), | 1002 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
1257 | {} | 1003 | {} |
@@ -1309,16 +1055,19 @@ static int stac92xx_build_controls(struct hda_codec *codec) | |||
1309 | int err; | 1055 | int err; |
1310 | int i; | 1056 | int i; |
1311 | 1057 | ||
1312 | err = snd_hda_add_new_ctls(codec, spec->mixer); | 1058 | if (spec->mixer) { |
1313 | if (err < 0) | 1059 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
1314 | return err; | 1060 | if (err < 0) |
1061 | return err; | ||
1062 | } | ||
1315 | 1063 | ||
1316 | for (i = 0; i < spec->num_mixers; i++) { | 1064 | for (i = 0; i < spec->num_mixers; i++) { |
1317 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | 1065 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
1318 | if (err < 0) | 1066 | if (err < 0) |
1319 | return err; | 1067 | return err; |
1320 | } | 1068 | } |
1321 | if (spec->num_dmuxes > 0) { | 1069 | if (!spec->auto_mic && spec->num_dmuxes > 0 && |
1070 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { | ||
1322 | stac_dmux_mixer.count = spec->num_dmuxes; | 1071 | stac_dmux_mixer.count = spec->num_dmuxes; |
1323 | err = snd_hda_ctl_add(codec, | 1072 | err = snd_hda_ctl_add(codec, |
1324 | snd_ctl_new1(&stac_dmux_mixer, codec)); | 1073 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
@@ -1765,22 +1514,32 @@ static unsigned int dell_m6_pin_configs[13] = { | |||
1765 | 0x4f0000f0, | 1514 | 0x4f0000f0, |
1766 | }; | 1515 | }; |
1767 | 1516 | ||
1517 | static unsigned int alienware_m17x_pin_configs[13] = { | ||
1518 | 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020, | ||
1519 | 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0, | ||
1520 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, | ||
1521 | 0x904601b0, | ||
1522 | }; | ||
1523 | |||
1768 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | 1524 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
1769 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, | 1525 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
1770 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, | 1526 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
1771 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, | 1527 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
1772 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, | 1528 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
1773 | [STAC_DELL_EQ] = dell_m6_pin_configs, | 1529 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
1530 | [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs, | ||
1774 | }; | 1531 | }; |
1775 | 1532 | ||
1776 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { | 1533 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
1777 | [STAC_92HD73XX_AUTO] = "auto", | 1534 | [STAC_92HD73XX_AUTO] = "auto", |
1778 | [STAC_92HD73XX_NO_JD] = "no-jd", | 1535 | [STAC_92HD73XX_NO_JD] = "no-jd", |
1779 | [STAC_92HD73XX_REF] = "ref", | 1536 | [STAC_92HD73XX_REF] = "ref", |
1537 | [STAC_92HD73XX_INTEL] = "intel", | ||
1780 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", | 1538 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
1781 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", | 1539 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
1782 | [STAC_DELL_M6_BOTH] = "dell-m6", | 1540 | [STAC_DELL_M6_BOTH] = "dell-m6", |
1783 | [STAC_DELL_EQ] = "dell-eq", | 1541 | [STAC_DELL_EQ] = "dell-eq", |
1542 | [STAC_ALIENWARE_M17X] = "alienware", | ||
1784 | }; | 1543 | }; |
1785 | 1544 | ||
1786 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | 1545 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
@@ -1789,6 +1548,10 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |||
1789 | "DFI LanParty", STAC_92HD73XX_REF), | 1548 | "DFI LanParty", STAC_92HD73XX_REF), |
1790 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1791 | "DFI LanParty", STAC_92HD73XX_REF), | 1550 | "DFI LanParty", STAC_92HD73XX_REF), |
1551 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, | ||
1552 | "Intel DG45ID", STAC_92HD73XX_INTEL), | ||
1553 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, | ||
1554 | "Intel DG45FC", STAC_92HD73XX_INTEL), | ||
1792 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, | 1555 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
1793 | "Dell Studio 1535", STAC_DELL_M6_DMIC), | 1556 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, | 1557 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
@@ -1814,6 +1577,12 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |||
1814 | {} /* terminator */ | 1577 | {} /* terminator */ |
1815 | }; | 1578 | }; |
1816 | 1579 | ||
1580 | static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = { | ||
1581 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1, | ||
1582 | "Alienware M17x", STAC_ALIENWARE_M17X), | ||
1583 | {} /* terminator */ | ||
1584 | }; | ||
1585 | |||
1817 | static unsigned int ref92hd83xxx_pin_configs[10] = { | 1586 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
1818 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, | 1587 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
1819 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, | 1588 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
@@ -1921,6 +1690,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |||
1921 | "HP mini 1000", STAC_HP_M4), | 1690 | "HP mini 1000", STAC_HP_M4), |
1922 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, | 1691 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
1923 | "HP HDX", STAC_HP_HDX), /* HDX16 */ | 1692 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
1693 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, | ||
1694 | "HP", STAC_HP_DV5), | ||
1924 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, | 1695 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
1925 | "unknown Dell", STAC_DELL_M4_1), | 1696 | "unknown Dell", STAC_DELL_M4_1), |
1926 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, | 1697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
@@ -2636,8 +2407,7 @@ static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, | |||
2636 | return 0; | 2407 | return 0; |
2637 | } | 2408 | } |
2638 | 2409 | ||
2639 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, | 2410 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid); |
2640 | unsigned char type); | ||
2641 | 2411 | ||
2642 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | 2412 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
2643 | struct snd_ctl_elem_value *ucontrol) | 2413 | struct snd_ctl_elem_value *ucontrol) |
@@ -2651,7 +2421,7 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | |||
2651 | /* check to be sure that the ports are upto date with | 2421 | /* check to be sure that the ports are upto date with |
2652 | * switch changes | 2422 | * switch changes |
2653 | */ | 2423 | */ |
2654 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); | 2424 | stac_issue_unsol_event(codec, nid); |
2655 | 2425 | ||
2656 | return 1; | 2426 | return 1; |
2657 | } | 2427 | } |
@@ -2784,7 +2554,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
2784 | * appropriately according to the pin direction | 2554 | * appropriately according to the pin direction |
2785 | */ | 2555 | */ |
2786 | if (spec->hp_detect) | 2556 | if (spec->hp_detect) |
2787 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); | 2557 | stac_issue_unsol_event(codec, nid); |
2788 | 2558 | ||
2789 | return 1; | 2559 | return 1; |
2790 | } | 2560 | } |
@@ -2853,8 +2623,6 @@ enum { | |||
2853 | STAC_CTL_WIDGET_VOL, | 2623 | STAC_CTL_WIDGET_VOL, |
2854 | STAC_CTL_WIDGET_MUTE, | 2624 | STAC_CTL_WIDGET_MUTE, |
2855 | STAC_CTL_WIDGET_MONO_MUX, | 2625 | STAC_CTL_WIDGET_MONO_MUX, |
2856 | STAC_CTL_WIDGET_AMP_MUX, | ||
2857 | STAC_CTL_WIDGET_AMP_VOL, | ||
2858 | STAC_CTL_WIDGET_HP_SWITCH, | 2626 | STAC_CTL_WIDGET_HP_SWITCH, |
2859 | STAC_CTL_WIDGET_IO_SWITCH, | 2627 | STAC_CTL_WIDGET_IO_SWITCH, |
2860 | STAC_CTL_WIDGET_CLFE_SWITCH, | 2628 | STAC_CTL_WIDGET_CLFE_SWITCH, |
@@ -2865,8 +2633,6 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = { | |||
2865 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), | 2633 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2866 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | 2634 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
2867 | STAC_MONO_MUX, | 2635 | STAC_MONO_MUX, |
2868 | STAC_AMP_MUX, | ||
2869 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), | ||
2870 | STAC_CODEC_HP_SWITCH(NULL), | 2636 | STAC_CODEC_HP_SWITCH(NULL), |
2871 | STAC_CODEC_IO_SWITCH(NULL, 0), | 2637 | STAC_CODEC_IO_SWITCH(NULL, 0), |
2872 | STAC_CODEC_CLFE_SWITCH(NULL, 0), | 2638 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
@@ -2967,6 +2733,8 @@ static int stac92xx_add_input_source(struct sigmatel_spec *spec) | |||
2967 | struct snd_kcontrol_new *knew; | 2733 | struct snd_kcontrol_new *knew; |
2968 | struct hda_input_mux *imux = &spec->private_imux; | 2734 | struct hda_input_mux *imux = &spec->private_imux; |
2969 | 2735 | ||
2736 | if (spec->auto_mic) | ||
2737 | return 0; /* no need for input source */ | ||
2970 | if (!spec->num_adcs || imux->num_items <= 1) | 2738 | if (!spec->num_adcs || imux->num_items <= 1) |
2971 | return 0; /* no need for input source control */ | 2739 | return 0; /* no need for input source control */ |
2972 | knew = stac_control_new(spec, &stac_input_src_temp, | 2740 | knew = stac_control_new(spec, &stac_input_src_temp, |
@@ -3060,7 +2828,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | |||
3060 | HDA_MAX_CONNECTIONS); | 2828 | HDA_MAX_CONNECTIONS); |
3061 | for (j = 0; j < conn_len; j++) { | 2829 | for (j = 0; j < conn_len; j++) { |
3062 | wcaps = get_wcaps(codec, conn[j]); | 2830 | wcaps = get_wcaps(codec, conn[j]); |
3063 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 2831 | wtype = get_wcaps_type(wcaps); |
3064 | /* we check only analog outputs */ | 2832 | /* we check only analog outputs */ |
3065 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) | 2833 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
3066 | continue; | 2834 | continue; |
@@ -3319,6 +3087,21 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, | |||
3319 | return 0; | 3087 | return 0; |
3320 | } | 3088 | } |
3321 | 3089 | ||
3090 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, | ||
3091 | unsigned long sw, int idx) | ||
3092 | { | ||
3093 | int err; | ||
3094 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, | ||
3095 | "Capture Volume", vol); | ||
3096 | if (err < 0) | ||
3097 | return err; | ||
3098 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, | ||
3099 | "Capture Switch", sw); | ||
3100 | if (err < 0) | ||
3101 | return err; | ||
3102 | return 0; | ||
3103 | } | ||
3104 | |||
3322 | /* add playback controls from the parsed DAC table */ | 3105 | /* add playback controls from the parsed DAC table */ |
3323 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | 3106 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
3324 | const struct auto_pin_cfg *cfg) | 3107 | const struct auto_pin_cfg *cfg) |
@@ -3392,7 +3175,7 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | |||
3392 | spec->mono_nid, | 3175 | spec->mono_nid, |
3393 | con_lst, | 3176 | con_lst, |
3394 | HDA_MAX_NUM_INPUTS); | 3177 | HDA_MAX_NUM_INPUTS); |
3395 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) | 3178 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
3396 | return -EINVAL; | 3179 | return -EINVAL; |
3397 | 3180 | ||
3398 | for (i = 0; i < num_cons; i++) { | 3181 | for (i = 0; i < num_cons; i++) { |
@@ -3406,37 +3189,6 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | |||
3406 | "Mono Mux", spec->mono_nid); | 3189 | "Mono Mux", spec->mono_nid); |
3407 | } | 3190 | } |
3408 | 3191 | ||
3409 | /* labels for amp mux outputs */ | ||
3410 | static const char *stac92xx_amp_labels[3] = { | ||
3411 | "Front Microphone", "Microphone", "Line In", | ||
3412 | }; | ||
3413 | |||
3414 | /* create amp out controls mux on capable codecs */ | ||
3415 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) | ||
3416 | { | ||
3417 | struct sigmatel_spec *spec = codec->spec; | ||
3418 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; | ||
3419 | int i, err; | ||
3420 | |||
3421 | for (i = 0; i < spec->num_amps; i++) { | ||
3422 | amp_mux->items[amp_mux->num_items].label = | ||
3423 | stac92xx_amp_labels[i]; | ||
3424 | amp_mux->items[amp_mux->num_items].index = i; | ||
3425 | amp_mux->num_items++; | ||
3426 | } | ||
3427 | |||
3428 | if (spec->num_amps > 1) { | ||
3429 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, | ||
3430 | "Amp Selector Capture Switch", 0); | ||
3431 | if (err < 0) | ||
3432 | return err; | ||
3433 | } | ||
3434 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, | ||
3435 | "Amp Capture Volume", | ||
3436 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); | ||
3437 | } | ||
3438 | |||
3439 | |||
3440 | /* create PC beep volume controls */ | 3192 | /* create PC beep volume controls */ |
3441 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | 3193 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
3442 | hda_nid_t nid) | 3194 | hda_nid_t nid) |
@@ -3505,19 +3257,33 @@ static int stac92xx_beep_switch_ctl(struct hda_codec *codec) | |||
3505 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) | 3257 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
3506 | { | 3258 | { |
3507 | struct sigmatel_spec *spec = codec->spec; | 3259 | struct sigmatel_spec *spec = codec->spec; |
3508 | int wcaps, nid, i, err = 0; | 3260 | int i, j, err = 0; |
3509 | 3261 | ||
3510 | for (i = 0; i < spec->num_muxes; i++) { | 3262 | for (i = 0; i < spec->num_muxes; i++) { |
3263 | hda_nid_t nid; | ||
3264 | unsigned int wcaps; | ||
3265 | unsigned long val; | ||
3266 | |||
3511 | nid = spec->mux_nids[i]; | 3267 | nid = spec->mux_nids[i]; |
3512 | wcaps = get_wcaps(codec, nid); | 3268 | wcaps = get_wcaps(codec, nid); |
3269 | if (!(wcaps & AC_WCAP_OUT_AMP)) | ||
3270 | continue; | ||
3513 | 3271 | ||
3514 | if (wcaps & AC_WCAP_OUT_AMP) { | 3272 | /* check whether already the same control was created as |
3515 | err = stac92xx_add_control_idx(spec, | 3273 | * normal Capture Volume. |
3516 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", | 3274 | */ |
3517 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 3275 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
3518 | if (err < 0) | 3276 | for (j = 0; j < spec->num_caps; j++) { |
3519 | return err; | 3277 | if (spec->capvols[j] == val) |
3278 | break; | ||
3520 | } | 3279 | } |
3280 | if (j < spec->num_caps) | ||
3281 | continue; | ||
3282 | |||
3283 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i, | ||
3284 | "Mux Capture Volume", val); | ||
3285 | if (err < 0) | ||
3286 | return err; | ||
3521 | } | 3287 | } |
3522 | return 0; | 3288 | return 0; |
3523 | }; | 3289 | }; |
@@ -3538,7 +3304,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) | |||
3538 | spec->smux_nids[0], | 3304 | spec->smux_nids[0], |
3539 | con_lst, | 3305 | con_lst, |
3540 | HDA_MAX_NUM_INPUTS); | 3306 | HDA_MAX_NUM_INPUTS); |
3541 | if (!num_cons) | 3307 | if (num_cons <= 0) |
3542 | return -EINVAL; | 3308 | return -EINVAL; |
3543 | 3309 | ||
3544 | if (!labels) | 3310 | if (!labels) |
@@ -3559,101 +3325,231 @@ static const char *stac92xx_dmic_labels[5] = { | |||
3559 | "Digital Mic 3", "Digital Mic 4" | 3325 | "Digital Mic 3", "Digital Mic 4" |
3560 | }; | 3326 | }; |
3561 | 3327 | ||
3328 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, | ||
3329 | hda_nid_t nid) | ||
3330 | { | ||
3331 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | ||
3332 | int i, nums; | ||
3333 | |||
3334 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | ||
3335 | for (i = 0; i < nums; i++) | ||
3336 | if (conn[i] == nid) | ||
3337 | return i; | ||
3338 | return -1; | ||
3339 | } | ||
3340 | |||
3341 | /* create a volume assigned to the given pin (only if supported) */ | ||
3342 | /* return 1 if the volume control is created */ | ||
3343 | static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, | ||
3344 | const char *label, int direction) | ||
3345 | { | ||
3346 | unsigned int caps, nums; | ||
3347 | char name[32]; | ||
3348 | int err; | ||
3349 | |||
3350 | if (direction == HDA_OUTPUT) | ||
3351 | caps = AC_WCAP_OUT_AMP; | ||
3352 | else | ||
3353 | caps = AC_WCAP_IN_AMP; | ||
3354 | if (!(get_wcaps(codec, nid) & caps)) | ||
3355 | return 0; | ||
3356 | caps = query_amp_caps(codec, nid, direction); | ||
3357 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; | ||
3358 | if (!nums) | ||
3359 | return 0; | ||
3360 | snprintf(name, sizeof(name), "%s Capture Volume", label); | ||
3361 | err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, | ||
3362 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); | ||
3363 | if (err < 0) | ||
3364 | return err; | ||
3365 | return 1; | ||
3366 | } | ||
3367 | |||
3562 | /* create playback/capture controls for input pins on dmic capable codecs */ | 3368 | /* create playback/capture controls for input pins on dmic capable codecs */ |
3563 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, | 3369 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
3564 | const struct auto_pin_cfg *cfg) | 3370 | const struct auto_pin_cfg *cfg) |
3565 | { | 3371 | { |
3566 | struct sigmatel_spec *spec = codec->spec; | 3372 | struct sigmatel_spec *spec = codec->spec; |
3373 | struct hda_input_mux *imux = &spec->private_imux; | ||
3567 | struct hda_input_mux *dimux = &spec->private_dimux; | 3374 | struct hda_input_mux *dimux = &spec->private_dimux; |
3568 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | 3375 | int err, i, active_mics; |
3569 | int err, i, j; | 3376 | unsigned int def_conf; |
3570 | char name[32]; | ||
3571 | 3377 | ||
3572 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; | 3378 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
3573 | dimux->items[dimux->num_items].index = 0; | 3379 | dimux->items[dimux->num_items].index = 0; |
3574 | dimux->num_items++; | 3380 | dimux->num_items++; |
3575 | 3381 | ||
3382 | active_mics = 0; | ||
3383 | for (i = 0; i < spec->num_dmics; i++) { | ||
3384 | /* check the validity: sometimes it's a dead vendor-spec node */ | ||
3385 | if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i])) | ||
3386 | != AC_WID_PIN) | ||
3387 | continue; | ||
3388 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); | ||
3389 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) | ||
3390 | active_mics++; | ||
3391 | } | ||
3392 | |||
3576 | for (i = 0; i < spec->num_dmics; i++) { | 3393 | for (i = 0; i < spec->num_dmics; i++) { |
3577 | hda_nid_t nid; | 3394 | hda_nid_t nid; |
3578 | int index; | 3395 | int index; |
3579 | int num_cons; | 3396 | const char *label; |
3580 | unsigned int wcaps; | ||
3581 | unsigned int def_conf; | ||
3582 | 3397 | ||
3583 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); | 3398 | nid = spec->dmic_nids[i]; |
3399 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | ||
3400 | continue; | ||
3401 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
3584 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | 3402 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
3585 | continue; | 3403 | continue; |
3586 | 3404 | ||
3587 | nid = spec->dmic_nids[i]; | 3405 | index = get_connection_index(codec, spec->dmux_nids[0], nid); |
3588 | num_cons = snd_hda_get_connections(codec, | 3406 | if (index < 0) |
3589 | spec->dmux_nids[0], | 3407 | continue; |
3590 | con_lst, | ||
3591 | HDA_MAX_NUM_INPUTS); | ||
3592 | for (j = 0; j < num_cons; j++) | ||
3593 | if (con_lst[j] == nid) { | ||
3594 | index = j; | ||
3595 | goto found; | ||
3596 | } | ||
3597 | continue; | ||
3598 | found: | ||
3599 | wcaps = get_wcaps(codec, nid) & | ||
3600 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); | ||
3601 | 3408 | ||
3602 | if (wcaps) { | 3409 | if (active_mics == 1) |
3603 | sprintf(name, "%s Capture Volume", | 3410 | label = "Digital Mic"; |
3604 | stac92xx_dmic_labels[dimux->num_items]); | 3411 | else |
3412 | label = stac92xx_dmic_labels[dimux->num_items]; | ||
3605 | 3413 | ||
3606 | err = stac92xx_add_control(spec, | 3414 | err = create_elem_capture_vol(codec, nid, label, HDA_INPUT); |
3607 | STAC_CTL_WIDGET_VOL, | 3415 | if (err < 0) |
3608 | name, | 3416 | return err; |
3609 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 3417 | if (!err) { |
3610 | (wcaps & AC_WCAP_OUT_AMP) ? | 3418 | err = create_elem_capture_vol(codec, nid, label, |
3611 | HDA_OUTPUT : HDA_INPUT)); | 3419 | HDA_OUTPUT); |
3612 | if (err < 0) | 3420 | if (err < 0) |
3613 | return err; | 3421 | return err; |
3614 | } | 3422 | } |
3615 | 3423 | ||
3616 | dimux->items[dimux->num_items].label = | 3424 | dimux->items[dimux->num_items].label = label; |
3617 | stac92xx_dmic_labels[dimux->num_items]; | ||
3618 | dimux->items[dimux->num_items].index = index; | 3425 | dimux->items[dimux->num_items].index = index; |
3619 | dimux->num_items++; | 3426 | dimux->num_items++; |
3427 | if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { | ||
3428 | imux->items[imux->num_items].label = label; | ||
3429 | imux->items[imux->num_items].index = index; | ||
3430 | imux->num_items++; | ||
3431 | } | ||
3620 | } | 3432 | } |
3621 | 3433 | ||
3622 | return 0; | 3434 | return 0; |
3623 | } | 3435 | } |
3624 | 3436 | ||
3437 | static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, | ||
3438 | hda_nid_t *fixed, hda_nid_t *ext) | ||
3439 | { | ||
3440 | unsigned int cfg; | ||
3441 | |||
3442 | if (!nid) | ||
3443 | return 0; | ||
3444 | cfg = snd_hda_codec_get_pincfg(codec, nid); | ||
3445 | switch (get_defcfg_connect(cfg)) { | ||
3446 | case AC_JACK_PORT_FIXED: | ||
3447 | if (*fixed) | ||
3448 | return 1; /* already occupied */ | ||
3449 | *fixed = nid; | ||
3450 | break; | ||
3451 | case AC_JACK_PORT_COMPLEX: | ||
3452 | if (*ext) | ||
3453 | return 1; /* already occupied */ | ||
3454 | *ext = nid; | ||
3455 | break; | ||
3456 | } | ||
3457 | return 0; | ||
3458 | } | ||
3459 | |||
3460 | static int set_mic_route(struct hda_codec *codec, | ||
3461 | struct sigmatel_mic_route *mic, | ||
3462 | hda_nid_t pin) | ||
3463 | { | ||
3464 | struct sigmatel_spec *spec = codec->spec; | ||
3465 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
3466 | int i; | ||
3467 | |||
3468 | mic->pin = pin; | ||
3469 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) | ||
3470 | if (pin == cfg->input_pins[i]) | ||
3471 | break; | ||
3472 | if (i <= AUTO_PIN_FRONT_MIC) { | ||
3473 | /* analog pin */ | ||
3474 | mic->dmux_idx = 0; | ||
3475 | i = get_connection_index(codec, spec->mux_nids[0], pin); | ||
3476 | if (i < 0) | ||
3477 | return -1; | ||
3478 | mic->mux_idx = i; | ||
3479 | } else if (spec->dmux_nids) { | ||
3480 | /* digital pin */ | ||
3481 | mic->mux_idx = 0; | ||
3482 | i = get_connection_index(codec, spec->dmux_nids[0], pin); | ||
3483 | if (i < 0) | ||
3484 | return -1; | ||
3485 | mic->dmux_idx = i; | ||
3486 | } | ||
3487 | return 0; | ||
3488 | } | ||
3489 | |||
3490 | /* return non-zero if the device is for automatic mic switch */ | ||
3491 | static int stac_check_auto_mic(struct hda_codec *codec) | ||
3492 | { | ||
3493 | struct sigmatel_spec *spec = codec->spec; | ||
3494 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
3495 | hda_nid_t fixed, ext; | ||
3496 | int i; | ||
3497 | |||
3498 | for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { | ||
3499 | if (cfg->input_pins[i]) | ||
3500 | return 0; /* must be exclusively mics */ | ||
3501 | } | ||
3502 | fixed = ext = 0; | ||
3503 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) | ||
3504 | if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) | ||
3505 | return 0; | ||
3506 | for (i = 0; i < spec->num_dmics; i++) | ||
3507 | if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) | ||
3508 | return 0; | ||
3509 | if (!fixed || !ext) | ||
3510 | return 0; | ||
3511 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | ||
3512 | return 0; /* no unsol support */ | ||
3513 | if (set_mic_route(codec, &spec->ext_mic, ext) || | ||
3514 | set_mic_route(codec, &spec->int_mic, fixed)) | ||
3515 | return 0; /* something is wrong */ | ||
3516 | return 1; | ||
3517 | } | ||
3518 | |||
3625 | /* create playback/capture controls for input pins */ | 3519 | /* create playback/capture controls for input pins */ |
3626 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | 3520 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
3627 | { | 3521 | { |
3628 | struct sigmatel_spec *spec = codec->spec; | 3522 | struct sigmatel_spec *spec = codec->spec; |
3629 | struct hda_input_mux *imux = &spec->private_imux; | 3523 | struct hda_input_mux *imux = &spec->private_imux; |
3630 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | 3524 | int i, j; |
3631 | int i, j, k; | ||
3632 | 3525 | ||
3633 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 3526 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
3634 | int index; | 3527 | hda_nid_t nid = cfg->input_pins[i]; |
3528 | int index, err; | ||
3635 | 3529 | ||
3636 | if (!cfg->input_pins[i]) | 3530 | if (!nid) |
3637 | continue; | 3531 | continue; |
3638 | index = -1; | 3532 | index = -1; |
3639 | for (j = 0; j < spec->num_muxes; j++) { | 3533 | for (j = 0; j < spec->num_muxes; j++) { |
3640 | int num_cons; | 3534 | index = get_connection_index(codec, spec->mux_nids[j], |
3641 | num_cons = snd_hda_get_connections(codec, | 3535 | nid); |
3642 | spec->mux_nids[j], | 3536 | if (index >= 0) |
3643 | con_lst, | 3537 | break; |
3644 | HDA_MAX_NUM_INPUTS); | ||
3645 | for (k = 0; k < num_cons; k++) | ||
3646 | if (con_lst[k] == cfg->input_pins[i]) { | ||
3647 | index = k; | ||
3648 | goto found; | ||
3649 | } | ||
3650 | } | 3538 | } |
3651 | continue; | 3539 | if (index < 0) |
3652 | found: | 3540 | continue; |
3541 | |||
3542 | err = create_elem_capture_vol(codec, nid, | ||
3543 | auto_pin_cfg_labels[i], | ||
3544 | HDA_INPUT); | ||
3545 | if (err < 0) | ||
3546 | return err; | ||
3547 | |||
3653 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | 3548 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
3654 | imux->items[imux->num_items].index = index; | 3549 | imux->items[imux->num_items].index = index; |
3655 | imux->num_items++; | 3550 | imux->num_items++; |
3656 | } | 3551 | } |
3552 | spec->num_analog_muxes = imux->num_items; | ||
3657 | 3553 | ||
3658 | if (imux->num_items) { | 3554 | if (imux->num_items) { |
3659 | /* | 3555 | /* |
@@ -3705,7 +3601,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3705 | { | 3601 | { |
3706 | struct sigmatel_spec *spec = codec->spec; | 3602 | struct sigmatel_spec *spec = codec->spec; |
3707 | int hp_swap = 0; | 3603 | int hp_swap = 0; |
3708 | int err; | 3604 | int i, err; |
3709 | 3605 | ||
3710 | if ((err = snd_hda_parse_pin_def_config(codec, | 3606 | if ((err = snd_hda_parse_pin_def_config(codec, |
3711 | &spec->autocfg, | 3607 | &spec->autocfg, |
@@ -3745,11 +3641,10 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3745 | if (snd_hda_get_connections(codec, | 3641 | if (snd_hda_get_connections(codec, |
3746 | spec->autocfg.mono_out_pin, conn_list, 1) && | 3642 | spec->autocfg.mono_out_pin, conn_list, 1) && |
3747 | snd_hda_get_connections(codec, conn_list[0], | 3643 | snd_hda_get_connections(codec, conn_list[0], |
3748 | conn_list, 1)) { | 3644 | conn_list, 1) > 0) { |
3749 | 3645 | ||
3750 | int wcaps = get_wcaps(codec, conn_list[0]); | 3646 | int wcaps = get_wcaps(codec, conn_list[0]); |
3751 | int wid_type = (wcaps & AC_WCAP_TYPE) | 3647 | int wid_type = get_wcaps_type(wcaps); |
3752 | >> AC_WCAP_TYPE_SHIFT; | ||
3753 | /* LR swap check, some stac925x have a mux that | 3648 | /* LR swap check, some stac925x have a mux that |
3754 | * changes the DACs output path instead of the | 3649 | * changes the DACs output path instead of the |
3755 | * mono-mux path. | 3650 | * mono-mux path. |
@@ -3840,6 +3735,21 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3840 | spec->autocfg.line_outs = 0; | 3735 | spec->autocfg.line_outs = 0; |
3841 | } | 3736 | } |
3842 | 3737 | ||
3738 | if (stac_check_auto_mic(codec)) { | ||
3739 | spec->auto_mic = 1; | ||
3740 | /* only one capture for auto-mic */ | ||
3741 | spec->num_adcs = 1; | ||
3742 | spec->num_caps = 1; | ||
3743 | spec->num_muxes = 1; | ||
3744 | } | ||
3745 | |||
3746 | for (i = 0; i < spec->num_caps; i++) { | ||
3747 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], | ||
3748 | spec->capsws[i], i); | ||
3749 | if (err < 0) | ||
3750 | return err; | ||
3751 | } | ||
3752 | |||
3843 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); | 3753 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
3844 | if (err < 0) | 3754 | if (err < 0) |
3845 | return err; | 3755 | return err; |
@@ -3849,11 +3759,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3849 | if (err < 0) | 3759 | if (err < 0) |
3850 | return err; | 3760 | return err; |
3851 | } | 3761 | } |
3852 | if (spec->num_amps > 0) { | ||
3853 | err = stac92xx_auto_create_amp_output_ctls(codec); | ||
3854 | if (err < 0) | ||
3855 | return err; | ||
3856 | } | ||
3857 | if (spec->num_dmics > 0 && !spec->dinput_mux) | 3762 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
3858 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, | 3763 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
3859 | &spec->autocfg)) < 0) | 3764 | &spec->autocfg)) < 0) |
@@ -3890,7 +3795,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3890 | spec->dinput_mux = &spec->private_dimux; | 3795 | spec->dinput_mux = &spec->private_dimux; |
3891 | spec->sinput_mux = &spec->private_smux; | 3796 | spec->sinput_mux = &spec->private_smux; |
3892 | spec->mono_mux = &spec->private_mono_mux; | 3797 | spec->mono_mux = &spec->private_mono_mux; |
3893 | spec->amp_mux = &spec->private_amp_mux; | ||
3894 | return 1; | 3798 | return 1; |
3895 | } | 3799 | } |
3896 | 3800 | ||
@@ -4102,14 +4006,14 @@ static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, | |||
4102 | } | 4006 | } |
4103 | 4007 | ||
4104 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, | 4008 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
4105 | hda_nid_t nid, unsigned char type) | 4009 | hda_nid_t nid) |
4106 | { | 4010 | { |
4107 | struct sigmatel_spec *spec = codec->spec; | 4011 | struct sigmatel_spec *spec = codec->spec; |
4108 | struct sigmatel_event *event = spec->events.list; | 4012 | struct sigmatel_event *event = spec->events.list; |
4109 | int i; | 4013 | int i; |
4110 | 4014 | ||
4111 | for (i = 0; i < spec->events.used; i++, event++) { | 4015 | for (i = 0; i < spec->events.used; i++, event++) { |
4112 | if (event->nid == nid && event->type == type) | 4016 | if (event->nid == nid) |
4113 | return event; | 4017 | return event; |
4114 | } | 4018 | } |
4115 | return NULL; | 4019 | return NULL; |
@@ -4129,24 +4033,32 @@ static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, | |||
4129 | return NULL; | 4033 | return NULL; |
4130 | } | 4034 | } |
4131 | 4035 | ||
4132 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | 4036 | /* check if given nid is a valid pin and no other events are assigned |
4133 | unsigned int type) | 4037 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
4038 | * Otherwise, returns zero. | ||
4039 | */ | ||
4040 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | ||
4041 | unsigned int type) | ||
4134 | { | 4042 | { |
4135 | struct sigmatel_event *event; | 4043 | struct sigmatel_event *event; |
4136 | int tag; | 4044 | int tag; |
4137 | 4045 | ||
4138 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) | 4046 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
4139 | return; | 4047 | return 0; |
4140 | event = stac_get_event(codec, nid, type); | 4048 | event = stac_get_event(codec, nid); |
4141 | if (event) | 4049 | if (event) { |
4050 | if (event->type != type) | ||
4051 | return 0; | ||
4142 | tag = event->tag; | 4052 | tag = event->tag; |
4143 | else | 4053 | } else { |
4144 | tag = stac_add_event(codec->spec, nid, type, 0); | 4054 | tag = stac_add_event(codec->spec, nid, type, 0); |
4145 | if (tag < 0) | 4055 | if (tag < 0) |
4146 | return; | 4056 | return 0; |
4057 | } | ||
4147 | snd_hda_codec_write_cache(codec, nid, 0, | 4058 | snd_hda_codec_write_cache(codec, nid, 0, |
4148 | AC_VERB_SET_UNSOLICITED_ENABLE, | 4059 | AC_VERB_SET_UNSOLICITED_ENABLE, |
4149 | AC_USRSP_EN | tag); | 4060 | AC_USRSP_EN | tag); |
4061 | return 1; | ||
4150 | } | 4062 | } |
4151 | 4063 | ||
4152 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) | 4064 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
@@ -4239,20 +4151,36 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4239 | hda_nid_t nid = cfg->hp_pins[i]; | 4151 | hda_nid_t nid = cfg->hp_pins[i]; |
4240 | enable_pin_detect(codec, nid, STAC_HP_EVENT); | 4152 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
4241 | } | 4153 | } |
4154 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && | ||
4155 | cfg->speaker_outs > 0) { | ||
4156 | /* enable pin-detect for line-outs as well */ | ||
4157 | for (i = 0; i < cfg->line_outs; i++) { | ||
4158 | hda_nid_t nid = cfg->line_out_pins[i]; | ||
4159 | enable_pin_detect(codec, nid, STAC_LO_EVENT); | ||
4160 | } | ||
4161 | } | ||
4162 | |||
4242 | /* force to enable the first line-out; the others are set up | 4163 | /* force to enable the first line-out; the others are set up |
4243 | * in unsol_event | 4164 | * in unsol_event |
4244 | */ | 4165 | */ |
4245 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], | 4166 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
4246 | AC_PINCTL_OUT_EN); | 4167 | AC_PINCTL_OUT_EN); |
4247 | /* fake event to set up pins */ | 4168 | /* fake event to set up pins */ |
4248 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], | 4169 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
4249 | STAC_HP_EVENT); | ||
4250 | } else { | 4170 | } else { |
4251 | stac92xx_auto_init_multi_out(codec); | 4171 | stac92xx_auto_init_multi_out(codec); |
4252 | stac92xx_auto_init_hp_out(codec); | 4172 | stac92xx_auto_init_hp_out(codec); |
4253 | for (i = 0; i < cfg->hp_outs; i++) | 4173 | for (i = 0; i < cfg->hp_outs; i++) |
4254 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); | 4174 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
4255 | } | 4175 | } |
4176 | if (spec->auto_mic) { | ||
4177 | /* initialize connection to analog input */ | ||
4178 | if (spec->dmux_nids) | ||
4179 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, | ||
4180 | AC_VERB_SET_CONNECT_SEL, 0); | ||
4181 | if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) | ||
4182 | stac_issue_unsol_event(codec, spec->ext_mic.pin); | ||
4183 | } | ||
4256 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 4184 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
4257 | hda_nid_t nid = cfg->input_pins[i]; | 4185 | hda_nid_t nid = cfg->input_pins[i]; |
4258 | if (nid) { | 4186 | if (nid) { |
@@ -4279,10 +4207,9 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4279 | } | 4207 | } |
4280 | conf = snd_hda_codec_get_pincfg(codec, nid); | 4208 | conf = snd_hda_codec_get_pincfg(codec, nid); |
4281 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { | 4209 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
4282 | enable_pin_detect(codec, nid, | 4210 | if (enable_pin_detect(codec, nid, |
4283 | STAC_INSERT_EVENT); | 4211 | STAC_INSERT_EVENT)) |
4284 | stac_issue_unsol_event(codec, nid, | 4212 | stac_issue_unsol_event(codec, nid); |
4285 | STAC_INSERT_EVENT); | ||
4286 | } | 4213 | } |
4287 | } | 4214 | } |
4288 | } | 4215 | } |
@@ -4327,10 +4254,8 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4327 | stac_toggle_power_map(codec, nid, 1); | 4254 | stac_toggle_power_map(codec, nid, 1); |
4328 | continue; | 4255 | continue; |
4329 | } | 4256 | } |
4330 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { | 4257 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) |
4331 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); | 4258 | stac_issue_unsol_event(codec, nid); |
4332 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); | ||
4333 | } | ||
4334 | } | 4259 | } |
4335 | if (spec->dac_list) | 4260 | if (spec->dac_list) |
4336 | stac92xx_power_down(codec); | 4261 | stac92xx_power_down(codec); |
@@ -4434,6 +4359,48 @@ static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) | |||
4434 | return 0; | 4359 | return 0; |
4435 | } | 4360 | } |
4436 | 4361 | ||
4362 | static void stac92xx_line_out_detect(struct hda_codec *codec, | ||
4363 | int presence) | ||
4364 | { | ||
4365 | struct sigmatel_spec *spec = codec->spec; | ||
4366 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
4367 | int i; | ||
4368 | |||
4369 | for (i = 0; i < cfg->line_outs; i++) { | ||
4370 | if (presence) | ||
4371 | break; | ||
4372 | presence = get_pin_presence(codec, cfg->line_out_pins[i]); | ||
4373 | if (presence) { | ||
4374 | unsigned int pinctl; | ||
4375 | pinctl = snd_hda_codec_read(codec, | ||
4376 | cfg->line_out_pins[i], 0, | ||
4377 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
4378 | if (pinctl & AC_PINCTL_IN_EN) | ||
4379 | presence = 0; /* mic- or line-input */ | ||
4380 | } | ||
4381 | } | ||
4382 | |||
4383 | if (presence) { | ||
4384 | /* disable speakers */ | ||
4385 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4386 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], | ||
4387 | AC_PINCTL_OUT_EN); | ||
4388 | if (spec->eapd_mask && spec->eapd_switch) | ||
4389 | stac_gpio_set(codec, spec->gpio_mask, | ||
4390 | spec->gpio_dir, spec->gpio_data & | ||
4391 | ~spec->eapd_mask); | ||
4392 | } else { | ||
4393 | /* enable speakers */ | ||
4394 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4395 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], | ||
4396 | AC_PINCTL_OUT_EN); | ||
4397 | if (spec->eapd_mask && spec->eapd_switch) | ||
4398 | stac_gpio_set(codec, spec->gpio_mask, | ||
4399 | spec->gpio_dir, spec->gpio_data | | ||
4400 | spec->eapd_mask); | ||
4401 | } | ||
4402 | } | ||
4403 | |||
4437 | /* return non-zero if the hp-pin of the given array index isn't | 4404 | /* return non-zero if the hp-pin of the given array index isn't |
4438 | * a jack-detection target | 4405 | * a jack-detection target |
4439 | */ | 4406 | */ |
@@ -4486,13 +4453,6 @@ static void stac92xx_hp_detect(struct hda_codec *codec) | |||
4486 | for (i = 0; i < cfg->line_outs; i++) | 4453 | for (i = 0; i < cfg->line_outs; i++) |
4487 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], | 4454 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
4488 | AC_PINCTL_OUT_EN); | 4455 | AC_PINCTL_OUT_EN); |
4489 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4490 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], | ||
4491 | AC_PINCTL_OUT_EN); | ||
4492 | if (spec->eapd_mask && spec->eapd_switch) | ||
4493 | stac_gpio_set(codec, spec->gpio_mask, | ||
4494 | spec->gpio_dir, spec->gpio_data & | ||
4495 | ~spec->eapd_mask); | ||
4496 | } else { | 4456 | } else { |
4497 | /* enable lineouts */ | 4457 | /* enable lineouts */ |
4498 | if (spec->hp_switch) | 4458 | if (spec->hp_switch) |
@@ -4501,14 +4461,8 @@ static void stac92xx_hp_detect(struct hda_codec *codec) | |||
4501 | for (i = 0; i < cfg->line_outs; i++) | 4461 | for (i = 0; i < cfg->line_outs; i++) |
4502 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], | 4462 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
4503 | AC_PINCTL_OUT_EN); | 4463 | AC_PINCTL_OUT_EN); |
4504 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4505 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], | ||
4506 | AC_PINCTL_OUT_EN); | ||
4507 | if (spec->eapd_mask && spec->eapd_switch) | ||
4508 | stac_gpio_set(codec, spec->gpio_mask, | ||
4509 | spec->gpio_dir, spec->gpio_data | | ||
4510 | spec->eapd_mask); | ||
4511 | } | 4464 | } |
4465 | stac92xx_line_out_detect(codec, presence); | ||
4512 | /* toggle hp outs */ | 4466 | /* toggle hp outs */ |
4513 | for (i = 0; i < cfg->hp_outs; i++) { | 4467 | for (i = 0; i < cfg->hp_outs; i++) { |
4514 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; | 4468 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
@@ -4593,10 +4547,28 @@ static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) | |||
4593 | } | 4547 | } |
4594 | } | 4548 | } |
4595 | 4549 | ||
4596 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, | 4550 | static void stac92xx_mic_detect(struct hda_codec *codec) |
4597 | unsigned char type) | ||
4598 | { | 4551 | { |
4599 | struct sigmatel_event *event = stac_get_event(codec, nid, type); | 4552 | struct sigmatel_spec *spec = codec->spec; |
4553 | struct sigmatel_mic_route *mic; | ||
4554 | |||
4555 | if (get_pin_presence(codec, spec->ext_mic.pin)) | ||
4556 | mic = &spec->ext_mic; | ||
4557 | else | ||
4558 | mic = &spec->int_mic; | ||
4559 | if (mic->dmux_idx) | ||
4560 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, | ||
4561 | AC_VERB_SET_CONNECT_SEL, | ||
4562 | mic->dmux_idx); | ||
4563 | else | ||
4564 | snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, | ||
4565 | AC_VERB_SET_CONNECT_SEL, | ||
4566 | mic->mux_idx); | ||
4567 | } | ||
4568 | |||
4569 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) | ||
4570 | { | ||
4571 | struct sigmatel_event *event = stac_get_event(codec, nid); | ||
4600 | if (!event) | 4572 | if (!event) |
4601 | return; | 4573 | return; |
4602 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); | 4574 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
@@ -4615,8 +4587,18 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4615 | 4587 | ||
4616 | switch (event->type) { | 4588 | switch (event->type) { |
4617 | case STAC_HP_EVENT: | 4589 | case STAC_HP_EVENT: |
4590 | case STAC_LO_EVENT: | ||
4618 | stac92xx_hp_detect(codec); | 4591 | stac92xx_hp_detect(codec); |
4619 | /* fallthru */ | 4592 | break; |
4593 | case STAC_MIC_EVENT: | ||
4594 | stac92xx_mic_detect(codec); | ||
4595 | break; | ||
4596 | } | ||
4597 | |||
4598 | switch (event->type) { | ||
4599 | case STAC_HP_EVENT: | ||
4600 | case STAC_LO_EVENT: | ||
4601 | case STAC_MIC_EVENT: | ||
4620 | case STAC_INSERT_EVENT: | 4602 | case STAC_INSERT_EVENT: |
4621 | case STAC_PWR_EVENT: | 4603 | case STAC_PWR_EVENT: |
4622 | if (spec->num_pwrs > 0) | 4604 | if (spec->num_pwrs > 0) |
@@ -4707,8 +4689,7 @@ static int stac92xx_resume(struct hda_codec *codec) | |||
4707 | snd_hda_codec_resume_cache(codec); | 4689 | snd_hda_codec_resume_cache(codec); |
4708 | /* fake event to set up pins again to override cached values */ | 4690 | /* fake event to set up pins again to override cached values */ |
4709 | if (spec->hp_detect) | 4691 | if (spec->hp_detect) |
4710 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], | 4692 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
4711 | STAC_HP_EVENT); | ||
4712 | return 0; | 4693 | return 0; |
4713 | } | 4694 | } |
4714 | 4695 | ||
@@ -4748,6 +4729,19 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec, | |||
4748 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | 4729 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
4749 | { | 4730 | { |
4750 | struct sigmatel_spec *spec = codec->spec; | 4731 | struct sigmatel_spec *spec = codec->spec; |
4732 | int i; | ||
4733 | hda_nid_t nid; | ||
4734 | |||
4735 | /* reset each pin before powering down DAC/ADC to avoid click noise */ | ||
4736 | nid = codec->start_nid; | ||
4737 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
4738 | unsigned int wcaps = get_wcaps(codec, nid); | ||
4739 | unsigned int wid_type = get_wcaps_type(wcaps); | ||
4740 | if (wid_type == AC_WID_PIN) | ||
4741 | snd_hda_codec_read(codec, nid, 0, | ||
4742 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
4743 | } | ||
4744 | |||
4751 | if (spec->eapd_mask) | 4745 | if (spec->eapd_mask) |
4752 | stac_gpio_set(codec, spec->gpio_mask, | 4746 | stac_gpio_set(codec, spec->gpio_mask, |
4753 | spec->gpio_dir, spec->gpio_data & | 4747 | spec->gpio_dir, spec->gpio_data & |
@@ -4784,7 +4778,8 @@ static int patch_stac9200(struct hda_codec *codec) | |||
4784 | stac9200_models, | 4778 | stac9200_models, |
4785 | stac9200_cfg_tbl); | 4779 | stac9200_cfg_tbl); |
4786 | if (spec->board_config < 0) | 4780 | if (spec->board_config < 0) |
4787 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); | 4781 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4782 | codec->chip_name); | ||
4788 | else | 4783 | else |
4789 | stac92xx_set_config_regs(codec, | 4784 | stac92xx_set_config_regs(codec, |
4790 | stac9200_brd_tbl[spec->board_config]); | 4785 | stac9200_brd_tbl[spec->board_config]); |
@@ -4856,8 +4851,8 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4856 | stac925x_cfg_tbl); | 4851 | stac925x_cfg_tbl); |
4857 | again: | 4852 | again: |
4858 | if (spec->board_config < 0) | 4853 | if (spec->board_config < 0) |
4859 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," | 4854 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4860 | "using BIOS defaults\n"); | 4855 | codec->chip_name); |
4861 | else | 4856 | else |
4862 | stac92xx_set_config_regs(codec, | 4857 | stac92xx_set_config_regs(codec, |
4863 | stac925x_brd_tbl[spec->board_config]); | 4858 | stac925x_brd_tbl[spec->board_config]); |
@@ -4887,6 +4882,9 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4887 | 4882 | ||
4888 | spec->init = stac925x_core_init; | 4883 | spec->init = stac925x_core_init; |
4889 | spec->mixer = stac925x_mixer; | 4884 | spec->mixer = stac925x_mixer; |
4885 | spec->num_caps = 1; | ||
4886 | spec->capvols = stac925x_capvols; | ||
4887 | spec->capsws = stac925x_capsws; | ||
4890 | 4888 | ||
4891 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); | 4889 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
4892 | if (!err) { | 4890 | if (!err) { |
@@ -4908,16 +4906,6 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4908 | return 0; | 4906 | return 0; |
4909 | } | 4907 | } |
4910 | 4908 | ||
4911 | static struct hda_input_mux stac92hd73xx_dmux = { | ||
4912 | .num_items = 4, | ||
4913 | .items = { | ||
4914 | { "Analog Inputs", 0x0b }, | ||
4915 | { "Digital Mic 1", 0x09 }, | ||
4916 | { "Digital Mic 2", 0x0a }, | ||
4917 | { "CD", 0x08 }, | ||
4918 | } | ||
4919 | }; | ||
4920 | |||
4921 | static int patch_stac92hd73xx(struct hda_codec *codec) | 4909 | static int patch_stac92hd73xx(struct hda_codec *codec) |
4922 | { | 4910 | { |
4923 | struct sigmatel_spec *spec; | 4911 | struct sigmatel_spec *spec; |
@@ -4937,10 +4925,16 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
4937 | STAC_92HD73XX_MODELS, | 4925 | STAC_92HD73XX_MODELS, |
4938 | stac92hd73xx_models, | 4926 | stac92hd73xx_models, |
4939 | stac92hd73xx_cfg_tbl); | 4927 | stac92hd73xx_cfg_tbl); |
4928 | /* check codec subsystem id if not found */ | ||
4929 | if (spec->board_config < 0) | ||
4930 | spec->board_config = | ||
4931 | snd_hda_check_board_codec_sid_config(codec, | ||
4932 | STAC_92HD73XX_MODELS, stac92hd73xx_models, | ||
4933 | stac92hd73xx_codec_id_cfg_tbl); | ||
4940 | again: | 4934 | again: |
4941 | if (spec->board_config < 0) | 4935 | if (spec->board_config < 0) |
4942 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 4936 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4943 | " STAC92HD73XX, using BIOS defaults\n"); | 4937 | codec->chip_name); |
4944 | else | 4938 | else |
4945 | stac92xx_set_config_regs(codec, | 4939 | stac92xx_set_config_regs(codec, |
4946 | stac92hd73xx_brd_tbl[spec->board_config]); | 4940 | stac92hd73xx_brd_tbl[spec->board_config]); |
@@ -4953,20 +4947,15 @@ again: | |||
4953 | "number of channels defaulting to DAC count\n"); | 4947 | "number of channels defaulting to DAC count\n"); |
4954 | num_dacs = STAC92HD73_DAC_COUNT; | 4948 | num_dacs = STAC92HD73_DAC_COUNT; |
4955 | } | 4949 | } |
4950 | spec->init = stac92hd73xx_core_init; | ||
4956 | switch (num_dacs) { | 4951 | switch (num_dacs) { |
4957 | case 0x3: /* 6 Channel */ | 4952 | case 0x3: /* 6 Channel */ |
4958 | spec->mixer = stac92hd73xx_6ch_mixer; | ||
4959 | spec->init = stac92hd73xx_6ch_core_init; | ||
4960 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; | 4953 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
4961 | break; | 4954 | break; |
4962 | case 0x4: /* 8 Channel */ | 4955 | case 0x4: /* 8 Channel */ |
4963 | spec->mixer = stac92hd73xx_8ch_mixer; | ||
4964 | spec->init = stac92hd73xx_8ch_core_init; | ||
4965 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; | 4956 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
4966 | break; | 4957 | break; |
4967 | case 0x5: /* 10 Channel */ | 4958 | case 0x5: /* 10 Channel */ |
4968 | spec->mixer = stac92hd73xx_10ch_mixer; | ||
4969 | spec->init = stac92hd73xx_10ch_core_init; | ||
4970 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; | 4959 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
4971 | break; | 4960 | break; |
4972 | } | 4961 | } |
@@ -4981,14 +4970,14 @@ again: | |||
4981 | spec->dmic_nids = stac92hd73xx_dmic_nids; | 4970 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
4982 | spec->dmux_nids = stac92hd73xx_dmux_nids; | 4971 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
4983 | spec->smux_nids = stac92hd73xx_smux_nids; | 4972 | spec->smux_nids = stac92hd73xx_smux_nids; |
4984 | spec->amp_nids = stac92hd73xx_amp_nids; | ||
4985 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); | ||
4986 | 4973 | ||
4987 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); | 4974 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
4988 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); | 4975 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
4989 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); | 4976 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
4990 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, | 4977 | |
4991 | sizeof(stac92hd73xx_dmux)); | 4978 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
4979 | spec->capvols = stac92hd73xx_capvols; | ||
4980 | spec->capsws = stac92hd73xx_capsws; | ||
4992 | 4981 | ||
4993 | switch (spec->board_config) { | 4982 | switch (spec->board_config) { |
4994 | case STAC_DELL_EQ: | 4983 | case STAC_DELL_EQ: |
@@ -4998,43 +4987,40 @@ again: | |||
4998 | case STAC_DELL_M6_DMIC: | 4987 | case STAC_DELL_M6_DMIC: |
4999 | case STAC_DELL_M6_BOTH: | 4988 | case STAC_DELL_M6_BOTH: |
5000 | spec->num_smuxes = 0; | 4989 | spec->num_smuxes = 0; |
5001 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; | ||
5002 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; | ||
5003 | spec->eapd_switch = 0; | 4990 | spec->eapd_switch = 0; |
5004 | spec->num_amps = 1; | ||
5005 | 4991 | ||
5006 | if (spec->board_config != STAC_DELL_EQ) | ||
5007 | spec->init = dell_m6_core_init; | ||
5008 | switch (spec->board_config) { | 4992 | switch (spec->board_config) { |
5009 | case STAC_DELL_M6_AMIC: /* Analog Mics */ | 4993 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
5010 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); | 4994 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
5011 | spec->num_dmics = 0; | 4995 | spec->num_dmics = 0; |
5012 | spec->private_dimux.num_items = 1; | ||
5013 | break; | 4996 | break; |
5014 | case STAC_DELL_M6_DMIC: /* Digital Mics */ | 4997 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
5015 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); | 4998 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
5016 | spec->num_dmics = 1; | 4999 | spec->num_dmics = 1; |
5017 | spec->private_dimux.num_items = 2; | ||
5018 | break; | 5000 | break; |
5019 | case STAC_DELL_M6_BOTH: /* Both */ | 5001 | case STAC_DELL_M6_BOTH: /* Both */ |
5020 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); | 5002 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
5021 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); | 5003 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
5022 | spec->num_dmics = 1; | 5004 | spec->num_dmics = 1; |
5023 | spec->private_dimux.num_items = 2; | ||
5024 | break; | 5005 | break; |
5025 | } | 5006 | } |
5026 | break; | 5007 | break; |
5008 | case STAC_ALIENWARE_M17X: | ||
5009 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; | ||
5010 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); | ||
5011 | spec->eapd_switch = 0; | ||
5012 | break; | ||
5027 | default: | 5013 | default: |
5028 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; | 5014 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
5029 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); | 5015 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
5030 | spec->eapd_switch = 1; | 5016 | spec->eapd_switch = 1; |
5017 | break; | ||
5031 | } | 5018 | } |
5032 | if (spec->board_config > STAC_92HD73XX_REF) { | 5019 | if (spec->board_config > STAC_92HD73XX_REF) { |
5033 | /* GPIO0 High = Enable EAPD */ | 5020 | /* GPIO0 High = Enable EAPD */ |
5034 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | 5021 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
5035 | spec->gpio_data = 0x01; | 5022 | spec->gpio_data = 0x01; |
5036 | } | 5023 | } |
5037 | spec->dinput_mux = &spec->private_dimux; | ||
5038 | 5024 | ||
5039 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); | 5025 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
5040 | spec->pwr_nids = stac92hd73xx_pwr_nids; | 5026 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
@@ -5066,15 +5052,6 @@ again: | |||
5066 | return 0; | 5052 | return 0; |
5067 | } | 5053 | } |
5068 | 5054 | ||
5069 | static struct hda_input_mux stac92hd83xxx_dmux = { | ||
5070 | .num_items = 3, | ||
5071 | .items = { | ||
5072 | { "Analog Inputs", 0x03 }, | ||
5073 | { "Digital Mic 1", 0x04 }, | ||
5074 | { "Digital Mic 2", 0x05 }, | ||
5075 | } | ||
5076 | }; | ||
5077 | |||
5078 | static int patch_stac92hd83xxx(struct hda_codec *codec) | 5055 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
5079 | { | 5056 | { |
5080 | struct sigmatel_spec *spec; | 5057 | struct sigmatel_spec *spec; |
@@ -5091,32 +5068,30 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5091 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; | 5068 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
5092 | spec->mono_nid = 0x19; | 5069 | spec->mono_nid = 0x19; |
5093 | spec->digbeep_nid = 0x21; | 5070 | spec->digbeep_nid = 0x21; |
5094 | spec->dmic_nids = stac92hd83xxx_dmic_nids; | 5071 | spec->mux_nids = stac92hd83xxx_mux_nids; |
5095 | spec->dmux_nids = stac92hd83xxx_dmux_nids; | 5072 | spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); |
5096 | spec->adc_nids = stac92hd83xxx_adc_nids; | 5073 | spec->adc_nids = stac92hd83xxx_adc_nids; |
5074 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | ||
5097 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 5075 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
5098 | spec->amp_nids = stac92hd83xxx_amp_nids; | ||
5099 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; | 5076 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
5100 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 5077 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
5101 | spec->multiout.dac_nids = spec->dac_nids; | 5078 | spec->multiout.dac_nids = spec->dac_nids; |
5102 | 5079 | ||
5103 | spec->init = stac92hd83xxx_core_init; | 5080 | spec->init = stac92hd83xxx_core_init; |
5104 | spec->mixer = stac92hd83xxx_mixer; | ||
5105 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); | 5081 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
5106 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); | ||
5107 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | ||
5108 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); | ||
5109 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; | ||
5110 | spec->dinput_mux = &stac92hd83xxx_dmux; | ||
5111 | spec->pin_nids = stac92hd83xxx_pin_nids; | 5082 | spec->pin_nids = stac92hd83xxx_pin_nids; |
5083 | spec->num_caps = STAC92HD83XXX_NUM_CAPS; | ||
5084 | spec->capvols = stac92hd83xxx_capvols; | ||
5085 | spec->capsws = stac92hd83xxx_capsws; | ||
5086 | |||
5112 | spec->board_config = snd_hda_check_board_config(codec, | 5087 | spec->board_config = snd_hda_check_board_config(codec, |
5113 | STAC_92HD83XXX_MODELS, | 5088 | STAC_92HD83XXX_MODELS, |
5114 | stac92hd83xxx_models, | 5089 | stac92hd83xxx_models, |
5115 | stac92hd83xxx_cfg_tbl); | 5090 | stac92hd83xxx_cfg_tbl); |
5116 | again: | 5091 | again: |
5117 | if (spec->board_config < 0) | 5092 | if (spec->board_config < 0) |
5118 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5093 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5119 | " STAC92HD83XXX, using BIOS defaults\n"); | 5094 | codec->chip_name); |
5120 | else | 5095 | else |
5121 | stac92xx_set_config_regs(codec, | 5096 | stac92xx_set_config_regs(codec, |
5122 | stac92hd83xxx_brd_tbl[spec->board_config]); | 5097 | stac92hd83xxx_brd_tbl[spec->board_config]); |
@@ -5158,6 +5133,8 @@ again: | |||
5158 | 5133 | ||
5159 | num_dacs = snd_hda_get_connections(codec, nid, | 5134 | num_dacs = snd_hda_get_connections(codec, nid, |
5160 | conn, STAC92HD83_DAC_COUNT + 1) - 1; | 5135 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
5136 | if (num_dacs < 0) | ||
5137 | num_dacs = STAC92HD83_DAC_COUNT; | ||
5161 | 5138 | ||
5162 | /* set port X to select the last DAC | 5139 | /* set port X to select the last DAC |
5163 | */ | 5140 | */ |
@@ -5171,25 +5148,6 @@ again: | |||
5171 | return 0; | 5148 | return 0; |
5172 | } | 5149 | } |
5173 | 5150 | ||
5174 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { | ||
5175 | .num_items = 3, | ||
5176 | .items = { | ||
5177 | { "Analog Inputs", 0x00 }, | ||
5178 | { "Digital Mic 1", 0x02 }, | ||
5179 | { "Digital Mic 2", 0x03 }, | ||
5180 | } | ||
5181 | }; | ||
5182 | |||
5183 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { | ||
5184 | .num_items = 4, | ||
5185 | .items = { | ||
5186 | { "Analog Inputs", 0x00 }, | ||
5187 | { "Mixer", 0x01 }, | ||
5188 | { "Digital Mic 1", 0x02 }, | ||
5189 | { "Digital Mic 2", 0x03 }, | ||
5190 | } | ||
5191 | }; | ||
5192 | |||
5193 | /* get the pin connection (fixed, none, etc) */ | 5151 | /* get the pin connection (fixed, none, etc) */ |
5194 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) | 5152 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
5195 | { | 5153 | { |
@@ -5250,7 +5208,6 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5250 | struct sigmatel_spec *spec; | 5208 | struct sigmatel_spec *spec; |
5251 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; | 5209 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
5252 | int err = 0; | 5210 | int err = 0; |
5253 | unsigned int ndmic_nids = 0; | ||
5254 | 5211 | ||
5255 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5212 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
5256 | if (spec == NULL) | 5213 | if (spec == NULL) |
@@ -5279,8 +5236,8 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5279 | stac92hd71bxx_cfg_tbl); | 5236 | stac92hd71bxx_cfg_tbl); |
5280 | again: | 5237 | again: |
5281 | if (spec->board_config < 0) | 5238 | if (spec->board_config < 0) |
5282 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5239 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5283 | " STAC92HD71BXX, using BIOS defaults\n"); | 5240 | codec->chip_name); |
5284 | else | 5241 | else |
5285 | stac92xx_set_config_regs(codec, | 5242 | stac92xx_set_config_regs(codec, |
5286 | stac92hd71bxx_brd_tbl[spec->board_config]); | 5243 | stac92hd71bxx_brd_tbl[spec->board_config]); |
@@ -5295,6 +5252,10 @@ again: | |||
5295 | spec->dmic_nids = stac92hd71bxx_dmic_nids; | 5252 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
5296 | spec->dmux_nids = stac92hd71bxx_dmux_nids; | 5253 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
5297 | 5254 | ||
5255 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; | ||
5256 | spec->capvols = stac92hd71bxx_capvols; | ||
5257 | spec->capsws = stac92hd71bxx_capsws; | ||
5258 | |||
5298 | switch (codec->vendor_id) { | 5259 | switch (codec->vendor_id) { |
5299 | case 0x111d76b6: /* 4 Port without Analog Mixer */ | 5260 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
5300 | case 0x111d76b7: | 5261 | case 0x111d76b7: |
@@ -5302,24 +5263,13 @@ again: | |||
5302 | /* fallthru */ | 5263 | /* fallthru */ |
5303 | case 0x111d76b4: /* 6 Port without Analog Mixer */ | 5264 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
5304 | case 0x111d76b5: | 5265 | case 0x111d76b5: |
5305 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, | ||
5306 | sizeof(stac92hd71bxx_dmux_nomixer)); | ||
5307 | spec->mixer = stac92hd71bxx_mixer; | ||
5308 | spec->init = stac92hd71bxx_core_init; | 5266 | spec->init = stac92hd71bxx_core_init; |
5309 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 5267 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
5310 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 5268 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5311 | stac92hd71bxx_dmic_nids, | 5269 | stac92hd71bxx_dmic_nids, |
5312 | STAC92HD71BXX_NUM_DMICS); | 5270 | STAC92HD71BXX_NUM_DMICS); |
5313 | if (spec->num_dmics) { | ||
5314 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | ||
5315 | spec->dinput_mux = &spec->private_dimux; | ||
5316 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; | ||
5317 | } | ||
5318 | break; | 5271 | break; |
5319 | case 0x111d7608: /* 5 Port with Analog Mixer */ | 5272 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
5320 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, | ||
5321 | sizeof(stac92hd71bxx_dmux_amixer)); | ||
5322 | spec->private_dimux.num_items--; | ||
5323 | switch (spec->board_config) { | 5273 | switch (spec->board_config) { |
5324 | case STAC_HP_M4: | 5274 | case STAC_HP_M4: |
5325 | /* Enable VREF power saving on GPIO1 detect */ | 5275 | /* Enable VREF power saving on GPIO1 detect */ |
@@ -5341,11 +5291,8 @@ again: | |||
5341 | 5291 | ||
5342 | /* no output amps */ | 5292 | /* no output amps */ |
5343 | spec->num_pwrs = 0; | 5293 | spec->num_pwrs = 0; |
5344 | spec->mixer = stac92hd71bxx_analog_mixer; | ||
5345 | spec->dinput_mux = &spec->private_dimux; | ||
5346 | |||
5347 | /* disable VSW */ | 5294 | /* disable VSW */ |
5348 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; | 5295 | spec->init = stac92hd71bxx_core_init; |
5349 | unmute_init++; | 5296 | unmute_init++; |
5350 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); | 5297 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
5351 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); | 5298 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
@@ -5353,8 +5300,6 @@ again: | |||
5353 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 5300 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5354 | stac92hd71bxx_dmic_nids, | 5301 | stac92hd71bxx_dmic_nids, |
5355 | STAC92HD71BXX_NUM_DMICS - 1); | 5302 | STAC92HD71BXX_NUM_DMICS - 1); |
5356 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | ||
5357 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; | ||
5358 | break; | 5303 | break; |
5359 | case 0x111d7603: /* 6 Port with Analog Mixer */ | 5304 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
5360 | if ((codec->revision_id & 0xf) == 1) | 5305 | if ((codec->revision_id & 0xf) == 1) |
@@ -5364,17 +5309,12 @@ again: | |||
5364 | spec->num_pwrs = 0; | 5309 | spec->num_pwrs = 0; |
5365 | /* fallthru */ | 5310 | /* fallthru */ |
5366 | default: | 5311 | default: |
5367 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, | 5312 | spec->init = stac92hd71bxx_core_init; |
5368 | sizeof(stac92hd71bxx_dmux_amixer)); | ||
5369 | spec->dinput_mux = &spec->private_dimux; | ||
5370 | spec->mixer = stac92hd71bxx_analog_mixer; | ||
5371 | spec->init = stac92hd71bxx_analog_core_init; | ||
5372 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 5313 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
5373 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 5314 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5374 | stac92hd71bxx_dmic_nids, | 5315 | stac92hd71bxx_dmic_nids, |
5375 | STAC92HD71BXX_NUM_DMICS); | 5316 | STAC92HD71BXX_NUM_DMICS); |
5376 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | 5317 | break; |
5377 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; | ||
5378 | } | 5318 | } |
5379 | 5319 | ||
5380 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) | 5320 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
@@ -5402,6 +5342,7 @@ again: | |||
5402 | 5342 | ||
5403 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); | 5343 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
5404 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); | 5344 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
5345 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | ||
5405 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); | 5346 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
5406 | 5347 | ||
5407 | switch (spec->board_config) { | 5348 | switch (spec->board_config) { |
@@ -5456,8 +5397,6 @@ again: | |||
5456 | #endif | 5397 | #endif |
5457 | 5398 | ||
5458 | spec->multiout.dac_nids = spec->dac_nids; | 5399 | spec->multiout.dac_nids = spec->dac_nids; |
5459 | if (spec->dinput_mux) | ||
5460 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; | ||
5461 | 5400 | ||
5462 | err = stac92xx_parse_auto_config(codec, 0x21, 0); | 5401 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
5463 | if (!err) { | 5402 | if (!err) { |
@@ -5535,8 +5474,8 @@ static int patch_stac922x(struct hda_codec *codec) | |||
5535 | 5474 | ||
5536 | again: | 5475 | again: |
5537 | if (spec->board_config < 0) | 5476 | if (spec->board_config < 0) |
5538 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " | 5477 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5539 | "using BIOS defaults\n"); | 5478 | codec->chip_name); |
5540 | else | 5479 | else |
5541 | stac92xx_set_config_regs(codec, | 5480 | stac92xx_set_config_regs(codec, |
5542 | stac922x_brd_tbl[spec->board_config]); | 5481 | stac922x_brd_tbl[spec->board_config]); |
@@ -5549,7 +5488,10 @@ static int patch_stac922x(struct hda_codec *codec) | |||
5549 | spec->num_pwrs = 0; | 5488 | spec->num_pwrs = 0; |
5550 | 5489 | ||
5551 | spec->init = stac922x_core_init; | 5490 | spec->init = stac922x_core_init; |
5552 | spec->mixer = stac922x_mixer; | 5491 | |
5492 | spec->num_caps = STAC922X_NUM_CAPS; | ||
5493 | spec->capvols = stac922x_capvols; | ||
5494 | spec->capsws = stac922x_capsws; | ||
5553 | 5495 | ||
5554 | spec->multiout.dac_nids = spec->dac_nids; | 5496 | spec->multiout.dac_nids = spec->dac_nids; |
5555 | 5497 | ||
@@ -5598,8 +5540,8 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5598 | stac927x_cfg_tbl); | 5540 | stac927x_cfg_tbl); |
5599 | again: | 5541 | again: |
5600 | if (spec->board_config < 0) | 5542 | if (spec->board_config < 0) |
5601 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5543 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5602 | "STAC927x, using BIOS defaults\n"); | 5544 | codec->chip_name); |
5603 | else | 5545 | else |
5604 | stac92xx_set_config_regs(codec, | 5546 | stac92xx_set_config_regs(codec, |
5605 | stac927x_brd_tbl[spec->board_config]); | 5547 | stac927x_brd_tbl[spec->board_config]); |
@@ -5624,7 +5566,6 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5624 | spec->num_dmics = 0; | 5566 | spec->num_dmics = 0; |
5625 | 5567 | ||
5626 | spec->init = d965_core_init; | 5568 | spec->init = d965_core_init; |
5627 | spec->mixer = stac927x_mixer; | ||
5628 | break; | 5569 | break; |
5629 | case STAC_DELL_BIOS: | 5570 | case STAC_DELL_BIOS: |
5630 | switch (codec->subsystem_id) { | 5571 | switch (codec->subsystem_id) { |
@@ -5656,7 +5597,6 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5656 | spec->num_dmics = STAC927X_NUM_DMICS; | 5597 | spec->num_dmics = STAC927X_NUM_DMICS; |
5657 | 5598 | ||
5658 | spec->init = d965_core_init; | 5599 | spec->init = d965_core_init; |
5659 | spec->mixer = stac927x_mixer; | ||
5660 | spec->dmux_nids = stac927x_dmux_nids; | 5600 | spec->dmux_nids = stac927x_dmux_nids; |
5661 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); | 5601 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
5662 | break; | 5602 | break; |
@@ -5669,9 +5609,12 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5669 | spec->num_dmics = 0; | 5609 | spec->num_dmics = 0; |
5670 | 5610 | ||
5671 | spec->init = stac927x_core_init; | 5611 | spec->init = stac927x_core_init; |
5672 | spec->mixer = stac927x_mixer; | ||
5673 | } | 5612 | } |
5674 | 5613 | ||
5614 | spec->num_caps = STAC927X_NUM_CAPS; | ||
5615 | spec->capvols = stac927x_capvols; | ||
5616 | spec->capsws = stac927x_capsws; | ||
5617 | |||
5675 | spec->num_pwrs = 0; | 5618 | spec->num_pwrs = 0; |
5676 | spec->aloopback_ctl = stac927x_loopback; | 5619 | spec->aloopback_ctl = stac927x_loopback; |
5677 | spec->aloopback_mask = 0x40; | 5620 | spec->aloopback_mask = 0x40; |
@@ -5733,7 +5676,8 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5733 | stac9205_cfg_tbl); | 5676 | stac9205_cfg_tbl); |
5734 | again: | 5677 | again: |
5735 | if (spec->board_config < 0) | 5678 | if (spec->board_config < 0) |
5736 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); | 5679 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5680 | codec->chip_name); | ||
5737 | else | 5681 | else |
5738 | stac92xx_set_config_regs(codec, | 5682 | stac92xx_set_config_regs(codec, |
5739 | stac9205_brd_tbl[spec->board_config]); | 5683 | stac9205_brd_tbl[spec->board_config]); |
@@ -5752,9 +5696,12 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5752 | spec->num_pwrs = 0; | 5696 | spec->num_pwrs = 0; |
5753 | 5697 | ||
5754 | spec->init = stac9205_core_init; | 5698 | spec->init = stac9205_core_init; |
5755 | spec->mixer = stac9205_mixer; | ||
5756 | spec->aloopback_ctl = stac9205_loopback; | 5699 | spec->aloopback_ctl = stac9205_loopback; |
5757 | 5700 | ||
5701 | spec->num_caps = STAC9205_NUM_CAPS; | ||
5702 | spec->capvols = stac9205_capvols; | ||
5703 | spec->capsws = stac9205_capsws; | ||
5704 | |||
5758 | spec->aloopback_mask = 0x40; | 5705 | spec->aloopback_mask = 0x40; |
5759 | spec->aloopback_shift = 0; | 5706 | spec->aloopback_shift = 0; |
5760 | /* Turn on/off EAPD per HP plugging */ | 5707 | /* Turn on/off EAPD per HP plugging */ |
@@ -5829,12 +5776,6 @@ static struct hda_verb stac9872_core_init[] = { | |||
5829 | {} | 5776 | {} |
5830 | }; | 5777 | }; |
5831 | 5778 | ||
5832 | static struct snd_kcontrol_new stac9872_mixer[] = { | ||
5833 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), | ||
5834 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), | ||
5835 | { } /* end */ | ||
5836 | }; | ||
5837 | |||
5838 | static hda_nid_t stac9872_pin_nids[] = { | 5779 | static hda_nid_t stac9872_pin_nids[] = { |
5839 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | 5780 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
5840 | 0x11, 0x13, 0x14, | 5781 | 0x11, 0x13, 0x14, |
@@ -5848,6 +5789,11 @@ static hda_nid_t stac9872_mux_nids[] = { | |||
5848 | 0x15 | 5789 | 0x15 |
5849 | }; | 5790 | }; |
5850 | 5791 | ||
5792 | static unsigned long stac9872_capvols[] = { | ||
5793 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | ||
5794 | }; | ||
5795 | #define stac9872_capsws stac9872_capvols | ||
5796 | |||
5851 | static unsigned int stac9872_vaio_pin_configs[9] = { | 5797 | static unsigned int stac9872_vaio_pin_configs[9] = { |
5852 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, | 5798 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
5853 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, | 5799 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
@@ -5885,8 +5831,8 @@ static int patch_stac9872(struct hda_codec *codec) | |||
5885 | stac9872_models, | 5831 | stac9872_models, |
5886 | stac9872_cfg_tbl); | 5832 | stac9872_cfg_tbl); |
5887 | if (spec->board_config < 0) | 5833 | if (spec->board_config < 0) |
5888 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " | 5834 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5889 | "using BIOS defaults\n"); | 5835 | codec->chip_name); |
5890 | else | 5836 | else |
5891 | stac92xx_set_config_regs(codec, | 5837 | stac92xx_set_config_regs(codec, |
5892 | stac9872_brd_tbl[spec->board_config]); | 5838 | stac9872_brd_tbl[spec->board_config]); |
@@ -5896,8 +5842,10 @@ static int patch_stac9872(struct hda_codec *codec) | |||
5896 | spec->adc_nids = stac9872_adc_nids; | 5842 | spec->adc_nids = stac9872_adc_nids; |
5897 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); | 5843 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
5898 | spec->mux_nids = stac9872_mux_nids; | 5844 | spec->mux_nids = stac9872_mux_nids; |
5899 | spec->mixer = stac9872_mixer; | ||
5900 | spec->init = stac9872_core_init; | 5845 | spec->init = stac9872_core_init; |
5846 | spec->num_caps = 1; | ||
5847 | spec->capvols = stac9872_capvols; | ||
5848 | spec->capsws = stac9872_capsws; | ||
5901 | 5849 | ||
5902 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); | 5850 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
5903 | if (err < 0) { | 5851 | if (err < 0) { |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 9008b4b013aa..ee89db90c9b6 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -1339,8 +1339,7 @@ static int get_mux_nids(struct hda_codec *codec) | |||
1339 | for (i = 0; i < spec->num_adc_nids; i++) { | 1339 | for (i = 0; i < spec->num_adc_nids; i++) { |
1340 | nid = spec->adc_nids[i]; | 1340 | nid = spec->adc_nids[i]; |
1341 | while (nid) { | 1341 | while (nid) { |
1342 | type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) | 1342 | type = get_wcaps_type(get_wcaps(codec, nid)); |
1343 | >> AC_WCAP_TYPE_SHIFT; | ||
1344 | if (type == AC_WID_PIN) | 1343 | if (type == AC_WID_PIN) |
1345 | break; | 1344 | break; |
1346 | n = snd_hda_get_connections(codec, nid, conn, | 1345 | n = snd_hda_get_connections(codec, nid, conn, |
@@ -1395,6 +1394,7 @@ static int patch_vt1708(struct hda_codec *codec) | |||
1395 | if (!spec->adc_nids && spec->input_mux) { | 1394 | if (!spec->adc_nids && spec->input_mux) { |
1396 | spec->adc_nids = vt1708_adc_nids; | 1395 | spec->adc_nids = vt1708_adc_nids; |
1397 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); | 1396 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); |
1397 | get_mux_nids(codec); | ||
1398 | spec->mixers[spec->num_mixers] = vt1708_capture_mixer; | 1398 | spec->mixers[spec->num_mixers] = vt1708_capture_mixer; |
1399 | spec->num_mixers++; | 1399 | spec->num_mixers++; |
1400 | } | 1400 | } |
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index adc909ec125c..9da2dae64c5b 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h | |||
@@ -379,6 +379,15 @@ struct snd_ice1712 { | |||
379 | unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); | 379 | unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); |
380 | void (*set_spdif_clock)(struct snd_ice1712 *ice); | 380 | void (*set_spdif_clock)(struct snd_ice1712 *ice); |
381 | 381 | ||
382 | #ifdef CONFIG_PM | ||
383 | int (*pm_suspend)(struct snd_ice1712 *); | ||
384 | int (*pm_resume)(struct snd_ice1712 *); | ||
385 | int pm_suspend_enabled:1; | ||
386 | int pm_saved_is_spdif_master:1; | ||
387 | unsigned int pm_saved_spdif_ctrl; | ||
388 | unsigned char pm_saved_spdif_cfg; | ||
389 | unsigned int pm_saved_route; | ||
390 | #endif | ||
382 | }; | 391 | }; |
383 | 392 | ||
384 | 393 | ||
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index cc84a831eb21..af6e00148621 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c | |||
@@ -560,6 +560,7 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
560 | 560 | ||
561 | case SNDRV_PCM_TRIGGER_START: | 561 | case SNDRV_PCM_TRIGGER_START: |
562 | case SNDRV_PCM_TRIGGER_STOP: | 562 | case SNDRV_PCM_TRIGGER_STOP: |
563 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
563 | spin_lock(&ice->reg_lock); | 564 | spin_lock(&ice->reg_lock); |
564 | old = inb(ICEMT1724(ice, DMA_CONTROL)); | 565 | old = inb(ICEMT1724(ice, DMA_CONTROL)); |
565 | if (cmd == SNDRV_PCM_TRIGGER_START) | 566 | if (cmd == SNDRV_PCM_TRIGGER_START) |
@@ -570,6 +571,10 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
570 | spin_unlock(&ice->reg_lock); | 571 | spin_unlock(&ice->reg_lock); |
571 | break; | 572 | break; |
572 | 573 | ||
574 | case SNDRV_PCM_TRIGGER_RESUME: | ||
575 | /* apps will have to restart stream */ | ||
576 | break; | ||
577 | |||
573 | default: | 578 | default: |
574 | return -EINVAL; | 579 | return -EINVAL; |
575 | } | 580 | } |
@@ -2262,7 +2267,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice, | |||
2262 | 2267 | ||
2263 | 2268 | ||
2264 | 2269 | ||
2265 | static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice) | 2270 | static void snd_vt1724_chip_reset(struct snd_ice1712 *ice) |
2266 | { | 2271 | { |
2267 | outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); | 2272 | outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); |
2268 | inb(ICEREG1724(ice, CONTROL)); /* pci posting flush */ | 2273 | inb(ICEREG1724(ice, CONTROL)); /* pci posting flush */ |
@@ -2272,7 +2277,7 @@ static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice) | |||
2272 | msleep(10); | 2277 | msleep(10); |
2273 | } | 2278 | } |
2274 | 2279 | ||
2275 | static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) | 2280 | static int snd_vt1724_chip_init(struct snd_ice1712 *ice) |
2276 | { | 2281 | { |
2277 | outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); | 2282 | outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); |
2278 | outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); | 2283 | outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); |
@@ -2287,6 +2292,14 @@ static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) | |||
2287 | 2292 | ||
2288 | outb(0, ICEREG1724(ice, POWERDOWN)); | 2293 | outb(0, ICEREG1724(ice, POWERDOWN)); |
2289 | 2294 | ||
2295 | /* MPU_RX and TX irq masks are cleared later dynamically */ | ||
2296 | outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK)); | ||
2297 | |||
2298 | /* don't handle FIFO overrun/underruns (just yet), | ||
2299 | * since they cause machine lockups | ||
2300 | */ | ||
2301 | outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK)); | ||
2302 | |||
2290 | return 0; | 2303 | return 0; |
2291 | } | 2304 | } |
2292 | 2305 | ||
@@ -2431,6 +2444,8 @@ static int __devinit snd_vt1724_create(struct snd_card *card, | |||
2431 | snd_vt1724_proc_init(ice); | 2444 | snd_vt1724_proc_init(ice); |
2432 | synchronize_irq(pci->irq); | 2445 | synchronize_irq(pci->irq); |
2433 | 2446 | ||
2447 | card->private_data = ice; | ||
2448 | |||
2434 | err = pci_request_regions(pci, "ICE1724"); | 2449 | err = pci_request_regions(pci, "ICE1724"); |
2435 | if (err < 0) { | 2450 | if (err < 0) { |
2436 | kfree(ice); | 2451 | kfree(ice); |
@@ -2459,14 +2474,6 @@ static int __devinit snd_vt1724_create(struct snd_card *card, | |||
2459 | return -EIO; | 2474 | return -EIO; |
2460 | } | 2475 | } |
2461 | 2476 | ||
2462 | /* MPU_RX and TX irq masks are cleared later dynamically */ | ||
2463 | outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK)); | ||
2464 | |||
2465 | /* don't handle FIFO overrun/underruns (just yet), | ||
2466 | * since they cause machine lockups | ||
2467 | */ | ||
2468 | outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK)); | ||
2469 | |||
2470 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops); | 2477 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops); |
2471 | if (err < 0) { | 2478 | if (err < 0) { |
2472 | snd_vt1724_free(ice); | 2479 | snd_vt1724_free(ice); |
@@ -2650,11 +2657,96 @@ static void __devexit snd_vt1724_remove(struct pci_dev *pci) | |||
2650 | pci_set_drvdata(pci, NULL); | 2657 | pci_set_drvdata(pci, NULL); |
2651 | } | 2658 | } |
2652 | 2659 | ||
2660 | #ifdef CONFIG_PM | ||
2661 | static int snd_vt1724_suspend(struct pci_dev *pci, pm_message_t state) | ||
2662 | { | ||
2663 | struct snd_card *card = pci_get_drvdata(pci); | ||
2664 | struct snd_ice1712 *ice = card->private_data; | ||
2665 | |||
2666 | if (!ice->pm_suspend_enabled) | ||
2667 | return 0; | ||
2668 | |||
2669 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
2670 | |||
2671 | snd_pcm_suspend_all(ice->pcm); | ||
2672 | snd_pcm_suspend_all(ice->pcm_pro); | ||
2673 | snd_pcm_suspend_all(ice->pcm_ds); | ||
2674 | snd_ac97_suspend(ice->ac97); | ||
2675 | |||
2676 | spin_lock_irq(&ice->reg_lock); | ||
2677 | ice->pm_saved_is_spdif_master = ice->is_spdif_master(ice); | ||
2678 | ice->pm_saved_spdif_ctrl = inw(ICEMT1724(ice, SPDIF_CTRL)); | ||
2679 | ice->pm_saved_spdif_cfg = inb(ICEREG1724(ice, SPDIF_CFG)); | ||
2680 | ice->pm_saved_route = inl(ICEMT1724(ice, ROUTE_PLAYBACK)); | ||
2681 | spin_unlock_irq(&ice->reg_lock); | ||
2682 | |||
2683 | if (ice->pm_suspend) | ||
2684 | ice->pm_suspend(ice); | ||
2685 | |||
2686 | pci_disable_device(pci); | ||
2687 | pci_save_state(pci); | ||
2688 | pci_set_power_state(pci, pci_choose_state(pci, state)); | ||
2689 | return 0; | ||
2690 | } | ||
2691 | |||
2692 | static int snd_vt1724_resume(struct pci_dev *pci) | ||
2693 | { | ||
2694 | struct snd_card *card = pci_get_drvdata(pci); | ||
2695 | struct snd_ice1712 *ice = card->private_data; | ||
2696 | |||
2697 | if (!ice->pm_suspend_enabled) | ||
2698 | return 0; | ||
2699 | |||
2700 | pci_set_power_state(pci, PCI_D0); | ||
2701 | pci_restore_state(pci); | ||
2702 | |||
2703 | if (pci_enable_device(pci) < 0) { | ||
2704 | snd_card_disconnect(card); | ||
2705 | return -EIO; | ||
2706 | } | ||
2707 | |||
2708 | pci_set_master(pci); | ||
2709 | |||
2710 | snd_vt1724_chip_reset(ice); | ||
2711 | |||
2712 | if (snd_vt1724_chip_init(ice) < 0) { | ||
2713 | snd_card_disconnect(card); | ||
2714 | return -EIO; | ||
2715 | } | ||
2716 | |||
2717 | if (ice->pm_resume) | ||
2718 | ice->pm_resume(ice); | ||
2719 | |||
2720 | if (ice->pm_saved_is_spdif_master) { | ||
2721 | /* switching to external clock via SPDIF */ | ||
2722 | ice->set_spdif_clock(ice); | ||
2723 | } else { | ||
2724 | /* internal on-card clock */ | ||
2725 | snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); | ||
2726 | } | ||
2727 | |||
2728 | update_spdif_bits(ice, ice->pm_saved_spdif_ctrl); | ||
2729 | |||
2730 | outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG)); | ||
2731 | outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK)); | ||
2732 | |||
2733 | if (ice->ac97) | ||
2734 | snd_ac97_resume(ice->ac97); | ||
2735 | |||
2736 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
2737 | return 0; | ||
2738 | } | ||
2739 | #endif | ||
2740 | |||
2653 | static struct pci_driver driver = { | 2741 | static struct pci_driver driver = { |
2654 | .name = "ICE1724", | 2742 | .name = "ICE1724", |
2655 | .id_table = snd_vt1724_ids, | 2743 | .id_table = snd_vt1724_ids, |
2656 | .probe = snd_vt1724_probe, | 2744 | .probe = snd_vt1724_probe, |
2657 | .remove = __devexit_p(snd_vt1724_remove), | 2745 | .remove = __devexit_p(snd_vt1724_remove), |
2746 | #ifdef CONFIG_PM | ||
2747 | .suspend = snd_vt1724_suspend, | ||
2748 | .resume = snd_vt1724_resume, | ||
2749 | #endif | ||
2658 | }; | 2750 | }; |
2659 | 2751 | ||
2660 | static int __init alsa_card_ice1724_init(void) | 2752 | static int __init alsa_card_ice1724_init(void) |
diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index 043a93879bd5..c75515f5be6f 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c | |||
@@ -1077,7 +1077,7 @@ static int __devinit prodigy_hifi_init(struct snd_ice1712 *ice) | |||
1077 | /* | 1077 | /* |
1078 | * initialize the chip | 1078 | * initialize the chip |
1079 | */ | 1079 | */ |
1080 | static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | 1080 | static void ak4396_init(struct snd_ice1712 *ice) |
1081 | { | 1081 | { |
1082 | static unsigned short ak4396_inits[] = { | 1082 | static unsigned short ak4396_inits[] = { |
1083 | AK4396_CTRL1, 0x87, /* I2S Normal Mode, 24 bit */ | 1083 | AK4396_CTRL1, 0x87, /* I2S Normal Mode, 24 bit */ |
@@ -1087,9 +1087,37 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | |||
1087 | AK4396_RCH_ATT, 0x00, | 1087 | AK4396_RCH_ATT, 0x00, |
1088 | }; | 1088 | }; |
1089 | 1089 | ||
1090 | struct prodigy_hifi_spec *spec; | ||
1091 | unsigned int i; | 1090 | unsigned int i; |
1092 | 1091 | ||
1092 | /* initialize ak4396 codec */ | ||
1093 | /* reset codec */ | ||
1094 | ak4396_write(ice, AK4396_CTRL1, 0x86); | ||
1095 | msleep(100); | ||
1096 | ak4396_write(ice, AK4396_CTRL1, 0x87); | ||
1097 | |||
1098 | for (i = 0; i < ARRAY_SIZE(ak4396_inits); i += 2) | ||
1099 | ak4396_write(ice, ak4396_inits[i], ak4396_inits[i+1]); | ||
1100 | } | ||
1101 | |||
1102 | #ifdef CONFIG_PM | ||
1103 | static int __devinit prodigy_hd2_resume(struct snd_ice1712 *ice) | ||
1104 | { | ||
1105 | /* initialize ak4396 codec and restore previous mixer volumes */ | ||
1106 | struct prodigy_hifi_spec *spec = ice->spec; | ||
1107 | int i; | ||
1108 | mutex_lock(&ice->gpio_mutex); | ||
1109 | ak4396_init(ice); | ||
1110 | for (i = 0; i < 2; i++) | ||
1111 | ak4396_write(ice, AK4396_LCH_ATT + i, spec->vol[i] & 0xff); | ||
1112 | mutex_unlock(&ice->gpio_mutex); | ||
1113 | return 0; | ||
1114 | } | ||
1115 | #endif | ||
1116 | |||
1117 | static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | ||
1118 | { | ||
1119 | struct prodigy_hifi_spec *spec; | ||
1120 | |||
1093 | ice->vt1720 = 0; | 1121 | ice->vt1720 = 0; |
1094 | ice->vt1724 = 1; | 1122 | ice->vt1724 = 1; |
1095 | 1123 | ||
@@ -1112,14 +1140,12 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | |||
1112 | return -ENOMEM; | 1140 | return -ENOMEM; |
1113 | ice->spec = spec; | 1141 | ice->spec = spec; |
1114 | 1142 | ||
1115 | /* initialize ak4396 codec */ | 1143 | #ifdef CONFIG_PM |
1116 | /* reset codec */ | 1144 | ice->pm_resume = &prodigy_hd2_resume; |
1117 | ak4396_write(ice, AK4396_CTRL1, 0x86); | 1145 | ice->pm_suspend_enabled = 1; |
1118 | msleep(100); | 1146 | #endif |
1119 | ak4396_write(ice, AK4396_CTRL1, 0x87); | 1147 | |
1120 | 1148 | ak4396_init(ice); | |
1121 | for (i = 0; i < ARRAY_SIZE(ak4396_inits); i += 2) | ||
1122 | ak4396_write(ice, ak4396_inits[i], ak4396_inits[i+1]); | ||
1123 | 1149 | ||
1124 | return 0; | 1150 | return 0; |
1125 | } | 1151 | } |
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index c1eb923f2ac9..09b2b2a36df5 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c | |||
@@ -215,17 +215,8 @@ EXPORT_SYMBOL(oxygen_write_spi); | |||
215 | 215 | ||
216 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) | 216 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) |
217 | { | 217 | { |
218 | unsigned long timeout; | ||
219 | |||
220 | /* should not need more than about 300 us */ | 218 | /* should not need more than about 300 us */ |
221 | timeout = jiffies + msecs_to_jiffies(1); | 219 | msleep(1); |
222 | do { | ||
223 | if (!(oxygen_read16(chip, OXYGEN_2WIRE_BUS_STATUS) | ||
224 | & OXYGEN_2WIRE_BUSY)) | ||
225 | break; | ||
226 | udelay(1); | ||
227 | cond_resched(); | ||
228 | } while (time_after_eq(timeout, jiffies)); | ||
229 | 220 | ||
230 | oxygen_write8(chip, OXYGEN_2WIRE_MAP, map); | 221 | oxygen_write8(chip, OXYGEN_2WIRE_MAP, map); |
231 | oxygen_write8(chip, OXYGEN_2WIRE_DATA, data); | 222 | oxygen_write8(chip, OXYGEN_2WIRE_DATA, data); |
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index 312251d39696..9a8936e20744 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c | |||
@@ -260,6 +260,9 @@ oxygen_search_pci_id(struct oxygen *chip, const struct pci_device_id ids[]) | |||
260 | * chip didn't if the first EEPROM word was overwritten. | 260 | * chip didn't if the first EEPROM word was overwritten. |
261 | */ | 261 | */ |
262 | subdevice = oxygen_read_eeprom(chip, 2); | 262 | subdevice = oxygen_read_eeprom(chip, 2); |
263 | /* use default ID if EEPROM is missing */ | ||
264 | if (subdevice == 0xffff) | ||
265 | subdevice = 0x8788; | ||
263 | /* | 266 | /* |
264 | * We use only the subsystem device ID for searching because it is | 267 | * We use only the subsystem device ID for searching because it is |
265 | * unique even without the subsystem vendor ID, which may have been | 268 | * unique even without the subsystem vendor ID, which may have been |
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 3b5ca70c9d4d..ef2345d82b86 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -469,9 +469,11 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | 469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, |
470 | oxygen_rate(hw_params) | | 470 | oxygen_rate(hw_params) | |
471 | chip->model.dac_i2s_format | | 471 | chip->model.dac_i2s_format | |
472 | oxygen_i2s_mclk(hw_params) | | ||
472 | oxygen_i2s_bits(hw_params), | 473 | oxygen_i2s_bits(hw_params), |
473 | OXYGEN_I2S_RATE_MASK | | 474 | OXYGEN_I2S_RATE_MASK | |
474 | OXYGEN_I2S_FORMAT_MASK | | 475 | OXYGEN_I2S_FORMAT_MASK | |
476 | OXYGEN_I2S_MCLK_MASK | | ||
475 | OXYGEN_I2S_BITS_MASK); | 477 | OXYGEN_I2S_BITS_MASK); |
476 | oxygen_update_dac_routing(chip); | 478 | oxygen_update_dac_routing(chip); |
477 | oxygen_update_spdif_source(chip); | 479 | oxygen_update_spdif_source(chip); |
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 3da5c029f93b..7bb827c7d806 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -3294,15 +3294,33 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | |||
3294 | char *clock_source; | 3294 | char *clock_source; |
3295 | int x; | 3295 | int x; |
3296 | 3296 | ||
3297 | if (hdsp_check_for_iobox (hdsp)) { | 3297 | status = hdsp_read(hdsp, HDSP_statusRegister); |
3298 | snd_iprintf(buffer, "No I/O box connected.\nPlease connect one and upload firmware.\n"); | 3298 | status2 = hdsp_read(hdsp, HDSP_status2Register); |
3299 | |||
3300 | snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, | ||
3301 | hdsp->card->number + 1); | ||
3302 | snd_iprintf(buffer, "Buffers: capture %p playback %p\n", | ||
3303 | hdsp->capture_buffer, hdsp->playback_buffer); | ||
3304 | snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", | ||
3305 | hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); | ||
3306 | snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); | ||
3307 | snd_iprintf(buffer, "Control2 register: 0x%x\n", | ||
3308 | hdsp->control2_register); | ||
3309 | snd_iprintf(buffer, "Status register: 0x%x\n", status); | ||
3310 | snd_iprintf(buffer, "Status2 register: 0x%x\n", status2); | ||
3311 | |||
3312 | if (hdsp_check_for_iobox(hdsp)) { | ||
3313 | snd_iprintf(buffer, "No I/O box connected.\n" | ||
3314 | "Please connect one and upload firmware.\n"); | ||
3299 | return; | 3315 | return; |
3300 | } | 3316 | } |
3301 | 3317 | ||
3302 | if (hdsp_check_for_firmware(hdsp, 0)) { | 3318 | if (hdsp_check_for_firmware(hdsp, 0)) { |
3303 | if (hdsp->state & HDSP_FirmwareCached) { | 3319 | if (hdsp->state & HDSP_FirmwareCached) { |
3304 | if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { | 3320 | if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { |
3305 | snd_iprintf(buffer, "Firmware loading from cache failed, please upload manually.\n"); | 3321 | snd_iprintf(buffer, "Firmware loading from " |
3322 | "cache failed, " | ||
3323 | "please upload manually.\n"); | ||
3306 | return; | 3324 | return; |
3307 | } | 3325 | } |
3308 | } else { | 3326 | } else { |
@@ -3319,18 +3337,6 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | |||
3319 | } | 3337 | } |
3320 | } | 3338 | } |
3321 | 3339 | ||
3322 | status = hdsp_read(hdsp, HDSP_statusRegister); | ||
3323 | status2 = hdsp_read(hdsp, HDSP_status2Register); | ||
3324 | |||
3325 | snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, hdsp->card->number + 1); | ||
3326 | snd_iprintf(buffer, "Buffers: capture %p playback %p\n", | ||
3327 | hdsp->capture_buffer, hdsp->playback_buffer); | ||
3328 | snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", | ||
3329 | hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); | ||
3330 | snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); | ||
3331 | snd_iprintf(buffer, "Control2 register: 0x%x\n", hdsp->control2_register); | ||
3332 | snd_iprintf(buffer, "Status register: 0x%x\n", status); | ||
3333 | snd_iprintf(buffer, "Status2 register: 0x%x\n", status2); | ||
3334 | snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); | 3340 | snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); |
3335 | snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); | 3341 | snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); |
3336 | snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); | 3342 | snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); |
@@ -3351,7 +3357,6 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | |||
3351 | 3357 | ||
3352 | snd_iprintf(buffer, "\n"); | 3358 | snd_iprintf(buffer, "\n"); |
3353 | 3359 | ||
3354 | |||
3355 | switch (hdsp_clock_source(hdsp)) { | 3360 | switch (hdsp_clock_source(hdsp)) { |
3356 | case HDSP_CLOCK_SOURCE_AUTOSYNC: | 3361 | case HDSP_CLOCK_SOURCE_AUTOSYNC: |
3357 | clock_source = "AutoSync"; | 3362 | clock_source = "AutoSync"; |
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index 6416d3f0c7be..a69e774d0b13 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c | |||
@@ -885,10 +885,10 @@ static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem | |||
885 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); | 885 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
886 | struct snd_vx222 *chip = (struct snd_vx222 *)_chip; | 886 | struct snd_vx222 *chip = (struct snd_vx222 *)_chip; |
887 | if (ucontrol->value.integer.value[0] < 0 || | 887 | if (ucontrol->value.integer.value[0] < 0 || |
888 | ucontrol->value.integer.value[0] < MIC_LEVEL_MAX) | 888 | ucontrol->value.integer.value[0] > MIC_LEVEL_MAX) |
889 | return -EINVAL; | 889 | return -EINVAL; |
890 | if (ucontrol->value.integer.value[1] < 0 || | 890 | if (ucontrol->value.integer.value[1] < 0 || |
891 | ucontrol->value.integer.value[1] < MIC_LEVEL_MAX) | 891 | ucontrol->value.integer.value[1] > MIC_LEVEL_MAX) |
892 | return -EINVAL; | 892 | return -EINVAL; |
893 | mutex_lock(&_chip->mixer_mutex); | 893 | mutex_lock(&_chip->mixer_mutex); |
894 | if (chip->input_level[0] != ucontrol->value.integer.value[0] || | 894 | if (chip->input_level[0] != ucontrol->value.integer.value[0] || |
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 2f0925236a1b..5518371db13f 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c | |||
@@ -834,7 +834,7 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id) | |||
834 | status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG); | 834 | status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG); |
835 | if (status & 1) { | 835 | if (status & 1) { |
836 | if (chip->timer) | 836 | if (chip->timer) |
837 | snd_timer_interrupt(chip->timer, chip->timer->sticks); | 837 | snd_timer_interrupt(chip->timer, chip->timer_ticks); |
838 | } | 838 | } |
839 | snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status); | 839 | snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status); |
840 | 840 | ||
@@ -1885,8 +1885,18 @@ static int snd_ymfpci_timer_start(struct snd_timer *timer) | |||
1885 | unsigned int count; | 1885 | unsigned int count; |
1886 | 1886 | ||
1887 | chip = snd_timer_chip(timer); | 1887 | chip = snd_timer_chip(timer); |
1888 | count = (timer->sticks << 1) - 1; | ||
1889 | spin_lock_irqsave(&chip->reg_lock, flags); | 1888 | spin_lock_irqsave(&chip->reg_lock, flags); |
1889 | if (timer->sticks > 1) { | ||
1890 | chip->timer_ticks = timer->sticks; | ||
1891 | count = timer->sticks - 1; | ||
1892 | } else { | ||
1893 | /* | ||
1894 | * Divisor 1 is not allowed; fake it by using divisor 2 and | ||
1895 | * counting two ticks for each interrupt. | ||
1896 | */ | ||
1897 | chip->timer_ticks = 2; | ||
1898 | count = 2 - 1; | ||
1899 | } | ||
1890 | snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); | 1900 | snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); |
1891 | snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); | 1901 | snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); |
1892 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1902 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
@@ -1909,14 +1919,14 @@ static int snd_ymfpci_timer_precise_resolution(struct snd_timer *timer, | |||
1909 | unsigned long *num, unsigned long *den) | 1919 | unsigned long *num, unsigned long *den) |
1910 | { | 1920 | { |
1911 | *num = 1; | 1921 | *num = 1; |
1912 | *den = 48000; | 1922 | *den = 96000; |
1913 | return 0; | 1923 | return 0; |
1914 | } | 1924 | } |
1915 | 1925 | ||
1916 | static struct snd_timer_hardware snd_ymfpci_timer_hw = { | 1926 | static struct snd_timer_hardware snd_ymfpci_timer_hw = { |
1917 | .flags = SNDRV_TIMER_HW_AUTO, | 1927 | .flags = SNDRV_TIMER_HW_AUTO, |
1918 | .resolution = 20833, /* 1/fs = 20.8333...us */ | 1928 | .resolution = 10417, /* 1 / 96 kHz = 10.41666...us */ |
1919 | .ticks = 0x8000, | 1929 | .ticks = 0x10000, |
1920 | .start = snd_ymfpci_timer_start, | 1930 | .start = snd_ymfpci_timer_start, |
1921 | .stop = snd_ymfpci_timer_stop, | 1931 | .stop = snd_ymfpci_timer_stop, |
1922 | .precise_resolution = snd_ymfpci_timer_precise_resolution, | 1932 | .precise_resolution = snd_ymfpci_timer_precise_resolution, |