Lines Matching +full:codec +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * BIOS auto-parser helper functions for HD-audio
24 return 1; in is_in_nid_list()
38 return (int)(a->seq - b->seq); in compare_seq()
55 /* add the found input-pin to the cfg->inputs[] table */
56 static void add_auto_cfg_input_pin(struct hda_codec *codec, struct auto_pin_cfg *cfg, in add_auto_cfg_input_pin() argument
59 if (cfg->num_inputs < AUTO_CFG_MAX_INS) { in add_auto_cfg_input_pin()
60 cfg->inputs[cfg->num_inputs].pin = nid; in add_auto_cfg_input_pin()
61 cfg->inputs[cfg->num_inputs].type = type; in add_auto_cfg_input_pin()
62 cfg->inputs[cfg->num_inputs].has_boost_on_pin = in add_auto_cfg_input_pin()
63 nid_has_volume(codec, nid, HDA_INPUT); in add_auto_cfg_input_pin()
64 cfg->num_inputs++; in add_auto_cfg_input_pin()
72 if (a->type != b->type) in compare_input_type()
73 return (int)(a->type - b->type); in compare_input_type()
76 if (a->is_headset_mic && b->is_headphone_mic) in compare_input_type()
77 return -1; /* don't swap */ in compare_input_type()
78 else if (a->is_headphone_mic && b->is_headset_mic) in compare_input_type()
79 return 1; /* swap */ in compare_input_type()
83 return (int)(b->has_boost_on_pin - a->has_boost_on_pin); in compare_input_type()
89 * 4-ch: front/surr => OK as it is
90 * 6-ch: front/clfe/surr
91 * 8-ch: front/clfe/rear/side|fc
98 swap(pins[1], pins[2]); in reorder_outputs()
104 static bool check_pincap_validity(struct hda_codec *codec, hda_nid_t pin, in check_pincap_validity() argument
107 unsigned int pincap = snd_hda_query_pin_caps(codec, pin); in check_pincap_validity()
125 static bool can_be_headset_mic(struct hda_codec *codec, in can_be_headset_mic() argument
131 if (item->type != AUTO_PIN_MIC) in can_be_headset_mic()
134 if (item->is_headset_mic || item->is_headphone_mic) in can_be_headset_mic()
137 def_conf = snd_hda_codec_get_pincfg(codec, item->pin); in can_be_headset_mic()
154 * The number of line-outs or any primary output is stored in line_outs,
159 * assisnged to hp_pins[] and speaker_pins[], respectively. If no line-out jack
168 int snd_hda_parse_pin_defcfg(struct hda_codec *codec, in snd_hda_parse_pin_defcfg() argument
175 struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)]; in snd_hda_parse_pin_defcfg()
176 struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)]; in snd_hda_parse_pin_defcfg()
177 struct auto_out_pin hp_out[ARRAY_SIZE(cfg->hp_pins)]; in snd_hda_parse_pin_defcfg()
180 if (!snd_hda_get_int_hint(codec, "parser_flags", &i)) in snd_hda_parse_pin_defcfg()
190 for_each_hda_codec_node(nid, codec) { in snd_hda_parse_pin_defcfg()
191 unsigned int wid_caps = get_wcaps(codec, nid); in snd_hda_parse_pin_defcfg()
199 /* ignore the given nids (e.g. pc-beep returns error) */ in snd_hda_parse_pin_defcfg()
203 def_conf = snd_hda_codec_get_pincfg(codec, nid); in snd_hda_parse_pin_defcfg()
217 if (!check_pincap_validity(codec, nid, dev)) in snd_hda_parse_pin_defcfg()
226 if (!cfg->mono_out_pin) in snd_hda_parse_pin_defcfg()
227 cfg->mono_out_pin = nid; in snd_hda_parse_pin_defcfg()
233 codec_info(codec, in snd_hda_parse_pin_defcfg()
238 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) { in snd_hda_parse_pin_defcfg()
239 codec_info(codec, in snd_hda_parse_pin_defcfg()
244 line_out[cfg->line_outs].pin = nid; in snd_hda_parse_pin_defcfg()
245 line_out[cfg->line_outs].seq = seq; in snd_hda_parse_pin_defcfg()
246 cfg->line_outs++; in snd_hda_parse_pin_defcfg()
251 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) { in snd_hda_parse_pin_defcfg()
252 codec_info(codec, in snd_hda_parse_pin_defcfg()
257 speaker_out[cfg->speaker_outs].pin = nid; in snd_hda_parse_pin_defcfg()
258 speaker_out[cfg->speaker_outs].seq = (assoc << 4) | seq; in snd_hda_parse_pin_defcfg()
259 cfg->speaker_outs++; in snd_hda_parse_pin_defcfg()
264 if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) { in snd_hda_parse_pin_defcfg()
265 codec_info(codec, in snd_hda_parse_pin_defcfg()
270 hp_out[cfg->hp_outs].pin = nid; in snd_hda_parse_pin_defcfg()
271 hp_out[cfg->hp_outs].seq = (assoc << 4) | seq; in snd_hda_parse_pin_defcfg()
272 cfg->hp_outs++; in snd_hda_parse_pin_defcfg()
275 add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_MIC); in snd_hda_parse_pin_defcfg()
278 add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_LINE_IN); in snd_hda_parse_pin_defcfg()
281 add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_CD); in snd_hda_parse_pin_defcfg()
284 add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_AUX); in snd_hda_parse_pin_defcfg()
288 if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) { in snd_hda_parse_pin_defcfg()
289 codec_info(codec, in snd_hda_parse_pin_defcfg()
294 cfg->dig_out_pins[cfg->dig_outs] = nid; in snd_hda_parse_pin_defcfg()
295 cfg->dig_out_type[cfg->dig_outs] = in snd_hda_parse_pin_defcfg()
298 cfg->dig_outs++; in snd_hda_parse_pin_defcfg()
302 cfg->dig_in_pin = nid; in snd_hda_parse_pin_defcfg()
304 cfg->dig_in_type = HDA_PCM_TYPE_HDMI; in snd_hda_parse_pin_defcfg()
306 cfg->dig_in_type = HDA_PCM_TYPE_SPDIF; in snd_hda_parse_pin_defcfg()
315 for (i = 0; (hsmic || hpmic) && (i < cfg->num_inputs); i++) in snd_hda_parse_pin_defcfg()
316 if (hsmic && can_be_headset_mic(codec, &cfg->inputs[i], 0xc)) { in snd_hda_parse_pin_defcfg()
317 cfg->inputs[i].is_headset_mic = 1; in snd_hda_parse_pin_defcfg()
319 } else if (hpmic && can_be_headset_mic(codec, &cfg->inputs[i], 0xd)) { in snd_hda_parse_pin_defcfg()
320 cfg->inputs[i].is_headphone_mic = 1; in snd_hda_parse_pin_defcfg()
325 for (i = 0; (hsmic || hpmic) && (i < cfg->num_inputs); i++) { in snd_hda_parse_pin_defcfg()
326 if (!can_be_headset_mic(codec, &cfg->inputs[i], -1)) in snd_hda_parse_pin_defcfg()
329 cfg->inputs[i].is_headset_mic = 1; in snd_hda_parse_pin_defcfg()
332 cfg->inputs[i].is_headphone_mic = 1; in snd_hda_parse_pin_defcfg()
338 codec_dbg(codec, "Told to look for a headset mic, but didn't find any.\n"); in snd_hda_parse_pin_defcfg()
340 codec_dbg(codec, "Told to look for a headphone mic, but didn't find any.\n"); in snd_hda_parse_pin_defcfg()
343 /* FIX-UP: in snd_hda_parse_pin_defcfg()
344 * If no line-out is defined but multiple HPs are found, in snd_hda_parse_pin_defcfg()
345 * some of them might be the real line-outs. in snd_hda_parse_pin_defcfg()
347 if (!cfg->line_outs && cfg->hp_outs > 1 && in snd_hda_parse_pin_defcfg()
350 while (i < cfg->hp_outs) { in snd_hda_parse_pin_defcfg()
356 /* Move it to the line-out table */ in snd_hda_parse_pin_defcfg()
357 line_out[cfg->line_outs++] = hp_out[i]; in snd_hda_parse_pin_defcfg()
358 cfg->hp_outs--; in snd_hda_parse_pin_defcfg()
359 memmove(hp_out + i, hp_out + i + 1, in snd_hda_parse_pin_defcfg()
360 sizeof(hp_out[0]) * (cfg->hp_outs - i)); in snd_hda_parse_pin_defcfg()
362 memset(hp_out + cfg->hp_outs, 0, in snd_hda_parse_pin_defcfg()
363 sizeof(hp_out[0]) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs)); in snd_hda_parse_pin_defcfg()
364 if (!cfg->hp_outs) in snd_hda_parse_pin_defcfg()
365 cfg->line_out_type = AUTO_PIN_HP_OUT; in snd_hda_parse_pin_defcfg()
370 sort_pins_by_sequence(cfg->line_out_pins, line_out, cfg->line_outs); in snd_hda_parse_pin_defcfg()
371 sort_pins_by_sequence(cfg->speaker_pins, speaker_out, in snd_hda_parse_pin_defcfg()
372 cfg->speaker_outs); in snd_hda_parse_pin_defcfg()
373 sort_pins_by_sequence(cfg->hp_pins, hp_out, cfg->hp_outs); in snd_hda_parse_pin_defcfg()
376 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin in snd_hda_parse_pin_defcfg()
379 if (!cfg->line_outs && in snd_hda_parse_pin_defcfg()
381 if (cfg->speaker_outs) { in snd_hda_parse_pin_defcfg()
382 cfg->line_outs = cfg->speaker_outs; in snd_hda_parse_pin_defcfg()
383 memcpy(cfg->line_out_pins, cfg->speaker_pins, in snd_hda_parse_pin_defcfg()
384 sizeof(cfg->speaker_pins)); in snd_hda_parse_pin_defcfg()
385 cfg->speaker_outs = 0; in snd_hda_parse_pin_defcfg()
386 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); in snd_hda_parse_pin_defcfg()
387 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; in snd_hda_parse_pin_defcfg()
388 } else if (cfg->hp_outs) { in snd_hda_parse_pin_defcfg()
389 cfg->line_outs = cfg->hp_outs; in snd_hda_parse_pin_defcfg()
390 memcpy(cfg->line_out_pins, cfg->hp_pins, in snd_hda_parse_pin_defcfg()
391 sizeof(cfg->hp_pins)); in snd_hda_parse_pin_defcfg()
392 cfg->hp_outs = 0; in snd_hda_parse_pin_defcfg()
393 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in snd_hda_parse_pin_defcfg()
394 cfg->line_out_type = AUTO_PIN_HP_OUT; in snd_hda_parse_pin_defcfg()
398 reorder_outputs(cfg->line_outs, cfg->line_out_pins); in snd_hda_parse_pin_defcfg()
399 reorder_outputs(cfg->hp_outs, cfg->hp_pins); in snd_hda_parse_pin_defcfg()
400 reorder_outputs(cfg->speaker_outs, cfg->speaker_pins); in snd_hda_parse_pin_defcfg()
403 sort(cfg->inputs, cfg->num_inputs, sizeof(cfg->inputs[0]), in snd_hda_parse_pin_defcfg()
409 codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", in snd_hda_parse_pin_defcfg()
410 codec->core.chip_name, cfg->line_outs, cfg->line_out_pins[0], in snd_hda_parse_pin_defcfg()
411 cfg->line_out_pins[1], cfg->line_out_pins[2], in snd_hda_parse_pin_defcfg()
412 cfg->line_out_pins[3], cfg->line_out_pins[4], in snd_hda_parse_pin_defcfg()
413 cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : in snd_hda_parse_pin_defcfg()
414 (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ? in snd_hda_parse_pin_defcfg()
416 codec_info(codec, " speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", in snd_hda_parse_pin_defcfg()
417 cfg->speaker_outs, cfg->speaker_pins[0], in snd_hda_parse_pin_defcfg()
418 cfg->speaker_pins[1], cfg->speaker_pins[2], in snd_hda_parse_pin_defcfg()
419 cfg->speaker_pins[3], cfg->speaker_pins[4]); in snd_hda_parse_pin_defcfg()
420 codec_info(codec, " hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", in snd_hda_parse_pin_defcfg()
421 cfg->hp_outs, cfg->hp_pins[0], in snd_hda_parse_pin_defcfg()
422 cfg->hp_pins[1], cfg->hp_pins[2], in snd_hda_parse_pin_defcfg()
423 cfg->hp_pins[3], cfg->hp_pins[4]); in snd_hda_parse_pin_defcfg()
424 codec_info(codec, " mono: mono_out=0x%x\n", cfg->mono_out_pin); in snd_hda_parse_pin_defcfg()
425 if (cfg->dig_outs) in snd_hda_parse_pin_defcfg()
426 codec_info(codec, " dig-out=0x%x/0x%x\n", in snd_hda_parse_pin_defcfg()
427 cfg->dig_out_pins[0], cfg->dig_out_pins[1]); in snd_hda_parse_pin_defcfg()
428 codec_info(codec, " inputs:\n"); in snd_hda_parse_pin_defcfg()
429 for (i = 0; i < cfg->num_inputs; i++) { in snd_hda_parse_pin_defcfg()
430 codec_info(codec, " %s=0x%x\n", in snd_hda_parse_pin_defcfg()
431 hda_get_autocfg_input_label(codec, cfg, i), in snd_hda_parse_pin_defcfg()
432 cfg->inputs[i].pin); in snd_hda_parse_pin_defcfg()
434 if (cfg->dig_in_pin) in snd_hda_parse_pin_defcfg()
435 codec_info(codec, " dig-in=0x%x\n", cfg->dig_in_pin); in snd_hda_parse_pin_defcfg()
442 * snd_hda_get_input_pin_attr - Get the input pin attribute from pin config
470 * hda_get_input_pin_label - Give a label for the given input pin
471 * @codec: the HDA codec
477 * for mic and line-in pins, and set an appropriate prefix like "Front",
480 static const char *hda_get_input_pin_label(struct hda_codec *codec, in hda_get_input_pin_label() argument
490 def_conf = snd_hda_codec_get_pincfg(codec, pin); in hda_get_input_pin_label()
494 if (item && item->is_headset_mic) in hda_get_input_pin_label()
496 if (item && item->is_headphone_mic) in hda_get_input_pin_label()
503 return mic_names[attr - 1]; in hda_get_input_pin_label()
529 * If all mic-jacks are in the same location (e.g. rear panel), we don't
532 static int check_mic_location_need(struct hda_codec *codec, in check_mic_location_need() argument
539 defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); in check_mic_location_need()
543 return 1; in check_mic_location_need()
546 for (i = 0; i < cfg->num_inputs; i++) { in check_mic_location_need()
547 defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); in check_mic_location_need()
551 return 1; /* different locations found */ in check_mic_location_need()
559 * hda_get_autocfg_input_label - Get a label for the given input
560 * @codec: the HDA codec
569 const char *hda_get_autocfg_input_label(struct hda_codec *codec, in hda_get_autocfg_input_label() argument
573 int type = cfg->inputs[input].type; in hda_get_autocfg_input_label()
576 if ((input > 0 && cfg->inputs[input - 1].type == type) || in hda_get_autocfg_input_label()
577 (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) in hda_get_autocfg_input_label()
578 has_multiple_pins = 1; in hda_get_autocfg_input_label()
580 has_multiple_pins &= check_mic_location_need(codec, cfg, input); in hda_get_autocfg_input_label()
581 has_multiple_pins |= codec->force_pin_prefix; in hda_get_autocfg_input_label()
582 return hda_get_input_pin_label(codec, &cfg->inputs[input], in hda_get_autocfg_input_label()
583 cfg->inputs[input].pin, in hda_get_autocfg_input_label()
588 /* return the position of NID in the list, or -1 if not found */
595 return -1; in find_idx_in_nid_list()
610 if (num_pins == 1) in check_output_sfx()
620 static const char *check_output_pfx(struct hda_codec *codec, hda_nid_t nid) in check_output_pfx() argument
622 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); in check_output_pfx()
635 static int get_hp_label_index(struct hda_codec *codec, hda_nid_t nid, in get_hp_label_index() argument
640 const char *pfx = check_output_pfx(codec, nid); in get_hp_label_index()
644 return -1; in get_hp_label_index()
646 if (pfx == check_output_pfx(codec, pins[j])) in get_hp_label_index()
652 static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, in fill_audio_out_name() argument
657 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); in fill_audio_out_name()
661 /* handle as a speaker if it's a fixed line-out */ in fill_audio_out_name()
664 pfx = check_output_pfx(codec, nid); in fill_audio_out_name()
668 sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, in fill_audio_out_name()
671 sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, in fill_audio_out_name()
675 int idx = get_hp_label_index(codec, nid, cfg->hp_pins, in fill_audio_out_name()
676 cfg->hp_outs); in fill_audio_out_name()
683 return 1; in fill_audio_out_name()
690 * snd_hda_get_pin_label - Get a label for the given I/O pin
691 * @codec: the HDA codec
699 * output pins. When @cfg is given as non-NULL, the function tries to get
703 * possible. For example, when the multiple line-outs are present, it adds
705 * If no unique name with a suffix is available and @indexp is non-NULL, the
708 int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, in snd_hda_get_pin_label() argument
712 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); in snd_hda_get_pin_label()
724 return fill_audio_out_name(codec, nid, cfg, "Line Out", in snd_hda_get_pin_label()
727 return fill_audio_out_name(codec, nid, cfg, "Speaker", in snd_hda_get_pin_label()
730 return fill_audio_out_name(codec, nid, cfg, "Headphone", in snd_hda_get_pin_label()
737 for (i = 0; i < cfg->dig_outs; i++) { in snd_hda_get_pin_label()
738 hda_nid_t pin = cfg->dig_out_pins[i]; in snd_hda_get_pin_label()
742 c = snd_hda_codec_get_pincfg(codec, pin); in snd_hda_get_pin_label()
749 for (i = 0; i < cfg->num_inputs; i++) { in snd_hda_get_pin_label()
750 if (cfg->inputs[i].pin != nid) in snd_hda_get_pin_label()
752 name = hda_get_autocfg_input_label(codec, cfg, i); in snd_hda_get_pin_label()
758 name = hda_get_input_pin_label(codec, NULL, nid, true); in snd_hda_get_pin_label()
764 return 1; in snd_hda_get_pin_label()
769 * snd_hda_add_verbs - Add verbs to the init list
770 * @codec: the HDA codec
771 * @list: zero-terminated verb list to add
776 int snd_hda_add_verbs(struct hda_codec *codec, in snd_hda_add_verbs() argument
780 v = snd_array_new(&codec->verbs); in snd_hda_add_verbs()
782 return -ENOMEM; in snd_hda_add_verbs()
789 * snd_hda_apply_verbs - Execute the init verb lists
790 * @codec: the HDA codec
792 void snd_hda_apply_verbs(struct hda_codec *codec) in snd_hda_apply_verbs() argument
797 snd_array_for_each(&codec->verbs, i, v) in snd_hda_apply_verbs()
798 snd_hda_sequence_write(codec, *v); in snd_hda_apply_verbs()
803 * snd_hda_apply_pincfgs - Set each pin config in the given list
804 * @codec: the HDA codec
805 * @cfg: NULL-terminated pin config table
807 void snd_hda_apply_pincfgs(struct hda_codec *codec, in snd_hda_apply_pincfgs() argument
810 for (; cfg->nid; cfg++) in snd_hda_apply_pincfgs()
811 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); in snd_hda_apply_pincfgs()
815 static void set_pin_targets(struct hda_codec *codec, in set_pin_targets() argument
818 for (; cfg->nid; cfg++) in set_pin_targets()
819 snd_hda_set_pin_ctl_cache(codec, cfg->nid, cfg->val); in set_pin_targets()
822 void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth) in __snd_hda_apply_fixup() argument
824 const char *modelname = codec->fixup_name; in __snd_hda_apply_fixup()
827 const struct hda_fixup *fix = codec->fixup_list + id; in __snd_hda_apply_fixup()
831 if (fix->chained_before) in __snd_hda_apply_fixup()
832 __snd_hda_apply_fixup(codec, fix->chain_id, action, depth + 1); in __snd_hda_apply_fixup()
834 switch (fix->type) { in __snd_hda_apply_fixup()
836 if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins) in __snd_hda_apply_fixup()
838 codec_dbg(codec, "%s: Apply pincfg for %s\n", in __snd_hda_apply_fixup()
839 codec->core.chip_name, modelname); in __snd_hda_apply_fixup()
840 snd_hda_apply_pincfgs(codec, fix->v.pins); in __snd_hda_apply_fixup()
843 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs) in __snd_hda_apply_fixup()
845 codec_dbg(codec, "%s: Apply fix-verbs for %s\n", in __snd_hda_apply_fixup()
846 codec->core.chip_name, modelname); in __snd_hda_apply_fixup()
847 snd_hda_add_verbs(codec, fix->v.verbs); in __snd_hda_apply_fixup()
850 if (!fix->v.func) in __snd_hda_apply_fixup()
852 codec_dbg(codec, "%s: Apply fix-func for %s\n", in __snd_hda_apply_fixup()
853 codec->core.chip_name, modelname); in __snd_hda_apply_fixup()
854 fix->v.func(codec, fix, action); in __snd_hda_apply_fixup()
857 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins) in __snd_hda_apply_fixup()
859 codec_dbg(codec, "%s: Apply pinctl for %s\n", in __snd_hda_apply_fixup()
860 codec->core.chip_name, modelname); in __snd_hda_apply_fixup()
861 set_pin_targets(codec, fix->v.pins); in __snd_hda_apply_fixup()
864 codec_err(codec, "%s: Invalid fixup type %d\n", in __snd_hda_apply_fixup()
865 codec->core.chip_name, fix->type); in __snd_hda_apply_fixup()
868 if (!fix->chained || fix->chained_before) in __snd_hda_apply_fixup()
870 id = fix->chain_id; in __snd_hda_apply_fixup()
876 * snd_hda_apply_fixup - Apply the fixup chain with the given action
877 * @codec: the HDA codec
880 void snd_hda_apply_fixup(struct hda_codec *codec, int action) in snd_hda_apply_fixup() argument
882 if (codec->fixup_list) in snd_hda_apply_fixup()
883 __snd_hda_apply_fixup(codec, codec->fixup_id, action, 0); in snd_hda_apply_fixup()
889 static bool pin_config_match(struct hda_codec *codec, in pin_config_match() argument
896 snd_array_for_each(&codec->init_pins, i, pin) { in pin_config_match()
897 hda_nid_t nid = pin->nid; in pin_config_match()
898 u32 cfg = pin->cfg; in pin_config_match()
904 for (; t_pins->nid; t_pins++) { in pin_config_match()
905 if (t_pins->nid == nid) { in pin_config_match()
906 found = 1; in pin_config_match()
907 if ((t_pins->val & IGNORE_SEQ_ASSOC) == (cfg & IGNORE_SEQ_ASSOC)) in pin_config_match()
909 else if ((cfg & 0xf0000000) == 0x40000000 && (t_pins->val & 0xf0000000) == 0x40000000) in pin_config_match()
924 * snd_hda_pick_pin_fixup - Pick up a fixup matching with the pin quirk list
925 * @codec: the HDA codec
926 * @pin_quirk: zero-terminated pin quirk list
930 void snd_hda_pick_pin_fixup(struct hda_codec *codec, in snd_hda_pick_pin_fixup() argument
937 if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET) in snd_hda_pick_pin_fixup()
940 for (pq = pin_quirk; pq->subvendor; pq++) { in snd_hda_pick_pin_fixup()
941 if ((codec->core.subsystem_id & 0xffff0000) != (pq->subvendor << 16)) in snd_hda_pick_pin_fixup()
943 if (codec->core.vendor_id != pq->codec) in snd_hda_pick_pin_fixup()
945 if (pin_config_match(codec, pq->pins, match_all_pins)) { in snd_hda_pick_pin_fixup()
946 codec->fixup_id = pq->value; in snd_hda_pick_pin_fixup()
948 codec->fixup_name = pq->name; in snd_hda_pick_pin_fixup()
949 codec_dbg(codec, "%s: picked fixup %s (pin match)\n", in snd_hda_pick_pin_fixup()
950 codec->core.chip_name, codec->fixup_name); in snd_hda_pick_pin_fixup()
952 codec->fixup_list = fixlist; in snd_hda_pick_pin_fixup()
960 * snd_hda_pick_fixup - Pick up a fixup matching with PCI/codec SSID or model string
961 * @codec: the HDA codec
962 * @models: NULL-terminated model string list
963 * @quirk: zero-terminated PCI/codec SSID quirk list
974 * If still nothing matched, try to look up the codec SSID.
976 void snd_hda_pick_fixup(struct hda_codec *codec, in snd_hda_pick_fixup() argument
987 if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET) in snd_hda_pick_fixup()
991 if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { in snd_hda_pick_fixup()
994 codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n", in snd_hda_pick_fixup()
995 codec->core.chip_name); in snd_hda_pick_fixup()
1000 if (codec->modelname && models) { in snd_hda_pick_fixup()
1001 while (models->name) { in snd_hda_pick_fixup()
1002 if (!strcmp(codec->modelname, models->name)) { in snd_hda_pick_fixup()
1003 id = models->id; in snd_hda_pick_fixup()
1004 name = models->name; in snd_hda_pick_fixup()
1005 codec_dbg(codec, "%s: picked fixup %s (model specified)\n", in snd_hda_pick_fixup()
1006 codec->core.chip_name, codec->fixup_name); in snd_hda_pick_fixup()
1017 if (codec->modelname && in snd_hda_pick_fixup()
1018 sscanf(codec->modelname, "%04x:%04x", &vendor, &device) == 2) { in snd_hda_pick_fixup()
1027 q = snd_pci_quirk_lookup(codec->bus->pci, quirk); in snd_hda_pick_fixup()
1033 /* match with the codec SSID */ in snd_hda_pick_fixup()
1034 q = snd_pci_quirk_lookup_id(codec->core.subsystem_id >> 16, in snd_hda_pick_fixup()
1035 codec->core.subsystem_id & 0xffff, in snd_hda_pick_fixup()
1038 type = "codec SSID"; in snd_hda_pick_fixup()
1045 id = q->value; in snd_hda_pick_fixup()
1047 name = q->name; in snd_hda_pick_fixup()
1049 codec_dbg(codec, "%s: picked fixup %s for %s %04x:%04x\n", in snd_hda_pick_fixup()
1050 codec->core.chip_name, name ? name : "", in snd_hda_pick_fixup()
1051 type, q->subvendor, q->subdevice); in snd_hda_pick_fixup()
1053 codec->fixup_id = id; in snd_hda_pick_fixup()
1054 codec->fixup_list = fixlist; in snd_hda_pick_fixup()
1055 codec->fixup_name = name; in snd_hda_pick_fixup()