Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 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> |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 12 | #include <sound/hda_regmap.h> |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 13 | #include "local.h" |
| 14 | |
| 15 | static void setup_fg_nodes(struct hdac_device *codec); |
| 16 | static int get_codec_vendor_name(struct hdac_device *codec); |
| 17 | |
| 18 | static void default_release(struct device *dev) |
| 19 | { |
| 20 | snd_hdac_device_exit(container_of(dev, struct hdac_device, dev)); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * snd_hdac_device_init - initialize the HD-audio codec base device |
| 25 | * @codec: device to initialize |
| 26 | * @bus: but to attach |
| 27 | * @name: device name string |
| 28 | * @addr: codec address |
| 29 | * |
| 30 | * Returns zero for success or a negative error code. |
| 31 | * |
| 32 | * This function increments the runtime PM counter and marks it active. |
| 33 | * The caller needs to turn it off appropriately later. |
| 34 | * |
| 35 | * The caller needs to set the device's release op properly by itself. |
| 36 | */ |
| 37 | int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, |
| 38 | const char *name, unsigned int addr) |
| 39 | { |
| 40 | struct device *dev; |
| 41 | hda_nid_t fg; |
| 42 | int err; |
| 43 | |
| 44 | dev = &codec->dev; |
| 45 | device_initialize(dev); |
| 46 | dev->parent = bus->dev; |
| 47 | dev->bus = &snd_hda_bus_type; |
| 48 | dev->release = default_release; |
Takashi Iwai | 3256be6 | 2015-02-24 14:59:42 +0100 | [diff] [blame] | 49 | dev->groups = hdac_dev_attr_groups; |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 50 | dev_set_name(dev, "%s", name); |
| 51 | device_enable_async_suspend(dev); |
| 52 | |
| 53 | codec->bus = bus; |
| 54 | codec->addr = addr; |
| 55 | codec->type = HDA_DEV_CORE; |
| 56 | pm_runtime_set_active(&codec->dev); |
| 57 | pm_runtime_get_noresume(&codec->dev); |
| 58 | atomic_set(&codec->in_pm, 0); |
| 59 | |
| 60 | err = snd_hdac_bus_add_device(bus, codec); |
| 61 | if (err < 0) |
| 62 | goto error; |
| 63 | |
| 64 | /* fill parameters */ |
| 65 | codec->vendor_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, |
| 66 | AC_PAR_VENDOR_ID); |
| 67 | if (codec->vendor_id == -1) { |
| 68 | /* read again, hopefully the access method was corrected |
| 69 | * in the last read... |
| 70 | */ |
| 71 | codec->vendor_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, |
| 72 | AC_PAR_VENDOR_ID); |
| 73 | } |
| 74 | |
| 75 | codec->subsystem_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, |
| 76 | AC_PAR_SUBSYSTEM_ID); |
| 77 | codec->revision_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, |
| 78 | AC_PAR_REV_ID); |
| 79 | |
| 80 | setup_fg_nodes(codec); |
| 81 | if (!codec->afg && !codec->mfg) { |
| 82 | dev_err(dev, "no AFG or MFG node found\n"); |
| 83 | err = -ENODEV; |
| 84 | goto error; |
| 85 | } |
| 86 | |
| 87 | fg = codec->afg ? codec->afg : codec->mfg; |
| 88 | |
| 89 | err = snd_hdac_refresh_widgets(codec); |
| 90 | if (err < 0) |
| 91 | goto error; |
| 92 | |
| 93 | codec->power_caps = snd_hdac_read_parm(codec, fg, AC_PAR_POWER_STATE); |
| 94 | /* reread ssid if not set by parameter */ |
| 95 | if (codec->subsystem_id == -1) |
| 96 | snd_hdac_read(codec, fg, AC_VERB_GET_SUBSYSTEM_ID, 0, |
| 97 | &codec->subsystem_id); |
| 98 | |
| 99 | err = get_codec_vendor_name(codec); |
| 100 | if (err < 0) |
| 101 | goto error; |
| 102 | |
| 103 | codec->chip_name = kasprintf(GFP_KERNEL, "ID %x", |
| 104 | codec->vendor_id & 0xffff); |
| 105 | if (!codec->chip_name) { |
| 106 | err = -ENOMEM; |
| 107 | goto error; |
| 108 | } |
| 109 | |
| 110 | return 0; |
| 111 | |
| 112 | error: |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 113 | put_device(&codec->dev); |
| 114 | return err; |
| 115 | } |
| 116 | EXPORT_SYMBOL_GPL(snd_hdac_device_init); |
| 117 | |
| 118 | /** |
| 119 | * snd_hdac_device_exit - clean up the HD-audio codec base device |
| 120 | * @codec: device to clean up |
| 121 | */ |
| 122 | void snd_hdac_device_exit(struct hdac_device *codec) |
| 123 | { |
Takashi Iwai | c4c2533 | 2015-03-03 17:22:12 +0100 | [diff] [blame] | 124 | pm_runtime_put_noidle(&codec->dev); |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 125 | snd_hdac_bus_remove_device(codec->bus, codec); |
| 126 | kfree(codec->vendor_name); |
| 127 | kfree(codec->chip_name); |
| 128 | } |
| 129 | EXPORT_SYMBOL_GPL(snd_hdac_device_exit); |
| 130 | |
| 131 | /** |
Takashi Iwai | 3256be6 | 2015-02-24 14:59:42 +0100 | [diff] [blame] | 132 | * snd_hdac_device_register - register the hd-audio codec base device |
| 133 | * codec: the device to register |
| 134 | */ |
| 135 | int snd_hdac_device_register(struct hdac_device *codec) |
| 136 | { |
| 137 | int err; |
| 138 | |
| 139 | err = device_add(&codec->dev); |
| 140 | if (err < 0) |
| 141 | return err; |
| 142 | err = hda_widget_sysfs_init(codec); |
| 143 | if (err < 0) { |
| 144 | device_del(&codec->dev); |
| 145 | return err; |
| 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | EXPORT_SYMBOL_GPL(snd_hdac_device_register); |
| 151 | |
| 152 | /** |
| 153 | * snd_hdac_device_unregister - unregister the hd-audio codec base device |
| 154 | * codec: the device to unregister |
| 155 | */ |
| 156 | void snd_hdac_device_unregister(struct hdac_device *codec) |
| 157 | { |
| 158 | if (device_is_registered(&codec->dev)) { |
| 159 | hda_widget_sysfs_exit(codec); |
| 160 | device_del(&codec->dev); |
| 161 | } |
| 162 | } |
| 163 | EXPORT_SYMBOL_GPL(snd_hdac_device_unregister); |
| 164 | |
| 165 | /** |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 166 | * snd_hdac_make_cmd - compose a 32bit command word to be sent to the |
| 167 | * HD-audio controller |
| 168 | * @codec: the codec object |
| 169 | * @nid: NID to encode |
| 170 | * @verb: verb to encode |
| 171 | * @parm: parameter to encode |
| 172 | * |
| 173 | * Return an encoded command verb or -1 for error. |
| 174 | */ |
| 175 | unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid, |
| 176 | unsigned int verb, unsigned int parm) |
| 177 | { |
| 178 | u32 val, addr; |
| 179 | |
| 180 | addr = codec->addr; |
| 181 | if ((addr & ~0xf) || (nid & ~0x7f) || |
| 182 | (verb & ~0xfff) || (parm & ~0xffff)) { |
| 183 | dev_err(&codec->dev, "out of range cmd %x:%x:%x:%x\n", |
| 184 | addr, nid, verb, parm); |
| 185 | return -1; |
| 186 | } |
| 187 | |
| 188 | val = addr << 28; |
| 189 | val |= (u32)nid << 20; |
| 190 | val |= verb << 8; |
| 191 | val |= parm; |
| 192 | return val; |
| 193 | } |
| 194 | EXPORT_SYMBOL_GPL(snd_hdac_make_cmd); |
| 195 | |
| 196 | /** |
Takashi Iwai | 0585244 | 2015-03-03 15:40:08 +0100 | [diff] [blame] | 197 | * snd_hdac_exec_verb - execute an encoded verb |
| 198 | * @codec: the codec object |
| 199 | * @cmd: encoded verb to execute |
| 200 | * @flags: optional flags, pass zero for default |
| 201 | * @res: the pointer to store the result, NULL if running async |
| 202 | * |
| 203 | * Returns zero if successful, or a negative error code. |
| 204 | * |
| 205 | * This calls the exec_verb op when set in hdac_codec. If not, |
| 206 | * call the default snd_hdac_bus_exec_verb(). |
| 207 | */ |
| 208 | int snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd, |
| 209 | unsigned int flags, unsigned int *res) |
| 210 | { |
| 211 | if (codec->exec_verb) |
| 212 | return codec->exec_verb(codec, cmd, flags, res); |
| 213 | return snd_hdac_bus_exec_verb(codec->bus, codec->addr, cmd, res); |
| 214 | } |
| 215 | EXPORT_SYMBOL_GPL(snd_hdac_exec_verb); |
| 216 | |
| 217 | |
| 218 | /** |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 219 | * snd_hdac_read - execute a verb |
| 220 | * @codec: the codec object |
| 221 | * @nid: NID to execute a verb |
| 222 | * @verb: verb to execute |
| 223 | * @parm: parameter for a verb |
| 224 | * @res: the pointer to store the result, NULL if running async |
| 225 | * |
| 226 | * Returns zero if successful, or a negative error code. |
| 227 | */ |
| 228 | int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid, |
| 229 | unsigned int verb, unsigned int parm, unsigned int *res) |
| 230 | { |
| 231 | unsigned int cmd = snd_hdac_make_cmd(codec, nid, verb, parm); |
| 232 | |
Takashi Iwai | 0585244 | 2015-03-03 15:40:08 +0100 | [diff] [blame] | 233 | return snd_hdac_exec_verb(codec, cmd, 0, res); |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 234 | } |
| 235 | EXPORT_SYMBOL_GPL(snd_hdac_read); |
| 236 | |
| 237 | /** |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 238 | * _snd_hdac_read_parm - read a parmeter |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 239 | * |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 240 | * This function returns zero or an error unlike snd_hdac_read_parm(). |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 241 | */ |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 242 | int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm, |
| 243 | unsigned int *res) |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 244 | { |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 245 | unsigned int cmd; |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 246 | |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 247 | cmd = snd_hdac_regmap_encode_verb(nid, AC_VERB_PARAMETERS) | parm; |
| 248 | return snd_hdac_regmap_read_raw(codec, cmd, res); |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 249 | } |
Takashi Iwai | 01ed3c0 | 2015-02-26 13:57:47 +0100 | [diff] [blame^] | 250 | EXPORT_SYMBOL_GPL(_snd_hdac_read_parm); |
Takashi Iwai | 7639a06 | 2015-03-03 10:07:24 +0100 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * snd_hdac_get_sub_nodes - get start NID and number of subtree nodes |
| 254 | * @codec: the codec object |
| 255 | * @nid: NID to inspect |
| 256 | * @start_id: the pointer to store the starting NID |
| 257 | * |
| 258 | * Returns the number of subtree nodes or zero if not found. |
| 259 | */ |
| 260 | int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid, |
| 261 | hda_nid_t *start_id) |
| 262 | { |
| 263 | unsigned int parm; |
| 264 | |
| 265 | parm = snd_hdac_read_parm(codec, nid, AC_PAR_NODE_COUNT); |
| 266 | if (parm == -1) { |
| 267 | *start_id = 0; |
| 268 | return 0; |
| 269 | } |
| 270 | *start_id = (parm >> 16) & 0x7fff; |
| 271 | return (int)(parm & 0x7fff); |
| 272 | } |
| 273 | EXPORT_SYMBOL_GPL(snd_hdac_get_sub_nodes); |
| 274 | |
| 275 | /* |
| 276 | * look for an AFG and MFG nodes |
| 277 | */ |
| 278 | static void setup_fg_nodes(struct hdac_device *codec) |
| 279 | { |
| 280 | int i, total_nodes, function_id; |
| 281 | hda_nid_t nid; |
| 282 | |
| 283 | total_nodes = snd_hdac_get_sub_nodes(codec, AC_NODE_ROOT, &nid); |
| 284 | for (i = 0; i < total_nodes; i++, nid++) { |
| 285 | function_id = snd_hdac_read_parm(codec, nid, |
| 286 | AC_PAR_FUNCTION_TYPE); |
| 287 | switch (function_id & 0xff) { |
| 288 | case AC_GRP_AUDIO_FUNCTION: |
| 289 | codec->afg = nid; |
| 290 | codec->afg_function_id = function_id & 0xff; |
| 291 | codec->afg_unsol = (function_id >> 8) & 1; |
| 292 | break; |
| 293 | case AC_GRP_MODEM_FUNCTION: |
| 294 | codec->mfg = nid; |
| 295 | codec->mfg_function_id = function_id & 0xff; |
| 296 | codec->mfg_unsol = (function_id >> 8) & 1; |
| 297 | break; |
| 298 | default: |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * snd_hdac_refresh_widgets - Reset the widget start/end nodes |
| 306 | * @codec: the codec object |
| 307 | */ |
| 308 | int snd_hdac_refresh_widgets(struct hdac_device *codec) |
| 309 | { |
| 310 | hda_nid_t start_nid; |
| 311 | int nums; |
| 312 | |
| 313 | nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); |
| 314 | if (!start_nid || nums <= 0 || nums >= 0xff) { |
| 315 | dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", |
| 316 | codec->afg); |
| 317 | return -EINVAL; |
| 318 | } |
| 319 | |
| 320 | codec->num_nodes = nums; |
| 321 | codec->start_nid = start_nid; |
| 322 | codec->end_nid = start_nid + nums; |
| 323 | return 0; |
| 324 | } |
| 325 | EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets); |
| 326 | |
| 327 | /* return CONNLIST_LEN parameter of the given widget */ |
| 328 | static unsigned int get_num_conns(struct hdac_device *codec, hda_nid_t nid) |
| 329 | { |
| 330 | unsigned int wcaps = get_wcaps(codec, nid); |
| 331 | unsigned int parm; |
| 332 | |
| 333 | if (!(wcaps & AC_WCAP_CONN_LIST) && |
| 334 | get_wcaps_type(wcaps) != AC_WID_VOL_KNB) |
| 335 | return 0; |
| 336 | |
| 337 | parm = snd_hdac_read_parm(codec, nid, AC_PAR_CONNLIST_LEN); |
| 338 | if (parm == -1) |
| 339 | parm = 0; |
| 340 | return parm; |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * snd_hdac_get_connections - get a widget connection list |
| 345 | * @codec: the codec object |
| 346 | * @nid: NID |
| 347 | * @conn_list: the array to store the results, can be NULL |
| 348 | * @max_conns: the max size of the given array |
| 349 | * |
| 350 | * Returns the number of connected widgets, zero for no connection, or a |
| 351 | * negative error code. When the number of elements don't fit with the |
| 352 | * given array size, it returns -ENOSPC. |
| 353 | * |
| 354 | * When @conn_list is NULL, it just checks the number of connections. |
| 355 | */ |
| 356 | int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid, |
| 357 | hda_nid_t *conn_list, int max_conns) |
| 358 | { |
| 359 | unsigned int parm; |
| 360 | int i, conn_len, conns, err; |
| 361 | unsigned int shift, num_elems, mask; |
| 362 | hda_nid_t prev_nid; |
| 363 | int null_count = 0; |
| 364 | |
| 365 | parm = get_num_conns(codec, nid); |
| 366 | if (!parm) |
| 367 | return 0; |
| 368 | |
| 369 | if (parm & AC_CLIST_LONG) { |
| 370 | /* long form */ |
| 371 | shift = 16; |
| 372 | num_elems = 2; |
| 373 | } else { |
| 374 | /* short form */ |
| 375 | shift = 8; |
| 376 | num_elems = 4; |
| 377 | } |
| 378 | conn_len = parm & AC_CLIST_LENGTH; |
| 379 | mask = (1 << (shift-1)) - 1; |
| 380 | |
| 381 | if (!conn_len) |
| 382 | return 0; /* no connection */ |
| 383 | |
| 384 | if (conn_len == 1) { |
| 385 | /* single connection */ |
| 386 | err = snd_hdac_read(codec, nid, AC_VERB_GET_CONNECT_LIST, 0, |
| 387 | &parm); |
| 388 | if (err < 0) |
| 389 | return err; |
| 390 | if (conn_list) |
| 391 | conn_list[0] = parm & mask; |
| 392 | return 1; |
| 393 | } |
| 394 | |
| 395 | /* multi connection */ |
| 396 | conns = 0; |
| 397 | prev_nid = 0; |
| 398 | for (i = 0; i < conn_len; i++) { |
| 399 | int range_val; |
| 400 | hda_nid_t val, n; |
| 401 | |
| 402 | if (i % num_elems == 0) { |
| 403 | err = snd_hdac_read(codec, nid, |
| 404 | AC_VERB_GET_CONNECT_LIST, i, |
| 405 | &parm); |
| 406 | if (err < 0) |
| 407 | return -EIO; |
| 408 | } |
| 409 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ |
| 410 | val = parm & mask; |
| 411 | if (val == 0 && null_count++) { /* no second chance */ |
| 412 | dev_dbg(&codec->dev, |
| 413 | "invalid CONNECT_LIST verb %x[%i]:%x\n", |
| 414 | nid, i, parm); |
| 415 | return 0; |
| 416 | } |
| 417 | parm >>= shift; |
| 418 | if (range_val) { |
| 419 | /* ranges between the previous and this one */ |
| 420 | if (!prev_nid || prev_nid >= val) { |
| 421 | dev_warn(&codec->dev, |
| 422 | "invalid dep_range_val %x:%x\n", |
| 423 | prev_nid, val); |
| 424 | continue; |
| 425 | } |
| 426 | for (n = prev_nid + 1; n <= val; n++) { |
| 427 | if (conn_list) { |
| 428 | if (conns >= max_conns) |
| 429 | return -ENOSPC; |
| 430 | conn_list[conns] = n; |
| 431 | } |
| 432 | conns++; |
| 433 | } |
| 434 | } else { |
| 435 | if (conn_list) { |
| 436 | if (conns >= max_conns) |
| 437 | return -ENOSPC; |
| 438 | conn_list[conns] = val; |
| 439 | } |
| 440 | conns++; |
| 441 | } |
| 442 | prev_nid = val; |
| 443 | } |
| 444 | return conns; |
| 445 | } |
| 446 | EXPORT_SYMBOL_GPL(snd_hdac_get_connections); |
| 447 | |
| 448 | #ifdef CONFIG_PM |
| 449 | /** |
| 450 | * snd_hdac_power_up - increment the runtime pm counter |
| 451 | * @codec: the codec object |
| 452 | */ |
| 453 | void snd_hdac_power_up(struct hdac_device *codec) |
| 454 | { |
| 455 | struct device *dev = &codec->dev; |
| 456 | |
| 457 | if (atomic_read(&codec->in_pm)) |
| 458 | return; |
| 459 | pm_runtime_get_sync(dev); |
| 460 | } |
| 461 | EXPORT_SYMBOL_GPL(snd_hdac_power_up); |
| 462 | |
| 463 | /** |
| 464 | * snd_hdac_power_up - decrement the runtime pm counter |
| 465 | * @codec: the codec object |
| 466 | */ |
| 467 | void snd_hdac_power_down(struct hdac_device *codec) |
| 468 | { |
| 469 | struct device *dev = &codec->dev; |
| 470 | |
| 471 | if (atomic_read(&codec->in_pm)) |
| 472 | return; |
| 473 | pm_runtime_mark_last_busy(dev); |
| 474 | pm_runtime_put_autosuspend(dev); |
| 475 | } |
| 476 | EXPORT_SYMBOL_GPL(snd_hdac_power_down); |
| 477 | #endif |
| 478 | |
| 479 | /* codec vendor labels */ |
| 480 | struct hda_vendor_id { |
| 481 | unsigned int id; |
| 482 | const char *name; |
| 483 | }; |
| 484 | |
| 485 | static struct hda_vendor_id hda_vendor_ids[] = { |
| 486 | { 0x1002, "ATI" }, |
| 487 | { 0x1013, "Cirrus Logic" }, |
| 488 | { 0x1057, "Motorola" }, |
| 489 | { 0x1095, "Silicon Image" }, |
| 490 | { 0x10de, "Nvidia" }, |
| 491 | { 0x10ec, "Realtek" }, |
| 492 | { 0x1102, "Creative" }, |
| 493 | { 0x1106, "VIA" }, |
| 494 | { 0x111d, "IDT" }, |
| 495 | { 0x11c1, "LSI" }, |
| 496 | { 0x11d4, "Analog Devices" }, |
| 497 | { 0x13f6, "C-Media" }, |
| 498 | { 0x14f1, "Conexant" }, |
| 499 | { 0x17e8, "Chrontel" }, |
| 500 | { 0x1854, "LG" }, |
| 501 | { 0x1aec, "Wolfson Microelectronics" }, |
| 502 | { 0x1af4, "QEMU" }, |
| 503 | { 0x434d, "C-Media" }, |
| 504 | { 0x8086, "Intel" }, |
| 505 | { 0x8384, "SigmaTel" }, |
| 506 | {} /* terminator */ |
| 507 | }; |
| 508 | |
| 509 | /* store the codec vendor name */ |
| 510 | static int get_codec_vendor_name(struct hdac_device *codec) |
| 511 | { |
| 512 | const struct hda_vendor_id *c; |
| 513 | u16 vendor_id = codec->vendor_id >> 16; |
| 514 | |
| 515 | for (c = hda_vendor_ids; c->id; c++) { |
| 516 | if (c->id == vendor_id) { |
| 517 | codec->vendor_name = kstrdup(c->name, GFP_KERNEL); |
| 518 | return codec->vendor_name ? 0 : -ENOMEM; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | codec->vendor_name = kasprintf(GFP_KERNEL, "Generic %04x", vendor_id); |
| 523 | return codec->vendor_name ? 0 : -ENOMEM; |
| 524 | } |