aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-03 04:07:24 -0500
committerTakashi Iwai <tiwai@suse.de>2015-03-23 08:17:17 -0400
commit7639a06c23c7d4cda34c2546bd7290d8753849ca (patch)
treee3ede67363b832c068f3e5e9ca6d1654824146a8 /sound/pci
parentd068ebc25e6e1360510ad8023fe7bca3dacd204e (diff)
ALSA: hda - Move a part of hda_codec stuff into hdac_device
Now some codes and functionalities of hda_codec struct are moved to hdac_device struct. A few basic attributes like the codec address, vendor ID number, FG numbers, etc are moved to hdac_device, and they are accessed like codec->core.addr. The basic verb exec functions are moved, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_auto_parser.c33
-rw-r--r--sound/pci/hda/hda_beep.c4
-rw-r--r--sound/pci/hda/hda_bind.c95
-rw-r--r--sound/pci/hda/hda_codec.c396
-rw-r--r--sound/pci/hda/hda_codec.h43
-rw-r--r--sound/pci/hda/hda_generic.c25
-rw-r--r--sound/pci/hda/hda_local.h15
-rw-r--r--sound/pci/hda/hda_proc.c42
-rw-r--r--sound/pci/hda/hda_sysfs.c58
-rw-r--r--sound/pci/hda/local.h39
-rw-r--r--sound/pci/hda/patch_analog.c2
-rw-r--r--sound/pci/hda/patch_ca0132.c6
-rw-r--r--sound/pci/hda/patch_conexant.c16
-rw-r--r--sound/pci/hda/patch_hdmi.c20
-rw-r--r--sound/pci/hda/patch_realtek.c78
-rw-r--r--sound/pci/hda/patch_si3054.c6
-rw-r--r--sound/pci/hda/patch_sigmatel.c84
-rw-r--r--sound/pci/hda/patch_via.c23
-rw-r--r--sound/pci/hda/thinkpad_helper.c2
19 files changed, 323 insertions, 664 deletions
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
index 3f8706bb3d16..03b7399bb7f0 100644
--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -172,7 +172,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
172 const hda_nid_t *ignore_nids, 172 const hda_nid_t *ignore_nids,
173 unsigned int cond_flags) 173 unsigned int cond_flags)
174{ 174{
175 hda_nid_t nid, end_nid; 175 hda_nid_t nid;
176 short seq, assoc_line_out; 176 short seq, assoc_line_out;
177 struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)]; 177 struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)];
178 struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)]; 178 struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)];
@@ -189,8 +189,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
189 memset(hp_out, 0, sizeof(hp_out)); 189 memset(hp_out, 0, sizeof(hp_out));
190 assoc_line_out = 0; 190 assoc_line_out = 0;
191 191
192 end_nid = codec->start_nid + codec->num_nodes; 192 for_each_hda_codec_node(nid, codec) {
193 for (nid = codec->start_nid; nid < end_nid; nid++) {
194 unsigned int wid_caps = get_wcaps(codec, nid); 193 unsigned int wid_caps = get_wcaps(codec, nid);
195 unsigned int wid_type = get_wcaps_type(wid_caps); 194 unsigned int wid_type = get_wcaps_type(wid_caps);
196 unsigned int def_conf; 195 unsigned int def_conf;
@@ -410,7 +409,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
410 * debug prints of the parsed results 409 * debug prints of the parsed results
411 */ 410 */
412 codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", 411 codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n",
413 codec->chip_name, cfg->line_outs, cfg->line_out_pins[0], 412 codec->core.chip_name, cfg->line_outs, cfg->line_out_pins[0],
414 cfg->line_out_pins[1], cfg->line_out_pins[2], 413 cfg->line_out_pins[1], cfg->line_out_pins[2],
415 cfg->line_out_pins[3], cfg->line_out_pins[4], 414 cfg->line_out_pins[3], cfg->line_out_pins[4],
416 cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : 415 cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" :
@@ -836,33 +835,33 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
836 if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins) 835 if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins)
837 break; 836 break;
838 codec_dbg(codec, "%s: Apply pincfg for %s\n", 837 codec_dbg(codec, "%s: Apply pincfg for %s\n",
839 codec->chip_name, modelname); 838 codec->core.chip_name, modelname);
840 snd_hda_apply_pincfgs(codec, fix->v.pins); 839 snd_hda_apply_pincfgs(codec, fix->v.pins);
841 break; 840 break;
842 case HDA_FIXUP_VERBS: 841 case HDA_FIXUP_VERBS:
843 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs) 842 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs)
844 break; 843 break;
845 codec_dbg(codec, "%s: Apply fix-verbs for %s\n", 844 codec_dbg(codec, "%s: Apply fix-verbs for %s\n",
846 codec->chip_name, modelname); 845 codec->core.chip_name, modelname);
847 snd_hda_add_verbs(codec, fix->v.verbs); 846 snd_hda_add_verbs(codec, fix->v.verbs);
848 break; 847 break;
849 case HDA_FIXUP_FUNC: 848 case HDA_FIXUP_FUNC:
850 if (!fix->v.func) 849 if (!fix->v.func)
851 break; 850 break;
852 codec_dbg(codec, "%s: Apply fix-func for %s\n", 851 codec_dbg(codec, "%s: Apply fix-func for %s\n",
853 codec->chip_name, modelname); 852 codec->core.chip_name, modelname);
854 fix->v.func(codec, fix, action); 853 fix->v.func(codec, fix, action);
855 break; 854 break;
856 case HDA_FIXUP_PINCTLS: 855 case HDA_FIXUP_PINCTLS:
857 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins) 856 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins)
858 break; 857 break;
859 codec_dbg(codec, "%s: Apply pinctl for %s\n", 858 codec_dbg(codec, "%s: Apply pinctl for %s\n",
860 codec->chip_name, modelname); 859 codec->core.chip_name, modelname);
861 set_pin_targets(codec, fix->v.pins); 860 set_pin_targets(codec, fix->v.pins);
862 break; 861 break;
863 default: 862 default:
864 codec_err(codec, "%s: Invalid fixup type %d\n", 863 codec_err(codec, "%s: Invalid fixup type %d\n",
865 codec->chip_name, fix->type); 864 codec->core.chip_name, fix->type);
866 break; 865 break;
867 } 866 }
868 if (!fix->chained || fix->chained_before) 867 if (!fix->chained || fix->chained_before)
@@ -912,16 +911,16 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
912 return; 911 return;
913 912
914 for (pq = pin_quirk; pq->subvendor; pq++) { 913 for (pq = pin_quirk; pq->subvendor; pq++) {
915 if ((codec->subsystem_id & 0xffff0000) != (pq->subvendor << 16)) 914 if ((codec->core.subsystem_id & 0xffff0000) != (pq->subvendor << 16))
916 continue; 915 continue;
917 if (codec->vendor_id != pq->codec) 916 if (codec->core.vendor_id != pq->codec)
918 continue; 917 continue;
919 if (pin_config_match(codec, pq->pins)) { 918 if (pin_config_match(codec, pq->pins)) {
920 codec->fixup_id = pq->value; 919 codec->fixup_id = pq->value;
921#ifdef CONFIG_SND_DEBUG_VERBOSE 920#ifdef CONFIG_SND_DEBUG_VERBOSE
922 codec->fixup_name = pq->name; 921 codec->fixup_name = pq->name;
923 codec_dbg(codec, "%s: picked fixup %s (pin match)\n", 922 codec_dbg(codec, "%s: picked fixup %s (pin match)\n",
924 codec->chip_name, codec->fixup_name); 923 codec->core.chip_name, codec->fixup_name);
925#endif 924#endif
926 codec->fixup_list = fixlist; 925 codec->fixup_list = fixlist;
927 return; 926 return;
@@ -963,7 +962,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
963 codec->fixup_name = NULL; 962 codec->fixup_name = NULL;
964 codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP; 963 codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP;
965 codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n", 964 codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n",
966 codec->chip_name); 965 codec->core.chip_name);
967 return; 966 return;
968 } 967 }
969 968
@@ -974,7 +973,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
974 codec->fixup_name = models->name; 973 codec->fixup_name = models->name;
975 codec->fixup_list = fixlist; 974 codec->fixup_list = fixlist;
976 codec_dbg(codec, "%s: picked fixup %s (model specified)\n", 975 codec_dbg(codec, "%s: picked fixup %s (model specified)\n",
977 codec->chip_name, codec->fixup_name); 976 codec->core.chip_name, codec->fixup_name);
978 return; 977 return;
979 } 978 }
980 models++; 979 models++;
@@ -987,7 +986,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
987#ifdef CONFIG_SND_DEBUG_VERBOSE 986#ifdef CONFIG_SND_DEBUG_VERBOSE
988 name = q->name; 987 name = q->name;
989 codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n", 988 codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n",
990 codec->chip_name, name, q->subdevice_mask ? "" : " - vendor generic"); 989 codec->core.chip_name, name, q->subdevice_mask ? "" : " - vendor generic");
991#endif 990#endif
992 } 991 }
993 } 992 }
@@ -996,12 +995,12 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
996 unsigned int vendorid = 995 unsigned int vendorid =
997 q->subdevice | (q->subvendor << 16); 996 q->subdevice | (q->subvendor << 16);
998 unsigned int mask = 0xffff0000 | q->subdevice_mask; 997 unsigned int mask = 0xffff0000 | q->subdevice_mask;
999 if ((codec->subsystem_id & mask) == (vendorid & mask)) { 998 if ((codec->core.subsystem_id & mask) == (vendorid & mask)) {
1000 id = q->value; 999 id = q->value;
1001#ifdef CONFIG_SND_DEBUG_VERBOSE 1000#ifdef CONFIG_SND_DEBUG_VERBOSE
1002 name = q->name; 1001 name = q->name;
1003 codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n", 1002 codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n",
1004 codec->chip_name, name); 1003 codec->core.chip_name, name);
1005#endif 1004#endif
1006 break; 1005 break;
1007 } 1006 }
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 4cdac3a71cae..3364dc0fdeab 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -165,8 +165,8 @@ static int snd_hda_do_attach(struct hda_beep *beep)
165 input_dev->id.bustype = BUS_PCI; 165 input_dev->id.bustype = BUS_PCI;
166 input_dev->dev.parent = &codec->card->card_dev; 166 input_dev->dev.parent = &codec->card->card_dev;
167 167
168 input_dev->id.vendor = codec->vendor_id >> 16; 168 input_dev->id.vendor = codec->core.vendor_id >> 16;
169 input_dev->id.product = codec->vendor_id & 0xffff; 169 input_dev->id.product = codec->core.vendor_id & 0xffff;
170 input_dev->id.version = 0x01; 170 input_dev->id.version = 0x01;
171 171
172 input_dev->evbit[0] = BIT_MASK(EV_SND); 172 input_dev->evbit[0] = BIT_MASK(EV_SND);
diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
index 0b9ea70c546b..ad276a9771db 100644
--- a/sound/pci/hda/hda_bind.c
+++ b/sound/pci/hda/hda_bind.c
@@ -14,36 +14,6 @@
14#include "hda_codec.h" 14#include "hda_codec.h"
15#include "hda_local.h" 15#include "hda_local.h"
16 16
17/* codec vendor labels */
18struct hda_vendor_id {
19 unsigned int id;
20 const char *name;
21};
22
23static struct hda_vendor_id hda_vendor_ids[] = {
24 { 0x1002, "ATI" },
25 { 0x1013, "Cirrus Logic" },
26 { 0x1057, "Motorola" },
27 { 0x1095, "Silicon Image" },
28 { 0x10de, "Nvidia" },
29 { 0x10ec, "Realtek" },
30 { 0x1102, "Creative" },
31 { 0x1106, "VIA" },
32 { 0x111d, "IDT" },
33 { 0x11c1, "LSI" },
34 { 0x11d4, "Analog Devices" },
35 { 0x13f6, "C-Media" },
36 { 0x14f1, "Conexant" },
37 { 0x17e8, "Chrontel" },
38 { 0x1854, "LG" },
39 { 0x1aec, "Wolfson Microelectronics" },
40 { 0x1af4, "QEMU" },
41 { 0x434d, "C-Media" },
42 { 0x8086, "Intel" },
43 { 0x8384, "SigmaTel" },
44 {} /* terminator */
45};
46
47/* 17/*
48 * find a matching codec preset 18 * find a matching codec preset
49 */ 19 */
@@ -54,19 +24,19 @@ static int hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
54 container_of(drv, struct hda_codec_driver, core); 24 container_of(drv, struct hda_codec_driver, core);
55 const struct hda_codec_preset *preset; 25 const struct hda_codec_preset *preset;
56 /* check probe_id instead of vendor_id if set */ 26 /* check probe_id instead of vendor_id if set */
57 u32 id = codec->probe_id ? codec->probe_id : codec->vendor_id; 27 u32 id = codec->probe_id ? codec->probe_id : codec->core.vendor_id;
58 28
59 for (preset = driver->preset; preset->id; preset++) { 29 for (preset = driver->preset; preset->id; preset++) {
60 u32 mask = preset->mask; 30 u32 mask = preset->mask;
61 31
62 if (preset->afg && preset->afg != codec->afg) 32 if (preset->afg && preset->afg != codec->core.afg)
63 continue; 33 continue;
64 if (preset->mfg && preset->mfg != codec->mfg) 34 if (preset->mfg && preset->mfg != codec->core.mfg)
65 continue; 35 continue;
66 if (!mask) 36 if (!mask)
67 mask = ~0; 37 mask = ~0;
68 if (preset->id == (id & mask) && 38 if (preset->id == (id & mask) &&
69 (!preset->rev || preset->rev == codec->revision_id)) { 39 (!preset->rev || preset->rev == codec->core.revision_id)) {
70 codec->preset = preset; 40 codec->preset = preset;
71 return 1; 41 return 1;
72 } 42 }
@@ -86,15 +56,11 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
86/* reset the codec name from the preset */ 56/* reset the codec name from the preset */
87static int codec_refresh_name(struct hda_codec *codec, const char *name) 57static int codec_refresh_name(struct hda_codec *codec, const char *name)
88{ 58{
89 char tmp[16]; 59 if (name) {
90 60 kfree(codec->core.chip_name);
91 kfree(codec->chip_name); 61 codec->core.chip_name = kstrdup(name, GFP_KERNEL);
92 if (!name) {
93 sprintf(tmp, "ID %x", codec->vendor_id & 0xffff);
94 name = tmp;
95 } 62 }
96 codec->chip_name = kstrdup(name, GFP_KERNEL); 63 return codec->core.chip_name ? 0 : -ENOMEM;
97 return codec->chip_name ? 0 : -ENOMEM;
98} 64}
99 65
100static int hda_codec_driver_probe(struct device *dev) 66static int hda_codec_driver_probe(struct device *dev)
@@ -192,48 +158,23 @@ static inline bool codec_probed(struct hda_codec *codec)
192static void codec_bind_module(struct hda_codec *codec) 158static void codec_bind_module(struct hda_codec *codec)
193{ 159{
194#ifdef MODULE 160#ifdef MODULE
195 request_module("snd-hda-codec-id:%08x", codec->vendor_id); 161 request_module("snd-hda-codec-id:%08x", codec->core.vendor_id);
196 if (codec_probed(codec)) 162 if (codec_probed(codec))
197 return; 163 return;
198 request_module("snd-hda-codec-id:%04x*", 164 request_module("snd-hda-codec-id:%04x*",
199 (codec->vendor_id >> 16) & 0xffff); 165 (codec->core.vendor_id >> 16) & 0xffff);
200 if (codec_probed(codec)) 166 if (codec_probed(codec))
201 return; 167 return;
202#endif 168#endif
203} 169}
204 170
205/* store the codec vendor name */
206static int get_codec_vendor_name(struct hda_codec *codec)
207{
208 const struct hda_vendor_id *c;
209 const char *vendor = NULL;
210 u16 vendor_id = codec->vendor_id >> 16;
211 char tmp[16];
212
213 for (c = hda_vendor_ids; c->id; c++) {
214 if (c->id == vendor_id) {
215 vendor = c->name;
216 break;
217 }
218 }
219 if (!vendor) {
220 sprintf(tmp, "Generic %04x", vendor_id);
221 vendor = tmp;
222 }
223 codec->vendor_name = kstrdup(vendor, GFP_KERNEL);
224 if (!codec->vendor_name)
225 return -ENOMEM;
226 return 0;
227}
228
229#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) 171#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
230/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */ 172/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
231static bool is_likely_hdmi_codec(struct hda_codec *codec) 173static bool is_likely_hdmi_codec(struct hda_codec *codec)
232{ 174{
233 hda_nid_t nid = codec->start_nid; 175 hda_nid_t nid;
234 int i;
235 176
236 for (i = 0; i < codec->num_nodes; i++, nid++) { 177 for_each_hda_codec_node(nid, codec) {
237 unsigned int wcaps = get_wcaps(codec, nid); 178 unsigned int wcaps = get_wcaps(codec, nid);
238 switch (get_wcaps_type(wcaps)) { 179 switch (get_wcaps_type(wcaps)) {
239 case AC_WID_AUD_IN: 180 case AC_WID_AUD_IN:
@@ -294,12 +235,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
294{ 235{
295 int err; 236 int err;
296 237
297 if (!codec->vendor_name) {
298 err = get_codec_vendor_name(codec);
299 if (err < 0)
300 return err;
301 }
302
303 if (is_generic_config(codec)) 238 if (is_generic_config(codec))
304 codec->probe_id = HDA_CODEC_ID_GENERIC; 239 codec->probe_id = HDA_CODEC_ID_GENERIC;
305 else 240 else
@@ -320,10 +255,10 @@ int snd_hda_codec_configure(struct hda_codec *codec)
320 } 255 }
321 256
322 /* audio codec should override the mixer name */ 257 /* audio codec should override the mixer name */
323 if (codec->afg || !*codec->card->mixername) 258 if (codec->core.afg || !*codec->card->mixername)
324 snprintf(codec->card->mixername, 259 snprintf(codec->card->mixername,
325 sizeof(codec->card->mixername), 260 sizeof(codec->card->mixername), "%s %s",
326 "%s %s", codec->vendor_name, codec->chip_name); 261 codec->core.vendor_name, codec->core.chip_name);
327 return 0; 262 return 0;
328 263
329 error: 264 error:
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index f96bff37c787..ddfc0fbbee23 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -40,7 +40,7 @@
40#include <sound/hda_hwdep.h> 40#include <sound/hda_hwdep.h>
41 41
42#ifdef CONFIG_PM 42#ifdef CONFIG_PM
43#define codec_in_pm(codec) atomic_read(&(codec)->in_pm) 43#define codec_in_pm(codec) atomic_read(&(codec)->core.in_pm)
44#define hda_codec_is_power_on(codec) \ 44#define hda_codec_is_power_on(codec) \
45 (!pm_runtime_suspended(hda_codec_dev(codec))) 45 (!pm_runtime_suspended(hda_codec_dev(codec)))
46#else 46#else
@@ -48,6 +48,11 @@
48#define hda_codec_is_power_on(codec) 1 48#define hda_codec_is_power_on(codec) 1
49#endif 49#endif
50 50
51#define codec_has_epss(codec) \
52 ((codec)->core.power_caps & AC_PWRST_EPSS)
53#define codec_has_clkstop(codec) \
54 ((codec)->core.power_caps & AC_PWRST_CLKSTOP)
55
51/** 56/**
52 * snd_hda_get_jack_location - Give a location string of the jack 57 * snd_hda_get_jack_location - Give a location string of the jack
53 * @cfg: pin default config value 58 * @cfg: pin default config value
@@ -119,30 +124,6 @@ const char *snd_hda_get_jack_type(u32 cfg)
119EXPORT_SYMBOL_GPL(snd_hda_get_jack_type); 124EXPORT_SYMBOL_GPL(snd_hda_get_jack_type);
120 125
121/* 126/*
122 * Compose a 32bit command word to be sent to the HD-audio controller
123 */
124static inline unsigned int
125make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int flags,
126 unsigned int verb, unsigned int parm)
127{
128 unsigned int addr = codec->core.addr;
129 u32 val;
130
131 if ((addr & ~0xf) || (nid & ~0x7f) ||
132 (verb & ~0xfff) || (parm & ~0xffff)) {
133 codec_err(codec, "hda-codec: out of range cmd %x:%x:%x:%x\n",
134 addr, nid, verb, parm);
135 return ~0;
136 }
137
138 val = (u32)addr << 28;
139 val |= (u32)nid << 20;
140 val |= verb << 8;
141 val |= parm;
142 return val;
143}
144
145/*
146 * Send and receive a verb 127 * Send and receive a verb
147 */ 128 */
148static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, 129static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
@@ -194,7 +175,7 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
194 int flags, 175 int flags,
195 unsigned int verb, unsigned int parm) 176 unsigned int verb, unsigned int parm)
196{ 177{
197 unsigned cmd = make_codec_cmd(codec, nid, flags, verb, parm); 178 unsigned int cmd = snd_hdac_make_cmd(&codec->core, nid, verb, parm);
198 unsigned int res; 179 unsigned int res;
199 if (codec_exec_verb(codec, cmd, flags, &res)) 180 if (codec_exec_verb(codec, cmd, flags, &res))
200 return -1; 181 return -1;
@@ -217,7 +198,7 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_read);
217int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, 198int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,
218 unsigned int verb, unsigned int parm) 199 unsigned int verb, unsigned int parm)
219{ 200{
220 unsigned int cmd = make_codec_cmd(codec, nid, flags, verb, parm); 201 unsigned int cmd = snd_hdac_make_cmd(&codec->core, nid, verb, parm);
221 return codec_exec_verb(codec, cmd, flags, NULL); 202 return codec_exec_verb(codec, cmd, flags, NULL);
222} 203}
223EXPORT_SYMBOL_GPL(snd_hda_codec_write); 204EXPORT_SYMBOL_GPL(snd_hda_codec_write);
@@ -237,30 +218,6 @@ void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
237} 218}
238EXPORT_SYMBOL_GPL(snd_hda_sequence_write); 219EXPORT_SYMBOL_GPL(snd_hda_sequence_write);
239 220
240/**
241 * snd_hda_get_sub_nodes - get the range of sub nodes
242 * @codec: the HDA codec
243 * @nid: NID to parse
244 * @start_id: the pointer to store the start NID
245 *
246 * Parse the NID and store the start NID of its sub-nodes.
247 * Returns the number of sub-nodes.
248 */
249int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
250 hda_nid_t *start_id)
251{
252 unsigned int parm;
253
254 parm = snd_hda_param_read(codec, nid, AC_PAR_NODE_COUNT);
255 if (parm == -1) {
256 *start_id = 0;
257 return 0;
258 }
259 *start_id = (parm >> 16) & 0x7fff;
260 return (int)(parm & 0x7fff);
261}
262EXPORT_SYMBOL_GPL(snd_hda_get_sub_nodes);
263
264/* connection list element */ 221/* connection list element */
265struct hda_conn_list { 222struct hda_conn_list {
266 struct list_head list; 223 struct list_head list;
@@ -401,128 +358,6 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
401} 358}
402EXPORT_SYMBOL_GPL(snd_hda_get_connections); 359EXPORT_SYMBOL_GPL(snd_hda_get_connections);
403 360
404/* return CONNLIST_LEN parameter of the given widget */
405static unsigned int get_num_conns(struct hda_codec *codec, hda_nid_t nid)
406{
407 unsigned int wcaps = get_wcaps(codec, nid);
408 unsigned int parm;
409
410 if (!(wcaps & AC_WCAP_CONN_LIST) &&
411 get_wcaps_type(wcaps) != AC_WID_VOL_KNB)
412 return 0;
413
414 parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN);
415 if (parm == -1)
416 parm = 0;
417 return parm;
418}
419
420int snd_hda_get_num_raw_conns(struct hda_codec *codec, hda_nid_t nid)
421{
422 return snd_hda_get_raw_connections(codec, nid, NULL, 0);
423}
424
425/**
426 * snd_hda_get_raw_connections - copy connection list without cache
427 * @codec: the HDA codec
428 * @nid: NID to parse
429 * @conn_list: connection list array
430 * @max_conns: max. number of connections to store
431 *
432 * Like snd_hda_get_connections(), copy the connection list but without
433 * checking through the connection-list cache.
434 * Currently called only from hda_proc.c, so not exported.
435 */
436int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
437 hda_nid_t *conn_list, int max_conns)
438{
439 unsigned int parm;
440 int i, conn_len, conns;
441 unsigned int shift, num_elems, mask;
442 hda_nid_t prev_nid;
443 int null_count = 0;
444
445 parm = get_num_conns(codec, nid);
446 if (!parm)
447 return 0;
448
449 if (parm & AC_CLIST_LONG) {
450 /* long form */
451 shift = 16;
452 num_elems = 2;
453 } else {
454 /* short form */
455 shift = 8;
456 num_elems = 4;
457 }
458 conn_len = parm & AC_CLIST_LENGTH;
459 mask = (1 << (shift-1)) - 1;
460
461 if (!conn_len)
462 return 0; /* no connection */
463
464 if (conn_len == 1) {
465 /* single connection */
466 parm = snd_hda_codec_read(codec, nid, 0,
467 AC_VERB_GET_CONNECT_LIST, 0);
468 if (parm == -1 && codec->bus->rirb_error)
469 return -EIO;
470 if (conn_list)
471 conn_list[0] = parm & mask;
472 return 1;
473 }
474
475 /* multi connection */
476 conns = 0;
477 prev_nid = 0;
478 for (i = 0; i < conn_len; i++) {
479 int range_val;
480 hda_nid_t val, n;
481
482 if (i % num_elems == 0) {
483 parm = snd_hda_codec_read(codec, nid, 0,
484 AC_VERB_GET_CONNECT_LIST, i);
485 if (parm == -1 && codec->bus->rirb_error)
486 return -EIO;
487 }
488 range_val = !!(parm & (1 << (shift-1))); /* ranges */
489 val = parm & mask;
490 if (val == 0 && null_count++) { /* no second chance */
491 codec_dbg(codec,
492 "invalid CONNECT_LIST verb %x[%i]:%x\n",
493 nid, i, parm);
494 return 0;
495 }
496 parm >>= shift;
497 if (range_val) {
498 /* ranges between the previous and this one */
499 if (!prev_nid || prev_nid >= val) {
500 codec_warn(codec,
501 "invalid dep_range_val %x:%x\n",
502 prev_nid, val);
503 continue;
504 }
505 for (n = prev_nid + 1; n <= val; n++) {
506 if (conn_list) {
507 if (conns >= max_conns)
508 return -ENOSPC;
509 conn_list[conns] = n;
510 }
511 conns++;
512 }
513 } else {
514 if (conn_list) {
515 if (conns >= max_conns)
516 return -ENOSPC;
517 conn_list[conns] = val;
518 }
519 conns++;
520 }
521 prev_nid = val;
522 }
523 return conns;
524}
525
526/** 361/**
527 * snd_hda_override_conn_list - add/modify the connection-list to cache 362 * snd_hda_override_conn_list - add/modify the connection-list to cache
528 * @codec: the HDA codec 363 * @codec: the HDA codec
@@ -738,35 +573,6 @@ int snd_hda_bus_new(struct snd_card *card,
738EXPORT_SYMBOL_GPL(snd_hda_bus_new); 573EXPORT_SYMBOL_GPL(snd_hda_bus_new);
739 574
740/* 575/*
741 * look for an AFG and MFG nodes
742 */
743static void setup_fg_nodes(struct hda_codec *codec)
744{
745 int i, total_nodes, function_id;
746 hda_nid_t nid;
747
748 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
749 for (i = 0; i < total_nodes; i++, nid++) {
750 function_id = snd_hda_param_read(codec, nid,
751 AC_PAR_FUNCTION_TYPE);
752 switch (function_id & 0xff) {
753 case AC_GRP_AUDIO_FUNCTION:
754 codec->afg = nid;
755 codec->afg_function_id = function_id & 0xff;
756 codec->afg_unsol = (function_id >> 8) & 1;
757 break;
758 case AC_GRP_MODEM_FUNCTION:
759 codec->mfg = nid;
760 codec->mfg_function_id = function_id & 0xff;
761 codec->mfg_unsol = (function_id >> 8) & 1;
762 break;
763 default:
764 break;
765 }
766 }
767}
768
769/*
770 * read widget caps for each widget and store in cache 576 * read widget caps for each widget and store in cache
771 */ 577 */
772static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) 578static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
@@ -774,13 +580,11 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
774 int i; 580 int i;
775 hda_nid_t nid; 581 hda_nid_t nid;
776 582
777 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node, 583 codec->wcaps = kmalloc(codec->core.num_nodes * 4, GFP_KERNEL);
778 &codec->start_nid);
779 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL);
780 if (!codec->wcaps) 584 if (!codec->wcaps)
781 return -ENOMEM; 585 return -ENOMEM;
782 nid = codec->start_nid; 586 nid = codec->core.start_nid;
783 for (i = 0; i < codec->num_nodes; i++, nid++) 587 for (i = 0; i < codec->core.num_nodes; i++, nid++)
784 codec->wcaps[i] = snd_hda_param_read(codec, nid, 588 codec->wcaps[i] = snd_hda_param_read(codec, nid,
785 AC_PAR_AUDIO_WIDGET_CAP); 589 AC_PAR_AUDIO_WIDGET_CAP);
786 return 0; 590 return 0;
@@ -789,10 +593,9 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
789/* read all pin default configurations and save codec->init_pins */ 593/* read all pin default configurations and save codec->init_pins */
790static int read_pin_defaults(struct hda_codec *codec) 594static int read_pin_defaults(struct hda_codec *codec)
791{ 595{
792 int i; 596 hda_nid_t nid;
793 hda_nid_t nid = codec->start_nid;
794 597
795 for (i = 0; i < codec->num_nodes; i++, nid++) { 598 for_each_hda_codec_node(nid, codec) {
796 struct hda_pincfg *pin; 599 struct hda_pincfg *pin;
797 unsigned int wcaps = get_wcaps(codec, nid); 600 unsigned int wcaps = get_wcaps(codec, nid);
798 unsigned int wid_type = get_wcaps_type(wcaps); 601 unsigned int wid_type = get_wcaps_type(wcaps);
@@ -1136,9 +939,6 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
1136 remove_conn_list(codec); 939 remove_conn_list(codec);
1137} 940}
1138 941
1139static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
1140 hda_nid_t fg, unsigned int power_state);
1141
1142static unsigned int hda_set_power_state(struct hda_codec *codec, 942static unsigned int hda_set_power_state(struct hda_codec *codec,
1143 unsigned int power_state); 943 unsigned int power_state);
1144 944
@@ -1178,12 +978,10 @@ static void snd_hda_codec_dev_release(struct device *dev)
1178 struct hda_codec *codec = dev_to_hda_codec(dev); 978 struct hda_codec *codec = dev_to_hda_codec(dev);
1179 979
1180 free_init_pincfgs(codec); 980 free_init_pincfgs(codec);
1181 snd_hdac_bus_remove_device(&codec->bus->core, &codec->core); 981 snd_hdac_device_exit(&codec->core);
1182 snd_hda_sysfs_clear(codec); 982 snd_hda_sysfs_clear(codec);
1183 free_hda_cache(&codec->amp_cache); 983 free_hda_cache(&codec->amp_cache);
1184 free_hda_cache(&codec->cmd_cache); 984 free_hda_cache(&codec->cmd_cache);
1185 kfree(codec->vendor_name);
1186 kfree(codec->chip_name);
1187 kfree(codec->modelname); 985 kfree(codec->modelname);
1188 kfree(codec->wcaps); 986 kfree(codec->wcaps);
1189 kfree(codec); 987 kfree(codec);
@@ -1201,7 +999,6 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1201 unsigned int codec_addr, struct hda_codec **codecp) 999 unsigned int codec_addr, struct hda_codec **codecp)
1202{ 1000{
1203 struct hda_codec *codec; 1001 struct hda_codec *codec;
1204 struct device *dev;
1205 char component[31]; 1002 char component[31];
1206 hda_nid_t fg; 1003 hda_nid_t fg;
1207 int err; 1004 int err;
@@ -1220,19 +1017,16 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1220 if (!codec) 1017 if (!codec)
1221 return -ENOMEM; 1018 return -ENOMEM;
1222 1019
1223 codec->core.bus = &bus->core; 1020 sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
1224 codec->core.addr = codec_addr; 1021 err = snd_hdac_device_init(&codec->core, &bus->core, component,
1225 codec->core.type = HDA_DEV_LEGACY; 1022 codec_addr);
1023 if (err < 0) {
1024 kfree(codec);
1025 return err;
1026 }
1226 1027
1227 dev = hda_codec_dev(codec); 1028 codec->core.dev.release = snd_hda_codec_dev_release;
1228 device_initialize(dev); 1029 codec->core.type = HDA_DEV_LEGACY;
1229 dev->parent = bus->core.dev;
1230 dev->bus = &snd_hda_bus_type;
1231 dev->release = snd_hda_codec_dev_release;
1232 dev->groups = snd_hda_dev_attr_groups;
1233 dev_set_name(dev, "hdaudioC%dD%d", card->number, codec_addr);
1234 dev_set_drvdata(dev, codec); /* for sysfs */
1235 device_enable_async_suspend(dev);
1236 1030
1237 codec->bus = bus; 1031 codec->bus = bus;
1238 codec->card = card; 1032 codec->card = card;
@@ -1258,12 +1052,6 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1258 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; 1052 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
1259 1053
1260#ifdef CONFIG_PM 1054#ifdef CONFIG_PM
1261 /* snd_hda_codec_new() marks the codec as power-up, and leave it as is.
1262 * it's powered down later in snd_hda_codec_dev_register().
1263 */
1264 set_bit(codec->core.addr, &bus->core.codec_powered);
1265 pm_runtime_set_active(hda_codec_dev(codec));
1266 pm_runtime_get_noresume(hda_codec_dev(codec));
1267 codec->power_jiffies = jiffies; 1055 codec->power_jiffies = jiffies;
1268#endif 1056#endif
1269 1057
@@ -1277,31 +1065,7 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1277 } 1065 }
1278 } 1066 }
1279 1067
1280 err = snd_hdac_bus_add_device(&bus->core, &codec->core); 1068 fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
1281 if (err < 0)
1282 goto error;
1283
1284 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
1285 AC_PAR_VENDOR_ID);
1286 if (codec->vendor_id == -1)
1287 /* read again, hopefully the access method was corrected
1288 * in the last read...
1289 */
1290 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
1291 AC_PAR_VENDOR_ID);
1292 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT,
1293 AC_PAR_SUBSYSTEM_ID);
1294 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT,
1295 AC_PAR_REV_ID);
1296
1297 setup_fg_nodes(codec);
1298 if (!codec->afg && !codec->mfg) {
1299 codec_err(codec, "no AFG or MFG node found\n");
1300 err = -ENODEV;
1301 goto error;
1302 }
1303
1304 fg = codec->afg ? codec->afg : codec->mfg;
1305 err = read_widget_caps(codec, fg); 1069 err = read_widget_caps(codec, fg);
1306 if (err < 0) 1070 if (err < 0)
1307 goto error; 1071 goto error;
@@ -1309,19 +1073,6 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1309 if (err < 0) 1073 if (err < 0)
1310 goto error; 1074 goto error;
1311 1075
1312 if (!codec->subsystem_id) {
1313 codec->subsystem_id =
1314 snd_hda_codec_read(codec, fg, 0,
1315 AC_VERB_GET_SUBSYSTEM_ID, 0);
1316 }
1317
1318#ifdef CONFIG_PM
1319 codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec, fg,
1320 AC_PWRST_CLKSTOP);
1321#endif
1322 codec->epss = snd_hda_codec_get_supported_ps(codec, fg,
1323 AC_PWRST_EPSS);
1324
1325 /* power-up all before initialization */ 1076 /* power-up all before initialization */
1326 hda_set_power_state(codec, AC_PWRST_D0); 1077 hda_set_power_state(codec, AC_PWRST_D0);
1327 1078
@@ -1329,8 +1080,8 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1329 1080
1330 snd_hda_create_hwdep(codec); 1081 snd_hda_create_hwdep(codec);
1331 1082
1332 sprintf(component, "HDA:%08x,%08x,%08x", codec->vendor_id, 1083 sprintf(component, "HDA:%08x,%08x,%08x", codec->core.vendor_id,
1333 codec->subsystem_id, codec->revision_id); 1084 codec->core.subsystem_id, codec->core.revision_id);
1334 snd_component_add(card, component); 1085 snd_component_add(card, component);
1335 1086
1336 err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops); 1087 err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);
@@ -1342,6 +1093,7 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1342 return 0; 1093 return 0;
1343 1094
1344 error: 1095 error:
1096 pm_runtime_put_noidle(hda_codec_dev(codec));
1345 put_device(hda_codec_dev(codec)); 1097 put_device(hda_codec_dev(codec));
1346 return err; 1098 return err;
1347} 1099}
@@ -1359,11 +1111,15 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)
1359 hda_nid_t fg; 1111 hda_nid_t fg;
1360 int err; 1112 int err;
1361 1113
1114 err = snd_hdac_refresh_widgets(&codec->core);
1115 if (err < 0)
1116 return err;
1117
1362 /* Assume the function group node does not change, 1118 /* Assume the function group node does not change,
1363 * only the widget nodes may change. 1119 * only the widget nodes may change.
1364 */ 1120 */
1365 kfree(codec->wcaps); 1121 kfree(codec->wcaps);
1366 fg = codec->afg ? codec->afg : codec->mfg; 1122 fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
1367 err = read_widget_caps(codec, fg); 1123 err = read_widget_caps(codec, fg);
1368 if (err < 0) 1124 if (err < 0)
1369 return err; 1125 return err;
@@ -1663,7 +1419,7 @@ static unsigned int read_amp_cap(struct hda_codec *codec, hda_nid_t nid,
1663 int direction) 1419 int direction)
1664{ 1420{
1665 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) 1421 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD))
1666 nid = codec->afg; 1422 nid = codec->core.afg;
1667 return snd_hda_param_read(codec, nid, 1423 return snd_hda_param_read(codec, nid,
1668 direction == HDA_OUTPUT ? 1424 direction == HDA_OUTPUT ?
1669 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); 1425 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
@@ -3664,10 +3420,9 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_flush_cache);
3664void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, 3420void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
3665 unsigned int power_state) 3421 unsigned int power_state)
3666{ 3422{
3667 hda_nid_t nid = codec->start_nid; 3423 hda_nid_t nid;
3668 int i;
3669 3424
3670 for (i = 0; i < codec->num_nodes; i++, nid++) { 3425 for_each_hda_codec_node(nid, codec) {
3671 unsigned int wcaps = get_wcaps(codec, nid); 3426 unsigned int wcaps = get_wcaps(codec, nid);
3672 unsigned int state = power_state; 3427 unsigned int state = power_state;
3673 if (!(wcaps & AC_WCAP_POWER)) 3428 if (!(wcaps & AC_WCAP_POWER))
@@ -3684,22 +3439,6 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
3684EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all); 3439EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all);
3685 3440
3686/* 3441/*
3687 * supported power states check
3688 */
3689static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, hda_nid_t fg,
3690 unsigned int power_state)
3691{
3692 int sup = snd_hda_param_read(codec, fg, AC_PAR_POWER_STATE);
3693
3694 if (sup == -1)
3695 return false;
3696 if (sup & power_state)
3697 return true;
3698 else
3699 return false;
3700}
3701
3702/*
3703 * wait until the state is reached, returns the current state 3442 * wait until the state is reached, returns the current state
3704 */ 3443 */
3705static unsigned int hda_sync_power_state(struct hda_codec *codec, 3444static unsigned int hda_sync_power_state(struct hda_codec *codec,
@@ -3738,7 +3477,7 @@ unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
3738 hda_nid_t nid, 3477 hda_nid_t nid,
3739 unsigned int power_state) 3478 unsigned int power_state)
3740{ 3479{
3741 if (nid == codec->afg || nid == codec->mfg) 3480 if (nid == codec->core.afg || nid == codec->core.mfg)
3742 return power_state; 3481 return power_state;
3743 if (power_state == AC_PWRST_D3 && 3482 if (power_state == AC_PWRST_D3 &&
3744 get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN && 3483 get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN &&
@@ -3758,7 +3497,7 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_eapd_power_filter);
3758static unsigned int hda_set_power_state(struct hda_codec *codec, 3497static unsigned int hda_set_power_state(struct hda_codec *codec,
3759 unsigned int power_state) 3498 unsigned int power_state)
3760{ 3499{
3761 hda_nid_t fg = codec->afg ? codec->afg : codec->mfg; 3500 hda_nid_t fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
3762 int count; 3501 int count;
3763 unsigned int state; 3502 unsigned int state;
3764 int flags = 0; 3503 int flags = 0;
@@ -3766,7 +3505,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
3766 /* this delay seems necessary to avoid click noise at power-down */ 3505 /* this delay seems necessary to avoid click noise at power-down */
3767 if (power_state == AC_PWRST_D3) { 3506 if (power_state == AC_PWRST_D3) {
3768 if (codec->depop_delay < 0) 3507 if (codec->depop_delay < 0)
3769 msleep(codec->epss ? 10 : 100); 3508 msleep(codec_has_epss(codec) ? 10 : 100);
3770 else if (codec->depop_delay > 0) 3509 else if (codec->depop_delay > 0)
3771 msleep(codec->depop_delay); 3510 msleep(codec->depop_delay);
3772 flags = HDA_RW_NO_RESPONSE_FALLBACK; 3511 flags = HDA_RW_NO_RESPONSE_FALLBACK;
@@ -3800,14 +3539,13 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
3800 */ 3539 */
3801static void sync_power_up_states(struct hda_codec *codec) 3540static void sync_power_up_states(struct hda_codec *codec)
3802{ 3541{
3803 hda_nid_t nid = codec->start_nid; 3542 hda_nid_t nid;
3804 int i;
3805 3543
3806 /* don't care if no filter is used */ 3544 /* don't care if no filter is used */
3807 if (!codec->power_filter) 3545 if (!codec->power_filter)
3808 return; 3546 return;
3809 3547
3810 for (i = 0; i < codec->num_nodes; i++, nid++) { 3548 for_each_hda_codec_node(nid, codec) {
3811 unsigned int wcaps = get_wcaps(codec, nid); 3549 unsigned int wcaps = get_wcaps(codec, nid);
3812 unsigned int target; 3550 unsigned int target;
3813 if (!(wcaps & AC_WCAP_POWER)) 3551 if (!(wcaps & AC_WCAP_POWER))
@@ -3858,14 +3596,14 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
3858{ 3596{
3859 unsigned int state; 3597 unsigned int state;
3860 3598
3861 atomic_inc(&codec->in_pm); 3599 atomic_inc(&codec->core.in_pm);
3862 3600
3863 if (codec->patch_ops.suspend) 3601 if (codec->patch_ops.suspend)
3864 codec->patch_ops.suspend(codec); 3602 codec->patch_ops.suspend(codec);
3865 hda_cleanup_all_streams(codec); 3603 hda_cleanup_all_streams(codec);
3866 state = hda_set_power_state(codec, AC_PWRST_D3); 3604 state = hda_set_power_state(codec, AC_PWRST_D3);
3867 update_power_acct(codec, true); 3605 update_power_acct(codec, true);
3868 atomic_dec(&codec->in_pm); 3606 atomic_dec(&codec->core.in_pm);
3869 return state; 3607 return state;
3870} 3608}
3871 3609
@@ -3890,7 +3628,7 @@ static void hda_mark_cmd_cache_dirty(struct hda_codec *codec)
3890 */ 3628 */
3891static void hda_call_codec_resume(struct hda_codec *codec) 3629static void hda_call_codec_resume(struct hda_codec *codec)
3892{ 3630{
3893 atomic_inc(&codec->in_pm); 3631 atomic_inc(&codec->core.in_pm);
3894 3632
3895 hda_mark_cmd_cache_dirty(codec); 3633 hda_mark_cmd_cache_dirty(codec);
3896 3634
@@ -3913,7 +3651,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3913 hda_jackpoll_work(&codec->jackpoll_work.work); 3651 hda_jackpoll_work(&codec->jackpoll_work.work);
3914 else 3652 else
3915 snd_hda_jack_report_sync(codec); 3653 snd_hda_jack_report_sync(codec);
3916 atomic_dec(&codec->in_pm); 3654 atomic_dec(&codec->core.in_pm);
3917} 3655}
3918 3656
3919static int hda_codec_runtime_suspend(struct device *dev) 3657static int hda_codec_runtime_suspend(struct device *dev)
@@ -3926,8 +3664,9 @@ static int hda_codec_runtime_suspend(struct device *dev)
3926 list_for_each_entry(pcm, &codec->pcm_list_head, list) 3664 list_for_each_entry(pcm, &codec->pcm_list_head, list)
3927 snd_pcm_suspend_all(pcm->pcm); 3665 snd_pcm_suspend_all(pcm->pcm);
3928 state = hda_call_codec_suspend(codec); 3666 state = hda_call_codec_suspend(codec);
3929 if (codec->d3_stop_clk && codec->epss && (state & AC_PWRST_CLK_STOP_OK)) 3667 if (codec_has_clkstop(codec) && codec_has_epss(codec) &&
3930 clear_bit(codec->core.addr, &codec->bus->core.codec_powered); 3668 (state & AC_PWRST_CLK_STOP_OK))
3669 snd_hdac_codec_link_down(&codec->core);
3931 return 0; 3670 return 0;
3932} 3671}
3933 3672
@@ -3935,7 +3674,7 @@ static int hda_codec_runtime_resume(struct device *dev)
3935{ 3674{
3936 struct hda_codec *codec = dev_to_hda_codec(dev); 3675 struct hda_codec *codec = dev_to_hda_codec(dev);
3937 3676
3938 set_bit(codec->core.addr, &codec->bus->core.codec_powered); 3677 snd_hdac_codec_link_up(&codec->core);
3939 hda_call_codec_resume(codec); 3678 hda_call_codec_resume(codec);
3940 pm_runtime_mark_last_busy(dev); 3679 pm_runtime_mark_last_busy(dev);
3941 return 0; 3680 return 0;
@@ -4129,11 +3868,11 @@ static unsigned int get_pcm_param(struct hda_codec *codec, hda_nid_t nid,
4129 int dir) 3868 int dir)
4130{ 3869{
4131 unsigned int val = 0; 3870 unsigned int val = 0;
4132 if (nid != codec->afg && 3871 if (nid != codec->core.afg &&
4133 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) 3872 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD))
4134 val = snd_hda_param_read(codec, nid, AC_PAR_PCM); 3873 val = snd_hda_param_read(codec, nid, AC_PAR_PCM);
4135 if (!val || val == -1) 3874 if (!val || val == -1)
4136 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 3875 val = snd_hda_param_read(codec, codec->core.afg, AC_PAR_PCM);
4137 if (!val || val == -1) 3876 if (!val || val == -1)
4138 return 0; 3877 return 0;
4139 return val; 3878 return val;
@@ -4150,7 +3889,7 @@ static unsigned int get_stream_param(struct hda_codec *codec, hda_nid_t nid,
4150{ 3889{
4151 unsigned int streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 3890 unsigned int streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
4152 if (!streams || streams == -1) 3891 if (!streams || streams == -1)
4153 streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 3892 streams = snd_hda_param_read(codec, codec->core.afg, AC_PAR_STREAM);
4154 if (!streams || streams == -1) 3893 if (!streams || streams == -1)
4155 return 0; 3894 return 0;
4156 return streams; 3895 return streams;
@@ -4632,39 +4371,6 @@ int snd_hda_add_new_ctls(struct hda_codec *codec,
4632EXPORT_SYMBOL_GPL(snd_hda_add_new_ctls); 4371EXPORT_SYMBOL_GPL(snd_hda_add_new_ctls);
4633 4372
4634#ifdef CONFIG_PM 4373#ifdef CONFIG_PM
4635/**
4636 * snd_hda_power_up - Power-up the codec
4637 * @codec: HD-audio codec
4638 *
4639 * Increment the usage counter and resume the device if not done yet.
4640 */
4641void snd_hda_power_up(struct hda_codec *codec)
4642{
4643 struct device *dev = hda_codec_dev(codec);
4644
4645 if (codec_in_pm(codec))
4646 return;
4647 pm_runtime_get_sync(dev);
4648}
4649EXPORT_SYMBOL_GPL(snd_hda_power_up);
4650
4651/**
4652 * snd_hda_power_down - Power-down the codec
4653 * @codec: HD-audio codec
4654 *
4655 * Decrement the usage counter and schedules the autosuspend if none used.
4656 */
4657void snd_hda_power_down(struct hda_codec *codec)
4658{
4659 struct device *dev = hda_codec_dev(codec);
4660
4661 if (codec_in_pm(codec))
4662 return;
4663 pm_runtime_mark_last_busy(dev);
4664 pm_runtime_put_autosuspend(dev);
4665}
4666EXPORT_SYMBOL_GPL(snd_hda_power_down);
4667
4668static void codec_set_power_save(struct hda_codec *codec, int delay) 4374static void codec_set_power_save(struct hda_codec *codec, int delay)
4669{ 4375{
4670 struct device *dev = hda_codec_dev(codec); 4376 struct device *dev = hda_codec_dev(codec);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 6efcb4ad6935..e7c47a439762 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -261,24 +261,10 @@ struct hda_codec {
261 struct hda_bus *bus; 261 struct hda_bus *bus;
262 struct snd_card *card; 262 struct snd_card *card;
263 unsigned int addr; /* codec addr*/ 263 unsigned int addr; /* codec addr*/
264
265 hda_nid_t afg; /* AFG node id */
266 hda_nid_t mfg; /* MFG node id */
267
268 /* ids */
269 u8 afg_function_id;
270 u8 mfg_function_id;
271 u8 afg_unsol;
272 u8 mfg_unsol;
273 u32 vendor_id;
274 u32 subsystem_id;
275 u32 revision_id;
276 u32 probe_id; /* overridden id for probing */ 264 u32 probe_id; /* overridden id for probing */
277 265
278 /* detected preset */ 266 /* detected preset */
279 const struct hda_codec_preset *preset; 267 const struct hda_codec_preset *preset;
280 const char *vendor_name; /* codec vendor name */
281 const char *chip_name; /* codec chip name */
282 const char *modelname; /* model name for preset */ 268 const char *modelname; /* model name for preset */
283 269
284 /* set by patch */ 270 /* set by patch */
@@ -295,8 +281,6 @@ struct hda_codec {
295 unsigned int beep_mode; 281 unsigned int beep_mode;
296 282
297 /* widget capabilities cache */ 283 /* widget capabilities cache */
298 unsigned int num_nodes;
299 hda_nid_t start_nid;
300 u32 *wcaps; 284 u32 *wcaps;
301 285
302 struct snd_array mixers; /* list of assigned mixer elements */ 286 struct snd_array mixers; /* list of assigned mixer elements */
@@ -347,14 +331,11 @@ struct hda_codec {
347 unsigned int inv_eapd:1; /* broken h/w: inverted EAPD control */ 331 unsigned int inv_eapd:1; /* broken h/w: inverted EAPD control */
348 unsigned int inv_jack_detect:1; /* broken h/w: inverted detection bit */ 332 unsigned int inv_jack_detect:1; /* broken h/w: inverted detection bit */
349 unsigned int pcm_format_first:1; /* PCM format must be set first */ 333 unsigned int pcm_format_first:1; /* PCM format must be set first */
350 unsigned int epss:1; /* supporting EPSS? */
351 unsigned int cached_write:1; /* write only to caches */ 334 unsigned int cached_write:1; /* write only to caches */
352 unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */ 335 unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */
353 unsigned int dump_coef:1; /* dump processing coefs in codec proc file */ 336 unsigned int dump_coef:1; /* dump processing coefs in codec proc file */
354 unsigned int power_save_node:1; /* advanced PM for each widget */ 337 unsigned int power_save_node:1; /* advanced PM for each widget */
355#ifdef CONFIG_PM 338#ifdef CONFIG_PM
356 unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
357 atomic_t in_pm; /* suspend/resume being performed */
358 unsigned long power_on_acct; 339 unsigned long power_on_acct;
359 unsigned long power_off_acct; 340 unsigned long power_off_acct;
360 unsigned long power_jiffies; 341 unsigned long power_jiffies;
@@ -395,11 +376,6 @@ struct hda_codec {
395#define list_for_each_codec(c, bus) \ 376#define list_for_each_codec(c, bus) \
396 list_for_each_entry(c, &(bus)->core.codec_list, core.list) 377 list_for_each_entry(c, &(bus)->core.codec_list, core.list)
397 378
398/* direction */
399enum {
400 HDA_INPUT, HDA_OUTPUT
401};
402
403/* snd_hda_codec_read/write optional flags */ 379/* snd_hda_codec_read/write optional flags */
404#define HDA_RW_NO_RESPONSE_FALLBACK (1 << 0) 380#define HDA_RW_NO_RESPONSE_FALLBACK (1 << 0)
405 381
@@ -422,8 +398,8 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,
422 unsigned int verb, unsigned int parm); 398 unsigned int verb, unsigned int parm);
423#define snd_hda_param_read(codec, nid, param) \ 399#define snd_hda_param_read(codec, nid, param) \
424 snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param) 400 snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param)
425int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, 401#define snd_hda_get_sub_nodes(codec, nid, start_nid) \
426 hda_nid_t *start_id); 402 snd_hdac_get_sub_nodes(&(codec)->core, nid, start_nid)
427int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, 403int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
428 hda_nid_t *conn_list, int max_conns); 404 hda_nid_t *conn_list, int max_conns);
429static inline int 405static inline int
@@ -431,9 +407,12 @@ snd_hda_get_num_conns(struct hda_codec *codec, hda_nid_t nid)
431{ 407{
432 return snd_hda_get_connections(codec, nid, NULL, 0); 408 return snd_hda_get_connections(codec, nid, NULL, 0);
433} 409}
434int snd_hda_get_num_raw_conns(struct hda_codec *codec, hda_nid_t nid); 410
435int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid, 411#define snd_hda_get_raw_connections(codec, nid, list, max_conns) \
436 hda_nid_t *conn_list, int max_conns); 412 snd_hdac_get_connections(&(codec)->core, nid, list, max_conns)
413#define snd_hda_get_num_raw_conns(codec, nid) \
414 snd_hdac_get_connections(&(codec)->core, nid, NULL, 0);
415
437int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid, 416int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid,
438 const hda_nid_t **listp); 417 const hda_nid_t **listp);
439int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums, 418int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums,
@@ -582,14 +561,12 @@ const char *snd_hda_get_jack_location(u32 cfg);
582/* 561/*
583 * power saving 562 * power saving
584 */ 563 */
564#define snd_hda_power_up(codec) snd_hdac_power_up(&(codec)->core)
565#define snd_hda_power_down(codec) snd_hdac_power_down(&(codec)->core)
585#ifdef CONFIG_PM 566#ifdef CONFIG_PM
586void snd_hda_power_up(struct hda_codec *codec);
587void snd_hda_power_down(struct hda_codec *codec);
588void snd_hda_set_power_save(struct hda_bus *bus, int delay); 567void snd_hda_set_power_save(struct hda_bus *bus, int delay);
589void snd_hda_update_power_acct(struct hda_codec *codec); 568void snd_hda_update_power_acct(struct hda_codec *codec);
590#else 569#else
591static inline void snd_hda_power_up(struct hda_codec *codec) {}
592static inline void snd_hda_power_down(struct hda_codec *codec) {}
593static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {} 570static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
594#endif 571#endif
595 572
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 0ef2459cd05f..4850f92c89c4 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -654,7 +654,7 @@ static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid,
654 int type = get_wcaps_type(get_wcaps(codec, nid)); 654 int type = get_wcaps_type(get_wcaps(codec, nid));
655 int i, n; 655 int i, n;
656 656
657 if (nid == codec->afg) 657 if (nid == codec->core.afg)
658 return true; 658 return true;
659 659
660 for (n = 0; n < spec->paths.used; n++) { 660 for (n = 0; n < spec->paths.used; n++) {
@@ -832,7 +832,7 @@ static hda_nid_t path_power_update(struct hda_codec *codec,
832 832
833 for (i = 0; i < path->depth; i++) { 833 for (i = 0; i < path->depth; i++) {
834 nid = path->path[i]; 834 nid = path->path[i];
835 if (nid == codec->afg) 835 if (nid == codec->core.afg)
836 continue; 836 continue;
837 if (!allow_powerdown || is_active_nid_for_any(codec, nid)) 837 if (!allow_powerdown || is_active_nid_for_any(codec, nid))
838 state = AC_PWRST_D0; 838 state = AC_PWRST_D0;
@@ -1897,12 +1897,11 @@ static void debug_show_configs(struct hda_codec *codec,
1897static void fill_all_dac_nids(struct hda_codec *codec) 1897static void fill_all_dac_nids(struct hda_codec *codec)
1898{ 1898{
1899 struct hda_gen_spec *spec = codec->spec; 1899 struct hda_gen_spec *spec = codec->spec;
1900 int i; 1900 hda_nid_t nid;
1901 hda_nid_t nid = codec->start_nid;
1902 1901
1903 spec->num_all_dacs = 0; 1902 spec->num_all_dacs = 0;
1904 memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); 1903 memset(spec->all_dacs, 0, sizeof(spec->all_dacs));
1905 for (i = 0; i < codec->num_nodes; i++, nid++) { 1904 for_each_hda_codec_node(nid, codec) {
1906 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) 1905 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT)
1907 continue; 1906 continue;
1908 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { 1907 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) {
@@ -3067,10 +3066,9 @@ static int fill_adc_nids(struct hda_codec *codec)
3067 hda_nid_t nid; 3066 hda_nid_t nid;
3068 hda_nid_t *adc_nids = spec->adc_nids; 3067 hda_nid_t *adc_nids = spec->adc_nids;
3069 int max_nums = ARRAY_SIZE(spec->adc_nids); 3068 int max_nums = ARRAY_SIZE(spec->adc_nids);
3070 int i, nums = 0; 3069 int nums = 0;
3071 3070
3072 nid = codec->start_nid; 3071 for_each_hda_codec_node(nid, codec) {
3073 for (i = 0; i < codec->num_nodes; i++, nid++) {
3074 unsigned int caps = get_wcaps(codec, nid); 3072 unsigned int caps = get_wcaps(codec, nid);
3075 int type = get_wcaps_type(caps); 3073 int type = get_wcaps_type(caps);
3076 3074
@@ -3864,8 +3862,7 @@ static void parse_digital(struct hda_codec *codec)
3864 3862
3865 if (spec->autocfg.dig_in_pin) { 3863 if (spec->autocfg.dig_in_pin) {
3866 pin = spec->autocfg.dig_in_pin; 3864 pin = spec->autocfg.dig_in_pin;
3867 dig_nid = codec->start_nid; 3865 for_each_hda_codec_node(dig_nid, codec) {
3868 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
3869 unsigned int wcaps = get_wcaps(codec, dig_nid); 3866 unsigned int wcaps = get_wcaps(codec, dig_nid);
3870 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) 3867 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
3871 continue; 3868 continue;
@@ -4706,7 +4703,7 @@ unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
4706 hda_nid_t nid, 4703 hda_nid_t nid,
4707 unsigned int power_state) 4704 unsigned int power_state)
4708{ 4705{
4709 if (power_state != AC_PWRST_D0 || nid == codec->afg) 4706 if (power_state != AC_PWRST_D0 || nid == codec->core.afg)
4710 return power_state; 4707 return power_state;
4711 if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER) 4708 if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER)
4712 return power_state; 4709 return power_state;
@@ -5478,7 +5475,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec)
5478 5475
5479 fill_pcm_stream_name(spec->stream_name_analog, 5476 fill_pcm_stream_name(spec->stream_name_analog,
5480 sizeof(spec->stream_name_analog), 5477 sizeof(spec->stream_name_analog),
5481 " Analog", codec->chip_name); 5478 " Analog", codec->core.chip_name);
5482 info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog); 5479 info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog);
5483 if (!info) 5480 if (!info)
5484 return -ENOMEM; 5481 return -ENOMEM;
@@ -5509,7 +5506,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec)
5509 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 5506 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
5510 fill_pcm_stream_name(spec->stream_name_digital, 5507 fill_pcm_stream_name(spec->stream_name_digital,
5511 sizeof(spec->stream_name_digital), 5508 sizeof(spec->stream_name_digital),
5512 " Digital", codec->chip_name); 5509 " Digital", codec->core.chip_name);
5513 info = snd_hda_codec_pcm_new(codec, "%s", 5510 info = snd_hda_codec_pcm_new(codec, "%s",
5514 spec->stream_name_digital); 5511 spec->stream_name_digital);
5515 if (!info) 5512 if (!info)
@@ -5544,7 +5541,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec)
5544 if (spec->alt_dac_nid || have_multi_adcs) { 5541 if (spec->alt_dac_nid || have_multi_adcs) {
5545 fill_pcm_stream_name(spec->stream_name_alt_analog, 5542 fill_pcm_stream_name(spec->stream_name_alt_analog,
5546 sizeof(spec->stream_name_alt_analog), 5543 sizeof(spec->stream_name_alt_analog),
5547 " Alt Analog", codec->chip_name); 5544 " Alt Analog", codec->core.chip_name);
5548 info = snd_hda_codec_pcm_new(codec, "%s", 5545 info = snd_hda_codec_pcm_new(codec, "%s",
5549 spec->stream_name_alt_analog); 5546 spec->stream_name_alt_analog);
5550 if (!info) 5547 if (!info)
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 1d001647fc47..e0db30c66e5f 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -515,15 +515,18 @@ int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid);
515int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid, 515int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
516 unsigned int val); 516 unsigned int val);
517 517
518#define for_each_hda_codec_node(nid, codec) \
519 for ((nid) = (codec)->core.start_nid; (nid) < (codec)->core.end_nid; (nid)++)
520
518/* 521/*
519 * get widget capabilities 522 * get widget capabilities
520 */ 523 */
521static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) 524static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
522{ 525{
523 if (nid < codec->start_nid || 526 if (nid < codec->core.start_nid ||
524 nid >= codec->start_nid + codec->num_nodes) 527 nid >= codec->core.start_nid + codec->core.num_nodes)
525 return 0; 528 return 0;
526 return codec->wcaps[nid - codec->start_nid]; 529 return codec->wcaps[nid - codec->core.start_nid];
527} 530}
528 531
529/* get the widget type from widget capability bits */ 532/* get the widget type from widget capability bits */
@@ -547,9 +550,9 @@ static inline unsigned int get_wcaps_channels(u32 wcaps)
547static inline void snd_hda_override_wcaps(struct hda_codec *codec, 550static inline void snd_hda_override_wcaps(struct hda_codec *codec,
548 hda_nid_t nid, u32 val) 551 hda_nid_t nid, u32 val)
549{ 552{
550 if (nid >= codec->start_nid && 553 if (nid >= codec->core.start_nid &&
551 nid < codec->start_nid + codec->num_nodes) 554 nid < codec->core.start_nid + codec->core.num_nodes)
552 codec->wcaps[nid - codec->start_nid] = val; 555 codec->wcaps[nid - codec->core.start_nid] = val;
553} 556}
554 557
555u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); 558u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index dacfe74a2a1f..a4f5a30f1d41 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -289,7 +289,7 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
289 snd_iprintf(buffer, " Balanced"); 289 snd_iprintf(buffer, " Balanced");
290 if (caps & AC_PINCAP_HDMI) { 290 if (caps & AC_PINCAP_HDMI) {
291 /* Realtek uses this bit as a different meaning */ 291 /* Realtek uses this bit as a different meaning */
292 if ((codec->vendor_id >> 16) == 0x10ec) 292 if ((codec->core.vendor_id >> 16) == 0x10ec)
293 snd_iprintf(buffer, " R/L"); 293 snd_iprintf(buffer, " R/L");
294 else { 294 else {
295 if (caps & AC_PINCAP_HBR) 295 if (caps & AC_PINCAP_HBR)
@@ -597,7 +597,7 @@ static void print_gpio(struct snd_info_buffer *buffer,
597 struct hda_codec *codec, hda_nid_t nid) 597 struct hda_codec *codec, hda_nid_t nid)
598{ 598{
599 unsigned int gpio = 599 unsigned int gpio =
600 snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); 600 snd_hda_param_read(codec, codec->core.afg, AC_PAR_GPIO_CAP);
601 unsigned int enable, direction, wake, unsol, sticky, data; 601 unsigned int enable, direction, wake, unsol, sticky, data;
602 int i, max; 602 int i, max;
603 snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, " 603 snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
@@ -667,13 +667,9 @@ static void print_device_list(struct snd_info_buffer *buffer,
667 } 667 }
668} 668}
669 669
670static void print_codec_info(struct snd_info_entry *entry, 670static void print_codec_core_info(struct hdac_device *codec,
671 struct snd_info_buffer *buffer) 671 struct snd_info_buffer *buffer)
672{ 672{
673 struct hda_codec *codec = entry->private_data;
674 hda_nid_t nid;
675 int i, nodes;
676
677 snd_iprintf(buffer, "Codec: "); 673 snd_iprintf(buffer, "Codec: ");
678 if (codec->vendor_name && codec->chip_name) 674 if (codec->vendor_name && codec->chip_name)
679 snd_iprintf(buffer, "%s %s\n", 675 snd_iprintf(buffer, "%s %s\n",
@@ -695,29 +691,39 @@ static void print_codec_info(struct snd_info_entry *entry,
695 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg); 691 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
696 else 692 else
697 snd_iprintf(buffer, "No Modem Function Group found\n"); 693 snd_iprintf(buffer, "No Modem Function Group found\n");
694}
695
696static void print_codec_info(struct snd_info_entry *entry,
697 struct snd_info_buffer *buffer)
698{
699 struct hda_codec *codec = entry->private_data;
700 hda_nid_t nid, fg;
701 int i, nodes;
698 702
699 if (! codec->afg) 703 print_codec_core_info(&codec->core, buffer);
704 fg = codec->core.afg;
705 if (!fg)
700 return; 706 return;
701 snd_hda_power_up(codec); 707 snd_hda_power_up(codec);
702 snd_iprintf(buffer, "Default PCM:\n"); 708 snd_iprintf(buffer, "Default PCM:\n");
703 print_pcm_caps(buffer, codec, codec->afg); 709 print_pcm_caps(buffer, codec, fg);
704 snd_iprintf(buffer, "Default Amp-In caps: "); 710 snd_iprintf(buffer, "Default Amp-In caps: ");
705 print_amp_caps(buffer, codec, codec->afg, HDA_INPUT); 711 print_amp_caps(buffer, codec, fg, HDA_INPUT);
706 snd_iprintf(buffer, "Default Amp-Out caps: "); 712 snd_iprintf(buffer, "Default Amp-Out caps: ");
707 print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT); 713 print_amp_caps(buffer, codec, fg, HDA_OUTPUT);
708 snd_iprintf(buffer, "State of AFG node 0x%02x:\n", codec->afg); 714 snd_iprintf(buffer, "State of AFG node 0x%02x:\n", fg);
709 print_power_state(buffer, codec, codec->afg); 715 print_power_state(buffer, codec, fg);
710 716
711 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); 717 nodes = snd_hda_get_sub_nodes(codec, fg, &nid);
712 if (! nid || nodes < 0) { 718 if (! nid || nodes < 0) {
713 snd_iprintf(buffer, "Invalid AFG subtree\n"); 719 snd_iprintf(buffer, "Invalid AFG subtree\n");
714 snd_hda_power_down(codec); 720 snd_hda_power_down(codec);
715 return; 721 return;
716 } 722 }
717 723
718 print_gpio(buffer, codec, codec->afg); 724 print_gpio(buffer, codec, fg);
719 if (codec->proc_widget_hook) 725 if (codec->proc_widget_hook)
720 codec->proc_widget_hook(buffer, codec, codec->afg); 726 codec->proc_widget_hook(buffer, codec, fg);
721 727
722 for (i = 0; i < nodes; i++, nid++) { 728 for (i = 0; i < nodes; i++, nid++) {
723 unsigned int wid_caps = 729 unsigned int wid_caps =
@@ -860,7 +866,7 @@ int snd_hda_codec_proc_new(struct hda_codec *codec)
860 struct snd_info_entry *entry; 866 struct snd_info_entry *entry;
861 int err; 867 int err;
862 868
863 snprintf(name, sizeof(name), "codec#%d", codec->addr); 869 snprintf(name, sizeof(name), "codec#%d", codec->core.addr);
864 err = snd_card_proc_new(codec->card, name, &entry); 870 err = snd_card_proc_new(codec->card, name, &entry);
865 if (err < 0) 871 if (err < 0)
866 return err; 872 return err;
diff --git a/sound/pci/hda/hda_sysfs.c b/sound/pci/hda/hda_sysfs.c
index 3b5ed1108f9f..a6e3d9b511ab 100644
--- a/sound/pci/hda/hda_sysfs.c
+++ b/sound/pci/hda/hda_sysfs.c
@@ -48,33 +48,33 @@ static DEVICE_ATTR_RO(power_on_acct);
48static DEVICE_ATTR_RO(power_off_acct); 48static DEVICE_ATTR_RO(power_off_acct);
49#endif /* CONFIG_PM */ 49#endif /* CONFIG_PM */
50 50
51#define CODEC_INFO_SHOW(type) \ 51#define CODEC_INFO_SHOW(type, field) \
52static ssize_t type##_show(struct device *dev, \ 52static ssize_t type##_show(struct device *dev, \
53 struct device_attribute *attr, \ 53 struct device_attribute *attr, \
54 char *buf) \ 54 char *buf) \
55{ \ 55{ \
56 struct hda_codec *codec = dev_get_drvdata(dev); \ 56 struct hda_codec *codec = dev_get_drvdata(dev); \
57 return sprintf(buf, "0x%x\n", codec->type); \ 57 return sprintf(buf, "0x%x\n", codec->field); \
58} 58}
59 59
60#define CODEC_INFO_STR_SHOW(type) \ 60#define CODEC_INFO_STR_SHOW(type, field) \
61static ssize_t type##_show(struct device *dev, \ 61static ssize_t type##_show(struct device *dev, \
62 struct device_attribute *attr, \ 62 struct device_attribute *attr, \
63 char *buf) \ 63 char *buf) \
64{ \ 64{ \
65 struct hda_codec *codec = dev_get_drvdata(dev); \ 65 struct hda_codec *codec = dev_get_drvdata(dev); \
66 return sprintf(buf, "%s\n", \ 66 return sprintf(buf, "%s\n", \
67 codec->type ? codec->type : ""); \ 67 codec->field ? codec->field : ""); \
68} 68}
69 69
70CODEC_INFO_SHOW(vendor_id); 70CODEC_INFO_SHOW(vendor_id, core.vendor_id);
71CODEC_INFO_SHOW(subsystem_id); 71CODEC_INFO_SHOW(subsystem_id, core.subsystem_id);
72CODEC_INFO_SHOW(revision_id); 72CODEC_INFO_SHOW(revision_id, core.revision_id);
73CODEC_INFO_SHOW(afg); 73CODEC_INFO_SHOW(afg, core.afg);
74CODEC_INFO_SHOW(mfg); 74CODEC_INFO_SHOW(mfg, core.mfg);
75CODEC_INFO_STR_SHOW(vendor_name); 75CODEC_INFO_STR_SHOW(vendor_name, core.vendor_name);
76CODEC_INFO_STR_SHOW(chip_name); 76CODEC_INFO_STR_SHOW(chip_name, core.chip_name);
77CODEC_INFO_STR_SHOW(modelname); 77CODEC_INFO_STR_SHOW(modelname, modelname);
78 78
79static ssize_t pin_configs_show(struct hda_codec *codec, 79static ssize_t pin_configs_show(struct hda_codec *codec,
80 struct snd_array *list, 80 struct snd_array *list,
@@ -170,7 +170,7 @@ static char *kstrndup_noeol(const char *src, size_t len)
170 return s; 170 return s;
171} 171}
172 172
173#define CODEC_INFO_STORE(type) \ 173#define CODEC_INFO_STORE(type, field) \
174static ssize_t type##_store(struct device *dev, \ 174static ssize_t type##_store(struct device *dev, \
175 struct device_attribute *attr, \ 175 struct device_attribute *attr, \
176 const char *buf, size_t count) \ 176 const char *buf, size_t count) \
@@ -180,11 +180,11 @@ static ssize_t type##_store(struct device *dev, \
180 int err = kstrtoul(buf, 0, &val); \ 180 int err = kstrtoul(buf, 0, &val); \
181 if (err < 0) \ 181 if (err < 0) \
182 return err; \ 182 return err; \
183 codec->type = val; \ 183 codec->field = val; \
184 return count; \ 184 return count; \
185} 185}
186 186
187#define CODEC_INFO_STR_STORE(type) \ 187#define CODEC_INFO_STR_STORE(type, field) \
188static ssize_t type##_store(struct device *dev, \ 188static ssize_t type##_store(struct device *dev, \
189 struct device_attribute *attr, \ 189 struct device_attribute *attr, \
190 const char *buf, size_t count) \ 190 const char *buf, size_t count) \
@@ -193,17 +193,17 @@ static ssize_t type##_store(struct device *dev, \
193 char *s = kstrndup_noeol(buf, 64); \ 193 char *s = kstrndup_noeol(buf, 64); \
194 if (!s) \ 194 if (!s) \
195 return -ENOMEM; \ 195 return -ENOMEM; \
196 kfree(codec->type); \ 196 kfree(codec->field); \
197 codec->type = s; \ 197 codec->field = s; \
198 return count; \ 198 return count; \
199} 199}
200 200
201CODEC_INFO_STORE(vendor_id); 201CODEC_INFO_STORE(vendor_id, core.vendor_id);
202CODEC_INFO_STORE(subsystem_id); 202CODEC_INFO_STORE(subsystem_id, core.subsystem_id);
203CODEC_INFO_STORE(revision_id); 203CODEC_INFO_STORE(revision_id, core.revision_id);
204CODEC_INFO_STR_STORE(vendor_name); 204CODEC_INFO_STR_STORE(vendor_name, core.vendor_name);
205CODEC_INFO_STR_STORE(chip_name); 205CODEC_INFO_STR_STORE(chip_name, core.chip_name);
206CODEC_INFO_STR_STORE(modelname); 206CODEC_INFO_STR_STORE(modelname, modelname);
207 207
208#define CODEC_ACTION_STORE(type) \ 208#define CODEC_ACTION_STORE(type) \
209static ssize_t type##_store(struct device *dev, \ 209static ssize_t type##_store(struct device *dev, \
@@ -553,9 +553,9 @@ static void parse_codec_mode(char *buf, struct hda_bus *bus,
553 *codecp = NULL; 553 *codecp = NULL;
554 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) { 554 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
555 list_for_each_codec(codec, bus) { 555 list_for_each_codec(codec, bus) {
556 if ((vendorid <= 0 || codec->vendor_id == vendorid) && 556 if ((vendorid <= 0 || codec->core.vendor_id == vendorid) &&
557 (subid <= 0 || codec->subsystem_id == subid) && 557 (subid <= 0 || codec->core.subsystem_id == subid) &&
558 codec->addr == caddr) { 558 codec->core.addr == caddr) {
559 *codecp = codec; 559 *codecp = codec;
560 break; 560 break;
561 } 561 }
@@ -595,8 +595,8 @@ static void parse_model_mode(char *buf, struct hda_bus *bus,
595static void parse_chip_name_mode(char *buf, struct hda_bus *bus, 595static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
596 struct hda_codec **codecp) 596 struct hda_codec **codecp)
597{ 597{
598 kfree((*codecp)->chip_name); 598 kfree((*codecp)->core.chip_name);
599 (*codecp)->chip_name = kstrdup(buf, GFP_KERNEL); 599 (*codecp)->core.chip_name = kstrdup(buf, GFP_KERNEL);
600} 600}
601 601
602#define DEFINE_PARSE_ID_MODE(name) \ 602#define DEFINE_PARSE_ID_MODE(name) \
@@ -605,7 +605,7 @@ static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
605{ \ 605{ \
606 unsigned long val; \ 606 unsigned long val; \
607 if (!kstrtoul(buf, 0, &val)) \ 607 if (!kstrtoul(buf, 0, &val)) \
608 (*codecp)->name = val; \ 608 (*codecp)->core.name = val; \
609} 609}
610 610
611DEFINE_PARSE_ID_MODE(vendor_id); 611DEFINE_PARSE_ID_MODE(vendor_id);
diff --git a/sound/pci/hda/local.h b/sound/pci/hda/local.h
new file mode 100644
index 000000000000..28cb7f98982e
--- /dev/null
+++ b/sound/pci/hda/local.h
@@ -0,0 +1,39 @@
1/*
2 */
3
4#ifndef __HDAC_LOCAL_H
5#define __HDAC_LOCAL_H
6
7int hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm);
8
9#define get_wcaps(codec, nid) \
10 hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP)
11/* get the widget type from widget capability bits */
12static inline int get_wcaps_type(unsigned int wcaps)
13{
14 if (!wcaps)
15 return -1; /* invalid type */
16 return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
17}
18
19#define get_pin_caps(codec, nid) \
20 hdac_read_parm(codec, nid, AC_PAR_PIN_CAP)
21
22static inline
23unsigned int get_pin_cfg(struct hdac_device *codec, hda_nid_t nid)
24{
25 unsigned int val;
26
27 if (snd_hdac_read(codec, nid, AC_VERB_GET_CONFIG_DEFAULT, 0, &val))
28 return -1;
29 return val;
30}
31
32#define get_amp_caps(codec, nid, dir) \
33 hdac_read_parm(codec, nid, (dir) == HDA_OUTPUT ? \
34 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP)
35
36#define get_power_caps(codec, nid) \
37 hdac_read_parm(codec, nid, AC_PAR_POWER_STATE)
38
39#endif /* __HDAC_LOCAL_H */
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index af4c7be86c27..2278e83234b5 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -99,7 +99,7 @@ static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
99static void ad198x_power_eapd(struct hda_codec *codec) 99static void ad198x_power_eapd(struct hda_codec *codec)
100{ 100{
101 /* We currently only handle front, HP */ 101 /* We currently only handle front, HP */
102 switch (codec->vendor_id) { 102 switch (codec->core.vendor_id) {
103 case 0x11d41882: 103 case 0x11d41882:
104 case 0x11d4882a: 104 case 0x11d4882a:
105 case 0x11d41884: 105 case 0x11d41884:
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 72d20652df50..5aff35a09fd4 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -4243,13 +4243,9 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec)
4243{ 4243{
4244 struct ca0132_spec *spec = codec->spec; 4244 struct ca0132_spec *spec = codec->spec;
4245 int i; 4245 int i;
4246 hda_nid_t nid;
4247 4246
4248 codec_dbg(codec, "ca0132_refresh_widget_caps.\n"); 4247 codec_dbg(codec, "ca0132_refresh_widget_caps.\n");
4249 nid = codec->start_nid; 4248 snd_hda_codec_update_widgets(codec);
4250 for (i = 0; i < codec->num_nodes; i++, nid++)
4251 codec->wcaps[i] = snd_hda_param_read(codec, nid,
4252 AC_PAR_AUDIO_WIDGET_CAP);
4253 4249
4254 for (i = 0; i < spec->multiout.num_dacs; i++) 4250 for (i = 0; i < spec->multiout.num_dacs; i++)
4255 refresh_amp_caps(codec, spec->dacs[i], HDA_OUTPUT); 4251 refresh_amp_caps(codec, spec->dacs[i], HDA_OUTPUT);
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 142a6cf786da..1e21f9fbd54b 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -103,10 +103,9 @@ static int add_beep_ctls(struct hda_codec *codec)
103static void cx_auto_parse_beep(struct hda_codec *codec) 103static void cx_auto_parse_beep(struct hda_codec *codec)
104{ 104{
105 struct conexant_spec *spec = codec->spec; 105 struct conexant_spec *spec = codec->spec;
106 hda_nid_t nid, end_nid; 106 hda_nid_t nid;
107 107
108 end_nid = codec->start_nid + codec->num_nodes; 108 for_each_hda_codec_node(nid, codec)
109 for (nid = codec->start_nid; nid < end_nid; nid++)
110 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 109 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) {
111 set_beep_amp(spec, nid, 0, HDA_OUTPUT); 110 set_beep_amp(spec, nid, 0, HDA_OUTPUT);
112 break; 111 break;
@@ -120,10 +119,9 @@ static void cx_auto_parse_beep(struct hda_codec *codec)
120static void cx_auto_parse_eapd(struct hda_codec *codec) 119static void cx_auto_parse_eapd(struct hda_codec *codec)
121{ 120{
122 struct conexant_spec *spec = codec->spec; 121 struct conexant_spec *spec = codec->spec;
123 hda_nid_t nid, end_nid; 122 hda_nid_t nid;
124 123
125 end_nid = codec->start_nid + codec->num_nodes; 124 for_each_hda_codec_node(nid, codec) {
126 for (nid = codec->start_nid; nid < end_nid; nid++) {
127 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 125 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
128 continue; 126 continue;
129 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 127 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
@@ -848,7 +846,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
848 struct conexant_spec *spec; 846 struct conexant_spec *spec;
849 int err; 847 int err;
850 848
851 codec_info(codec, "%s: BIOS auto-probing.\n", codec->chip_name); 849 codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
852 850
853 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 851 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
854 if (!spec) 852 if (!spec)
@@ -862,7 +860,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
862 if (spec->dynamic_eapd) 860 if (spec->dynamic_eapd)
863 spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 861 spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
864 862
865 switch (codec->vendor_id) { 863 switch (codec->core.vendor_id) {
866 case 0x14f15045: 864 case 0x14f15045:
867 codec->single_adc_amp = 1; 865 codec->single_adc_amp = 1;
868 spec->gen.mixer_nid = 0x17; 866 spec->gen.mixer_nid = 0x17;
@@ -896,7 +894,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
896 * others may use EAPD really as an amp switch, so it might be 894 * others may use EAPD really as an amp switch, so it might be
897 * not good to expose it blindly. 895 * not good to expose it blindly.
898 */ 896 */
899 switch (codec->subsystem_id >> 16) { 897 switch (codec->core.subsystem_id >> 16) {
900 case 0x103c: 898 case 0x103c:
901 spec->gen.vmaster_mute_enum = 1; 899 spec->gen.vmaster_mute_enum = 1;
902 break; 900 break;
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 7e9ff7b16e56..35d92a8a99ce 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -45,14 +45,14 @@ static bool static_hdmi_pcm;
45module_param(static_hdmi_pcm, bool, 0644); 45module_param(static_hdmi_pcm, bool, 0644);
46MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); 46MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
47 47
48#define is_haswell(codec) ((codec)->vendor_id == 0x80862807) 48#define is_haswell(codec) ((codec)->core.vendor_id == 0x80862807)
49#define is_broadwell(codec) ((codec)->vendor_id == 0x80862808) 49#define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808)
50#define is_skylake(codec) ((codec)->vendor_id == 0x80862809) 50#define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809)
51#define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \ 51#define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \
52 || is_skylake(codec)) 52 || is_skylake(codec))
53 53
54#define is_valleyview(codec) ((codec)->vendor_id == 0x80862882) 54#define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882)
55#define is_cherryview(codec) ((codec)->vendor_id == 0x80862883) 55#define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883)
56#define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec)) 56#define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec))
57 57
58struct hdmi_spec_per_cvt { 58struct hdmi_spec_per_cvt {
@@ -1391,13 +1391,12 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec,
1391 hda_nid_t pin_nid, int mux_idx) 1391 hda_nid_t pin_nid, int mux_idx)
1392{ 1392{
1393 struct hdmi_spec *spec = codec->spec; 1393 struct hdmi_spec *spec = codec->spec;
1394 hda_nid_t nid, end_nid; 1394 hda_nid_t nid;
1395 int cvt_idx, curr; 1395 int cvt_idx, curr;
1396 struct hdmi_spec_per_cvt *per_cvt; 1396 struct hdmi_spec_per_cvt *per_cvt;
1397 1397
1398 /* configure all pins, including "no physical connection" ones */ 1398 /* configure all pins, including "no physical connection" ones */
1399 end_nid = codec->start_nid + codec->num_nodes; 1399 for_each_hda_codec_node(nid, codec) {
1400 for (nid = codec->start_nid; nid < end_nid; nid++) {
1401 unsigned int wid_caps = get_wcaps(codec, nid); 1400 unsigned int wid_caps = get_wcaps(codec, nid);
1402 unsigned int wid_type = get_wcaps_type(wid_caps); 1401 unsigned int wid_type = get_wcaps_type(wid_caps);
1403 1402
@@ -1728,7 +1727,7 @@ static int hdmi_parse_codec(struct hda_codec *codec)
1728 hda_nid_t nid; 1727 hda_nid_t nid;
1729 int i, nodes; 1728 int i, nodes;
1730 1729
1731 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); 1730 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid);
1732 if (!nid || nodes < 0) { 1731 if (!nid || nodes < 0) {
1733 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); 1732 codec_warn(codec, "HDMI: failed to get afg sub nodes\n");
1734 return -EINVAL; 1733 return -EINVAL;
@@ -2928,7 +2927,8 @@ static int patch_nvhdmi(struct hda_codec *codec)
2928 */ 2927 */
2929 2928
2930#define is_amdhdmi_rev3_or_later(codec) \ 2929#define is_amdhdmi_rev3_or_later(codec) \
2931 ((codec)->vendor_id == 0x1002aa01 && ((codec)->revision_id & 0xff00) >= 0x0300) 2930 ((codec)->core.vendor_id == 0x1002aa01 && \
2931 ((codec)->core.revision_id & 0xff00) >= 0x0300)
2932#define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) 2932#define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec)
2933 2933
2934/* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */ 2934/* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 124eacf67fc4..eee4532ab5f6 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -299,7 +299,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
299 299
300 coef = alc_get_coef0(codec); 300 coef = alc_get_coef0(codec);
301 301
302 switch (codec->vendor_id) { 302 switch (codec->core.vendor_id) {
303 case 0x10ec0262: 303 case 0x10ec0262:
304 alc_update_coef_idx(codec, 0x7, 0, 1<<5); 304 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
305 break; 305 break;
@@ -432,7 +432,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
432 snd_hda_sequence_write(codec, alc_gpio3_init_verbs); 432 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
433 break; 433 break;
434 case ALC_INIT_DEFAULT: 434 case ALC_INIT_DEFAULT:
435 switch (codec->vendor_id) { 435 switch (codec->core.vendor_id) {
436 case 0x10ec0260: 436 case 0x10ec0260:
437 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010); 437 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
438 break; 438 break;
@@ -498,18 +498,18 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
498 498
499 if (!codec->bus->pci) 499 if (!codec->bus->pci)
500 return -1; 500 return -1;
501 ass = codec->subsystem_id & 0xffff; 501 ass = codec->core.subsystem_id & 0xffff;
502 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) 502 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
503 goto do_sku; 503 goto do_sku;
504 504
505 nid = 0x1d; 505 nid = 0x1d;
506 if (codec->vendor_id == 0x10ec0260) 506 if (codec->core.vendor_id == 0x10ec0260)
507 nid = 0x17; 507 nid = 0x17;
508 ass = snd_hda_codec_get_pincfg(codec, nid); 508 ass = snd_hda_codec_get_pincfg(codec, nid);
509 509
510 if (!(ass & 1)) { 510 if (!(ass & 1)) {
511 codec_info(codec, "%s: SKU not ready 0x%08x\n", 511 codec_info(codec, "%s: SKU not ready 0x%08x\n",
512 codec->chip_name, ass); 512 codec->core.chip_name, ass);
513 return -1; 513 return -1;
514 } 514 }
515 515
@@ -585,7 +585,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
585 goto do_sku; 585 goto do_sku;
586 } 586 }
587 587
588 ass = codec->subsystem_id & 0xffff; 588 ass = codec->core.subsystem_id & 0xffff;
589 if (codec->bus->pci && 589 if (codec->bus->pci &&
590 ass != codec->bus->pci->subsystem_device && (ass & 1)) 590 ass != codec->bus->pci->subsystem_device && (ass & 1))
591 goto do_sku; 591 goto do_sku;
@@ -600,7 +600,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
600 * 0 : override 600 * 0 : override
601 */ 601 */
602 nid = 0x1d; 602 nid = 0x1d;
603 if (codec->vendor_id == 0x10ec0260) 603 if (codec->core.vendor_id == 0x10ec0260)
604 nid = 0x17; 604 nid = 0x17;
605 ass = snd_hda_codec_get_pincfg(codec, nid); 605 ass = snd_hda_codec_get_pincfg(codec, nid);
606 codec_dbg(codec, 606 codec_dbg(codec,
@@ -621,7 +621,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
621 return 0; 621 return 0;
622do_sku: 622do_sku:
623 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", 623 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
624 ass & 0xffff, codec->vendor_id); 624 ass & 0xffff, codec->core.vendor_id);
625 /* 625 /*
626 * 0 : override 626 * 0 : override
627 * 1 : Swap Jack 627 * 1 : Swap Jack
@@ -826,9 +826,9 @@ static const struct hda_codec_ops alc_patch_ops = {
826/* replace the codec chip_name with the given string */ 826/* replace the codec chip_name with the given string */
827static int alc_codec_rename(struct hda_codec *codec, const char *name) 827static int alc_codec_rename(struct hda_codec *codec, const char *name)
828{ 828{
829 kfree(codec->chip_name); 829 kfree(codec->core.chip_name);
830 codec->chip_name = kstrdup(name, GFP_KERNEL); 830 codec->core.chip_name = kstrdup(name, GFP_KERNEL);
831 if (!codec->chip_name) { 831 if (!codec->core.chip_name) {
832 alc_free(codec); 832 alc_free(codec);
833 return -ENOMEM; 833 return -ENOMEM;
834 } 834 }
@@ -904,7 +904,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
904 const struct alc_codec_rename_pci_table *q; 904 const struct alc_codec_rename_pci_table *q;
905 905
906 for (p = rename_tbl; p->vendor_id; p++) { 906 for (p = rename_tbl; p->vendor_id; p++) {
907 if (p->vendor_id != codec->vendor_id) 907 if (p->vendor_id != codec->core.vendor_id)
908 continue; 908 continue;
909 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) 909 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
910 return alc_codec_rename(codec, p->name); 910 return alc_codec_rename(codec, p->name);
@@ -913,7 +913,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
913 if (!codec->bus->pci) 913 if (!codec->bus->pci)
914 return 0; 914 return 0;
915 for (q = rename_pci_tbl; q->codec_vendor_id; q++) { 915 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
916 if (q->codec_vendor_id != codec->vendor_id) 916 if (q->codec_vendor_id != codec->core.vendor_id)
917 continue; 917 continue;
918 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor) 918 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
919 continue; 919 continue;
@@ -1785,7 +1785,7 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1785{ 1785{
1786 unsigned int gpiostate, gpiomask, gpiodir; 1786 unsigned int gpiostate, gpiomask, gpiodir;
1787 1787
1788 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 1788 gpiostate = snd_hda_codec_read(codec, codec->core.afg, 0,
1789 AC_VERB_GET_GPIO_DATA, 0); 1789 AC_VERB_GET_GPIO_DATA, 0);
1790 1790
1791 if (!muted) 1791 if (!muted)
@@ -1793,23 +1793,23 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1793 else 1793 else
1794 gpiostate &= ~(1 << pin); 1794 gpiostate &= ~(1 << pin);
1795 1795
1796 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 1796 gpiomask = snd_hda_codec_read(codec, codec->core.afg, 0,
1797 AC_VERB_GET_GPIO_MASK, 0); 1797 AC_VERB_GET_GPIO_MASK, 0);
1798 gpiomask |= (1 << pin); 1798 gpiomask |= (1 << pin);
1799 1799
1800 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 1800 gpiodir = snd_hda_codec_read(codec, codec->core.afg, 0,
1801 AC_VERB_GET_GPIO_DIRECTION, 0); 1801 AC_VERB_GET_GPIO_DIRECTION, 0);
1802 gpiodir |= (1 << pin); 1802 gpiodir |= (1 << pin);
1803 1803
1804 1804
1805 snd_hda_codec_write(codec, codec->afg, 0, 1805 snd_hda_codec_write(codec, codec->core.afg, 0,
1806 AC_VERB_SET_GPIO_MASK, gpiomask); 1806 AC_VERB_SET_GPIO_MASK, gpiomask);
1807 snd_hda_codec_write(codec, codec->afg, 0, 1807 snd_hda_codec_write(codec, codec->core.afg, 0,
1808 AC_VERB_SET_GPIO_DIRECTION, gpiodir); 1808 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1809 1809
1810 msleep(1); 1810 msleep(1);
1811 1811
1812 snd_hda_codec_write(codec, codec->afg, 0, 1812 snd_hda_codec_write(codec, codec->core.afg, 0,
1813 AC_VERB_SET_GPIO_DATA, gpiostate); 1813 AC_VERB_SET_GPIO_DATA, gpiostate);
1814} 1814}
1815 1815
@@ -2269,7 +2269,7 @@ static int patch_alc882(struct hda_codec *codec)
2269 2269
2270 spec = codec->spec; 2270 spec = codec->spec;
2271 2271
2272 switch (codec->vendor_id) { 2272 switch (codec->core.vendor_id) {
2273 case 0x10ec0882: 2273 case 0x10ec0882:
2274 case 0x10ec0885: 2274 case 0x10ec0885:
2275 case 0x10ec0900: 2275 case 0x10ec0900:
@@ -3067,7 +3067,7 @@ static int alc269_resume(struct hda_codec *codec)
3067 * in the driver. 3067 * in the driver.
3068 */ 3068 */
3069 if (spec->gpio_led) 3069 if (spec->gpio_led)
3070 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA, 3070 snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DATA,
3071 spec->gpio_led); 3071 spec->gpio_led);
3072 3072
3073 if (spec->has_alc5505_dsp) 3073 if (spec->has_alc5505_dsp)
@@ -3112,8 +3112,8 @@ static void alc271_fixup_dmic(struct hda_codec *codec,
3112 }; 3112 };
3113 unsigned int cfg; 3113 unsigned int cfg;
3114 3114
3115 if (strcmp(codec->chip_name, "ALC271X") && 3115 if (strcmp(codec->core.chip_name, "ALC271X") &&
3116 strcmp(codec->chip_name, "ALC269VB")) 3116 strcmp(codec->core.chip_name, "ALC269VB"))
3117 return; 3117 return;
3118 cfg = snd_hda_codec_get_pincfg(codec, 0x12); 3118 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3119 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) 3119 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
@@ -3479,9 +3479,9 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
3479 } 3479 }
3480 3480
3481 snd_hda_add_verbs(codec, gpio_init); 3481 snd_hda_add_verbs(codec, gpio_init);
3482 snd_hda_codec_write_cache(codec, codec->afg, 0, 3482 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
3483 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04); 3483 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
3484 snd_hda_jack_detect_enable_callback(codec, codec->afg, 3484 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
3485 gpio2_mic_hotkey_event); 3485 gpio2_mic_hotkey_event);
3486 3486
3487 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook; 3487 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
@@ -3564,7 +3564,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
3564 {} 3564 {}
3565 }; 3565 };
3566 3566
3567 switch (codec->vendor_id) { 3567 switch (codec->core.vendor_id) {
3568 case 0x10ec0255: 3568 case 0x10ec0255:
3569 alc_process_coef_fw(codec, coef0255); 3569 alc_process_coef_fw(codec, coef0255);
3570 break; 3570 break;
@@ -3619,7 +3619,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3619 {} 3619 {}
3620 }; 3620 };
3621 3621
3622 switch (codec->vendor_id) { 3622 switch (codec->core.vendor_id) {
3623 case 0x10ec0255: 3623 case 0x10ec0255:
3624 alc_write_coef_idx(codec, 0x45, 0xc489); 3624 alc_write_coef_idx(codec, 0x45, 0xc489);
3625 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3625 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
@@ -3688,7 +3688,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
3688 {} 3688 {}
3689 }; 3689 };
3690 3690
3691 switch (codec->vendor_id) { 3691 switch (codec->core.vendor_id) {
3692 case 0x10ec0255: 3692 case 0x10ec0255:
3693 alc_process_coef_fw(codec, coef0255); 3693 alc_process_coef_fw(codec, coef0255);
3694 break; 3694 break;
@@ -3742,7 +3742,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
3742 {} 3742 {}
3743 }; 3743 };
3744 3744
3745 switch (codec->vendor_id) { 3745 switch (codec->core.vendor_id) {
3746 case 0x10ec0255: 3746 case 0x10ec0255:
3747 alc_process_coef_fw(codec, coef0255); 3747 alc_process_coef_fw(codec, coef0255);
3748 break; 3748 break;
@@ -3796,7 +3796,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
3796 {} 3796 {}
3797 }; 3797 };
3798 3798
3799 switch (codec->vendor_id) { 3799 switch (codec->core.vendor_id) {
3800 case 0x10ec0255: 3800 case 0x10ec0255:
3801 alc_process_coef_fw(codec, coef0255); 3801 alc_process_coef_fw(codec, coef0255);
3802 break; 3802 break;
@@ -3841,7 +3841,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
3841 {} 3841 {}
3842 }; 3842 };
3843 3843
3844 switch (codec->vendor_id) { 3844 switch (codec->core.vendor_id) {
3845 case 0x10ec0255: 3845 case 0x10ec0255:
3846 alc_process_coef_fw(codec, coef0255); 3846 alc_process_coef_fw(codec, coef0255);
3847 msleep(300); 3847 msleep(300);
@@ -4078,7 +4078,7 @@ static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
4078 4078
4079 /* Avoid pop noises when headphones are plugged in */ 4079 /* Avoid pop noises when headphones are plugged in */
4080 if (spec->gen.hp_jack_present) 4080 if (spec->gen.hp_jack_present)
4081 if (nid == codec->afg || nid == 0x02 || nid == 0x15) 4081 if (nid == codec->core.afg || nid == 0x02 || nid == 0x15)
4082 return AC_PWRST_D0; 4082 return AC_PWRST_D0;
4083 return power_state; 4083 return power_state;
4084} 4084}
@@ -5428,7 +5428,7 @@ static int patch_alc269(struct hda_codec *codec)
5428 if (has_cdefine_beep(codec)) 5428 if (has_cdefine_beep(codec))
5429 spec->gen.beep_nid = 0x01; 5429 spec->gen.beep_nid = 0x01;
5430 5430
5431 switch (codec->vendor_id) { 5431 switch (codec->core.vendor_id) {
5432 case 0x10ec0269: 5432 case 0x10ec0269:
5433 spec->codec_variant = ALC269_TYPE_ALC269VA; 5433 spec->codec_variant = ALC269_TYPE_ALC269VA;
5434 switch (alc_get_coef0(codec) & 0x00f0) { 5434 switch (alc_get_coef0(codec) & 0x00f0) {
@@ -5772,9 +5772,9 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
5772 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5772 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5773 const hda_nid_t *ssids; 5773 const hda_nid_t *ssids;
5774 5774
5775 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || 5775 if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
5776 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 || 5776 codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
5777 codec->vendor_id == 0x10ec0671) 5777 codec->core.vendor_id == 0x10ec0671)
5778 ssids = alc663_ssids; 5778 ssids = alc663_ssids;
5779 else 5779 else
5780 ssids = alc662_ssids; 5780 ssids = alc662_ssids;
@@ -5819,7 +5819,7 @@ static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5819 unsigned int power_state) 5819 unsigned int power_state)
5820{ 5820{
5821 struct alc_spec *spec = codec->spec; 5821 struct alc_spec *spec = codec->spec;
5822 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led) 5822 if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5823 return AC_PWRST_D0; 5823 return AC_PWRST_D0;
5824 return power_state; 5824 return power_state;
5825} 5825}
@@ -6317,7 +6317,7 @@ static int patch_alc662(struct hda_codec *codec)
6317 6317
6318 alc_fix_pll_init(codec, 0x20, 0x04, 15); 6318 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6319 6319
6320 switch (codec->vendor_id) { 6320 switch (codec->core.vendor_id) {
6321 case 0x10ec0668: 6321 case 0x10ec0668:
6322 spec->init_hook = alc668_restore_default_value; 6322 spec->init_hook = alc668_restore_default_value;
6323 break; 6323 break;
@@ -6347,7 +6347,7 @@ static int patch_alc662(struct hda_codec *codec)
6347 goto error; 6347 goto error;
6348 6348
6349 if (!spec->gen.no_analog && spec->gen.beep_nid) { 6349 if (!spec->gen.no_analog && spec->gen.beep_nid) {
6350 switch (codec->vendor_id) { 6350 switch (codec->core.vendor_id) {
6351 case 0x10ec0662: 6351 case 0x10ec0662:
6352 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 6352 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6353 break; 6353 break;
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index df243134baa8..49b4868797a5 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -205,8 +205,8 @@ static int si3054_build_pcms(struct hda_codec *codec)
205 return -ENOMEM; 205 return -ENOMEM;
206 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm; 206 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm;
207 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm; 207 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm;
208 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = codec->mfg; 208 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = codec->core.mfg;
209 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = codec->mfg; 209 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = codec->core.mfg;
210 info->pcm_type = HDA_PCM_TYPE_MODEM; 210 info->pcm_type = HDA_PCM_TYPE_MODEM;
211 return 0; 211 return 0;
212} 212}
@@ -223,7 +223,7 @@ static int si3054_init(struct hda_codec *codec)
223 u16 val; 223 u16 val;
224 224
225 snd_hda_codec_write(codec, AC_NODE_ROOT, 0, AC_VERB_SET_CODEC_RESET, 0); 225 snd_hda_codec_write(codec, AC_NODE_ROOT, 0, AC_VERB_SET_CODEC_RESET, 0);
226 snd_hda_codec_write(codec, codec->mfg, 0, AC_VERB_SET_STREAM_FORMAT, 0); 226 snd_hda_codec_write(codec, codec->core.mfg, 0, AC_VERB_SET_STREAM_FORMAT, 0);
227 SET_REG(codec, SI3054_LINE_RATE, 9600); 227 SET_REG(codec, SI3054_LINE_RATE, 9600);
228 SET_REG(codec, SI3054_LINE_LEVEL, SI3054_DTAG_MASK|SI3054_ATAG_MASK); 228 SET_REG(codec, SI3054_LINE_LEVEL, SI3054_DTAG_MASK|SI3054_ATAG_MASK);
229 SET_REG(codec, SI3054_EXTENDED_MID, 0); 229 SET_REG(codec, SI3054_EXTENDED_MID, 0);
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 5b7c173adcb8..b314551749f1 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -299,32 +299,33 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
299 unsigned int dir_mask, unsigned int data) 299 unsigned int dir_mask, unsigned int data)
300{ 300{
301 unsigned int gpiostate, gpiomask, gpiodir; 301 unsigned int gpiostate, gpiomask, gpiodir;
302 hda_nid_t fg = codec->core.afg;
302 303
303 codec_dbg(codec, "%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data); 304 codec_dbg(codec, "%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
304 305
305 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 306 gpiostate = snd_hda_codec_read(codec, fg, 0,
306 AC_VERB_GET_GPIO_DATA, 0); 307 AC_VERB_GET_GPIO_DATA, 0);
307 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); 308 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
308 309
309 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 310 gpiomask = snd_hda_codec_read(codec, fg, 0,
310 AC_VERB_GET_GPIO_MASK, 0); 311 AC_VERB_GET_GPIO_MASK, 0);
311 gpiomask |= mask; 312 gpiomask |= mask;
312 313
313 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 314 gpiodir = snd_hda_codec_read(codec, fg, 0,
314 AC_VERB_GET_GPIO_DIRECTION, 0); 315 AC_VERB_GET_GPIO_DIRECTION, 0);
315 gpiodir |= dir_mask; 316 gpiodir |= dir_mask;
316 317
317 /* Configure GPIOx as CMOS */ 318 /* Configure GPIOx as CMOS */
318 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); 319 snd_hda_codec_write(codec, fg, 0, 0x7e7, 0);
319 320
320 snd_hda_codec_write(codec, codec->afg, 0, 321 snd_hda_codec_write(codec, fg, 0,
321 AC_VERB_SET_GPIO_MASK, gpiomask); 322 AC_VERB_SET_GPIO_MASK, gpiomask);
322 snd_hda_codec_read(codec, codec->afg, 0, 323 snd_hda_codec_read(codec, fg, 0,
323 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ 324 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
324 325
325 msleep(1); 326 msleep(1);
326 327
327 snd_hda_codec_read(codec, codec->afg, 0, 328 snd_hda_codec_read(codec, fg, 0,
328 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ 329 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
329} 330}
330 331
@@ -387,7 +388,7 @@ static unsigned int stac_vref_led_power_filter(struct hda_codec *codec,
387 hda_nid_t nid, 388 hda_nid_t nid,
388 unsigned int power_state) 389 unsigned int power_state)
389{ 390{
390 if (nid == codec->afg && power_state == AC_PWRST_D3) 391 if (nid == codec->core.afg && power_state == AC_PWRST_D3)
391 return AC_PWRST_D1; 392 return AC_PWRST_D1;
392 return snd_hda_gen_path_power_filter(codec, nid, power_state); 393 return snd_hda_gen_path_power_filter(codec, nid, power_state);
393} 394}
@@ -432,7 +433,7 @@ static void stac_update_outputs(struct hda_codec *codec)
432 433
433 if (spec->gpio_mute) 434 if (spec->gpio_mute)
434 spec->gen.master_mute = 435 spec->gen.master_mute =
435 !(snd_hda_codec_read(codec, codec->afg, 0, 436 !(snd_hda_codec_read(codec, codec->core.afg, 0,
436 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); 437 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
437 438
438 snd_hda_gen_update_outputs(codec); 439 snd_hda_gen_update_outputs(codec);
@@ -476,7 +477,7 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
476 if (val != spec->power_map_bits) { 477 if (val != spec->power_map_bits) {
477 spec->power_map_bits = val; 478 spec->power_map_bits = val;
478 if (do_write) 479 if (do_write)
479 snd_hda_codec_write(codec, codec->afg, 0, 480 snd_hda_codec_write(codec, codec->core.afg, 0,
480 AC_VERB_IDT_SET_POWER_MAP, val); 481 AC_VERB_IDT_SET_POWER_MAP, val);
481 } 482 }
482} 483}
@@ -508,7 +509,8 @@ static void jack_update_power(struct hda_codec *codec,
508 false); 509 false);
509 } 510 }
510 511
511 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_IDT_SET_POWER_MAP, 512 snd_hda_codec_write(codec, codec->core.afg, 0,
513 AC_VERB_IDT_SET_POWER_MAP,
512 spec->power_map_bits); 514 spec->power_map_bits);
513} 515}
514 516
@@ -517,10 +519,10 @@ static void stac_vref_event(struct hda_codec *codec,
517{ 519{
518 unsigned int data; 520 unsigned int data;
519 521
520 data = snd_hda_codec_read(codec, codec->afg, 0, 522 data = snd_hda_codec_read(codec, codec->core.afg, 0,
521 AC_VERB_GET_GPIO_DATA, 0); 523 AC_VERB_GET_GPIO_DATA, 0);
522 /* toggle VREF state based on GPIOx status */ 524 /* toggle VREF state based on GPIOx status */
523 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, 525 snd_hda_codec_write(codec, codec->core.afg, 0, 0x7e0,
524 !!(data & (1 << event->private_data))); 526 !!(data & (1 << event->private_data)));
525} 527}
526 528
@@ -622,7 +624,7 @@ static int stac_aloopback_put(struct snd_kcontrol *kcontrol,
622 /* Only return the bits defined by the shift value of the 624 /* Only return the bits defined by the shift value of the
623 * first two bytes of the mask 625 * first two bytes of the mask
624 */ 626 */
625 dac_mode = snd_hda_codec_read(codec, codec->afg, 0, 627 dac_mode = snd_hda_codec_read(codec, codec->core.afg, 0,
626 kcontrol->private_value & 0xFFFF, 0x0); 628 kcontrol->private_value & 0xFFFF, 0x0);
627 dac_mode >>= spec->aloopback_shift; 629 dac_mode >>= spec->aloopback_shift;
628 630
@@ -634,7 +636,7 @@ static int stac_aloopback_put(struct snd_kcontrol *kcontrol,
634 dac_mode &= ~idx_val; 636 dac_mode &= ~idx_val;
635 } 637 }
636 638
637 snd_hda_codec_write_cache(codec, codec->afg, 0, 639 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
638 kcontrol->private_value >> 16, dac_mode); 640 kcontrol->private_value >> 16, dac_mode);
639 641
640 return 1; 642 return 1;
@@ -658,11 +660,11 @@ static int stac_aloopback_put(struct snd_kcontrol *kcontrol,
658/* check whether it's a HP laptop with a docking port */ 660/* check whether it's a HP laptop with a docking port */
659static bool hp_bnb2011_with_dock(struct hda_codec *codec) 661static bool hp_bnb2011_with_dock(struct hda_codec *codec)
660{ 662{
661 if (codec->vendor_id != 0x111d7605 && 663 if (codec->core.vendor_id != 0x111d7605 &&
662 codec->vendor_id != 0x111d76d1) 664 codec->core.vendor_id != 0x111d76d1)
663 return false; 665 return false;
664 666
665 switch (codec->subsystem_id) { 667 switch (codec->core.subsystem_id) {
666 case 0x103c1618: 668 case 0x103c1618:
667 case 0x103c1619: 669 case 0x103c1619:
668 case 0x103c161a: 670 case 0x103c161a:
@@ -733,7 +735,7 @@ static void set_hp_led_gpio(struct hda_codec *codec)
733 if (spec->gpio_led) 735 if (spec->gpio_led)
734 return; 736 return;
735 737
736 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); 738 gpio = snd_hda_param_read(codec, codec->core.afg, AC_PAR_GPIO_CAP);
737 gpio &= AC_GPIO_IO_COUNT; 739 gpio &= AC_GPIO_IO_COUNT;
738 if (gpio > 3) 740 if (gpio > 3)
739 spec->gpio_led = 0x08; /* GPIO 3 */ 741 spec->gpio_led = 0x08; /* GPIO 3 */
@@ -777,7 +779,7 @@ static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
777 &spec->gpio_led_polarity, 779 &spec->gpio_led_polarity,
778 &spec->gpio_led) == 2) { 780 &spec->gpio_led) == 2) {
779 unsigned int max_gpio; 781 unsigned int max_gpio;
780 max_gpio = snd_hda_param_read(codec, codec->afg, 782 max_gpio = snd_hda_param_read(codec, codec->core.afg,
781 AC_PAR_GPIO_CAP); 783 AC_PAR_GPIO_CAP);
782 max_gpio &= AC_GPIO_IO_COUNT; 784 max_gpio &= AC_GPIO_IO_COUNT;
783 if (spec->gpio_led < max_gpio) 785 if (spec->gpio_led < max_gpio)
@@ -807,7 +809,7 @@ static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
807 * we statically set the GPIO - if not a B-series system 809 * we statically set the GPIO - if not a B-series system
808 * and default polarity is provided 810 * and default polarity is provided
809 */ 811 */
810 if (!hp_blike_system(codec->subsystem_id) && 812 if (!hp_blike_system(codec->core.subsystem_id) &&
811 (default_polarity == 0 || default_polarity == 1)) { 813 (default_polarity == 0 || default_polarity == 1)) {
812 set_hp_led_gpio(codec); 814 set_hp_led_gpio(codec);
813 spec->gpio_led_polarity = default_polarity; 815 spec->gpio_led_polarity = default_polarity;
@@ -2134,7 +2136,7 @@ static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
2134 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ 2136 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
2135#ifdef CONFIG_PM 2137#ifdef CONFIG_PM
2136 /* resetting controller clears GPIO, so we need to keep on */ 2138 /* resetting controller clears GPIO, so we need to keep on */
2137 codec->d3_stop_clk = 0; 2139 codec->core.power_caps &= ~AC_PWRST_CLKSTOP;
2138#endif 2140#endif
2139 } 2141 }
2140} 2142}
@@ -3031,9 +3033,9 @@ static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
3031 return; 3033 return;
3032 3034
3033 /* Enable VREF power saving on GPIO1 detect */ 3035 /* Enable VREF power saving on GPIO1 detect */
3034 snd_hda_codec_write_cache(codec, codec->afg, 0, 3036 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
3035 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); 3037 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
3036 jack = snd_hda_jack_detect_enable_callback(codec, codec->afg, 3038 jack = snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
3037 stac_vref_event); 3039 stac_vref_event);
3038 if (!IS_ERR(jack)) 3040 if (!IS_ERR(jack))
3039 jack->private_data = 0x02; 3041 jack->private_data = 0x02;
@@ -3093,7 +3095,7 @@ static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
3093 if (action != HDA_FIXUP_ACT_PRE_PROBE) 3095 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3094 return; 3096 return;
3095 3097
3096 if (hp_blike_system(codec->subsystem_id)) { 3098 if (hp_blike_system(codec->core.subsystem_id)) {
3097 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f); 3099 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
3098 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT || 3100 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
3099 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER || 3101 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
@@ -3792,7 +3794,7 @@ static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3792 if (action != HDA_FIXUP_ACT_PRE_PROBE) 3794 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3793 return; 3795 return;
3794 3796
3795 if (codec->subsystem_id != 0x1028022f) { 3797 if (codec->core.subsystem_id != 0x1028022f) {
3796 /* GPIO2 High = Enable EAPD */ 3798 /* GPIO2 High = Enable EAPD */
3797 spec->eapd_mask = spec->gpio_mask = 0x04; 3799 spec->eapd_mask = spec->gpio_mask = 0x04;
3798 spec->gpio_dir = spec->gpio_data = 0x04; 3800 spec->gpio_dir = spec->gpio_data = 0x04;
@@ -4053,9 +4055,9 @@ static void stac9205_fixup_dell_m43(struct hda_codec *codec,
4053 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs); 4055 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
4054 4056
4055 /* Enable unsol response for GPIO4/Dock HP connection */ 4057 /* Enable unsol response for GPIO4/Dock HP connection */
4056 snd_hda_codec_write_cache(codec, codec->afg, 0, 4058 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4057 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); 4059 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4058 jack = snd_hda_jack_detect_enable_callback(codec, codec->afg, 4060 jack = snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4059 stac_vref_event); 4061 stac_vref_event);
4060 if (!IS_ERR(jack)) 4062 if (!IS_ERR(jack))
4061 jack->private_data = 0x01; 4063 jack->private_data = 0x01;
@@ -4302,7 +4304,7 @@ static int stac_init(struct hda_codec *codec)
4302 4304
4303 /* sync the power-map */ 4305 /* sync the power-map */
4304 if (spec->num_pwrs) 4306 if (spec->num_pwrs)
4305 snd_hda_codec_write(codec, codec->afg, 0, 4307 snd_hda_codec_write(codec, codec->core.afg, 0,
4306 AC_VERB_IDT_SET_POWER_MAP, 4308 AC_VERB_IDT_SET_POWER_MAP,
4307 spec->power_map_bits); 4309 spec->power_map_bits);
4308 4310
@@ -4338,7 +4340,7 @@ static void stac_shutup(struct hda_codec *codec)
4338static void stac92hd_proc_hook(struct snd_info_buffer *buffer, 4340static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4339 struct hda_codec *codec, hda_nid_t nid) 4341 struct hda_codec *codec, hda_nid_t nid)
4340{ 4342{
4341 if (nid == codec->afg) 4343 if (nid == codec->core.afg)
4342 snd_iprintf(buffer, "Power-Map: 0x%02x\n", 4344 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4343 snd_hda_codec_read(codec, nid, 0, 4345 snd_hda_codec_read(codec, nid, 0,
4344 AC_VERB_IDT_GET_POWER_MAP, 0)); 4346 AC_VERB_IDT_GET_POWER_MAP, 0));
@@ -4349,7 +4351,7 @@ static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4349 unsigned int verb) 4351 unsigned int verb)
4350{ 4352{
4351 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", 4353 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4352 snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); 4354 snd_hda_codec_read(codec, codec->core.afg, 0, verb, 0));
4353} 4355}
4354 4356
4355/* stac92hd71bxx, stac92hd73xx */ 4357/* stac92hd71bxx, stac92hd73xx */
@@ -4357,21 +4359,21 @@ static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4357 struct hda_codec *codec, hda_nid_t nid) 4359 struct hda_codec *codec, hda_nid_t nid)
4358{ 4360{
4359 stac92hd_proc_hook(buffer, codec, nid); 4361 stac92hd_proc_hook(buffer, codec, nid);
4360 if (nid == codec->afg) 4362 if (nid == codec->core.afg)
4361 analog_loop_proc_hook(buffer, codec, 0xfa0); 4363 analog_loop_proc_hook(buffer, codec, 0xfa0);
4362} 4364}
4363 4365
4364static void stac9205_proc_hook(struct snd_info_buffer *buffer, 4366static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4365 struct hda_codec *codec, hda_nid_t nid) 4367 struct hda_codec *codec, hda_nid_t nid)
4366{ 4368{
4367 if (nid == codec->afg) 4369 if (nid == codec->core.afg)
4368 analog_loop_proc_hook(buffer, codec, 0xfe0); 4370 analog_loop_proc_hook(buffer, codec, 0xfe0);
4369} 4371}
4370 4372
4371static void stac927x_proc_hook(struct snd_info_buffer *buffer, 4373static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4372 struct hda_codec *codec, hda_nid_t nid) 4374 struct hda_codec *codec, hda_nid_t nid)
4373{ 4375{
4374 if (nid == codec->afg) 4376 if (nid == codec->core.afg)
4375 analog_loop_proc_hook(buffer, codec, 0xfeb); 4377 analog_loop_proc_hook(buffer, codec, 0xfeb);
4376} 4378}
4377#else 4379#else
@@ -4597,7 +4599,8 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
4597 if (err < 0) 4599 if (err < 0)
4598 return err; 4600 return err;
4599 4601
4600 codec->epss = 0; /* longer delay needed for D3 */ 4602 /* longer delay needed for D3 */
4603 codec->core.power_caps &= ~AC_PWRST_EPSS;
4601 4604
4602 spec = codec->spec; 4605 spec = codec->spec;
4603 codec->power_save_node = 1; 4606 codec->power_save_node = 1;
@@ -4647,7 +4650,8 @@ static int patch_stac92hd95(struct hda_codec *codec)
4647 if (err < 0) 4650 if (err < 0)
4648 return err; 4651 return err;
4649 4652
4650 codec->epss = 0; /* longer delay needed for D3 */ 4653 /* longer delay needed for D3 */
4654 codec->core.power_caps &= ~AC_PWRST_EPSS;
4651 4655
4652 spec = codec->spec; 4656 spec = codec->spec;
4653 codec->power_save_node = 1; 4657 codec->power_save_node = 1;
@@ -4706,14 +4710,14 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
4706 spec->gpio_dir = 0x01; 4710 spec->gpio_dir = 0x01;
4707 spec->gpio_data = 0x01; 4711 spec->gpio_data = 0x01;
4708 4712
4709 switch (codec->vendor_id) { 4713 switch (codec->core.vendor_id) {
4710 case 0x111d76b6: /* 4 Port without Analog Mixer */ 4714 case 0x111d76b6: /* 4 Port without Analog Mixer */
4711 case 0x111d76b7: 4715 case 0x111d76b7:
4712 unmute_init++; 4716 unmute_init++;
4713 break; 4717 break;
4714 case 0x111d7608: /* 5 Port with Analog Mixer */ 4718 case 0x111d7608: /* 5 Port with Analog Mixer */
4715 if ((codec->revision_id & 0xf) == 0 || 4719 if ((codec->core.revision_id & 0xf) == 0 ||
4716 (codec->revision_id & 0xf) == 1) 4720 (codec->core.revision_id & 0xf) == 1)
4717 spec->stream_delay = 40; /* 40 milliseconds */ 4721 spec->stream_delay = 40; /* 40 milliseconds */
4718 4722
4719 /* disable VSW */ 4723 /* disable VSW */
@@ -4722,7 +4726,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
4722 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); 4726 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
4723 break; 4727 break;
4724 case 0x111d7603: /* 6 Port with Analog Mixer */ 4728 case 0x111d7603: /* 6 Port with Analog Mixer */
4725 if ((codec->revision_id & 0xf) == 1) 4729 if ((codec->core.revision_id & 0xf) == 1)
4726 spec->stream_delay = 40; /* 40 milliseconds */ 4730 spec->stream_delay = 40; /* 40 milliseconds */
4727 4731
4728 break; 4732 break;
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 485663bb9101..a34d7671937f 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -140,7 +140,7 @@ static struct via_spec *via_new_spec(struct hda_codec *codec)
140 140
141static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) 141static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
142{ 142{
143 u32 vendor_id = codec->vendor_id; 143 u32 vendor_id = codec->core.vendor_id;
144 u16 ven_id = vendor_id >> 16; 144 u16 ven_id = vendor_id >> 16;
145 u16 dev_id = vendor_id & 0xffff; 145 u16 dev_id = vendor_id & 0xffff;
146 enum VIA_HDA_CODEC codec_type; 146 enum VIA_HDA_CODEC codec_type;
@@ -335,7 +335,7 @@ static void __analog_low_current_mode(struct hda_codec *codec, bool force)
335 return; /* other codecs are not supported */ 335 return; /* other codecs are not supported */
336 } 336 }
337 /* send verb */ 337 /* send verb */
338 snd_hda_codec_write(codec, codec->afg, 0, verb, parm); 338 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm);
339} 339}
340 340
341static void analog_low_current_mode(struct hda_codec *codec) 341static void analog_low_current_mode(struct hda_codec *codec)
@@ -558,7 +558,7 @@ static int vt1708_build_pcms(struct hda_codec *codec)
558 int i, err; 558 int i, err;
559 559
560 err = snd_hda_gen_build_pcms(codec); 560 err = snd_hda_gen_build_pcms(codec);
561 if (err < 0 || codec->vendor_id != 0x11061708) 561 if (err < 0 || codec->core.vendor_id != 0x11061708)
562 return err; 562 return err;
563 563
564 /* We got noisy outputs on the right channel on VT1708 when 564 /* We got noisy outputs on the right channel on VT1708 when
@@ -714,19 +714,19 @@ static int patch_vt1708S(struct hda_codec *codec)
714 714
715 /* correct names for VT1708BCE */ 715 /* correct names for VT1708BCE */
716 if (get_codec_type(codec) == VT1708BCE) { 716 if (get_codec_type(codec) == VT1708BCE) {
717 kfree(codec->chip_name); 717 kfree(codec->core.chip_name);
718 codec->chip_name = kstrdup("VT1708BCE", GFP_KERNEL); 718 codec->core.chip_name = kstrdup("VT1708BCE", GFP_KERNEL);
719 snprintf(codec->card->mixername, 719 snprintf(codec->card->mixername,
720 sizeof(codec->card->mixername), 720 sizeof(codec->card->mixername),
721 "%s %s", codec->vendor_name, codec->chip_name); 721 "%s %s", codec->core.vendor_name, codec->core.chip_name);
722 } 722 }
723 /* correct names for VT1705 */ 723 /* correct names for VT1705 */
724 if (codec->vendor_id == 0x11064397) { 724 if (codec->core.vendor_id == 0x11064397) {
725 kfree(codec->chip_name); 725 kfree(codec->core.chip_name);
726 codec->chip_name = kstrdup("VT1705", GFP_KERNEL); 726 codec->core.chip_name = kstrdup("VT1705", GFP_KERNEL);
727 snprintf(codec->card->mixername, 727 snprintf(codec->card->mixername,
728 sizeof(codec->card->mixername), 728 sizeof(codec->card->mixername),
729 "%s %s", codec->vendor_name, codec->chip_name); 729 "%s %s", codec->core.vendor_name, codec->core.chip_name);
730 } 730 }
731 731
732 /* automatic parse from the BIOS config */ 732 /* automatic parse from the BIOS config */
@@ -815,8 +815,7 @@ static int add_secret_dac_path(struct hda_codec *codec)
815 } 815 }
816 816
817 /* find the primary DAC and add to the connection list */ 817 /* find the primary DAC and add to the connection list */
818 nid = codec->start_nid; 818 for_each_hda_codec_node(nid, codec) {
819 for (i = 0; i < codec->num_nodes; i++, nid++) {
820 unsigned int caps = get_wcaps(codec, nid); 819 unsigned int caps = get_wcaps(codec, nid);
821 if (get_wcaps_type(caps) == AC_WID_AUD_OUT && 820 if (get_wcaps_type(caps) == AC_WID_AUD_OUT &&
822 !(caps & AC_WCAP_DIGITAL)) { 821 !(caps & AC_WCAP_DIGITAL)) {
diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c
index 6ba0b5517c40..0a4ad5feb82e 100644
--- a/sound/pci/hda/thinkpad_helper.c
+++ b/sound/pci/hda/thinkpad_helper.c
@@ -21,7 +21,7 @@ static acpi_status acpi_check_cb(acpi_handle handle, u32 lvl, void *context,
21static bool is_thinkpad(struct hda_codec *codec) 21static bool is_thinkpad(struct hda_codec *codec)
22{ 22{
23 bool found = false; 23 bool found = false;
24 if (codec->subsystem_id >> 16 != 0x17aa) 24 if (codec->core.subsystem_id >> 16 != 0x17aa)
25 return false; 25 return false;
26 if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found) 26 if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found)
27 return true; 27 return true;