Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

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