2 * BIOS auto-parser helper functions for HD-audio
4 * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de>
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/slab.h>
13 #include <linux/export.h>
14 #include <linux/sort.h>
15 #include <sound/core.h>
16 #include "hda_codec.h"
17 #include "hda_local.h"
18 #include "hda_auto_parser.h"
20 #define SFX "hda_codec: "
23 * Helper for automatic pin configuration
26 static int is_in_nid_list(hda_nid_t nid, const hda_nid_t *list)
34 /* a pair of input pin and its sequence */
40 static int compare_seq(const void *ap, const void *bp)
42 const struct auto_out_pin *a = ap;
43 const struct auto_out_pin *b = bp;
44 return (int)(a->seq - b->seq);
48 * Sort an associated group of pins according to their sequence numbers.
49 * then store it to a pin array.
51 static void sort_pins_by_sequence(hda_nid_t *pins, struct auto_out_pin *list,
55 sort(list, num_pins, sizeof(list[0]), compare_seq, NULL);
56 for (i = 0; i < num_pins; i++)
57 pins[i] = list[i].pin;
61 /* add the found input-pin to the cfg->inputs[] table */
62 static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid,
65 if (cfg->num_inputs < AUTO_CFG_MAX_INS) {
66 cfg->inputs[cfg->num_inputs].pin = nid;
67 cfg->inputs[cfg->num_inputs].type = type;
72 static int compare_input_type(const void *ap, const void *bp)
74 const struct auto_pin_cfg_item *a = ap;
75 const struct auto_pin_cfg_item *b = bp;
76 return (int)(a->type - b->type);
79 /* Reorder the surround channels
80 * ALSA sequence is front/surr/clfe/side
82 * 4-ch: front/surr => OK as it is
83 * 6-ch: front/clfe/surr
84 * 8-ch: front/clfe/rear/side|fc
86 static void reorder_outputs(unsigned int nums, hda_nid_t *pins)
100 /* check whether the given pin has a proper pin I/O capability bit */
101 static bool check_pincap_validity(struct hda_codec *codec, hda_nid_t pin,
104 unsigned int pincap = snd_hda_query_pin_caps(codec, pin);
106 /* some old hardware don't return the proper pincaps */
111 case AC_JACK_LINE_OUT:
112 case AC_JACK_SPEAKER:
114 case AC_JACK_SPDIF_OUT:
115 case AC_JACK_DIG_OTHER_OUT:
116 return !!(pincap & AC_PINCAP_OUT);
118 return !!(pincap & AC_PINCAP_IN);
123 * Parse all pin widgets and store the useful pin nids to cfg
125 * The number of line-outs or any primary output is stored in line_outs,
126 * and the corresponding output pins are assigned to line_out_pins[],
127 * in the order of front, rear, CLFE, side, ...
129 * If more extra outputs (speaker and headphone) are found, the pins are
130 * assisnged to hp_pins[] and speaker_pins[], respectively. If no line-out jack
131 * is detected, one of speaker of HP pins is assigned as the primary
132 * output, i.e. to line_out_pins[0]. So, line_outs is always positive
133 * if any analog output exists.
135 * The analog input pins are assigned to inputs array.
136 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
139 int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
140 struct auto_pin_cfg *cfg,
141 const hda_nid_t *ignore_nids,
142 unsigned int cond_flags)
144 hda_nid_t nid, end_nid;
145 short seq, assoc_line_out;
146 struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)];
147 struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)];
148 struct auto_out_pin hp_out[ARRAY_SIZE(cfg->hp_pins)];
151 if (!snd_hda_get_int_hint(codec, "parser_flags", &i))
154 memset(cfg, 0, sizeof(*cfg));
156 memset(line_out, 0, sizeof(line_out));
157 memset(speaker_out, 0, sizeof(speaker_out));
158 memset(hp_out, 0, sizeof(hp_out));
161 end_nid = codec->start_nid + codec->num_nodes;
162 for (nid = codec->start_nid; nid < end_nid; nid++) {
163 unsigned int wid_caps = get_wcaps(codec, nid);
164 unsigned int wid_type = get_wcaps_type(wid_caps);
165 unsigned int def_conf;
166 short assoc, loc, conn, dev;
168 /* read all default configuration for pin complex */
169 if (wid_type != AC_WID_PIN)
171 /* ignore the given nids (e.g. pc-beep returns error) */
172 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
175 def_conf = snd_hda_codec_get_pincfg(codec, nid);
176 conn = get_defcfg_connect(def_conf);
177 if (conn == AC_JACK_PORT_NONE)
179 loc = get_defcfg_location(def_conf);
180 dev = get_defcfg_device(def_conf);
182 /* workaround for buggy BIOS setups */
183 if (dev == AC_JACK_LINE_OUT) {
184 if (conn == AC_JACK_PORT_FIXED ||
185 conn == AC_JACK_PORT_BOTH)
186 dev = AC_JACK_SPEAKER;
189 if (!check_pincap_validity(codec, nid, dev))
193 case AC_JACK_LINE_OUT:
194 seq = get_defcfg_sequence(def_conf);
195 assoc = get_defcfg_association(def_conf);
197 if (!(wid_caps & AC_WCAP_STEREO))
198 if (!cfg->mono_out_pin)
199 cfg->mono_out_pin = nid;
203 assoc_line_out = assoc;
204 else if (assoc_line_out != assoc)
206 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
208 line_out[cfg->line_outs].pin = nid;
209 line_out[cfg->line_outs].seq = seq;
212 case AC_JACK_SPEAKER:
213 seq = get_defcfg_sequence(def_conf);
214 assoc = get_defcfg_association(def_conf);
215 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
217 speaker_out[cfg->speaker_outs].pin = nid;
218 speaker_out[cfg->speaker_outs].seq = (assoc << 4) | seq;
222 seq = get_defcfg_sequence(def_conf);
223 assoc = get_defcfg_association(def_conf);
224 if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins))
226 hp_out[cfg->hp_outs].pin = nid;
227 hp_out[cfg->hp_outs].seq = (assoc << 4) | seq;
231 add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_MIC);
233 case AC_JACK_LINE_IN:
234 add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_LINE_IN);
237 add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD);
240 add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX);
242 case AC_JACK_SPDIF_OUT:
243 case AC_JACK_DIG_OTHER_OUT:
244 if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins))
246 cfg->dig_out_pins[cfg->dig_outs] = nid;
247 cfg->dig_out_type[cfg->dig_outs] =
248 (loc == AC_JACK_LOC_HDMI) ?
249 HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF;
252 case AC_JACK_SPDIF_IN:
253 case AC_JACK_DIG_OTHER_IN:
254 cfg->dig_in_pin = nid;
255 if (loc == AC_JACK_LOC_HDMI)
256 cfg->dig_in_type = HDA_PCM_TYPE_HDMI;
258 cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
263 /* Take first mic to be a headset mic pin */
264 if (cond_flags & HDA_PINCFG_HEADSET_MIC) {
265 for (i = 0; i < cfg->num_inputs; i++) {
267 unsigned int def_conf;
268 if (cfg->inputs[i].type != AUTO_PIN_MIC)
270 def_conf = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin);
271 attr = snd_hda_get_input_pin_attr(def_conf);
272 if (attr <= INPUT_PIN_ATTR_DOCK)
274 cfg->inputs[i].is_headset_mic = 1;
280 * If no line-out is defined but multiple HPs are found,
281 * some of them might be the real line-outs.
283 if (!cfg->line_outs && cfg->hp_outs > 1 &&
284 !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) {
286 while (i < cfg->hp_outs) {
287 /* The real HPs should have the sequence 0x0f */
288 if ((hp_out[i].seq & 0x0f) == 0x0f) {
292 /* Move it to the line-out table */
293 line_out[cfg->line_outs++] = hp_out[i];
295 memmove(hp_out + i, hp_out + i + 1,
296 sizeof(hp_out[0]) * (cfg->hp_outs - i));
298 memset(hp_out + cfg->hp_outs, 0,
299 sizeof(hp_out[0]) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs));
301 cfg->line_out_type = AUTO_PIN_HP_OUT;
305 /* sort by sequence */
306 sort_pins_by_sequence(cfg->line_out_pins, line_out, cfg->line_outs);
307 sort_pins_by_sequence(cfg->speaker_pins, speaker_out,
309 sort_pins_by_sequence(cfg->hp_pins, hp_out, cfg->hp_outs);
312 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
313 * as a primary output
315 if (!cfg->line_outs &&
316 !(cond_flags & HDA_PINCFG_NO_LO_FIXUP)) {
317 if (cfg->speaker_outs) {
318 cfg->line_outs = cfg->speaker_outs;
319 memcpy(cfg->line_out_pins, cfg->speaker_pins,
320 sizeof(cfg->speaker_pins));
321 cfg->speaker_outs = 0;
322 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
323 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
324 } else if (cfg->hp_outs) {
325 cfg->line_outs = cfg->hp_outs;
326 memcpy(cfg->line_out_pins, cfg->hp_pins,
327 sizeof(cfg->hp_pins));
329 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
330 cfg->line_out_type = AUTO_PIN_HP_OUT;
334 reorder_outputs(cfg->line_outs, cfg->line_out_pins);
335 reorder_outputs(cfg->hp_outs, cfg->hp_pins);
336 reorder_outputs(cfg->speaker_outs, cfg->speaker_pins);
338 /* sort inputs in the order of AUTO_PIN_* type */
339 sort(cfg->inputs, cfg->num_inputs, sizeof(cfg->inputs[0]),
340 compare_input_type, NULL);
343 * debug prints of the parsed results
345 snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n",
346 cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1],
347 cfg->line_out_pins[2], cfg->line_out_pins[3],
348 cfg->line_out_pins[4],
349 cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" :
350 (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ?
351 "speaker" : "line"));
352 snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
353 cfg->speaker_outs, cfg->speaker_pins[0],
354 cfg->speaker_pins[1], cfg->speaker_pins[2],
355 cfg->speaker_pins[3], cfg->speaker_pins[4]);
356 snd_printd(" hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
357 cfg->hp_outs, cfg->hp_pins[0],
358 cfg->hp_pins[1], cfg->hp_pins[2],
359 cfg->hp_pins[3], cfg->hp_pins[4]);
360 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin);
362 snd_printd(" dig-out=0x%x/0x%x\n",
363 cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
364 snd_printd(" inputs:\n");
365 for (i = 0; i < cfg->num_inputs; i++) {
366 snd_printd(" %s=0x%x\n",
367 hda_get_autocfg_input_label(codec, cfg, i),
371 snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin);
375 EXPORT_SYMBOL_HDA(snd_hda_parse_pin_defcfg);
377 int snd_hda_get_input_pin_attr(unsigned int def_conf)
379 unsigned int loc = get_defcfg_location(def_conf);
380 unsigned int conn = get_defcfg_connect(def_conf);
381 if (conn == AC_JACK_PORT_NONE)
382 return INPUT_PIN_ATTR_UNUSED;
383 /* Windows may claim the internal mic to be BOTH, too */
384 if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH)
385 return INPUT_PIN_ATTR_INT;
386 if ((loc & 0x30) == AC_JACK_LOC_INTERNAL)
387 return INPUT_PIN_ATTR_INT;
388 if ((loc & 0x30) == AC_JACK_LOC_SEPARATE)
389 return INPUT_PIN_ATTR_DOCK;
390 if (loc == AC_JACK_LOC_REAR)
391 return INPUT_PIN_ATTR_REAR;
392 if (loc == AC_JACK_LOC_FRONT)
393 return INPUT_PIN_ATTR_FRONT;
394 return INPUT_PIN_ATTR_NORMAL;
396 EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr);
399 * hda_get_input_pin_label - Give a label for the given input pin
401 * When check_location is true, the function checks the pin location
402 * for mic and line-in pins, and set an appropriate prefix like "Front",
403 * "Rear", "Internal".
406 static const char *hda_get_input_pin_label(struct hda_codec *codec,
407 const struct auto_pin_cfg_item *item,
408 hda_nid_t pin, bool check_location)
410 unsigned int def_conf;
411 static const char * const mic_names[] = {
412 "Internal Mic", "Dock Mic", "Mic", "Rear Mic", "Front Mic"
416 def_conf = snd_hda_codec_get_pincfg(codec, pin);
418 switch (get_defcfg_device(def_conf)) {
420 if (item && item->is_headset_mic)
421 return "Headset Mic";
424 attr = snd_hda_get_input_pin_attr(def_conf);
427 return mic_names[attr - 1];
428 case AC_JACK_LINE_IN:
431 attr = snd_hda_get_input_pin_attr(def_conf);
434 if (attr == INPUT_PIN_ATTR_DOCK)
441 case AC_JACK_SPDIF_IN:
443 case AC_JACK_DIG_OTHER_IN:
446 return "Headphone Mic";
452 /* Check whether the location prefix needs to be added to the label.
453 * If all mic-jacks are in the same location (e.g. rear panel), we don't
454 * have to put "Front" prefix to each label. In such a case, returns false.
456 static int check_mic_location_need(struct hda_codec *codec,
457 const struct auto_pin_cfg *cfg,
463 defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin);
464 attr = snd_hda_get_input_pin_attr(defc);
465 /* for internal or docking mics, we need locations */
466 if (attr <= INPUT_PIN_ATTR_NORMAL)
470 for (i = 0; i < cfg->num_inputs; i++) {
471 defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin);
472 attr2 = snd_hda_get_input_pin_attr(defc);
473 if (attr2 >= INPUT_PIN_ATTR_NORMAL) {
474 if (attr && attr != attr2)
475 return 1; /* different locations found */
483 * hda_get_autocfg_input_label - Get a label for the given input
485 * Get a label for the given input pin defined by the autocfg item.
486 * Unlike hda_get_input_pin_label(), this function checks all inputs
487 * defined in autocfg and avoids the redundant mic/line prefix as much as
490 const char *hda_get_autocfg_input_label(struct hda_codec *codec,
491 const struct auto_pin_cfg *cfg,
494 int type = cfg->inputs[input].type;
495 int has_multiple_pins = 0;
497 if ((input > 0 && cfg->inputs[input - 1].type == type) ||
498 (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type))
499 has_multiple_pins = 1;
500 if (has_multiple_pins && type == AUTO_PIN_MIC)
501 has_multiple_pins &= check_mic_location_need(codec, cfg, input);
502 return hda_get_input_pin_label(codec, &cfg->inputs[input],
503 cfg->inputs[input].pin,
506 EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
508 /* return the position of NID in the list, or -1 if not found */
509 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
512 for (i = 0; i < nums; i++)
518 /* get a unique suffix or an index number */
519 static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
520 int num_pins, int *indexp)
522 static const char * const channel_sfx[] = {
523 " Front", " Surround", " CLFE", " Side"
527 i = find_idx_in_nid_list(nid, pins, num_pins);
532 if (num_pins > ARRAY_SIZE(channel_sfx)) {
537 return channel_sfx[i];
540 static const char *check_output_pfx(struct hda_codec *codec, hda_nid_t nid)
542 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
543 int attr = snd_hda_get_input_pin_attr(def_conf);
545 /* check the location */
547 case INPUT_PIN_ATTR_DOCK:
549 case INPUT_PIN_ATTR_FRONT:
555 static int get_hp_label_index(struct hda_codec *codec, hda_nid_t nid,
556 const hda_nid_t *pins, int num_pins)
560 const char *pfx = check_output_pfx(codec, nid);
562 i = find_idx_in_nid_list(nid, pins, num_pins);
565 for (j = 0; j < i; j++)
566 if (pfx == check_output_pfx(codec, pins[j]))
572 static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
573 const struct auto_pin_cfg *cfg,
574 const char *name, char *label, int maxlen,
577 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
578 int attr = snd_hda_get_input_pin_attr(def_conf);
579 const char *pfx, *sfx = "";
581 /* handle as a speaker if it's a fixed line-out */
582 if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT)
584 pfx = check_output_pfx(codec, nid);
587 /* try to give a unique suffix if needed */
588 sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs,
591 sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs,
594 /* don't add channel suffix for Headphone controls */
595 int idx = get_hp_label_index(codec, nid, cfg->hp_pins,
602 snprintf(label, maxlen, "%s%s%s", pfx, name, sfx);
606 #define is_hdmi_cfg(conf) \
607 (get_defcfg_location(conf) == AC_JACK_LOC_HDMI)
610 * snd_hda_get_pin_label - Get a label for the given I/O pin
612 * Get a label for the given pin. This function works for both input and
613 * output pins. When @cfg is given as non-NULL, the function tries to get
614 * an optimized label using hda_get_autocfg_input_label().
616 * This function tries to give a unique label string for the pin as much as
617 * possible. For example, when the multiple line-outs are present, it adds
618 * the channel suffix like "Front", "Surround", etc (only when @cfg is given).
619 * If no unique name with a suffix is available and @indexp is non-NULL, the
620 * index number is stored in the pointer.
622 int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
623 const struct auto_pin_cfg *cfg,
624 char *label, int maxlen, int *indexp)
626 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
627 const char *name = NULL;
633 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
636 switch (get_defcfg_device(def_conf)) {
637 case AC_JACK_LINE_OUT:
638 return fill_audio_out_name(codec, nid, cfg, "Line Out",
639 label, maxlen, indexp);
640 case AC_JACK_SPEAKER:
641 return fill_audio_out_name(codec, nid, cfg, "Speaker",
642 label, maxlen, indexp);
644 return fill_audio_out_name(codec, nid, cfg, "Headphone",
645 label, maxlen, indexp);
646 case AC_JACK_SPDIF_OUT:
647 case AC_JACK_DIG_OTHER_OUT:
648 hdmi = is_hdmi_cfg(def_conf);
649 name = hdmi ? "HDMI" : "SPDIF";
651 for (i = 0; i < cfg->dig_outs; i++) {
652 hda_nid_t pin = cfg->dig_out_pins[i];
656 c = snd_hda_codec_get_pincfg(codec, pin);
657 if (hdmi == is_hdmi_cfg(c))
663 for (i = 0; i < cfg->num_inputs; i++) {
664 if (cfg->inputs[i].pin != nid)
666 name = hda_get_autocfg_input_label(codec, cfg, i);
672 name = hda_get_input_pin_label(codec, NULL, nid, true);
677 strlcpy(label, name, maxlen);
680 EXPORT_SYMBOL_HDA(snd_hda_get_pin_label);
682 int snd_hda_add_verbs(struct hda_codec *codec,
683 const struct hda_verb *list)
685 const struct hda_verb **v;
686 v = snd_array_new(&codec->verbs);
692 EXPORT_SYMBOL_HDA(snd_hda_add_verbs);
694 void snd_hda_apply_verbs(struct hda_codec *codec)
697 for (i = 0; i < codec->verbs.used; i++) {
698 struct hda_verb **v = snd_array_elem(&codec->verbs, i);
699 snd_hda_sequence_write(codec, *v);
702 EXPORT_SYMBOL_HDA(snd_hda_apply_verbs);
704 void snd_hda_apply_pincfgs(struct hda_codec *codec,
705 const struct hda_pintbl *cfg)
707 for (; cfg->nid; cfg++)
708 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
710 EXPORT_SYMBOL_HDA(snd_hda_apply_pincfgs);
712 static void set_pin_targets(struct hda_codec *codec,
713 const struct hda_pintbl *cfg)
715 for (; cfg->nid; cfg++)
716 snd_hda_set_pin_ctl_cache(codec, cfg->nid, cfg->val);
719 static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
721 const char *modelname = codec->fixup_name;
724 const struct hda_fixup *fix = codec->fixup_list + id;
726 if (fix->chained_before)
727 apply_fixup(codec, fix->chain_id, action, depth + 1);
731 if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins)
733 snd_printdd(KERN_INFO SFX
734 "%s: Apply pincfg for %s\n",
735 codec->chip_name, modelname);
736 snd_hda_apply_pincfgs(codec, fix->v.pins);
738 case HDA_FIXUP_VERBS:
739 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs)
741 snd_printdd(KERN_INFO SFX
742 "%s: Apply fix-verbs for %s\n",
743 codec->chip_name, modelname);
744 snd_hda_add_verbs(codec, fix->v.verbs);
749 snd_printdd(KERN_INFO SFX
750 "%s: Apply fix-func for %s\n",
751 codec->chip_name, modelname);
752 fix->v.func(codec, fix, action);
754 case HDA_FIXUP_PINCTLS:
755 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins)
757 snd_printdd(KERN_INFO SFX
758 "%s: Apply pinctl for %s\n",
759 codec->chip_name, modelname);
760 set_pin_targets(codec, fix->v.pins);
763 snd_printk(KERN_ERR SFX
764 "%s: Invalid fixup type %d\n",
765 codec->chip_name, fix->type);
768 if (!fix->chained || fix->chained_before)
776 void snd_hda_apply_fixup(struct hda_codec *codec, int action)
778 if (codec->fixup_list)
779 apply_fixup(codec, codec->fixup_id, action, 0);
781 EXPORT_SYMBOL_HDA(snd_hda_apply_fixup);
783 void snd_hda_pick_fixup(struct hda_codec *codec,
784 const struct hda_model_fixup *models,
785 const struct snd_pci_quirk *quirk,
786 const struct hda_fixup *fixlist)
788 const struct snd_pci_quirk *q;
790 const char *name = NULL;
792 /* when model=nofixup is given, don't pick up any fixups */
793 if (codec->modelname && !strcmp(codec->modelname, "nofixup")) {
794 codec->fixup_list = NULL;
795 codec->fixup_id = -1;
799 if (codec->modelname && models) {
800 while (models->name) {
801 if (!strcmp(codec->modelname, models->name)) {
809 if (id < 0 && quirk) {
810 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
813 #ifdef CONFIG_SND_DEBUG_VERBOSE
818 if (id < 0 && quirk) {
819 for (q = quirk; q->subvendor; q++) {
820 unsigned int vendorid =
821 q->subdevice | (q->subvendor << 16);
822 unsigned int mask = 0xffff0000 | q->subdevice_mask;
823 if ((codec->subsystem_id & mask) == (vendorid & mask)) {
825 #ifdef CONFIG_SND_DEBUG_VERBOSE
833 codec->fixup_id = id;
835 codec->fixup_list = fixlist;
836 codec->fixup_name = name;
839 EXPORT_SYMBOL_HDA(snd_hda_pick_fixup);