aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig124
-rw-r--r--sound/pci/hda/Kconfig188
-rw-r--r--sound/pci/hda/Makefile75
-rw-r--r--sound/pci/hda/hda_beep.c2
-rw-r--r--sound/pci/hda/hda_codec.c777
-rw-r--r--sound/pci/hda/hda_codec.h105
-rw-r--r--sound/pci/hda/hda_eld.c590
-rw-r--r--sound/pci/hda/hda_generic.c21
-rw-r--r--sound/pci/hda/hda_hwdep.c234
-rw-r--r--sound/pci/hda/hda_intel.c329
-rw-r--r--sound/pci/hda/hda_local.h100
-rw-r--r--sound/pci/hda/hda_patch.h22
-rw-r--r--sound/pci/hda/hda_proc.c91
-rw-r--r--sound/pci/hda/patch_analog.c132
-rw-r--r--sound/pci/hda/patch_atihdmi.c40
-rw-r--r--sound/pci/hda/patch_cmedia.c27
-rw-r--r--sound/pci/hda/patch_conexant.c39
-rw-r--r--sound/pci/hda/patch_intelhdmi.c711
-rw-r--r--sound/pci/hda/patch_nvhdmi.c32
-rw-r--r--sound/pci/hda/patch_realtek.c1663
-rw-r--r--sound/pci/hda/patch_si3054.c35
-rw-r--r--sound/pci/hda/patch_sigmatel.c782
-rw-r--r--sound/pci/hda/patch_via.c171
23 files changed, 4535 insertions, 1755 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 7003711f4fcc..caebf296b62b 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -497,129 +497,7 @@ config SND_FM801_TEA575X
497 depends on SND_FM801_TEA575X_BOOL 497 depends on SND_FM801_TEA575X_BOOL
498 default SND_FM801 498 default SND_FM801
499 499
500config SND_HDA_INTEL 500source "sound/pci/hda/Kconfig"
501 tristate "Intel HD Audio"
502 select SND_PCM
503 select SND_VMASTER
504 help
505 Say Y here to include support for Intel "High Definition
506 Audio" (Azalia) motherboard devices.
507
508 To compile this driver as a module, choose M here: the module
509 will be called snd-hda-intel.
510
511config SND_HDA_HWDEP
512 bool "Build hwdep interface for HD-audio driver"
513 depends on SND_HDA_INTEL
514 select SND_HWDEP
515 help
516 Say Y here to build a hwdep interface for HD-audio driver.
517 This interface can be used for out-of-band communication
518 with codecs for debugging purposes.
519
520config SND_HDA_INPUT_BEEP
521 bool "Support digital beep via input layer"
522 depends on SND_HDA_INTEL
523 depends on INPUT=y || INPUT=SND_HDA_INTEL
524 help
525 Say Y here to build a digital beep interface for HD-audio
526 driver. This interface is used to generate digital beeps.
527
528config SND_HDA_CODEC_REALTEK
529 bool "Build Realtek HD-audio codec support"
530 depends on SND_HDA_INTEL
531 default y
532 help
533 Say Y here to include Realtek HD-audio codec support in
534 snd-hda-intel driver, such as ALC880.
535
536config SND_HDA_CODEC_ANALOG
537 bool "Build Analog Device HD-audio codec support"
538 depends on SND_HDA_INTEL
539 default y
540 help
541 Say Y here to include Analog Device HD-audio codec support in
542 snd-hda-intel driver, such as AD1986A.
543
544config SND_HDA_CODEC_SIGMATEL
545 bool "Build IDT/Sigmatel HD-audio codec support"
546 depends on SND_HDA_INTEL
547 default y
548 help
549 Say Y here to include IDT (Sigmatel) HD-audio codec support in
550 snd-hda-intel driver, such as STAC9200.
551
552config SND_HDA_CODEC_VIA
553 bool "Build VIA HD-audio codec support"
554 depends on SND_HDA_INTEL
555 default y
556 help
557 Say Y here to include VIA HD-audio codec support in
558 snd-hda-intel driver, such as VT1708.
559
560config SND_HDA_CODEC_ATIHDMI
561 bool "Build ATI HDMI HD-audio codec support"
562 depends on SND_HDA_INTEL
563 default y
564 help
565 Say Y here to include ATI HDMI HD-audio codec support in
566 snd-hda-intel driver, such as ATI RS600 HDMI.
567
568config SND_HDA_CODEC_NVHDMI
569 bool "Build NVIDIA HDMI HD-audio codec support"
570 depends on SND_HDA_INTEL
571 default y
572 help
573 Say Y here to include NVIDIA HDMI HD-audio codec support in
574 snd-hda-intel driver, such as NVIDIA MCP78 HDMI.
575
576config SND_HDA_CODEC_CONEXANT
577 bool "Build Conexant HD-audio codec support"
578 depends on SND_HDA_INTEL
579 default y
580 help
581 Say Y here to include Conexant HD-audio codec support in
582 snd-hda-intel driver, such as CX20549.
583
584config SND_HDA_CODEC_CMEDIA
585 bool "Build C-Media HD-audio codec support"
586 depends on SND_HDA_INTEL
587 default y
588 help
589 Say Y here to include C-Media HD-audio codec support in
590 snd-hda-intel driver, such as CMI9880.
591
592config SND_HDA_CODEC_SI3054
593 bool "Build Silicon Labs 3054 HD-modem codec support"
594 depends on SND_HDA_INTEL
595 default y
596 help
597 Say Y here to include Silicon Labs 3054 HD-modem codec
598 (and compatibles) support in snd-hda-intel driver.
599
600config SND_HDA_GENERIC
601 bool "Enable generic HD-audio codec parser"
602 depends on SND_HDA_INTEL
603 default y
604 help
605 Say Y here to enable the generic HD-audio codec parser
606 in snd-hda-intel driver.
607
608config SND_HDA_POWER_SAVE
609 bool "Aggressive power-saving on HD-audio"
610 depends on SND_HDA_INTEL && EXPERIMENTAL
611 help
612 Say Y here to enable more aggressive power-saving mode on
613 HD-audio driver. The power-saving timeout can be configured
614 via power_save option or over sysfs on-the-fly.
615
616config SND_HDA_POWER_SAVE_DEFAULT
617 int "Default time-out for HD-audio power-save mode"
618 depends on SND_HDA_POWER_SAVE
619 default 0
620 help
621 The default time-out value in seconds for HD-audio automatic
622 power-save mode. 0 means to disable the power-save mode.
623 501
624config SND_HDSP 502config SND_HDSP
625 tristate "RME Hammerfall DSP Audio" 503 tristate "RME Hammerfall DSP Audio"
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
new file mode 100644
index 000000000000..eb2a19b894a0
--- /dev/null
+++ b/sound/pci/hda/Kconfig
@@ -0,0 +1,188 @@
1menuconfig SND_HDA_INTEL
2 tristate "Intel HD Audio"
3 select SND_PCM
4 select SND_VMASTER
5 select SND_JACK if INPUT=y || INPUT=SND
6 help
7 Say Y here to include support for Intel "High Definition
8 Audio" (Azalia) and its compatible devices.
9
10 This option enables the HD-audio controller. Don't forget
11 to choose the appropriate codec options below.
12
13 To compile this driver as a module, choose M here: the module
14 will be called snd-hda-intel.
15
16if SND_HDA_INTEL
17
18config SND_HDA_HWDEP
19 bool "Build hwdep interface for HD-audio driver"
20 select SND_HWDEP
21 help
22 Say Y here to build a hwdep interface for HD-audio driver.
23 This interface can be used for out-of-band communication
24 with codecs for debugging purposes.
25
26config SND_HDA_RECONFIG
27 bool "Allow dynamic codec reconfiguration (EXPERIMENTAL)"
28 depends on SND_HDA_HWDEP && EXPERIMENTAL
29 help
30 Say Y here to enable the HD-audio codec re-configuration feature.
31 This adds the sysfs interfaces to allow user to clear the whole
32 codec configuration, change the codec setup, add extra verbs,
33 and re-configure the codec dynamically.
34
35config SND_HDA_INPUT_BEEP
36 bool "Support digital beep via input layer"
37 depends on INPUT=y || INPUT=SND_HDA_INTEL
38 help
39 Say Y here to build a digital beep interface for HD-audio
40 driver. This interface is used to generate digital beeps.
41
42config SND_HDA_CODEC_REALTEK
43 bool "Build Realtek HD-audio codec support"
44 default y
45 help
46 Say Y here to include Realtek HD-audio codec support in
47 snd-hda-intel driver, such as ALC880.
48
49 When the HD-audio driver is built as a module, the codec
50 support code is also built as another module,
51 snd-hda-codec-realtek.
52 This module is automatically loaded at probing.
53
54config SND_HDA_CODEC_ANALOG
55 bool "Build Analog Device HD-audio codec support"
56 default y
57 help
58 Say Y here to include Analog Device HD-audio codec support in
59 snd-hda-intel driver, such as AD1986A.
60
61 When the HD-audio driver is built as a module, the codec
62 support code is also built as another module,
63 snd-hda-codec-analog.
64 This module is automatically loaded at probing.
65
66config SND_HDA_CODEC_SIGMATEL
67 bool "Build IDT/Sigmatel HD-audio codec support"
68 default y
69 help
70 Say Y here to include IDT (Sigmatel) HD-audio codec support in
71 snd-hda-intel driver, such as STAC9200.
72
73 When the HD-audio driver is built as a module, the codec
74 support code is also built as another module,
75 snd-hda-codec-idt.
76 This module is automatically loaded at probing.
77
78config SND_HDA_CODEC_VIA
79 bool "Build VIA HD-audio codec support"
80 default y
81 help
82 Say Y here to include VIA HD-audio codec support in
83 snd-hda-intel driver, such as VT1708.
84
85 When the HD-audio driver is built as a module, the codec
86 support code is also built as another module,
87 snd-hda-codec-via.
88 This module is automatically loaded at probing.
89
90config SND_HDA_CODEC_ATIHDMI
91 bool "Build ATI HDMI HD-audio codec support"
92 default y
93 help
94 Say Y here to include ATI HDMI HD-audio codec support in
95 snd-hda-intel driver, such as ATI RS600 HDMI.
96
97 When the HD-audio driver is built as a module, the codec
98 support code is also built as another module,
99 snd-hda-codec-atihdmi.
100 This module is automatically loaded at probing.
101
102config SND_HDA_CODEC_NVHDMI
103 bool "Build NVIDIA HDMI HD-audio codec support"
104 default y
105 help
106 Say Y here to include NVIDIA HDMI HD-audio codec support in
107 snd-hda-intel driver, such as NVIDIA MCP78 HDMI.
108
109 When the HD-audio driver is built as a module, the codec
110 support code is also built as another module,
111 snd-hda-codec-nvhdmi.
112 This module is automatically loaded at probing.
113
114config SND_HDA_CODEC_INTELHDMI
115 bool "Build INTEL HDMI HD-audio codec support"
116 default y
117 help
118 Say Y here to include INTEL HDMI HD-audio codec support in
119 snd-hda-intel driver, such as Eaglelake integrated HDMI.
120
121 When the HD-audio driver is built as a module, the codec
122 support code is also built as another module,
123 snd-hda-codec-intelhdmi.
124 This module is automatically loaded at probing.
125
126config SND_HDA_ELD
127 def_bool y
128 depends on SND_HDA_CODEC_INTELHDMI
129
130config SND_HDA_CODEC_CONEXANT
131 bool "Build Conexant HD-audio codec support"
132 default y
133 help
134 Say Y here to include Conexant HD-audio codec support in
135 snd-hda-intel driver, such as CX20549.
136
137 When the HD-audio driver is built as a module, the codec
138 support code is also built as another module,
139 snd-hda-codec-conexant.
140 This module is automatically loaded at probing.
141
142config SND_HDA_CODEC_CMEDIA
143 bool "Build C-Media HD-audio codec support"
144 default y
145 help
146 Say Y here to include C-Media HD-audio codec support in
147 snd-hda-intel driver, such as CMI9880.
148
149 When the HD-audio driver is built as a module, the codec
150 support code is also built as another module,
151 snd-hda-codec-cmedia.
152 This module is automatically loaded at probing.
153
154config SND_HDA_CODEC_SI3054
155 bool "Build Silicon Labs 3054 HD-modem codec support"
156 default y
157 help
158 Say Y here to include Silicon Labs 3054 HD-modem codec
159 (and compatibles) support in snd-hda-intel driver.
160
161 When the HD-audio driver is built as a module, the codec
162 support code is also built as another module,
163 snd-hda-codec-si3054.
164 This module is automatically loaded at probing.
165
166config SND_HDA_GENERIC
167 bool "Enable generic HD-audio codec parser"
168 default y
169 help
170 Say Y here to enable the generic HD-audio codec parser
171 in snd-hda-intel driver.
172
173config SND_HDA_POWER_SAVE
174 bool "Aggressive power-saving on HD-audio"
175 help
176 Say Y here to enable more aggressive power-saving mode on
177 HD-audio driver. The power-saving timeout can be configured
178 via power_save option or over sysfs on-the-fly.
179
180config SND_HDA_POWER_SAVE_DEFAULT
181 int "Default time-out for HD-audio power-save mode"
182 depends on SND_HDA_POWER_SAVE
183 default 0
184 help
185 The default time-out value in seconds for HD-audio automatic
186 power-save mode. 0 means to disable the power-save mode.
187
188endif
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 1980c6d207e7..50f9d0967251 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,20 +1,59 @@
1snd-hda-intel-y := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally
4# designed to be individual modules
5snd-hda-intel-y += hda_codec.o
6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o
7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8snd-hda-intel-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
9snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
10snd-hda-intel-$(CONFIG_SND_HDA_CODEC_REALTEK) += patch_realtek.o
11snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CMEDIA) += patch_cmedia.o
12snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ANALOG) += patch_analog.o
13snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SIGMATEL) += patch_sigmatel.o
14snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SI3054) += patch_si3054.o
15snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o
16snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o
17snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o
18snd-hda-intel-$(CONFIG_SND_HDA_CODEC_NVHDMI) += patch_nvhdmi.o
19 2
3snd-hda-codec-y := hda_codec.o
4snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
5snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
6# snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o
7snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
9
10snd-hda-codec-realtek-objs := patch_realtek.o
11snd-hda-codec-cmedia-objs := patch_cmedia.o
12snd-hda-codec-analog-objs := patch_analog.o
13snd-hda-codec-idt-objs := patch_sigmatel.o
14snd-hda-codec-si3054-objs := patch_si3054.o
15snd-hda-codec-atihdmi-objs := patch_atihdmi.o
16snd-hda-codec-conexant-objs := patch_conexant.o
17snd-hda-codec-via-objs := patch_via.o
18snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o
19snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o hda_eld.o
20
21# common driver
22obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o
23
24# codec drivers (note: CONFIG_SND_HDA_CODEC_XXX are booleans)
25ifdef CONFIG_SND_HDA_CODEC_REALTEK
26obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-realtek.o
27endif
28ifdef CONFIG_SND_HDA_CODEC_CMEDIA
29obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-cmedia.o
30endif
31ifdef CONFIG_SND_HDA_CODEC_ANALOG
32obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-analog.o
33endif
34ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
35obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-idt.o
36endif
37ifdef CONFIG_SND_HDA_CODEC_SI3054
38obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-si3054.o
39endif
40ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
41obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o
42endif
43ifdef CONFIG_SND_HDA_CODEC_CONEXANT
44obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-conexant.o
45endif
46ifdef CONFIG_SND_HDA_CODEC_VIA
47obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-via.o
48endif
49ifdef CONFIG_SND_HDA_CODEC_NVHDMI
50obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-nvhdmi.o
51endif
52ifdef CONFIG_SND_HDA_CODEC_INTELHDMI
53obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-intelhdmi.o
54endif
55
56# this must be the last entry after codec drivers;
57# otherwise the codec patches won't be hooked before the PCI probe
58# when built in kernel
20obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o 59obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 3ecd7e797dee..e00421c0d8ba 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -128,6 +128,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
128 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep); 128 INIT_WORK(&beep->beep_work, &snd_hda_generate_beep);
129 return 0; 129 return 0;
130} 130}
131EXPORT_SYMBOL_HDA(snd_hda_attach_beep_device);
131 132
132void snd_hda_detach_beep_device(struct hda_codec *codec) 133void snd_hda_detach_beep_device(struct hda_codec *codec)
133{ 134{
@@ -140,3 +141,4 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
140 kfree(beep); 141 kfree(beep);
141 } 142 }
142} 143}
144EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device);
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index eb9164176dab..625fe5984dd6 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -31,15 +31,6 @@
31#include <sound/initval.h> 31#include <sound/initval.h>
32#include "hda_local.h" 32#include "hda_local.h"
33#include <sound/hda_hwdep.h> 33#include <sound/hda_hwdep.h>
34#include "hda_patch.h" /* codec presets */
35
36#ifdef CONFIG_SND_HDA_POWER_SAVE
37/* define this option here to hide as static */
38static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
39module_param(power_save, int, 0644);
40MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
41 "(in second, 0 = disable).");
42#endif
43 34
44/* 35/*
45 * vendor / preset table 36 * vendor / preset table
@@ -55,6 +46,7 @@ static struct hda_vendor_id hda_vendor_ids[] = {
55 { 0x1002, "ATI" }, 46 { 0x1002, "ATI" },
56 { 0x1057, "Motorola" }, 47 { 0x1057, "Motorola" },
57 { 0x1095, "Silicon Image" }, 48 { 0x1095, "Silicon Image" },
49 { 0x10de, "Nvidia" },
58 { 0x10ec, "Realtek" }, 50 { 0x10ec, "Realtek" },
59 { 0x1106, "VIA" }, 51 { 0x1106, "VIA" },
60 { 0x111d, "IDT" }, 52 { 0x111d, "IDT" },
@@ -66,40 +58,31 @@ static struct hda_vendor_id hda_vendor_ids[] = {
66 { 0x1854, "LG" }, 58 { 0x1854, "LG" },
67 { 0x1aec, "Wolfson Microelectronics" }, 59 { 0x1aec, "Wolfson Microelectronics" },
68 { 0x434d, "C-Media" }, 60 { 0x434d, "C-Media" },
61 { 0x8086, "Intel" },
69 { 0x8384, "SigmaTel" }, 62 { 0x8384, "SigmaTel" },
70 {} /* terminator */ 63 {} /* terminator */
71}; 64};
72 65
73static const struct hda_codec_preset *hda_preset_tables[] = { 66static DEFINE_MUTEX(preset_mutex);
74#ifdef CONFIG_SND_HDA_CODEC_REALTEK 67static LIST_HEAD(hda_preset_tables);
75 snd_hda_preset_realtek, 68
76#endif 69int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset)
77#ifdef CONFIG_SND_HDA_CODEC_CMEDIA 70{
78 snd_hda_preset_cmedia, 71 mutex_lock(&preset_mutex);
79#endif 72 list_add_tail(&preset->list, &hda_preset_tables);
80#ifdef CONFIG_SND_HDA_CODEC_ANALOG 73 mutex_unlock(&preset_mutex);
81 snd_hda_preset_analog, 74 return 0;
82#endif 75}
83#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL 76EXPORT_SYMBOL_HDA(snd_hda_add_codec_preset);
84 snd_hda_preset_sigmatel, 77
85#endif 78int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset)
86#ifdef CONFIG_SND_HDA_CODEC_SI3054 79{
87 snd_hda_preset_si3054, 80 mutex_lock(&preset_mutex);
88#endif 81 list_del(&preset->list);
89#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI 82 mutex_unlock(&preset_mutex);
90 snd_hda_preset_atihdmi, 83 return 0;
91#endif 84}
92#ifdef CONFIG_SND_HDA_CODEC_CONEXANT 85EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset);
93 snd_hda_preset_conexant,
94#endif
95#ifdef CONFIG_SND_HDA_CODEC_VIA
96 snd_hda_preset_via,
97#endif
98#ifdef CONFIG_SND_HDA_CODEC_NVHDMI
99 snd_hda_preset_nvhdmi,
100#endif
101 NULL
102};
103 86
104#ifdef CONFIG_SND_HDA_POWER_SAVE 87#ifdef CONFIG_SND_HDA_POWER_SAVE
105static void hda_power_work(struct work_struct *work); 88static void hda_power_work(struct work_struct *work);
@@ -108,6 +91,72 @@ static void hda_keep_power_on(struct hda_codec *codec);
108static inline void hda_keep_power_on(struct hda_codec *codec) {} 91static inline void hda_keep_power_on(struct hda_codec *codec) {}
109#endif 92#endif
110 93
94const char *snd_hda_get_jack_location(u32 cfg)
95{
96 static char *bases[7] = {
97 "N/A", "Rear", "Front", "Left", "Right", "Top", "Bottom",
98 };
99 static unsigned char specials_idx[] = {
100 0x07, 0x08,
101 0x17, 0x18, 0x19,
102 0x37, 0x38
103 };
104 static char *specials[] = {
105 "Rear Panel", "Drive Bar",
106 "Riser", "HDMI", "ATAPI",
107 "Mobile-In", "Mobile-Out"
108 };
109 int i;
110 cfg = (cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT;
111 if ((cfg & 0x0f) < 7)
112 return bases[cfg & 0x0f];
113 for (i = 0; i < ARRAY_SIZE(specials_idx); i++) {
114 if (cfg == specials_idx[i])
115 return specials[i];
116 }
117 return "UNKNOWN";
118}
119EXPORT_SYMBOL_HDA(snd_hda_get_jack_location);
120
121const char *snd_hda_get_jack_connectivity(u32 cfg)
122{
123 static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" };
124
125 return jack_locations[(cfg >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3];
126}
127EXPORT_SYMBOL_HDA(snd_hda_get_jack_connectivity);
128
129const char *snd_hda_get_jack_type(u32 cfg)
130{
131 static char *jack_types[16] = {
132 "Line Out", "Speaker", "HP Out", "CD",
133 "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand",
134 "Line In", "Aux", "Mic", "Telephony",
135 "SPDIF In", "Digitial In", "Reserved", "Other"
136 };
137
138 return jack_types[(cfg & AC_DEFCFG_DEVICE)
139 >> AC_DEFCFG_DEVICE_SHIFT];
140}
141EXPORT_SYMBOL_HDA(snd_hda_get_jack_type);
142
143/*
144 * Compose a 32bit command word to be sent to the HD-audio controller
145 */
146static inline unsigned int
147make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,
148 unsigned int verb, unsigned int parm)
149{
150 u32 val;
151
152 val = (u32)(codec->addr & 0x0f) << 28;
153 val |= (u32)direct << 27;
154 val |= (u32)nid << 20;
155 val |= verb << 8;
156 val |= parm;
157 return val;
158}
159
111/** 160/**
112 * snd_hda_codec_read - send a command and get the response 161 * snd_hda_codec_read - send a command and get the response
113 * @codec: the HDA codec 162 * @codec: the HDA codec
@@ -124,17 +173,21 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
124 int direct, 173 int direct,
125 unsigned int verb, unsigned int parm) 174 unsigned int verb, unsigned int parm)
126{ 175{
176 struct hda_bus *bus = codec->bus;
127 unsigned int res; 177 unsigned int res;
178
179 res = make_codec_cmd(codec, nid, direct, verb, parm);
128 snd_hda_power_up(codec); 180 snd_hda_power_up(codec);
129 mutex_lock(&codec->bus->cmd_mutex); 181 mutex_lock(&bus->cmd_mutex);
130 if (!codec->bus->ops.command(codec, nid, direct, verb, parm)) 182 if (!bus->ops.command(bus, res))
131 res = codec->bus->ops.get_response(codec); 183 res = bus->ops.get_response(bus);
132 else 184 else
133 res = (unsigned int)-1; 185 res = (unsigned int)-1;
134 mutex_unlock(&codec->bus->cmd_mutex); 186 mutex_unlock(&bus->cmd_mutex);
135 snd_hda_power_down(codec); 187 snd_hda_power_down(codec);
136 return res; 188 return res;
137} 189}
190EXPORT_SYMBOL_HDA(snd_hda_codec_read);
138 191
139/** 192/**
140 * snd_hda_codec_write - send a single command without waiting for response 193 * snd_hda_codec_write - send a single command without waiting for response
@@ -151,14 +204,19 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
151int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct, 204int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
152 unsigned int verb, unsigned int parm) 205 unsigned int verb, unsigned int parm)
153{ 206{
207 struct hda_bus *bus = codec->bus;
208 unsigned int res;
154 int err; 209 int err;
210
211 res = make_codec_cmd(codec, nid, direct, verb, parm);
155 snd_hda_power_up(codec); 212 snd_hda_power_up(codec);
156 mutex_lock(&codec->bus->cmd_mutex); 213 mutex_lock(&bus->cmd_mutex);
157 err = codec->bus->ops.command(codec, nid, direct, verb, parm); 214 err = bus->ops.command(bus, res);
158 mutex_unlock(&codec->bus->cmd_mutex); 215 mutex_unlock(&bus->cmd_mutex);
159 snd_hda_power_down(codec); 216 snd_hda_power_down(codec);
160 return err; 217 return err;
161} 218}
219EXPORT_SYMBOL_HDA(snd_hda_codec_write);
162 220
163/** 221/**
164 * snd_hda_sequence_write - sequence writes 222 * snd_hda_sequence_write - sequence writes
@@ -173,6 +231,7 @@ void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
173 for (; seq->nid; seq++) 231 for (; seq->nid; seq++)
174 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); 232 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
175} 233}
234EXPORT_SYMBOL_HDA(snd_hda_sequence_write);
176 235
177/** 236/**
178 * snd_hda_get_sub_nodes - get the range of sub nodes 237 * snd_hda_get_sub_nodes - get the range of sub nodes
@@ -194,6 +253,7 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
194 *start_id = (parm >> 16) & 0x7fff; 253 *start_id = (parm >> 16) & 0x7fff;
195 return (int)(parm & 0x7fff); 254 return (int)(parm & 0x7fff);
196} 255}
256EXPORT_SYMBOL_HDA(snd_hda_get_sub_nodes);
197 257
198/** 258/**
199 * snd_hda_get_connections - get connection list 259 * snd_hda_get_connections - get connection list
@@ -282,6 +342,7 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
282 } 342 }
283 return conns; 343 return conns;
284} 344}
345EXPORT_SYMBOL_HDA(snd_hda_get_connections);
285 346
286 347
287/** 348/**
@@ -316,6 +377,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
316 377
317 return 0; 378 return 0;
318} 379}
380EXPORT_SYMBOL_HDA(snd_hda_queue_unsol_event);
319 381
320/* 382/*
321 * process queued unsolicited events 383 * process queued unsolicited events
@@ -345,7 +407,7 @@ static void process_unsol_events(struct work_struct *work)
345/* 407/*
346 * initialize unsolicited queue 408 * initialize unsolicited queue
347 */ 409 */
348static int __devinit init_unsol_queue(struct hda_bus *bus) 410static int init_unsol_queue(struct hda_bus *bus)
349{ 411{
350 struct hda_bus_unsolicited *unsol; 412 struct hda_bus_unsolicited *unsol;
351 413
@@ -391,9 +453,24 @@ static int snd_hda_bus_free(struct hda_bus *bus)
391static int snd_hda_bus_dev_free(struct snd_device *device) 453static int snd_hda_bus_dev_free(struct snd_device *device)
392{ 454{
393 struct hda_bus *bus = device->device_data; 455 struct hda_bus *bus = device->device_data;
456 bus->shutdown = 1;
394 return snd_hda_bus_free(bus); 457 return snd_hda_bus_free(bus);
395} 458}
396 459
460#ifdef CONFIG_SND_HDA_HWDEP
461static int snd_hda_bus_dev_register(struct snd_device *device)
462{
463 struct hda_bus *bus = device->device_data;
464 struct hda_codec *codec;
465 list_for_each_entry(codec, &bus->codec_list, list) {
466 snd_hda_hwdep_add_sysfs(codec);
467 }
468 return 0;
469}
470#else
471#define snd_hda_bus_dev_register NULL
472#endif
473
397/** 474/**
398 * snd_hda_bus_new - create a HDA bus 475 * snd_hda_bus_new - create a HDA bus
399 * @card: the card entry 476 * @card: the card entry
@@ -402,13 +479,14 @@ static int snd_hda_bus_dev_free(struct snd_device *device)
402 * 479 *
403 * Returns 0 if successful, or a negative error code. 480 * Returns 0 if successful, or a negative error code.
404 */ 481 */
405int __devinit snd_hda_bus_new(struct snd_card *card, 482int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
406 const struct hda_bus_template *temp, 483 const struct hda_bus_template *temp,
407 struct hda_bus **busp) 484 struct hda_bus **busp)
408{ 485{
409 struct hda_bus *bus; 486 struct hda_bus *bus;
410 int err; 487 int err;
411 static struct snd_device_ops dev_ops = { 488 static struct snd_device_ops dev_ops = {
489 .dev_register = snd_hda_bus_dev_register,
412 .dev_free = snd_hda_bus_dev_free, 490 .dev_free = snd_hda_bus_dev_free,
413 }; 491 };
414 492
@@ -430,6 +508,7 @@ int __devinit snd_hda_bus_new(struct snd_card *card,
430 bus->private_data = temp->private_data; 508 bus->private_data = temp->private_data;
431 bus->pci = temp->pci; 509 bus->pci = temp->pci;
432 bus->modelname = temp->modelname; 510 bus->modelname = temp->modelname;
511 bus->power_save = temp->power_save;
433 bus->ops = temp->ops; 512 bus->ops = temp->ops;
434 513
435 mutex_init(&bus->cmd_mutex); 514 mutex_init(&bus->cmd_mutex);
@@ -444,27 +523,42 @@ int __devinit snd_hda_bus_new(struct snd_card *card,
444 *busp = bus; 523 *busp = bus;
445 return 0; 524 return 0;
446} 525}
526EXPORT_SYMBOL_HDA(snd_hda_bus_new);
447 527
448#ifdef CONFIG_SND_HDA_GENERIC 528#ifdef CONFIG_SND_HDA_GENERIC
449#define is_generic_config(codec) \ 529#define is_generic_config(codec) \
450 (codec->bus->modelname && !strcmp(codec->bus->modelname, "generic")) 530 (codec->modelname && !strcmp(codec->modelname, "generic"))
451#else 531#else
452#define is_generic_config(codec) 0 532#define is_generic_config(codec) 0
453#endif 533#endif
454 534
535#ifdef MODULE
536#define HDA_MODREQ_MAX_COUNT 2 /* two request_modules()'s */
537#else
538#define HDA_MODREQ_MAX_COUNT 0 /* all presets are statically linked */
539#endif
540
455/* 541/*
456 * find a matching codec preset 542 * find a matching codec preset
457 */ 543 */
458static const struct hda_codec_preset __devinit * 544static const struct hda_codec_preset *
459find_codec_preset(struct hda_codec *codec) 545find_codec_preset(struct hda_codec *codec)
460{ 546{
461 const struct hda_codec_preset **tbl, *preset; 547 struct hda_codec_preset_list *tbl;
548 const struct hda_codec_preset *preset;
549 int mod_requested = 0;
462 550
463 if (is_generic_config(codec)) 551 if (is_generic_config(codec))
464 return NULL; /* use the generic parser */ 552 return NULL; /* use the generic parser */
465 553
466 for (tbl = hda_preset_tables; *tbl; tbl++) { 554 again:
467 for (preset = *tbl; preset->id; preset++) { 555 mutex_lock(&preset_mutex);
556 list_for_each_entry(tbl, &hda_preset_tables, list) {
557 if (!try_module_get(tbl->owner)) {
558 snd_printk(KERN_ERR "hda_codec: cannot module_get\n");
559 continue;
560 }
561 for (preset = tbl->preset; preset->id; preset++) {
468 u32 mask = preset->mask; 562 u32 mask = preset->mask;
469 if (preset->afg && preset->afg != codec->afg) 563 if (preset->afg && preset->afg != codec->afg)
470 continue; 564 continue;
@@ -474,23 +568,40 @@ find_codec_preset(struct hda_codec *codec)
474 mask = ~0; 568 mask = ~0;
475 if (preset->id == (codec->vendor_id & mask) && 569 if (preset->id == (codec->vendor_id & mask) &&
476 (!preset->rev || 570 (!preset->rev ||
477 preset->rev == codec->revision_id)) 571 preset->rev == codec->revision_id)) {
572 mutex_unlock(&preset_mutex);
573 codec->owner = tbl->owner;
478 return preset; 574 return preset;
575 }
479 } 576 }
577 module_put(tbl->owner);
578 }
579 mutex_unlock(&preset_mutex);
580
581 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
582 char name[32];
583 if (!mod_requested)
584 snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
585 codec->vendor_id);
586 else
587 snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
588 (codec->vendor_id >> 16) & 0xffff);
589 request_module(name);
590 mod_requested++;
591 goto again;
480 } 592 }
481 return NULL; 593 return NULL;
482} 594}
483 595
484/* 596/*
485 * snd_hda_get_codec_name - store the codec name 597 * get_codec_name - store the codec name
486 */ 598 */
487void snd_hda_get_codec_name(struct hda_codec *codec, 599static int get_codec_name(struct hda_codec *codec)
488 char *name, int namelen)
489{ 600{
490 const struct hda_vendor_id *c; 601 const struct hda_vendor_id *c;
491 const char *vendor = NULL; 602 const char *vendor = NULL;
492 u16 vendor_id = codec->vendor_id >> 16; 603 u16 vendor_id = codec->vendor_id >> 16;
493 char tmp[16]; 604 char tmp[16], name[32];
494 605
495 for (c = hda_vendor_ids; c->id; c++) { 606 for (c = hda_vendor_ids; c->id; c++) {
496 if (c->id == vendor_id) { 607 if (c->id == vendor_id) {
@@ -503,16 +614,21 @@ void snd_hda_get_codec_name(struct hda_codec *codec,
503 vendor = tmp; 614 vendor = tmp;
504 } 615 }
505 if (codec->preset && codec->preset->name) 616 if (codec->preset && codec->preset->name)
506 snprintf(name, namelen, "%s %s", vendor, codec->preset->name); 617 snprintf(name, sizeof(name), "%s %s", vendor,
618 codec->preset->name);
507 else 619 else
508 snprintf(name, namelen, "%s ID %x", vendor, 620 snprintf(name, sizeof(name), "%s ID %x", vendor,
509 codec->vendor_id & 0xffff); 621 codec->vendor_id & 0xffff);
622 codec->name = kstrdup(name, GFP_KERNEL);
623 if (!codec->name)
624 return -ENOMEM;
625 return 0;
510} 626}
511 627
512/* 628/*
513 * look for an AFG and MFG nodes 629 * look for an AFG and MFG nodes
514 */ 630 */
515static void __devinit setup_fg_nodes(struct hda_codec *codec) 631static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec)
516{ 632{
517 int i, total_nodes; 633 int i, total_nodes;
518 hda_nid_t nid; 634 hda_nid_t nid;
@@ -571,11 +687,15 @@ static void snd_hda_codec_free(struct hda_codec *codec)
571 flush_scheduled_work(); 687 flush_scheduled_work();
572#endif 688#endif
573 list_del(&codec->list); 689 list_del(&codec->list);
690 snd_array_free(&codec->mixers);
574 codec->bus->caddr_tbl[codec->addr] = NULL; 691 codec->bus->caddr_tbl[codec->addr] = NULL;
575 if (codec->patch_ops.free) 692 if (codec->patch_ops.free)
576 codec->patch_ops.free(codec); 693 codec->patch_ops.free(codec);
694 module_put(codec->owner);
577 free_hda_cache(&codec->amp_cache); 695 free_hda_cache(&codec->amp_cache);
578 free_hda_cache(&codec->cmd_cache); 696 free_hda_cache(&codec->cmd_cache);
697 kfree(codec->name);
698 kfree(codec->modelname);
579 kfree(codec->wcaps); 699 kfree(codec->wcaps);
580 kfree(codec); 700 kfree(codec);
581} 701}
@@ -588,7 +708,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
588 * 708 *
589 * Returns 0 if successful, or a negative error code. 709 * Returns 0 if successful, or a negative error code.
590 */ 710 */
591int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 711int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
592 struct hda_codec **codecp) 712 struct hda_codec **codecp)
593{ 713{
594 struct hda_codec *codec; 714 struct hda_codec *codec;
@@ -617,6 +737,14 @@ int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
617 mutex_init(&codec->spdif_mutex); 737 mutex_init(&codec->spdif_mutex);
618 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 738 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
619 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 739 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
740 snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32);
741 if (codec->bus->modelname) {
742 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
743 if (!codec->modelname) {
744 snd_hda_codec_free(codec);
745 return -ENODEV;
746 }
747 }
620 748
621#ifdef CONFIG_SND_HDA_POWER_SAVE 749#ifdef CONFIG_SND_HDA_POWER_SAVE
622 INIT_DELAYED_WORK(&codec->power_work, hda_power_work); 750 INIT_DELAYED_WORK(&codec->power_work, hda_power_work);
@@ -662,12 +790,42 @@ int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
662 snd_hda_codec_read(codec, nid, 0, 790 snd_hda_codec_read(codec, nid, 0,
663 AC_VERB_GET_SUBSYSTEM_ID, 0); 791 AC_VERB_GET_SUBSYSTEM_ID, 0);
664 } 792 }
793 if (bus->modelname)
794 codec->modelname = kstrdup(bus->modelname, GFP_KERNEL);
795
796 err = snd_hda_codec_configure(codec);
797 if (err < 0) {
798 snd_hda_codec_free(codec);
799 return err;
800 }
801 snd_hda_codec_proc_new(codec);
802
803 snd_hda_create_hwdep(codec);
804
805 sprintf(component, "HDA:%08x,%08x,%08x", codec->vendor_id,
806 codec->subsystem_id, codec->revision_id);
807 snd_component_add(codec->bus->card, component);
808
809 if (codecp)
810 *codecp = codec;
811 return 0;
812}
813EXPORT_SYMBOL_HDA(snd_hda_codec_new);
814
815int snd_hda_codec_configure(struct hda_codec *codec)
816{
817 int err;
665 818
666 codec->preset = find_codec_preset(codec); 819 codec->preset = find_codec_preset(codec);
820 if (!codec->name) {
821 err = get_codec_name(codec);
822 if (err < 0)
823 return err;
824 }
667 /* audio codec should override the mixer name */ 825 /* audio codec should override the mixer name */
668 if (codec->afg || !*bus->card->mixername) 826 if (codec->afg || !*codec->bus->card->mixername)
669 snd_hda_get_codec_name(codec, bus->card->mixername, 827 strlcpy(codec->bus->card->mixername, codec->name,
670 sizeof(bus->card->mixername)); 828 sizeof(codec->bus->card->mixername));
671 829
672 if (is_generic_config(codec)) { 830 if (is_generic_config(codec)) {
673 err = snd_hda_parse_generic_codec(codec); 831 err = snd_hda_parse_generic_codec(codec);
@@ -684,25 +842,9 @@ int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
684 printk(KERN_ERR "hda-codec: No codec parser is available\n"); 842 printk(KERN_ERR "hda-codec: No codec parser is available\n");
685 843
686 patched: 844 patched:
687 if (err < 0) { 845 if (!err && codec->patch_ops.unsol_event)
688 snd_hda_codec_free(codec); 846 err = init_unsol_queue(codec->bus);
689 return err; 847 return err;
690 }
691
692 if (codec->patch_ops.unsol_event)
693 init_unsol_queue(bus);
694
695 snd_hda_codec_proc_new(codec);
696#ifdef CONFIG_SND_HDA_HWDEP
697 snd_hda_create_hwdep(codec);
698#endif
699
700 sprintf(component, "HDA:%08x,%08x,%08x", codec->vendor_id, codec->subsystem_id, codec->revision_id);
701 snd_component_add(codec->bus->card, component);
702
703 if (codecp)
704 *codecp = codec;
705 return 0;
706} 848}
707 849
708/** 850/**
@@ -728,6 +870,7 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
728 msleep(1); 870 msleep(1);
729 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 871 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
730} 872}
873EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream);
731 874
732void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) 875void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
733{ 876{
@@ -741,6 +884,7 @@ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
741 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0); 884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0);
742#endif 885#endif
743} 886}
887EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream);
744 888
745/* 889/*
746 * amp access functions 890 * amp access functions
@@ -752,17 +896,17 @@ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
752#define INFO_AMP_VOL(ch) (1 << (1 + (ch))) 896#define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
753 897
754/* initialize the hash table */ 898/* initialize the hash table */
755static void __devinit init_hda_cache(struct hda_cache_rec *cache, 899static void /*__devinit*/ init_hda_cache(struct hda_cache_rec *cache,
756 unsigned int record_size) 900 unsigned int record_size)
757{ 901{
758 memset(cache, 0, sizeof(*cache)); 902 memset(cache, 0, sizeof(*cache));
759 memset(cache->hash, 0xff, sizeof(cache->hash)); 903 memset(cache->hash, 0xff, sizeof(cache->hash));
760 cache->record_size = record_size; 904 snd_array_init(&cache->buf, record_size, 64);
761} 905}
762 906
763static void free_hda_cache(struct hda_cache_rec *cache) 907static void free_hda_cache(struct hda_cache_rec *cache)
764{ 908{
765 kfree(cache->buffer); 909 snd_array_free(&cache->buf);
766} 910}
767 911
768/* query the hash. allocate an entry if not found. */ 912/* query the hash. allocate an entry if not found. */
@@ -774,35 +918,17 @@ static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
774 struct hda_cache_head *info; 918 struct hda_cache_head *info;
775 919
776 while (cur != 0xffff) { 920 while (cur != 0xffff) {
777 info = (struct hda_cache_head *)(cache->buffer + 921 info = snd_array_elem(&cache->buf, cur);
778 cur * cache->record_size);
779 if (info->key == key) 922 if (info->key == key)
780 return info; 923 return info;
781 cur = info->next; 924 cur = info->next;
782 } 925 }
783 926
784 /* add a new hash entry */ 927 /* add a new hash entry */
785 if (cache->num_entries >= cache->size) { 928 info = snd_array_new(&cache->buf);
786 /* reallocate the array */ 929 if (!info)
787 unsigned int new_size = cache->size + 64; 930 return NULL;
788 void *new_buffer; 931 cur = snd_array_index(&cache->buf, info);
789 new_buffer = kcalloc(new_size, cache->record_size, GFP_KERNEL);
790 if (!new_buffer) {
791 snd_printk(KERN_ERR "hda_codec: "
792 "can't malloc amp_info\n");
793 return NULL;
794 }
795 if (cache->buffer) {
796 memcpy(new_buffer, cache->buffer,
797 cache->size * cache->record_size);
798 kfree(cache->buffer);
799 }
800 cache->size = new_size;
801 cache->buffer = new_buffer;
802 }
803 cur = cache->num_entries++;
804 info = (struct hda_cache_head *)(cache->buffer +
805 cur * cache->record_size);
806 info->key = key; 932 info->key = key;
807 info->val = 0; 933 info->val = 0;
808 info->next = cache->hash[idx]; 934 info->next = cache->hash[idx];
@@ -840,6 +966,7 @@ u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
840 } 966 }
841 return info->amp_caps; 967 return info->amp_caps;
842} 968}
969EXPORT_SYMBOL_HDA(query_amp_caps);
843 970
844int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 971int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
845 unsigned int caps) 972 unsigned int caps)
@@ -853,6 +980,7 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
853 info->head.val |= INFO_AMP_CAPS; 980 info->head.val |= INFO_AMP_CAPS;
854 return 0; 981 return 0;
855} 982}
983EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps);
856 984
857/* 985/*
858 * read the current volume to info 986 * read the current volume to info
@@ -906,6 +1034,7 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
906 return 0; 1034 return 0;
907 return get_vol_mute(codec, info, nid, ch, direction, index); 1035 return get_vol_mute(codec, info, nid, ch, direction, index);
908} 1036}
1037EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read);
909 1038
910/* 1039/*
911 * update the AMP value, mask = bit mask to set, val = the value 1040 * update the AMP value, mask = bit mask to set, val = the value
@@ -925,6 +1054,7 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
925 put_vol_mute(codec, info, nid, ch, direction, idx, val); 1054 put_vol_mute(codec, info, nid, ch, direction, idx, val);
926 return 1; 1055 return 1;
927} 1056}
1057EXPORT_SYMBOL_HDA(snd_hda_codec_amp_update);
928 1058
929/* 1059/*
930 * update the AMP stereo with the same mask and value 1060 * update the AMP stereo with the same mask and value
@@ -938,15 +1068,16 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
938 idx, mask, val); 1068 idx, mask, val);
939 return ret; 1069 return ret;
940} 1070}
1071EXPORT_SYMBOL_HDA(snd_hda_codec_amp_stereo);
941 1072
942#ifdef SND_HDA_NEEDS_RESUME 1073#ifdef SND_HDA_NEEDS_RESUME
943/* resume the all amp commands from the cache */ 1074/* resume the all amp commands from the cache */
944void snd_hda_codec_resume_amp(struct hda_codec *codec) 1075void snd_hda_codec_resume_amp(struct hda_codec *codec)
945{ 1076{
946 struct hda_amp_info *buffer = codec->amp_cache.buffer; 1077 struct hda_amp_info *buffer = codec->amp_cache.buf.list;
947 int i; 1078 int i;
948 1079
949 for (i = 0; i < codec->amp_cache.size; i++, buffer++) { 1080 for (i = 0; i < codec->amp_cache.buf.used; i++, buffer++) {
950 u32 key = buffer->head.key; 1081 u32 key = buffer->head.key;
951 hda_nid_t nid; 1082 hda_nid_t nid;
952 unsigned int idx, dir, ch; 1083 unsigned int idx, dir, ch;
@@ -963,6 +1094,7 @@ void snd_hda_codec_resume_amp(struct hda_codec *codec)
963 } 1094 }
964 } 1095 }
965} 1096}
1097EXPORT_SYMBOL_HDA(snd_hda_codec_resume_amp);
966#endif /* SND_HDA_NEEDS_RESUME */ 1098#endif /* SND_HDA_NEEDS_RESUME */
967 1099
968/* volume */ 1100/* volume */
@@ -990,6 +1122,7 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
990 uinfo->value.integer.max = caps; 1122 uinfo->value.integer.max = caps;
991 return 0; 1123 return 0;
992} 1124}
1125EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info);
993 1126
994int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, 1127int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
995 struct snd_ctl_elem_value *ucontrol) 1128 struct snd_ctl_elem_value *ucontrol)
@@ -1009,6 +1142,7 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
1009 & HDA_AMP_VOLMASK; 1142 & HDA_AMP_VOLMASK;
1010 return 0; 1143 return 0;
1011} 1144}
1145EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get);
1012 1146
1013int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, 1147int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
1014 struct snd_ctl_elem_value *ucontrol) 1148 struct snd_ctl_elem_value *ucontrol)
@@ -1033,6 +1167,7 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
1033 snd_hda_power_down(codec); 1167 snd_hda_power_down(codec);
1034 return change; 1168 return change;
1035} 1169}
1170EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_put);
1036 1171
1037int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, 1172int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1038 unsigned int size, unsigned int __user *_tlv) 1173 unsigned int size, unsigned int __user *_tlv)
@@ -1059,6 +1194,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1059 return -EFAULT; 1194 return -EFAULT;
1060 return 0; 1195 return 0;
1061} 1196}
1197EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_tlv);
1062 1198
1063/* 1199/*
1064 * set (static) TLV for virtual master volume; recalculated as max 0dB 1200 * set (static) TLV for virtual master volume; recalculated as max 0dB
@@ -1078,6 +1214,7 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
1078 tlv[2] = -nums * step; 1214 tlv[2] = -nums * step;
1079 tlv[3] = step; 1215 tlv[3] = step;
1080} 1216}
1217EXPORT_SYMBOL_HDA(snd_hda_set_vmaster_tlv);
1081 1218
1082/* find a mixer control element with the given name */ 1219/* find a mixer control element with the given name */
1083static struct snd_kcontrol * 1220static struct snd_kcontrol *
@@ -1097,6 +1234,69 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1097{ 1234{
1098 return _snd_hda_find_mixer_ctl(codec, name, 0); 1235 return _snd_hda_find_mixer_ctl(codec, name, 0);
1099} 1236}
1237EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl);
1238
1239/* Add a control element and assign to the codec */
1240int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl)
1241{
1242 int err;
1243 struct snd_kcontrol **knewp;
1244
1245 err = snd_ctl_add(codec->bus->card, kctl);
1246 if (err < 0)
1247 return err;
1248 knewp = snd_array_new(&codec->mixers);
1249 if (!knewp)
1250 return -ENOMEM;
1251 *knewp = kctl;
1252 return 0;
1253}
1254EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
1255
1256#ifdef CONFIG_SND_HDA_RECONFIG
1257/* Clear all controls assigned to the given codec */
1258void snd_hda_ctls_clear(struct hda_codec *codec)
1259{
1260 int i;
1261 struct snd_kcontrol **kctls = codec->mixers.list;
1262 for (i = 0; i < codec->mixers.used; i++)
1263 snd_ctl_remove(codec->bus->card, kctls[i]);
1264 snd_array_free(&codec->mixers);
1265}
1266
1267void snd_hda_codec_reset(struct hda_codec *codec)
1268{
1269 int i;
1270
1271#ifdef CONFIG_SND_HDA_POWER_SAVE
1272 cancel_delayed_work(&codec->power_work);
1273 flush_scheduled_work();
1274#endif
1275 snd_hda_ctls_clear(codec);
1276 /* relase PCMs */
1277 for (i = 0; i < codec->num_pcms; i++) {
1278 if (codec->pcm_info[i].pcm) {
1279 snd_device_free(codec->bus->card,
1280 codec->pcm_info[i].pcm);
1281 clear_bit(codec->pcm_info[i].device,
1282 codec->bus->pcm_dev_bits);
1283 }
1284 }
1285 if (codec->patch_ops.free)
1286 codec->patch_ops.free(codec);
1287 codec->proc_widget_hook = NULL;
1288 codec->spec = NULL;
1289 free_hda_cache(&codec->amp_cache);
1290 free_hda_cache(&codec->cmd_cache);
1291 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
1292 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
1293 codec->num_pcms = 0;
1294 codec->pcm_info = NULL;
1295 codec->preset = NULL;
1296 module_put(codec->owner);
1297 codec->owner = NULL;
1298}
1299#endif /* CONFIG_SND_HDA_RECONFIG */
1100 1300
1101/* create a virtual master control and add slaves */ 1301/* create a virtual master control and add slaves */
1102int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 1302int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
@@ -1115,7 +1315,7 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1115 kctl = snd_ctl_make_virtual_master(name, tlv); 1315 kctl = snd_ctl_make_virtual_master(name, tlv);
1116 if (!kctl) 1316 if (!kctl)
1117 return -ENOMEM; 1317 return -ENOMEM;
1118 err = snd_ctl_add(codec->bus->card, kctl); 1318 err = snd_hda_ctl_add(codec, kctl);
1119 if (err < 0) 1319 if (err < 0)
1120 return err; 1320 return err;
1121 1321
@@ -1133,6 +1333,7 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1133 } 1333 }
1134 return 0; 1334 return 0;
1135} 1335}
1336EXPORT_SYMBOL_HDA(snd_hda_add_vmaster);
1136 1337
1137/* switch */ 1338/* switch */
1138int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, 1339int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
@@ -1146,6 +1347,7 @@ int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
1146 uinfo->value.integer.max = 1; 1347 uinfo->value.integer.max = 1;
1147 return 0; 1348 return 0;
1148} 1349}
1350EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_info);
1149 1351
1150int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, 1352int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
1151 struct snd_ctl_elem_value *ucontrol) 1353 struct snd_ctl_elem_value *ucontrol)
@@ -1165,6 +1367,7 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
1165 HDA_AMP_MUTE) ? 0 : 1; 1367 HDA_AMP_MUTE) ? 0 : 1;
1166 return 0; 1368 return 0;
1167} 1369}
1370EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_get);
1168 1371
1169int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, 1372int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
1170 struct snd_ctl_elem_value *ucontrol) 1373 struct snd_ctl_elem_value *ucontrol)
@@ -1195,6 +1398,7 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
1195 snd_hda_power_down(codec); 1398 snd_hda_power_down(codec);
1196 return change; 1399 return change;
1197} 1400}
1401EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put);
1198 1402
1199/* 1403/*
1200 * bound volume controls 1404 * bound volume controls
@@ -1220,6 +1424,7 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
1220 mutex_unlock(&codec->spdif_mutex); 1424 mutex_unlock(&codec->spdif_mutex);
1221 return err; 1425 return err;
1222} 1426}
1427EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get);
1223 1428
1224int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, 1429int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
1225 struct snd_ctl_elem_value *ucontrol) 1430 struct snd_ctl_elem_value *ucontrol)
@@ -1243,6 +1448,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
1243 mutex_unlock(&codec->spdif_mutex); 1448 mutex_unlock(&codec->spdif_mutex);
1244 return err < 0 ? err : change; 1449 return err < 0 ? err : change;
1245} 1450}
1451EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put);
1246 1452
1247/* 1453/*
1248 * generic bound volume/swtich controls 1454 * generic bound volume/swtich controls
@@ -1262,6 +1468,7 @@ int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol,
1262 mutex_unlock(&codec->spdif_mutex); 1468 mutex_unlock(&codec->spdif_mutex);
1263 return err; 1469 return err;
1264} 1470}
1471EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info);
1265 1472
1266int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, 1473int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
1267 struct snd_ctl_elem_value *ucontrol) 1474 struct snd_ctl_elem_value *ucontrol)
@@ -1278,6 +1485,7 @@ int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
1278 mutex_unlock(&codec->spdif_mutex); 1485 mutex_unlock(&codec->spdif_mutex);
1279 return err; 1486 return err;
1280} 1487}
1488EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get);
1281 1489
1282int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, 1490int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
1283 struct snd_ctl_elem_value *ucontrol) 1491 struct snd_ctl_elem_value *ucontrol)
@@ -1300,6 +1508,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
1300 mutex_unlock(&codec->spdif_mutex); 1508 mutex_unlock(&codec->spdif_mutex);
1301 return err < 0 ? err : change; 1509 return err < 0 ? err : change;
1302} 1510}
1511EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put);
1303 1512
1304int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, 1513int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1305 unsigned int size, unsigned int __user *tlv) 1514 unsigned int size, unsigned int __user *tlv)
@@ -1316,6 +1525,7 @@ int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1316 mutex_unlock(&codec->spdif_mutex); 1525 mutex_unlock(&codec->spdif_mutex);
1317 return err; 1526 return err;
1318} 1527}
1528EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv);
1319 1529
1320struct hda_ctl_ops snd_hda_bind_vol = { 1530struct hda_ctl_ops snd_hda_bind_vol = {
1321 .info = snd_hda_mixer_amp_volume_info, 1531 .info = snd_hda_mixer_amp_volume_info,
@@ -1323,6 +1533,7 @@ struct hda_ctl_ops snd_hda_bind_vol = {
1323 .put = snd_hda_mixer_amp_volume_put, 1533 .put = snd_hda_mixer_amp_volume_put,
1324 .tlv = snd_hda_mixer_amp_tlv 1534 .tlv = snd_hda_mixer_amp_tlv
1325}; 1535};
1536EXPORT_SYMBOL_HDA(snd_hda_bind_vol);
1326 1537
1327struct hda_ctl_ops snd_hda_bind_sw = { 1538struct hda_ctl_ops snd_hda_bind_sw = {
1328 .info = snd_hda_mixer_amp_switch_info, 1539 .info = snd_hda_mixer_amp_switch_info,
@@ -1330,6 +1541,7 @@ struct hda_ctl_ops snd_hda_bind_sw = {
1330 .put = snd_hda_mixer_amp_switch_put, 1541 .put = snd_hda_mixer_amp_switch_put,
1331 .tlv = snd_hda_mixer_amp_tlv 1542 .tlv = snd_hda_mixer_amp_tlv
1332}; 1543};
1544EXPORT_SYMBOL_HDA(snd_hda_bind_sw);
1333 1545
1334/* 1546/*
1335 * SPDIF out controls 1547 * SPDIF out controls
@@ -1577,9 +1789,11 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1577 } 1789 }
1578 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { 1790 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1579 kctl = snd_ctl_new1(dig_mix, codec); 1791 kctl = snd_ctl_new1(dig_mix, codec);
1792 if (!kctl)
1793 return -ENOMEM;
1580 kctl->id.index = idx; 1794 kctl->id.index = idx;
1581 kctl->private_value = nid; 1795 kctl->private_value = nid;
1582 err = snd_ctl_add(codec->bus->card, kctl); 1796 err = snd_hda_ctl_add(codec, kctl);
1583 if (err < 0) 1797 if (err < 0)
1584 return err; 1798 return err;
1585 } 1799 }
@@ -1589,6 +1803,7 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1589 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1803 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1590 return 0; 1804 return 0;
1591} 1805}
1806EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls);
1592 1807
1593/* 1808/*
1594 * SPDIF sharing with analog output 1809 * SPDIF sharing with analog output
@@ -1623,9 +1838,10 @@ int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
1623 if (!mout->dig_out_nid) 1838 if (!mout->dig_out_nid)
1624 return 0; 1839 return 0;
1625 /* ATTENTION: here mout is passed as private_data, instead of codec */ 1840 /* ATTENTION: here mout is passed as private_data, instead of codec */
1626 return snd_ctl_add(codec->bus->card, 1841 return snd_hda_ctl_add(codec,
1627 snd_ctl_new1(&spdif_share_sw, mout)); 1842 snd_ctl_new1(&spdif_share_sw, mout));
1628} 1843}
1844EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw);
1629 1845
1630/* 1846/*
1631 * SPDIF input 1847 * SPDIF input
@@ -1725,7 +1941,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1725 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1941 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1726 kctl = snd_ctl_new1(dig_mix, codec); 1942 kctl = snd_ctl_new1(dig_mix, codec);
1727 kctl->private_value = nid; 1943 kctl->private_value = nid;
1728 err = snd_ctl_add(codec->bus->card, kctl); 1944 err = snd_hda_ctl_add(codec, kctl);
1729 if (err < 0) 1945 if (err < 0)
1730 return err; 1946 return err;
1731 } 1947 }
@@ -1735,6 +1951,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1735 AC_DIG1_ENABLE; 1951 AC_DIG1_ENABLE;
1736 return 0; 1952 return 0;
1737} 1953}
1954EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls);
1738 1955
1739#ifdef SND_HDA_NEEDS_RESUME 1956#ifdef SND_HDA_NEEDS_RESUME
1740/* 1957/*
@@ -1761,10 +1978,14 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1761int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, 1978int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
1762 int direct, unsigned int verb, unsigned int parm) 1979 int direct, unsigned int verb, unsigned int parm)
1763{ 1980{
1981 struct hda_bus *bus = codec->bus;
1982 unsigned int res;
1764 int err; 1983 int err;
1984
1985 res = make_codec_cmd(codec, nid, direct, verb, parm);
1765 snd_hda_power_up(codec); 1986 snd_hda_power_up(codec);
1766 mutex_lock(&codec->bus->cmd_mutex); 1987 mutex_lock(&bus->cmd_mutex);
1767 err = codec->bus->ops.command(codec, nid, direct, verb, parm); 1988 err = bus->ops.command(bus, res);
1768 if (!err) { 1989 if (!err) {
1769 struct hda_cache_head *c; 1990 struct hda_cache_head *c;
1770 u32 key = build_cmd_cache_key(nid, verb); 1991 u32 key = build_cmd_cache_key(nid, verb);
@@ -1772,18 +1993,19 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
1772 if (c) 1993 if (c)
1773 c->val = parm; 1994 c->val = parm;
1774 } 1995 }
1775 mutex_unlock(&codec->bus->cmd_mutex); 1996 mutex_unlock(&bus->cmd_mutex);
1776 snd_hda_power_down(codec); 1997 snd_hda_power_down(codec);
1777 return err; 1998 return err;
1778} 1999}
2000EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache);
1779 2001
1780/* resume the all commands from the cache */ 2002/* resume the all commands from the cache */
1781void snd_hda_codec_resume_cache(struct hda_codec *codec) 2003void snd_hda_codec_resume_cache(struct hda_codec *codec)
1782{ 2004{
1783 struct hda_cache_head *buffer = codec->cmd_cache.buffer; 2005 struct hda_cache_head *buffer = codec->cmd_cache.buf.list;
1784 int i; 2006 int i;
1785 2007
1786 for (i = 0; i < codec->cmd_cache.size; i++, buffer++) { 2008 for (i = 0; i < codec->cmd_cache.buf.used; i++, buffer++) {
1787 u32 key = buffer->key; 2009 u32 key = buffer->key;
1788 if (!key) 2010 if (!key)
1789 continue; 2011 continue;
@@ -1791,6 +2013,7 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec)
1791 get_cmd_cache_cmd(key), buffer->val); 2013 get_cmd_cache_cmd(key), buffer->val);
1792 } 2014 }
1793} 2015}
2016EXPORT_SYMBOL_HDA(snd_hda_codec_resume_cache);
1794 2017
1795/** 2018/**
1796 * snd_hda_sequence_write_cache - sequence writes with caching 2019 * snd_hda_sequence_write_cache - sequence writes with caching
@@ -1808,6 +2031,7 @@ void snd_hda_sequence_write_cache(struct hda_codec *codec,
1808 snd_hda_codec_write_cache(codec, seq->nid, 0, seq->verb, 2031 snd_hda_codec_write_cache(codec, seq->nid, 0, seq->verb,
1809 seq->param); 2032 seq->param);
1810} 2033}
2034EXPORT_SYMBOL_HDA(snd_hda_sequence_write_cache);
1811#endif /* SND_HDA_NEEDS_RESUME */ 2035#endif /* SND_HDA_NEEDS_RESUME */
1812 2036
1813/* 2037/*
@@ -1868,6 +2092,17 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1868 } 2092 }
1869} 2093}
1870 2094
2095#ifdef CONFIG_SND_HDA_HWDEP
2096/* execute additional init verbs */
2097static void hda_exec_init_verbs(struct hda_codec *codec)
2098{
2099 if (codec->init_verbs.list)
2100 snd_hda_sequence_write(codec, codec->init_verbs.list);
2101}
2102#else
2103static inline void hda_exec_init_verbs(struct hda_codec *codec) {}
2104#endif
2105
1871#ifdef SND_HDA_NEEDS_RESUME 2106#ifdef SND_HDA_NEEDS_RESUME
1872/* 2107/*
1873 * call suspend and power-down; used both from PM and power-save 2108 * call suspend and power-down; used both from PM and power-save
@@ -1894,6 +2129,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
1894 hda_set_power_state(codec, 2129 hda_set_power_state(codec,
1895 codec->afg ? codec->afg : codec->mfg, 2130 codec->afg ? codec->afg : codec->mfg,
1896 AC_PWRST_D0); 2131 AC_PWRST_D0);
2132 hda_exec_init_verbs(codec);
1897 if (codec->patch_ops.resume) 2133 if (codec->patch_ops.resume)
1898 codec->patch_ops.resume(codec); 2134 codec->patch_ops.resume(codec);
1899 else { 2135 else {
@@ -1914,28 +2150,37 @@ static void hda_call_codec_resume(struct hda_codec *codec)
1914 * 2150 *
1915 * Returns 0 if successful, otherwise a negative error code. 2151 * Returns 0 if successful, otherwise a negative error code.
1916 */ 2152 */
1917int __devinit snd_hda_build_controls(struct hda_bus *bus) 2153int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
1918{ 2154{
1919 struct hda_codec *codec; 2155 struct hda_codec *codec;
1920 2156
1921 list_for_each_entry(codec, &bus->codec_list, list) { 2157 list_for_each_entry(codec, &bus->codec_list, list) {
1922 int err = 0; 2158 int err = snd_hda_codec_build_controls(codec);
1923 /* fake as if already powered-on */
1924 hda_keep_power_on(codec);
1925 /* then fire up */
1926 hda_set_power_state(codec,
1927 codec->afg ? codec->afg : codec->mfg,
1928 AC_PWRST_D0);
1929 /* continue to initialize... */
1930 if (codec->patch_ops.init)
1931 err = codec->patch_ops.init(codec);
1932 if (!err && codec->patch_ops.build_controls)
1933 err = codec->patch_ops.build_controls(codec);
1934 snd_hda_power_down(codec);
1935 if (err < 0) 2159 if (err < 0)
1936 return err; 2160 return err;
1937 } 2161 }
2162 return 0;
2163}
2164EXPORT_SYMBOL_HDA(snd_hda_build_controls);
1938 2165
2166int snd_hda_codec_build_controls(struct hda_codec *codec)
2167{
2168 int err = 0;
2169 /* fake as if already powered-on */
2170 hda_keep_power_on(codec);
2171 /* then fire up */
2172 hda_set_power_state(codec,
2173 codec->afg ? codec->afg : codec->mfg,
2174 AC_PWRST_D0);
2175 hda_exec_init_verbs(codec);
2176 /* continue to initialize... */
2177 if (codec->patch_ops.init)
2178 err = codec->patch_ops.init(codec);
2179 if (!err && codec->patch_ops.build_controls)
2180 err = codec->patch_ops.build_controls(codec);
2181 snd_hda_power_down(codec);
2182 if (err < 0)
2183 return err;
1939 return 0; 2184 return 0;
1940} 2185}
1941 2186
@@ -2028,6 +2273,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
2028 2273
2029 return val; 2274 return val;
2030} 2275}
2276EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format);
2031 2277
2032/** 2278/**
2033 * snd_hda_query_supported_pcm - query the supported PCM rates and formats 2279 * snd_hda_query_supported_pcm - query the supported PCM rates and formats
@@ -2042,7 +2288,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
2042 * 2288 *
2043 * Returns 0 if successful, otherwise a negative error code. 2289 * Returns 0 if successful, otherwise a negative error code.
2044 */ 2290 */
2045int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, 2291static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2046 u32 *ratesp, u64 *formatsp, unsigned int *bpsp) 2292 u32 *ratesp, u64 *formatsp, unsigned int *bpsp)
2047{ 2293{
2048 int i; 2294 int i;
@@ -2207,6 +2453,7 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
2207 2453
2208 return 1; 2454 return 1;
2209} 2455}
2456EXPORT_SYMBOL_HDA(snd_hda_is_supported_format);
2210 2457
2211/* 2458/*
2212 * PCM stuff 2459 * PCM stuff
@@ -2236,8 +2483,8 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
2236 return 0; 2483 return 0;
2237} 2484}
2238 2485
2239static int __devinit set_pcm_default_values(struct hda_codec *codec, 2486static int set_pcm_default_values(struct hda_codec *codec,
2240 struct hda_pcm_stream *info) 2487 struct hda_pcm_stream *info)
2241{ 2488{
2242 /* query support PCM information from the given NID */ 2489 /* query support PCM information from the given NID */
2243 if (info->nid && (!info->rates || !info->formats)) { 2490 if (info->nid && (!info->rates || !info->formats)) {
@@ -2263,6 +2510,110 @@ static int __devinit set_pcm_default_values(struct hda_codec *codec,
2263 return 0; 2510 return 0;
2264} 2511}
2265 2512
2513/*
2514 * get the empty PCM device number to assign
2515 */
2516static int get_empty_pcm_device(struct hda_bus *bus, int type)
2517{
2518 static const char *dev_name[HDA_PCM_NTYPES] = {
2519 "Audio", "SPDIF", "HDMI", "Modem"
2520 };
2521 /* starting device index for each PCM type */
2522 static int dev_idx[HDA_PCM_NTYPES] = {
2523 [HDA_PCM_TYPE_AUDIO] = 0,
2524 [HDA_PCM_TYPE_SPDIF] = 1,
2525 [HDA_PCM_TYPE_HDMI] = 3,
2526 [HDA_PCM_TYPE_MODEM] = 6
2527 };
2528 /* normal audio device indices; not linear to keep compatibility */
2529 static int audio_idx[4] = { 0, 2, 4, 5 };
2530 int i, dev;
2531
2532 switch (type) {
2533 case HDA_PCM_TYPE_AUDIO:
2534 for (i = 0; i < ARRAY_SIZE(audio_idx); i++) {
2535 dev = audio_idx[i];
2536 if (!test_bit(dev, bus->pcm_dev_bits))
2537 break;
2538 }
2539 if (i >= ARRAY_SIZE(audio_idx)) {
2540 snd_printk(KERN_WARNING "Too many audio devices\n");
2541 return -EAGAIN;
2542 }
2543 break;
2544 case HDA_PCM_TYPE_SPDIF:
2545 case HDA_PCM_TYPE_HDMI:
2546 case HDA_PCM_TYPE_MODEM:
2547 dev = dev_idx[type];
2548 if (test_bit(dev, bus->pcm_dev_bits)) {
2549 snd_printk(KERN_WARNING "%s already defined\n",
2550 dev_name[type]);
2551 return -EAGAIN;
2552 }
2553 break;
2554 default:
2555 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
2556 return -EINVAL;
2557 }
2558 set_bit(dev, bus->pcm_dev_bits);
2559 return dev;
2560}
2561
2562/*
2563 * attach a new PCM stream
2564 */
2565static int snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm)
2566{
2567 struct hda_bus *bus = codec->bus;
2568 struct hda_pcm_stream *info;
2569 int stream, err;
2570
2571 if (snd_BUG_ON(!pcm->name))
2572 return -EINVAL;
2573 for (stream = 0; stream < 2; stream++) {
2574 info = &pcm->stream[stream];
2575 if (info->substreams) {
2576 err = set_pcm_default_values(codec, info);
2577 if (err < 0)
2578 return err;
2579 }
2580 }
2581 return bus->ops.attach_pcm(bus, codec, pcm);
2582}
2583
2584/* assign all PCMs of the given codec */
2585int snd_hda_codec_build_pcms(struct hda_codec *codec)
2586{
2587 unsigned int pcm;
2588 int err;
2589
2590 if (!codec->num_pcms) {
2591 if (!codec->patch_ops.build_pcms)
2592 return 0;
2593 err = codec->patch_ops.build_pcms(codec);
2594 if (err < 0)
2595 return err;
2596 }
2597 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
2598 struct hda_pcm *cpcm = &codec->pcm_info[pcm];
2599 int dev;
2600
2601 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
2602 return 0; /* no substreams assigned */
2603
2604 if (!cpcm->pcm) {
2605 dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type);
2606 if (dev < 0)
2607 return 0;
2608 cpcm->device = dev;
2609 err = snd_hda_attach_pcm(codec, cpcm);
2610 if (err < 0)
2611 return err;
2612 }
2613 }
2614 return 0;
2615}
2616
2266/** 2617/**
2267 * snd_hda_build_pcms - build PCM information 2618 * snd_hda_build_pcms - build PCM information
2268 * @bus: the BUS 2619 * @bus: the BUS
@@ -2294,27 +2645,13 @@ int __devinit snd_hda_build_pcms(struct hda_bus *bus)
2294 struct hda_codec *codec; 2645 struct hda_codec *codec;
2295 2646
2296 list_for_each_entry(codec, &bus->codec_list, list) { 2647 list_for_each_entry(codec, &bus->codec_list, list) {
2297 unsigned int pcm, s; 2648 int err = snd_hda_codec_build_pcms(codec);
2298 int err;
2299 if (!codec->patch_ops.build_pcms)
2300 continue;
2301 err = codec->patch_ops.build_pcms(codec);
2302 if (err < 0) 2649 if (err < 0)
2303 return err; 2650 return err;
2304 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
2305 for (s = 0; s < 2; s++) {
2306 struct hda_pcm_stream *info;
2307 info = &codec->pcm_info[pcm].stream[s];
2308 if (!info->substreams)
2309 continue;
2310 err = set_pcm_default_values(codec, info);
2311 if (err < 0)
2312 return err;
2313 }
2314 }
2315 } 2651 }
2316 return 0; 2652 return 0;
2317} 2653}
2654EXPORT_SYMBOL_HDA(snd_hda_build_pcms);
2318 2655
2319/** 2656/**
2320 * snd_hda_check_board_config - compare the current codec with the config table 2657 * snd_hda_check_board_config - compare the current codec with the config table
@@ -2333,11 +2670,11 @@ int snd_hda_check_board_config(struct hda_codec *codec,
2333 int num_configs, const char **models, 2670 int num_configs, const char **models,
2334 const struct snd_pci_quirk *tbl) 2671 const struct snd_pci_quirk *tbl)
2335{ 2672{
2336 if (codec->bus->modelname && models) { 2673 if (codec->modelname && models) {
2337 int i; 2674 int i;
2338 for (i = 0; i < num_configs; i++) { 2675 for (i = 0; i < num_configs; i++) {
2339 if (models[i] && 2676 if (models[i] &&
2340 !strcmp(codec->bus->modelname, models[i])) { 2677 !strcmp(codec->modelname, models[i])) {
2341 snd_printd(KERN_INFO "hda_codec: model '%s' is " 2678 snd_printd(KERN_INFO "hda_codec: model '%s' is "
2342 "selected\n", models[i]); 2679 "selected\n", models[i]);
2343 return i; 2680 return i;
@@ -2370,6 +2707,7 @@ int snd_hda_check_board_config(struct hda_codec *codec,
2370 } 2707 }
2371 return -1; 2708 return -1;
2372} 2709}
2710EXPORT_SYMBOL_HDA(snd_hda_check_board_config);
2373 2711
2374/** 2712/**
2375 * snd_hda_add_new_ctls - create controls from the array 2713 * snd_hda_add_new_ctls - create controls from the array
@@ -2390,7 +2728,7 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2390 kctl = snd_ctl_new1(knew, codec); 2728 kctl = snd_ctl_new1(knew, codec);
2391 if (!kctl) 2729 if (!kctl)
2392 return -ENOMEM; 2730 return -ENOMEM;
2393 err = snd_ctl_add(codec->bus->card, kctl); 2731 err = snd_hda_ctl_add(codec, kctl);
2394 if (err < 0) { 2732 if (err < 0) {
2395 if (!codec->addr) 2733 if (!codec->addr)
2396 return err; 2734 return err;
@@ -2398,13 +2736,14 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2398 if (!kctl) 2736 if (!kctl)
2399 return -ENOMEM; 2737 return -ENOMEM;
2400 kctl->id.device = codec->addr; 2738 kctl->id.device = codec->addr;
2401 err = snd_ctl_add(codec->bus->card, kctl); 2739 err = snd_hda_ctl_add(codec, kctl);
2402 if (err < 0) 2740 if (err < 0)
2403 return err; 2741 return err;
2404 } 2742 }
2405 } 2743 }
2406 return 0; 2744 return 0;
2407} 2745}
2746EXPORT_SYMBOL_HDA(snd_hda_add_new_ctls);
2408 2747
2409#ifdef CONFIG_SND_HDA_POWER_SAVE 2748#ifdef CONFIG_SND_HDA_POWER_SAVE
2410static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, 2749static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
@@ -2414,6 +2753,7 @@ static void hda_power_work(struct work_struct *work)
2414{ 2753{
2415 struct hda_codec *codec = 2754 struct hda_codec *codec =
2416 container_of(work, struct hda_codec, power_work.work); 2755 container_of(work, struct hda_codec, power_work.work);
2756 struct hda_bus *bus = codec->bus;
2417 2757
2418 if (!codec->power_on || codec->power_count) { 2758 if (!codec->power_on || codec->power_count) {
2419 codec->power_transition = 0; 2759 codec->power_transition = 0;
@@ -2421,8 +2761,8 @@ static void hda_power_work(struct work_struct *work)
2421 } 2761 }
2422 2762
2423 hda_call_codec_suspend(codec); 2763 hda_call_codec_suspend(codec);
2424 if (codec->bus->ops.pm_notify) 2764 if (bus->ops.pm_notify)
2425 codec->bus->ops.pm_notify(codec); 2765 bus->ops.pm_notify(bus);
2426} 2766}
2427 2767
2428static void hda_keep_power_on(struct hda_codec *codec) 2768static void hda_keep_power_on(struct hda_codec *codec)
@@ -2433,29 +2773,39 @@ static void hda_keep_power_on(struct hda_codec *codec)
2433 2773
2434void snd_hda_power_up(struct hda_codec *codec) 2774void snd_hda_power_up(struct hda_codec *codec)
2435{ 2775{
2776 struct hda_bus *bus = codec->bus;
2777
2436 codec->power_count++; 2778 codec->power_count++;
2437 if (codec->power_on || codec->power_transition) 2779 if (codec->power_on || codec->power_transition)
2438 return; 2780 return;
2439 2781
2440 codec->power_on = 1; 2782 codec->power_on = 1;
2441 if (codec->bus->ops.pm_notify) 2783 if (bus->ops.pm_notify)
2442 codec->bus->ops.pm_notify(codec); 2784 bus->ops.pm_notify(bus);
2443 hda_call_codec_resume(codec); 2785 hda_call_codec_resume(codec);
2444 cancel_delayed_work(&codec->power_work); 2786 cancel_delayed_work(&codec->power_work);
2445 codec->power_transition = 0; 2787 codec->power_transition = 0;
2446} 2788}
2789EXPORT_SYMBOL_HDA(snd_hda_power_up);
2790
2791#define power_save(codec) \
2792 ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
2793
2794#define power_save(codec) \
2795 ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
2447 2796
2448void snd_hda_power_down(struct hda_codec *codec) 2797void snd_hda_power_down(struct hda_codec *codec)
2449{ 2798{
2450 --codec->power_count; 2799 --codec->power_count;
2451 if (!codec->power_on || codec->power_count || codec->power_transition) 2800 if (!codec->power_on || codec->power_count || codec->power_transition)
2452 return; 2801 return;
2453 if (power_save) { 2802 if (power_save(codec)) {
2454 codec->power_transition = 1; /* avoid reentrance */ 2803 codec->power_transition = 1; /* avoid reentrance */
2455 schedule_delayed_work(&codec->power_work, 2804 schedule_delayed_work(&codec->power_work,
2456 msecs_to_jiffies(power_save * 1000)); 2805 msecs_to_jiffies(power_save(codec) * 1000));
2457 } 2806 }
2458} 2807}
2808EXPORT_SYMBOL_HDA(snd_hda_power_down);
2459 2809
2460int snd_hda_check_amp_list_power(struct hda_codec *codec, 2810int snd_hda_check_amp_list_power(struct hda_codec *codec,
2461 struct hda_loopback_check *check, 2811 struct hda_loopback_check *check,
@@ -2492,6 +2842,7 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
2492 } 2842 }
2493 return 0; 2843 return 0;
2494} 2844}
2845EXPORT_SYMBOL_HDA(snd_hda_check_amp_list_power);
2495#endif 2846#endif
2496 2847
2497/* 2848/*
@@ -2511,6 +2862,7 @@ int snd_hda_ch_mode_info(struct hda_codec *codec,
2511 chmode[uinfo->value.enumerated.item].channels); 2862 chmode[uinfo->value.enumerated.item].channels);
2512 return 0; 2863 return 0;
2513} 2864}
2865EXPORT_SYMBOL_HDA(snd_hda_ch_mode_info);
2514 2866
2515int snd_hda_ch_mode_get(struct hda_codec *codec, 2867int snd_hda_ch_mode_get(struct hda_codec *codec,
2516 struct snd_ctl_elem_value *ucontrol, 2868 struct snd_ctl_elem_value *ucontrol,
@@ -2528,6 +2880,7 @@ int snd_hda_ch_mode_get(struct hda_codec *codec,
2528 } 2880 }
2529 return 0; 2881 return 0;
2530} 2882}
2883EXPORT_SYMBOL_HDA(snd_hda_ch_mode_get);
2531 2884
2532int snd_hda_ch_mode_put(struct hda_codec *codec, 2885int snd_hda_ch_mode_put(struct hda_codec *codec,
2533 struct snd_ctl_elem_value *ucontrol, 2886 struct snd_ctl_elem_value *ucontrol,
@@ -2548,6 +2901,7 @@ int snd_hda_ch_mode_put(struct hda_codec *codec,
2548 snd_hda_sequence_write_cache(codec, chmode[mode].sequence); 2901 snd_hda_sequence_write_cache(codec, chmode[mode].sequence);
2549 return 1; 2902 return 1;
2550} 2903}
2904EXPORT_SYMBOL_HDA(snd_hda_ch_mode_put);
2551 2905
2552/* 2906/*
2553 * input MUX helper 2907 * input MUX helper
@@ -2568,6 +2922,7 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux,
2568 strcpy(uinfo->value.enumerated.name, imux->items[index].label); 2922 strcpy(uinfo->value.enumerated.name, imux->items[index].label);
2569 return 0; 2923 return 0;
2570} 2924}
2925EXPORT_SYMBOL_HDA(snd_hda_input_mux_info);
2571 2926
2572int snd_hda_input_mux_put(struct hda_codec *codec, 2927int snd_hda_input_mux_put(struct hda_codec *codec,
2573 const struct hda_input_mux *imux, 2928 const struct hda_input_mux *imux,
@@ -2589,6 +2944,7 @@ int snd_hda_input_mux_put(struct hda_codec *codec,
2589 *cur_val = idx; 2944 *cur_val = idx;
2590 return 1; 2945 return 1;
2591} 2946}
2947EXPORT_SYMBOL_HDA(snd_hda_input_mux_put);
2592 2948
2593 2949
2594/* 2950/*
@@ -2641,6 +2997,7 @@ int snd_hda_multi_out_dig_open(struct hda_codec *codec,
2641 mutex_unlock(&codec->spdif_mutex); 2997 mutex_unlock(&codec->spdif_mutex);
2642 return 0; 2998 return 0;
2643} 2999}
3000EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_open);
2644 3001
2645int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, 3002int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
2646 struct hda_multi_out *mout, 3003 struct hda_multi_out *mout,
@@ -2653,6 +3010,7 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
2653 mutex_unlock(&codec->spdif_mutex); 3010 mutex_unlock(&codec->spdif_mutex);
2654 return 0; 3011 return 0;
2655} 3012}
3013EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare);
2656 3014
2657/* 3015/*
2658 * release the digital out 3016 * release the digital out
@@ -2665,6 +3023,7 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec,
2665 mutex_unlock(&codec->spdif_mutex); 3023 mutex_unlock(&codec->spdif_mutex);
2666 return 0; 3024 return 0;
2667} 3025}
3026EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_close);
2668 3027
2669/* 3028/*
2670 * set up more restrictions for analog out 3029 * set up more restrictions for analog out
@@ -2704,6 +3063,7 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2704 return snd_pcm_hw_constraint_step(substream->runtime, 0, 3063 return snd_pcm_hw_constraint_step(substream->runtime, 0,
2705 SNDRV_PCM_HW_PARAM_CHANNELS, 2); 3064 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
2706} 3065}
3066EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_open);
2707 3067
2708/* 3068/*
2709 * set up the i/o for analog out 3069 * set up the i/o for analog out
@@ -2762,6 +3122,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2762 } 3122 }
2763 return 0; 3123 return 0;
2764} 3124}
3125EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare);
2765 3126
2766/* 3127/*
2767 * clean up the setting for analog out 3128 * clean up the setting for analog out
@@ -2788,6 +3149,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2788 mutex_unlock(&codec->spdif_mutex); 3149 mutex_unlock(&codec->spdif_mutex);
2789 return 0; 3150 return 0;
2790} 3151}
3152EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup);
2791 3153
2792/* 3154/*
2793 * Helper for automatic pin configuration 3155 * Helper for automatic pin configuration
@@ -3073,11 +3435,13 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3073 3435
3074 return 0; 3436 return 0;
3075} 3437}
3438EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config);
3076 3439
3077/* labels for input pins */ 3440/* labels for input pins */
3078const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { 3441const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
3079 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" 3442 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
3080}; 3443};
3444EXPORT_SYMBOL_HDA(auto_pin_cfg_labels);
3081 3445
3082 3446
3083#ifdef CONFIG_PM 3447#ifdef CONFIG_PM
@@ -3105,11 +3469,11 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
3105 } 3469 }
3106 return 0; 3470 return 0;
3107} 3471}
3472EXPORT_SYMBOL_HDA(snd_hda_suspend);
3108 3473
3109/** 3474/**
3110 * snd_hda_resume - resume the codecs 3475 * snd_hda_resume - resume the codecs
3111 * @bus: the HDA bus 3476 * @bus: the HDA bus
3112 * @state: resume state
3113 * 3477 *
3114 * Returns 0 if successful. 3478 * Returns 0 if successful.
3115 * 3479 *
@@ -3126,16 +3490,79 @@ int snd_hda_resume(struct hda_bus *bus)
3126 } 3490 }
3127 return 0; 3491 return 0;
3128} 3492}
3129#ifdef CONFIG_SND_HDA_POWER_SAVE 3493EXPORT_SYMBOL_HDA(snd_hda_resume);
3130int snd_hda_codecs_inuse(struct hda_bus *bus) 3494#endif /* CONFIG_PM */
3131{
3132 struct hda_codec *codec;
3133 3495
3134 list_for_each_entry(codec, &bus->codec_list, list) { 3496/*
3135 if (snd_hda_codec_needs_resume(codec)) 3497 * generic arrays
3136 return 1; 3498 */
3499
3500/* get a new element from the given array
3501 * if it exceeds the pre-allocated array size, re-allocate the array
3502 */
3503void *snd_array_new(struct snd_array *array)
3504{
3505 if (array->used >= array->alloced) {
3506 int num = array->alloced + array->alloc_align;
3507 void *nlist;
3508 if (snd_BUG_ON(num >= 4096))
3509 return NULL;
3510 nlist = kcalloc(num + 1, array->elem_size, GFP_KERNEL);
3511 if (!nlist)
3512 return NULL;
3513 if (array->list) {
3514 memcpy(nlist, array->list,
3515 array->elem_size * array->alloced);
3516 kfree(array->list);
3517 }
3518 array->list = nlist;
3519 array->alloced = num;
3137 } 3520 }
3138 return 0; 3521 return snd_array_elem(array, array->used++);
3139} 3522}
3140#endif 3523EXPORT_SYMBOL_HDA(snd_array_new);
3141#endif 3524
3525/* free the given array elements */
3526void snd_array_free(struct snd_array *array)
3527{
3528 kfree(array->list);
3529 array->used = 0;
3530 array->alloced = 0;
3531 array->list = NULL;
3532}
3533EXPORT_SYMBOL_HDA(snd_array_free);
3534
3535/*
3536 * used by hda_proc.c and hda_eld.c
3537 */
3538void snd_print_pcm_rates(int pcm, char *buf, int buflen)
3539{
3540 static unsigned int rates[] = {
3541 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
3542 96000, 176400, 192000, 384000
3543 };
3544 int i, j;
3545
3546 for (i = 0, j = 0; i < ARRAY_SIZE(rates); i++)
3547 if (pcm & (1 << i))
3548 j += snprintf(buf + j, buflen - j, " %d", rates[i]);
3549
3550 buf[j] = '\0'; /* necessary when j == 0 */
3551}
3552EXPORT_SYMBOL_HDA(snd_print_pcm_rates);
3553
3554void snd_print_pcm_bits(int pcm, char *buf, int buflen)
3555{
3556 static unsigned int bits[] = { 8, 16, 20, 24, 32 };
3557 int i, j;
3558
3559 for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
3560 if (pcm & (AC_SUPPCM_BITS_8 << i))
3561 j += snprintf(buf + j, buflen - j, " %d", bits[i]);
3562
3563 buf[j] = '\0'; /* necessary when j == 0 */
3564}
3565EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
3566
3567MODULE_DESCRIPTION("HDA codec core");
3568MODULE_LICENSE("GPL");
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 60468f562400..5587d416229f 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -520,6 +520,36 @@ enum {
520#define HDA_MAX_CODEC_ADDRESS 0x0f 520#define HDA_MAX_CODEC_ADDRESS 0x0f
521 521
522/* 522/*
523 * generic arrays
524 */
525struct snd_array {
526 unsigned int used;
527 unsigned int alloced;
528 unsigned int elem_size;
529 unsigned int alloc_align;
530 void *list;
531};
532
533void *snd_array_new(struct snd_array *array);
534void snd_array_free(struct snd_array *array);
535static inline void snd_array_init(struct snd_array *array, unsigned int size,
536 unsigned int align)
537{
538 array->elem_size = size;
539 array->alloc_align = align;
540}
541
542static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
543{
544 return array->list + idx * array->elem_size;
545}
546
547static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
548{
549 return (unsigned long)(ptr - array->list) / array->elem_size;
550}
551
552/*
523 * Structures 553 * Structures
524 */ 554 */
525 555
@@ -536,15 +566,17 @@ typedef u16 hda_nid_t;
536/* bus operators */ 566/* bus operators */
537struct hda_bus_ops { 567struct hda_bus_ops {
538 /* send a single command */ 568 /* send a single command */
539 int (*command)(struct hda_codec *codec, hda_nid_t nid, int direct, 569 int (*command)(struct hda_bus *bus, unsigned int cmd);
540 unsigned int verb, unsigned int parm);
541 /* get a response from the last command */ 570 /* get a response from the last command */
542 unsigned int (*get_response)(struct hda_codec *codec); 571 unsigned int (*get_response)(struct hda_bus *bus);
543 /* free the private data */ 572 /* free the private data */
544 void (*private_free)(struct hda_bus *); 573 void (*private_free)(struct hda_bus *);
574 /* attach a PCM stream */
575 int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec,
576 struct hda_pcm *pcm);
545#ifdef CONFIG_SND_HDA_POWER_SAVE 577#ifdef CONFIG_SND_HDA_POWER_SAVE
546 /* notify power-up/down from codec to controller */ 578 /* notify power-up/down from codec to controller */
547 void (*pm_notify)(struct hda_codec *codec); 579 void (*pm_notify)(struct hda_bus *bus);
548#endif 580#endif
549}; 581};
550 582
@@ -553,6 +585,7 @@ struct hda_bus_template {
553 void *private_data; 585 void *private_data;
554 struct pci_dev *pci; 586 struct pci_dev *pci;
555 const char *modelname; 587 const char *modelname;
588 int *power_save;
556 struct hda_bus_ops ops; 589 struct hda_bus_ops ops;
557}; 590};
558 591
@@ -569,6 +602,7 @@ struct hda_bus {
569 void *private_data; 602 void *private_data;
570 struct pci_dev *pci; 603 struct pci_dev *pci;
571 const char *modelname; 604 const char *modelname;
605 int *power_save;
572 struct hda_bus_ops ops; 606 struct hda_bus_ops ops;
573 607
574 /* codec linked list */ 608 /* codec linked list */
@@ -581,10 +615,12 @@ struct hda_bus {
581 /* unsolicited event queue */ 615 /* unsolicited event queue */
582 struct hda_bus_unsolicited *unsol; 616 struct hda_bus_unsolicited *unsol;
583 617
584 struct snd_info_entry *proc; 618 /* assigned PCMs */
619 DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
585 620
586 /* misc op flags */ 621 /* misc op flags */
587 unsigned int needs_damn_long_delay :1; 622 unsigned int needs_damn_long_delay :1;
623 unsigned int shutdown :1; /* being unloaded */
588}; 624};
589 625
590/* 626/*
@@ -604,6 +640,16 @@ struct hda_codec_preset {
604 int (*patch)(struct hda_codec *codec); 640 int (*patch)(struct hda_codec *codec);
605}; 641};
606 642
643struct hda_codec_preset_list {
644 const struct hda_codec_preset *preset;
645 struct module *owner;
646 struct list_head list;
647};
648
649/* initial hook */
650int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset);
651int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset);
652
607/* ops set by the preset patch */ 653/* ops set by the preset patch */
608struct hda_codec_ops { 654struct hda_codec_ops {
609 int (*build_controls)(struct hda_codec *codec); 655 int (*build_controls)(struct hda_codec *codec);
@@ -635,10 +681,7 @@ struct hda_amp_info {
635 681
636struct hda_cache_rec { 682struct hda_cache_rec {
637 u16 hash[64]; /* hash table for index */ 683 u16 hash[64]; /* hash table for index */
638 unsigned int num_entries; /* number of assigned entries */ 684 struct snd_array buf; /* record entries */
639 unsigned int size; /* allocated size */
640 unsigned int record_size; /* record size (including header) */
641 void *buffer; /* hash table entries */
642}; 685};
643 686
644/* PCM callbacks */ 687/* PCM callbacks */
@@ -680,7 +723,8 @@ struct hda_pcm {
680 char *name; 723 char *name;
681 struct hda_pcm_stream stream[2]; 724 struct hda_pcm_stream stream[2];
682 unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */ 725 unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */
683 int device; /* assigned device number */ 726 int device; /* device number to assign */
727 struct snd_pcm *pcm; /* assigned PCM instance */
684}; 728};
685 729
686/* codec information */ 730/* codec information */
@@ -699,6 +743,9 @@ struct hda_codec {
699 743
700 /* detected preset */ 744 /* detected preset */
701 const struct hda_codec_preset *preset; 745 const struct hda_codec_preset *preset;
746 struct module *owner;
747 const char *name; /* codec name */
748 const char *modelname; /* model name for preset */
702 749
703 /* set by patch */ 750 /* set by patch */
704 struct hda_codec_ops patch_ops; 751 struct hda_codec_ops patch_ops;
@@ -718,6 +765,8 @@ struct hda_codec {
718 hda_nid_t start_nid; 765 hda_nid_t start_nid;
719 u32 *wcaps; 766 u32 *wcaps;
720 767
768 struct snd_array mixers; /* list of assigned mixer elements */
769
721 struct hda_cache_rec amp_cache; /* cache for amp access */ 770 struct hda_cache_rec amp_cache; /* cache for amp access */
722 struct hda_cache_rec cmd_cache; /* cache for other commands */ 771 struct hda_cache_rec cmd_cache; /* cache for other commands */
723 772
@@ -727,7 +776,11 @@ struct hda_codec {
727 unsigned int spdif_in_enable; /* SPDIF input enable? */ 776 unsigned int spdif_in_enable; /* SPDIF input enable? */
728 hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ 777 hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
729 778
779#ifdef CONFIG_SND_HDA_HWDEP
730 struct snd_hwdep *hwdep; /* assigned hwdep device */ 780 struct snd_hwdep *hwdep; /* assigned hwdep device */
781 struct snd_array init_verbs; /* additional init verbs */
782 struct snd_array hints; /* additional hints */
783#endif
731 784
732 /* misc flags */ 785 /* misc flags */
733 unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each 786 unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each
@@ -740,6 +793,10 @@ struct hda_codec {
740 int power_count; /* current (global) power refcount */ 793 int power_count; /* current (global) power refcount */
741 struct delayed_work power_work; /* delayed task for powerdown */ 794 struct delayed_work power_work; /* delayed task for powerdown */
742#endif 795#endif
796
797 /* codec-specific additional proc output */
798 void (*proc_widget_hook)(struct snd_info_buffer *buffer,
799 struct hda_codec *codec, hda_nid_t nid);
743}; 800};
744 801
745/* direction */ 802/* direction */
@@ -799,11 +856,13 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec);
799 * Mixer 856 * Mixer
800 */ 857 */
801int snd_hda_build_controls(struct hda_bus *bus); 858int snd_hda_build_controls(struct hda_bus *bus);
859int snd_hda_codec_build_controls(struct hda_codec *codec);
802 860
803/* 861/*
804 * PCM 862 * PCM
805 */ 863 */
806int snd_hda_build_pcms(struct hda_bus *bus); 864int snd_hda_build_pcms(struct hda_bus *bus);
865int snd_hda_codec_build_pcms(struct hda_codec *codec);
807void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, 866void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
808 u32 stream_tag, 867 u32 stream_tag,
809 int channel_id, int format); 868 int channel_id, int format);
@@ -812,8 +871,6 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
812 unsigned int channels, 871 unsigned int channels,
813 unsigned int format, 872 unsigned int format,
814 unsigned int maxbps); 873 unsigned int maxbps);
815int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
816 u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
817int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, 874int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
818 unsigned int format); 875 unsigned int format);
819 876
@@ -831,18 +888,38 @@ int snd_hda_resume(struct hda_bus *bus);
831#endif 888#endif
832 889
833/* 890/*
891 * get widget information
892 */
893const char *snd_hda_get_jack_connectivity(u32 cfg);
894const char *snd_hda_get_jack_type(u32 cfg);
895const char *snd_hda_get_jack_location(u32 cfg);
896
897/*
834 * power saving 898 * power saving
835 */ 899 */
836#ifdef CONFIG_SND_HDA_POWER_SAVE 900#ifdef CONFIG_SND_HDA_POWER_SAVE
837void snd_hda_power_up(struct hda_codec *codec); 901void snd_hda_power_up(struct hda_codec *codec);
838void snd_hda_power_down(struct hda_codec *codec); 902void snd_hda_power_down(struct hda_codec *codec);
839#define snd_hda_codec_needs_resume(codec) codec->power_count 903#define snd_hda_codec_needs_resume(codec) codec->power_count
840int snd_hda_codecs_inuse(struct hda_bus *bus);
841#else 904#else
842static inline void snd_hda_power_up(struct hda_codec *codec) {} 905static inline void snd_hda_power_up(struct hda_codec *codec) {}
843static inline void snd_hda_power_down(struct hda_codec *codec) {} 906static inline void snd_hda_power_down(struct hda_codec *codec) {}
844#define snd_hda_codec_needs_resume(codec) 1 907#define snd_hda_codec_needs_resume(codec) 1
845#define snd_hda_codecs_inuse(bus) 1 908#endif
909
910/*
911 * Codec modularization
912 */
913
914/* Export symbols only for communication with codec drivers;
915 * When built in kernel, all HD-audio drivers are supposed to be statically
916 * linked to the kernel. Thus, the symbols don't have to (or shouldn't) be
917 * exported unless it's built as a module.
918 */
919#ifdef MODULE
920#define EXPORT_SYMBOL_HDA(sym) EXPORT_SYMBOL_GPL(sym)
921#else
922#define EXPORT_SYMBOL_HDA(sym)
846#endif 923#endif
847 924
848#endif /* __SOUND_HDA_CODEC_H */ 925#endif /* __SOUND_HDA_CODEC_H */
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
new file mode 100644
index 000000000000..fcad5ec31773
--- /dev/null
+++ b/sound/pci/hda/hda_eld.c
@@ -0,0 +1,590 @@
1/*
2 * Generic routines and proc interface for ELD(EDID Like Data) information
3 *
4 * Copyright(c) 2008 Intel Corporation.
5 *
6 * Authors:
7 * Wu Fengguang <wfg@linux.intel.com>
8 *
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/init.h>
25#include <sound/core.h>
26#include <asm/unaligned.h>
27#include "hda_codec.h"
28#include "hda_local.h"
29
30enum eld_versions {
31 ELD_VER_CEA_861D = 2,
32 ELD_VER_PARTIAL = 31,
33};
34
35enum cea_edid_versions {
36 CEA_EDID_VER_NONE = 0,
37 CEA_EDID_VER_CEA861 = 1,
38 CEA_EDID_VER_CEA861A = 2,
39 CEA_EDID_VER_CEA861BCD = 3,
40 CEA_EDID_VER_RESERVED = 4,
41};
42
43static char *cea_speaker_allocation_names[] = {
44 /* 0 */ "FL/FR",
45 /* 1 */ "LFE",
46 /* 2 */ "FC",
47 /* 3 */ "RL/RR",
48 /* 4 */ "RC",
49 /* 5 */ "FLC/FRC",
50 /* 6 */ "RLC/RRC",
51 /* 7 */ "FLW/FRW",
52 /* 8 */ "FLH/FRH",
53 /* 9 */ "TC",
54 /* 10 */ "FCH",
55};
56
57static char *eld_connection_type_names[4] = {
58 "HDMI",
59 "DisplayPort",
60 "2-reserved",
61 "3-reserved"
62};
63
64enum cea_audio_coding_types {
65 AUDIO_CODING_TYPE_REF_STREAM_HEADER = 0,
66 AUDIO_CODING_TYPE_LPCM = 1,
67 AUDIO_CODING_TYPE_AC3 = 2,
68 AUDIO_CODING_TYPE_MPEG1 = 3,
69 AUDIO_CODING_TYPE_MP3 = 4,
70 AUDIO_CODING_TYPE_MPEG2 = 5,
71 AUDIO_CODING_TYPE_AACLC = 6,
72 AUDIO_CODING_TYPE_DTS = 7,
73 AUDIO_CODING_TYPE_ATRAC = 8,
74 AUDIO_CODING_TYPE_SACD = 9,
75 AUDIO_CODING_TYPE_EAC3 = 10,
76 AUDIO_CODING_TYPE_DTS_HD = 11,
77 AUDIO_CODING_TYPE_MLP = 12,
78 AUDIO_CODING_TYPE_DST = 13,
79 AUDIO_CODING_TYPE_WMAPRO = 14,
80 AUDIO_CODING_TYPE_REF_CXT = 15,
81 /* also include valid xtypes below */
82 AUDIO_CODING_TYPE_HE_AAC = 15,
83 AUDIO_CODING_TYPE_HE_AAC2 = 16,
84 AUDIO_CODING_TYPE_MPEG_SURROUND = 17,
85};
86
87enum cea_audio_coding_xtypes {
88 AUDIO_CODING_XTYPE_HE_REF_CT = 0,
89 AUDIO_CODING_XTYPE_HE_AAC = 1,
90 AUDIO_CODING_XTYPE_HE_AAC2 = 2,
91 AUDIO_CODING_XTYPE_MPEG_SURROUND = 3,
92 AUDIO_CODING_XTYPE_FIRST_RESERVED = 4,
93};
94
95static char *cea_audio_coding_type_names[] = {
96 /* 0 */ "undefined",
97 /* 1 */ "LPCM",
98 /* 2 */ "AC-3",
99 /* 3 */ "MPEG1",
100 /* 4 */ "MP3",
101 /* 5 */ "MPEG2",
102 /* 6 */ "AAC-LC",
103 /* 7 */ "DTS",
104 /* 8 */ "ATRAC",
105 /* 9 */ "DSD (One Bit Audio)",
106 /* 10 */ "E-AC-3/DD+ (Dolby Digital Plus)",
107 /* 11 */ "DTS-HD",
108 /* 12 */ "MLP (Dolby TrueHD)",
109 /* 13 */ "DST",
110 /* 14 */ "WMAPro",
111 /* 15 */ "HE-AAC",
112 /* 16 */ "HE-AACv2",
113 /* 17 */ "MPEG Surround",
114};
115
116/*
117 * The following two lists are shared between
118 * - HDMI audio InfoFrame (source to sink)
119 * - CEA E-EDID Extension (sink to source)
120 */
121
122/*
123 * SS1:SS0 index => sample size
124 */
125static int cea_sample_sizes[4] = {
126 0, /* 0: Refer to Stream Header */
127 AC_SUPPCM_BITS_16, /* 1: 16 bits */
128 AC_SUPPCM_BITS_20, /* 2: 20 bits */
129 AC_SUPPCM_BITS_24, /* 3: 24 bits */
130};
131
132/*
133 * SF2:SF1:SF0 index => sampling frequency
134 */
135static int cea_sampling_frequencies[8] = {
136 0, /* 0: Refer to Stream Header */
137 SNDRV_PCM_RATE_32000, /* 1: 32000Hz */
138 SNDRV_PCM_RATE_44100, /* 2: 44100Hz */
139 SNDRV_PCM_RATE_48000, /* 3: 48000Hz */
140 SNDRV_PCM_RATE_88200, /* 4: 88200Hz */
141 SNDRV_PCM_RATE_96000, /* 5: 96000Hz */
142 SNDRV_PCM_RATE_176400, /* 6: 176400Hz */
143 SNDRV_PCM_RATE_192000, /* 7: 192000Hz */
144};
145
146static unsigned char hdmi_get_eld_byte(struct hda_codec *codec, hda_nid_t nid,
147 int byte_index)
148{
149 unsigned int val;
150
151 val = snd_hda_codec_read(codec, nid, 0,
152 AC_VERB_GET_HDMI_ELDD, byte_index);
153
154#ifdef BE_PARANOID
155 printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val);
156#endif
157
158 if ((val & AC_ELDD_ELD_VALID) == 0) {
159 snd_printd(KERN_INFO "HDMI: invalid ELD data byte %d\n",
160 byte_index);
161 val = 0;
162 }
163
164 return val & AC_ELDD_ELD_DATA;
165}
166
167#define GRAB_BITS(buf, byte, lowbit, bits) \
168({ \
169 BUILD_BUG_ON(lowbit > 7); \
170 BUILD_BUG_ON(bits > 8); \
171 BUILD_BUG_ON(bits <= 0); \
172 \
173 (buf[byte] >> (lowbit)) & ((1 << (bits)) - 1); \
174})
175
176static void hdmi_update_short_audio_desc(struct cea_sad *a,
177 const unsigned char *buf)
178{
179 int i;
180 int val;
181
182 val = GRAB_BITS(buf, 1, 0, 7);
183 a->rates = 0;
184 for (i = 0; i < 7; i++)
185 if (val & (1 << i))
186 a->rates |= cea_sampling_frequencies[i + 1];
187
188 a->channels = GRAB_BITS(buf, 0, 0, 3);
189 a->channels++;
190
191 a->format = GRAB_BITS(buf, 0, 3, 4);
192 switch (a->format) {
193 case AUDIO_CODING_TYPE_REF_STREAM_HEADER:
194 snd_printd(KERN_INFO
195 "HDMI: audio coding type 0 not expected\n");
196 break;
197
198 case AUDIO_CODING_TYPE_LPCM:
199 val = GRAB_BITS(buf, 2, 0, 3);
200 a->sample_bits = 0;
201 for (i = 0; i < 3; i++)
202 if (val & (1 << i))
203 a->sample_bits |= cea_sample_sizes[i + 1];
204 break;
205
206 case AUDIO_CODING_TYPE_AC3:
207 case AUDIO_CODING_TYPE_MPEG1:
208 case AUDIO_CODING_TYPE_MP3:
209 case AUDIO_CODING_TYPE_MPEG2:
210 case AUDIO_CODING_TYPE_AACLC:
211 case AUDIO_CODING_TYPE_DTS:
212 case AUDIO_CODING_TYPE_ATRAC:
213 a->max_bitrate = GRAB_BITS(buf, 2, 0, 8);
214 a->max_bitrate *= 8000;
215 break;
216
217 case AUDIO_CODING_TYPE_SACD:
218 break;
219
220 case AUDIO_CODING_TYPE_EAC3:
221 break;
222
223 case AUDIO_CODING_TYPE_DTS_HD:
224 break;
225
226 case AUDIO_CODING_TYPE_MLP:
227 break;
228
229 case AUDIO_CODING_TYPE_DST:
230 break;
231
232 case AUDIO_CODING_TYPE_WMAPRO:
233 a->profile = GRAB_BITS(buf, 2, 0, 3);
234 break;
235
236 case AUDIO_CODING_TYPE_REF_CXT:
237 a->format = GRAB_BITS(buf, 2, 3, 5);
238 if (a->format == AUDIO_CODING_XTYPE_HE_REF_CT ||
239 a->format >= AUDIO_CODING_XTYPE_FIRST_RESERVED) {
240 snd_printd(KERN_INFO
241 "HDMI: audio coding xtype %d not expected\n",
242 a->format);
243 a->format = 0;
244 } else
245 a->format += AUDIO_CODING_TYPE_HE_AAC -
246 AUDIO_CODING_XTYPE_HE_AAC;
247 break;
248 }
249}
250
251/*
252 * Be careful, ELD buf could be totally rubbish!
253 */
254static int hdmi_update_eld(struct hdmi_eld *e,
255 const unsigned char *buf, int size)
256{
257 int mnl;
258 int i;
259
260 e->eld_ver = GRAB_BITS(buf, 0, 3, 5);
261 if (e->eld_ver != ELD_VER_CEA_861D &&
262 e->eld_ver != ELD_VER_PARTIAL) {
263 snd_printd(KERN_INFO "HDMI: Unknown ELD version %d\n",
264 e->eld_ver);
265 goto out_fail;
266 }
267
268 e->eld_size = size;
269 e->baseline_len = GRAB_BITS(buf, 2, 0, 8);
270 mnl = GRAB_BITS(buf, 4, 0, 5);
271 e->cea_edid_ver = GRAB_BITS(buf, 4, 5, 3);
272
273 e->support_hdcp = GRAB_BITS(buf, 5, 0, 1);
274 e->support_ai = GRAB_BITS(buf, 5, 1, 1);
275 e->conn_type = GRAB_BITS(buf, 5, 2, 2);
276 e->sad_count = GRAB_BITS(buf, 5, 4, 4);
277
278 e->aud_synch_delay = GRAB_BITS(buf, 6, 0, 8) * 2;
279 e->spk_alloc = GRAB_BITS(buf, 7, 0, 7);
280
281 e->port_id = get_unaligned_le64(buf + 8);
282
283 /* not specified, but the spec's tendency is little endian */
284 e->manufacture_id = get_unaligned_le16(buf + 16);
285 e->product_id = get_unaligned_le16(buf + 18);
286
287 if (mnl > ELD_MAX_MNL) {
288 snd_printd(KERN_INFO "HDMI: MNL is reserved value %d\n", mnl);
289 goto out_fail;
290 } else if (ELD_FIXED_BYTES + mnl > size) {
291 snd_printd(KERN_INFO "HDMI: out of range MNL %d\n", mnl);
292 goto out_fail;
293 } else
294 strlcpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl);
295
296 for (i = 0; i < e->sad_count; i++) {
297 if (ELD_FIXED_BYTES + mnl + 3 * (i + 1) > size) {
298 snd_printd(KERN_INFO "HDMI: out of range SAD %d\n", i);
299 goto out_fail;
300 }
301 hdmi_update_short_audio_desc(e->sad + i,
302 buf + ELD_FIXED_BYTES + mnl + 3 * i);
303 }
304
305 return 0;
306
307out_fail:
308 e->eld_ver = 0;
309 return -EINVAL;
310}
311
312static int hdmi_present_sense(struct hda_codec *codec, hda_nid_t nid)
313{
314 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0);
315}
316
317static int hdmi_eld_valid(struct hda_codec *codec, hda_nid_t nid)
318{
319 int eldv;
320 int present;
321
322 present = hdmi_present_sense(codec, nid);
323 eldv = (present & AC_PINSENSE_ELDV);
324 present = (present & AC_PINSENSE_PRESENCE);
325
326#ifdef CONFIG_SND_DEBUG_VERBOSE
327 printk(KERN_INFO "HDMI: sink_present = %d, eld_valid = %d\n",
328 !!present, !!eldv);
329#endif
330
331 return eldv && present;
332}
333
334int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid)
335{
336 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE,
337 AC_DIPSIZE_ELD_BUF);
338}
339
340int snd_hdmi_get_eld(struct hdmi_eld *eld,
341 struct hda_codec *codec, hda_nid_t nid)
342{
343 int i;
344 int ret;
345 int size;
346 unsigned char *buf;
347
348 if (!hdmi_eld_valid(codec, nid))
349 return -ENOENT;
350
351 size = snd_hdmi_get_eld_size(codec, nid);
352 if (size == 0) {
353 /* wfg: workaround for ASUS P5E-VM HDMI board */
354 snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n");
355 size = 128;
356 }
357 if (size < ELD_FIXED_BYTES || size > PAGE_SIZE) {
358 snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size);
359 return -ERANGE;
360 }
361
362 buf = kmalloc(size, GFP_KERNEL);
363 if (!buf)
364 return -ENOMEM;
365
366 for (i = 0; i < size; i++)
367 buf[i] = hdmi_get_eld_byte(codec, nid, i);
368
369 ret = hdmi_update_eld(eld, buf, size);
370
371 kfree(buf);
372 return ret;
373}
374
375static void hdmi_show_short_audio_desc(struct cea_sad *a)
376{
377 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
378 char buf2[8 + SND_PRINT_BITS_ADVISED_BUFSIZE] = ", bits =";
379
380 if (!a->format)
381 return;
382
383 snd_print_pcm_rates(a->rates, buf, sizeof(buf));
384
385 if (a->format == AUDIO_CODING_TYPE_LPCM)
386 snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2 - 8));
387 else if (a->max_bitrate)
388 snprintf(buf2, sizeof(buf2),
389 ", max bitrate = %d", a->max_bitrate);
390 else
391 buf2[0] = '\0';
392
393 printk(KERN_INFO "HDMI: supports coding type %s:"
394 " channels = %d, rates =%s%s\n",
395 cea_audio_coding_type_names[a->format],
396 a->channels,
397 buf,
398 buf2);
399}
400
401void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen)
402{
403 int i, j;
404
405 for (i = 0, j = 0; i < ARRAY_SIZE(cea_speaker_allocation_names); i++) {
406 if (spk_alloc & (1 << i))
407 j += snprintf(buf + j, buflen - j, " %s",
408 cea_speaker_allocation_names[i]);
409 }
410 buf[j] = '\0'; /* necessary when j == 0 */
411}
412
413void snd_hdmi_show_eld(struct hdmi_eld *e)
414{
415 int i;
416
417 printk(KERN_INFO "HDMI: detected monitor %s at connection type %s\n",
418 e->monitor_name,
419 eld_connection_type_names[e->conn_type]);
420
421 if (e->spk_alloc) {
422 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
423 snd_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
424 printk(KERN_INFO "HDMI: available speakers:%s\n", buf);
425 }
426
427 for (i = 0; i < e->sad_count; i++)
428 hdmi_show_short_audio_desc(e->sad + i);
429}
430
431#ifdef CONFIG_PROC_FS
432
433static void hdmi_print_sad_info(int i, struct cea_sad *a,
434 struct snd_info_buffer *buffer)
435{
436 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
437
438 snd_iprintf(buffer, "sad%d_coding_type\t[0x%x] %s\n",
439 i, a->format, cea_audio_coding_type_names[a->format]);
440 snd_iprintf(buffer, "sad%d_channels\t\t%d\n", i, a->channels);
441
442 snd_print_pcm_rates(a->rates, buf, sizeof(buf));
443 snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf);
444
445 if (a->format == AUDIO_CODING_TYPE_LPCM) {
446 snd_print_pcm_bits(a->sample_bits, buf, sizeof(buf));
447 snd_iprintf(buffer, "sad%d_bits\t\t[0x%x]%s\n",
448 i, a->sample_bits, buf);
449 }
450
451 if (a->max_bitrate)
452 snd_iprintf(buffer, "sad%d_max_bitrate\t%d\n",
453 i, a->max_bitrate);
454
455 if (a->profile)
456 snd_iprintf(buffer, "sad%d_profile\t\t%d\n", i, a->profile);
457}
458
459static void hdmi_print_eld_info(struct snd_info_entry *entry,
460 struct snd_info_buffer *buffer)
461{
462 struct hdmi_eld *e = entry->private_data;
463 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
464 int i;
465 static char *eld_versoin_names[32] = {
466 "reserved",
467 "reserved",
468 "CEA-861D or below",
469 [3 ... 30] = "reserved",
470 [31] = "partial"
471 };
472 static char *cea_edid_version_names[8] = {
473 "no CEA EDID Timing Extension block present",
474 "CEA-861",
475 "CEA-861-A",
476 "CEA-861-B, C or D",
477 [4 ... 7] = "reserved"
478 };
479
480 snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name);
481 snd_iprintf(buffer, "connection_type\t\t%s\n",
482 eld_connection_type_names[e->conn_type]);
483 snd_iprintf(buffer, "eld_version\t\t[0x%x] %s\n", e->eld_ver,
484 eld_versoin_names[e->eld_ver]);
485 snd_iprintf(buffer, "edid_version\t\t[0x%x] %s\n", e->cea_edid_ver,
486 cea_edid_version_names[e->cea_edid_ver]);
487 snd_iprintf(buffer, "manufacture_id\t\t0x%x\n", e->manufacture_id);
488 snd_iprintf(buffer, "product_id\t\t0x%x\n", e->product_id);
489 snd_iprintf(buffer, "port_id\t\t\t0x%llx\n", (long long)e->port_id);
490 snd_iprintf(buffer, "support_hdcp\t\t%d\n", e->support_hdcp);
491 snd_iprintf(buffer, "support_ai\t\t%d\n", e->support_ai);
492 snd_iprintf(buffer, "audio_sync_delay\t%d\n", e->aud_synch_delay);
493
494 snd_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
495 snd_iprintf(buffer, "speakers\t\t[0x%x]%s\n", e->spk_alloc, buf);
496
497 snd_iprintf(buffer, "sad_count\t\t%d\n", e->sad_count);
498
499 for (i = 0; i < e->sad_count; i++)
500 hdmi_print_sad_info(i, e->sad + i, buffer);
501}
502
503static void hdmi_write_eld_info(struct snd_info_entry *entry,
504 struct snd_info_buffer *buffer)
505{
506 struct hdmi_eld *e = entry->private_data;
507 char line[64];
508 char name[64];
509 char *sname;
510 long long val;
511 int n;
512
513 while (!snd_info_get_line(buffer, line, sizeof(line))) {
514 if (sscanf(line, "%s %llx", name, &val) != 2)
515 continue;
516 /*
517 * We don't allow modification to these fields:
518 * monitor_name manufacture_id product_id
519 * eld_version edid_version
520 */
521 if (!strcmp(name, "connection_type"))
522 e->conn_type = val;
523 else if (!strcmp(name, "port_id"))
524 e->port_id = val;
525 else if (!strcmp(name, "support_hdcp"))
526 e->support_hdcp = val;
527 else if (!strcmp(name, "support_ai"))
528 e->support_ai = val;
529 else if (!strcmp(name, "audio_sync_delay"))
530 e->aud_synch_delay = val;
531 else if (!strcmp(name, "speakers"))
532 e->spk_alloc = val;
533 else if (!strcmp(name, "sad_count"))
534 e->sad_count = val;
535 else if (!strncmp(name, "sad", 3)) {
536 sname = name + 4;
537 n = name[3] - '0';
538 if (name[4] >= '0' && name[4] <= '9') {
539 sname++;
540 n = 10 * n + name[4] - '0';
541 }
542 if (n < 0 || n > 31) /* double the CEA limit */
543 continue;
544 if (!strcmp(sname, "_coding_type"))
545 e->sad[n].format = val;
546 else if (!strcmp(sname, "_channels"))
547 e->sad[n].channels = val;
548 else if (!strcmp(sname, "_rates"))
549 e->sad[n].rates = val;
550 else if (!strcmp(sname, "_bits"))
551 e->sad[n].sample_bits = val;
552 else if (!strcmp(sname, "_max_bitrate"))
553 e->sad[n].max_bitrate = val;
554 else if (!strcmp(sname, "_profile"))
555 e->sad[n].profile = val;
556 if (n >= e->sad_count)
557 e->sad_count = n + 1;
558 }
559 }
560}
561
562
563int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld)
564{
565 char name[32];
566 struct snd_info_entry *entry;
567 int err;
568
569 snprintf(name, sizeof(name), "eld#%d", codec->addr);
570 err = snd_card_proc_new(codec->bus->card, name, &entry);
571 if (err < 0)
572 return err;
573
574 snd_info_set_text_ops(entry, eld, hdmi_print_eld_info);
575 entry->c.text.write = hdmi_write_eld_info;
576 entry->mode |= S_IWUSR;
577 eld->proc_entry = entry;
578
579 return 0;
580}
581
582void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
583{
584 if (!codec->bus->shutdown && eld->proc_entry) {
585 snd_device_free(codec->bus->card, eld->proc_entry);
586 eld->proc_entry = NULL;
587 }
588}
589
590#endif /* CONFIG_PROC_FS */
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 0ca30894f7c6..65745e96dc70 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -723,7 +723,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
723 if (is_loopback) 723 if (is_loopback)
724 add_input_loopback(codec, node->nid, HDA_INPUT, index); 724 add_input_loopback(codec, node->nid, HDA_INPUT, index);
725 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); 725 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
726 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 726 err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
727 if (err < 0)
727 return err; 728 return err;
728 created = 1; 729 created = 1;
729 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && 730 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
@@ -732,7 +733,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
732 if (is_loopback) 733 if (is_loopback)
733 add_input_loopback(codec, node->nid, HDA_OUTPUT, 0); 734 add_input_loopback(codec, node->nid, HDA_OUTPUT, 0);
734 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); 735 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
735 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 736 err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
737 if (err < 0)
736 return err; 738 return err;
737 created = 1; 739 created = 1;
738 } 740 }
@@ -745,14 +747,16 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
745 (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) { 747 (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) {
746 knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); 748 knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT);
747 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); 749 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
748 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 750 err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
751 if (err < 0)
749 return err; 752 return err;
750 created = 1; 753 created = 1;
751 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && 754 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
752 (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) { 755 (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) {
753 knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); 756 knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);
754 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); 757 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
755 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 758 err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
759 if (err < 0)
756 return err; 760 return err;
757 created = 1; 761 created = 1;
758 } 762 }
@@ -849,8 +853,8 @@ static int build_input_controls(struct hda_codec *codec)
849 } 853 }
850 854
851 /* create input MUX if multiple sources are available */ 855 /* create input MUX if multiple sources are available */
852 if ((err = snd_ctl_add(codec->bus->card, 856 err = snd_hda_ctl_add(codec, snd_ctl_new1(&cap_sel, codec));
853 snd_ctl_new1(&cap_sel, codec))) < 0) 857 if (err < 0)
854 return err; 858 return err;
855 859
856 /* no volume control? */ 860 /* no volume control? */
@@ -867,8 +871,8 @@ static int build_input_controls(struct hda_codec *codec)
867 HDA_CODEC_VOLUME(name, adc_node->nid, 871 HDA_CODEC_VOLUME(name, adc_node->nid,
868 spec->input_mux.items[i].index, 872 spec->input_mux.items[i].index,
869 HDA_INPUT); 873 HDA_INPUT);
870 if ((err = snd_ctl_add(codec->bus->card, 874 err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
871 snd_ctl_new1(&knew, codec))) < 0) 875 if (err < 0)
872 return err; 876 return err;
873 } 877 }
874 878
@@ -1097,3 +1101,4 @@ int snd_hda_parse_generic_codec(struct hda_codec *codec)
1097 snd_hda_generic_free(codec); 1101 snd_hda_generic_free(codec);
1098 return err; 1102 return err;
1099} 1103}
1104EXPORT_SYMBOL(snd_hda_parse_generic_codec);
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index 6e18a422d993..300ab407cf42 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -23,10 +23,12 @@
23#include <linux/pci.h> 23#include <linux/pci.h>
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 <sound/core.h> 27#include <sound/core.h>
27#include "hda_codec.h" 28#include "hda_codec.h"
28#include "hda_local.h" 29#include "hda_local.h"
29#include <sound/hda_hwdep.h> 30#include <sound/hda_hwdep.h>
31#include <sound/minors.h>
30 32
31/* 33/*
32 * write/read an out-of-bound verb 34 * write/read an out-of-bound verb
@@ -95,7 +97,26 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
95 return 0; 97 return 0;
96} 98}
97 99
98int __devinit snd_hda_create_hwdep(struct hda_codec *codec) 100static void clear_hwdep_elements(struct hda_codec *codec)
101{
102 char **head;
103 int i;
104
105 /* clear init verbs */
106 snd_array_free(&codec->init_verbs);
107 /* clear hints */
108 head = codec->hints.list;
109 for (i = 0; i < codec->hints.used; i++, head++)
110 kfree(*head);
111 snd_array_free(&codec->hints);
112}
113
114static void hwdep_free(struct snd_hwdep *hwdep)
115{
116 clear_hwdep_elements(hwdep->private_data);
117}
118
119int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
99{ 120{
100 char hwname[16]; 121 char hwname[16];
101 struct snd_hwdep *hwdep; 122 struct snd_hwdep *hwdep;
@@ -109,6 +130,7 @@ int __devinit snd_hda_create_hwdep(struct hda_codec *codec)
109 sprintf(hwdep->name, "HDA Codec %d", codec->addr); 130 sprintf(hwdep->name, "HDA Codec %d", codec->addr);
110 hwdep->iface = SNDRV_HWDEP_IFACE_HDA; 131 hwdep->iface = SNDRV_HWDEP_IFACE_HDA;
111 hwdep->private_data = codec; 132 hwdep->private_data = codec;
133 hwdep->private_free = hwdep_free;
112 hwdep->exclusive = 1; 134 hwdep->exclusive = 1;
113 135
114 hwdep->ops.open = hda_hwdep_open; 136 hwdep->ops.open = hda_hwdep_open;
@@ -117,5 +139,215 @@ int __devinit snd_hda_create_hwdep(struct hda_codec *codec)
117 hwdep->ops.ioctl_compat = hda_hwdep_ioctl_compat; 139 hwdep->ops.ioctl_compat = hda_hwdep_ioctl_compat;
118#endif 140#endif
119 141
142 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
143 snd_array_init(&codec->hints, sizeof(char *), 32);
144
120 return 0; 145 return 0;
121} 146}
147
148#ifdef CONFIG_SND_HDA_RECONFIG
149
150/*
151 * sysfs interface
152 */
153
154static int clear_codec(struct hda_codec *codec)
155{
156 snd_hda_codec_reset(codec);
157 clear_hwdep_elements(codec);
158 return 0;
159}
160
161static int reconfig_codec(struct hda_codec *codec)
162{
163 int err;
164
165 snd_printk(KERN_INFO "hda-codec: reconfiguring\n");
166 snd_hda_codec_reset(codec);
167 err = snd_hda_codec_configure(codec);
168 if (err < 0)
169 return err;
170 /* rebuild PCMs */
171 err = snd_hda_codec_build_pcms(codec);
172 if (err < 0)
173 return err;
174 /* rebuild mixers */
175 err = snd_hda_codec_build_controls(codec);
176 if (err < 0)
177 return err;
178 return 0;
179}
180
181/*
182 * allocate a string at most len chars, and remove the trailing EOL
183 */
184static char *kstrndup_noeol(const char *src, size_t len)
185{
186 char *s = kstrndup(src, len, GFP_KERNEL);
187 char *p;
188 if (!s)
189 return NULL;
190 p = strchr(s, '\n');
191 if (p)
192 *p = 0;
193 return s;
194}
195
196#define CODEC_INFO_SHOW(type) \
197static ssize_t type##_show(struct device *dev, \
198 struct device_attribute *attr, \
199 char *buf) \
200{ \
201 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
202 struct hda_codec *codec = hwdep->private_data; \
203 return sprintf(buf, "0x%x\n", codec->type); \
204}
205
206#define CODEC_INFO_STR_SHOW(type) \
207static ssize_t type##_show(struct device *dev, \
208 struct device_attribute *attr, \
209 char *buf) \
210{ \
211 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
212 struct hda_codec *codec = hwdep->private_data; \
213 return sprintf(buf, "%s\n", \
214 codec->type ? codec->type : ""); \
215}
216
217CODEC_INFO_SHOW(vendor_id);
218CODEC_INFO_SHOW(subsystem_id);
219CODEC_INFO_SHOW(revision_id);
220CODEC_INFO_SHOW(afg);
221CODEC_INFO_SHOW(mfg);
222CODEC_INFO_STR_SHOW(name);
223CODEC_INFO_STR_SHOW(modelname);
224
225#define CODEC_INFO_STORE(type) \
226static ssize_t type##_store(struct device *dev, \
227 struct device_attribute *attr, \
228 const char *buf, size_t count) \
229{ \
230 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
231 struct hda_codec *codec = hwdep->private_data; \
232 char *after; \
233 codec->type = simple_strtoul(buf, &after, 0); \
234 return count; \
235}
236
237#define CODEC_INFO_STR_STORE(type) \
238static ssize_t type##_store(struct device *dev, \
239 struct device_attribute *attr, \
240 const char *buf, size_t count) \
241{ \
242 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
243 struct hda_codec *codec = hwdep->private_data; \
244 char *s = kstrndup_noeol(buf, 64); \
245 if (!s) \
246 return -ENOMEM; \
247 kfree(codec->type); \
248 codec->type = s; \
249 return count; \
250}
251
252CODEC_INFO_STORE(vendor_id);
253CODEC_INFO_STORE(subsystem_id);
254CODEC_INFO_STORE(revision_id);
255CODEC_INFO_STR_STORE(name);
256CODEC_INFO_STR_STORE(modelname);
257
258#define CODEC_ACTION_STORE(type) \
259static ssize_t type##_store(struct device *dev, \
260 struct device_attribute *attr, \
261 const char *buf, size_t count) \
262{ \
263 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
264 struct hda_codec *codec = hwdep->private_data; \
265 int err = 0; \
266 if (*buf) \
267 err = type##_codec(codec); \
268 return err < 0 ? err : count; \
269}
270
271CODEC_ACTION_STORE(reconfig);
272CODEC_ACTION_STORE(clear);
273
274static ssize_t init_verbs_store(struct device *dev,
275 struct device_attribute *attr,
276 const char *buf, size_t count)
277{
278 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
279 struct hda_codec *codec = hwdep->private_data;
280 char *p;
281 struct hda_verb verb, *v;
282
283 verb.nid = simple_strtoul(buf, &p, 0);
284 verb.verb = simple_strtoul(p, &p, 0);
285 verb.param = simple_strtoul(p, &p, 0);
286 if (!verb.nid || !verb.verb || !verb.param)
287 return -EINVAL;
288 v = snd_array_new(&codec->init_verbs);
289 if (!v)
290 return -ENOMEM;
291 *v = verb;
292 return count;
293}
294
295static ssize_t hints_store(struct device *dev,
296 struct device_attribute *attr,
297 const char *buf, size_t count)
298{
299 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
300 struct hda_codec *codec = hwdep->private_data;
301 char *p;
302 char **hint;
303
304 if (!*buf || isspace(*buf) || *buf == '#' || *buf == '\n')
305 return count;
306 p = kstrndup_noeol(buf, 1024);
307 if (!p)
308 return -ENOMEM;
309 hint = snd_array_new(&codec->hints);
310 if (!hint) {
311 kfree(p);
312 return -ENOMEM;
313 }
314 *hint = p;
315 return count;
316}
317
318#define CODEC_ATTR_RW(type) \
319 __ATTR(type, 0644, type##_show, type##_store)
320#define CODEC_ATTR_RO(type) \
321 __ATTR_RO(type)
322#define CODEC_ATTR_WO(type) \
323 __ATTR(type, 0200, NULL, type##_store)
324
325static struct device_attribute codec_attrs[] = {
326 CODEC_ATTR_RW(vendor_id),
327 CODEC_ATTR_RW(subsystem_id),
328 CODEC_ATTR_RW(revision_id),
329 CODEC_ATTR_RO(afg),
330 CODEC_ATTR_RO(mfg),
331 CODEC_ATTR_RW(name),
332 CODEC_ATTR_RW(modelname),
333 CODEC_ATTR_WO(init_verbs),
334 CODEC_ATTR_WO(hints),
335 CODEC_ATTR_WO(reconfig),
336 CODEC_ATTR_WO(clear),
337};
338
339/*
340 * create sysfs files on hwdep directory
341 */
342int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
343{
344 struct snd_hwdep *hwdep = codec->hwdep;
345 int i;
346
347 for (i = 0; i < ARRAY_SIZE(codec_attrs); i++)
348 snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card,
349 hwdep->device, &codec_attrs[i]);
350 return 0;
351}
352
353#endif /* CONFIG_SND_HDA_RECONFIG */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 35722ec920cb..a26ae8c4cf70 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -83,7 +83,10 @@ module_param(enable_msi, int, 0444);
83MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); 83MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)");
84 84
85#ifdef CONFIG_SND_HDA_POWER_SAVE 85#ifdef CONFIG_SND_HDA_POWER_SAVE
86/* power_save option is defined in hda_codec.c */ 86static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
87module_param(power_save, int, 0644);
88MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
89 "(in second, 0 = disable).");
87 90
88/* reset the HD-audio controller in power save mode. 91/* reset the HD-audio controller in power save mode.
89 * this may give more power-saving, but will take longer time to 92 * this may give more power-saving, but will take longer time to
@@ -292,6 +295,8 @@ enum {
292/* Define VIA HD Audio Device ID*/ 295/* Define VIA HD Audio Device ID*/
293#define VIA_HDAC_DEVICE_ID 0x3288 296#define VIA_HDAC_DEVICE_ID 0x3288
294 297
298/* HD Audio class code */
299#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
295 300
296/* 301/*
297 */ 302 */
@@ -392,6 +397,7 @@ struct azx {
392 unsigned int msi :1; 397 unsigned int msi :1;
393 unsigned int irq_pending_warned :1; 398 unsigned int irq_pending_warned :1;
394 unsigned int via_dmapos_patch :1; /* enable DMA-position fix for VIA */ 399 unsigned int via_dmapos_patch :1; /* enable DMA-position fix for VIA */
400 unsigned int probing :1; /* codec probing phase */
395 401
396 /* for debugging */ 402 /* for debugging */
397 unsigned int last_cmd; /* last issued command (to sync) */ 403 unsigned int last_cmd; /* last issued command (to sync) */
@@ -414,6 +420,7 @@ enum {
414 AZX_DRIVER_ULI, 420 AZX_DRIVER_ULI,
415 AZX_DRIVER_NVIDIA, 421 AZX_DRIVER_NVIDIA,
416 AZX_DRIVER_TERA, 422 AZX_DRIVER_TERA,
423 AZX_DRIVER_GENERIC,
417 AZX_NUM_DRIVERS, /* keep this as last entry */ 424 AZX_NUM_DRIVERS, /* keep this as last entry */
418}; 425};
419 426
@@ -427,6 +434,7 @@ static char *driver_short_names[] __devinitdata = {
427 [AZX_DRIVER_ULI] = "HDA ULI M5461", 434 [AZX_DRIVER_ULI] = "HDA ULI M5461",
428 [AZX_DRIVER_NVIDIA] = "HDA NVidia", 435 [AZX_DRIVER_NVIDIA] = "HDA NVidia",
429 [AZX_DRIVER_TERA] = "HDA Teradici", 436 [AZX_DRIVER_TERA] = "HDA Teradici",
437 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
430}; 438};
431 439
432/* 440/*
@@ -527,9 +535,9 @@ static void azx_free_cmd_io(struct azx *chip)
527} 535}
528 536
529/* send a command */ 537/* send a command */
530static int azx_corb_send_cmd(struct hda_codec *codec, u32 val) 538static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
531{ 539{
532 struct azx *chip = codec->bus->private_data; 540 struct azx *chip = bus->private_data;
533 unsigned int wp; 541 unsigned int wp;
534 542
535 /* add command to corb */ 543 /* add command to corb */
@@ -577,9 +585,9 @@ static void azx_update_rirb(struct azx *chip)
577} 585}
578 586
579/* receive a response */ 587/* receive a response */
580static unsigned int azx_rirb_get_response(struct hda_codec *codec) 588static unsigned int azx_rirb_get_response(struct hda_bus *bus)
581{ 589{
582 struct azx *chip = codec->bus->private_data; 590 struct azx *chip = bus->private_data;
583 unsigned long timeout; 591 unsigned long timeout;
584 592
585 again: 593 again:
@@ -596,7 +604,7 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
596 } 604 }
597 if (time_after(jiffies, timeout)) 605 if (time_after(jiffies, timeout))
598 break; 606 break;
599 if (codec->bus->needs_damn_long_delay) 607 if (bus->needs_damn_long_delay)
600 msleep(2); /* temporary workaround */ 608 msleep(2); /* temporary workaround */
601 else { 609 else {
602 udelay(10); 610 udelay(10);
@@ -624,6 +632,14 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
624 goto again; 632 goto again;
625 } 633 }
626 634
635 if (chip->probing) {
636 /* If this critical timeout happens during the codec probing
637 * phase, this is likely an access to a non-existing codec
638 * slot. Better to return an error and reset the system.
639 */
640 return -1;
641 }
642
627 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 643 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
628 "switching to single_cmd mode: last cmd=0x%08x\n", 644 "switching to single_cmd mode: last cmd=0x%08x\n",
629 chip->last_cmd); 645 chip->last_cmd);
@@ -646,9 +662,9 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
646 */ 662 */
647 663
648/* send a command */ 664/* send a command */
649static int azx_single_send_cmd(struct hda_codec *codec, u32 val) 665static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
650{ 666{
651 struct azx *chip = codec->bus->private_data; 667 struct azx *chip = bus->private_data;
652 int timeout = 50; 668 int timeout = 50;
653 669
654 while (timeout--) { 670 while (timeout--) {
@@ -671,9 +687,9 @@ static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
671} 687}
672 688
673/* receive a response */ 689/* receive a response */
674static unsigned int azx_single_get_response(struct hda_codec *codec) 690static unsigned int azx_single_get_response(struct hda_bus *bus)
675{ 691{
676 struct azx *chip = codec->bus->private_data; 692 struct azx *chip = bus->private_data;
677 int timeout = 50; 693 int timeout = 50;
678 694
679 while (timeout--) { 695 while (timeout--) {
@@ -696,38 +712,29 @@ static unsigned int azx_single_get_response(struct hda_codec *codec)
696 */ 712 */
697 713
698/* send a command */ 714/* send a command */
699static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, 715static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
700 int direct, unsigned int verb,
701 unsigned int para)
702{ 716{
703 struct azx *chip = codec->bus->private_data; 717 struct azx *chip = bus->private_data;
704 u32 val;
705
706 val = (u32)(codec->addr & 0x0f) << 28;
707 val |= (u32)direct << 27;
708 val |= (u32)nid << 20;
709 val |= verb << 8;
710 val |= para;
711 chip->last_cmd = val;
712 718
719 chip->last_cmd = val;
713 if (chip->single_cmd) 720 if (chip->single_cmd)
714 return azx_single_send_cmd(codec, val); 721 return azx_single_send_cmd(bus, val);
715 else 722 else
716 return azx_corb_send_cmd(codec, val); 723 return azx_corb_send_cmd(bus, val);
717} 724}
718 725
719/* get a response */ 726/* get a response */
720static unsigned int azx_get_response(struct hda_codec *codec) 727static unsigned int azx_get_response(struct hda_bus *bus)
721{ 728{
722 struct azx *chip = codec->bus->private_data; 729 struct azx *chip = bus->private_data;
723 if (chip->single_cmd) 730 if (chip->single_cmd)
724 return azx_single_get_response(codec); 731 return azx_single_get_response(bus);
725 else 732 else
726 return azx_rirb_get_response(codec); 733 return azx_rirb_get_response(bus);
727} 734}
728 735
729#ifdef CONFIG_SND_HDA_POWER_SAVE 736#ifdef CONFIG_SND_HDA_POWER_SAVE
730static void azx_power_notify(struct hda_codec *codec); 737static void azx_power_notify(struct hda_bus *bus);
731#endif 738#endif
732 739
733/* reset codec link */ 740/* reset codec link */
@@ -1184,6 +1191,28 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1184 return 0; 1191 return 0;
1185} 1192}
1186 1193
1194/*
1195 * Probe the given codec address
1196 */
1197static int probe_codec(struct azx *chip, int addr)
1198{
1199 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
1200 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
1201 unsigned int res;
1202
1203 chip->probing = 1;
1204 azx_send_cmd(chip->bus, cmd);
1205 res = azx_get_response(chip->bus);
1206 chip->probing = 0;
1207 if (res == -1)
1208 return -EIO;
1209 snd_printdd("hda_intel: codec #%d probed OK\n", addr);
1210 return 0;
1211}
1212
1213static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
1214 struct hda_pcm *cpcm);
1215static void azx_stop_chip(struct azx *chip);
1187 1216
1188/* 1217/*
1189 * Codec initialization 1218 * Codec initialization
@@ -1194,21 +1223,12 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1194 [AZX_DRIVER_TERA] = 1, 1223 [AZX_DRIVER_TERA] = 1,
1195}; 1224};
1196 1225
1197/* number of slots to probe as default
1198 * this can be different from azx_max_codecs[] -- e.g. some boards
1199 * report wrongly the non-existing 4th slot availability
1200 */
1201static unsigned int azx_default_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1202 [AZX_DRIVER_ICH] = 3,
1203 [AZX_DRIVER_ATI] = 3,
1204};
1205
1206static int __devinit azx_codec_create(struct azx *chip, const char *model, 1226static int __devinit azx_codec_create(struct azx *chip, const char *model,
1207 unsigned int codec_probe_mask) 1227 unsigned int codec_probe_mask)
1208{ 1228{
1209 struct hda_bus_template bus_temp; 1229 struct hda_bus_template bus_temp;
1210 int c, codecs, audio_codecs, err; 1230 int c, codecs, err;
1211 int def_slots, max_slots; 1231 int max_slots;
1212 1232
1213 memset(&bus_temp, 0, sizeof(bus_temp)); 1233 memset(&bus_temp, 0, sizeof(bus_temp));
1214 bus_temp.private_data = chip; 1234 bus_temp.private_data = chip;
@@ -1216,7 +1236,9 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1216 bus_temp.pci = chip->pci; 1236 bus_temp.pci = chip->pci;
1217 bus_temp.ops.command = azx_send_cmd; 1237 bus_temp.ops.command = azx_send_cmd;
1218 bus_temp.ops.get_response = azx_get_response; 1238 bus_temp.ops.get_response = azx_get_response;
1239 bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
1219#ifdef CONFIG_SND_HDA_POWER_SAVE 1240#ifdef CONFIG_SND_HDA_POWER_SAVE
1241 bus_temp.power_save = &power_save;
1220 bus_temp.ops.pm_notify = azx_power_notify; 1242 bus_temp.ops.pm_notify = azx_power_notify;
1221#endif 1243#endif
1222 1244
@@ -1227,33 +1249,43 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1227 if (chip->driver_type == AZX_DRIVER_NVIDIA) 1249 if (chip->driver_type == AZX_DRIVER_NVIDIA)
1228 chip->bus->needs_damn_long_delay = 1; 1250 chip->bus->needs_damn_long_delay = 1;
1229 1251
1230 codecs = audio_codecs = 0; 1252 codecs = 0;
1231 max_slots = azx_max_codecs[chip->driver_type]; 1253 max_slots = azx_max_codecs[chip->driver_type];
1232 if (!max_slots) 1254 if (!max_slots)
1233 max_slots = AZX_MAX_CODECS; 1255 max_slots = AZX_MAX_CODECS;
1234 def_slots = azx_default_codecs[chip->driver_type]; 1256
1235 if (!def_slots) 1257 /* First try to probe all given codec slots */
1236 def_slots = max_slots; 1258 for (c = 0; c < max_slots; c++) {
1237 for (c = 0; c < def_slots; c++) { 1259 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1260 if (probe_codec(chip, c) < 0) {
1261 /* Some BIOSen give you wrong codec addresses
1262 * that don't exist
1263 */
1264 snd_printk(KERN_WARNING
1265 "hda_intel: Codec #%d probe error; "
1266 "disabling it...\n", c);
1267 chip->codec_mask &= ~(1 << c);
1268 /* More badly, accessing to a non-existing
1269 * codec often screws up the controller chip,
1270 * and distrubs the further communications.
1271 * Thus if an error occurs during probing,
1272 * better to reset the controller chip to
1273 * get back to the sanity state.
1274 */
1275 azx_stop_chip(chip);
1276 azx_init_chip(chip);
1277 }
1278 }
1279 }
1280
1281 /* Then create codec instances */
1282 for (c = 0; c < max_slots; c++) {
1238 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1283 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1239 struct hda_codec *codec; 1284 struct hda_codec *codec;
1240 err = snd_hda_codec_new(chip->bus, c, &codec); 1285 err = snd_hda_codec_new(chip->bus, c, &codec);
1241 if (err < 0) 1286 if (err < 0)
1242 continue; 1287 continue;
1243 codecs++; 1288 codecs++;
1244 if (codec->afg)
1245 audio_codecs++;
1246 }
1247 }
1248 if (!audio_codecs) {
1249 /* probe additional slots if no codec is found */
1250 for (; c < max_slots; c++) {
1251 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1252 err = snd_hda_codec_new(chip->bus, c, NULL);
1253 if (err < 0)
1254 continue;
1255 codecs++;
1256 }
1257 } 1289 }
1258 } 1290 }
1259 if (!codecs) { 1291 if (!codecs) {
@@ -1722,111 +1754,59 @@ static struct snd_pcm_ops azx_pcm_ops = {
1722 1754
1723static void azx_pcm_free(struct snd_pcm *pcm) 1755static void azx_pcm_free(struct snd_pcm *pcm)
1724{ 1756{
1725 kfree(pcm->private_data); 1757 struct azx_pcm *apcm = pcm->private_data;
1758 if (apcm) {
1759 apcm->chip->pcm[pcm->device] = NULL;
1760 kfree(apcm);
1761 }
1726} 1762}
1727 1763
1728static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec, 1764static int
1729 struct hda_pcm *cpcm) 1765azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
1766 struct hda_pcm *cpcm)
1730{ 1767{
1731 int err; 1768 struct azx *chip = bus->private_data;
1732 struct snd_pcm *pcm; 1769 struct snd_pcm *pcm;
1733 struct azx_pcm *apcm; 1770 struct azx_pcm *apcm;
1771 int pcm_dev = cpcm->device;
1772 int s, err;
1734 1773
1735 /* if no substreams are defined for both playback and capture, 1774 if (pcm_dev >= AZX_MAX_PCMS) {
1736 * it's just a placeholder. ignore it. 1775 snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n",
1737 */ 1776 pcm_dev);
1738 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
1739 return 0;
1740
1741 if (snd_BUG_ON(!cpcm->name))
1742 return -EINVAL; 1777 return -EINVAL;
1743 1778 }
1744 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device, 1779 if (chip->pcm[pcm_dev]) {
1745 cpcm->stream[0].substreams, 1780 snd_printk(KERN_ERR SFX "PCM %d already exists\n", pcm_dev);
1746 cpcm->stream[1].substreams, 1781 return -EBUSY;
1782 }
1783 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
1784 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
1785 cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
1747 &pcm); 1786 &pcm);
1748 if (err < 0) 1787 if (err < 0)
1749 return err; 1788 return err;
1750 strcpy(pcm->name, cpcm->name); 1789 strcpy(pcm->name, cpcm->name);
1751 apcm = kmalloc(sizeof(*apcm), GFP_KERNEL); 1790 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
1752 if (apcm == NULL) 1791 if (apcm == NULL)
1753 return -ENOMEM; 1792 return -ENOMEM;
1754 apcm->chip = chip; 1793 apcm->chip = chip;
1755 apcm->codec = codec; 1794 apcm->codec = codec;
1756 apcm->hinfo[0] = &cpcm->stream[0];
1757 apcm->hinfo[1] = &cpcm->stream[1];
1758 pcm->private_data = apcm; 1795 pcm->private_data = apcm;
1759 pcm->private_free = azx_pcm_free; 1796 pcm->private_free = azx_pcm_free;
1760 if (cpcm->stream[0].substreams) 1797 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
1761 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &azx_pcm_ops); 1798 pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
1762 if (cpcm->stream[1].substreams) 1799 chip->pcm[pcm_dev] = pcm;
1763 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops); 1800 cpcm->pcm = pcm;
1801 for (s = 0; s < 2; s++) {
1802 apcm->hinfo[s] = &cpcm->stream[s];
1803 if (cpcm->stream[s].substreams)
1804 snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
1805 }
1806 /* buffer pre-allocation */
1764 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 1807 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1765 snd_dma_pci_data(chip->pci), 1808 snd_dma_pci_data(chip->pci),
1766 1024 * 64, 32 * 1024 * 1024); 1809 1024 * 64, 32 * 1024 * 1024);
1767 chip->pcm[cpcm->device] = pcm;
1768 return 0;
1769}
1770
1771static int __devinit azx_pcm_create(struct azx *chip)
1772{
1773 static const char *dev_name[HDA_PCM_NTYPES] = {
1774 "Audio", "SPDIF", "HDMI", "Modem"
1775 };
1776 /* starting device index for each PCM type */
1777 static int dev_idx[HDA_PCM_NTYPES] = {
1778 [HDA_PCM_TYPE_AUDIO] = 0,
1779 [HDA_PCM_TYPE_SPDIF] = 1,
1780 [HDA_PCM_TYPE_HDMI] = 3,
1781 [HDA_PCM_TYPE_MODEM] = 6
1782 };
1783 /* normal audio device indices; not linear to keep compatibility */
1784 static int audio_idx[4] = { 0, 2, 4, 5 };
1785 struct hda_codec *codec;
1786 int c, err;
1787 int num_devs[HDA_PCM_NTYPES];
1788
1789 err = snd_hda_build_pcms(chip->bus);
1790 if (err < 0)
1791 return err;
1792
1793 /* create audio PCMs */
1794 memset(num_devs, 0, sizeof(num_devs));
1795 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1796 for (c = 0; c < codec->num_pcms; c++) {
1797 struct hda_pcm *cpcm = &codec->pcm_info[c];
1798 int type = cpcm->pcm_type;
1799 switch (type) {
1800 case HDA_PCM_TYPE_AUDIO:
1801 if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
1802 snd_printk(KERN_WARNING
1803 "Too many audio devices\n");
1804 continue;
1805 }
1806 cpcm->device = audio_idx[num_devs[type]];
1807 break;
1808 case HDA_PCM_TYPE_SPDIF:
1809 case HDA_PCM_TYPE_HDMI:
1810 case HDA_PCM_TYPE_MODEM:
1811 if (num_devs[type]) {
1812 snd_printk(KERN_WARNING
1813 "%s already defined\n",
1814 dev_name[type]);
1815 continue;
1816 }
1817 cpcm->device = dev_idx[type];
1818 break;
1819 default:
1820 snd_printk(KERN_WARNING
1821 "Invalid PCM type %d\n", type);
1822 continue;
1823 }
1824 num_devs[type]++;
1825 err = create_codec_pcm(chip, codec, cpcm);
1826 if (err < 0)
1827 return err;
1828 }
1829 }
1830 return 0; 1810 return 0;
1831} 1811}
1832 1812
@@ -1903,13 +1883,13 @@ static void azx_stop_chip(struct azx *chip)
1903 1883
1904#ifdef CONFIG_SND_HDA_POWER_SAVE 1884#ifdef CONFIG_SND_HDA_POWER_SAVE
1905/* power-up/down the controller */ 1885/* power-up/down the controller */
1906static void azx_power_notify(struct hda_codec *codec) 1886static void azx_power_notify(struct hda_bus *bus)
1907{ 1887{
1908 struct azx *chip = codec->bus->private_data; 1888 struct azx *chip = bus->private_data;
1909 struct hda_codec *c; 1889 struct hda_codec *c;
1910 int power_on = 0; 1890 int power_on = 0;
1911 1891
1912 list_for_each_entry(c, &codec->bus->codec_list, list) { 1892 list_for_each_entry(c, &bus->codec_list, list) {
1913 if (c->power_on) { 1893 if (c->power_on) {
1914 power_on = 1; 1894 power_on = 1;
1915 break; 1895 break;
@@ -1926,6 +1906,18 @@ static void azx_power_notify(struct hda_codec *codec)
1926/* 1906/*
1927 * power management 1907 * power management
1928 */ 1908 */
1909
1910static int snd_hda_codecs_inuse(struct hda_bus *bus)
1911{
1912 struct hda_codec *codec;
1913
1914 list_for_each_entry(codec, &bus->codec_list, list) {
1915 if (snd_hda_codec_needs_resume(codec))
1916 return 1;
1917 }
1918 return 0;
1919}
1920
1929static int azx_suspend(struct pci_dev *pci, pm_message_t state) 1921static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1930{ 1922{
1931 struct snd_card *card = pci_get_drvdata(pci); 1923 struct snd_card *card = pci_get_drvdata(pci);
@@ -2095,6 +2087,10 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
2095 SND_PCI_QUIRK(0x1014, 0x05b7, "Thinkpad Z60", 0x01), 2087 SND_PCI_QUIRK(0x1014, 0x05b7, "Thinkpad Z60", 0x01),
2096 SND_PCI_QUIRK(0x17aa, 0x2010, "Thinkpad X/T/R60", 0x01), 2088 SND_PCI_QUIRK(0x17aa, 0x2010, "Thinkpad X/T/R60", 0x01),
2097 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X/T/R61", 0x01), 2089 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X/T/R61", 0x01),
2090 /* broken BIOS */
2091 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
2092 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
2093 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
2098 {} 2094 {}
2099}; 2095};
2100 2096
@@ -2229,6 +2225,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2229 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; 2225 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
2230 chip->capture_streams = ATIHDMI_NUM_CAPTURE; 2226 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
2231 break; 2227 break;
2228 case AZX_DRIVER_GENERIC:
2232 default: 2229 default:
2233 chip->playback_streams = ICH6_NUM_PLAYBACK; 2230 chip->playback_streams = ICH6_NUM_PLAYBACK;
2234 chip->capture_streams = ICH6_NUM_CAPTURE; 2231 chip->capture_streams = ICH6_NUM_CAPTURE;
@@ -2338,40 +2335,30 @@ static int __devinit azx_probe(struct pci_dev *pci,
2338 } 2335 }
2339 2336
2340 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); 2337 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
2341 if (err < 0) { 2338 if (err < 0)
2342 snd_card_free(card); 2339 goto out_free;
2343 return err;
2344 }
2345 card->private_data = chip; 2340 card->private_data = chip;
2346 2341
2347 /* create codec instances */ 2342 /* create codec instances */
2348 err = azx_codec_create(chip, model[dev], probe_mask[dev]); 2343 err = azx_codec_create(chip, model[dev], probe_mask[dev]);
2349 if (err < 0) { 2344 if (err < 0)
2350 snd_card_free(card); 2345 goto out_free;
2351 return err;
2352 }
2353 2346
2354 /* create PCM streams */ 2347 /* create PCM streams */
2355 err = azx_pcm_create(chip); 2348 err = snd_hda_build_pcms(chip->bus);
2356 if (err < 0) { 2349 if (err < 0)
2357 snd_card_free(card); 2350 goto out_free;
2358 return err;
2359 }
2360 2351
2361 /* create mixer controls */ 2352 /* create mixer controls */
2362 err = azx_mixer_create(chip); 2353 err = azx_mixer_create(chip);
2363 if (err < 0) { 2354 if (err < 0)
2364 snd_card_free(card); 2355 goto out_free;
2365 return err;
2366 }
2367 2356
2368 snd_card_set_dev(card, &pci->dev); 2357 snd_card_set_dev(card, &pci->dev);
2369 2358
2370 err = snd_card_register(card); 2359 err = snd_card_register(card);
2371 if (err < 0) { 2360 if (err < 0)
2372 snd_card_free(card); 2361 goto out_free;
2373 return err;
2374 }
2375 2362
2376 pci_set_drvdata(pci, card); 2363 pci_set_drvdata(pci, card);
2377 chip->running = 1; 2364 chip->running = 1;
@@ -2380,6 +2367,9 @@ static int __devinit azx_probe(struct pci_dev *pci,
2380 2367
2381 dev++; 2368 dev++;
2382 return err; 2369 return err;
2370out_free:
2371 snd_card_free(card);
2372 return err;
2383} 2373}
2384 2374
2385static void __devexit azx_remove(struct pci_dev *pci) 2375static void __devexit azx_remove(struct pci_dev *pci)
@@ -2453,6 +2443,11 @@ static struct pci_device_id azx_ids[] = {
2453 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA }, 2443 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA },
2454 /* Teradici */ 2444 /* Teradici */
2455 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2445 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
2446 /* AMD Generic, PCI class code and Vendor ID for HD Audio */
2447 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID),
2448 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
2449 .class_mask = 0xffffff,
2450 .driver_data = AZX_DRIVER_GENERIC },
2456 { 0, } 2451 { 0, }
2457}; 2452};
2458MODULE_DEVICE_TABLE(pci, azx_ids); 2453MODULE_DEVICE_TABLE(pci, azx_ids);
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 7957fefda730..6f2fe0f9fdd8 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -96,6 +96,8 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
96 const char *name); 96 const char *name);
97int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 97int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
98 unsigned int *tlv, const char **slaves); 98 unsigned int *tlv, const char **slaves);
99void snd_hda_codec_reset(struct hda_codec *codec);
100int snd_hda_codec_configure(struct hda_codec *codec);
99 101
100/* amp value bits */ 102/* amp value bits */
101#define HDA_AMP_MUTE 0x80 103#define HDA_AMP_MUTE 0x80
@@ -282,6 +284,12 @@ int snd_hda_codec_proc_new(struct hda_codec *codec);
282static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; } 284static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
283#endif 285#endif
284 286
287#define SND_PRINT_RATES_ADVISED_BUFSIZE 80
288void snd_print_pcm_rates(int pcm, char *buf, int buflen);
289
290#define SND_PRINT_BITS_ADVISED_BUFSIZE 16
291void snd_print_pcm_bits(int pcm, char *buf, int buflen);
292
285/* 293/*
286 * Misc 294 * Misc
287 */ 295 */
@@ -364,17 +372,17 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
364/* amp values */ 372/* amp values */
365#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) 373#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
366#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) 374#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
367#define AMP_OUT_MUTE 0xb080 375#define AMP_OUT_MUTE 0xb080
368#define AMP_OUT_UNMUTE 0xb000 376#define AMP_OUT_UNMUTE 0xb000
369#define AMP_OUT_ZERO 0xb000 377#define AMP_OUT_ZERO 0xb000
370/* pinctl values */ 378/* pinctl values */
371#define PIN_IN (AC_PINCTL_IN_EN) 379#define PIN_IN (AC_PINCTL_IN_EN)
372#define PIN_VREFHIZ (AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ) 380#define PIN_VREFHIZ (AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ)
373#define PIN_VREF50 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_50) 381#define PIN_VREF50 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_50)
374#define PIN_VREFGRD (AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD) 382#define PIN_VREFGRD (AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD)
375#define PIN_VREF80 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_80) 383#define PIN_VREF80 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_80)
376#define PIN_VREF100 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_100) 384#define PIN_VREF100 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_100)
377#define PIN_OUT (AC_PINCTL_OUT_EN) 385#define PIN_OUT (AC_PINCTL_OUT_EN)
378#define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) 386#define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN)
379#define PIN_HP_AMP (AC_PINCTL_HP_EN) 387#define PIN_HP_AMP (AC_PINCTL_HP_EN)
380 388
@@ -393,10 +401,26 @@ u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
393int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 401int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
394 unsigned int caps); 402 unsigned int caps);
395 403
404int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl);
405void snd_hda_ctls_clear(struct hda_codec *codec);
406
396/* 407/*
397 * hwdep interface 408 * hwdep interface
398 */ 409 */
410#ifdef CONFIG_SND_HDA_HWDEP
399int snd_hda_create_hwdep(struct hda_codec *codec); 411int snd_hda_create_hwdep(struct hda_codec *codec);
412#else
413static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
414#endif
415
416#ifdef CONFIG_SND_HDA_RECONFIG
417int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
418#else
419static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
420{
421 return 0;
422}
423#endif
400 424
401/* 425/*
402 * power-management 426 * power-management
@@ -430,4 +454,66 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
430#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) 454#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1)
431#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 455#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
432 456
457/*
458 * CEA Short Audio Descriptor data
459 */
460struct cea_sad {
461 int channels;
462 int format; /* (format == 0) indicates invalid SAD */
463 int rates;
464 int sample_bits; /* for LPCM */
465 int max_bitrate; /* for AC3...ATRAC */
466 int profile; /* for WMAPRO */
467};
468
469#define ELD_FIXED_BYTES 20
470#define ELD_MAX_MNL 16
471#define ELD_MAX_SAD 16
472
473/*
474 * ELD: EDID Like Data
475 */
476struct hdmi_eld {
477 int eld_size;
478 int baseline_len;
479 int eld_ver; /* (eld_ver == 0) indicates invalid ELD */
480 int cea_edid_ver;
481 char monitor_name[ELD_MAX_MNL + 1];
482 int manufacture_id;
483 int product_id;
484 u64 port_id;
485 int support_hdcp;
486 int support_ai;
487 int conn_type;
488 int aud_synch_delay;
489 int spk_alloc;
490 int sad_count;
491 struct cea_sad sad[ELD_MAX_SAD];
492#ifdef CONFIG_PROC_FS
493 struct snd_info_entry *proc_entry;
494#endif
495};
496
497int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
498int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t);
499void snd_hdmi_show_eld(struct hdmi_eld *eld);
500
501#ifdef CONFIG_PROC_FS
502int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld);
503void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld);
504#else
505static inline int snd_hda_eld_proc_new(struct hda_codec *codec,
506 struct hdmi_eld *eld)
507{
508 return 0;
509}
510static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
511 struct hdmi_eld *eld)
512{
513}
514#endif
515
516#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
517void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
518
433#endif /* __SOUND_HDA_LOCAL_H */ 519#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
deleted file mode 100644
index dfbcfa88da44..000000000000
--- a/sound/pci/hda/hda_patch.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * HDA Patches - included by hda_codec.c
3 */
4
5/* Realtek codecs */
6extern struct hda_codec_preset snd_hda_preset_realtek[];
7/* C-Media codecs */
8extern struct hda_codec_preset snd_hda_preset_cmedia[];
9/* Analog Devices codecs */
10extern struct hda_codec_preset snd_hda_preset_analog[];
11/* SigmaTel codecs */
12extern struct hda_codec_preset snd_hda_preset_sigmatel[];
13/* SiLabs 3054/3055 modem codecs */
14extern struct hda_codec_preset snd_hda_preset_si3054[];
15/* ATI HDMI codecs */
16extern struct hda_codec_preset snd_hda_preset_atihdmi[];
17/* Conexant audio codec */
18extern struct hda_codec_preset snd_hda_preset_conexant[];
19/* VIA codecs */
20extern struct hda_codec_preset snd_hda_preset_via[];
21/* NVIDIA HDMI codecs */
22extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index c39af986bff1..7ca66d654148 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -91,31 +91,21 @@ static void print_amp_vals(struct snd_info_buffer *buffer,
91 91
92static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm) 92static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
93{ 93{
94 static unsigned int rates[] = { 94 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
95 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
96 96000, 176400, 192000, 384000
97 };
98 int i;
99 95
100 pcm &= AC_SUPPCM_RATES; 96 pcm &= AC_SUPPCM_RATES;
101 snd_iprintf(buffer, " rates [0x%x]:", pcm); 97 snd_iprintf(buffer, " rates [0x%x]:", pcm);
102 for (i = 0; i < ARRAY_SIZE(rates); i++) 98 snd_print_pcm_rates(pcm, buf, sizeof(buf));
103 if (pcm & (1 << i)) 99 snd_iprintf(buffer, "%s\n", buf);
104 snd_iprintf(buffer, " %d", rates[i]);
105 snd_iprintf(buffer, "\n");
106} 100}
107 101
108static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm) 102static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
109{ 103{
110 static unsigned int bits[] = { 8, 16, 20, 24, 32 }; 104 char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
111 int i;
112 105
113 pcm = (pcm >> 16) & 0xff; 106 snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff);
114 snd_iprintf(buffer, " bits [0x%x]:", pcm); 107 snd_print_pcm_bits(pcm, buf, sizeof(buf));
115 for (i = 0; i < ARRAY_SIZE(bits); i++) 108 snd_iprintf(buffer, "%s\n", buf);
116 if (pcm & (1 << i))
117 snd_iprintf(buffer, " %d", bits[i]);
118 snd_iprintf(buffer, "\n");
119} 109}
120 110
121static void print_pcm_formats(struct snd_info_buffer *buffer, 111static void print_pcm_formats(struct snd_info_buffer *buffer,
@@ -145,32 +135,6 @@ static void print_pcm_caps(struct snd_info_buffer *buffer,
145 print_pcm_formats(buffer, stream); 135 print_pcm_formats(buffer, stream);
146} 136}
147 137
148static const char *get_jack_location(u32 cfg)
149{
150 static char *bases[7] = {
151 "N/A", "Rear", "Front", "Left", "Right", "Top", "Bottom",
152 };
153 static unsigned char specials_idx[] = {
154 0x07, 0x08,
155 0x17, 0x18, 0x19,
156 0x37, 0x38
157 };
158 static char *specials[] = {
159 "Rear Panel", "Drive Bar",
160 "Riser", "HDMI", "ATAPI",
161 "Mobile-In", "Mobile-Out"
162 };
163 int i;
164 cfg = (cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT;
165 if ((cfg & 0x0f) < 7)
166 return bases[cfg & 0x0f];
167 for (i = 0; i < ARRAY_SIZE(specials_idx); i++) {
168 if (cfg == specials_idx[i])
169 return specials[i];
170 }
171 return "UNKNOWN";
172}
173
174static const char *get_jack_connection(u32 cfg) 138static const char *get_jack_connection(u32 cfg)
175{ 139{
176 static char *names[16] = { 140 static char *names[16] = {
@@ -206,13 +170,6 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
206 int *supports_vref) 170 int *supports_vref)
207{ 171{
208 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; 172 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
209 static char *jack_types[16] = {
210 "Line Out", "Speaker", "HP Out", "CD",
211 "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand",
212 "Line In", "Aux", "Mic", "Telephony",
213 "SPDIF In", "Digitial In", "Reserved", "Other"
214 };
215 static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" };
216 unsigned int caps, val; 173 unsigned int caps, val;
217 174
218 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 175 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
@@ -274,9 +231,9 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
274 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 231 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
275 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, 232 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
276 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], 233 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
277 jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT], 234 snd_hda_get_jack_type(caps),
278 jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3], 235 snd_hda_get_jack_connectivity(caps),
279 get_jack_location(caps)); 236 snd_hda_get_jack_location(caps));
280 snd_iprintf(buffer, " Conn = %s, Color = %s\n", 237 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
281 get_jack_connection(caps), 238 get_jack_connection(caps),
282 get_jack_color(caps)); 239 get_jack_color(caps));
@@ -457,17 +414,6 @@ static void print_conn_list(struct snd_info_buffer *buffer,
457 } 414 }
458} 415}
459 416
460static void print_realtek_coef(struct snd_info_buffer *buffer,
461 struct hda_codec *codec, hda_nid_t nid)
462{
463 int coeff = snd_hda_codec_read(codec, nid, 0,
464 AC_VERB_GET_PROC_COEF, 0);
465 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
466 coeff = snd_hda_codec_read(codec, nid, 0,
467 AC_VERB_GET_COEF_INDEX, 0);
468 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
469}
470
471static void print_gpio(struct snd_info_buffer *buffer, 417static void print_gpio(struct snd_info_buffer *buffer,
472 struct hda_codec *codec, hda_nid_t nid) 418 struct hda_codec *codec, hda_nid_t nid)
473{ 419{
@@ -500,12 +446,13 @@ static void print_gpio(struct snd_info_buffer *buffer,
500 for (i = 0; i < max; ++i) 446 for (i = 0; i < max; ++i)
501 snd_iprintf(buffer, 447 snd_iprintf(buffer,
502 " IO[%d]: enable=%d, dir=%d, wake=%d, " 448 " IO[%d]: enable=%d, dir=%d, wake=%d, "
503 "sticky=%d, data=%d\n", i, 449 "sticky=%d, data=%d, unsol=%d\n", i,
504 (enable & (1<<i)) ? 1 : 0, 450 (enable & (1<<i)) ? 1 : 0,
505 (direction & (1<<i)) ? 1 : 0, 451 (direction & (1<<i)) ? 1 : 0,
506 (wake & (1<<i)) ? 1 : 0, 452 (wake & (1<<i)) ? 1 : 0,
507 (sticky & (1<<i)) ? 1 : 0, 453 (sticky & (1<<i)) ? 1 : 0,
508 (data & (1<<i)) ? 1 : 0); 454 (data & (1<<i)) ? 1 : 0,
455 (unsol & (1<<i)) ? 1 : 0);
509 /* FIXME: add GPO and GPI pin information */ 456 /* FIXME: add GPO and GPI pin information */
510} 457}
511 458
@@ -513,12 +460,11 @@ static void print_codec_info(struct snd_info_entry *entry,
513 struct snd_info_buffer *buffer) 460 struct snd_info_buffer *buffer)
514{ 461{
515 struct hda_codec *codec = entry->private_data; 462 struct hda_codec *codec = entry->private_data;
516 char buf[32];
517 hda_nid_t nid; 463 hda_nid_t nid;
518 int i, nodes; 464 int i, nodes;
519 465
520 snd_hda_get_codec_name(codec, buf, sizeof(buf)); 466 snd_iprintf(buffer, "Codec: %s\n",
521 snd_iprintf(buffer, "Codec: %s\n", buf); 467 codec->name ? codec->name : "Not Set");
522 snd_iprintf(buffer, "Address: %d\n", codec->addr); 468 snd_iprintf(buffer, "Address: %d\n", codec->addr);
523 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); 469 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
524 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); 470 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
@@ -547,6 +493,8 @@ static void print_codec_info(struct snd_info_entry *entry,
547 } 493 }
548 494
549 print_gpio(buffer, codec, codec->afg); 495 print_gpio(buffer, codec, codec->afg);
496 if (codec->proc_widget_hook)
497 codec->proc_widget_hook(buffer, codec, codec->afg);
550 498
551 for (i = 0; i < nodes; i++, nid++) { 499 for (i = 0; i < nodes; i++, nid++) {
552 unsigned int wid_caps = 500 unsigned int wid_caps =
@@ -649,9 +597,8 @@ static void print_codec_info(struct snd_info_entry *entry,
649 if (wid_caps & AC_WCAP_PROC_WID) 597 if (wid_caps & AC_WCAP_PROC_WID)
650 print_proc_caps(buffer, codec, nid); 598 print_proc_caps(buffer, codec, nid);
651 599
652 /* NID 0x20 == Realtek Define Registers */ 600 if (codec->proc_widget_hook)
653 if (codec->vendor_id == 0x10ec && nid == 0x20) 601 codec->proc_widget_hook(buffer, codec, nid);
654 print_realtek_coef(buffer, codec, nid);
655 } 602 }
656 snd_hda_power_down(codec); 603 snd_hda_power_down(codec);
657} 604}
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 686c77491dea..26247cfe749d 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -27,7 +27,6 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
31 30
32struct ad198x_spec { 31struct ad198x_spec {
33 struct snd_kcontrol_new *mixers[5]; 32 struct snd_kcontrol_new *mixers[5];
@@ -67,8 +66,7 @@ struct ad198x_spec {
67 66
68 /* dynamic controls, init_verbs and input_mux */ 67 /* dynamic controls, init_verbs and input_mux */
69 struct auto_pin_cfg autocfg; 68 struct auto_pin_cfg autocfg;
70 unsigned int num_kctl_alloc, num_kctl_used; 69 struct snd_array kctls;
71 struct snd_kcontrol_new *kctl_alloc;
72 struct hda_input_mux private_imux; 70 struct hda_input_mux private_imux;
73 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 71 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
74 72
@@ -154,6 +152,8 @@ static const char *ad_slave_sws[] = {
154 NULL 152 NULL
155}; 153};
156 154
155static void ad198x_free_kctls(struct hda_codec *codec);
156
157static int ad198x_build_controls(struct hda_codec *codec) 157static int ad198x_build_controls(struct hda_codec *codec)
158{ 158{
159 struct ad198x_spec *spec = codec->spec; 159 struct ad198x_spec *spec = codec->spec;
@@ -202,6 +202,7 @@ static int ad198x_build_controls(struct hda_codec *codec)
202 return err; 202 return err;
203 } 203 }
204 204
205 ad198x_free_kctls(codec); /* no longer needed */
205 return 0; 206 return 0;
206} 207}
207 208
@@ -375,16 +376,27 @@ static int ad198x_build_pcms(struct hda_codec *codec)
375 return 0; 376 return 0;
376} 377}
377 378
378static void ad198x_free(struct hda_codec *codec) 379static void ad198x_free_kctls(struct hda_codec *codec)
379{ 380{
380 struct ad198x_spec *spec = codec->spec; 381 struct ad198x_spec *spec = codec->spec;
381 unsigned int i;
382 382
383 if (spec->kctl_alloc) { 383 if (spec->kctls.list) {
384 for (i = 0; i < spec->num_kctl_used; i++) 384 struct snd_kcontrol_new *kctl = spec->kctls.list;
385 kfree(spec->kctl_alloc[i].name); 385 int i;
386 kfree(spec->kctl_alloc); 386 for (i = 0; i < spec->kctls.used; i++)
387 kfree(kctl[i].name);
387 } 388 }
389 snd_array_free(&spec->kctls);
390}
391
392static void ad198x_free(struct hda_codec *codec)
393{
394 struct ad198x_spec *spec = codec->spec;
395
396 if (!spec)
397 return;
398
399 ad198x_free_kctls(codec);
388 kfree(codec->spec); 400 kfree(codec->spec);
389} 401}
390 402
@@ -629,6 +641,36 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
629 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), 641 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
630 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), 642 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
631 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), 643 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
644 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
645 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
647 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
648 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
649 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
650 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
651 {
652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
653 .name = "Capture Source",
654 .info = ad198x_mux_enum_info,
655 .get = ad198x_mux_enum_get,
656 .put = ad198x_mux_enum_put,
657 },
658 {
659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
660 .name = "External Amplifier",
661 .info = ad198x_eapd_info,
662 .get = ad198x_eapd_get,
663 .put = ad198x_eapd_put,
664 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
665 },
666 { } /* end */
667};
668
669static struct snd_kcontrol_new ad1986a_samsung_mixers[] = {
670 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
671 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
672 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
673 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
633 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 675 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
634 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 676 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
@@ -917,6 +959,7 @@ enum {
917 AD1986A_LAPTOP_EAPD, 959 AD1986A_LAPTOP_EAPD,
918 AD1986A_LAPTOP_AUTOMUTE, 960 AD1986A_LAPTOP_AUTOMUTE,
919 AD1986A_ULTRA, 961 AD1986A_ULTRA,
962 AD1986A_SAMSUNG,
920 AD1986A_MODELS 963 AD1986A_MODELS
921}; 964};
922 965
@@ -927,6 +970,7 @@ static const char *ad1986a_models[AD1986A_MODELS] = {
927 [AD1986A_LAPTOP_EAPD] = "laptop-eapd", 970 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
928 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute", 971 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
929 [AD1986A_ULTRA] = "ultra", 972 [AD1986A_ULTRA] = "ultra",
973 [AD1986A_SAMSUNG] = "samsung",
930}; 974};
931 975
932static struct snd_pci_quirk ad1986a_cfg_tbl[] = { 976static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
@@ -949,9 +993,9 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
949 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), 993 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
950 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), 994 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
951 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), 995 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
952 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD), 996 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_SAMSUNG),
953 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD), 997 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_SAMSUNG),
954 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD), 998 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_SAMSUNG),
955 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), 999 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
956 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), 1000 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
957 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), 1001 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
@@ -1033,6 +1077,17 @@ static int patch_ad1986a(struct hda_codec *codec)
1033 break; 1077 break;
1034 case AD1986A_LAPTOP_EAPD: 1078 case AD1986A_LAPTOP_EAPD:
1035 spec->mixers[0] = ad1986a_laptop_eapd_mixers; 1079 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
1080 spec->num_init_verbs = 2;
1081 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1082 spec->multiout.max_channels = 2;
1083 spec->multiout.num_dacs = 1;
1084 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1085 if (!is_jack_available(codec, 0x25))
1086 spec->multiout.dig_out_nid = 0;
1087 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1088 break;
1089 case AD1986A_SAMSUNG:
1090 spec->mixers[0] = ad1986a_samsung_mixers;
1036 spec->num_init_verbs = 3; 1091 spec->num_init_verbs = 3;
1037 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 1092 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1038 spec->init_verbs[2] = ad1986a_automic_verbs; 1093 spec->init_verbs[2] = ad1986a_automic_verbs;
@@ -2452,9 +2507,6 @@ static struct hda_amp_list ad1988_loopbacks[] = {
2452 * Automatic parse of I/O pins from the BIOS configuration 2507 * Automatic parse of I/O pins from the BIOS configuration
2453 */ 2508 */
2454 2509
2455#define NUM_CONTROL_ALLOC 32
2456#define NUM_VERB_ALLOC 32
2457
2458enum { 2510enum {
2459 AD_CTL_WIDGET_VOL, 2511 AD_CTL_WIDGET_VOL,
2460 AD_CTL_WIDGET_MUTE, 2512 AD_CTL_WIDGET_MUTE,
@@ -2472,27 +2524,15 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name,
2472{ 2524{
2473 struct snd_kcontrol_new *knew; 2525 struct snd_kcontrol_new *knew;
2474 2526
2475 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2527 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2476 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2528 knew = snd_array_new(&spec->kctls);
2477 2529 if (!knew)
2478 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2530 return -ENOMEM;
2479 if (! knew)
2480 return -ENOMEM;
2481 if (spec->kctl_alloc) {
2482 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2483 kfree(spec->kctl_alloc);
2484 }
2485 spec->kctl_alloc = knew;
2486 spec->num_kctl_alloc = num;
2487 }
2488
2489 knew = &spec->kctl_alloc[spec->num_kctl_used];
2490 *knew = ad1988_control_templates[type]; 2531 *knew = ad1988_control_templates[type];
2491 knew->name = kstrdup(name, GFP_KERNEL); 2532 knew->name = kstrdup(name, GFP_KERNEL);
2492 if (! knew->name) 2533 if (! knew->name)
2493 return -ENOMEM; 2534 return -ENOMEM;
2494 knew->private_value = val; 2535 knew->private_value = val;
2495 spec->num_kctl_used++;
2496 return 0; 2536 return 0;
2497} 2537}
2498 2538
@@ -2846,8 +2886,8 @@ static int ad1988_parse_auto_config(struct hda_codec *codec)
2846 if (spec->autocfg.dig_in_pin) 2886 if (spec->autocfg.dig_in_pin)
2847 spec->dig_in_nid = AD1988_SPDIF_IN; 2887 spec->dig_in_nid = AD1988_SPDIF_IN;
2848 2888
2849 if (spec->kctl_alloc) 2889 if (spec->kctls.list)
2850 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 2890 spec->mixers[spec->num_mixers++] = spec->kctls.list;
2851 2891
2852 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; 2892 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2853 2893
@@ -3861,6 +3901,7 @@ static const char *ad1884a_models[AD1884A_MODELS] = {
3861static struct snd_pci_quirk ad1884a_cfg_tbl[] = { 3901static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3862 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), 3902 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
3863 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), 3903 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
3904 SND_PCI_QUIRK(0x103c, 0x30e6, "HP 6730b", AD1884A_LAPTOP),
3864 SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP), 3905 SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP),
3865 SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP), 3906 SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP),
3866 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), 3907 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
@@ -4267,7 +4308,7 @@ static int patch_ad1882(struct hda_codec *codec)
4267/* 4308/*
4268 * patch entries 4309 * patch entries
4269 */ 4310 */
4270struct hda_codec_preset snd_hda_preset_analog[] = { 4311static struct hda_codec_preset snd_hda_preset_analog[] = {
4271 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a }, 4312 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
4272 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, 4313 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
4273 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a }, 4314 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
@@ -4285,3 +4326,26 @@ struct hda_codec_preset snd_hda_preset_analog[] = {
4285 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 }, 4326 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
4286 {} /* terminator */ 4327 {} /* terminator */
4287}; 4328};
4329
4330MODULE_ALIAS("snd-hda-codec-id:11d4*");
4331
4332MODULE_LICENSE("GPL");
4333MODULE_DESCRIPTION("Analog Devices HD-audio codec");
4334
4335static struct hda_codec_preset_list analog_list = {
4336 .preset = snd_hda_preset_analog,
4337 .owner = THIS_MODULE,
4338};
4339
4340static int __init patch_analog_init(void)
4341{
4342 return snd_hda_add_codec_preset(&analog_list);
4343}
4344
4345static void __exit patch_analog_exit(void)
4346{
4347 snd_hda_delete_codec_preset(&analog_list);
4348}
4349
4350module_init(patch_analog_init)
4351module_exit(patch_analog_exit)
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index ba61575983fd..233e4778bba9 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -27,7 +27,6 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
31 30
32struct atihdmi_spec { 31struct atihdmi_spec {
33 struct hda_multi_out multiout; 32 struct hda_multi_out multiout;
@@ -187,13 +186,40 @@ static int patch_atihdmi(struct hda_codec *codec)
187/* 186/*
188 * patch entries 187 * patch entries
189 */ 188 */
190struct hda_codec_preset snd_hda_preset_atihdmi[] = { 189static struct hda_codec_preset snd_hda_preset_atihdmi[] = {
191 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 190 { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi },
192 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 191 { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi },
193 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi }, 192 { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi },
194 { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi }, 193 { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi },
195 { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi }, 194 { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi },
196 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_atihdmi },
197 { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi }, 195 { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi },
198 {} /* terminator */ 196 {} /* terminator */
199}; 197};
198
199MODULE_ALIAS("snd-hda-codec-id:1002793c");
200MODULE_ALIAS("snd-hda-codec-id:10027919");
201MODULE_ALIAS("snd-hda-codec-id:1002791a");
202MODULE_ALIAS("snd-hda-codec-id:1002aa01");
203MODULE_ALIAS("snd-hda-codec-id:10951390");
204MODULE_ALIAS("snd-hda-codec-id:17e80047");
205
206MODULE_LICENSE("GPL");
207MODULE_DESCRIPTION("ATI HDMI HD-audio codec");
208
209static struct hda_codec_preset_list atihdmi_list = {
210 .preset = snd_hda_preset_atihdmi,
211 .owner = THIS_MODULE,
212};
213
214static int __init patch_atihdmi_init(void)
215{
216 return snd_hda_add_codec_preset(&atihdmi_list);
217}
218
219static void __exit patch_atihdmi_exit(void)
220{
221 snd_hda_delete_codec_preset(&atihdmi_list);
222}
223
224module_init(patch_atihdmi_init)
225module_exit(patch_atihdmi_exit)
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 6ef57fbfb6eb..f3ebe837f2d5 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -28,7 +28,6 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_patch.h"
32#define NUM_PINS 11 31#define NUM_PINS 11
33 32
34 33
@@ -736,8 +735,32 @@ static int patch_cmi9880(struct hda_codec *codec)
736/* 735/*
737 * patch entries 736 * patch entries
738 */ 737 */
739struct hda_codec_preset snd_hda_preset_cmedia[] = { 738static struct hda_codec_preset snd_hda_preset_cmedia[] = {
740 { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 }, 739 { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 },
741 { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 }, 740 { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 },
742 {} /* terminator */ 741 {} /* terminator */
743}; 742};
743
744MODULE_ALIAS("snd-hda-codec-id:13f69880");
745MODULE_ALIAS("snd-hda-codec-id:434d4980");
746
747MODULE_LICENSE("GPL");
748MODULE_DESCRIPTION("C-Media HD-audio codec");
749
750static struct hda_codec_preset_list cmedia_list = {
751 .preset = snd_hda_preset_cmedia,
752 .owner = THIS_MODULE,
753};
754
755static int __init patch_cmedia_init(void)
756{
757 return snd_hda_add_codec_preset(&cmedia_list);
758}
759
760static void __exit patch_cmedia_exit(void)
761{
762 snd_hda_delete_codec_preset(&cmedia_list);
763}
764
765module_init(patch_cmedia_init)
766module_exit(patch_cmedia_exit)
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 7c1eb23f0cec..b20e1cede00b 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -27,7 +27,6 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
31 30
32#define CXT_PIN_DIR_IN 0x00 31#define CXT_PIN_DIR_IN 0x00
33#define CXT_PIN_DIR_OUT 0x01 32#define CXT_PIN_DIR_OUT 0x01
@@ -86,8 +85,6 @@ struct conexant_spec {
86 85
87 /* dynamic controls, init_verbs and input_mux */ 86 /* dynamic controls, init_verbs and input_mux */
88 struct auto_pin_cfg autocfg; 87 struct auto_pin_cfg autocfg;
89 unsigned int num_kctl_alloc, num_kctl_used;
90 struct snd_kcontrol_new *kctl_alloc;
91 struct hda_input_mux private_imux; 88 struct hda_input_mux private_imux;
92 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 89 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
93 90
@@ -344,15 +341,6 @@ static int conexant_init(struct hda_codec *codec)
344 341
345static void conexant_free(struct hda_codec *codec) 342static void conexant_free(struct hda_codec *codec)
346{ 343{
347 struct conexant_spec *spec = codec->spec;
348 unsigned int i;
349
350 if (spec->kctl_alloc) {
351 for (i = 0; i < spec->num_kctl_used; i++)
352 kfree(spec->kctl_alloc[i].name);
353 kfree(spec->kctl_alloc);
354 }
355
356 kfree(codec->spec); 344 kfree(codec->spec);
357} 345}
358 346
@@ -1782,7 +1770,7 @@ static int patch_cxt5051(struct hda_codec *codec)
1782/* 1770/*
1783 */ 1771 */
1784 1772
1785struct hda_codec_preset snd_hda_preset_conexant[] = { 1773static struct hda_codec_preset snd_hda_preset_conexant[] = {
1786 { .id = 0x14f15045, .name = "CX20549 (Venice)", 1774 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1787 .patch = patch_cxt5045 }, 1775 .patch = patch_cxt5045 },
1788 { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 1776 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
@@ -1791,3 +1779,28 @@ struct hda_codec_preset snd_hda_preset_conexant[] = {
1791 .patch = patch_cxt5051 }, 1779 .patch = patch_cxt5051 },
1792 {} /* terminator */ 1780 {} /* terminator */
1793}; 1781};
1782
1783MODULE_ALIAS("snd-hda-codec-id:14f15045");
1784MODULE_ALIAS("snd-hda-codec-id:14f15047");
1785MODULE_ALIAS("snd-hda-codec-id:14f15051");
1786
1787MODULE_LICENSE("GPL");
1788MODULE_DESCRIPTION("Conexant HD-audio codec");
1789
1790static struct hda_codec_preset_list conexant_list = {
1791 .preset = snd_hda_preset_conexant,
1792 .owner = THIS_MODULE,
1793};
1794
1795static int __init patch_conexant_init(void)
1796{
1797 return snd_hda_add_codec_preset(&conexant_list);
1798}
1799
1800static void __exit patch_conexant_exit(void)
1801{
1802 snd_hda_delete_codec_preset(&conexant_list);
1803}
1804
1805module_init(patch_conexant_init)
1806module_exit(patch_conexant_exit)
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c
new file mode 100644
index 000000000000..3564f4e4b74c
--- /dev/null
+++ b/sound/pci/hda/patch_intelhdmi.c
@@ -0,0 +1,711 @@
1/*
2 *
3 * patch_intelhdmi.c - Patch for Intel HDMI codecs
4 *
5 * Copyright(c) 2008 Intel Corporation. All rights reserved.
6 *
7 * Authors:
8 * Jiang Zhe <zhe.jiang@intel.com>
9 * Wu Fengguang <wfg@linux.intel.com>
10 *
11 * Maintained by:
12 * Wu Fengguang <wfg@linux.intel.com>
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option)
17 * any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29#include <linux/init.h>
30#include <linux/delay.h>
31#include <linux/slab.h>
32#include <sound/core.h>
33#include "hda_codec.h"
34#include "hda_local.h"
35
36#define CVT_NID 0x02 /* audio converter */
37#define PIN_NID 0x03 /* HDMI output pin */
38
39#define INTEL_HDMI_EVENT_TAG 0x08
40
41struct intel_hdmi_spec {
42 struct hda_multi_out multiout;
43 struct hda_pcm pcm_rec;
44 struct hdmi_eld sink_eld;
45};
46
47static struct hda_verb pinout_enable_verb[] = {
48 {PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
49 {} /* terminator */
50};
51
52static struct hda_verb pinout_disable_verb[] = {
53 {PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00},
54 {}
55};
56
57static struct hda_verb unsolicited_response_verb[] = {
58 {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN |
59 INTEL_HDMI_EVENT_TAG},
60 {}
61};
62
63static struct hda_verb def_chan_map[] = {
64 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x00},
65 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x11},
66 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x22},
67 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x33},
68 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x44},
69 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x55},
70 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x66},
71 {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x77},
72 {}
73};
74
75
76struct hdmi_audio_infoframe {
77 u8 type; /* 0x84 */
78 u8 ver; /* 0x01 */
79 u8 len; /* 0x0a */
80
81 u8 checksum; /* PB0 */
82 u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */
83 u8 SS01_SF24;
84 u8 CXT04;
85 u8 CA;
86 u8 LFEPBL01_LSV36_DM_INH7;
87 u8 reserved[5]; /* PB6 - PB10 */
88};
89
90/*
91 * CEA speaker placement:
92 *
93 * FLH FCH FRH
94 * FLW FL FLC FC FRC FR FRW
95 *
96 * LFE
97 * TC
98 *
99 * RL RLC RC RRC RR
100 *
101 * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to
102 * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC.
103 */
104enum cea_speaker_placement {
105 FL = (1 << 0), /* Front Left */
106 FC = (1 << 1), /* Front Center */
107 FR = (1 << 2), /* Front Right */
108 FLC = (1 << 3), /* Front Left Center */
109 FRC = (1 << 4), /* Front Right Center */
110 RL = (1 << 5), /* Rear Left */
111 RC = (1 << 6), /* Rear Center */
112 RR = (1 << 7), /* Rear Right */
113 RLC = (1 << 8), /* Rear Left Center */
114 RRC = (1 << 9), /* Rear Right Center */
115 LFE = (1 << 10), /* Low Frequency Effect */
116 FLW = (1 << 11), /* Front Left Wide */
117 FRW = (1 << 12), /* Front Right Wide */
118 FLH = (1 << 13), /* Front Left High */
119 FCH = (1 << 14), /* Front Center High */
120 FRH = (1 << 15), /* Front Right High */
121 TC = (1 << 16), /* Top Center */
122};
123
124/*
125 * ELD SA bits in the CEA Speaker Allocation data block
126 */
127static int eld_speaker_allocation_bits[] = {
128 [0] = FL | FR,
129 [1] = LFE,
130 [2] = FC,
131 [3] = RL | RR,
132 [4] = RC,
133 [5] = FLC | FRC,
134 [6] = RLC | RRC,
135 /* the following are not defined in ELD yet */
136 [7] = FLW | FRW,
137 [8] = FLH | FRH,
138 [9] = TC,
139 [10] = FCH,
140};
141
142struct cea_channel_speaker_allocation {
143 int ca_index;
144 int speakers[8];
145
146 /* derived values, just for convenience */
147 int channels;
148 int spk_mask;
149};
150
151/*
152 * This is an ordered list!
153 *
154 * The preceding ones have better chances to be selected by
155 * hdmi_setup_channel_allocation().
156 */
157static struct cea_channel_speaker_allocation channel_allocations[] = {
158/* channel: 8 7 6 5 4 3 2 1 */
159{ .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } },
160 /* 2.1 */
161{ .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } },
162 /* Dolby Surround */
163{ .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } },
164{ .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } },
165{ .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } },
166{ .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } },
167{ .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } },
168{ .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } },
169{ .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } },
170{ .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } },
171{ .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } },
172 /* 5.1 */
173{ .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } },
174{ .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } },
175{ .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } },
176{ .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } },
177 /* 6.1 */
178{ .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } },
179{ .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } },
180{ .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } },
181{ .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } },
182 /* 7.1 */
183{ .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } },
184{ .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
185{ .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
186{ .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
187{ .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
188{ .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
189{ .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
190{ .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
191{ .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
192{ .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
193{ .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
194{ .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
195{ .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
196{ .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } },
197{ .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } },
198{ .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } },
199{ .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } },
200{ .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } },
201{ .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } },
202{ .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } },
203{ .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } },
204{ .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } },
205{ .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } },
206{ .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } },
207{ .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } },
208{ .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } },
209{ .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } },
210{ .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } },
211{ .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } },
212{ .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } },
213{ .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
214};
215
216/*
217 * HDMI routines
218 */
219
220#ifdef BE_PARANOID
221static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t nid,
222 int *packet_index, int *byte_index)
223{
224 int val;
225
226 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_INDEX, 0);
227
228 *packet_index = val >> 5;
229 *byte_index = val & 0x1f;
230}
231#endif
232
233static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t nid,
234 int packet_index, int byte_index)
235{
236 int val;
237
238 val = (packet_index << 5) | (byte_index & 0x1f);
239
240 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val);
241}
242
243static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid,
244 unsigned char val)
245{
246 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val);
247}
248
249static void hdmi_enable_output(struct hda_codec *codec)
250{
251 /* Enable Audio InfoFrame Transmission */
252 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
253 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
254 AC_DIPXMIT_BEST);
255 /* Unmute */
256 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP)
257 snd_hda_codec_write(codec, PIN_NID, 0,
258 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
259 /* Enable pin out */
260 snd_hda_sequence_write(codec, pinout_enable_verb);
261}
262
263static void hdmi_disable_output(struct hda_codec *codec)
264{
265 snd_hda_sequence_write(codec, pinout_disable_verb);
266 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP)
267 snd_hda_codec_write(codec, PIN_NID, 0,
268 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
269
270 /*
271 * FIXME: noises may arise when playing music after reloading the
272 * kernel module, until the next X restart or monitor repower.
273 */
274}
275
276static int hdmi_get_channel_count(struct hda_codec *codec)
277{
278 return 1 + snd_hda_codec_read(codec, CVT_NID, 0,
279 AC_VERB_GET_CVT_CHAN_COUNT, 0);
280}
281
282static void hdmi_set_channel_count(struct hda_codec *codec, int chs)
283{
284 snd_hda_codec_write(codec, CVT_NID, 0,
285 AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
286
287 if (chs != hdmi_get_channel_count(codec))
288 snd_printd(KERN_INFO "HDMI channel count: expect %d, get %d\n",
289 chs, hdmi_get_channel_count(codec));
290}
291
292static void hdmi_debug_channel_mapping(struct hda_codec *codec)
293{
294#ifdef CONFIG_SND_DEBUG_VERBOSE
295 int i;
296 int slot;
297
298 for (i = 0; i < 8; i++) {
299 slot = snd_hda_codec_read(codec, CVT_NID, 0,
300 AC_VERB_GET_HDMI_CHAN_SLOT, i);
301 printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
302 slot >> 4, slot & 0x7);
303 }
304#endif
305}
306
307static void hdmi_parse_eld(struct hda_codec *codec)
308{
309 struct intel_hdmi_spec *spec = codec->spec;
310 struct hdmi_eld *eld = &spec->sink_eld;
311
312 if (!snd_hdmi_get_eld(eld, codec, PIN_NID))
313 snd_hdmi_show_eld(eld);
314}
315
316
317/*
318 * Audio InfoFrame routines
319 */
320
321static void hdmi_debug_dip_size(struct hda_codec *codec)
322{
323#ifdef CONFIG_SND_DEBUG_VERBOSE
324 int i;
325 int size;
326
327 size = snd_hdmi_get_eld_size(codec, PIN_NID);
328 printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size);
329
330 for (i = 0; i < 8; i++) {
331 size = snd_hda_codec_read(codec, PIN_NID, 0,
332 AC_VERB_GET_HDMI_DIP_SIZE, i);
333 printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size);
334 }
335#endif
336}
337
338static void hdmi_clear_dip_buffers(struct hda_codec *codec)
339{
340#ifdef BE_PARANOID
341 int i, j;
342 int size;
343 int pi, bi;
344 for (i = 0; i < 8; i++) {
345 size = snd_hda_codec_read(codec, PIN_NID, 0,
346 AC_VERB_GET_HDMI_DIP_SIZE, i);
347 if (size == 0)
348 continue;
349
350 hdmi_set_dip_index(codec, PIN_NID, i, 0x0);
351 for (j = 1; j < 1000; j++) {
352 hdmi_write_dip_byte(codec, PIN_NID, 0x0);
353 hdmi_get_dip_index(codec, PIN_NID, &pi, &bi);
354 if (pi != i)
355 snd_printd(KERN_INFO "dip index %d: %d != %d\n",
356 bi, pi, i);
357 if (bi == 0) /* byte index wrapped around */
358 break;
359 }
360 snd_printd(KERN_INFO
361 "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
362 i, size, j);
363 }
364#endif
365}
366
367static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
368 struct hdmi_audio_infoframe *ai)
369{
370 u8 *params = (u8 *)ai;
371 int i;
372
373 hdmi_debug_dip_size(codec);
374 hdmi_clear_dip_buffers(codec); /* be paranoid */
375
376 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
377 for (i = 0; i < sizeof(ai); i++)
378 hdmi_write_dip_byte(codec, PIN_NID, params[i]);
379}
380
381/*
382 * Compute derived values in channel_allocations[].
383 */
384static void init_channel_allocations(void)
385{
386 int i, j;
387 struct cea_channel_speaker_allocation *p;
388
389 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
390 p = channel_allocations + i;
391 p->channels = 0;
392 p->spk_mask = 0;
393 for (j = 0; j < ARRAY_SIZE(p->speakers); j++)
394 if (p->speakers[j]) {
395 p->channels++;
396 p->spk_mask |= p->speakers[j];
397 }
398 }
399}
400
401/*
402 * The transformation takes two steps:
403 *
404 * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
405 * spk_mask => (channel_allocations[]) => ai->CA
406 *
407 * TODO: it could select the wrong CA from multiple candidates.
408*/
409static int hdmi_setup_channel_allocation(struct hda_codec *codec,
410 struct hdmi_audio_infoframe *ai)
411{
412 struct intel_hdmi_spec *spec = codec->spec;
413 struct hdmi_eld *eld = &spec->sink_eld;
414 int i;
415 int spk_mask = 0;
416 int channels = 1 + (ai->CC02_CT47 & 0x7);
417 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
418
419 /*
420 * CA defaults to 0 for basic stereo audio
421 */
422 if (!eld->eld_ver)
423 return 0;
424 if (!eld->spk_alloc)
425 return 0;
426 if (channels <= 2)
427 return 0;
428
429 /*
430 * expand ELD's speaker allocation mask
431 *
432 * ELD tells the speaker mask in a compact(paired) form,
433 * expand ELD's notions to match the ones used by Audio InfoFrame.
434 */
435 for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
436 if (eld->spk_alloc & (1 << i))
437 spk_mask |= eld_speaker_allocation_bits[i];
438 }
439
440 /* search for the first working match in the CA table */
441 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
442 if (channels == channel_allocations[i].channels &&
443 (spk_mask & channel_allocations[i].spk_mask) ==
444 channel_allocations[i].spk_mask) {
445 ai->CA = channel_allocations[i].ca_index;
446 break;
447 }
448 }
449
450 snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf));
451 snd_printdd(KERN_INFO
452 "HDMI: select CA 0x%x for %d-channel allocation: %s\n",
453 ai->CA, channels, buf);
454
455 return ai->CA;
456}
457
458static void hdmi_setup_channel_mapping(struct hda_codec *codec,
459 struct hdmi_audio_infoframe *ai)
460{
461 if (!ai->CA)
462 return;
463
464 /*
465 * TODO: adjust channel mapping if necessary
466 * ALSA sequence is front/surr/clfe/side?
467 */
468
469 snd_hda_sequence_write(codec, def_chan_map);
470 hdmi_debug_channel_mapping(codec);
471}
472
473
474static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
475 struct snd_pcm_substream *substream)
476{
477 struct hdmi_audio_infoframe ai = {
478 .type = 0x84,
479 .ver = 0x01,
480 .len = 0x0a,
481 .CC02_CT47 = substream->runtime->channels - 1,
482 };
483
484 hdmi_setup_channel_allocation(codec, &ai);
485 hdmi_setup_channel_mapping(codec, &ai);
486
487 hdmi_fill_audio_infoframe(codec, &ai);
488}
489
490
491/*
492 * Unsolicited events
493 */
494
495static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
496{
497 int pind = !!(res & AC_UNSOL_RES_PD);
498 int eldv = !!(res & AC_UNSOL_RES_ELDV);
499
500 printk(KERN_INFO
501 "HDMI hot plug event: Presence_Detect=%d ELD_Valid=%d\n",
502 pind, eldv);
503
504 if (pind && eldv) {
505 hdmi_parse_eld(codec);
506 /* TODO: do real things about ELD */
507 }
508}
509
510static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
511{
512 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
513 int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
514 int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
515
516 printk(KERN_INFO
517 "HDMI content protection event: SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
518 subtag,
519 cp_state,
520 cp_ready);
521
522 /* TODO */
523 if (cp_state)
524 ;
525 if (cp_ready)
526 ;
527}
528
529
530static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
531{
532 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
533 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
534
535 if (tag != INTEL_HDMI_EVENT_TAG) {
536 snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
537 return;
538 }
539
540 if (subtag == 0)
541 hdmi_intrinsic_event(codec, res);
542 else
543 hdmi_non_intrinsic_event(codec, res);
544}
545
546/*
547 * Callbacks
548 */
549
550static int intel_hdmi_playback_pcm_open(struct hda_pcm_stream *hinfo,
551 struct hda_codec *codec,
552 struct snd_pcm_substream *substream)
553{
554 struct intel_hdmi_spec *spec = codec->spec;
555
556 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
557}
558
559static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo,
560 struct hda_codec *codec,
561 struct snd_pcm_substream *substream)
562{
563 struct intel_hdmi_spec *spec = codec->spec;
564
565 hdmi_disable_output(codec);
566
567 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
568}
569
570static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
571 struct hda_codec *codec,
572 unsigned int stream_tag,
573 unsigned int format,
574 struct snd_pcm_substream *substream)
575{
576 struct intel_hdmi_spec *spec = codec->spec;
577
578 snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
579 format, substream);
580
581 hdmi_set_channel_count(codec, substream->runtime->channels);
582
583 hdmi_setup_audio_infoframe(codec, substream);
584
585 hdmi_enable_output(codec);
586
587 return 0;
588}
589
590static struct hda_pcm_stream intel_hdmi_pcm_playback = {
591 .substreams = 1,
592 .channels_min = 2,
593 .channels_max = 8,
594 .nid = CVT_NID, /* NID to query formats and rates and setup streams */
595 .ops = {
596 .open = intel_hdmi_playback_pcm_open,
597 .close = intel_hdmi_playback_pcm_close,
598 .prepare = intel_hdmi_playback_pcm_prepare
599 },
600};
601
602static int intel_hdmi_build_pcms(struct hda_codec *codec)
603{
604 struct intel_hdmi_spec *spec = codec->spec;
605 struct hda_pcm *info = &spec->pcm_rec;
606
607 codec->num_pcms = 1;
608 codec->pcm_info = info;
609
610 info->name = "INTEL HDMI";
611 info->pcm_type = HDA_PCM_TYPE_HDMI;
612 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = intel_hdmi_pcm_playback;
613
614 return 0;
615}
616
617static int intel_hdmi_build_controls(struct hda_codec *codec)
618{
619 struct intel_hdmi_spec *spec = codec->spec;
620 int err;
621
622 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
623 if (err < 0)
624 return err;
625
626 return 0;
627}
628
629static int intel_hdmi_init(struct hda_codec *codec)
630{
631 /* disable audio output as early as possible */
632 hdmi_disable_output(codec);
633
634 snd_hda_sequence_write(codec, unsolicited_response_verb);
635
636 return 0;
637}
638
639static void intel_hdmi_free(struct hda_codec *codec)
640{
641 struct intel_hdmi_spec *spec = codec->spec;
642
643 snd_hda_eld_proc_free(codec, &spec->sink_eld);
644 kfree(spec);
645}
646
647static struct hda_codec_ops intel_hdmi_patch_ops = {
648 .init = intel_hdmi_init,
649 .free = intel_hdmi_free,
650 .build_pcms = intel_hdmi_build_pcms,
651 .build_controls = intel_hdmi_build_controls,
652 .unsol_event = intel_hdmi_unsol_event,
653};
654
655static int patch_intel_hdmi(struct hda_codec *codec)
656{
657 struct intel_hdmi_spec *spec;
658
659 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
660 if (spec == NULL)
661 return -ENOMEM;
662
663 spec->multiout.num_dacs = 0; /* no analog */
664 spec->multiout.max_channels = 8;
665 spec->multiout.dig_out_nid = CVT_NID;
666
667 codec->spec = spec;
668 codec->patch_ops = intel_hdmi_patch_ops;
669
670 snd_hda_eld_proc_new(codec, &spec->sink_eld);
671
672 init_channel_allocations();
673
674 return 0;
675}
676
677static struct hda_codec_preset snd_hda_preset_intelhdmi[] = {
678 { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi },
679 { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi },
680 { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi },
681 { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi },
682 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi },
683 {} /* terminator */
684};
685
686MODULE_ALIAS("snd-hda-codec-id:808629fb");
687MODULE_ALIAS("snd-hda-codec-id:80862801");
688MODULE_ALIAS("snd-hda-codec-id:80862802");
689MODULE_ALIAS("snd-hda-codec-id:80862803");
690MODULE_ALIAS("snd-hda-codec-id:10951392");
691
692MODULE_LICENSE("GPL");
693MODULE_DESCRIPTION("Intel HDMI HD-audio codec");
694
695static struct hda_codec_preset_list intel_list = {
696 .preset = snd_hda_preset_intelhdmi,
697 .owner = THIS_MODULE,
698};
699
700static int __init patch_intelhdmi_init(void)
701{
702 return snd_hda_add_codec_preset(&intel_list);
703}
704
705static void __exit patch_intelhdmi_exit(void)
706{
707 snd_hda_delete_codec_preset(&intel_list);
708}
709
710module_init(patch_intelhdmi_init)
711module_exit(patch_intelhdmi_exit)
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
index 2eed2c8b98da..0270fda0bda5 100644
--- a/sound/pci/hda/patch_nvhdmi.c
+++ b/sound/pci/hda/patch_nvhdmi.c
@@ -158,8 +158,34 @@ static int patch_nvhdmi(struct hda_codec *codec)
158/* 158/*
159 * patch entries 159 * patch entries
160 */ 160 */
161struct hda_codec_preset snd_hda_preset_nvhdmi[] = { 161static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
162 { .id = 0x10de0002, .name = "NVIDIA MCP78 HDMI", .patch = patch_nvhdmi }, 162 { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi },
163 { .id = 0x10de0007, .name = "NVIDIA MCP7A HDMI", .patch = patch_nvhdmi }, 163 { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi },
164 { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi },
164 {} /* terminator */ 165 {} /* terminator */
165}; 166};
167
168MODULE_ALIAS("snd-hda-codec-id:10de0002");
169MODULE_ALIAS("snd-hda-codec-id:10de0007");
170MODULE_ALIAS("snd-hda-codec-id:10de0067");
171
172MODULE_LICENSE("GPL");
173MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec");
174
175static struct hda_codec_preset_list nvhdmi_list = {
176 .preset = snd_hda_preset_nvhdmi,
177 .owner = THIS_MODULE,
178};
179
180static int __init patch_nvhdmi_init(void)
181{
182 return snd_hda_add_codec_preset(&nvhdmi_list);
183}
184
185static void __exit patch_nvhdmi_exit(void)
186{
187 snd_hda_delete_codec_preset(&nvhdmi_list);
188}
189
190module_init(patch_nvhdmi_init)
191module_exit(patch_nvhdmi_exit)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a378c0145125..0bd4e6bf354d 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -30,7 +30,6 @@
30#include <sound/core.h> 30#include <sound/core.h>
31#include "hda_codec.h" 31#include "hda_codec.h"
32#include "hda_local.h" 32#include "hda_local.h"
33#include "hda_patch.h"
34 33
35#define ALC880_FRONT_EVENT 0x01 34#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02 35#define ALC880_DCVOL_EVENT 0x02
@@ -114,6 +113,7 @@ enum {
114 ALC268_3ST, 113 ALC268_3ST,
115 ALC268_TOSHIBA, 114 ALC268_TOSHIBA,
116 ALC268_ACER, 115 ALC268_ACER,
116 ALC268_ACER_DMIC,
117 ALC268_ACER_ASPIRE_ONE, 117 ALC268_ACER_ASPIRE_ONE,
118 ALC268_DELL, 118 ALC268_DELL,
119 ALC268_ZEPTO, 119 ALC268_ZEPTO,
@@ -130,6 +130,8 @@ enum {
130 ALC269_QUANTA_FL1, 130 ALC269_QUANTA_FL1,
131 ALC269_ASUS_EEEPC_P703, 131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901, 132 ALC269_ASUS_EEEPC_P901,
133 ALC269_FUJITSU,
134 ALC269_LIFEBOOK,
133 ALC269_AUTO, 135 ALC269_AUTO,
134 ALC269_MODEL_LAST /* last tag */ 136 ALC269_MODEL_LAST /* last tag */
135}; 137};
@@ -152,6 +154,7 @@ enum {
152enum { 154enum {
153 ALC660VD_3ST, 155 ALC660VD_3ST,
154 ALC660VD_3ST_DIG, 156 ALC660VD_3ST_DIG,
157 ALC660VD_ASUS_V1S,
155 ALC861VD_3ST, 158 ALC861VD_3ST,
156 ALC861VD_3ST_DIG, 159 ALC861VD_3ST_DIG,
157 ALC861VD_6ST_DIG, 160 ALC861VD_6ST_DIG,
@@ -212,6 +215,7 @@ enum {
212 ALC883_TARGA_2ch_DIG, 215 ALC883_TARGA_2ch_DIG,
213 ALC883_ACER, 216 ALC883_ACER,
214 ALC883_ACER_ASPIRE, 217 ALC883_ACER_ASPIRE,
218 ALC888_ACER_ASPIRE_4930G,
215 ALC883_MEDION, 219 ALC883_MEDION,
216 ALC883_MEDION_MD2, 220 ALC883_MEDION_MD2,
217 ALC883_LAPTOP_EAPD, 221 ALC883_LAPTOP_EAPD,
@@ -225,9 +229,11 @@ enum {
225 ALC883_MITAC, 229 ALC883_MITAC,
226 ALC883_CLEVO_M720, 230 ALC883_CLEVO_M720,
227 ALC883_FUJITSU_PI2515, 231 ALC883_FUJITSU_PI2515,
232 ALC888_FUJITSU_XA3530,
228 ALC883_3ST_6ch_INTEL, 233 ALC883_3ST_6ch_INTEL,
229 ALC888_ASUS_M90V, 234 ALC888_ASUS_M90V,
230 ALC888_ASUS_EEE1601, 235 ALC888_ASUS_EEE1601,
236 ALC1200_ASUS_P5Q,
231 ALC883_AUTO, 237 ALC883_AUTO,
232 ALC883_MODEL_LAST, 238 ALC883_MODEL_LAST,
233}; 239};
@@ -239,6 +245,7 @@ struct alc_spec {
239 /* codec parameterization */ 245 /* codec parameterization */
240 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
241 unsigned int num_mixers; 247 unsigned int num_mixers;
248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
242 249
243 const struct hda_verb *init_verbs[5]; /* initialization verbs 250 const struct hda_verb *init_verbs[5]; /* initialization verbs
244 * don't forget NULL 251 * don't forget NULL
@@ -268,6 +275,7 @@ struct alc_spec {
268 hda_nid_t *adc_nids; 275 hda_nid_t *adc_nids;
269 hda_nid_t *capsrc_nids; 276 hda_nid_t *capsrc_nids;
270 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 277 hda_nid_t dig_in_nid; /* digital-in NID; optional */
278 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
271 279
272 /* capture source */ 280 /* capture source */
273 unsigned int num_mux_defs; 281 unsigned int num_mux_defs;
@@ -284,8 +292,7 @@ struct alc_spec {
284 292
285 /* dynamic controls, init_verbs and input_mux */ 293 /* dynamic controls, init_verbs and input_mux */
286 struct auto_pin_cfg autocfg; 294 struct auto_pin_cfg autocfg;
287 unsigned int num_kctl_alloc, num_kctl_used; 295 struct snd_array kctls;
288 struct snd_kcontrol_new *kctl_alloc;
289 struct hda_input_mux private_imux; 296 struct hda_input_mux private_imux;
290 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 297 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
291 298
@@ -323,6 +330,7 @@ struct alc_config_preset {
323 struct snd_kcontrol_new *mixers[5]; /* should be identical size 330 struct snd_kcontrol_new *mixers[5]; /* should be identical size
324 * with spec 331 * with spec
325 */ 332 */
333 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
326 const struct hda_verb *init_verbs[5]; 334 const struct hda_verb *init_verbs[5];
327 unsigned int num_dacs; 335 unsigned int num_dacs;
328 hda_nid_t *dac_nids; 336 hda_nid_t *dac_nids;
@@ -375,14 +383,39 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
375{ 383{
376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
377 struct alc_spec *spec = codec->spec; 385 struct alc_spec *spec = codec->spec;
386 const struct hda_input_mux *imux;
378 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 387 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
379 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 388 unsigned int mux_idx;
380 hda_nid_t nid = spec->capsrc_nids ? 389 hda_nid_t nid = spec->capsrc_nids ?
381 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; 390 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
382 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
383 nid, &spec->cur_mux[adc_idx]);
384}
385 391
392 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
393 imux = &spec->input_mux[mux_idx];
394
395 if (spec->is_mix_capture) {
396 /* Matrix-mixer style (e.g. ALC882) */
397 unsigned int *cur_val = &spec->cur_mux[adc_idx];
398 unsigned int i, idx;
399
400 idx = ucontrol->value.enumerated.item[0];
401 if (idx >= imux->num_items)
402 idx = imux->num_items - 1;
403 if (*cur_val == idx)
404 return 0;
405 for (i = 0; i < imux->num_items; i++) {
406 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
407 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
408 imux->items[i].index,
409 HDA_AMP_MUTE, v);
410 }
411 *cur_val = idx;
412 return 1;
413 } else {
414 /* MUX style (e.g. ALC880) */
415 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
416 &spec->cur_mux[adc_idx]);
417 }
418}
386 419
387/* 420/*
388 * channel mode setting 421 * channel mode setting
@@ -717,6 +750,43 @@ static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
717#endif /* CONFIG_SND_DEBUG */ 750#endif /* CONFIG_SND_DEBUG */
718 751
719/* 752/*
753 */
754static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
755{
756 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
757 return;
758 spec->mixers[spec->num_mixers++] = mix;
759}
760
761static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
762{
763 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
764 return;
765 spec->init_verbs[spec->num_init_verbs++] = verb;
766}
767
768#ifdef CONFIG_PROC_FS
769/*
770 * hook for proc
771 */
772static void print_realtek_coef(struct snd_info_buffer *buffer,
773 struct hda_codec *codec, hda_nid_t nid)
774{
775 int coeff;
776
777 if (nid != 0x20)
778 return;
779 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
780 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
781 coeff = snd_hda_codec_read(codec, nid, 0,
782 AC_VERB_GET_COEF_INDEX, 0);
783 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
784}
785#else
786#define print_realtek_coef NULL
787#endif
788
789/*
720 * set up from the preset table 790 * set up from the preset table
721 */ 791 */
722static void setup_preset(struct alc_spec *spec, 792static void setup_preset(struct alc_spec *spec,
@@ -725,11 +795,11 @@ static void setup_preset(struct alc_spec *spec,
725 int i; 795 int i;
726 796
727 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 797 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
728 spec->mixers[spec->num_mixers++] = preset->mixers[i]; 798 add_mixer(spec, preset->mixers[i]);
799 spec->cap_mixer = preset->cap_mixer;
729 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; 800 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
730 i++) 801 i++)
731 spec->init_verbs[spec->num_init_verbs++] = 802 add_verb(spec, preset->init_verbs[i]);
732 preset->init_verbs[i];
733 803
734 spec->channel_mode = preset->channel_mode; 804 spec->channel_mode = preset->channel_mode;
735 spec->num_channel_mode = preset->num_channel_mode; 805 spec->num_channel_mode = preset->num_channel_mode;
@@ -1107,6 +1177,226 @@ static void alc_fix_pincfg(struct hda_codec *codec,
1107} 1177}
1108 1178
1109/* 1179/*
1180 * ALC888
1181 */
1182
1183/*
1184 * 2ch mode
1185 */
1186static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1187/* Mic-in jack as mic in */
1188 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1189 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1190/* Line-in jack as Line in */
1191 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1192 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1193/* Line-Out as Front */
1194 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1195 { } /* end */
1196};
1197
1198/*
1199 * 4ch mode
1200 */
1201static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1202/* Mic-in jack as mic in */
1203 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1204 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1205/* Line-in jack as Surround */
1206 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1207 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1208/* Line-Out as Front */
1209 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1210 { } /* end */
1211};
1212
1213/*
1214 * 6ch mode
1215 */
1216static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1217/* Mic-in jack as CLFE */
1218 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1219 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1220/* Line-in jack as Surround */
1221 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1222 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1223/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1224 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1225 { } /* end */
1226};
1227
1228/*
1229 * 8ch mode
1230 */
1231static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1232/* Mic-in jack as CLFE */
1233 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1234 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1235/* Line-in jack as Surround */
1236 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1237 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1238/* Line-Out as Side */
1239 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1240 { } /* end */
1241};
1242
1243static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1244 { 2, alc888_4ST_ch2_intel_init },
1245 { 4, alc888_4ST_ch4_intel_init },
1246 { 6, alc888_4ST_ch6_intel_init },
1247 { 8, alc888_4ST_ch8_intel_init },
1248};
1249
1250/*
1251 * ALC888 Fujitsu Siemens Amillo xa3530
1252 */
1253
1254static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1255/* Front Mic: set to PIN_IN (empty by default) */
1256 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1257/* Connect Internal HP to Front */
1258 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1259 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1260 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1261/* Connect Bass HP to Front */
1262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1265/* Connect Line-Out side jack (SPDIF) to Side */
1266 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1267 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1268 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1269/* Connect Mic jack to CLFE */
1270 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1272 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1273/* Connect Line-in jack to Surround */
1274 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1276 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1277/* Connect HP out jack to Front */
1278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1280 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1281/* Enable unsolicited event for HP jack and Line-out jack */
1282 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1283 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1284 {}
1285};
1286
1287static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1288{
1289 unsigned int present;
1290 unsigned int bits;
1291 /* Line out presence */
1292 present = snd_hda_codec_read(codec, 0x17, 0,
1293 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1294 /* HP out presence */
1295 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1296 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1297 bits = present ? HDA_AMP_MUTE : 0;
1298 /* Toggle internal speakers muting */
1299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1300 HDA_AMP_MUTE, bits);
1301 /* Toggle internal bass muting */
1302 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1303 HDA_AMP_MUTE, bits);
1304}
1305
1306static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1307 unsigned int res)
1308{
1309 if (res >> 26 == ALC880_HP_EVENT)
1310 alc888_fujitsu_xa3530_automute(codec);
1311}
1312
1313
1314/*
1315 * ALC888 Acer Aspire 4930G model
1316 */
1317
1318static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1319/* Front Mic: set to PIN_IN (empty by default) */
1320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1321/* Unselect Front Mic by default in input mixer 3 */
1322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1323/* Enable unsolicited event for HP jack */
1324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1325/* Connect Internal HP to front */
1326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1328 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1329/* Connect HP out to front */
1330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1333 { }
1334};
1335
1336static struct hda_input_mux alc888_2_capture_sources[2] = {
1337 /* Front mic only available on one ADC */
1338 {
1339 .num_items = 4,
1340 .items = {
1341 { "Mic", 0x0 },
1342 { "Line", 0x2 },
1343 { "CD", 0x4 },
1344 { "Front Mic", 0xb },
1345 },
1346 },
1347 {
1348 .num_items = 3,
1349 .items = {
1350 { "Mic", 0x0 },
1351 { "Line", 0x2 },
1352 { "CD", 0x4 },
1353 },
1354 }
1355};
1356
1357static struct snd_kcontrol_new alc888_base_mixer[] = {
1358 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1359 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1361 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1363 HDA_OUTPUT),
1364 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1365 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1366 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1367 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1368 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1369 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1370 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1376 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1377 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1378 { } /* end */
1379};
1380
1381static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1382{
1383 unsigned int present;
1384 unsigned int bits;
1385 present = snd_hda_codec_read(codec, 0x15, 0,
1386 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1387 bits = present ? HDA_AMP_MUTE : 0;
1388 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1389 HDA_AMP_MUTE, bits);
1390}
1391
1392static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1393 unsigned int res)
1394{
1395 if (res >> 26 == ALC880_HP_EVENT)
1396 alc888_acer_aspire_4930g_automute(codec);
1397}
1398
1399/*
1110 * ALC880 3-stack model 1400 * ALC880 3-stack model
1111 * 1401 *
1112 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) 1402 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
@@ -1205,49 +1495,126 @@ static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1205}; 1495};
1206 1496
1207/* capture mixer elements */ 1497/* capture mixer elements */
1208static struct snd_kcontrol_new alc880_capture_mixer[] = { 1498static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1209 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 1499 struct snd_ctl_elem_info *uinfo)
1210 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 1500{
1211 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 1501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1212 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 1502 struct alc_spec *spec = codec->spec;
1213 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 1503 int err;
1214 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1215 {
1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1217 /* The multiple "Capture Source" controls confuse alsamixer
1218 * So call somewhat different..
1219 */
1220 /* .name = "Capture Source", */
1221 .name = "Input Source",
1222 .count = 3,
1223 .info = alc_mux_enum_info,
1224 .get = alc_mux_enum_get,
1225 .put = alc_mux_enum_put,
1226 },
1227 { } /* end */
1228};
1229 1504
1230/* capture mixer elements (in case NID 0x07 not available) */ 1505 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1231static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { 1506 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1232 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 1507 HDA_INPUT);
1233 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 1508 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1234 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 1509 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1235 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 1510 return err;
1236 { 1511}
1237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1512
1238 /* The multiple "Capture Source" controls confuse alsamixer 1513static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1239 * So call somewhat different.. 1514 unsigned int size, unsigned int __user *tlv)
1240 */ 1515{
1241 /* .name = "Capture Source", */ 1516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1242 .name = "Input Source", 1517 struct alc_spec *spec = codec->spec;
1243 .count = 2, 1518 int err;
1244 .info = alc_mux_enum_info,
1245 .get = alc_mux_enum_get,
1246 .put = alc_mux_enum_put,
1247 },
1248 { } /* end */
1249};
1250 1519
1520 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1521 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1522 HDA_INPUT);
1523 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1524 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1525 return err;
1526}
1527
1528typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1529 struct snd_ctl_elem_value *ucontrol);
1530
1531static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1532 struct snd_ctl_elem_value *ucontrol,
1533 getput_call_t func)
1534{
1535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1536 struct alc_spec *spec = codec->spec;
1537 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1538 int err;
1539
1540 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1541 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1542 3, 0, HDA_INPUT);
1543 err = func(kcontrol, ucontrol);
1544 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1545 return err;
1546}
1547
1548static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1549 struct snd_ctl_elem_value *ucontrol)
1550{
1551 return alc_cap_getput_caller(kcontrol, ucontrol,
1552 snd_hda_mixer_amp_volume_get);
1553}
1554
1555static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1556 struct snd_ctl_elem_value *ucontrol)
1557{
1558 return alc_cap_getput_caller(kcontrol, ucontrol,
1559 snd_hda_mixer_amp_volume_put);
1560}
1561
1562/* capture mixer elements */
1563#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1564
1565static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1566 struct snd_ctl_elem_value *ucontrol)
1567{
1568 return alc_cap_getput_caller(kcontrol, ucontrol,
1569 snd_hda_mixer_amp_switch_get);
1570}
1571
1572static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1573 struct snd_ctl_elem_value *ucontrol)
1574{
1575 return alc_cap_getput_caller(kcontrol, ucontrol,
1576 snd_hda_mixer_amp_switch_put);
1577}
1578
1579#define DEFINE_CAPMIX(num) \
1580static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1581 { \
1582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1583 .name = "Capture Switch", \
1584 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1585 .count = num, \
1586 .info = alc_cap_sw_info, \
1587 .get = alc_cap_sw_get, \
1588 .put = alc_cap_sw_put, \
1589 }, \
1590 { \
1591 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1592 .name = "Capture Volume", \
1593 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1594 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1595 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1596 .count = num, \
1597 .info = alc_cap_vol_info, \
1598 .get = alc_cap_vol_get, \
1599 .put = alc_cap_vol_put, \
1600 .tlv = { .c = alc_cap_vol_tlv }, \
1601 }, \
1602 { \
1603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1604 /* .name = "Capture Source", */ \
1605 .name = "Input Source", \
1606 .count = num, \
1607 .info = alc_mux_enum_info, \
1608 .get = alc_mux_enum_get, \
1609 .put = alc_mux_enum_put, \
1610 }, \
1611 { } /* end */ \
1612}
1613
1614/* up to three ADCs */
1615DEFINE_CAPMIX(1);
1616DEFINE_CAPMIX(2);
1617DEFINE_CAPMIX(3);
1251 1618
1252 1619
1253/* 1620/*
@@ -1533,18 +1900,6 @@ static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), 1900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1534 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 1901 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1535 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 1902 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1536 {
1537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1538 /* The multiple "Capture Source" controls confuse alsamixer
1539 * So call somewhat different..
1540 */
1541 /* .name = "Capture Source", */
1542 .name = "Input Source",
1543 .count = 1,
1544 .info = alc_mux_enum_info,
1545 .get = alc_mux_enum_get,
1546 .put = alc_mux_enum_put,
1547 },
1548 { } /* end */ 1903 { } /* end */
1549}; 1904};
1550 1905
@@ -1619,6 +1974,7 @@ static const char *alc_slave_vols[] = {
1619 "Speaker Playback Volume", 1974 "Speaker Playback Volume",
1620 "Mono Playback Volume", 1975 "Mono Playback Volume",
1621 "Line-Out Playback Volume", 1976 "Line-Out Playback Volume",
1977 "PCM Playback Volume",
1622 NULL, 1978 NULL,
1623}; 1979};
1624 1980
@@ -1638,6 +1994,9 @@ static const char *alc_slave_sws[] = {
1638/* 1994/*
1639 * build control elements 1995 * build control elements
1640 */ 1996 */
1997
1998static void alc_free_kctls(struct hda_codec *codec);
1999
1641static int alc_build_controls(struct hda_codec *codec) 2000static int alc_build_controls(struct hda_codec *codec)
1642{ 2001{
1643 struct alc_spec *spec = codec->spec; 2002 struct alc_spec *spec = codec->spec;
@@ -1649,7 +2008,11 @@ static int alc_build_controls(struct hda_codec *codec)
1649 if (err < 0) 2008 if (err < 0)
1650 return err; 2009 return err;
1651 } 2010 }
1652 2011 if (spec->cap_mixer) {
2012 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2013 if (err < 0)
2014 return err;
2015 }
1653 if (spec->multiout.dig_out_nid) { 2016 if (spec->multiout.dig_out_nid) {
1654 err = snd_hda_create_spdif_out_ctls(codec, 2017 err = snd_hda_create_spdif_out_ctls(codec,
1655 spec->multiout.dig_out_nid); 2018 spec->multiout.dig_out_nid);
@@ -1684,6 +2047,7 @@ static int alc_build_controls(struct hda_codec *codec)
1684 return err; 2047 return err;
1685 } 2048 }
1686 2049
2050 alc_free_kctls(codec); /* no longer needed */
1687 return 0; 2051 return 0;
1688} 2052}
1689 2053
@@ -2774,19 +3138,27 @@ static int alc_build_pcms(struct hda_codec *codec)
2774 return 0; 3138 return 0;
2775} 3139}
2776 3140
3141static void alc_free_kctls(struct hda_codec *codec)
3142{
3143 struct alc_spec *spec = codec->spec;
3144
3145 if (spec->kctls.list) {
3146 struct snd_kcontrol_new *kctl = spec->kctls.list;
3147 int i;
3148 for (i = 0; i < spec->kctls.used; i++)
3149 kfree(kctl[i].name);
3150 }
3151 snd_array_free(&spec->kctls);
3152}
3153
2777static void alc_free(struct hda_codec *codec) 3154static void alc_free(struct hda_codec *codec)
2778{ 3155{
2779 struct alc_spec *spec = codec->spec; 3156 struct alc_spec *spec = codec->spec;
2780 unsigned int i;
2781 3157
2782 if (!spec) 3158 if (!spec)
2783 return; 3159 return;
2784 3160
2785 if (spec->kctl_alloc) { 3161 alc_free_kctls(codec);
2786 for (i = 0; i < spec->num_kctl_used; i++)
2787 kfree(spec->kctl_alloc[i].name);
2788 kfree(spec->kctl_alloc);
2789 }
2790 kfree(spec); 3162 kfree(spec);
2791 codec->spec = NULL; /* to be sure */ 3163 codec->spec = NULL; /* to be sure */
2792} 3164}
@@ -3268,6 +3640,8 @@ static struct alc_config_preset alc880_presets[] = {
3268 alc880_gpio2_init_verbs }, 3640 alc880_gpio2_init_verbs },
3269 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 3641 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3270 .dac_nids = alc880_dac_nids, 3642 .dac_nids = alc880_dac_nids,
3643 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3644 .num_adc_nids = 1, /* single ADC */
3271 .hp_nid = 0x03, 3645 .hp_nid = 0x03,
3272 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3646 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3273 .channel_mode = alc880_2_jack_modes, 3647 .channel_mode = alc880_2_jack_modes,
@@ -3532,9 +3906,6 @@ static struct alc_config_preset alc880_presets[] = {
3532 * Automatic parse of I/O pins from the BIOS configuration 3906 * Automatic parse of I/O pins from the BIOS configuration
3533 */ 3907 */
3534 3908
3535#define NUM_CONTROL_ALLOC 32
3536#define NUM_VERB_ALLOC 32
3537
3538enum { 3909enum {
3539 ALC_CTL_WIDGET_VOL, 3910 ALC_CTL_WIDGET_VOL,
3540 ALC_CTL_WIDGET_MUTE, 3911 ALC_CTL_WIDGET_MUTE,
@@ -3552,29 +3923,15 @@ static int add_control(struct alc_spec *spec, int type, const char *name,
3552{ 3923{
3553 struct snd_kcontrol_new *knew; 3924 struct snd_kcontrol_new *knew;
3554 3925
3555 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 3926 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3556 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 3927 knew = snd_array_new(&spec->kctls);
3557 3928 if (!knew)
3558 /* array + terminator */ 3929 return -ENOMEM;
3559 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3560 if (!knew)
3561 return -ENOMEM;
3562 if (spec->kctl_alloc) {
3563 memcpy(knew, spec->kctl_alloc,
3564 sizeof(*knew) * spec->num_kctl_alloc);
3565 kfree(spec->kctl_alloc);
3566 }
3567 spec->kctl_alloc = knew;
3568 spec->num_kctl_alloc = num;
3569 }
3570
3571 knew = &spec->kctl_alloc[spec->num_kctl_used];
3572 *knew = alc880_control_templates[type]; 3930 *knew = alc880_control_templates[type];
3573 knew->name = kstrdup(name, GFP_KERNEL); 3931 knew->name = kstrdup(name, GFP_KERNEL);
3574 if (!knew->name) 3932 if (!knew->name)
3575 return -ENOMEM; 3933 return -ENOMEM;
3576 knew->private_value = val; 3934 knew->private_value = val;
3577 spec->num_kctl_used++;
3578 return 0; 3935 return 0;
3579} 3936}
3580 3937
@@ -3898,10 +4255,10 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
3898 if (spec->autocfg.dig_in_pin) 4255 if (spec->autocfg.dig_in_pin)
3899 spec->dig_in_nid = ALC880_DIGIN_NID; 4256 spec->dig_in_nid = ALC880_DIGIN_NID;
3900 4257
3901 if (spec->kctl_alloc) 4258 if (spec->kctls.list)
3902 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 4259 add_mixer(spec, spec->kctls.list);
3903 4260
3904 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; 4261 add_verb(spec, alc880_volume_init_verbs);
3905 4262
3906 spec->num_mux_defs = 1; 4263 spec->num_mux_defs = 1;
3907 spec->input_mux = &spec->private_imux; 4264 spec->input_mux = &spec->private_imux;
@@ -3925,6 +4282,17 @@ static void alc880_auto_init(struct hda_codec *codec)
3925 * OK, here we have finally the patch for ALC880 4282 * OK, here we have finally the patch for ALC880
3926 */ 4283 */
3927 4284
4285static void set_capture_mixer(struct alc_spec *spec)
4286{
4287 static struct snd_kcontrol_new *caps[3] = {
4288 alc_capture_mixer1,
4289 alc_capture_mixer2,
4290 alc_capture_mixer3,
4291 };
4292 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
4293 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4294}
4295
3928static int patch_alc880(struct hda_codec *codec) 4296static int patch_alc880(struct hda_codec *codec)
3929{ 4297{
3930 struct alc_spec *spec; 4298 struct alc_spec *spec;
@@ -3980,16 +4348,12 @@ static int patch_alc880(struct hda_codec *codec)
3980 if (wcap != AC_WID_AUD_IN) { 4348 if (wcap != AC_WID_AUD_IN) {
3981 spec->adc_nids = alc880_adc_nids_alt; 4349 spec->adc_nids = alc880_adc_nids_alt;
3982 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 4350 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3983 spec->mixers[spec->num_mixers] =
3984 alc880_capture_alt_mixer;
3985 spec->num_mixers++;
3986 } else { 4351 } else {
3987 spec->adc_nids = alc880_adc_nids; 4352 spec->adc_nids = alc880_adc_nids;
3988 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 4353 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3989 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3990 spec->num_mixers++;
3991 } 4354 }
3992 } 4355 }
4356 set_capture_mixer(spec);
3993 4357
3994 spec->vmaster_nid = 0x0c; 4358 spec->vmaster_nid = 0x0c;
3995 4359
@@ -4000,6 +4364,7 @@ static int patch_alc880(struct hda_codec *codec)
4000 if (!spec->loopback.amplist) 4364 if (!spec->loopback.amplist)
4001 spec->loopback.amplist = alc880_loopbacks; 4365 spec->loopback.amplist = alc880_loopbacks;
4002#endif 4366#endif
4367 codec->proc_widget_hook = print_realtek_coef;
4003 4368
4004 return 0; 4369 return 0;
4005} 4370}
@@ -4024,11 +4389,6 @@ static hda_nid_t alc260_adc_nids_alt[1] = {
4024 0x05, 4389 0x05,
4025}; 4390};
4026 4391
4027static hda_nid_t alc260_hp_adc_nids[2] = {
4028 /* ADC1, 0 */
4029 0x05, 0x04
4030};
4031
4032/* NIDs used when simultaneous access to both ADCs makes sense. Note that 4392/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4033 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. 4393 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4034 */ 4394 */
@@ -4157,13 +4517,13 @@ static void alc260_hp_master_update(struct hda_codec *codec,
4157 struct alc_spec *spec = codec->spec; 4517 struct alc_spec *spec = codec->spec;
4158 unsigned int val = spec->master_sw ? PIN_HP : 0; 4518 unsigned int val = spec->master_sw ? PIN_HP : 0;
4159 /* change HP and line-out pins */ 4519 /* change HP and line-out pins */
4160 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4520 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4161 val); 4521 val);
4162 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4522 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4163 val); 4523 val);
4164 /* mono (speaker) depending on the HP jack sense */ 4524 /* mono (speaker) depending on the HP jack sense */
4165 val = (val && !spec->jack_present) ? PIN_OUT : 0; 4525 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4166 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4526 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4167 val); 4527 val);
4168} 4528}
4169 4529
@@ -4242,7 +4602,7 @@ static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
4242 .info = snd_ctl_boolean_mono_info, 4602 .info = snd_ctl_boolean_mono_info,
4243 .get = alc260_hp_master_sw_get, 4603 .get = alc260_hp_master_sw_get,
4244 .put = alc260_hp_master_sw_put, 4604 .put = alc260_hp_master_sw_put,
4245 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 4605 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
4246 }, 4606 },
4247 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4607 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4248 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), 4608 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
@@ -4295,7 +4655,7 @@ static void alc260_hp_3013_automute(struct hda_codec *codec)
4295 present = snd_hda_codec_read(codec, 0x15, 0, 4655 present = snd_hda_codec_read(codec, 0x15, 0,
4296 AC_VERB_GET_PIN_SENSE, 0); 4656 AC_VERB_GET_PIN_SENSE, 0);
4297 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 4657 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4298 alc260_hp_master_update(codec, 0x10, 0x15, 0x11); 4658 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
4299} 4659}
4300 4660
4301static void alc260_hp_3013_unsol_event(struct hda_codec *codec, 4661static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
@@ -4427,45 +4787,6 @@ static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4427 { } /* end */ 4787 { } /* end */
4428}; 4788};
4429 4789
4430/* capture mixer elements */
4431static struct snd_kcontrol_new alc260_capture_mixer[] = {
4432 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4433 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
4434 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4435 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
4436 {
4437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4438 /* The multiple "Capture Source" controls confuse alsamixer
4439 * So call somewhat different..
4440 */
4441 /* .name = "Capture Source", */
4442 .name = "Input Source",
4443 .count = 2,
4444 .info = alc_mux_enum_info,
4445 .get = alc_mux_enum_get,
4446 .put = alc_mux_enum_put,
4447 },
4448 { } /* end */
4449};
4450
4451static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4452 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4453 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4454 {
4455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4456 /* The multiple "Capture Source" controls confuse alsamixer
4457 * So call somewhat different..
4458 */
4459 /* .name = "Capture Source", */
4460 .name = "Input Source",
4461 .count = 1,
4462 .info = alc_mux_enum_info,
4463 .get = alc_mux_enum_get,
4464 .put = alc_mux_enum_put,
4465 },
4466 { } /* end */
4467};
4468
4469/* 4790/*
4470 * initialization verbs 4791 * initialization verbs
4471 */ 4792 */
@@ -5282,7 +5603,6 @@ static struct hda_verb alc260_volume_init_verbs[] = {
5282static int alc260_parse_auto_config(struct hda_codec *codec) 5603static int alc260_parse_auto_config(struct hda_codec *codec)
5283{ 5604{
5284 struct alc_spec *spec = codec->spec; 5605 struct alc_spec *spec = codec->spec;
5285 unsigned int wcap;
5286 int err; 5606 int err;
5287 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 5607 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5288 5608
@@ -5293,7 +5613,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5293 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); 5613 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5294 if (err < 0) 5614 if (err < 0)
5295 return err; 5615 return err;
5296 if (!spec->kctl_alloc) 5616 if (!spec->kctls.list)
5297 return 0; /* can't find valid BIOS pin config */ 5617 return 0; /* can't find valid BIOS pin config */
5298 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); 5618 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5299 if (err < 0) 5619 if (err < 0)
@@ -5303,28 +5623,14 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5303 5623
5304 if (spec->autocfg.dig_out_pin) 5624 if (spec->autocfg.dig_out_pin)
5305 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; 5625 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5306 if (spec->kctl_alloc) 5626 if (spec->kctls.list)
5307 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 5627 add_mixer(spec, spec->kctls.list);
5308 5628
5309 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; 5629 add_verb(spec, alc260_volume_init_verbs);
5310 5630
5311 spec->num_mux_defs = 1; 5631 spec->num_mux_defs = 1;
5312 spec->input_mux = &spec->private_imux; 5632 spec->input_mux = &spec->private_imux;
5313 5633
5314 /* check whether NID 0x04 is valid */
5315 wcap = get_wcaps(codec, 0x04);
5316 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5317 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5318 spec->adc_nids = alc260_adc_nids_alt;
5319 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5320 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
5321 } else {
5322 spec->adc_nids = alc260_adc_nids;
5323 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5324 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
5325 }
5326 spec->num_mixers++;
5327
5328 store_pin_configs(codec); 5634 store_pin_configs(codec);
5329 return 1; 5635 return 1;
5330} 5636}
@@ -5394,12 +5700,11 @@ static struct alc_config_preset alc260_presets[] = {
5394 [ALC260_BASIC] = { 5700 [ALC260_BASIC] = {
5395 .mixers = { alc260_base_output_mixer, 5701 .mixers = { alc260_base_output_mixer,
5396 alc260_input_mixer, 5702 alc260_input_mixer,
5397 alc260_pc_beep_mixer, 5703 alc260_pc_beep_mixer },
5398 alc260_capture_mixer },
5399 .init_verbs = { alc260_init_verbs }, 5704 .init_verbs = { alc260_init_verbs },
5400 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5705 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5401 .dac_nids = alc260_dac_nids, 5706 .dac_nids = alc260_dac_nids,
5402 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 5707 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5403 .adc_nids = alc260_adc_nids, 5708 .adc_nids = alc260_adc_nids,
5404 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5709 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5405 .channel_mode = alc260_modes, 5710 .channel_mode = alc260_modes,
@@ -5407,14 +5712,13 @@ static struct alc_config_preset alc260_presets[] = {
5407 }, 5712 },
5408 [ALC260_HP] = { 5713 [ALC260_HP] = {
5409 .mixers = { alc260_hp_output_mixer, 5714 .mixers = { alc260_hp_output_mixer,
5410 alc260_input_mixer, 5715 alc260_input_mixer },
5411 alc260_capture_alt_mixer },
5412 .init_verbs = { alc260_init_verbs, 5716 .init_verbs = { alc260_init_verbs,
5413 alc260_hp_unsol_verbs }, 5717 alc260_hp_unsol_verbs },
5414 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5718 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5415 .dac_nids = alc260_dac_nids, 5719 .dac_nids = alc260_dac_nids,
5416 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5720 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5417 .adc_nids = alc260_hp_adc_nids, 5721 .adc_nids = alc260_adc_nids_alt,
5418 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5722 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5419 .channel_mode = alc260_modes, 5723 .channel_mode = alc260_modes,
5420 .input_mux = &alc260_capture_source, 5724 .input_mux = &alc260_capture_source,
@@ -5423,14 +5727,13 @@ static struct alc_config_preset alc260_presets[] = {
5423 }, 5727 },
5424 [ALC260_HP_DC7600] = { 5728 [ALC260_HP_DC7600] = {
5425 .mixers = { alc260_hp_dc7600_mixer, 5729 .mixers = { alc260_hp_dc7600_mixer,
5426 alc260_input_mixer, 5730 alc260_input_mixer },
5427 alc260_capture_alt_mixer },
5428 .init_verbs = { alc260_init_verbs, 5731 .init_verbs = { alc260_init_verbs,
5429 alc260_hp_dc7600_verbs }, 5732 alc260_hp_dc7600_verbs },
5430 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5733 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5431 .dac_nids = alc260_dac_nids, 5734 .dac_nids = alc260_dac_nids,
5432 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5735 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5433 .adc_nids = alc260_hp_adc_nids, 5736 .adc_nids = alc260_adc_nids_alt,
5434 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5737 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5435 .channel_mode = alc260_modes, 5738 .channel_mode = alc260_modes,
5436 .input_mux = &alc260_capture_source, 5739 .input_mux = &alc260_capture_source,
@@ -5439,14 +5742,13 @@ static struct alc_config_preset alc260_presets[] = {
5439 }, 5742 },
5440 [ALC260_HP_3013] = { 5743 [ALC260_HP_3013] = {
5441 .mixers = { alc260_hp_3013_mixer, 5744 .mixers = { alc260_hp_3013_mixer,
5442 alc260_input_mixer, 5745 alc260_input_mixer },
5443 alc260_capture_alt_mixer },
5444 .init_verbs = { alc260_hp_3013_init_verbs, 5746 .init_verbs = { alc260_hp_3013_init_verbs,
5445 alc260_hp_3013_unsol_verbs }, 5747 alc260_hp_3013_unsol_verbs },
5446 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5748 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5447 .dac_nids = alc260_dac_nids, 5749 .dac_nids = alc260_dac_nids,
5448 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 5750 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5449 .adc_nids = alc260_hp_adc_nids, 5751 .adc_nids = alc260_adc_nids_alt,
5450 .num_channel_mode = ARRAY_SIZE(alc260_modes), 5752 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5451 .channel_mode = alc260_modes, 5753 .channel_mode = alc260_modes,
5452 .input_mux = &alc260_capture_source, 5754 .input_mux = &alc260_capture_source,
@@ -5454,8 +5756,7 @@ static struct alc_config_preset alc260_presets[] = {
5454 .init_hook = alc260_hp_3013_automute, 5756 .init_hook = alc260_hp_3013_automute,
5455 }, 5757 },
5456 [ALC260_FUJITSU_S702X] = { 5758 [ALC260_FUJITSU_S702X] = {
5457 .mixers = { alc260_fujitsu_mixer, 5759 .mixers = { alc260_fujitsu_mixer },
5458 alc260_capture_mixer },
5459 .init_verbs = { alc260_fujitsu_init_verbs }, 5760 .init_verbs = { alc260_fujitsu_init_verbs },
5460 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5761 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5461 .dac_nids = alc260_dac_nids, 5762 .dac_nids = alc260_dac_nids,
@@ -5467,8 +5768,7 @@ static struct alc_config_preset alc260_presets[] = {
5467 .input_mux = alc260_fujitsu_capture_sources, 5768 .input_mux = alc260_fujitsu_capture_sources,
5468 }, 5769 },
5469 [ALC260_ACER] = { 5770 [ALC260_ACER] = {
5470 .mixers = { alc260_acer_mixer, 5771 .mixers = { alc260_acer_mixer },
5471 alc260_capture_mixer },
5472 .init_verbs = { alc260_acer_init_verbs }, 5772 .init_verbs = { alc260_acer_init_verbs },
5473 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5773 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5474 .dac_nids = alc260_dac_nids, 5774 .dac_nids = alc260_dac_nids,
@@ -5480,8 +5780,7 @@ static struct alc_config_preset alc260_presets[] = {
5480 .input_mux = alc260_acer_capture_sources, 5780 .input_mux = alc260_acer_capture_sources,
5481 }, 5781 },
5482 [ALC260_WILL] = { 5782 [ALC260_WILL] = {
5483 .mixers = { alc260_will_mixer, 5783 .mixers = { alc260_will_mixer },
5484 alc260_capture_mixer },
5485 .init_verbs = { alc260_init_verbs, alc260_will_verbs }, 5784 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5486 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5785 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5487 .dac_nids = alc260_dac_nids, 5786 .dac_nids = alc260_dac_nids,
@@ -5493,8 +5792,7 @@ static struct alc_config_preset alc260_presets[] = {
5493 .input_mux = &alc260_capture_source, 5792 .input_mux = &alc260_capture_source,
5494 }, 5793 },
5495 [ALC260_REPLACER_672V] = { 5794 [ALC260_REPLACER_672V] = {
5496 .mixers = { alc260_replacer_672v_mixer, 5795 .mixers = { alc260_replacer_672v_mixer },
5497 alc260_capture_mixer },
5498 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, 5796 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5499 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5797 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5500 .dac_nids = alc260_dac_nids, 5798 .dac_nids = alc260_dac_nids,
@@ -5509,8 +5807,7 @@ static struct alc_config_preset alc260_presets[] = {
5509 }, 5807 },
5510#ifdef CONFIG_SND_DEBUG 5808#ifdef CONFIG_SND_DEBUG
5511 [ALC260_TEST] = { 5809 [ALC260_TEST] = {
5512 .mixers = { alc260_test_mixer, 5810 .mixers = { alc260_test_mixer },
5513 alc260_capture_mixer },
5514 .init_verbs = { alc260_test_init_verbs }, 5811 .init_verbs = { alc260_test_init_verbs },
5515 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), 5812 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5516 .dac_nids = alc260_test_dac_nids, 5813 .dac_nids = alc260_test_dac_nids,
@@ -5569,6 +5866,21 @@ static int patch_alc260(struct hda_codec *codec)
5569 spec->stream_digital_playback = &alc260_pcm_digital_playback; 5866 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5570 spec->stream_digital_capture = &alc260_pcm_digital_capture; 5867 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5571 5868
5869 if (!spec->adc_nids && spec->input_mux) {
5870 /* check whether NID 0x04 is valid */
5871 unsigned int wcap = get_wcaps(codec, 0x04);
5872 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5873 /* get type */
5874 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5875 spec->adc_nids = alc260_adc_nids_alt;
5876 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5877 } else {
5878 spec->adc_nids = alc260_adc_nids;
5879 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5880 }
5881 }
5882 set_capture_mixer(spec);
5883
5572 spec->vmaster_nid = 0x08; 5884 spec->vmaster_nid = 0x08;
5573 5885
5574 codec->patch_ops = alc_patch_ops; 5886 codec->patch_ops = alc_patch_ops;
@@ -5578,6 +5890,7 @@ static int patch_alc260(struct hda_codec *codec)
5578 if (!spec->loopback.amplist) 5890 if (!spec->loopback.amplist)
5579 spec->loopback.amplist = alc260_loopbacks; 5891 spec->loopback.amplist = alc260_loopbacks;
5580#endif 5892#endif
5893 codec->proc_widget_hook = print_realtek_coef;
5581 5894
5582 return 0; 5895 return 0;
5583} 5896}
@@ -5625,36 +5938,6 @@ static struct hda_input_mux alc882_capture_source = {
5625 { "CD", 0x4 }, 5938 { "CD", 0x4 },
5626 }, 5939 },
5627}; 5940};
5628#define alc882_mux_enum_info alc_mux_enum_info
5629#define alc882_mux_enum_get alc_mux_enum_get
5630
5631static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5632 struct snd_ctl_elem_value *ucontrol)
5633{
5634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5635 struct alc_spec *spec = codec->spec;
5636 const struct hda_input_mux *imux = spec->input_mux;
5637 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5638 hda_nid_t nid = spec->capsrc_nids ?
5639 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
5640 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5641 unsigned int i, idx;
5642
5643 idx = ucontrol->value.enumerated.item[0];
5644 if (idx >= imux->num_items)
5645 idx = imux->num_items - 1;
5646 if (*cur_val == idx)
5647 return 0;
5648 for (i = 0; i < imux->num_items; i++) {
5649 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5650 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5651 imux->items[i].index,
5652 HDA_AMP_MUTE, v);
5653 }
5654 *cur_val = idx;
5655 return 1;
5656}
5657
5658/* 5941/*
5659 * 2ch mode 5942 * 2ch mode
5660 */ 5943 */
@@ -6337,49 +6620,6 @@ static struct hda_verb alc882_auto_init_verbs[] = {
6337 { } 6620 { }
6338}; 6621};
6339 6622
6340/* capture mixer elements */
6341static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6342 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6343 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6344 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6345 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6346 {
6347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6348 /* The multiple "Capture Source" controls confuse alsamixer
6349 * So call somewhat different..
6350 */
6351 /* .name = "Capture Source", */
6352 .name = "Input Source",
6353 .count = 2,
6354 .info = alc882_mux_enum_info,
6355 .get = alc882_mux_enum_get,
6356 .put = alc882_mux_enum_put,
6357 },
6358 { } /* end */
6359};
6360
6361static struct snd_kcontrol_new alc882_capture_mixer[] = {
6362 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6363 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6364 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6365 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6366 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6367 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6368 {
6369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6370 /* The multiple "Capture Source" controls confuse alsamixer
6371 * So call somewhat different..
6372 */
6373 /* .name = "Capture Source", */
6374 .name = "Input Source",
6375 .count = 3,
6376 .info = alc882_mux_enum_info,
6377 .get = alc882_mux_enum_get,
6378 .put = alc882_mux_enum_put,
6379 },
6380 { } /* end */
6381};
6382
6383#ifdef CONFIG_SND_HDA_POWER_SAVE 6623#ifdef CONFIG_SND_HDA_POWER_SAVE
6384#define alc882_loopbacks alc880_loopbacks 6624#define alc882_loopbacks alc880_loopbacks
6385#endif 6625#endif
@@ -6508,8 +6748,7 @@ static struct alc_config_preset alc882_presets[] = {
6508 .init_hook = alc885_imac24_init_hook, 6748 .init_hook = alc885_imac24_init_hook,
6509 }, 6749 },
6510 [ALC882_TARGA] = { 6750 [ALC882_TARGA] = {
6511 .mixers = { alc882_targa_mixer, alc882_chmode_mixer, 6751 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
6512 alc882_capture_mixer },
6513 .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, 6752 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6514 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6753 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6515 .dac_nids = alc882_dac_nids, 6754 .dac_nids = alc882_dac_nids,
@@ -6525,8 +6764,7 @@ static struct alc_config_preset alc882_presets[] = {
6525 .init_hook = alc882_targa_automute, 6764 .init_hook = alc882_targa_automute,
6526 }, 6765 },
6527 [ALC882_ASUS_A7J] = { 6766 [ALC882_ASUS_A7J] = {
6528 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, 6767 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
6529 alc882_capture_mixer },
6530 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, 6768 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6531 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 6769 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6532 .dac_nids = alc882_dac_nids, 6770 .dac_nids = alc882_dac_nids,
@@ -6831,6 +7069,7 @@ static int patch_alc882(struct hda_codec *codec)
6831 spec->stream_digital_playback = &alc882_pcm_digital_playback; 7069 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6832 spec->stream_digital_capture = &alc882_pcm_digital_capture; 7070 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6833 7071
7072 spec->is_mix_capture = 1; /* matrix-style capture */
6834 if (!spec->adc_nids && spec->input_mux) { 7073 if (!spec->adc_nids && spec->input_mux) {
6835 /* check whether NID 0x07 is valid */ 7074 /* check whether NID 0x07 is valid */
6836 unsigned int wcap = get_wcaps(codec, 0x07); 7075 unsigned int wcap = get_wcaps(codec, 0x07);
@@ -6840,17 +7079,13 @@ static int patch_alc882(struct hda_codec *codec)
6840 spec->adc_nids = alc882_adc_nids_alt; 7079 spec->adc_nids = alc882_adc_nids_alt;
6841 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 7080 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6842 spec->capsrc_nids = alc882_capsrc_nids_alt; 7081 spec->capsrc_nids = alc882_capsrc_nids_alt;
6843 spec->mixers[spec->num_mixers] =
6844 alc882_capture_alt_mixer;
6845 spec->num_mixers++;
6846 } else { 7082 } else {
6847 spec->adc_nids = alc882_adc_nids; 7083 spec->adc_nids = alc882_adc_nids;
6848 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 7084 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6849 spec->capsrc_nids = alc882_capsrc_nids; 7085 spec->capsrc_nids = alc882_capsrc_nids;
6850 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6851 spec->num_mixers++;
6852 } 7086 }
6853 } 7087 }
7088 set_capture_mixer(spec);
6854 7089
6855 spec->vmaster_nid = 0x0c; 7090 spec->vmaster_nid = 0x0c;
6856 7091
@@ -6861,6 +7096,7 @@ static int patch_alc882(struct hda_codec *codec)
6861 if (!spec->loopback.amplist) 7096 if (!spec->loopback.amplist)
6862 spec->loopback.amplist = alc882_loopbacks; 7097 spec->loopback.amplist = alc882_loopbacks;
6863#endif 7098#endif
7099 codec->proc_widget_hook = print_realtek_coef;
6864 7100
6865 return 0; 7101 return 0;
6866} 7102}
@@ -6879,6 +7115,8 @@ static int patch_alc882(struct hda_codec *codec)
6879#define ALC883_DIGOUT_NID 0x06 7115#define ALC883_DIGOUT_NID 0x06
6880#define ALC883_DIGIN_NID 0x0a 7116#define ALC883_DIGIN_NID 0x0a
6881 7117
7118#define ALC1200_DIGOUT_NID 0x10
7119
6882static hda_nid_t alc883_dac_nids[4] = { 7120static hda_nid_t alc883_dac_nids[4] = {
6883 /* front, rear, clfe, rear_surr */ 7121 /* front, rear, clfe, rear_surr */
6884 0x02, 0x03, 0x04, 0x05 7122 0x02, 0x03, 0x04, 0x05
@@ -6889,8 +7127,20 @@ static hda_nid_t alc883_adc_nids[2] = {
6889 0x08, 0x09, 7127 0x08, 0x09,
6890}; 7128};
6891 7129
7130static hda_nid_t alc883_adc_nids_alt[1] = {
7131 /* ADC1 */
7132 0x08,
7133};
7134
7135static hda_nid_t alc883_adc_nids_rev[2] = {
7136 /* ADC2-1 */
7137 0x09, 0x08
7138};
7139
6892static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; 7140static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6893 7141
7142static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7143
6894/* input MUX */ 7144/* input MUX */
6895/* FIXME: should be a matrix-type input source selection */ 7145/* FIXME: should be a matrix-type input source selection */
6896 7146
@@ -6957,11 +7207,6 @@ static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6957 }, 7207 },
6958}; 7208};
6959 7209
6960#define alc883_mux_enum_info alc_mux_enum_info
6961#define alc883_mux_enum_get alc_mux_enum_get
6962/* ALC883 has the ALC882-type input selection */
6963#define alc883_mux_enum_put alc882_mux_enum_put
6964
6965/* 7210/*
6966 * 2ch mode 7211 * 2ch mode
6967 */ 7212 */
@@ -7115,19 +7360,6 @@ static struct snd_kcontrol_new alc883_base_mixer[] = {
7115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7116 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7361 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7117 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7362 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7122 {
7123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7124 /* .name = "Capture Source", */
7125 .name = "Input Source",
7126 .count = 2,
7127 .info = alc883_mux_enum_info,
7128 .get = alc883_mux_enum_get,
7129 .put = alc883_mux_enum_put,
7130 },
7131 { } /* end */ 7363 { } /* end */
7132}; 7364};
7133 7365
@@ -7145,19 +7377,6 @@ static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7145 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7377 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7146 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7378 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7379 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7152 {
7153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7154 /* .name = "Capture Source", */
7155 .name = "Input Source",
7156 .count = 2,
7157 .info = alc883_mux_enum_info,
7158 .get = alc883_mux_enum_get,
7159 .put = alc883_mux_enum_put,
7160 },
7161 { } /* end */ 7380 { } /* end */
7162}; 7381};
7163 7382
@@ -7172,19 +7391,6 @@ static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
7172 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7391 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7173 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7392 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7174 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7393 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7175 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7176 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7177 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7178 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7179 {
7180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7181 /* .name = "Capture Source", */
7182 .name = "Input Source",
7183 .count = 2,
7184 .info = alc883_mux_enum_info,
7185 .get = alc883_mux_enum_get,
7186 .put = alc883_mux_enum_put,
7187 },
7188 { } /* end */ 7394 { } /* end */
7189}; 7395};
7190 7396
@@ -7199,19 +7405,6 @@ static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7199 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7405 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7200 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7406 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7201 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7407 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7202 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7203 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7204 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7205 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7206 {
7207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7208 /* .name = "Capture Source", */
7209 .name = "Input Source",
7210 .count = 2,
7211 .info = alc883_mux_enum_info,
7212 .get = alc883_mux_enum_get,
7213 .put = alc883_mux_enum_put,
7214 },
7215 { } /* end */ 7408 { } /* end */
7216}; 7409};
7217 7410
@@ -7231,19 +7424,6 @@ static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7231 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7232 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7425 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7233 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7426 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7234 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7235 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7236 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7237 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7238 {
7239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7240 /* .name = "Capture Source", */
7241 .name = "Input Source",
7242 .count = 2,
7243 .info = alc883_mux_enum_info,
7244 .get = alc883_mux_enum_get,
7245 .put = alc883_mux_enum_put,
7246 },
7247 { } /* end */ 7427 { } /* end */
7248}; 7428};
7249 7429
@@ -7269,17 +7449,6 @@ static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7269 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7270 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7450 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7271 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7451 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7272 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7273 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7274 {
7275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7276 /* .name = "Capture Source", */
7277 .name = "Input Source",
7278 .count = 1,
7279 .info = alc883_mux_enum_info,
7280 .get = alc883_mux_enum_get,
7281 .put = alc883_mux_enum_put,
7282 },
7283 { } /* end */ 7452 { } /* end */
7284}; 7453};
7285 7454
@@ -7306,19 +7475,6 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7306 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7307 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7476 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7308 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7477 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7309 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7310 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7311 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7312 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7313 {
7314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7315 /* .name = "Capture Source", */
7316 .name = "Input Source",
7317 .count = 2,
7318 .info = alc883_mux_enum_info,
7319 .get = alc883_mux_enum_get,
7320 .put = alc883_mux_enum_put,
7321 },
7322 { } /* end */ 7478 { } /* end */
7323}; 7479};
7324 7480
@@ -7344,18 +7500,6 @@ static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7344 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7345 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 7501 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7346 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 7502 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7347 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7348 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7349
7350 {
7351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7352 /* .name = "Capture Source", */
7353 .name = "Input Source",
7354 .count = 1,
7355 .info = alc883_mux_enum_info,
7356 .get = alc883_mux_enum_get,
7357 .put = alc883_mux_enum_put,
7358 },
7359 { } /* end */ 7503 { } /* end */
7360}; 7504};
7361 7505
@@ -7376,19 +7520,6 @@ static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7521 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7379 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7380 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7381 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7382 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7383 {
7384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7385 /* .name = "Capture Source", */
7386 .name = "Input Source",
7387 .count = 2,
7388 .info = alc883_mux_enum_info,
7389 .get = alc883_mux_enum_get,
7390 .put = alc883_mux_enum_put,
7391 },
7392 { } /* end */ 7523 { } /* end */
7393}; 7524};
7394 7525
@@ -7404,19 +7535,6 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7404 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7535 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7405 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 7536 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7406 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7537 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7407 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7408 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7409 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7410 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7411 {
7412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7413 /* .name = "Capture Source", */
7414 .name = "Input Source",
7415 .count = 2,
7416 .info = alc883_mux_enum_info,
7417 .get = alc883_mux_enum_get,
7418 .put = alc883_mux_enum_put,
7419 },
7420 { } /* end */ 7538 { } /* end */
7421}; 7539};
7422 7540
@@ -7429,17 +7547,6 @@ static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7548 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7432 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7433 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7434 {
7435 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7436 /* .name = "Capture Source", */
7437 .name = "Input Source",
7438 .count = 1,
7439 .info = alc883_mux_enum_info,
7440 .get = alc883_mux_enum_get,
7441 .put = alc883_mux_enum_put,
7442 },
7443 { } /* end */ 7550 { } /* end */
7444}; 7551};
7445 7552
@@ -7453,19 +7560,6 @@ static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7454 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7561 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7455 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7562 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7456 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7457 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7458 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7459 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7460 {
7461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7462 /* .name = "Capture Source", */
7463 .name = "Input Source",
7464 .count = 2,
7465 .info = alc883_mux_enum_info,
7466 .get = alc883_mux_enum_get,
7467 .put = alc883_mux_enum_put,
7468 },
7469 { } /* end */ 7563 { } /* end */
7470}; 7564};
7471 7565
@@ -7479,19 +7573,6 @@ static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7480 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7574 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7481 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7575 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7482 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7483 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7484 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7485 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7486 {
7487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7488 /* .name = "Capture Source", */
7489 .name = "Input Source",
7490 .count = 2,
7491 .info = alc883_mux_enum_info,
7492 .get = alc883_mux_enum_get,
7493 .put = alc883_mux_enum_put,
7494 },
7495 { } /* end */ 7576 { } /* end */
7496}; 7577};
7497 7578
@@ -7504,19 +7585,6 @@ static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7505 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7586 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7507 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7508 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7509 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7510 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7511 {
7512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7513 /* .name = "Capture Source", */
7514 .name = "Input Source",
7515 .count = 2,
7516 .info = alc883_mux_enum_info,
7517 .get = alc883_mux_enum_get,
7518 .put = alc883_mux_enum_put,
7519 },
7520 { } /* end */ 7588 { } /* end */
7521}; 7589};
7522 7590
@@ -7544,19 +7612,6 @@ static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7544 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7545 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7613 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7614 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7547 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7548 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7549 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7550 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7551 {
7552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7553 /* .name = "Capture Source", */
7554 .name = "Input Source",
7555 .count = 2,
7556 .info = alc883_mux_enum_info,
7557 .get = alc883_mux_enum_get,
7558 .put = alc883_mux_enum_put,
7559 },
7560 { } /* end */ 7615 { } /* end */
7561}; 7616};
7562 7617
@@ -7587,6 +7642,10 @@ static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 7643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7645 { } /* end */
7646};
7647
7648static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
7590 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), 7649 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7591 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), 7650 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7592 { 7651 {
@@ -7594,9 +7653,9 @@ static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7594 /* .name = "Capture Source", */ 7653 /* .name = "Capture Source", */
7595 .name = "Input Source", 7654 .name = "Input Source",
7596 .count = 1, 7655 .count = 1,
7597 .info = alc883_mux_enum_info, 7656 .info = alc_mux_enum_info,
7598 .get = alc883_mux_enum_get, 7657 .get = alc_mux_enum_get,
7599 .put = alc883_mux_enum_put, 7658 .put = alc_mux_enum_put,
7600 }, 7659 },
7601 { } /* end */ 7660 { } /* end */
7602}; 7661};
@@ -8251,27 +8310,6 @@ static struct hda_verb alc883_auto_init_verbs[] = {
8251 { } 8310 { }
8252}; 8311};
8253 8312
8254/* capture mixer elements */
8255static struct snd_kcontrol_new alc883_capture_mixer[] = {
8256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8258 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
8259 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
8260 {
8261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8262 /* The multiple "Capture Source" controls confuse alsamixer
8263 * So call somewhat different..
8264 */
8265 /* .name = "Capture Source", */
8266 .name = "Input Source",
8267 .count = 2,
8268 .info = alc882_mux_enum_info,
8269 .get = alc882_mux_enum_get,
8270 .put = alc882_mux_enum_put,
8271 },
8272 { } /* end */
8273};
8274
8275static struct hda_verb alc888_asus_m90v_verbs[] = { 8313static struct hda_verb alc888_asus_m90v_verbs[] = {
8276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
@@ -8394,6 +8432,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
8394 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", 8432 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8395 [ALC883_ACER] = "acer", 8433 [ALC883_ACER] = "acer",
8396 [ALC883_ACER_ASPIRE] = "acer-aspire", 8434 [ALC883_ACER_ASPIRE] = "acer-aspire",
8435 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8397 [ALC883_MEDION] = "medion", 8436 [ALC883_MEDION] = "medion",
8398 [ALC883_MEDION_MD2] = "medion-md2", 8437 [ALC883_MEDION_MD2] = "medion-md2",
8399 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 8438 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
@@ -8407,7 +8446,9 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
8407 [ALC883_MITAC] = "mitac", 8446 [ALC883_MITAC] = "mitac",
8408 [ALC883_CLEVO_M720] = "clevo-m720", 8447 [ALC883_CLEVO_M720] = "clevo-m720",
8409 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", 8448 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
8449 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8410 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", 8450 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8451 [ALC1200_ASUS_P5Q] = "asus-p5q",
8411 [ALC883_AUTO] = "auto", 8452 [ALC883_AUTO] = "auto",
8412}; 8453};
8413 8454
@@ -8418,6 +8459,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8418 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 8459 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8419 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), 8460 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8420 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), 8461 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
8462 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8463 ALC888_ACER_ASPIRE_4930G),
8421 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ 8464 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
8422 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8465 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8423 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8466 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
@@ -8426,6 +8469,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8426 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8469 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8427 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8470 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8428 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8471 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8472 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8429 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8473 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8430 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8474 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8431 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8475 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
@@ -8452,6 +8496,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8452 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 8496 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8453 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 8497 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8454 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), 8498 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
8499 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
8455 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), 8500 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
8456 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 8501 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8457 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 8502 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
@@ -8463,6 +8508,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8463 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8508 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8464 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8509 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8465 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), 8510 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
8511 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8512 ALC888_FUJITSU_XA3530),
8466 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 8513 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8467 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 8514 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8468 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 8515 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
@@ -8553,6 +8600,8 @@ static struct alc_config_preset alc883_presets[] = {
8553 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, 8600 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8554 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8601 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8555 .dac_nids = alc883_dac_nids, 8602 .dac_nids = alc883_dac_nids,
8603 .adc_nids = alc883_adc_nids_alt,
8604 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8556 .dig_out_nid = ALC883_DIGOUT_NID, 8605 .dig_out_nid = ALC883_DIGOUT_NID,
8557 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8606 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8558 .channel_mode = alc883_3ST_2ch_modes, 8607 .channel_mode = alc883_3ST_2ch_modes,
@@ -8586,6 +8635,26 @@ static struct alc_config_preset alc883_presets[] = {
8586 .unsol_event = alc883_acer_aspire_unsol_event, 8635 .unsol_event = alc883_acer_aspire_unsol_event,
8587 .init_hook = alc883_acer_aspire_automute, 8636 .init_hook = alc883_acer_aspire_automute,
8588 }, 8637 },
8638 [ALC888_ACER_ASPIRE_4930G] = {
8639 .mixers = { alc888_base_mixer,
8640 alc883_chmode_mixer },
8641 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8642 alc888_acer_aspire_4930g_verbs },
8643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8644 .dac_nids = alc883_dac_nids,
8645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8646 .adc_nids = alc883_adc_nids_rev,
8647 .capsrc_nids = alc883_capsrc_nids_rev,
8648 .dig_out_nid = ALC883_DIGOUT_NID,
8649 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8650 .channel_mode = alc883_3ST_6ch_modes,
8651 .need_dac_fix = 1,
8652 .num_mux_defs =
8653 ARRAY_SIZE(alc888_2_capture_sources),
8654 .input_mux = alc888_2_capture_sources,
8655 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8656 .init_hook = alc888_acer_aspire_4930g_automute,
8657 },
8589 [ALC883_MEDION] = { 8658 [ALC883_MEDION] = {
8590 .mixers = { alc883_fivestack_mixer, 8659 .mixers = { alc883_fivestack_mixer,
8591 alc883_chmode_mixer }, 8660 alc883_chmode_mixer },
@@ -8593,6 +8662,8 @@ static struct alc_config_preset alc883_presets[] = {
8593 alc883_medion_eapd_verbs }, 8662 alc883_medion_eapd_verbs },
8594 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8663 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8595 .dac_nids = alc883_dac_nids, 8664 .dac_nids = alc883_dac_nids,
8665 .adc_nids = alc883_adc_nids_alt,
8666 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8596 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8667 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8597 .channel_mode = alc883_sixstack_modes, 8668 .channel_mode = alc883_sixstack_modes,
8598 .input_mux = &alc883_capture_source, 8669 .input_mux = &alc883_capture_source,
@@ -8635,6 +8706,8 @@ static struct alc_config_preset alc883_presets[] = {
8635 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, 8706 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8636 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8637 .dac_nids = alc883_dac_nids, 8708 .dac_nids = alc883_dac_nids,
8709 .adc_nids = alc883_adc_nids_alt,
8710 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8638 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8711 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8639 .channel_mode = alc883_3ST_2ch_modes, 8712 .channel_mode = alc883_3ST_2ch_modes,
8640 .input_mux = &alc883_lenovo_101e_capture_source, 8713 .input_mux = &alc883_lenovo_101e_capture_source,
@@ -8725,14 +8798,30 @@ static struct alc_config_preset alc883_presets[] = {
8725 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, 8798 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8726 .init_hook = alc883_2ch_fujitsu_pi2515_automute, 8799 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8727 }, 8800 },
8801 [ALC888_FUJITSU_XA3530] = {
8802 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8803 .init_verbs = { alc883_init_verbs,
8804 alc888_fujitsu_xa3530_verbs },
8805 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8806 .dac_nids = alc883_dac_nids,
8807 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8808 .adc_nids = alc883_adc_nids_rev,
8809 .capsrc_nids = alc883_capsrc_nids_rev,
8810 .dig_out_nid = ALC883_DIGOUT_NID,
8811 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8812 .channel_mode = alc888_4ST_8ch_intel_modes,
8813 .num_mux_defs =
8814 ARRAY_SIZE(alc888_2_capture_sources),
8815 .input_mux = alc888_2_capture_sources,
8816 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8817 .init_hook = alc888_fujitsu_xa3530_automute,
8818 },
8728 [ALC888_LENOVO_SKY] = { 8819 [ALC888_LENOVO_SKY] = {
8729 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, 8820 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8730 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, 8821 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8731 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8822 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8732 .dac_nids = alc883_dac_nids, 8823 .dac_nids = alc883_dac_nids,
8733 .dig_out_nid = ALC883_DIGOUT_NID, 8824 .dig_out_nid = ALC883_DIGOUT_NID,
8734 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
8735 .adc_nids = alc883_adc_nids,
8736 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 8825 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8737 .channel_mode = alc883_sixstack_modes, 8826 .channel_mode = alc883_sixstack_modes,
8738 .need_dac_fix = 1, 8827 .need_dac_fix = 1,
@@ -8756,6 +8845,7 @@ static struct alc_config_preset alc883_presets[] = {
8756 }, 8845 },
8757 [ALC888_ASUS_EEE1601] = { 8846 [ALC888_ASUS_EEE1601] = {
8758 .mixers = { alc883_asus_eee1601_mixer }, 8847 .mixers = { alc883_asus_eee1601_mixer },
8848 .cap_mixer = alc883_asus_eee1601_cap_mixer,
8759 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, 8849 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8760 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8850 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8761 .dac_nids = alc883_dac_nids, 8851 .dac_nids = alc883_dac_nids,
@@ -8768,6 +8858,17 @@ static struct alc_config_preset alc883_presets[] = {
8768 .unsol_event = alc883_eee1601_unsol_event, 8858 .unsol_event = alc883_eee1601_unsol_event,
8769 .init_hook = alc883_eee1601_inithook, 8859 .init_hook = alc883_eee1601_inithook,
8770 }, 8860 },
8861 [ALC1200_ASUS_P5Q] = {
8862 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8863 .init_verbs = { alc883_init_verbs },
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
8866 .dig_out_nid = ALC1200_DIGOUT_NID,
8867 .dig_in_nid = ALC883_DIGIN_NID,
8868 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8869 .channel_mode = alc883_sixstack_modes,
8870 .input_mux = &alc883_capture_source,
8871 },
8771}; 8872};
8772 8873
8773 8874
@@ -8862,8 +8963,6 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8862 8963
8863 /* hack - override the init verbs */ 8964 /* hack - override the init verbs */
8864 spec->init_verbs[0] = alc883_auto_init_verbs; 8965 spec->init_verbs[0] = alc883_auto_init_verbs;
8865 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8866 spec->num_mixers++;
8867 8966
8868 return 1; /* config found */ 8967 return 1; /* config found */
8869} 8968}
@@ -8946,9 +9045,15 @@ static int patch_alc883(struct hda_codec *codec)
8946 spec->stream_digital_playback = &alc883_pcm_digital_playback; 9045 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8947 spec->stream_digital_capture = &alc883_pcm_digital_capture; 9046 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8948 9047
8949 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 9048 if (!spec->num_adc_nids) {
8950 spec->adc_nids = alc883_adc_nids; 9049 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8951 spec->capsrc_nids = alc883_capsrc_nids; 9050 spec->adc_nids = alc883_adc_nids;
9051 }
9052 if (!spec->capsrc_nids)
9053 spec->capsrc_nids = alc883_capsrc_nids;
9054 spec->is_mix_capture = 1; /* matrix-style capture */
9055 if (!spec->cap_mixer)
9056 set_capture_mixer(spec);
8952 9057
8953 spec->vmaster_nid = 0x0c; 9058 spec->vmaster_nid = 0x0c;
8954 9059
@@ -8960,6 +9065,7 @@ static int patch_alc883(struct hda_codec *codec)
8960 if (!spec->loopback.amplist) 9065 if (!spec->loopback.amplist)
8961 spec->loopback.amplist = alc883_loopbacks; 9066 spec->loopback.amplist = alc883_loopbacks;
8962#endif 9067#endif
9068 codec->proc_widget_hook = print_realtek_coef;
8963 9069
8964 return 0; 9070 return 0;
8965} 9071}
@@ -9439,20 +9545,6 @@ static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 9546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 9547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9442 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9443 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9444 {
9445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9446 /* The multiple "Capture Source" controls confuse alsamixer
9447 * So call somewhat different..
9448 */
9449 /* .name = "Capture Source", */
9450 .name = "Input Source",
9451 .count = 1,
9452 .info = alc_mux_enum_info,
9453 .get = alc_mux_enum_get,
9454 .put = alc_mux_enum_put,
9455 },
9456 { } /* end */ 9548 { } /* end */
9457}; 9549};
9458 9550
@@ -9969,7 +10061,7 @@ static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9969 struct alc_spec *spec = codec->spec; 10061 struct alc_spec *spec = codec->spec;
9970 int ret; 10062 int ret;
9971 10063
9972 ret = alc882_mux_enum_put(kcontrol, ucontrol); 10064 ret = alc_mux_enum_put(kcontrol, ucontrol);
9973 if (!ret) 10065 if (!ret)
9974 return 0; 10066 return 0;
9975 /* reprogram the HP pin as mic or HP according to the input source */ 10067 /* reprogram the HP pin as mic or HP according to the input source */
@@ -9986,8 +10078,8 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9986 { 10078 {
9987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9988 .name = "Capture Source", 10080 .name = "Capture Source",
9989 .info = alc882_mux_enum_info, 10081 .info = alc_mux_enum_info,
9990 .get = alc882_mux_enum_get, 10082 .get = alc_mux_enum_get,
9991 .put = alc262_ultra_mux_enum_put, 10083 .put = alc262_ultra_mux_enum_put,
9992 }, 10084 },
9993 { } /* end */ 10085 { } /* end */
@@ -10380,10 +10472,10 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10380 if (spec->autocfg.dig_in_pin) 10472 if (spec->autocfg.dig_in_pin)
10381 spec->dig_in_nid = ALC262_DIGIN_NID; 10473 spec->dig_in_nid = ALC262_DIGIN_NID;
10382 10474
10383 if (spec->kctl_alloc) 10475 if (spec->kctls.list)
10384 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 10476 add_mixer(spec, spec->kctls.list);
10385 10477
10386 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; 10478 add_verb(spec, alc262_volume_init_verbs);
10387 spec->num_mux_defs = 1; 10479 spec->num_mux_defs = 1;
10388 spec->input_mux = &spec->private_imux; 10480 spec->input_mux = &spec->private_imux;
10389 10481
@@ -10466,6 +10558,8 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
10466 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10558 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10467 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10559 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10468 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 10560 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
10561 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10562 ALC262_SONY_ASSAMD),
10469 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 10563 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10470 ALC262_TOSHIBA_RX1), 10564 ALC262_TOSHIBA_RX1),
10471 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), 10565 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
@@ -10624,7 +10718,8 @@ static struct alc_config_preset alc262_presets[] = {
10624 .init_hook = alc262_hippo_automute, 10718 .init_hook = alc262_hippo_automute,
10625 }, 10719 },
10626 [ALC262_ULTRA] = { 10720 [ALC262_ULTRA] = {
10627 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer }, 10721 .mixers = { alc262_ultra_mixer },
10722 .cap_mixer = alc262_ultra_capture_mixer,
10628 .init_verbs = { alc262_ultra_verbs }, 10723 .init_verbs = { alc262_ultra_verbs },
10629 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 10724 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10630 .dac_nids = alc262_dac_nids, 10725 .dac_nids = alc262_dac_nids,
@@ -10750,6 +10845,7 @@ static int patch_alc262(struct hda_codec *codec)
10750 spec->stream_digital_playback = &alc262_pcm_digital_playback; 10845 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10751 spec->stream_digital_capture = &alc262_pcm_digital_capture; 10846 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10752 10847
10848 spec->is_mix_capture = 1;
10753 if (!spec->adc_nids && spec->input_mux) { 10849 if (!spec->adc_nids && spec->input_mux) {
10754 /* check whether NID 0x07 is valid */ 10850 /* check whether NID 0x07 is valid */
10755 unsigned int wcap = get_wcaps(codec, 0x07); 10851 unsigned int wcap = get_wcaps(codec, 0x07);
@@ -10760,17 +10856,14 @@ static int patch_alc262(struct hda_codec *codec)
10760 spec->adc_nids = alc262_adc_nids_alt; 10856 spec->adc_nids = alc262_adc_nids_alt;
10761 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 10857 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
10762 spec->capsrc_nids = alc262_capsrc_nids_alt; 10858 spec->capsrc_nids = alc262_capsrc_nids_alt;
10763 spec->mixers[spec->num_mixers] =
10764 alc262_capture_alt_mixer;
10765 spec->num_mixers++;
10766 } else { 10859 } else {
10767 spec->adc_nids = alc262_adc_nids; 10860 spec->adc_nids = alc262_adc_nids;
10768 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); 10861 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
10769 spec->capsrc_nids = alc262_capsrc_nids; 10862 spec->capsrc_nids = alc262_capsrc_nids;
10770 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10771 spec->num_mixers++;
10772 } 10863 }
10773 } 10864 }
10865 if (!spec->cap_mixer)
10866 set_capture_mixer(spec);
10774 10867
10775 spec->vmaster_nid = 0x0c; 10868 spec->vmaster_nid = 0x0c;
10776 10869
@@ -10781,6 +10874,7 @@ static int patch_alc262(struct hda_codec *codec)
10781 if (!spec->loopback.amplist) 10874 if (!spec->loopback.amplist)
10782 spec->loopback.amplist = alc262_loopbacks; 10875 spec->loopback.amplist = alc262_loopbacks;
10783#endif 10876#endif
10877 codec->proc_widget_hook = print_realtek_coef;
10784 10878
10785 return 0; 10879 return 0;
10786} 10880}
@@ -10942,6 +11036,22 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = {
10942 { } 11036 { }
10943}; 11037};
10944 11038
11039static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11040 /* output mixer control */
11041 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11042 {
11043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11044 .name = "Master Playback Switch",
11045 .info = snd_hda_mixer_amp_switch_info,
11046 .get = snd_hda_mixer_amp_switch_get,
11047 .put = alc268_acer_master_sw_put,
11048 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11049 },
11050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11051 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11052 { }
11053};
11054
10945static struct hda_verb alc268_acer_aspire_one_verbs[] = { 11055static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10946 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 11056 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10947 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 11057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
@@ -11218,10 +11328,6 @@ static struct hda_verb alc268_volume_init_verbs[] = {
11218 { } 11328 { }
11219}; 11329};
11220 11330
11221#define alc268_mux_enum_info alc_mux_enum_info
11222#define alc268_mux_enum_get alc_mux_enum_get
11223#define alc268_mux_enum_put alc_mux_enum_put
11224
11225static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 11331static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11226 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 11332 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11227 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), 11333 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
@@ -11233,9 +11339,9 @@ static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11233 /* .name = "Capture Source", */ 11339 /* .name = "Capture Source", */
11234 .name = "Input Source", 11340 .name = "Input Source",
11235 .count = 1, 11341 .count = 1,
11236 .info = alc268_mux_enum_info, 11342 .info = alc_mux_enum_info,
11237 .get = alc268_mux_enum_get, 11343 .get = alc_mux_enum_get,
11238 .put = alc268_mux_enum_put, 11344 .put = alc_mux_enum_put,
11239 }, 11345 },
11240 { } /* end */ 11346 { } /* end */
11241}; 11347};
@@ -11253,9 +11359,9 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = {
11253 /* .name = "Capture Source", */ 11359 /* .name = "Capture Source", */
11254 .name = "Input Source", 11360 .name = "Input Source",
11255 .count = 2, 11361 .count = 2,
11256 .info = alc268_mux_enum_info, 11362 .info = alc_mux_enum_info,
11257 .get = alc268_mux_enum_get, 11363 .get = alc_mux_enum_get,
11258 .put = alc268_mux_enum_put, 11364 .put = alc_mux_enum_put,
11259 }, 11365 },
11260 { } /* end */ 11366 { } /* end */
11261}; 11367};
@@ -11274,6 +11380,15 @@ static struct hda_input_mux alc268_acer_capture_source = {
11274 .num_items = 3, 11380 .num_items = 3,
11275 .items = { 11381 .items = {
11276 { "Mic", 0x0 }, 11382 { "Mic", 0x0 },
11383 { "Internal Mic", 0x1 },
11384 { "Line", 0x2 },
11385 },
11386};
11387
11388static struct hda_input_mux alc268_acer_dmic_capture_source = {
11389 .num_items = 3,
11390 .items = {
11391 { "Mic", 0x0 },
11277 { "Internal Mic", 0x6 }, 11392 { "Internal Mic", 0x6 },
11278 { "Line", 0x2 }, 11393 { "Line", 0x2 },
11279 }, 11394 },
@@ -11512,13 +11627,13 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
11512 if (spec->autocfg.dig_out_pin) 11627 if (spec->autocfg.dig_out_pin)
11513 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; 11628 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11514 11629
11515 if (spec->kctl_alloc) 11630 if (spec->kctls.list)
11516 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 11631 add_mixer(spec, spec->kctls.list);
11517 11632
11518 if (spec->autocfg.speaker_pins[0] != 0x1d) 11633 if (spec->autocfg.speaker_pins[0] != 0x1d)
11519 spec->mixers[spec->num_mixers++] = alc268_beep_mixer; 11634 add_mixer(spec, alc268_beep_mixer);
11520 11635
11521 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; 11636 add_verb(spec, alc268_volume_init_verbs);
11522 spec->num_mux_defs = 1; 11637 spec->num_mux_defs = 1;
11523 spec->input_mux = &spec->private_imux; 11638 spec->input_mux = &spec->private_imux;
11524 11639
@@ -11554,6 +11669,7 @@ static const char *alc268_models[ALC268_MODEL_LAST] = {
11554 [ALC268_3ST] = "3stack", 11669 [ALC268_3ST] = "3stack",
11555 [ALC268_TOSHIBA] = "toshiba", 11670 [ALC268_TOSHIBA] = "toshiba",
11556 [ALC268_ACER] = "acer", 11671 [ALC268_ACER] = "acer",
11672 [ALC268_ACER_DMIC] = "acer-dmic",
11557 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", 11673 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
11558 [ALC268_DELL] = "dell", 11674 [ALC268_DELL] = "dell",
11559 [ALC268_ZEPTO] = "zepto", 11675 [ALC268_ZEPTO] = "zepto",
@@ -11649,6 +11765,23 @@ static struct alc_config_preset alc268_presets[] = {
11649 .unsol_event = alc268_acer_unsol_event, 11765 .unsol_event = alc268_acer_unsol_event,
11650 .init_hook = alc268_acer_init_hook, 11766 .init_hook = alc268_acer_init_hook,
11651 }, 11767 },
11768 [ALC268_ACER_DMIC] = {
11769 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11770 alc268_beep_mixer },
11771 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11772 alc268_acer_verbs },
11773 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11774 .dac_nids = alc268_dac_nids,
11775 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11776 .adc_nids = alc268_adc_nids_alt,
11777 .capsrc_nids = alc268_capsrc_nids,
11778 .hp_nid = 0x02,
11779 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11780 .channel_mode = alc268_modes,
11781 .input_mux = &alc268_acer_dmic_capture_source,
11782 .unsol_event = alc268_acer_unsol_event,
11783 .init_hook = alc268_acer_init_hook,
11784 },
11652 [ALC268_ACER_ASPIRE_ONE] = { 11785 [ALC268_ACER_ASPIRE_ONE] = {
11653 .mixers = { alc268_acer_aspire_one_mixer, 11786 .mixers = { alc268_acer_aspire_one_mixer,
11654 alc268_capture_alt_mixer }, 11787 alc268_capture_alt_mixer },
@@ -11787,15 +11920,11 @@ static int patch_alc268(struct hda_codec *codec)
11787 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { 11920 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
11788 spec->adc_nids = alc268_adc_nids_alt; 11921 spec->adc_nids = alc268_adc_nids_alt;
11789 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 11922 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11790 spec->mixers[spec->num_mixers] = 11923 add_mixer(spec, alc268_capture_alt_mixer);
11791 alc268_capture_alt_mixer;
11792 spec->num_mixers++;
11793 } else { 11924 } else {
11794 spec->adc_nids = alc268_adc_nids; 11925 spec->adc_nids = alc268_adc_nids;
11795 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); 11926 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11796 spec->mixers[spec->num_mixers] = 11927 add_mixer(spec, alc268_capture_mixer);
11797 alc268_capture_mixer;
11798 spec->num_mixers++;
11799 } 11928 }
11800 spec->capsrc_nids = alc268_capsrc_nids; 11929 spec->capsrc_nids = alc268_capsrc_nids;
11801 /* set default input source */ 11930 /* set default input source */
@@ -11811,6 +11940,8 @@ static int patch_alc268(struct hda_codec *codec)
11811 if (board_config == ALC268_AUTO) 11940 if (board_config == ALC268_AUTO)
11812 spec->init_hook = alc268_auto_init; 11941 spec->init_hook = alc268_auto_init;
11813 11942
11943 codec->proc_widget_hook = print_realtek_coef;
11944
11814 return 0; 11945 return 0;
11815} 11946}
11816 11947
@@ -11893,6 +12024,31 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11893 { } 12024 { }
11894}; 12025};
11895 12026
12027static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12028 /* output mixer control */
12029 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12030 {
12031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12032 .name = "Master Playback Switch",
12033 .info = snd_hda_mixer_amp_switch_info,
12034 .get = snd_hda_mixer_amp_switch_get,
12035 .put = alc268_acer_master_sw_put,
12036 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12037 },
12038 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12040 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12041 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12042 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12043 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12044 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12045 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12046 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12047 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12048 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12049 { }
12050};
12051
11896/* bind volumes of both NID 0x0c and 0x0d */ 12052/* bind volumes of both NID 0x0c and 0x0d */
11897static struct hda_bind_ctls alc269_epc_bind_vol = { 12053static struct hda_bind_ctls alc269_epc_bind_vol = {
11898 .ops = &snd_hda_bind_vol, 12054 .ops = &snd_hda_bind_vol,
@@ -11911,28 +12067,18 @@ static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11911}; 12067};
11912 12068
11913/* capture mixer elements */ 12069/* capture mixer elements */
11914static struct snd_kcontrol_new alc269_capture_mixer[] = { 12070static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11915 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12071 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11916 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12072 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11917 { 12073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11919 /* The multiple "Capture Source" controls confuse alsamixer
11920 * So call somewhat different..
11921 */
11922 /* .name = "Capture Source", */
11923 .name = "Input Source",
11924 .count = 1,
11925 .info = alc_mux_enum_info,
11926 .get = alc_mux_enum_get,
11927 .put = alc_mux_enum_put,
11928 },
11929 { } /* end */ 12074 { } /* end */
11930}; 12075};
11931 12076
11932/* capture mixer elements */ 12077/* FSC amilo */
11933static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { 12078static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
11934 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 12079 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11935 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 12080 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12081 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
11936 { } /* end */ 12082 { } /* end */
11937}; 12083};
11938 12084
@@ -11953,6 +12099,20 @@ static struct hda_verb alc269_quanta_fl1_verbs[] = {
11953 { } 12099 { }
11954}; 12100};
11955 12101
12102static struct hda_verb alc269_lifebook_verbs[] = {
12103 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12104 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12105 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12106 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12107 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12109 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12110 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12111 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12112 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12113 { }
12114};
12115
11956/* toggle speaker-output according to the hp-jack state */ 12116/* toggle speaker-output according to the hp-jack state */
11957static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) 12117static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11958{ 12118{
@@ -11978,6 +12138,37 @@ static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11978 AC_VERB_SET_PROC_COEF, 0x480); 12138 AC_VERB_SET_PROC_COEF, 0x480);
11979} 12139}
11980 12140
12141/* toggle speaker-output according to the hp-jacks state */
12142static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12143{
12144 unsigned int present;
12145 unsigned char bits;
12146
12147 /* Check laptop headphone socket */
12148 present = snd_hda_codec_read(codec, 0x15, 0,
12149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12150
12151 /* Check port replicator headphone socket */
12152 present |= snd_hda_codec_read(codec, 0x1a, 0,
12153 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12154
12155 bits = present ? AMP_IN_MUTE(0) : 0;
12156 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12157 AMP_IN_MUTE(0), bits);
12158 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12159 AMP_IN_MUTE(0), bits);
12160
12161 snd_hda_codec_write(codec, 0x20, 0,
12162 AC_VERB_SET_COEF_INDEX, 0x0c);
12163 snd_hda_codec_write(codec, 0x20, 0,
12164 AC_VERB_SET_PROC_COEF, 0x680);
12165
12166 snd_hda_codec_write(codec, 0x20, 0,
12167 AC_VERB_SET_COEF_INDEX, 0x0c);
12168 snd_hda_codec_write(codec, 0x20, 0,
12169 AC_VERB_SET_PROC_COEF, 0x480);
12170}
12171
11981static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) 12172static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11982{ 12173{
11983 unsigned int present; 12174 unsigned int present;
@@ -11988,6 +12179,29 @@ static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11988 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); 12179 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11989} 12180}
11990 12181
12182static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12183{
12184 unsigned int present_laptop;
12185 unsigned int present_dock;
12186
12187 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12188 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12189
12190 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12191 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12192
12193 /* Laptop mic port overrides dock mic port, design decision */
12194 if (present_dock)
12195 snd_hda_codec_write(codec, 0x23, 0,
12196 AC_VERB_SET_CONNECT_SEL, 0x3);
12197 if (present_laptop)
12198 snd_hda_codec_write(codec, 0x23, 0,
12199 AC_VERB_SET_CONNECT_SEL, 0x0);
12200 if (!present_dock && !present_laptop)
12201 snd_hda_codec_write(codec, 0x23, 0,
12202 AC_VERB_SET_CONNECT_SEL, 0x1);
12203}
12204
11991static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, 12205static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11992 unsigned int res) 12206 unsigned int res)
11993{ 12207{
@@ -11997,12 +12211,27 @@ static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11997 alc269_quanta_fl1_mic_automute(codec); 12211 alc269_quanta_fl1_mic_automute(codec);
11998} 12212}
11999 12213
12214static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12215 unsigned int res)
12216{
12217 if ((res >> 26) == ALC880_HP_EVENT)
12218 alc269_lifebook_speaker_automute(codec);
12219 if ((res >> 26) == ALC880_MIC_EVENT)
12220 alc269_lifebook_mic_autoswitch(codec);
12221}
12222
12000static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) 12223static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12001{ 12224{
12002 alc269_quanta_fl1_speaker_automute(codec); 12225 alc269_quanta_fl1_speaker_automute(codec);
12003 alc269_quanta_fl1_mic_automute(codec); 12226 alc269_quanta_fl1_mic_automute(codec);
12004} 12227}
12005 12228
12229static void alc269_lifebook_init_hook(struct hda_codec *codec)
12230{
12231 alc269_lifebook_speaker_automute(codec);
12232 alc269_lifebook_mic_autoswitch(codec);
12233}
12234
12006static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { 12235static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12236 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12008 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, 12237 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
@@ -12303,17 +12532,17 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12303 if (spec->autocfg.dig_out_pin) 12532 if (spec->autocfg.dig_out_pin)
12304 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; 12533 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12305 12534
12306 if (spec->kctl_alloc) 12535 if (spec->kctls.list)
12307 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 12536 add_mixer(spec, spec->kctls.list);
12308 12537
12309 /* create a beep mixer control if the pin 0x1d isn't assigned */ 12538 /* create a beep mixer control if the pin 0x1d isn't assigned */
12310 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++) 12539 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12311 if (spec->autocfg.input_pins[i] == 0x1d) 12540 if (spec->autocfg.input_pins[i] == 0x1d)
12312 break; 12541 break;
12313 if (i >= ARRAY_SIZE(spec->autocfg.input_pins)) 12542 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12314 spec->mixers[spec->num_mixers++] = alc269_beep_mixer; 12543 add_mixer(spec, alc269_beep_mixer);
12315 12544
12316 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs; 12545 add_verb(spec, alc269_init_verbs);
12317 spec->num_mux_defs = 1; 12546 spec->num_mux_defs = 1;
12318 spec->input_mux = &spec->private_imux; 12547 spec->input_mux = &spec->private_imux;
12319 /* set default input source */ 12548 /* set default input source */
@@ -12325,8 +12554,8 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12325 if (err < 0) 12554 if (err < 0)
12326 return err; 12555 return err;
12327 12556
12328 spec->mixers[spec->num_mixers] = alc269_capture_mixer; 12557 if (!spec->cap_mixer)
12329 spec->num_mixers++; 12558 set_capture_mixer(spec);
12330 12559
12331 store_pin_configs(codec); 12560 store_pin_configs(codec);
12332 return 1; 12561 return 1;
@@ -12355,7 +12584,9 @@ static const char *alc269_models[ALC269_MODEL_LAST] = {
12355 [ALC269_BASIC] = "basic", 12584 [ALC269_BASIC] = "basic",
12356 [ALC269_QUANTA_FL1] = "quanta", 12585 [ALC269_QUANTA_FL1] = "quanta",
12357 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", 12586 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12358 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901" 12587 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
12588 [ALC269_FUJITSU] = "fujitsu",
12589 [ALC269_LIFEBOOK] = "lifebook"
12359}; 12590};
12360 12591
12361static struct snd_pci_quirk alc269_cfg_tbl[] = { 12592static struct snd_pci_quirk alc269_cfg_tbl[] = {
@@ -12366,12 +12597,14 @@ static struct snd_pci_quirk alc269_cfg_tbl[] = {
12366 ALC269_ASUS_EEEPC_P901), 12597 ALC269_ASUS_EEEPC_P901),
12367 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", 12598 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12368 ALC269_ASUS_EEEPC_P901), 12599 ALC269_ASUS_EEEPC_P901),
12600 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
12601 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
12369 {} 12602 {}
12370}; 12603};
12371 12604
12372static struct alc_config_preset alc269_presets[] = { 12605static struct alc_config_preset alc269_presets[] = {
12373 [ALC269_BASIC] = { 12606 [ALC269_BASIC] = {
12374 .mixers = { alc269_base_mixer, alc269_capture_mixer }, 12607 .mixers = { alc269_base_mixer },
12375 .init_verbs = { alc269_init_verbs }, 12608 .init_verbs = { alc269_init_verbs },
12376 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12609 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12377 .dac_nids = alc269_dac_nids, 12610 .dac_nids = alc269_dac_nids,
@@ -12393,7 +12626,8 @@ static struct alc_config_preset alc269_presets[] = {
12393 .init_hook = alc269_quanta_fl1_init_hook, 12626 .init_hook = alc269_quanta_fl1_init_hook,
12394 }, 12627 },
12395 [ALC269_ASUS_EEEPC_P703] = { 12628 [ALC269_ASUS_EEEPC_P703] = {
12396 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer }, 12629 .mixers = { alc269_eeepc_mixer },
12630 .cap_mixer = alc269_epc_capture_mixer,
12397 .init_verbs = { alc269_init_verbs, 12631 .init_verbs = { alc269_init_verbs,
12398 alc269_eeepc_amic_init_verbs }, 12632 alc269_eeepc_amic_init_verbs },
12399 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12633 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
@@ -12406,7 +12640,8 @@ static struct alc_config_preset alc269_presets[] = {
12406 .init_hook = alc269_eeepc_amic_inithook, 12640 .init_hook = alc269_eeepc_amic_inithook,
12407 }, 12641 },
12408 [ALC269_ASUS_EEEPC_P901] = { 12642 [ALC269_ASUS_EEEPC_P901] = {
12409 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer}, 12643 .mixers = { alc269_eeepc_mixer },
12644 .cap_mixer = alc269_epc_capture_mixer,
12410 .init_verbs = { alc269_init_verbs, 12645 .init_verbs = { alc269_init_verbs,
12411 alc269_eeepc_dmic_init_verbs }, 12646 alc269_eeepc_dmic_init_verbs },
12412 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 12647 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
@@ -12418,6 +12653,32 @@ static struct alc_config_preset alc269_presets[] = {
12418 .unsol_event = alc269_eeepc_dmic_unsol_event, 12653 .unsol_event = alc269_eeepc_dmic_unsol_event,
12419 .init_hook = alc269_eeepc_dmic_inithook, 12654 .init_hook = alc269_eeepc_dmic_inithook,
12420 }, 12655 },
12656 [ALC269_FUJITSU] = {
12657 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12658 .cap_mixer = alc269_epc_capture_mixer,
12659 .init_verbs = { alc269_init_verbs,
12660 alc269_eeepc_dmic_init_verbs },
12661 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12662 .dac_nids = alc269_dac_nids,
12663 .hp_nid = 0x03,
12664 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12665 .channel_mode = alc269_modes,
12666 .input_mux = &alc269_eeepc_dmic_capture_source,
12667 .unsol_event = alc269_eeepc_dmic_unsol_event,
12668 .init_hook = alc269_eeepc_dmic_inithook,
12669 },
12670 [ALC269_LIFEBOOK] = {
12671 .mixers = { alc269_lifebook_mixer },
12672 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12673 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12674 .dac_nids = alc269_dac_nids,
12675 .hp_nid = 0x03,
12676 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12677 .channel_mode = alc269_modes,
12678 .input_mux = &alc269_capture_source,
12679 .unsol_event = alc269_lifebook_unsol_event,
12680 .init_hook = alc269_lifebook_init_hook,
12681 },
12421}; 12682};
12422 12683
12423static int patch_alc269(struct hda_codec *codec) 12684static int patch_alc269(struct hda_codec *codec)
@@ -12472,6 +12733,8 @@ static int patch_alc269(struct hda_codec *codec)
12472 spec->adc_nids = alc269_adc_nids; 12733 spec->adc_nids = alc269_adc_nids;
12473 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 12734 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
12474 spec->capsrc_nids = alc269_capsrc_nids; 12735 spec->capsrc_nids = alc269_capsrc_nids;
12736 if (!spec->cap_mixer)
12737 set_capture_mixer(spec);
12475 12738
12476 codec->patch_ops = alc_patch_ops; 12739 codec->patch_ops = alc_patch_ops;
12477 if (board_config == ALC269_AUTO) 12740 if (board_config == ALC269_AUTO)
@@ -12480,6 +12743,7 @@ static int patch_alc269(struct hda_codec *codec)
12480 if (!spec->loopback.amplist) 12743 if (!spec->loopback.amplist)
12481 spec->loopback.amplist = alc269_loopbacks; 12744 spec->loopback.amplist = alc269_loopbacks;
12482#endif 12745#endif
12746 codec->proc_widget_hook = print_realtek_coef;
12483 12747
12484 return 0; 12748 return 0;
12485} 12749}
@@ -12612,17 +12876,6 @@ static struct snd_kcontrol_new alc861_base_mixer[] = {
12612 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12613 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 12877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
12614 12878
12615 /* Capture mixer control */
12616 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12617 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12618 {
12619 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12620 .name = "Capture Source",
12621 .count = 1,
12622 .info = alc_mux_enum_info,
12623 .get = alc_mux_enum_get,
12624 .put = alc_mux_enum_put,
12625 },
12626 { } /* end */ 12879 { } /* end */
12627}; 12880};
12628 12881
@@ -12646,17 +12899,6 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12646 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12899 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12647 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 12900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
12648 12901
12649 /* Capture mixer control */
12650 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12651 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12652 {
12653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12654 .name = "Capture Source",
12655 .count = 1,
12656 .info = alc_mux_enum_info,
12657 .get = alc_mux_enum_get,
12658 .put = alc_mux_enum_put,
12659 },
12660 { 12902 {
12661 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12662 .name = "Channel Mode", 12904 .name = "Channel Mode",
@@ -12674,18 +12916,6 @@ static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
12674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 12916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12675 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 12917 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12676 12918
12677 /*Capture mixer control */
12678 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12679 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12680 {
12681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12682 .name = "Capture Source",
12683 .count = 1,
12684 .info = alc_mux_enum_info,
12685 .get = alc_mux_enum_get,
12686 .put = alc_mux_enum_put,
12687 },
12688
12689 { } /* end */ 12919 { } /* end */
12690}; 12920};
12691 12921
@@ -12709,17 +12939,6 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 12940 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
12711 12941
12712 /* Capture mixer control */
12713 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12714 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12715 {
12716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12717 .name = "Capture Source",
12718 .count = 1,
12719 .info = alc_mux_enum_info,
12720 .get = alc_mux_enum_get,
12721 .put = alc_mux_enum_put,
12722 },
12723 { 12942 {
12724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12725 .name = "Channel Mode", 12944 .name = "Channel Mode",
@@ -12751,17 +12970,6 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
12751 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 12970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), 12971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12753 12972
12754 /* Capture mixer control */
12755 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12756 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12757 {
12758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12759 .name = "Capture Source",
12760 .count = 1,
12761 .info = alc_mux_enum_info,
12762 .get = alc_mux_enum_get,
12763 .put = alc_mux_enum_put,
12764 },
12765 { 12973 {
12766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12767 .name = "Channel Mode", 12975 .name = "Channel Mode",
@@ -13293,25 +13501,6 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13293 return 0; 13501 return 0;
13294} 13502}
13295 13503
13296static struct snd_kcontrol_new alc861_capture_mixer[] = {
13297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13299
13300 {
13301 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13302 /* The multiple "Capture Source" controls confuse alsamixer
13303 * So call somewhat different..
13304 */
13305 /* .name = "Capture Source", */
13306 .name = "Input Source",
13307 .count = 1,
13308 .info = alc_mux_enum_info,
13309 .get = alc_mux_enum_get,
13310 .put = alc_mux_enum_put,
13311 },
13312 { } /* end */
13313};
13314
13315static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, 13504static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13316 hda_nid_t nid, 13505 hda_nid_t nid,
13317 int pin_type, int dac_idx) 13506 int pin_type, int dac_idx)
@@ -13402,18 +13591,17 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
13402 if (spec->autocfg.dig_out_pin) 13591 if (spec->autocfg.dig_out_pin)
13403 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; 13592 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13404 13593
13405 if (spec->kctl_alloc) 13594 if (spec->kctls.list)
13406 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 13595 add_mixer(spec, spec->kctls.list);
13407 13596
13408 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; 13597 add_verb(spec, alc861_auto_init_verbs);
13409 13598
13410 spec->num_mux_defs = 1; 13599 spec->num_mux_defs = 1;
13411 spec->input_mux = &spec->private_imux; 13600 spec->input_mux = &spec->private_imux;
13412 13601
13413 spec->adc_nids = alc861_adc_nids; 13602 spec->adc_nids = alc861_adc_nids;
13414 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 13603 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13415 spec->mixers[spec->num_mixers] = alc861_capture_mixer; 13604 set_capture_mixer(spec);
13416 spec->num_mixers++;
13417 13605
13418 store_pin_configs(codec); 13606 store_pin_configs(codec);
13419 return 1; 13607 return 1;
@@ -13644,6 +13832,7 @@ static int patch_alc861(struct hda_codec *codec)
13644 if (!spec->loopback.amplist) 13832 if (!spec->loopback.amplist)
13645 spec->loopback.amplist = alc861_loopbacks; 13833 spec->loopback.amplist = alc861_loopbacks;
13646#endif 13834#endif
13835 codec->proc_widget_hook = print_realtek_coef;
13647 13836
13648 return 0; 13837 return 0;
13649} 13838}
@@ -13709,11 +13898,6 @@ static struct hda_input_mux alc861vd_hp_capture_source = {
13709 }, 13898 },
13710}; 13899};
13711 13900
13712#define alc861vd_mux_enum_info alc_mux_enum_info
13713#define alc861vd_mux_enum_get alc_mux_enum_get
13714/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13715#define alc861vd_mux_enum_put alc882_mux_enum_put
13716
13717/* 13901/*
13718 * 2ch mode 13902 * 2ch mode
13719 */ 13903 */
@@ -13759,25 +13943,6 @@ static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13759 { } /* end */ 13943 { } /* end */
13760}; 13944};
13761 13945
13762static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13763 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13764 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13765
13766 {
13767 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13768 /* The multiple "Capture Source" controls confuse alsamixer
13769 * So call somewhat different..
13770 */
13771 /* .name = "Capture Source", */
13772 .name = "Input Source",
13773 .count = 1,
13774 .info = alc861vd_mux_enum_info,
13775 .get = alc861vd_mux_enum_get,
13776 .put = alc861vd_mux_enum_put,
13777 },
13778 { } /* end */
13779};
13780
13781/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 13946/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13782 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 13947 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13783 */ 13948 */
@@ -14169,6 +14334,7 @@ static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int re
14169static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { 14334static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14170 [ALC660VD_3ST] = "3stack-660", 14335 [ALC660VD_3ST] = "3stack-660",
14171 [ALC660VD_3ST_DIG] = "3stack-660-digout", 14336 [ALC660VD_3ST_DIG] = "3stack-660-digout",
14337 [ALC660VD_ASUS_V1S] = "asus-v1s",
14172 [ALC861VD_3ST] = "3stack", 14338 [ALC861VD_3ST] = "3stack",
14173 [ALC861VD_3ST_DIG] = "3stack-digout", 14339 [ALC861VD_3ST_DIG] = "3stack-digout",
14174 [ALC861VD_6ST_DIG] = "6stack-digout", 14340 [ALC861VD_6ST_DIG] = "6stack-digout",
@@ -14183,7 +14349,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
14183 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), 14349 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
14184 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), 14350 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
14185 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 14351 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
14186 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO), 14352 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
14187 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), 14353 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
14188 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 14354 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
14189 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 14355 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
@@ -14290,6 +14456,21 @@ static struct alc_config_preset alc861vd_presets[] = {
14290 .unsol_event = alc861vd_dallas_unsol_event, 14456 .unsol_event = alc861vd_dallas_unsol_event,
14291 .init_hook = alc861vd_dallas_automute, 14457 .init_hook = alc861vd_dallas_automute,
14292 }, 14458 },
14459 [ALC660VD_ASUS_V1S] = {
14460 .mixers = { alc861vd_lenovo_mixer },
14461 .init_verbs = { alc861vd_volume_init_verbs,
14462 alc861vd_3stack_init_verbs,
14463 alc861vd_eapd_verbs,
14464 alc861vd_lenovo_unsol_verbs },
14465 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14466 .dac_nids = alc660vd_dac_nids,
14467 .dig_out_nid = ALC861VD_DIGOUT_NID,
14468 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14469 .channel_mode = alc861vd_3stack_2ch_modes,
14470 .input_mux = &alc861vd_capture_source,
14471 .unsol_event = alc861vd_lenovo_unsol_event,
14472 .init_hook = alc861vd_lenovo_automute,
14473 },
14293}; 14474};
14294 14475
14295/* 14476/*
@@ -14514,11 +14695,10 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
14514 if (spec->autocfg.dig_out_pin) 14695 if (spec->autocfg.dig_out_pin)
14515 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; 14696 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14516 14697
14517 if (spec->kctl_alloc) 14698 if (spec->kctls.list)
14518 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 14699 add_mixer(spec, spec->kctls.list);
14519 14700
14520 spec->init_verbs[spec->num_init_verbs++] 14701 add_verb(spec, alc861vd_volume_init_verbs);
14521 = alc861vd_volume_init_verbs;
14522 14702
14523 spec->num_mux_defs = 1; 14703 spec->num_mux_defs = 1;
14524 spec->input_mux = &spec->private_imux; 14704 spec->input_mux = &spec->private_imux;
@@ -14585,7 +14765,7 @@ static int patch_alc861vd(struct hda_codec *codec)
14585 spec->stream_name_analog = "ALC660-VD Analog"; 14765 spec->stream_name_analog = "ALC660-VD Analog";
14586 spec->stream_name_digital = "ALC660-VD Digital"; 14766 spec->stream_name_digital = "ALC660-VD Digital";
14587 /* always turn on EAPD */ 14767 /* always turn on EAPD */
14588 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs; 14768 add_verb(spec, alc660vd_eapd_verbs);
14589 } else { 14769 } else {
14590 spec->stream_name_analog = "ALC861VD Analog"; 14770 spec->stream_name_analog = "ALC861VD Analog";
14591 spec->stream_name_digital = "ALC861VD Digital"; 14771 spec->stream_name_digital = "ALC861VD Digital";
@@ -14600,9 +14780,9 @@ static int patch_alc861vd(struct hda_codec *codec)
14600 spec->adc_nids = alc861vd_adc_nids; 14780 spec->adc_nids = alc861vd_adc_nids;
14601 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 14781 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
14602 spec->capsrc_nids = alc861vd_capsrc_nids; 14782 spec->capsrc_nids = alc861vd_capsrc_nids;
14783 spec->is_mix_capture = 1;
14603 14784
14604 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; 14785 set_capture_mixer(spec);
14605 spec->num_mixers++;
14606 14786
14607 spec->vmaster_nid = 0x02; 14787 spec->vmaster_nid = 0x02;
14608 14788
@@ -14614,6 +14794,7 @@ static int patch_alc861vd(struct hda_codec *codec)
14614 if (!spec->loopback.amplist) 14794 if (!spec->loopback.amplist)
14615 spec->loopback.amplist = alc861vd_loopbacks; 14795 spec->loopback.amplist = alc861vd_loopbacks;
14616#endif 14796#endif
14797 codec->proc_widget_hook = print_realtek_coef;
14617 14798
14618 return 0; 14799 return 0;
14619} 14800}
@@ -14689,10 +14870,6 @@ static struct hda_input_mux alc663_m51va_capture_source = {
14689 }, 14870 },
14690}; 14871};
14691 14872
14692#define alc662_mux_enum_info alc_mux_enum_info
14693#define alc662_mux_enum_get alc_mux_enum_get
14694#define alc662_mux_enum_put alc882_mux_enum_put
14695
14696/* 14873/*
14697 * 2ch mode 14874 * 2ch mode
14698 */ 14875 */
@@ -15278,25 +15455,6 @@ static struct hda_verb alc662_ecs_init_verbs[] = {
15278 {} 15455 {}
15279}; 15456};
15280 15457
15281/* capture mixer elements */
15282static struct snd_kcontrol_new alc662_capture_mixer[] = {
15283 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15284 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15285 {
15286 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15287 /* The multiple "Capture Source" controls confuse alsamixer
15288 * So call somewhat different..
15289 */
15290 /* .name = "Capture Source", */
15291 .name = "Input Source",
15292 .count = 1,
15293 .info = alc662_mux_enum_info,
15294 .get = alc662_mux_enum_get,
15295 .put = alc662_mux_enum_put,
15296 },
15297 { } /* end */
15298};
15299
15300static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { 15458static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15301 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), 15459 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15302 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), 15460 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
@@ -15868,7 +16026,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
15868 16026
15869static struct alc_config_preset alc662_presets[] = { 16027static struct alc_config_preset alc662_presets[] = {
15870 [ALC662_3ST_2ch_DIG] = { 16028 [ALC662_3ST_2ch_DIG] = {
15871 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, 16029 .mixers = { alc662_3ST_2ch_mixer },
15872 .init_verbs = { alc662_init_verbs }, 16030 .init_verbs = { alc662_init_verbs },
15873 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16031 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15874 .dac_nids = alc662_dac_nids, 16032 .dac_nids = alc662_dac_nids,
@@ -15879,8 +16037,7 @@ static struct alc_config_preset alc662_presets[] = {
15879 .input_mux = &alc662_capture_source, 16037 .input_mux = &alc662_capture_source,
15880 }, 16038 },
15881 [ALC662_3ST_6ch_DIG] = { 16039 [ALC662_3ST_6ch_DIG] = {
15882 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, 16040 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
15883 alc662_capture_mixer },
15884 .init_verbs = { alc662_init_verbs }, 16041 .init_verbs = { alc662_init_verbs },
15885 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16042 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15886 .dac_nids = alc662_dac_nids, 16043 .dac_nids = alc662_dac_nids,
@@ -15892,8 +16049,7 @@ static struct alc_config_preset alc662_presets[] = {
15892 .input_mux = &alc662_capture_source, 16049 .input_mux = &alc662_capture_source,
15893 }, 16050 },
15894 [ALC662_3ST_6ch] = { 16051 [ALC662_3ST_6ch] = {
15895 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, 16052 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
15896 alc662_capture_mixer },
15897 .init_verbs = { alc662_init_verbs }, 16053 .init_verbs = { alc662_init_verbs },
15898 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16054 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15899 .dac_nids = alc662_dac_nids, 16055 .dac_nids = alc662_dac_nids,
@@ -15903,8 +16059,7 @@ static struct alc_config_preset alc662_presets[] = {
15903 .input_mux = &alc662_capture_source, 16059 .input_mux = &alc662_capture_source,
15904 }, 16060 },
15905 [ALC662_5ST_DIG] = { 16061 [ALC662_5ST_DIG] = {
15906 .mixers = { alc662_base_mixer, alc662_chmode_mixer, 16062 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
15907 alc662_capture_mixer },
15908 .init_verbs = { alc662_init_verbs }, 16063 .init_verbs = { alc662_init_verbs },
15909 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16064 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15910 .dac_nids = alc662_dac_nids, 16065 .dac_nids = alc662_dac_nids,
@@ -15915,7 +16070,7 @@ static struct alc_config_preset alc662_presets[] = {
15915 .input_mux = &alc662_capture_source, 16070 .input_mux = &alc662_capture_source,
15916 }, 16071 },
15917 [ALC662_LENOVO_101E] = { 16072 [ALC662_LENOVO_101E] = {
15918 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, 16073 .mixers = { alc662_lenovo_101e_mixer },
15919 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, 16074 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15920 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16075 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15921 .dac_nids = alc662_dac_nids, 16076 .dac_nids = alc662_dac_nids,
@@ -15926,7 +16081,7 @@ static struct alc_config_preset alc662_presets[] = {
15926 .init_hook = alc662_lenovo_101e_all_automute, 16081 .init_hook = alc662_lenovo_101e_all_automute,
15927 }, 16082 },
15928 [ALC662_ASUS_EEEPC_P701] = { 16083 [ALC662_ASUS_EEEPC_P701] = {
15929 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, 16084 .mixers = { alc662_eeepc_p701_mixer },
15930 .init_verbs = { alc662_init_verbs, 16085 .init_verbs = { alc662_init_verbs,
15931 alc662_eeepc_sue_init_verbs }, 16086 alc662_eeepc_sue_init_verbs },
15932 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16087 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -15938,7 +16093,7 @@ static struct alc_config_preset alc662_presets[] = {
15938 .init_hook = alc662_eeepc_inithook, 16093 .init_hook = alc662_eeepc_inithook,
15939 }, 16094 },
15940 [ALC662_ASUS_EEEPC_EP20] = { 16095 [ALC662_ASUS_EEEPC_EP20] = {
15941 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer, 16096 .mixers = { alc662_eeepc_ep20_mixer,
15942 alc662_chmode_mixer }, 16097 alc662_chmode_mixer },
15943 .init_verbs = { alc662_init_verbs, 16098 .init_verbs = { alc662_init_verbs,
15944 alc662_eeepc_ep20_sue_init_verbs }, 16099 alc662_eeepc_ep20_sue_init_verbs },
@@ -15951,7 +16106,7 @@ static struct alc_config_preset alc662_presets[] = {
15951 .init_hook = alc662_eeepc_ep20_inithook, 16106 .init_hook = alc662_eeepc_ep20_inithook,
15952 }, 16107 },
15953 [ALC662_ECS] = { 16108 [ALC662_ECS] = {
15954 .mixers = { alc662_ecs_mixer, alc662_capture_mixer }, 16109 .mixers = { alc662_ecs_mixer },
15955 .init_verbs = { alc662_init_verbs, 16110 .init_verbs = { alc662_init_verbs,
15956 alc662_ecs_init_verbs }, 16111 alc662_ecs_init_verbs },
15957 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16112 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -15963,7 +16118,7 @@ static struct alc_config_preset alc662_presets[] = {
15963 .init_hook = alc662_eeepc_inithook, 16118 .init_hook = alc662_eeepc_inithook,
15964 }, 16119 },
15965 [ALC663_ASUS_M51VA] = { 16120 [ALC663_ASUS_M51VA] = {
15966 .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, 16121 .mixers = { alc663_m51va_mixer },
15967 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, 16122 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15968 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16123 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15969 .dac_nids = alc662_dac_nids, 16124 .dac_nids = alc662_dac_nids,
@@ -15975,7 +16130,7 @@ static struct alc_config_preset alc662_presets[] = {
15975 .init_hook = alc663_m51va_inithook, 16130 .init_hook = alc663_m51va_inithook,
15976 }, 16131 },
15977 [ALC663_ASUS_G71V] = { 16132 [ALC663_ASUS_G71V] = {
15978 .mixers = { alc663_g71v_mixer, alc662_capture_mixer}, 16133 .mixers = { alc663_g71v_mixer },
15979 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, 16134 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15980 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16135 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15981 .dac_nids = alc662_dac_nids, 16136 .dac_nids = alc662_dac_nids,
@@ -15987,7 +16142,7 @@ static struct alc_config_preset alc662_presets[] = {
15987 .init_hook = alc663_g71v_inithook, 16142 .init_hook = alc663_g71v_inithook,
15988 }, 16143 },
15989 [ALC663_ASUS_H13] = { 16144 [ALC663_ASUS_H13] = {
15990 .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, 16145 .mixers = { alc663_m51va_mixer },
15991 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, 16146 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15992 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16147 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15993 .dac_nids = alc662_dac_nids, 16148 .dac_nids = alc662_dac_nids,
@@ -15998,7 +16153,7 @@ static struct alc_config_preset alc662_presets[] = {
15998 .init_hook = alc663_m51va_inithook, 16153 .init_hook = alc663_m51va_inithook,
15999 }, 16154 },
16000 [ALC663_ASUS_G50V] = { 16155 [ALC663_ASUS_G50V] = {
16001 .mixers = { alc663_g50v_mixer, alc662_capture_mixer}, 16156 .mixers = { alc663_g50v_mixer },
16002 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, 16157 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16003 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16158 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16004 .dac_nids = alc662_dac_nids, 16159 .dac_nids = alc662_dac_nids,
@@ -16010,7 +16165,8 @@ static struct alc_config_preset alc662_presets[] = {
16010 .init_hook = alc663_g50v_inithook, 16165 .init_hook = alc663_g50v_inithook,
16011 }, 16166 },
16012 [ALC663_ASUS_MODE1] = { 16167 [ALC663_ASUS_MODE1] = {
16013 .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer }, 16168 .mixers = { alc663_m51va_mixer },
16169 .cap_mixer = alc662_auto_capture_mixer,
16014 .init_verbs = { alc662_init_verbs, 16170 .init_verbs = { alc662_init_verbs,
16015 alc663_21jd_amic_init_verbs }, 16171 alc663_21jd_amic_init_verbs },
16016 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16172 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -16024,7 +16180,8 @@ static struct alc_config_preset alc662_presets[] = {
16024 .init_hook = alc663_mode1_inithook, 16180 .init_hook = alc663_mode1_inithook,
16025 }, 16181 },
16026 [ALC662_ASUS_MODE2] = { 16182 [ALC662_ASUS_MODE2] = {
16027 .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer }, 16183 .mixers = { alc662_1bjd_mixer },
16184 .cap_mixer = alc662_auto_capture_mixer,
16028 .init_verbs = { alc662_init_verbs, 16185 .init_verbs = { alc662_init_verbs,
16029 alc662_1bjd_amic_init_verbs }, 16186 alc662_1bjd_amic_init_verbs },
16030 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16187 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -16037,7 +16194,8 @@ static struct alc_config_preset alc662_presets[] = {
16037 .init_hook = alc662_mode2_inithook, 16194 .init_hook = alc662_mode2_inithook,
16038 }, 16195 },
16039 [ALC663_ASUS_MODE3] = { 16196 [ALC663_ASUS_MODE3] = {
16040 .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer }, 16197 .mixers = { alc663_two_hp_m1_mixer },
16198 .cap_mixer = alc662_auto_capture_mixer,
16041 .init_verbs = { alc662_init_verbs, 16199 .init_verbs = { alc662_init_verbs,
16042 alc663_two_hp_amic_m1_init_verbs }, 16200 alc663_two_hp_amic_m1_init_verbs },
16043 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16201 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -16051,8 +16209,8 @@ static struct alc_config_preset alc662_presets[] = {
16051 .init_hook = alc663_mode3_inithook, 16209 .init_hook = alc663_mode3_inithook,
16052 }, 16210 },
16053 [ALC663_ASUS_MODE4] = { 16211 [ALC663_ASUS_MODE4] = {
16054 .mixers = { alc663_asus_21jd_clfe_mixer, 16212 .mixers = { alc663_asus_21jd_clfe_mixer },
16055 alc662_auto_capture_mixer}, 16213 .cap_mixer = alc662_auto_capture_mixer,
16056 .init_verbs = { alc662_init_verbs, 16214 .init_verbs = { alc662_init_verbs,
16057 alc663_21jd_amic_init_verbs}, 16215 alc663_21jd_amic_init_verbs},
16058 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16216 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -16066,8 +16224,8 @@ static struct alc_config_preset alc662_presets[] = {
16066 .init_hook = alc663_mode4_inithook, 16224 .init_hook = alc663_mode4_inithook,
16067 }, 16225 },
16068 [ALC663_ASUS_MODE5] = { 16226 [ALC663_ASUS_MODE5] = {
16069 .mixers = { alc663_asus_15jd_clfe_mixer, 16227 .mixers = { alc663_asus_15jd_clfe_mixer },
16070 alc662_auto_capture_mixer }, 16228 .cap_mixer = alc662_auto_capture_mixer,
16071 .init_verbs = { alc662_init_verbs, 16229 .init_verbs = { alc662_init_verbs,
16072 alc663_15jd_amic_init_verbs }, 16230 alc663_15jd_amic_init_verbs },
16073 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16231 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -16081,7 +16239,8 @@ static struct alc_config_preset alc662_presets[] = {
16081 .init_hook = alc663_mode5_inithook, 16239 .init_hook = alc663_mode5_inithook,
16082 }, 16240 },
16083 [ALC663_ASUS_MODE6] = { 16241 [ALC663_ASUS_MODE6] = {
16084 .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer }, 16242 .mixers = { alc663_two_hp_m2_mixer },
16243 .cap_mixer = alc662_auto_capture_mixer,
16085 .init_verbs = { alc662_init_verbs, 16244 .init_verbs = { alc662_init_verbs,
16086 alc663_two_hp_amic_m2_init_verbs }, 16245 alc663_two_hp_amic_m2_init_verbs },
16087 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 16246 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
@@ -16342,24 +16501,20 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
16342 if (spec->autocfg.dig_out_pin) 16501 if (spec->autocfg.dig_out_pin)
16343 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 16502 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16344 16503
16345 if (spec->kctl_alloc) 16504 if (spec->kctls.list)
16346 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 16505 add_mixer(spec, spec->kctls.list);
16347 16506
16348 spec->num_mux_defs = 1; 16507 spec->num_mux_defs = 1;
16349 spec->input_mux = &spec->private_imux; 16508 spec->input_mux = &spec->private_imux;
16350 16509
16351 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; 16510 add_verb(spec, alc662_auto_init_verbs);
16352 if (codec->vendor_id == 0x10ec0663) 16511 if (codec->vendor_id == 0x10ec0663)
16353 spec->init_verbs[spec->num_init_verbs++] = 16512 add_verb(spec, alc663_auto_init_verbs);
16354 alc663_auto_init_verbs;
16355 16513
16356 err = alc_auto_add_mic_boost(codec); 16514 err = alc_auto_add_mic_boost(codec);
16357 if (err < 0) 16515 if (err < 0)
16358 return err; 16516 return err;
16359 16517
16360 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
16361 spec->num_mixers++;
16362
16363 store_pin_configs(codec); 16518 store_pin_configs(codec);
16364 return 1; 16519 return 1;
16365} 16520}
@@ -16435,6 +16590,10 @@ static int patch_alc662(struct hda_codec *codec)
16435 spec->adc_nids = alc662_adc_nids; 16590 spec->adc_nids = alc662_adc_nids;
16436 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 16591 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16437 spec->capsrc_nids = alc662_capsrc_nids; 16592 spec->capsrc_nids = alc662_capsrc_nids;
16593 spec->is_mix_capture = 1;
16594
16595 if (!spec->cap_mixer)
16596 set_capture_mixer(spec);
16438 16597
16439 spec->vmaster_nid = 0x02; 16598 spec->vmaster_nid = 0x02;
16440 16599
@@ -16445,6 +16604,7 @@ static int patch_alc662(struct hda_codec *codec)
16445 if (!spec->loopback.amplist) 16604 if (!spec->loopback.amplist)
16446 spec->loopback.amplist = alc662_loopbacks; 16605 spec->loopback.amplist = alc662_loopbacks;
16447#endif 16606#endif
16607 codec->proc_widget_hook = print_realtek_coef;
16448 16608
16449 return 0; 16609 return 0;
16450} 16610}
@@ -16452,7 +16612,7 @@ static int patch_alc662(struct hda_codec *codec)
16452/* 16612/*
16453 * patch entries 16613 * patch entries
16454 */ 16614 */
16455struct hda_codec_preset snd_hda_preset_realtek[] = { 16615static struct hda_codec_preset snd_hda_preset_realtek[] = {
16456 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 16616 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
16457 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 16617 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
16458 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 16618 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
@@ -16484,3 +16644,26 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
16484 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 16644 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
16485 {} /* terminator */ 16645 {} /* terminator */
16486}; 16646};
16647
16648MODULE_ALIAS("snd-hda-codec-id:10ec*");
16649
16650MODULE_LICENSE("GPL");
16651MODULE_DESCRIPTION("Realtek HD-audio codec");
16652
16653static struct hda_codec_preset_list realtek_list = {
16654 .preset = snd_hda_preset_realtek,
16655 .owner = THIS_MODULE,
16656};
16657
16658static int __init patch_realtek_init(void)
16659{
16660 return snd_hda_add_codec_preset(&realtek_list);
16661}
16662
16663static void __exit patch_realtek_exit(void)
16664{
16665 snd_hda_delete_codec_preset(&realtek_list);
16666}
16667
16668module_init(patch_realtek_init)
16669module_exit(patch_realtek_exit)
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 9332b63e406c..43b436c5d01b 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -28,7 +28,6 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_patch.h"
32 31
33/* si3054 verbs */ 32/* si3054 verbs */
34#define SI3054_VERB_READ_NODE 0x900 33#define SI3054_VERB_READ_NODE 0x900
@@ -283,7 +282,7 @@ static int patch_si3054(struct hda_codec *codec)
283/* 282/*
284 * patch entries 283 * patch entries
285 */ 284 */
286struct hda_codec_preset snd_hda_preset_si3054[] = { 285static struct hda_codec_preset snd_hda_preset_si3054[] = {
287 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 }, 286 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 },
288 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 }, 287 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 },
289 { .id = 0x11c13026, .name = "Si3054", .patch = patch_si3054 }, 288 { .id = 0x11c13026, .name = "Si3054", .patch = patch_si3054 },
@@ -301,3 +300,35 @@ struct hda_codec_preset snd_hda_preset_si3054[] = {
301 {} 300 {}
302}; 301};
303 302
303MODULE_ALIAS("snd-hda-codec-id:163c3055");
304MODULE_ALIAS("snd-hda-codec-id:163c3155");
305MODULE_ALIAS("snd-hda-codec-id:11c13026");
306MODULE_ALIAS("snd-hda-codec-id:11c13055");
307MODULE_ALIAS("snd-hda-codec-id:11c13155");
308MODULE_ALIAS("snd-hda-codec-id:10573055");
309MODULE_ALIAS("snd-hda-codec-id:10573057");
310MODULE_ALIAS("snd-hda-codec-id:10573155");
311MODULE_ALIAS("snd-hda-codec-id:11063288");
312MODULE_ALIAS("snd-hda-codec-id:15433155");
313MODULE_ALIAS("snd-hda-codec-id:18540018");
314
315MODULE_LICENSE("GPL");
316MODULE_DESCRIPTION("Si3054 HD-audio modem codec");
317
318static struct hda_codec_preset_list si3054_list = {
319 .preset = snd_hda_preset_si3054,
320 .owner = THIS_MODULE,
321};
322
323static int __init patch_si3054_init(void)
324{
325 return snd_hda_add_codec_preset(&si3054_list);
326}
327
328static void __exit patch_si3054_exit(void)
329{
330 snd_hda_delete_codec_preset(&si3054_list);
331}
332
333module_init(patch_si3054_init)
334module_exit(patch_si3054_exit)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 596ceabd6504..b7b419691803 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -30,17 +30,17 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <sound/core.h> 31#include <sound/core.h>
32#include <sound/asoundef.h> 32#include <sound/asoundef.h>
33#include <sound/jack.h>
33#include "hda_codec.h" 34#include "hda_codec.h"
34#include "hda_local.h" 35#include "hda_local.h"
35#include "hda_patch.h"
36#include "hda_beep.h" 36#include "hda_beep.h"
37 37
38#define NUM_CONTROL_ALLOC 32 38enum {
39 39 STAC_VREF_EVENT = 1,
40#define STAC_VREF_EVENT 0x00 40 STAC_INSERT_EVENT,
41#define STAC_INSERT_EVENT 0x10 41 STAC_PWR_EVENT,
42#define STAC_PWR_EVENT 0x20 42 STAC_HP_EVENT,
43#define STAC_HP_EVENT 0x30 43};
44 44
45enum { 45enum {
46 STAC_REF, 46 STAC_REF,
@@ -137,6 +137,19 @@ enum {
137 STAC_927X_MODELS 137 STAC_927X_MODELS
138}; 138};
139 139
140struct sigmatel_event {
141 hda_nid_t nid;
142 unsigned char type;
143 unsigned char tag;
144 int data;
145};
146
147struct sigmatel_jack {
148 hda_nid_t nid;
149 int type;
150 struct snd_jack *jack;
151};
152
140struct sigmatel_spec { 153struct sigmatel_spec {
141 struct snd_kcontrol_new *mixers[4]; 154 struct snd_kcontrol_new *mixers[4];
142 unsigned int num_mixers; 155 unsigned int num_mixers;
@@ -170,6 +183,12 @@ struct sigmatel_spec {
170 hda_nid_t *pwr_nids; 183 hda_nid_t *pwr_nids;
171 hda_nid_t *dac_list; 184 hda_nid_t *dac_list;
172 185
186 /* jack detection */
187 struct snd_array jacks;
188
189 /* events */
190 struct snd_array events;
191
173 /* playback */ 192 /* playback */
174 struct hda_input_mux *mono_mux; 193 struct hda_input_mux *mono_mux;
175 struct hda_input_mux *amp_mux; 194 struct hda_input_mux *amp_mux;
@@ -199,7 +218,6 @@ struct sigmatel_spec {
199 hda_nid_t *pin_nids; 218 hda_nid_t *pin_nids;
200 unsigned int num_pins; 219 unsigned int num_pins;
201 unsigned int *pin_configs; 220 unsigned int *pin_configs;
202 unsigned int *bios_pin_configs;
203 221
204 /* codec specific stuff */ 222 /* codec specific stuff */
205 struct hda_verb *init; 223 struct hda_verb *init;
@@ -227,8 +245,7 @@ struct sigmatel_spec {
227 245
228 /* dynamic controls and input_mux */ 246 /* dynamic controls and input_mux */
229 struct auto_pin_cfg autocfg; 247 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used; 248 struct snd_array kctls;
231 struct snd_kcontrol_new *kctl_alloc;
232 struct hda_input_mux private_dimux; 249 struct hda_input_mux private_dimux;
233 struct hda_input_mux private_imux; 250 struct hda_input_mux private_imux;
234 struct hda_input_mux private_smux; 251 struct hda_input_mux private_smux;
@@ -574,12 +591,12 @@ static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
574 else 591 else
575 nid = codec->slave_dig_outs[smux_idx - 1]; 592 nid = codec->slave_dig_outs[smux_idx - 1];
576 if (spec->cur_smux[smux_idx] == smux->num_items - 1) 593 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
577 val = AMP_OUT_MUTE; 594 val = HDA_AMP_MUTE;
578 else 595 else
579 val = AMP_OUT_UNMUTE; 596 val = 0;
580 /* un/mute SPDIF out */ 597 /* un/mute SPDIF out */
581 snd_hda_codec_write_cache(codec, nid, 0, 598 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
582 AC_VERB_SET_AMP_GAIN_MUTE, val); 599 HDA_AMP_MUTE, val);
583 } 600 }
584 return 0; 601 return 0;
585} 602}
@@ -1238,9 +1255,14 @@ static const char *slave_sws[] = {
1238 NULL 1255 NULL
1239}; 1256};
1240 1257
1258static void stac92xx_free_kctls(struct hda_codec *codec);
1259static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1260
1241static int stac92xx_build_controls(struct hda_codec *codec) 1261static int stac92xx_build_controls(struct hda_codec *codec)
1242{ 1262{
1243 struct sigmatel_spec *spec = codec->spec; 1263 struct sigmatel_spec *spec = codec->spec;
1264 struct auto_pin_cfg *cfg = &spec->autocfg;
1265 hda_nid_t nid;
1244 int err; 1266 int err;
1245 int i; 1267 int i;
1246 1268
@@ -1255,7 +1277,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1255 } 1277 }
1256 if (spec->num_dmuxes > 0) { 1278 if (spec->num_dmuxes > 0) {
1257 stac_dmux_mixer.count = spec->num_dmuxes; 1279 stac_dmux_mixer.count = spec->num_dmuxes;
1258 err = snd_ctl_add(codec->bus->card, 1280 err = snd_hda_ctl_add(codec,
1259 snd_ctl_new1(&stac_dmux_mixer, codec)); 1281 snd_ctl_new1(&stac_dmux_mixer, codec));
1260 if (err < 0) 1282 if (err < 0)
1261 return err; 1283 return err;
@@ -1271,7 +1293,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1271 spec->spdif_mute = 1; 1293 spec->spdif_mute = 1;
1272 } 1294 }
1273 stac_smux_mixer.count = spec->num_smuxes; 1295 stac_smux_mixer.count = spec->num_smuxes;
1274 err = snd_ctl_add(codec->bus->card, 1296 err = snd_hda_ctl_add(codec,
1275 snd_ctl_new1(&stac_smux_mixer, codec)); 1297 snd_ctl_new1(&stac_smux_mixer, codec));
1276 if (err < 0) 1298 if (err < 0)
1277 return err; 1299 return err;
@@ -1310,6 +1332,37 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1310 return err; 1332 return err;
1311 } 1333 }
1312 1334
1335 stac92xx_free_kctls(codec); /* no longer needed */
1336
1337 /* create jack input elements */
1338 if (spec->hp_detect) {
1339 for (i = 0; i < cfg->hp_outs; i++) {
1340 int type = SND_JACK_HEADPHONE;
1341 nid = cfg->hp_pins[i];
1342 /* jack detection */
1343 if (cfg->hp_outs == i)
1344 type |= SND_JACK_LINEOUT;
1345 err = stac92xx_add_jack(codec, nid, type);
1346 if (err < 0)
1347 return err;
1348 }
1349 }
1350 for (i = 0; i < cfg->line_outs; i++) {
1351 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1352 SND_JACK_LINEOUT);
1353 if (err < 0)
1354 return err;
1355 }
1356 for (i = 0; i < AUTO_PIN_LAST; i++) {
1357 nid = cfg->input_pins[i];
1358 if (nid) {
1359 err = stac92xx_add_jack(codec, nid,
1360 SND_JACK_MICROPHONE);
1361 if (err < 0)
1362 return err;
1363 }
1364 }
1365
1313 return 0; 1366 return 0;
1314} 1367}
1315 1368
@@ -2200,12 +2253,11 @@ static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2200 int i; 2253 int i;
2201 struct sigmatel_spec *spec = codec->spec; 2254 struct sigmatel_spec *spec = codec->spec;
2202 2255
2203 if (! spec->bios_pin_configs) { 2256 kfree(spec->pin_configs);
2204 spec->bios_pin_configs = kcalloc(spec->num_pins, 2257 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2205 sizeof(*spec->bios_pin_configs), GFP_KERNEL); 2258 GFP_KERNEL);
2206 if (! spec->bios_pin_configs) 2259 if (!spec->pin_configs)
2207 return -ENOMEM; 2260 return -ENOMEM;
2208 }
2209 2261
2210 for (i = 0; i < spec->num_pins; i++) { 2262 for (i = 0; i < spec->num_pins; i++) {
2211 hda_nid_t nid = spec->pin_nids[i]; 2263 hda_nid_t nid = spec->pin_nids[i];
@@ -2215,7 +2267,7 @@ static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2215 AC_VERB_GET_CONFIG_DEFAULT, 0x00); 2267 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2216 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", 2268 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2217 nid, pin_cfg); 2269 nid, pin_cfg);
2218 spec->bios_pin_configs[i] = pin_cfg; 2270 spec->pin_configs[i] = pin_cfg;
2219 } 2271 }
2220 2272
2221 return 0; 2273 return 0;
@@ -2257,6 +2309,39 @@ static void stac92xx_set_config_regs(struct hda_codec *codec)
2257 spec->pin_configs[i]); 2309 spec->pin_configs[i]);
2258} 2310}
2259 2311
2312static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2313{
2314 struct sigmatel_spec *spec = codec->spec;
2315
2316 if (!pins)
2317 return stac92xx_save_bios_config_regs(codec);
2318
2319 kfree(spec->pin_configs);
2320 spec->pin_configs = kmemdup(pins,
2321 spec->num_pins * sizeof(*pins),
2322 GFP_KERNEL);
2323 if (!spec->pin_configs)
2324 return -ENOMEM;
2325
2326 stac92xx_set_config_regs(codec);
2327 return 0;
2328}
2329
2330static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2331 unsigned int cfg)
2332{
2333 struct sigmatel_spec *spec = codec->spec;
2334 int i;
2335
2336 for (i = 0; i < spec->num_pins; i++) {
2337 if (spec->pin_nids[i] == nid) {
2338 spec->pin_configs[i] = cfg;
2339 stac92xx_set_config_reg(codec, nid, cfg);
2340 break;
2341 }
2342 }
2343}
2344
2260/* 2345/*
2261 * Analog playback callbacks 2346 * Analog playback callbacks
2262 */ 2347 */
@@ -2334,7 +2419,7 @@ static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2334 2419
2335 if (spec->powerdown_adcs) { 2420 if (spec->powerdown_adcs) {
2336 msleep(40); 2421 msleep(40);
2337 snd_hda_codec_write_cache(codec, nid, 0, 2422 snd_hda_codec_write(codec, nid, 0,
2338 AC_VERB_SET_POWER_STATE, AC_PWRST_D0); 2423 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2339 } 2424 }
2340 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); 2425 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
@@ -2350,7 +2435,7 @@ static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2350 2435
2351 snd_hda_codec_cleanup_stream(codec, nid); 2436 snd_hda_codec_cleanup_stream(codec, nid);
2352 if (spec->powerdown_adcs) 2437 if (spec->powerdown_adcs)
2353 snd_hda_codec_write_cache(codec, nid, 0, 2438 snd_hda_codec_write(codec, nid, 0,
2354 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 2439 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2355 return 0; 2440 return 0;
2356} 2441}
@@ -2482,6 +2567,9 @@ static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2482 return 0; 2567 return 0;
2483} 2568}
2484 2569
2570static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2571 unsigned char type);
2572
2485static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, 2573static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2486 struct snd_ctl_elem_value *ucontrol) 2574 struct snd_ctl_elem_value *ucontrol)
2487{ 2575{
@@ -2494,7 +2582,7 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2494 /* check to be sure that the ports are upto date with 2582 /* check to be sure that the ports are upto date with
2495 * switch changes 2583 * switch changes
2496 */ 2584 */
2497 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 2585 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2498 2586
2499 return 1; 2587 return 1;
2500} 2588}
@@ -2534,7 +2622,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
2534 * appropriately according to the pin direction 2622 * appropriately according to the pin direction
2535 */ 2623 */
2536 if (spec->hp_detect) 2624 if (spec->hp_detect)
2537 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 2625 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2538 2626
2539 return 1; 2627 return 1;
2540} 2628}
@@ -2629,28 +2717,16 @@ static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2629{ 2717{
2630 struct snd_kcontrol_new *knew; 2718 struct snd_kcontrol_new *knew;
2631 2719
2632 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2720 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2633 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2721 knew = snd_array_new(&spec->kctls);
2634 2722 if (!knew)
2635 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2723 return -ENOMEM;
2636 if (! knew)
2637 return -ENOMEM;
2638 if (spec->kctl_alloc) {
2639 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2640 kfree(spec->kctl_alloc);
2641 }
2642 spec->kctl_alloc = knew;
2643 spec->num_kctl_alloc = num;
2644 }
2645
2646 knew = &spec->kctl_alloc[spec->num_kctl_used];
2647 *knew = *ktemp; 2724 *knew = *ktemp;
2648 knew->index = idx; 2725 knew->index = idx;
2649 knew->name = kstrdup(name, GFP_KERNEL); 2726 knew->name = kstrdup(name, GFP_KERNEL);
2650 if (!knew->name) 2727 if (!knew->name)
2651 return -ENOMEM; 2728 return -ENOMEM;
2652 knew->private_value = val; 2729 knew->private_value = val;
2653 spec->num_kctl_used++;
2654 return 0; 2730 return 0;
2655} 2731}
2656 2732
@@ -3527,8 +3603,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3527 if (dig_in && spec->autocfg.dig_in_pin) 3603 if (dig_in && spec->autocfg.dig_in_pin)
3528 spec->dig_in_nid = dig_in; 3604 spec->dig_in_nid = dig_in;
3529 3605
3530 if (spec->kctl_alloc) 3606 if (spec->kctls.list)
3531 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 3607 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3532 3608
3533 spec->input_mux = &spec->private_imux; 3609 spec->input_mux = &spec->private_imux;
3534 spec->dinput_mux = &spec->private_dimux; 3610 spec->dinput_mux = &spec->private_dimux;
@@ -3635,8 +3711,8 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
3635 if (spec->autocfg.dig_in_pin) 3711 if (spec->autocfg.dig_in_pin)
3636 spec->dig_in_nid = 0x04; 3712 spec->dig_in_nid = 0x04;
3637 3713
3638 if (spec->kctl_alloc) 3714 if (spec->kctls.list)
3639 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 3715 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3640 3716
3641 spec->input_mux = &spec->private_imux; 3717 spec->input_mux = &spec->private_imux;
3642 spec->dinput_mux = &spec->private_dimux; 3718 spec->dinput_mux = &spec->private_dimux;
@@ -3680,13 +3756,101 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3680 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ 3756 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3681} 3757}
3682 3758
3759static int stac92xx_add_jack(struct hda_codec *codec,
3760 hda_nid_t nid, int type)
3761{
3762#ifdef CONFIG_SND_JACK
3763 struct sigmatel_spec *spec = codec->spec;
3764 struct sigmatel_jack *jack;
3765 int def_conf = snd_hda_codec_read(codec, nid,
3766 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3767 int connectivity = get_defcfg_connect(def_conf);
3768 char name[32];
3769
3770 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3771 return 0;
3772
3773 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3774 jack = snd_array_new(&spec->jacks);
3775 if (!jack)
3776 return -ENOMEM;
3777 jack->nid = nid;
3778 jack->type = type;
3779
3780 sprintf(name, "%s at %s %s Jack",
3781 snd_hda_get_jack_type(def_conf),
3782 snd_hda_get_jack_connectivity(def_conf),
3783 snd_hda_get_jack_location(def_conf));
3784
3785 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3786#else
3787 return 0;
3788#endif
3789}
3790
3791static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3792 unsigned char type, int data)
3793{
3794 struct sigmatel_event *event;
3795
3796 snd_array_init(&spec->events, sizeof(*event), 32);
3797 event = snd_array_new(&spec->events);
3798 if (!event)
3799 return -ENOMEM;
3800 event->nid = nid;
3801 event->type = type;
3802 event->tag = spec->events.used;
3803 event->data = data;
3804
3805 return event->tag;
3806}
3807
3808static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3809 hda_nid_t nid, unsigned char type)
3810{
3811 struct sigmatel_spec *spec = codec->spec;
3812 struct sigmatel_event *event = spec->events.list;
3813 int i;
3814
3815 for (i = 0; i < spec->events.used; i++, event++) {
3816 if (event->nid == nid && event->type == type)
3817 return event;
3818 }
3819 return NULL;
3820}
3821
3822static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3823 unsigned char tag)
3824{
3825 struct sigmatel_spec *spec = codec->spec;
3826 struct sigmatel_event *event = spec->events.list;
3827 int i;
3828
3829 for (i = 0; i < spec->events.used; i++, event++) {
3830 if (event->tag == tag)
3831 return event;
3832 }
3833 return NULL;
3834}
3835
3683static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, 3836static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3684 unsigned int event) 3837 unsigned int type)
3685{ 3838{
3686 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) 3839 struct sigmatel_event *event;
3687 snd_hda_codec_write_cache(codec, nid, 0, 3840 int tag;
3688 AC_VERB_SET_UNSOLICITED_ENABLE, 3841
3689 (AC_USRSP_EN | event)); 3842 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3843 return;
3844 event = stac_get_event(codec, nid, type);
3845 if (event)
3846 tag = event->tag;
3847 else
3848 tag = stac_add_event(codec->spec, nid, type, 0);
3849 if (tag < 0)
3850 return;
3851 snd_hda_codec_write_cache(codec, nid, 0,
3852 AC_VERB_SET_UNSOLICITED_ENABLE,
3853 AC_USRSP_EN | tag);
3690} 3854}
3691 3855
3692static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) 3856static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
@@ -3708,7 +3872,7 @@ static void stac92xx_power_down(struct hda_codec *codec)
3708 for (dac = spec->dac_list; *dac; dac++) 3872 for (dac = spec->dac_list; *dac; dac++)
3709 if (!is_in_dac_nids(spec, *dac) && 3873 if (!is_in_dac_nids(spec, *dac) &&
3710 spec->multiout.hp_nid != *dac) 3874 spec->multiout.hp_nid != *dac)
3711 snd_hda_codec_write_cache(codec, *dac, 0, 3875 snd_hda_codec_write(codec, *dac, 0,
3712 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 3876 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3713} 3877}
3714 3878
@@ -3727,7 +3891,7 @@ static int stac92xx_init(struct hda_codec *codec)
3727 /* power down adcs initially */ 3891 /* power down adcs initially */
3728 if (spec->powerdown_adcs) 3892 if (spec->powerdown_adcs)
3729 for (i = 0; i < spec->num_adcs; i++) 3893 for (i = 0; i < spec->num_adcs; i++)
3730 snd_hda_codec_write_cache(codec, 3894 snd_hda_codec_write(codec,
3731 spec->adc_nids[i], 0, 3895 spec->adc_nids[i], 0,
3732 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 3896 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3733 3897
@@ -3743,37 +3907,51 @@ static int stac92xx_init(struct hda_codec *codec)
3743 /* set up pins */ 3907 /* set up pins */
3744 if (spec->hp_detect) { 3908 if (spec->hp_detect) {
3745 /* Enable unsolicited responses on the HP widget */ 3909 /* Enable unsolicited responses on the HP widget */
3746 for (i = 0; i < cfg->hp_outs; i++) 3910 for (i = 0; i < cfg->hp_outs; i++) {
3747 enable_pin_detect(codec, cfg->hp_pins[i], 3911 hda_nid_t nid = cfg->hp_pins[i];
3748 STAC_HP_EVENT); 3912 enable_pin_detect(codec, nid, STAC_HP_EVENT);
3913 }
3749 /* force to enable the first line-out; the others are set up 3914 /* force to enable the first line-out; the others are set up
3750 * in unsol_event 3915 * in unsol_event
3751 */ 3916 */
3752 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], 3917 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3753 AC_PINCTL_OUT_EN); 3918 AC_PINCTL_OUT_EN);
3754 stac92xx_auto_init_hp_out(codec);
3755 /* fake event to set up pins */ 3919 /* fake event to set up pins */
3756 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 3920 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3921 STAC_HP_EVENT);
3757 } else { 3922 } else {
3758 stac92xx_auto_init_multi_out(codec); 3923 stac92xx_auto_init_multi_out(codec);
3759 stac92xx_auto_init_hp_out(codec); 3924 stac92xx_auto_init_hp_out(codec);
3925 for (i = 0; i < cfg->hp_outs; i++)
3926 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
3760 } 3927 }
3761 for (i = 0; i < AUTO_PIN_LAST; i++) { 3928 for (i = 0; i < AUTO_PIN_LAST; i++) {
3762 hda_nid_t nid = cfg->input_pins[i]; 3929 hda_nid_t nid = cfg->input_pins[i];
3763 if (nid) { 3930 if (nid) {
3764 unsigned int pinctl; 3931 unsigned int pinctl, conf;
3765 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { 3932 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3766 /* for mic pins, force to initialize */ 3933 /* for mic pins, force to initialize */
3767 pinctl = stac92xx_get_vref(codec, nid); 3934 pinctl = stac92xx_get_vref(codec, nid);
3935 pinctl |= AC_PINCTL_IN_EN;
3936 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3768 } else { 3937 } else {
3769 pinctl = snd_hda_codec_read(codec, nid, 0, 3938 pinctl = snd_hda_codec_read(codec, nid, 0,
3770 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 3939 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3771 /* if PINCTL already set then skip */ 3940 /* if PINCTL already set then skip */
3772 if (pinctl & AC_PINCTL_IN_EN) 3941 if (!(pinctl & AC_PINCTL_IN_EN)) {
3773 continue; 3942 pinctl |= AC_PINCTL_IN_EN;
3943 stac92xx_auto_set_pinctl(codec, nid,
3944 pinctl);
3945 }
3946 }
3947 conf = snd_hda_codec_read(codec, nid, 0,
3948 AC_VERB_GET_CONFIG_DEFAULT, 0);
3949 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3950 enable_pin_detect(codec, nid,
3951 STAC_INSERT_EVENT);
3952 stac_issue_unsol_event(codec, nid,
3953 STAC_INSERT_EVENT);
3774 } 3954 }
3775 pinctl |= AC_PINCTL_IN_EN;
3776 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3777 } 3955 }
3778 } 3956 }
3779 for (i = 0; i < spec->num_dmics; i++) 3957 for (i = 0; i < spec->num_dmics; i++)
@@ -3788,7 +3966,6 @@ static int stac92xx_init(struct hda_codec *codec)
3788 for (i = 0; i < spec->num_pwrs; i++) { 3966 for (i = 0; i < spec->num_pwrs; i++) {
3789 hda_nid_t nid = spec->pwr_nids[i]; 3967 hda_nid_t nid = spec->pwr_nids[i];
3790 int pinctl, def_conf; 3968 int pinctl, def_conf;
3791 int event = STAC_PWR_EVENT;
3792 3969
3793 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect) 3970 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3794 continue; /* already has an unsol event */ 3971 continue; /* already has an unsol event */
@@ -3811,30 +3988,54 @@ static int stac92xx_init(struct hda_codec *codec)
3811 stac_toggle_power_map(codec, nid, 1); 3988 stac_toggle_power_map(codec, nid, 1);
3812 continue; 3989 continue;
3813 } 3990 }
3814 enable_pin_detect(codec, spec->pwr_nids[i], event | i); 3991 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
3815 codec->patch_ops.unsol_event(codec, (event | i) << 26); 3992 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
3993 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
3994 }
3816 } 3995 }
3817 if (spec->dac_list) 3996 if (spec->dac_list)
3818 stac92xx_power_down(codec); 3997 stac92xx_power_down(codec);
3819 return 0; 3998 return 0;
3820} 3999}
3821 4000
4001static void stac92xx_free_jacks(struct hda_codec *codec)
4002{
4003#ifdef CONFIG_SND_JACK
4004 /* free jack instances manually when clearing/reconfiguring */
4005 struct sigmatel_spec *spec = codec->spec;
4006 if (!codec->bus->shutdown && spec->jacks.list) {
4007 struct sigmatel_jack *jacks = spec->jacks.list;
4008 int i;
4009 for (i = 0; i < spec->jacks.used; i++)
4010 snd_device_free(codec->bus->card, &jacks[i].jack);
4011 }
4012 snd_array_free(&spec->jacks);
4013#endif
4014}
4015
4016static void stac92xx_free_kctls(struct hda_codec *codec)
4017{
4018 struct sigmatel_spec *spec = codec->spec;
4019
4020 if (spec->kctls.list) {
4021 struct snd_kcontrol_new *kctl = spec->kctls.list;
4022 int i;
4023 for (i = 0; i < spec->kctls.used; i++)
4024 kfree(kctl[i].name);
4025 }
4026 snd_array_free(&spec->kctls);
4027}
4028
3822static void stac92xx_free(struct hda_codec *codec) 4029static void stac92xx_free(struct hda_codec *codec)
3823{ 4030{
3824 struct sigmatel_spec *spec = codec->spec; 4031 struct sigmatel_spec *spec = codec->spec;
3825 int i;
3826 4032
3827 if (! spec) 4033 if (! spec)
3828 return; 4034 return;
3829 4035
3830 if (spec->kctl_alloc) { 4036 kfree(spec->pin_configs);
3831 for (i = 0; i < spec->num_kctl_used; i++) 4037 stac92xx_free_jacks(codec);
3832 kfree(spec->kctl_alloc[i].name); 4038 snd_array_free(&spec->events);
3833 kfree(spec->kctl_alloc);
3834 }
3835
3836 if (spec->bios_pin_configs)
3837 kfree(spec->bios_pin_configs);
3838 4039
3839 kfree(spec); 4040 kfree(spec);
3840 snd_hda_detach_beep_device(codec); 4041 snd_hda_detach_beep_device(codec);
@@ -3881,20 +4082,13 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3881 pin_ctl & ~flag); 4082 pin_ctl & ~flag);
3882} 4083}
3883 4084
3884static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid) 4085static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3885{ 4086{
3886 if (!nid) 4087 if (!nid)
3887 return 0; 4088 return 0;
3888 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) 4089 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3889 & (1 << 31)) { 4090 & (1 << 31))
3890 unsigned int pinctl; 4091 return 1;
3891 pinctl = snd_hda_codec_read(codec, nid, 0,
3892 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3893 if (pinctl & AC_PINCTL_IN_EN)
3894 return 0; /* mic- or line-input */
3895 else
3896 return 1; /* HP-output */
3897 }
3898 return 0; 4092 return 0;
3899} 4093}
3900 4094
@@ -3918,7 +4112,7 @@ static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3918 return 0; 4112 return 0;
3919} 4113}
3920 4114
3921static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) 4115static void stac92xx_hp_detect(struct hda_codec *codec)
3922{ 4116{
3923 struct sigmatel_spec *spec = codec->spec; 4117 struct sigmatel_spec *spec = codec->spec;
3924 struct auto_pin_cfg *cfg = &spec->autocfg; 4118 struct auto_pin_cfg *cfg = &spec->autocfg;
@@ -3934,7 +4128,14 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3934 break; 4128 break;
3935 if (no_hp_sensing(spec, i)) 4129 if (no_hp_sensing(spec, i))
3936 continue; 4130 continue;
3937 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); 4131 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4132 if (presence) {
4133 unsigned int pinctl;
4134 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4135 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4136 if (pinctl & AC_PINCTL_IN_EN)
4137 presence = 0; /* mic- or line-input */
4138 }
3938 } 4139 }
3939 4140
3940 if (presence) { 4141 if (presence) {
@@ -4011,50 +4212,145 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4011 4212
4012static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) 4213static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4013{ 4214{
4014 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid)); 4215 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4216}
4217
4218static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4219{
4220 struct sigmatel_spec *spec = codec->spec;
4221 struct sigmatel_jack *jacks = spec->jacks.list;
4222
4223 if (jacks) {
4224 int i;
4225 for (i = 0; i < spec->jacks.used; i++) {
4226 if (jacks->nid == nid) {
4227 unsigned int pin_ctl =
4228 snd_hda_codec_read(codec, nid,
4229 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4230 0x00);
4231 int type = jacks->type;
4232 if (type == (SND_JACK_LINEOUT
4233 | SND_JACK_HEADPHONE))
4234 type = (pin_ctl & AC_PINCTL_HP_EN)
4235 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4236 snd_jack_report(jacks->jack,
4237 get_pin_presence(codec, nid)
4238 ? type : 0);
4239 }
4240 jacks++;
4241 }
4242 }
4243}
4244
4245static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4246 unsigned char type)
4247{
4248 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4249 if (!event)
4250 return;
4251 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4015} 4252}
4016 4253
4017static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) 4254static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4018{ 4255{
4019 struct sigmatel_spec *spec = codec->spec; 4256 struct sigmatel_spec *spec = codec->spec;
4020 int idx = res >> 26 & 0x0f; 4257 struct sigmatel_event *event;
4258 int tag, data;
4021 4259
4022 switch ((res >> 26) & 0x70) { 4260 tag = (res >> 26) & 0x7f;
4261 event = stac_get_event_from_tag(codec, tag);
4262 if (!event)
4263 return;
4264
4265 switch (event->type) {
4023 case STAC_HP_EVENT: 4266 case STAC_HP_EVENT:
4024 stac92xx_hp_detect(codec, res); 4267 stac92xx_hp_detect(codec);
4025 /* fallthru */ 4268 /* fallthru */
4269 case STAC_INSERT_EVENT:
4026 case STAC_PWR_EVENT: 4270 case STAC_PWR_EVENT:
4027 if (spec->num_pwrs > 0) 4271 if (spec->num_pwrs > 0)
4028 stac92xx_pin_sense(codec, idx); 4272 stac92xx_pin_sense(codec, event->nid);
4273 stac92xx_report_jack(codec, event->nid);
4029 break; 4274 break;
4030 case STAC_VREF_EVENT: { 4275 case STAC_VREF_EVENT:
4031 int data = snd_hda_codec_read(codec, codec->afg, 0, 4276 data = snd_hda_codec_read(codec, codec->afg, 0,
4032 AC_VERB_GET_GPIO_DATA, 0); 4277 AC_VERB_GET_GPIO_DATA, 0);
4033 /* toggle VREF state based on GPIOx status */ 4278 /* toggle VREF state based on GPIOx status */
4034 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, 4279 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4035 !!(data & (1 << idx))); 4280 !!(data & (1 << event->data)));
4036 break; 4281 break;
4037 }
4038 } 4282 }
4039} 4283}
4040 4284
4285#ifdef CONFIG_PROC_FS
4286static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4287 struct hda_codec *codec, hda_nid_t nid)
4288{
4289 if (nid == codec->afg)
4290 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4291 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4292}
4293
4294static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4295 struct hda_codec *codec,
4296 unsigned int verb)
4297{
4298 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4299 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4300}
4301
4302/* stac92hd71bxx, stac92hd73xx */
4303static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4304 struct hda_codec *codec, hda_nid_t nid)
4305{
4306 stac92hd_proc_hook(buffer, codec, nid);
4307 if (nid == codec->afg)
4308 analog_loop_proc_hook(buffer, codec, 0xfa0);
4309}
4310
4311static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4312 struct hda_codec *codec, hda_nid_t nid)
4313{
4314 if (nid == codec->afg)
4315 analog_loop_proc_hook(buffer, codec, 0xfe0);
4316}
4317
4318static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4319 struct hda_codec *codec, hda_nid_t nid)
4320{
4321 if (nid == codec->afg)
4322 analog_loop_proc_hook(buffer, codec, 0xfeb);
4323}
4324#else
4325#define stac92hd_proc_hook NULL
4326#define stac92hd7x_proc_hook NULL
4327#define stac9205_proc_hook NULL
4328#define stac927x_proc_hook NULL
4329#endif
4330
4041#ifdef SND_HDA_NEEDS_RESUME 4331#ifdef SND_HDA_NEEDS_RESUME
4042static int stac92xx_resume(struct hda_codec *codec) 4332static int stac92xx_resume(struct hda_codec *codec)
4043{ 4333{
4044 struct sigmatel_spec *spec = codec->spec; 4334 struct sigmatel_spec *spec = codec->spec;
4045 4335
4046 stac92xx_set_config_regs(codec); 4336 stac92xx_set_config_regs(codec);
4047 snd_hda_sequence_write(codec, spec->init); 4337 stac92xx_init(codec);
4048 stac_gpio_set(codec, spec->gpio_mask,
4049 spec->gpio_dir, spec->gpio_data);
4050 snd_hda_codec_resume_amp(codec); 4338 snd_hda_codec_resume_amp(codec);
4051 snd_hda_codec_resume_cache(codec); 4339 snd_hda_codec_resume_cache(codec);
4052 /* power down inactive DACs */ 4340 /* fake event to set up pins again to override cached values */
4053 if (spec->dac_list)
4054 stac92xx_power_down(codec);
4055 /* invoke unsolicited event to reset the HP state */
4056 if (spec->hp_detect) 4341 if (spec->hp_detect)
4057 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 4342 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4343 STAC_HP_EVENT);
4344 return 0;
4345}
4346
4347static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4348{
4349 struct sigmatel_spec *spec = codec->spec;
4350 if (spec->eapd_mask)
4351 stac_gpio_set(codec, spec->gpio_mask,
4352 spec->gpio_dir, spec->gpio_data &
4353 ~spec->eapd_mask);
4058 return 0; 4354 return 0;
4059} 4355}
4060#endif 4356#endif
@@ -4066,6 +4362,7 @@ static struct hda_codec_ops stac92xx_patch_ops = {
4066 .free = stac92xx_free, 4362 .free = stac92xx_free,
4067 .unsol_event = stac92xx_unsol_event, 4363 .unsol_event = stac92xx_unsol_event,
4068#ifdef SND_HDA_NEEDS_RESUME 4364#ifdef SND_HDA_NEEDS_RESUME
4365 .suspend = stac92xx_suspend,
4069 .resume = stac92xx_resume, 4366 .resume = stac92xx_resume,
4070#endif 4367#endif
4071}; 4368};
@@ -4088,14 +4385,12 @@ static int patch_stac9200(struct hda_codec *codec)
4088 if (spec->board_config < 0) { 4385 if (spec->board_config < 0) {
4089 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); 4386 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4090 err = stac92xx_save_bios_config_regs(codec); 4387 err = stac92xx_save_bios_config_regs(codec);
4091 if (err < 0) { 4388 } else
4092 stac92xx_free(codec); 4389 err = stac_save_pin_cfgs(codec,
4093 return err; 4390 stac9200_brd_tbl[spec->board_config]);
4094 } 4391 if (err < 0) {
4095 spec->pin_configs = spec->bios_pin_configs; 4392 stac92xx_free(codec);
4096 } else { 4393 return err;
4097 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4098 stac92xx_set_config_regs(codec);
4099 } 4394 }
4100 4395
4101 spec->multiout.max_channels = 2; 4396 spec->multiout.max_channels = 2;
@@ -4151,14 +4446,12 @@ static int patch_stac925x(struct hda_codec *codec)
4151 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 4446 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4152 "using BIOS defaults\n"); 4447 "using BIOS defaults\n");
4153 err = stac92xx_save_bios_config_regs(codec); 4448 err = stac92xx_save_bios_config_regs(codec);
4154 if (err < 0) { 4449 } else
4155 stac92xx_free(codec); 4450 err = stac_save_pin_cfgs(codec,
4156 return err; 4451 stac925x_brd_tbl[spec->board_config]);
4157 } 4452 if (err < 0) {
4158 spec->pin_configs = spec->bios_pin_configs; 4453 stac92xx_free(codec);
4159 } else if (stac925x_brd_tbl[spec->board_config] != NULL){ 4454 return err;
4160 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4161 stac92xx_set_config_regs(codec);
4162 } 4455 }
4163 4456
4164 spec->multiout.max_channels = 2; 4457 spec->multiout.max_channels = 2;
@@ -4240,14 +4533,12 @@ again:
4240 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4533 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4241 " STAC92HD73XX, using BIOS defaults\n"); 4534 " STAC92HD73XX, using BIOS defaults\n");
4242 err = stac92xx_save_bios_config_regs(codec); 4535 err = stac92xx_save_bios_config_regs(codec);
4243 if (err < 0) { 4536 } else
4244 stac92xx_free(codec); 4537 err = stac_save_pin_cfgs(codec,
4245 return err; 4538 stac92hd73xx_brd_tbl[spec->board_config]);
4246 } 4539 if (err < 0) {
4247 spec->pin_configs = spec->bios_pin_configs; 4540 stac92xx_free(codec);
4248 } else { 4541 return err;
4249 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4250 stac92xx_set_config_regs(codec);
4251 } 4542 }
4252 4543
4253 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a, 4544 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
@@ -4367,6 +4658,8 @@ again:
4367 4658
4368 codec->patch_ops = stac92xx_patch_ops; 4659 codec->patch_ops = stac92xx_patch_ops;
4369 4660
4661 codec->proc_widget_hook = stac92hd7x_proc_hook;
4662
4370 return 0; 4663 return 0;
4371} 4664}
4372 4665
@@ -4427,14 +4720,12 @@ again:
4427 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4720 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4428 " STAC92HD83XXX, using BIOS defaults\n"); 4721 " STAC92HD83XXX, using BIOS defaults\n");
4429 err = stac92xx_save_bios_config_regs(codec); 4722 err = stac92xx_save_bios_config_regs(codec);
4430 if (err < 0) { 4723 } else
4431 stac92xx_free(codec); 4724 err = stac_save_pin_cfgs(codec,
4432 return err; 4725 stac92hd83xxx_brd_tbl[spec->board_config]);
4433 } 4726 if (err < 0) {
4434 spec->pin_configs = spec->bios_pin_configs; 4727 stac92xx_free(codec);
4435 } else { 4728 return err;
4436 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4437 stac92xx_set_config_regs(codec);
4438 } 4729 }
4439 4730
4440 err = stac92xx_parse_auto_config(codec, 0x1d, 0); 4731 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
@@ -4455,56 +4746,10 @@ again:
4455 4746
4456 codec->patch_ops = stac92xx_patch_ops; 4747 codec->patch_ops = stac92xx_patch_ops;
4457 4748
4458 return 0; 4749 codec->proc_widget_hook = stac92hd_proc_hook;
4459}
4460
4461#ifdef SND_HDA_NEEDS_RESUME
4462static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4463{
4464 struct sigmatel_spec *spec = codec->spec;
4465 int i;
4466 snd_hda_codec_write_cache(codec, codec->afg, 0,
4467 AC_VERB_SET_POWER_STATE, pwr);
4468
4469 msleep(1);
4470 for (i = 0; i < spec->num_adcs; i++) {
4471 snd_hda_codec_write_cache(codec,
4472 spec->adc_nids[i], 0,
4473 AC_VERB_SET_POWER_STATE, pwr);
4474 }
4475};
4476 4750
4477static int stac92hd71xx_resume(struct hda_codec *codec)
4478{
4479 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4480 return stac92xx_resume(codec);
4481}
4482
4483static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4484{
4485 struct sigmatel_spec *spec = codec->spec;
4486
4487 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4488 if (spec->eapd_mask)
4489 stac_gpio_set(codec, spec->gpio_mask,
4490 spec->gpio_dir, spec->gpio_data &
4491 ~spec->eapd_mask);
4492 return 0; 4751 return 0;
4493}; 4752}
4494
4495#endif
4496
4497static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4498 .build_controls = stac92xx_build_controls,
4499 .build_pcms = stac92xx_build_pcms,
4500 .init = stac92xx_init,
4501 .free = stac92xx_free,
4502 .unsol_event = stac92xx_unsol_event,
4503#ifdef SND_HDA_NEEDS_RESUME
4504 .resume = stac92hd71xx_resume,
4505 .suspend = stac92hd71xx_suspend,
4506#endif
4507};
4508 4753
4509static struct hda_input_mux stac92hd71bxx_dmux = { 4754static struct hda_input_mux stac92hd71bxx_dmux = {
4510 .num_items = 4, 4755 .num_items = 4,
@@ -4541,14 +4786,12 @@ again:
4541 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4786 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4542 " STAC92HD71BXX, using BIOS defaults\n"); 4787 " STAC92HD71BXX, using BIOS defaults\n");
4543 err = stac92xx_save_bios_config_regs(codec); 4788 err = stac92xx_save_bios_config_regs(codec);
4544 if (err < 0) { 4789 } else
4545 stac92xx_free(codec); 4790 err = stac_save_pin_cfgs(codec,
4546 return err; 4791 stac92hd71bxx_brd_tbl[spec->board_config]);
4547 } 4792 if (err < 0) {
4548 spec->pin_configs = spec->bios_pin_configs; 4793 stac92xx_free(codec);
4549 } else { 4794 return err;
4550 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4551 stac92xx_set_config_regs(codec);
4552 } 4795 }
4553 4796
4554 if (spec->board_config > STAC_92HD71BXX_REF) { 4797 if (spec->board_config > STAC_92HD71BXX_REF) {
@@ -4571,21 +4814,21 @@ again:
4571 switch (spec->board_config) { 4814 switch (spec->board_config) {
4572 case STAC_HP_M4: 4815 case STAC_HP_M4:
4573 /* Enable VREF power saving on GPIO1 detect */ 4816 /* Enable VREF power saving on GPIO1 detect */
4817 err = stac_add_event(spec, codec->afg,
4818 STAC_VREF_EVENT, 0x02);
4819 if (err < 0)
4820 return err;
4574 snd_hda_codec_write_cache(codec, codec->afg, 0, 4821 snd_hda_codec_write_cache(codec, codec->afg, 0,
4575 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); 4822 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4576 snd_hda_codec_write_cache(codec, codec->afg, 0, 4823 snd_hda_codec_write_cache(codec, codec->afg, 0,
4577 AC_VERB_SET_UNSOLICITED_ENABLE, 4824 AC_VERB_SET_UNSOLICITED_ENABLE,
4578 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01)); 4825 AC_USRSP_EN | err);
4579 spec->gpio_mask |= 0x02; 4826 spec->gpio_mask |= 0x02;
4580 break; 4827 break;
4581 } 4828 }
4582 if ((codec->revision_id & 0xf) == 0 || 4829 if ((codec->revision_id & 0xf) == 0 ||
4583 (codec->revision_id & 0xf) == 1) { 4830 (codec->revision_id & 0xf) == 1)
4584#ifdef SND_HDA_NEEDS_RESUME
4585 codec->patch_ops = stac92hd71bxx_patch_ops;
4586#endif
4587 spec->stream_delay = 40; /* 40 milliseconds */ 4831 spec->stream_delay = 40; /* 40 milliseconds */
4588 }
4589 4832
4590 /* no output amps */ 4833 /* no output amps */
4591 spec->num_pwrs = 0; 4834 spec->num_pwrs = 0;
@@ -4594,15 +4837,11 @@ again:
4594 4837
4595 /* disable VSW */ 4838 /* disable VSW */
4596 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; 4839 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4597 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0); 4840 stac_change_pin_config(codec, 0xf, 0x40f000f0);
4598 break; 4841 break;
4599 case 0x111d7603: /* 6 Port with Analog Mixer */ 4842 case 0x111d7603: /* 6 Port with Analog Mixer */
4600 if ((codec->revision_id & 0xf) == 1) { 4843 if ((codec->revision_id & 0xf) == 1)
4601#ifdef SND_HDA_NEEDS_RESUME
4602 codec->patch_ops = stac92hd71bxx_patch_ops;
4603#endif
4604 spec->stream_delay = 40; /* 40 milliseconds */ 4844 spec->stream_delay = 40; /* 40 milliseconds */
4605 }
4606 4845
4607 /* no output amps */ 4846 /* no output amps */
4608 spec->num_pwrs = 0; 4847 spec->num_pwrs = 0;
@@ -4632,7 +4871,7 @@ again:
4632 switch (spec->board_config) { 4871 switch (spec->board_config) {
4633 case STAC_HP_M4: 4872 case STAC_HP_M4:
4634 /* enable internal microphone */ 4873 /* enable internal microphone */
4635 stac92xx_set_config_reg(codec, 0x0e, 0x01813040); 4874 stac_change_pin_config(codec, 0x0e, 0x01813040);
4636 stac92xx_auto_set_pinctl(codec, 0x0e, 4875 stac92xx_auto_set_pinctl(codec, 0x0e,
4637 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); 4876 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4638 /* fallthru */ 4877 /* fallthru */
@@ -4677,6 +4916,8 @@ again:
4677 return err; 4916 return err;
4678 } 4917 }
4679 4918
4919 codec->proc_widget_hook = stac92hd7x_proc_hook;
4920
4680 return 0; 4921 return 0;
4681}; 4922};
4682 4923
@@ -4738,14 +4979,12 @@ static int patch_stac922x(struct hda_codec *codec)
4738 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " 4979 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4739 "using BIOS defaults\n"); 4980 "using BIOS defaults\n");
4740 err = stac92xx_save_bios_config_regs(codec); 4981 err = stac92xx_save_bios_config_regs(codec);
4741 if (err < 0) { 4982 } else
4742 stac92xx_free(codec); 4983 err = stac_save_pin_cfgs(codec,
4743 return err; 4984 stac922x_brd_tbl[spec->board_config]);
4744 } 4985 if (err < 0) {
4745 spec->pin_configs = spec->bios_pin_configs; 4986 stac92xx_free(codec);
4746 } else if (stac922x_brd_tbl[spec->board_config] != NULL) { 4987 return err;
4747 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4748 stac92xx_set_config_regs(codec);
4749 } 4988 }
4750 4989
4751 spec->adc_nids = stac922x_adc_nids; 4990 spec->adc_nids = stac922x_adc_nids;
@@ -4808,14 +5047,12 @@ static int patch_stac927x(struct hda_codec *codec)
4808 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5047 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4809 "STAC927x, using BIOS defaults\n"); 5048 "STAC927x, using BIOS defaults\n");
4810 err = stac92xx_save_bios_config_regs(codec); 5049 err = stac92xx_save_bios_config_regs(codec);
4811 if (err < 0) { 5050 } else
4812 stac92xx_free(codec); 5051 err = stac_save_pin_cfgs(codec,
4813 return err; 5052 stac927x_brd_tbl[spec->board_config]);
4814 } 5053 if (err < 0) {
4815 spec->pin_configs = spec->bios_pin_configs; 5054 stac92xx_free(codec);
4816 } else { 5055 return err;
4817 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4818 stac92xx_set_config_regs(codec);
4819 } 5056 }
4820 5057
4821 spec->digbeep_nid = 0x23; 5058 spec->digbeep_nid = 0x23;
@@ -4845,15 +5082,15 @@ static int patch_stac927x(struct hda_codec *codec)
4845 case 0x10280209: 5082 case 0x10280209:
4846 case 0x1028022e: 5083 case 0x1028022e:
4847 /* correct the device field to SPDIF out */ 5084 /* correct the device field to SPDIF out */
4848 stac92xx_set_config_reg(codec, 0x21, 0x01442070); 5085 stac_change_pin_config(codec, 0x21, 0x01442070);
4849 break; 5086 break;
4850 }; 5087 };
4851 /* configure the analog microphone on some laptops */ 5088 /* configure the analog microphone on some laptops */
4852 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130); 5089 stac_change_pin_config(codec, 0x0c, 0x90a79130);
4853 /* correct the front output jack as a hp out */ 5090 /* correct the front output jack as a hp out */
4854 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f); 5091 stac_change_pin_config(codec, 0x0f, 0x0227011f);
4855 /* correct the front input jack as a mic */ 5092 /* correct the front input jack as a mic */
4856 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130); 5093 stac_change_pin_config(codec, 0x0e, 0x02a79130);
4857 /* fallthru */ 5094 /* fallthru */
4858 case STAC_DELL_3ST: 5095 case STAC_DELL_3ST:
4859 /* GPIO2 High = Enable EAPD */ 5096 /* GPIO2 High = Enable EAPD */
@@ -4901,6 +5138,8 @@ static int patch_stac927x(struct hda_codec *codec)
4901 5138
4902 codec->patch_ops = stac92xx_patch_ops; 5139 codec->patch_ops = stac92xx_patch_ops;
4903 5140
5141 codec->proc_widget_hook = stac927x_proc_hook;
5142
4904 /* 5143 /*
4905 * !!FIXME!! 5144 * !!FIXME!!
4906 * The STAC927x seem to require fairly long delays for certain 5145 * The STAC927x seem to require fairly long delays for certain
@@ -4939,14 +5178,12 @@ static int patch_stac9205(struct hda_codec *codec)
4939 if (spec->board_config < 0) { 5178 if (spec->board_config < 0) {
4940 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); 5179 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4941 err = stac92xx_save_bios_config_regs(codec); 5180 err = stac92xx_save_bios_config_regs(codec);
4942 if (err < 0) { 5181 } else
4943 stac92xx_free(codec); 5182 err = stac_save_pin_cfgs(codec,
4944 return err; 5183 stac9205_brd_tbl[spec->board_config]);
4945 } 5184 if (err < 0) {
4946 spec->pin_configs = spec->bios_pin_configs; 5185 stac92xx_free(codec);
4947 } else { 5186 return err;
4948 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4949 stac92xx_set_config_regs(codec);
4950 } 5187 }
4951 5188
4952 spec->digbeep_nid = 0x23; 5189 spec->digbeep_nid = 0x23;
@@ -4973,15 +5210,18 @@ static int patch_stac9205(struct hda_codec *codec)
4973 switch (spec->board_config){ 5210 switch (spec->board_config){
4974 case STAC_9205_DELL_M43: 5211 case STAC_9205_DELL_M43:
4975 /* Enable SPDIF in/out */ 5212 /* Enable SPDIF in/out */
4976 stac92xx_set_config_reg(codec, 0x1f, 0x01441030); 5213 stac_change_pin_config(codec, 0x1f, 0x01441030);
4977 stac92xx_set_config_reg(codec, 0x20, 0x1c410030); 5214 stac_change_pin_config(codec, 0x20, 0x1c410030);
4978 5215
4979 /* Enable unsol response for GPIO4/Dock HP connection */ 5216 /* Enable unsol response for GPIO4/Dock HP connection */
5217 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5218 if (err < 0)
5219 return err;
4980 snd_hda_codec_write_cache(codec, codec->afg, 0, 5220 snd_hda_codec_write_cache(codec, codec->afg, 0,
4981 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); 5221 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4982 snd_hda_codec_write_cache(codec, codec->afg, 0, 5222 snd_hda_codec_write_cache(codec, codec->afg, 0,
4983 AC_VERB_SET_UNSOLICITED_ENABLE, 5223 AC_VERB_SET_UNSOLICITED_ENABLE,
4984 (AC_USRSP_EN | STAC_HP_EVENT)); 5224 AC_USRSP_EN | err);
4985 5225
4986 spec->gpio_dir = 0x0b; 5226 spec->gpio_dir = 0x0b;
4987 spec->eapd_mask = 0x01; 5227 spec->eapd_mask = 0x01;
@@ -5019,6 +5259,8 @@ static int patch_stac9205(struct hda_codec *codec)
5019 5259
5020 codec->patch_ops = stac92xx_patch_ops; 5260 codec->patch_ops = stac92xx_patch_ops;
5021 5261
5262 codec->proc_widget_hook = stac9205_proc_hook;
5263
5022 return 0; 5264 return 0;
5023} 5265}
5024 5266
@@ -5075,29 +5317,11 @@ static struct hda_verb vaio_ar_init[] = {
5075 {} 5317 {}
5076}; 5318};
5077 5319
5078/* bind volumes of both NID 0x02 and 0x05 */
5079static struct hda_bind_ctls vaio_bind_master_vol = {
5080 .ops = &snd_hda_bind_vol,
5081 .values = {
5082 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5083 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5084 0
5085 },
5086};
5087
5088/* bind volumes of both NID 0x02 and 0x05 */
5089static struct hda_bind_ctls vaio_bind_master_sw = {
5090 .ops = &snd_hda_bind_sw,
5091 .values = {
5092 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5093 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5094 0,
5095 },
5096};
5097
5098static struct snd_kcontrol_new vaio_mixer[] = { 5320static struct snd_kcontrol_new vaio_mixer[] = {
5099 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), 5321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5100 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), 5322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5323 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5324 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
5101 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ 5325 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5102 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 5326 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5103 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 5327 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
@@ -5113,8 +5337,10 @@ static struct snd_kcontrol_new vaio_mixer[] = {
5113}; 5337};
5114 5338
5115static struct snd_kcontrol_new vaio_ar_mixer[] = { 5339static struct snd_kcontrol_new vaio_ar_mixer[] = {
5116 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), 5340 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5117 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), 5341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5342 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5343 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
5118 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ 5344 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5119 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 5345 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5120 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 5346 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
@@ -5155,7 +5381,7 @@ static int stac9872_vaio_init(struct hda_codec *codec)
5155 5381
5156static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) 5382static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5157{ 5383{
5158 if (get_hp_pin_presence(codec, 0x0a)) { 5384 if (get_pin_presence(codec, 0x0a)) {
5159 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); 5385 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5160 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); 5386 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5161 } else { 5387 } else {
@@ -5266,7 +5492,7 @@ static int patch_stac9872(struct hda_codec *codec)
5266/* 5492/*
5267 * patch entries 5493 * patch entries
5268 */ 5494 */
5269struct hda_codec_preset snd_hda_preset_sigmatel[] = { 5495static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5270 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, 5496 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5271 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, 5497 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5272 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, 5498 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
@@ -5330,3 +5556,27 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5330 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, 5556 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5331 {} /* terminator */ 5557 {} /* terminator */
5332}; 5558};
5559
5560MODULE_ALIAS("snd-hda-codec-id:8384*");
5561MODULE_ALIAS("snd-hda-codec-id:111d*");
5562
5563MODULE_LICENSE("GPL");
5564MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5565
5566static struct hda_codec_preset_list sigmatel_list = {
5567 .preset = snd_hda_preset_sigmatel,
5568 .owner = THIS_MODULE,
5569};
5570
5571static int __init patch_sigmatel_init(void)
5572{
5573 return snd_hda_add_codec_preset(&sigmatel_list);
5574}
5575
5576static void __exit patch_sigmatel_exit(void)
5577{
5578 snd_hda_delete_codec_preset(&sigmatel_list);
5579}
5580
5581module_init(patch_sigmatel_init)
5582module_exit(patch_sigmatel_exit)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 63e4871e5d8f..c761394cbe84 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -47,15 +47,11 @@
47#include <sound/asoundef.h> 47#include <sound/asoundef.h>
48#include "hda_codec.h" 48#include "hda_codec.h"
49#include "hda_local.h" 49#include "hda_local.h"
50#include "hda_patch.h"
51 50
52/* amp values */ 51/* amp values */
53#define AMP_VAL_IDX_SHIFT 19 52#define AMP_VAL_IDX_SHIFT 19
54#define AMP_VAL_IDX_MASK (0x0f<<19) 53#define AMP_VAL_IDX_MASK (0x0f<<19)
55 54
56#define NUM_CONTROL_ALLOC 32
57#define NUM_VERB_ALLOC 32
58
59/* Pin Widget NID */ 55/* Pin Widget NID */
60#define VT1708_HP_NID 0x13 56#define VT1708_HP_NID 0x13
61#define VT1708_DIGOUT_NID 0x14 57#define VT1708_DIGOUT_NID 0x14
@@ -145,8 +141,6 @@ enum {
145 AUTO_SEQ_SIDE 141 AUTO_SEQ_SIDE
146}; 142};
147 143
148#define get_amp_nid(kc) ((kc)->private_value & 0xffff)
149
150/* Some VT1708S based boards gets the micboost setting wrong, so we have 144/* Some VT1708S based boards gets the micboost setting wrong, so we have
151 * to apply some brute-force and re-write the TLV's by software. */ 145 * to apply some brute-force and re-write the TLV's by software. */
152static int mic_boost_tlv(struct snd_kcontrol *kcontrol, int op_flag, 146static int mic_boost_tlv(struct snd_kcontrol *kcontrol, int op_flag,
@@ -227,8 +221,7 @@ struct via_spec {
227 221
228 /* dynamic controls, init_verbs and input_mux */ 222 /* dynamic controls, init_verbs and input_mux */
229 struct auto_pin_cfg autocfg; 223 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used; 224 struct snd_array kctls;
231 struct snd_kcontrol_new *kctl_alloc;
232 struct hda_input_mux private_imux[2]; 225 struct hda_input_mux private_imux[2];
233 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 226 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
234 227
@@ -272,33 +265,31 @@ static int via_add_control(struct via_spec *spec, int type, const char *name,
272{ 265{
273 struct snd_kcontrol_new *knew; 266 struct snd_kcontrol_new *knew;
274 267
275 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 268 snd_array_init(&spec->kctls, sizeof(*knew), 32);
276 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 269 knew = snd_array_new(&spec->kctls);
277 270 if (!knew)
278 /* array + terminator */ 271 return -ENOMEM;
279 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
280 if (!knew)
281 return -ENOMEM;
282 if (spec->kctl_alloc) {
283 memcpy(knew, spec->kctl_alloc,
284 sizeof(*knew) * spec->num_kctl_alloc);
285 kfree(spec->kctl_alloc);
286 }
287 spec->kctl_alloc = knew;
288 spec->num_kctl_alloc = num;
289 }
290
291 knew = &spec->kctl_alloc[spec->num_kctl_used];
292 *knew = vt1708_control_templates[type]; 272 *knew = vt1708_control_templates[type];
293 knew->name = kstrdup(name, GFP_KERNEL); 273 knew->name = kstrdup(name, GFP_KERNEL);
294
295 if (!knew->name) 274 if (!knew->name)
296 return -ENOMEM; 275 return -ENOMEM;
297 knew->private_value = val; 276 knew->private_value = val;
298 spec->num_kctl_used++;
299 return 0; 277 return 0;
300} 278}
301 279
280static void via_free_kctls(struct hda_codec *codec)
281{
282 struct via_spec *spec = codec->spec;
283
284 if (spec->kctls.list) {
285 struct snd_kcontrol_new *kctl = spec->kctls.list;
286 int i;
287 for (i = 0; i < spec->kctls.used; i++)
288 kfree(kctl[i].name);
289 }
290 snd_array_free(&spec->kctls);
291}
292
302/* create input playback/capture controls for the given pin */ 293/* create input playback/capture controls for the given pin */
303static int via_new_analog_input(struct via_spec *spec, hda_nid_t pin, 294static int via_new_analog_input(struct via_spec *spec, hda_nid_t pin,
304 const char *ctlname, int idx, int mix_nid) 295 const char *ctlname, int idx, int mix_nid)
@@ -896,6 +887,7 @@ static int via_build_controls(struct hda_codec *codec)
896 if (err < 0) 887 if (err < 0)
897 return err; 888 return err;
898 } 889 }
890 via_free_kctls(codec); /* no longer needed */
899 return 0; 891 return 0;
900} 892}
901 893
@@ -941,17 +933,11 @@ static int via_build_pcms(struct hda_codec *codec)
941static void via_free(struct hda_codec *codec) 933static void via_free(struct hda_codec *codec)
942{ 934{
943 struct via_spec *spec = codec->spec; 935 struct via_spec *spec = codec->spec;
944 unsigned int i;
945 936
946 if (!spec) 937 if (!spec)
947 return; 938 return;
948 939
949 if (spec->kctl_alloc) { 940 via_free_kctls(codec);
950 for (i = 0; i < spec->num_kctl_used; i++)
951 kfree(spec->kctl_alloc[i].name);
952 kfree(spec->kctl_alloc);
953 }
954
955 kfree(codec->spec); 941 kfree(codec->spec);
956} 942}
957 943
@@ -1373,8 +1359,8 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
1373 if (spec->autocfg.dig_in_pin) 1359 if (spec->autocfg.dig_in_pin)
1374 spec->dig_in_nid = VT1708_DIGIN_NID; 1360 spec->dig_in_nid = VT1708_DIGIN_NID;
1375 1361
1376 if (spec->kctl_alloc) 1362 if (spec->kctls.list)
1377 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 1363 spec->mixers[spec->num_mixers++] = spec->kctls.list;
1378 1364
1379 spec->init_verbs[spec->num_iverbs++] = vt1708_volume_init_verbs; 1365 spec->init_verbs[spec->num_iverbs++] = vt1708_volume_init_verbs;
1380 1366
@@ -1846,8 +1832,8 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
1846 if (spec->autocfg.dig_in_pin) 1832 if (spec->autocfg.dig_in_pin)
1847 spec->dig_in_nid = VT1709_DIGIN_NID; 1833 spec->dig_in_nid = VT1709_DIGIN_NID;
1848 1834
1849 if (spec->kctl_alloc) 1835 if (spec->kctls.list)
1850 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 1836 spec->mixers[spec->num_mixers++] = spec->kctls.list;
1851 1837
1852 spec->input_mux = &spec->private_imux[0]; 1838 spec->input_mux = &spec->private_imux[0];
1853 1839
@@ -2390,8 +2376,8 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
2390 if (spec->autocfg.dig_in_pin) 2376 if (spec->autocfg.dig_in_pin)
2391 spec->dig_in_nid = VT1708B_DIGIN_NID; 2377 spec->dig_in_nid = VT1708B_DIGIN_NID;
2392 2378
2393 if (spec->kctl_alloc) 2379 if (spec->kctls.list)
2394 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 2380 spec->mixers[spec->num_mixers++] = spec->kctls.list;
2395 2381
2396 spec->input_mux = &spec->private_imux[0]; 2382 spec->input_mux = &spec->private_imux[0];
2397 2383
@@ -2855,8 +2841,8 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec)
2855 2841
2856 spec->extra_dig_out_nid = 0x15; 2842 spec->extra_dig_out_nid = 0x15;
2857 2843
2858 if (spec->kctl_alloc) 2844 if (spec->kctls.list)
2859 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 2845 spec->mixers[spec->num_mixers++] = spec->kctls.list;
2860 2846
2861 spec->input_mux = &spec->private_imux[0]; 2847 spec->input_mux = &spec->private_imux[0];
2862 2848
@@ -3174,8 +3160,8 @@ static int vt1702_parse_auto_config(struct hda_codec *codec)
3174 3160
3175 spec->extra_dig_out_nid = 0x1B; 3161 spec->extra_dig_out_nid = 0x1B;
3176 3162
3177 if (spec->kctl_alloc) 3163 if (spec->kctls.list)
3178 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 3164 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3179 3165
3180 spec->input_mux = &spec->private_imux[0]; 3166 spec->input_mux = &spec->private_imux[0];
3181 3167
@@ -3262,74 +3248,97 @@ static int patch_vt1702(struct hda_codec *codec)
3262/* 3248/*
3263 * patch entries 3249 * patch entries
3264 */ 3250 */
3265struct hda_codec_preset snd_hda_preset_via[] = { 3251static struct hda_codec_preset snd_hda_preset_via[] = {
3266 { .id = 0x11061708, .name = "VIA VT1708", .patch = patch_vt1708}, 3252 { .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708},
3267 { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708}, 3253 { .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708},
3268 { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708}, 3254 { .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708},
3269 { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708}, 3255 { .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708},
3270 { .id = 0x1106E710, .name = "VIA VT1709 10-Ch", 3256 { .id = 0x1106e710, .name = "VT1709 10-Ch",
3271 .patch = patch_vt1709_10ch}, 3257 .patch = patch_vt1709_10ch},
3272 { .id = 0x1106E711, .name = "VIA VT1709 10-Ch", 3258 { .id = 0x1106e711, .name = "VT1709 10-Ch",
3273 .patch = patch_vt1709_10ch}, 3259 .patch = patch_vt1709_10ch},
3274 { .id = 0x1106E712, .name = "VIA VT1709 10-Ch", 3260 { .id = 0x1106e712, .name = "VT1709 10-Ch",
3275 .patch = patch_vt1709_10ch}, 3261 .patch = patch_vt1709_10ch},
3276 { .id = 0x1106E713, .name = "VIA VT1709 10-Ch", 3262 { .id = 0x1106e713, .name = "VT1709 10-Ch",
3277 .patch = patch_vt1709_10ch}, 3263 .patch = patch_vt1709_10ch},
3278 { .id = 0x1106E714, .name = "VIA VT1709 6-Ch", 3264 { .id = 0x1106e714, .name = "VT1709 6-Ch",
3279 .patch = patch_vt1709_6ch}, 3265 .patch = patch_vt1709_6ch},
3280 { .id = 0x1106E715, .name = "VIA VT1709 6-Ch", 3266 { .id = 0x1106e715, .name = "VT1709 6-Ch",
3281 .patch = patch_vt1709_6ch}, 3267 .patch = patch_vt1709_6ch},
3282 { .id = 0x1106E716, .name = "VIA VT1709 6-Ch", 3268 { .id = 0x1106e716, .name = "VT1709 6-Ch",
3283 .patch = patch_vt1709_6ch}, 3269 .patch = patch_vt1709_6ch},
3284 { .id = 0x1106E717, .name = "VIA VT1709 6-Ch", 3270 { .id = 0x1106e717, .name = "VT1709 6-Ch",
3285 .patch = patch_vt1709_6ch}, 3271 .patch = patch_vt1709_6ch},
3286 { .id = 0x1106E720, .name = "VIA VT1708B 8-Ch", 3272 { .id = 0x1106e720, .name = "VT1708B 8-Ch",
3287 .patch = patch_vt1708B_8ch}, 3273 .patch = patch_vt1708B_8ch},
3288 { .id = 0x1106E721, .name = "VIA VT1708B 8-Ch", 3274 { .id = 0x1106e721, .name = "VT1708B 8-Ch",
3289 .patch = patch_vt1708B_8ch}, 3275 .patch = patch_vt1708B_8ch},
3290 { .id = 0x1106E722, .name = "VIA VT1708B 8-Ch", 3276 { .id = 0x1106e722, .name = "VT1708B 8-Ch",
3291 .patch = patch_vt1708B_8ch}, 3277 .patch = patch_vt1708B_8ch},
3292 { .id = 0x1106E723, .name = "VIA VT1708B 8-Ch", 3278 { .id = 0x1106e723, .name = "VT1708B 8-Ch",
3293 .patch = patch_vt1708B_8ch}, 3279 .patch = patch_vt1708B_8ch},
3294 { .id = 0x1106E724, .name = "VIA VT1708B 4-Ch", 3280 { .id = 0x1106e724, .name = "VT1708B 4-Ch",
3295 .patch = patch_vt1708B_4ch}, 3281 .patch = patch_vt1708B_4ch},
3296 { .id = 0x1106E725, .name = "VIA VT1708B 4-Ch", 3282 { .id = 0x1106e725, .name = "VT1708B 4-Ch",
3297 .patch = patch_vt1708B_4ch}, 3283 .patch = patch_vt1708B_4ch},
3298 { .id = 0x1106E726, .name = "VIA VT1708B 4-Ch", 3284 { .id = 0x1106e726, .name = "VT1708B 4-Ch",
3299 .patch = patch_vt1708B_4ch}, 3285 .patch = patch_vt1708B_4ch},
3300 { .id = 0x1106E727, .name = "VIA VT1708B 4-Ch", 3286 { .id = 0x1106e727, .name = "VT1708B 4-Ch",
3301 .patch = patch_vt1708B_4ch}, 3287 .patch = patch_vt1708B_4ch},
3302 { .id = 0x11060397, .name = "VIA VT1708S", 3288 { .id = 0x11060397, .name = "VT1708S",
3303 .patch = patch_vt1708S}, 3289 .patch = patch_vt1708S},
3304 { .id = 0x11061397, .name = "VIA VT1708S", 3290 { .id = 0x11061397, .name = "VT1708S",
3305 .patch = patch_vt1708S}, 3291 .patch = patch_vt1708S},
3306 { .id = 0x11062397, .name = "VIA VT1708S", 3292 { .id = 0x11062397, .name = "VT1708S",
3307 .patch = patch_vt1708S}, 3293 .patch = patch_vt1708S},
3308 { .id = 0x11063397, .name = "VIA VT1708S", 3294 { .id = 0x11063397, .name = "VT1708S",
3309 .patch = patch_vt1708S}, 3295 .patch = patch_vt1708S},
3310 { .id = 0x11064397, .name = "VIA VT1708S", 3296 { .id = 0x11064397, .name = "VT1708S",
3311 .patch = patch_vt1708S}, 3297 .patch = patch_vt1708S},
3312 { .id = 0x11065397, .name = "VIA VT1708S", 3298 { .id = 0x11065397, .name = "VT1708S",
3313 .patch = patch_vt1708S}, 3299 .patch = patch_vt1708S},
3314 { .id = 0x11066397, .name = "VIA VT1708S", 3300 { .id = 0x11066397, .name = "VT1708S",
3315 .patch = patch_vt1708S}, 3301 .patch = patch_vt1708S},
3316 { .id = 0x11067397, .name = "VIA VT1708S", 3302 { .id = 0x11067397, .name = "VT1708S",
3317 .patch = patch_vt1708S}, 3303 .patch = patch_vt1708S},
3318 { .id = 0x11060398, .name = "VIA VT1702", 3304 { .id = 0x11060398, .name = "VT1702",
3319 .patch = patch_vt1702}, 3305 .patch = patch_vt1702},
3320 { .id = 0x11061398, .name = "VIA VT1702", 3306 { .id = 0x11061398, .name = "VT1702",
3321 .patch = patch_vt1702}, 3307 .patch = patch_vt1702},
3322 { .id = 0x11062398, .name = "VIA VT1702", 3308 { .id = 0x11062398, .name = "VT1702",
3323 .patch = patch_vt1702}, 3309 .patch = patch_vt1702},
3324 { .id = 0x11063398, .name = "VIA VT1702", 3310 { .id = 0x11063398, .name = "VT1702",
3325 .patch = patch_vt1702}, 3311 .patch = patch_vt1702},
3326 { .id = 0x11064398, .name = "VIA VT1702", 3312 { .id = 0x11064398, .name = "VT1702",
3327 .patch = patch_vt1702}, 3313 .patch = patch_vt1702},
3328 { .id = 0x11065398, .name = "VIA VT1702", 3314 { .id = 0x11065398, .name = "VT1702",
3329 .patch = patch_vt1702}, 3315 .patch = patch_vt1702},
3330 { .id = 0x11066398, .name = "VIA VT1702", 3316 { .id = 0x11066398, .name = "VT1702",
3331 .patch = patch_vt1702}, 3317 .patch = patch_vt1702},
3332 { .id = 0x11067398, .name = "VIA VT1702", 3318 { .id = 0x11067398, .name = "VT1702",
3333 .patch = patch_vt1702}, 3319 .patch = patch_vt1702},
3334 {} /* terminator */ 3320 {} /* terminator */
3335}; 3321};
3322
3323MODULE_ALIAS("snd-hda-codec-id:1106*");
3324
3325static struct hda_codec_preset_list via_list = {
3326 .preset = snd_hda_preset_via,
3327 .owner = THIS_MODULE,
3328};
3329
3330MODULE_LICENSE("GPL");
3331MODULE_DESCRIPTION("VIA HD-audio codec");
3332
3333static int __init patch_via_init(void)
3334{
3335 return snd_hda_add_codec_preset(&via_list);
3336}
3337
3338static void __exit patch_via_exit(void)
3339{
3340 snd_hda_delete_codec_preset(&via_list);
3341}
3342
3343module_init(patch_via_init)
3344module_exit(patch_via_exit)