Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1 | /* |
| 2 | * BIOS auto-parser helper functions for HD-audio |
| 3 | * |
| 4 | * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de> |
| 5 | * |
| 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. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/slab.h> |
| 13 | #include <linux/export.h> |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 14 | #include <linux/sort.h> |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 15 | #include <sound/core.h> |
| 16 | #include "hda_codec.h" |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 17 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 18 | #include "hda_auto_parser.h" |
| 19 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 20 | /* |
| 21 | * Helper for automatic pin configuration |
| 22 | */ |
| 23 | |
| 24 | static int is_in_nid_list(hda_nid_t nid, const hda_nid_t *list) |
| 25 | { |
| 26 | for (; *list; list++) |
| 27 | if (*list == nid) |
| 28 | return 1; |
| 29 | return 0; |
| 30 | } |
| 31 | |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 32 | /* a pair of input pin and its sequence */ |
| 33 | struct auto_out_pin { |
| 34 | hda_nid_t pin; |
| 35 | short seq; |
| 36 | }; |
| 37 | |
| 38 | static int compare_seq(const void *ap, const void *bp) |
| 39 | { |
| 40 | const struct auto_out_pin *a = ap; |
| 41 | const struct auto_out_pin *b = bp; |
| 42 | return (int)(a->seq - b->seq); |
| 43 | } |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 44 | |
| 45 | /* |
| 46 | * Sort an associated group of pins according to their sequence numbers. |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 47 | * then store it to a pin array. |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 48 | */ |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 49 | static void sort_pins_by_sequence(hda_nid_t *pins, struct auto_out_pin *list, |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 50 | int num_pins) |
| 51 | { |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 52 | int i; |
| 53 | sort(list, num_pins, sizeof(list[0]), compare_seq, NULL); |
| 54 | for (i = 0; i < num_pins; i++) |
| 55 | pins[i] = list[i].pin; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | |
| 59 | /* add the found input-pin to the cfg->inputs[] table */ |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 60 | static void add_auto_cfg_input_pin(struct hda_codec *codec, struct auto_pin_cfg *cfg, |
| 61 | hda_nid_t nid, int type) |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 62 | { |
| 63 | if (cfg->num_inputs < AUTO_CFG_MAX_INS) { |
| 64 | cfg->inputs[cfg->num_inputs].pin = nid; |
| 65 | cfg->inputs[cfg->num_inputs].type = type; |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 66 | cfg->inputs[cfg->num_inputs].has_boost_on_pin = |
| 67 | nid_has_volume(codec, nid, HDA_INPUT); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 68 | cfg->num_inputs++; |
| 69 | } |
| 70 | } |
| 71 | |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 72 | static int compare_input_type(const void *ap, const void *bp) |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 73 | { |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 74 | const struct auto_pin_cfg_item *a = ap; |
| 75 | const struct auto_pin_cfg_item *b = bp; |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 76 | if (a->type != b->type) |
| 77 | return (int)(a->type - b->type); |
| 78 | |
| 79 | /* In case one has boost and the other one has not, |
| 80 | pick the one with boost first. */ |
| 81 | return (int)(b->has_boost_on_pin - a->has_boost_on_pin); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | /* Reorder the surround channels |
| 85 | * ALSA sequence is front/surr/clfe/side |
| 86 | * HDA sequence is: |
| 87 | * 4-ch: front/surr => OK as it is |
| 88 | * 6-ch: front/clfe/surr |
| 89 | * 8-ch: front/clfe/rear/side|fc |
| 90 | */ |
| 91 | static void reorder_outputs(unsigned int nums, hda_nid_t *pins) |
| 92 | { |
| 93 | hda_nid_t nid; |
| 94 | |
| 95 | switch (nums) { |
| 96 | case 3: |
| 97 | case 4: |
| 98 | nid = pins[1]; |
| 99 | pins[1] = pins[2]; |
| 100 | pins[2] = nid; |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | |
Takashi Iwai | 52fd5cb | 2013-01-15 08:45:33 +0100 | [diff] [blame] | 105 | /* check whether the given pin has a proper pin I/O capability bit */ |
| 106 | static bool check_pincap_validity(struct hda_codec *codec, hda_nid_t pin, |
| 107 | unsigned int dev) |
| 108 | { |
| 109 | unsigned int pincap = snd_hda_query_pin_caps(codec, pin); |
| 110 | |
| 111 | /* some old hardware don't return the proper pincaps */ |
| 112 | if (!pincap) |
| 113 | return true; |
| 114 | |
| 115 | switch (dev) { |
| 116 | case AC_JACK_LINE_OUT: |
| 117 | case AC_JACK_SPEAKER: |
| 118 | case AC_JACK_HP_OUT: |
| 119 | case AC_JACK_SPDIF_OUT: |
| 120 | case AC_JACK_DIG_OTHER_OUT: |
| 121 | return !!(pincap & AC_PINCAP_OUT); |
| 122 | default: |
| 123 | return !!(pincap & AC_PINCAP_IN); |
| 124 | } |
| 125 | } |
| 126 | |
David Henningsson | cb420b1 | 2013-04-11 11:30:28 +0200 | [diff] [blame] | 127 | static bool can_be_headset_mic(struct hda_codec *codec, |
| 128 | struct auto_pin_cfg_item *item, |
| 129 | int seq_number) |
| 130 | { |
| 131 | int attr; |
| 132 | unsigned int def_conf; |
| 133 | if (item->type != AUTO_PIN_MIC) |
| 134 | return false; |
| 135 | |
| 136 | if (item->is_headset_mic || item->is_headphone_mic) |
| 137 | return false; /* Already assigned */ |
| 138 | |
| 139 | def_conf = snd_hda_codec_get_pincfg(codec, item->pin); |
| 140 | attr = snd_hda_get_input_pin_attr(def_conf); |
| 141 | if (attr <= INPUT_PIN_ATTR_DOCK) |
| 142 | return false; |
| 143 | |
| 144 | if (seq_number >= 0) { |
| 145 | int seq = get_defcfg_sequence(def_conf); |
| 146 | if (seq != seq_number) |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | return true; |
| 151 | } |
| 152 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 153 | /* |
| 154 | * Parse all pin widgets and store the useful pin nids to cfg |
| 155 | * |
| 156 | * The number of line-outs or any primary output is stored in line_outs, |
| 157 | * and the corresponding output pins are assigned to line_out_pins[], |
| 158 | * in the order of front, rear, CLFE, side, ... |
| 159 | * |
| 160 | * If more extra outputs (speaker and headphone) are found, the pins are |
| 161 | * assisnged to hp_pins[] and speaker_pins[], respectively. If no line-out jack |
| 162 | * is detected, one of speaker of HP pins is assigned as the primary |
| 163 | * output, i.e. to line_out_pins[0]. So, line_outs is always positive |
| 164 | * if any analog output exists. |
| 165 | * |
| 166 | * The analog input pins are assigned to inputs array. |
| 167 | * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, |
| 168 | * respectively. |
| 169 | */ |
| 170 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, |
| 171 | struct auto_pin_cfg *cfg, |
| 172 | const hda_nid_t *ignore_nids, |
| 173 | unsigned int cond_flags) |
| 174 | { |
| 175 | hda_nid_t nid, end_nid; |
| 176 | short seq, assoc_line_out; |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 177 | struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)]; |
| 178 | struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)]; |
| 179 | struct auto_out_pin hp_out[ARRAY_SIZE(cfg->hp_pins)]; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 180 | int i; |
| 181 | |
Takashi Iwai | 1c70a58 | 2013-01-11 17:48:22 +0100 | [diff] [blame] | 182 | if (!snd_hda_get_int_hint(codec, "parser_flags", &i)) |
| 183 | cond_flags = i; |
| 184 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 185 | memset(cfg, 0, sizeof(*cfg)); |
| 186 | |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 187 | memset(line_out, 0, sizeof(line_out)); |
| 188 | memset(speaker_out, 0, sizeof(speaker_out)); |
| 189 | memset(hp_out, 0, sizeof(hp_out)); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 190 | assoc_line_out = 0; |
| 191 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 192 | end_nid = codec->start_nid + codec->num_nodes; |
| 193 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 194 | unsigned int wid_caps = get_wcaps(codec, nid); |
| 195 | unsigned int wid_type = get_wcaps_type(wid_caps); |
| 196 | unsigned int def_conf; |
| 197 | short assoc, loc, conn, dev; |
| 198 | |
| 199 | /* read all default configuration for pin complex */ |
| 200 | if (wid_type != AC_WID_PIN) |
| 201 | continue; |
| 202 | /* ignore the given nids (e.g. pc-beep returns error) */ |
| 203 | if (ignore_nids && is_in_nid_list(nid, ignore_nids)) |
| 204 | continue; |
| 205 | |
| 206 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 207 | conn = get_defcfg_connect(def_conf); |
| 208 | if (conn == AC_JACK_PORT_NONE) |
| 209 | continue; |
| 210 | loc = get_defcfg_location(def_conf); |
| 211 | dev = get_defcfg_device(def_conf); |
| 212 | |
| 213 | /* workaround for buggy BIOS setups */ |
| 214 | if (dev == AC_JACK_LINE_OUT) { |
Takashi Iwai | fb690cf | 2013-01-07 18:21:47 +0100 | [diff] [blame] | 215 | if (conn == AC_JACK_PORT_FIXED || |
| 216 | conn == AC_JACK_PORT_BOTH) |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 217 | dev = AC_JACK_SPEAKER; |
| 218 | } |
| 219 | |
Takashi Iwai | 52fd5cb | 2013-01-15 08:45:33 +0100 | [diff] [blame] | 220 | if (!check_pincap_validity(codec, nid, dev)) |
| 221 | continue; |
| 222 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 223 | switch (dev) { |
| 224 | case AC_JACK_LINE_OUT: |
| 225 | seq = get_defcfg_sequence(def_conf); |
| 226 | assoc = get_defcfg_association(def_conf); |
| 227 | |
| 228 | if (!(wid_caps & AC_WCAP_STEREO)) |
| 229 | if (!cfg->mono_out_pin) |
| 230 | cfg->mono_out_pin = nid; |
| 231 | if (!assoc) |
| 232 | continue; |
| 233 | if (!assoc_line_out) |
| 234 | assoc_line_out = assoc; |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 235 | else if (assoc_line_out != assoc) { |
| 236 | codec_info(codec, |
| 237 | "ignore pin 0x%x with mismatching assoc# 0x%x vs 0x%x\n", |
| 238 | nid, assoc, assoc_line_out); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 239 | continue; |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 240 | } |
| 241 | if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) { |
| 242 | codec_info(codec, |
| 243 | "ignore pin 0x%x, too many assigned pins\n", |
| 244 | nid); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 245 | continue; |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 246 | } |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 247 | line_out[cfg->line_outs].pin = nid; |
| 248 | line_out[cfg->line_outs].seq = seq; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 249 | cfg->line_outs++; |
| 250 | break; |
| 251 | case AC_JACK_SPEAKER: |
| 252 | seq = get_defcfg_sequence(def_conf); |
| 253 | assoc = get_defcfg_association(def_conf); |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 254 | if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) { |
| 255 | codec_info(codec, |
| 256 | "ignore pin 0x%x, too many assigned pins\n", |
| 257 | nid); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 258 | continue; |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 259 | } |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 260 | speaker_out[cfg->speaker_outs].pin = nid; |
| 261 | speaker_out[cfg->speaker_outs].seq = (assoc << 4) | seq; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 262 | cfg->speaker_outs++; |
| 263 | break; |
| 264 | case AC_JACK_HP_OUT: |
| 265 | seq = get_defcfg_sequence(def_conf); |
| 266 | assoc = get_defcfg_association(def_conf); |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 267 | if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) { |
| 268 | codec_info(codec, |
| 269 | "ignore pin 0x%x, too many assigned pins\n", |
| 270 | nid); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 271 | continue; |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 272 | } |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 273 | hp_out[cfg->hp_outs].pin = nid; |
| 274 | hp_out[cfg->hp_outs].seq = (assoc << 4) | seq; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 275 | cfg->hp_outs++; |
| 276 | break; |
| 277 | case AC_JACK_MIC_IN: |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 278 | add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_MIC); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 279 | break; |
| 280 | case AC_JACK_LINE_IN: |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 281 | add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_LINE_IN); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 282 | break; |
| 283 | case AC_JACK_CD: |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 284 | add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_CD); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 285 | break; |
| 286 | case AC_JACK_AUX: |
David Henningsson | 95f72cf | 2014-09-23 10:38:18 +0200 | [diff] [blame] | 287 | add_auto_cfg_input_pin(codec, cfg, nid, AUTO_PIN_AUX); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 288 | break; |
| 289 | case AC_JACK_SPDIF_OUT: |
| 290 | case AC_JACK_DIG_OTHER_OUT: |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 291 | if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) { |
| 292 | codec_info(codec, |
| 293 | "ignore pin 0x%x, too many assigned pins\n", |
| 294 | nid); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 295 | continue; |
Takashi Iwai | 9b7564a | 2014-03-25 10:02:01 +0100 | [diff] [blame] | 296 | } |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 297 | cfg->dig_out_pins[cfg->dig_outs] = nid; |
| 298 | cfg->dig_out_type[cfg->dig_outs] = |
| 299 | (loc == AC_JACK_LOC_HDMI) ? |
| 300 | HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF; |
| 301 | cfg->dig_outs++; |
| 302 | break; |
| 303 | case AC_JACK_SPDIF_IN: |
| 304 | case AC_JACK_DIG_OTHER_IN: |
| 305 | cfg->dig_in_pin = nid; |
| 306 | if (loc == AC_JACK_LOC_HDMI) |
| 307 | cfg->dig_in_type = HDA_PCM_TYPE_HDMI; |
| 308 | else |
| 309 | cfg->dig_in_type = HDA_PCM_TYPE_SPDIF; |
| 310 | break; |
| 311 | } |
| 312 | } |
| 313 | |
David Henningsson | cb420b1 | 2013-04-11 11:30:28 +0200 | [diff] [blame] | 314 | /* Find a pin that could be a headset or headphone mic */ |
| 315 | if (cond_flags & HDA_PINCFG_HEADSET_MIC || cond_flags & HDA_PINCFG_HEADPHONE_MIC) { |
| 316 | bool hsmic = !!(cond_flags & HDA_PINCFG_HEADSET_MIC); |
| 317 | bool hpmic = !!(cond_flags & HDA_PINCFG_HEADPHONE_MIC); |
| 318 | for (i = 0; (hsmic || hpmic) && (i < cfg->num_inputs); i++) |
| 319 | if (hsmic && can_be_headset_mic(codec, &cfg->inputs[i], 0xc)) { |
| 320 | cfg->inputs[i].is_headset_mic = 1; |
| 321 | hsmic = false; |
| 322 | } else if (hpmic && can_be_headset_mic(codec, &cfg->inputs[i], 0xd)) { |
| 323 | cfg->inputs[i].is_headphone_mic = 1; |
| 324 | hpmic = false; |
| 325 | } |
| 326 | |
| 327 | /* If we didn't find our sequence number mark, fall back to any sequence number */ |
| 328 | for (i = 0; (hsmic || hpmic) && (i < cfg->num_inputs); i++) { |
| 329 | if (!can_be_headset_mic(codec, &cfg->inputs[i], -1)) |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 330 | continue; |
David Henningsson | cb420b1 | 2013-04-11 11:30:28 +0200 | [diff] [blame] | 331 | if (hsmic) { |
| 332 | cfg->inputs[i].is_headset_mic = 1; |
| 333 | hsmic = false; |
| 334 | } else if (hpmic) { |
| 335 | cfg->inputs[i].is_headphone_mic = 1; |
| 336 | hpmic = false; |
| 337 | } |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 338 | } |
David Henningsson | cb420b1 | 2013-04-11 11:30:28 +0200 | [diff] [blame] | 339 | |
| 340 | if (hsmic) |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 341 | codec_dbg(codec, "Told to look for a headset mic, but didn't find any.\n"); |
David Henningsson | cb420b1 | 2013-04-11 11:30:28 +0200 | [diff] [blame] | 342 | if (hpmic) |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 343 | codec_dbg(codec, "Told to look for a headphone mic, but didn't find any.\n"); |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 344 | } |
| 345 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 346 | /* FIX-UP: |
| 347 | * If no line-out is defined but multiple HPs are found, |
| 348 | * some of them might be the real line-outs. |
| 349 | */ |
| 350 | if (!cfg->line_outs && cfg->hp_outs > 1 && |
| 351 | !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) { |
| 352 | int i = 0; |
| 353 | while (i < cfg->hp_outs) { |
| 354 | /* The real HPs should have the sequence 0x0f */ |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 355 | if ((hp_out[i].seq & 0x0f) == 0x0f) { |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 356 | i++; |
| 357 | continue; |
| 358 | } |
| 359 | /* Move it to the line-out table */ |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 360 | line_out[cfg->line_outs++] = hp_out[i]; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 361 | cfg->hp_outs--; |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 362 | memmove(hp_out + i, hp_out + i + 1, |
| 363 | sizeof(hp_out[0]) * (cfg->hp_outs - i)); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 364 | } |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 365 | memset(hp_out + cfg->hp_outs, 0, |
| 366 | sizeof(hp_out[0]) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs)); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 367 | if (!cfg->hp_outs) |
| 368 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 369 | |
| 370 | } |
| 371 | |
| 372 | /* sort by sequence */ |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 373 | sort_pins_by_sequence(cfg->line_out_pins, line_out, cfg->line_outs); |
| 374 | sort_pins_by_sequence(cfg->speaker_pins, speaker_out, |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 375 | cfg->speaker_outs); |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 376 | sort_pins_by_sequence(cfg->hp_pins, hp_out, cfg->hp_outs); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 377 | |
| 378 | /* |
| 379 | * FIX-UP: if no line-outs are detected, try to use speaker or HP pin |
| 380 | * as a primary output |
| 381 | */ |
| 382 | if (!cfg->line_outs && |
| 383 | !(cond_flags & HDA_PINCFG_NO_LO_FIXUP)) { |
| 384 | if (cfg->speaker_outs) { |
| 385 | cfg->line_outs = cfg->speaker_outs; |
| 386 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 387 | sizeof(cfg->speaker_pins)); |
| 388 | cfg->speaker_outs = 0; |
| 389 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 390 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
| 391 | } else if (cfg->hp_outs) { |
| 392 | cfg->line_outs = cfg->hp_outs; |
| 393 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 394 | sizeof(cfg->hp_pins)); |
| 395 | cfg->hp_outs = 0; |
| 396 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 397 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | reorder_outputs(cfg->line_outs, cfg->line_out_pins); |
| 402 | reorder_outputs(cfg->hp_outs, cfg->hp_pins); |
| 403 | reorder_outputs(cfg->speaker_outs, cfg->speaker_pins); |
| 404 | |
Takashi Iwai | b9030a0 | 2012-11-29 10:18:57 +0100 | [diff] [blame] | 405 | /* sort inputs in the order of AUTO_PIN_* type */ |
| 406 | sort(cfg->inputs, cfg->num_inputs, sizeof(cfg->inputs[0]), |
| 407 | compare_input_type, NULL); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 408 | |
| 409 | /* |
| 410 | * debug prints of the parsed results |
| 411 | */ |
David Henningsson | 322b8af1 | 2015-01-07 14:41:58 +0100 | [diff] [blame] | 412 | codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", |
| 413 | codec->chip_name, cfg->line_outs, cfg->line_out_pins[0], |
| 414 | cfg->line_out_pins[1], cfg->line_out_pins[2], |
| 415 | cfg->line_out_pins[3], cfg->line_out_pins[4], |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 416 | cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : |
| 417 | (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ? |
| 418 | "speaker" : "line")); |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 419 | codec_info(codec, " speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 420 | cfg->speaker_outs, cfg->speaker_pins[0], |
| 421 | cfg->speaker_pins[1], cfg->speaker_pins[2], |
| 422 | cfg->speaker_pins[3], cfg->speaker_pins[4]); |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 423 | codec_info(codec, " hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 424 | cfg->hp_outs, cfg->hp_pins[0], |
| 425 | cfg->hp_pins[1], cfg->hp_pins[2], |
| 426 | cfg->hp_pins[3], cfg->hp_pins[4]); |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 427 | codec_info(codec, " mono: mono_out=0x%x\n", cfg->mono_out_pin); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 428 | if (cfg->dig_outs) |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 429 | codec_info(codec, " dig-out=0x%x/0x%x\n", |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 430 | cfg->dig_out_pins[0], cfg->dig_out_pins[1]); |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 431 | codec_info(codec, " inputs:\n"); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 432 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 433 | codec_info(codec, " %s=0x%x\n", |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 434 | hda_get_autocfg_input_label(codec, cfg, i), |
| 435 | cfg->inputs[i].pin); |
| 436 | } |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 437 | if (cfg->dig_in_pin) |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 438 | codec_info(codec, " dig-in=0x%x\n", cfg->dig_in_pin); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 439 | |
| 440 | return 0; |
| 441 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 442 | EXPORT_SYMBOL_GPL(snd_hda_parse_pin_defcfg); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 443 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 444 | /** |
| 445 | * snd_hda_get_input_pin_attr - Get the input pin attribute from pin config |
| 446 | * @def_conf: pin configuration value |
| 447 | * |
| 448 | * Guess the input pin attribute (INPUT_PIN_ATTR_XXX) from the given |
| 449 | * default pin configuration value. |
| 450 | */ |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 451 | int snd_hda_get_input_pin_attr(unsigned int def_conf) |
| 452 | { |
| 453 | unsigned int loc = get_defcfg_location(def_conf); |
| 454 | unsigned int conn = get_defcfg_connect(def_conf); |
| 455 | if (conn == AC_JACK_PORT_NONE) |
| 456 | return INPUT_PIN_ATTR_UNUSED; |
| 457 | /* Windows may claim the internal mic to be BOTH, too */ |
| 458 | if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) |
| 459 | return INPUT_PIN_ATTR_INT; |
| 460 | if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) |
| 461 | return INPUT_PIN_ATTR_INT; |
| 462 | if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) |
| 463 | return INPUT_PIN_ATTR_DOCK; |
| 464 | if (loc == AC_JACK_LOC_REAR) |
| 465 | return INPUT_PIN_ATTR_REAR; |
| 466 | if (loc == AC_JACK_LOC_FRONT) |
| 467 | return INPUT_PIN_ATTR_FRONT; |
| 468 | return INPUT_PIN_ATTR_NORMAL; |
| 469 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 470 | EXPORT_SYMBOL_GPL(snd_hda_get_input_pin_attr); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 471 | |
| 472 | /** |
| 473 | * hda_get_input_pin_label - Give a label for the given input pin |
Takashi Iwai | a11e9b1 | 2014-10-29 15:06:01 +0100 | [diff] [blame] | 474 | * @codec: the HDA codec |
| 475 | * @item: ping config item to refer |
| 476 | * @pin: the pin NID |
| 477 | * @check_location: flag to add the jack location prefix |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 478 | * |
Takashi Iwai | a11e9b1 | 2014-10-29 15:06:01 +0100 | [diff] [blame] | 479 | * When @check_location is true, the function checks the pin location |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 480 | * for mic and line-in pins, and set an appropriate prefix like "Front", |
| 481 | * "Rear", "Internal". |
| 482 | */ |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 483 | static const char *hda_get_input_pin_label(struct hda_codec *codec, |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 484 | const struct auto_pin_cfg_item *item, |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 485 | hda_nid_t pin, bool check_location) |
| 486 | { |
| 487 | unsigned int def_conf; |
| 488 | static const char * const mic_names[] = { |
Takashi Iwai | 5ec16d1 | 2012-11-28 18:11:59 +0100 | [diff] [blame] | 489 | "Internal Mic", "Dock Mic", "Mic", "Rear Mic", "Front Mic" |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 490 | }; |
| 491 | int attr; |
| 492 | |
| 493 | def_conf = snd_hda_codec_get_pincfg(codec, pin); |
| 494 | |
| 495 | switch (get_defcfg_device(def_conf)) { |
| 496 | case AC_JACK_MIC_IN: |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 497 | if (item && item->is_headset_mic) |
| 498 | return "Headset Mic"; |
David Henningsson | cb420b1 | 2013-04-11 11:30:28 +0200 | [diff] [blame] | 499 | if (item && item->is_headphone_mic) |
| 500 | return "Headphone Mic"; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 501 | if (!check_location) |
| 502 | return "Mic"; |
| 503 | attr = snd_hda_get_input_pin_attr(def_conf); |
| 504 | if (!attr) |
| 505 | return "None"; |
| 506 | return mic_names[attr - 1]; |
| 507 | case AC_JACK_LINE_IN: |
| 508 | if (!check_location) |
| 509 | return "Line"; |
| 510 | attr = snd_hda_get_input_pin_attr(def_conf); |
| 511 | if (!attr) |
| 512 | return "None"; |
| 513 | if (attr == INPUT_PIN_ATTR_DOCK) |
| 514 | return "Dock Line"; |
| 515 | return "Line"; |
| 516 | case AC_JACK_AUX: |
| 517 | return "Aux"; |
| 518 | case AC_JACK_CD: |
| 519 | return "CD"; |
| 520 | case AC_JACK_SPDIF_IN: |
| 521 | return "SPDIF In"; |
| 522 | case AC_JACK_DIG_OTHER_IN: |
| 523 | return "Digital In"; |
Takashi Iwai | 54d778b | 2013-01-09 08:46:34 +0100 | [diff] [blame] | 524 | case AC_JACK_HP_OUT: |
| 525 | return "Headphone Mic"; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 526 | default: |
| 527 | return "Misc"; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | /* Check whether the location prefix needs to be added to the label. |
| 532 | * If all mic-jacks are in the same location (e.g. rear panel), we don't |
| 533 | * have to put "Front" prefix to each label. In such a case, returns false. |
| 534 | */ |
| 535 | static int check_mic_location_need(struct hda_codec *codec, |
| 536 | const struct auto_pin_cfg *cfg, |
| 537 | int input) |
| 538 | { |
| 539 | unsigned int defc; |
| 540 | int i, attr, attr2; |
| 541 | |
| 542 | defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); |
| 543 | attr = snd_hda_get_input_pin_attr(defc); |
| 544 | /* for internal or docking mics, we need locations */ |
| 545 | if (attr <= INPUT_PIN_ATTR_NORMAL) |
| 546 | return 1; |
| 547 | |
| 548 | attr = 0; |
| 549 | for (i = 0; i < cfg->num_inputs; i++) { |
| 550 | defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); |
| 551 | attr2 = snd_hda_get_input_pin_attr(defc); |
| 552 | if (attr2 >= INPUT_PIN_ATTR_NORMAL) { |
| 553 | if (attr && attr != attr2) |
| 554 | return 1; /* different locations found */ |
| 555 | attr = attr2; |
| 556 | } |
| 557 | } |
| 558 | return 0; |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * hda_get_autocfg_input_label - Get a label for the given input |
Takashi Iwai | a11e9b1 | 2014-10-29 15:06:01 +0100 | [diff] [blame] | 563 | * @codec: the HDA codec |
| 564 | * @cfg: the parsed pin configuration |
| 565 | * @input: the input index number |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 566 | * |
| 567 | * Get a label for the given input pin defined by the autocfg item. |
| 568 | * Unlike hda_get_input_pin_label(), this function checks all inputs |
| 569 | * defined in autocfg and avoids the redundant mic/line prefix as much as |
| 570 | * possible. |
| 571 | */ |
| 572 | const char *hda_get_autocfg_input_label(struct hda_codec *codec, |
| 573 | const struct auto_pin_cfg *cfg, |
| 574 | int input) |
| 575 | { |
| 576 | int type = cfg->inputs[input].type; |
| 577 | int has_multiple_pins = 0; |
| 578 | |
| 579 | if ((input > 0 && cfg->inputs[input - 1].type == type) || |
| 580 | (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) |
| 581 | has_multiple_pins = 1; |
| 582 | if (has_multiple_pins && type == AUTO_PIN_MIC) |
| 583 | has_multiple_pins &= check_mic_location_need(codec, cfg, input); |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 584 | return hda_get_input_pin_label(codec, &cfg->inputs[input], |
| 585 | cfg->inputs[input].pin, |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 586 | has_multiple_pins); |
| 587 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 588 | EXPORT_SYMBOL_GPL(hda_get_autocfg_input_label); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 589 | |
| 590 | /* return the position of NID in the list, or -1 if not found */ |
| 591 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 592 | { |
| 593 | int i; |
| 594 | for (i = 0; i < nums; i++) |
| 595 | if (list[i] == nid) |
| 596 | return i; |
| 597 | return -1; |
| 598 | } |
| 599 | |
| 600 | /* get a unique suffix or an index number */ |
| 601 | static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, |
| 602 | int num_pins, int *indexp) |
| 603 | { |
| 604 | static const char * const channel_sfx[] = { |
| 605 | " Front", " Surround", " CLFE", " Side" |
| 606 | }; |
| 607 | int i; |
| 608 | |
| 609 | i = find_idx_in_nid_list(nid, pins, num_pins); |
| 610 | if (i < 0) |
| 611 | return NULL; |
| 612 | if (num_pins == 1) |
| 613 | return ""; |
| 614 | if (num_pins > ARRAY_SIZE(channel_sfx)) { |
| 615 | if (indexp) |
| 616 | *indexp = i; |
| 617 | return ""; |
| 618 | } |
| 619 | return channel_sfx[i]; |
| 620 | } |
| 621 | |
David Henningsson | eee3ed4 | 2012-10-03 11:12:53 +0200 | [diff] [blame] | 622 | static const char *check_output_pfx(struct hda_codec *codec, hda_nid_t nid) |
| 623 | { |
| 624 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 625 | int attr = snd_hda_get_input_pin_attr(def_conf); |
| 626 | |
| 627 | /* check the location */ |
| 628 | switch (attr) { |
| 629 | case INPUT_PIN_ATTR_DOCK: |
| 630 | return "Dock "; |
| 631 | case INPUT_PIN_ATTR_FRONT: |
| 632 | return "Front "; |
| 633 | } |
| 634 | return ""; |
| 635 | } |
| 636 | |
| 637 | static int get_hp_label_index(struct hda_codec *codec, hda_nid_t nid, |
| 638 | const hda_nid_t *pins, int num_pins) |
| 639 | { |
| 640 | int i, j, idx = 0; |
| 641 | |
| 642 | const char *pfx = check_output_pfx(codec, nid); |
| 643 | |
| 644 | i = find_idx_in_nid_list(nid, pins, num_pins); |
| 645 | if (i < 0) |
| 646 | return -1; |
| 647 | for (j = 0; j < i; j++) |
| 648 | if (pfx == check_output_pfx(codec, pins[j])) |
| 649 | idx++; |
| 650 | |
| 651 | return idx; |
| 652 | } |
| 653 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 654 | static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, |
| 655 | const struct auto_pin_cfg *cfg, |
| 656 | const char *name, char *label, int maxlen, |
| 657 | int *indexp) |
| 658 | { |
| 659 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 660 | int attr = snd_hda_get_input_pin_attr(def_conf); |
David Henningsson | eee3ed4 | 2012-10-03 11:12:53 +0200 | [diff] [blame] | 661 | const char *pfx, *sfx = ""; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 662 | |
| 663 | /* handle as a speaker if it's a fixed line-out */ |
| 664 | if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT) |
| 665 | name = "Speaker"; |
David Henningsson | eee3ed4 | 2012-10-03 11:12:53 +0200 | [diff] [blame] | 666 | pfx = check_output_pfx(codec, nid); |
| 667 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 668 | if (cfg) { |
| 669 | /* try to give a unique suffix if needed */ |
| 670 | sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, |
| 671 | indexp); |
| 672 | if (!sfx) |
| 673 | sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, |
| 674 | indexp); |
| 675 | if (!sfx) { |
| 676 | /* don't add channel suffix for Headphone controls */ |
David Henningsson | eee3ed4 | 2012-10-03 11:12:53 +0200 | [diff] [blame] | 677 | int idx = get_hp_label_index(codec, nid, cfg->hp_pins, |
| 678 | cfg->hp_outs); |
Takashi Iwai | 728deec | 2013-10-28 11:39:23 +0100 | [diff] [blame] | 679 | if (idx >= 0 && indexp) |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 680 | *indexp = idx; |
| 681 | sfx = ""; |
| 682 | } |
| 683 | } |
| 684 | snprintf(label, maxlen, "%s%s%s", pfx, name, sfx); |
| 685 | return 1; |
| 686 | } |
| 687 | |
David Henningsson | 3f25dcf | 2013-01-18 15:43:03 +0100 | [diff] [blame] | 688 | #define is_hdmi_cfg(conf) \ |
| 689 | (get_defcfg_location(conf) == AC_JACK_LOC_HDMI) |
| 690 | |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 691 | /** |
| 692 | * snd_hda_get_pin_label - Get a label for the given I/O pin |
Takashi Iwai | a11e9b1 | 2014-10-29 15:06:01 +0100 | [diff] [blame] | 693 | * @codec: the HDA codec |
| 694 | * @nid: pin NID |
| 695 | * @cfg: the parsed pin configuration |
| 696 | * @label: the string buffer to store |
| 697 | * @maxlen: the max length of string buffer (including termination) |
| 698 | * @indexp: the pointer to return the index number (for multiple ctls) |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 699 | * |
| 700 | * Get a label for the given pin. This function works for both input and |
| 701 | * output pins. When @cfg is given as non-NULL, the function tries to get |
| 702 | * an optimized label using hda_get_autocfg_input_label(). |
| 703 | * |
| 704 | * This function tries to give a unique label string for the pin as much as |
| 705 | * possible. For example, when the multiple line-outs are present, it adds |
| 706 | * the channel suffix like "Front", "Surround", etc (only when @cfg is given). |
| 707 | * If no unique name with a suffix is available and @indexp is non-NULL, the |
| 708 | * index number is stored in the pointer. |
| 709 | */ |
| 710 | int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, |
| 711 | const struct auto_pin_cfg *cfg, |
| 712 | char *label, int maxlen, int *indexp) |
| 713 | { |
| 714 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 715 | const char *name = NULL; |
| 716 | int i; |
David Henningsson | 3f25dcf | 2013-01-18 15:43:03 +0100 | [diff] [blame] | 717 | bool hdmi; |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 718 | |
| 719 | if (indexp) |
| 720 | *indexp = 0; |
| 721 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 722 | return 0; |
| 723 | |
| 724 | switch (get_defcfg_device(def_conf)) { |
| 725 | case AC_JACK_LINE_OUT: |
| 726 | return fill_audio_out_name(codec, nid, cfg, "Line Out", |
| 727 | label, maxlen, indexp); |
| 728 | case AC_JACK_SPEAKER: |
| 729 | return fill_audio_out_name(codec, nid, cfg, "Speaker", |
| 730 | label, maxlen, indexp); |
| 731 | case AC_JACK_HP_OUT: |
| 732 | return fill_audio_out_name(codec, nid, cfg, "Headphone", |
| 733 | label, maxlen, indexp); |
| 734 | case AC_JACK_SPDIF_OUT: |
| 735 | case AC_JACK_DIG_OTHER_OUT: |
David Henningsson | 3f25dcf | 2013-01-18 15:43:03 +0100 | [diff] [blame] | 736 | hdmi = is_hdmi_cfg(def_conf); |
| 737 | name = hdmi ? "HDMI" : "SPDIF"; |
| 738 | if (cfg && indexp) |
| 739 | for (i = 0; i < cfg->dig_outs; i++) { |
| 740 | hda_nid_t pin = cfg->dig_out_pins[i]; |
| 741 | unsigned int c; |
| 742 | if (pin == nid) |
| 743 | break; |
| 744 | c = snd_hda_codec_get_pincfg(codec, pin); |
| 745 | if (hdmi == is_hdmi_cfg(c)) |
| 746 | (*indexp)++; |
| 747 | } |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 748 | break; |
| 749 | default: |
| 750 | if (cfg) { |
| 751 | for (i = 0; i < cfg->num_inputs; i++) { |
| 752 | if (cfg->inputs[i].pin != nid) |
| 753 | continue; |
| 754 | name = hda_get_autocfg_input_label(codec, cfg, i); |
| 755 | if (name) |
| 756 | break; |
| 757 | } |
| 758 | } |
| 759 | if (!name) |
David Henningsson | a385d97 | 2013-03-21 12:16:29 +0100 | [diff] [blame] | 760 | name = hda_get_input_pin_label(codec, NULL, nid, true); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 761 | break; |
| 762 | } |
| 763 | if (!name) |
| 764 | return 0; |
| 765 | strlcpy(label, name, maxlen); |
| 766 | return 1; |
| 767 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 768 | EXPORT_SYMBOL_GPL(snd_hda_get_pin_label); |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 769 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 770 | /** |
| 771 | * snd_hda_add_verbs - Add verbs to the init list |
| 772 | * @codec: the HDA codec |
| 773 | * @list: zero-terminated verb list to add |
| 774 | * |
| 775 | * Append the given verb list to the execution list. The verbs will be |
| 776 | * performed at init and resume time via snd_hda_apply_verbs(). |
| 777 | */ |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 778 | int snd_hda_add_verbs(struct hda_codec *codec, |
| 779 | const struct hda_verb *list) |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 780 | { |
| 781 | const struct hda_verb **v; |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 782 | v = snd_array_new(&codec->verbs); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 783 | if (!v) |
| 784 | return -ENOMEM; |
| 785 | *v = list; |
| 786 | return 0; |
| 787 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 788 | EXPORT_SYMBOL_GPL(snd_hda_add_verbs); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 789 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 790 | /** |
| 791 | * snd_hda_apply_verbs - Execute the init verb lists |
| 792 | * @codec: the HDA codec |
| 793 | */ |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 794 | void snd_hda_apply_verbs(struct hda_codec *codec) |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 795 | { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 796 | int i; |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 797 | for (i = 0; i < codec->verbs.used; i++) { |
| 798 | struct hda_verb **v = snd_array_elem(&codec->verbs, i); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 799 | snd_hda_sequence_write(codec, *v); |
| 800 | } |
| 801 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 802 | EXPORT_SYMBOL_GPL(snd_hda_apply_verbs); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 803 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 804 | /** |
| 805 | * snd_hda_apply_pincfgs - Set each pin config in the given list |
| 806 | * @codec: the HDA codec |
| 807 | * @cfg: NULL-terminated pin config table |
| 808 | */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 809 | void snd_hda_apply_pincfgs(struct hda_codec *codec, |
| 810 | const struct hda_pintbl *cfg) |
| 811 | { |
| 812 | for (; cfg->nid; cfg++) |
| 813 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); |
| 814 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 815 | EXPORT_SYMBOL_GPL(snd_hda_apply_pincfgs); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 816 | |
Takashi Iwai | fd10821 | 2013-01-10 10:18:14 +0100 | [diff] [blame] | 817 | static void set_pin_targets(struct hda_codec *codec, |
| 818 | const struct hda_pintbl *cfg) |
| 819 | { |
| 820 | for (; cfg->nid; cfg++) |
| 821 | snd_hda_set_pin_ctl_cache(codec, cfg->nid, cfg->val); |
| 822 | } |
| 823 | |
Takashi Iwai | 1f57825 | 2013-01-23 18:10:10 +0100 | [diff] [blame] | 824 | static void apply_fixup(struct hda_codec *codec, int id, int action, int depth) |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 825 | { |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 826 | const char *modelname = codec->fixup_name; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 827 | |
| 828 | while (id >= 0) { |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 829 | const struct hda_fixup *fix = codec->fixup_list + id; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 830 | |
Takashi Iwai | 1f57825 | 2013-01-23 18:10:10 +0100 | [diff] [blame] | 831 | if (fix->chained_before) |
| 832 | apply_fixup(codec, fix->chain_id, action, depth + 1); |
| 833 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 834 | switch (fix->type) { |
| 835 | case HDA_FIXUP_PINS: |
| 836 | if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins) |
| 837 | break; |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 838 | codec_dbg(codec, "%s: Apply pincfg for %s\n", |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 839 | codec->chip_name, modelname); |
| 840 | snd_hda_apply_pincfgs(codec, fix->v.pins); |
| 841 | break; |
| 842 | case HDA_FIXUP_VERBS: |
| 843 | if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs) |
| 844 | break; |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 845 | codec_dbg(codec, "%s: Apply fix-verbs for %s\n", |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 846 | codec->chip_name, modelname); |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 847 | snd_hda_add_verbs(codec, fix->v.verbs); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 848 | break; |
| 849 | case HDA_FIXUP_FUNC: |
| 850 | if (!fix->v.func) |
| 851 | break; |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 852 | codec_dbg(codec, "%s: Apply fix-func for %s\n", |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 853 | codec->chip_name, modelname); |
| 854 | fix->v.func(codec, fix, action); |
| 855 | break; |
Takashi Iwai | fd10821 | 2013-01-10 10:18:14 +0100 | [diff] [blame] | 856 | case HDA_FIXUP_PINCTLS: |
| 857 | if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins) |
| 858 | break; |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 859 | codec_dbg(codec, "%s: Apply pinctl for %s\n", |
Takashi Iwai | fd10821 | 2013-01-10 10:18:14 +0100 | [diff] [blame] | 860 | codec->chip_name, modelname); |
| 861 | set_pin_targets(codec, fix->v.pins); |
| 862 | break; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 863 | default: |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 864 | codec_err(codec, "%s: Invalid fixup type %d\n", |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 865 | codec->chip_name, fix->type); |
| 866 | break; |
| 867 | } |
Takashi Iwai | 1f57825 | 2013-01-23 18:10:10 +0100 | [diff] [blame] | 868 | if (!fix->chained || fix->chained_before) |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 869 | break; |
| 870 | if (++depth > 10) |
| 871 | break; |
| 872 | id = fix->chain_id; |
| 873 | } |
| 874 | } |
Takashi Iwai | 1f57825 | 2013-01-23 18:10:10 +0100 | [diff] [blame] | 875 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 876 | /** |
| 877 | * snd_hda_apply_fixup - Apply the fixup chain with the given action |
| 878 | * @codec: the HDA codec |
| 879 | * @action: fixup action (HDA_FIXUP_ACT_XXX) |
| 880 | */ |
Takashi Iwai | 1f57825 | 2013-01-23 18:10:10 +0100 | [diff] [blame] | 881 | void snd_hda_apply_fixup(struct hda_codec *codec, int action) |
| 882 | { |
| 883 | if (codec->fixup_list) |
| 884 | apply_fixup(codec, codec->fixup_id, action, 0); |
| 885 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 886 | EXPORT_SYMBOL_GPL(snd_hda_apply_fixup); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 887 | |
David Henningsson | 2053141 | 2014-05-26 16:22:41 +0800 | [diff] [blame] | 888 | static bool pin_config_match(struct hda_codec *codec, |
| 889 | const struct hda_pintbl *pins) |
| 890 | { |
| 891 | for (; pins->nid; pins++) { |
| 892 | u32 def_conf = snd_hda_codec_get_pincfg(codec, pins->nid); |
Hui Wang | 37df094 | 2014-05-29 15:59:17 +0800 | [diff] [blame] | 893 | if (pins->val != def_conf) |
David Henningsson | 2053141 | 2014-05-26 16:22:41 +0800 | [diff] [blame] | 894 | return false; |
| 895 | } |
| 896 | return true; |
| 897 | } |
| 898 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 899 | /** |
| 900 | * snd_hda_pick_pin_fixup - Pick up a fixup matching with the pin quirk list |
| 901 | * @codec: the HDA codec |
| 902 | * @pin_quirk: zero-terminated pin quirk list |
| 903 | * @fixlist: the fixup list |
| 904 | */ |
David Henningsson | 2053141 | 2014-05-26 16:22:41 +0800 | [diff] [blame] | 905 | void snd_hda_pick_pin_fixup(struct hda_codec *codec, |
| 906 | const struct snd_hda_pin_quirk *pin_quirk, |
| 907 | const struct hda_fixup *fixlist) |
| 908 | { |
| 909 | const struct snd_hda_pin_quirk *pq; |
| 910 | |
David Henningsson | f5662e1 | 2014-07-22 14:09:34 +0200 | [diff] [blame] | 911 | if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET) |
David Henningsson | 2053141 | 2014-05-26 16:22:41 +0800 | [diff] [blame] | 912 | return; |
| 913 | |
| 914 | for (pq = pin_quirk; pq->subvendor; pq++) { |
Hui Wang | 621b5a0 | 2014-05-26 16:22:42 +0800 | [diff] [blame] | 915 | if ((codec->subsystem_id & 0xffff0000) != (pq->subvendor << 16)) |
David Henningsson | 2053141 | 2014-05-26 16:22:41 +0800 | [diff] [blame] | 916 | continue; |
| 917 | if (codec->vendor_id != pq->codec) |
| 918 | continue; |
| 919 | if (pin_config_match(codec, pq->pins)) { |
| 920 | codec->fixup_id = pq->value; |
| 921 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 922 | codec->fixup_name = pq->name; |
David Henningsson | 4f7946e | 2015-01-07 14:41:59 +0100 | [diff] [blame^] | 923 | codec_dbg(codec, "%s: picked fixup %s (pin match)\n", |
| 924 | codec->chip_name, codec->fixup_name); |
David Henningsson | 2053141 | 2014-05-26 16:22:41 +0800 | [diff] [blame] | 925 | #endif |
| 926 | codec->fixup_list = fixlist; |
| 927 | return; |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | EXPORT_SYMBOL_GPL(snd_hda_pick_pin_fixup); |
| 932 | |
Takashi Iwai | 95a962c | 2014-10-29 16:03:58 +0100 | [diff] [blame] | 933 | /** |
| 934 | * snd_hda_pick_fixup - Pick up a fixup matching with PCI/codec SSID or model string |
| 935 | * @codec: the HDA codec |
| 936 | * @models: NULL-terminated model string list |
| 937 | * @quirk: zero-terminated PCI/codec SSID quirk list |
| 938 | * @fixlist: the fixup list |
| 939 | * |
| 940 | * Pick up a fixup entry matching with the given model string or SSID. |
| 941 | * If a fixup was already set beforehand, the function doesn't do anything. |
| 942 | * When a special model string "nofixup" is given, also no fixup is applied. |
| 943 | * |
| 944 | * The function tries to find the matching model name at first, if given. |
| 945 | * If nothing matched, try to look up the PCI SSID. |
| 946 | * If still nothing matched, try to look up the codec SSID. |
| 947 | */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 948 | void snd_hda_pick_fixup(struct hda_codec *codec, |
| 949 | const struct hda_model_fixup *models, |
| 950 | const struct snd_pci_quirk *quirk, |
| 951 | const struct hda_fixup *fixlist) |
| 952 | { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 953 | const struct snd_pci_quirk *q; |
David Henningsson | f5662e1 | 2014-07-22 14:09:34 +0200 | [diff] [blame] | 954 | int id = HDA_FIXUP_ID_NOT_SET; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 955 | const char *name = NULL; |
| 956 | |
David Henningsson | f5662e1 | 2014-07-22 14:09:34 +0200 | [diff] [blame] | 957 | if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET) |
| 958 | return; |
| 959 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 960 | /* when model=nofixup is given, don't pick up any fixups */ |
| 961 | if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 962 | codec->fixup_list = NULL; |
David Henningsson | f5662e1 | 2014-07-22 14:09:34 +0200 | [diff] [blame] | 963 | codec->fixup_name = NULL; |
| 964 | codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP; |
David Henningsson | 4f7946e | 2015-01-07 14:41:59 +0100 | [diff] [blame^] | 965 | codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n", |
| 966 | codec->chip_name); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 967 | return; |
| 968 | } |
| 969 | |
| 970 | if (codec->modelname && models) { |
| 971 | while (models->name) { |
| 972 | if (!strcmp(codec->modelname, models->name)) { |
David Henningsson | c21c8cf | 2014-05-26 16:22:40 +0800 | [diff] [blame] | 973 | codec->fixup_id = models->id; |
| 974 | codec->fixup_name = models->name; |
David Henningsson | 8fffe7d | 2014-06-19 22:07:19 +0200 | [diff] [blame] | 975 | codec->fixup_list = fixlist; |
David Henningsson | 4f7946e | 2015-01-07 14:41:59 +0100 | [diff] [blame^] | 976 | codec_dbg(codec, "%s: picked fixup %s (model specified)\n", |
| 977 | codec->chip_name, codec->fixup_name); |
David Henningsson | c21c8cf | 2014-05-26 16:22:40 +0800 | [diff] [blame] | 978 | return; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 979 | } |
| 980 | models++; |
| 981 | } |
| 982 | } |
David Henningsson | f5662e1 | 2014-07-22 14:09:34 +0200 | [diff] [blame] | 983 | if (quirk) { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 984 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| 985 | if (q) { |
| 986 | id = q->value; |
| 987 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 988 | name = q->name; |
David Henningsson | 4f7946e | 2015-01-07 14:41:59 +0100 | [diff] [blame^] | 989 | codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n", |
| 990 | codec->chip_name, name, q->subdevice_mask ? "" : " - vendor generic"); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 991 | #endif |
| 992 | } |
| 993 | } |
David Henningsson | 639aa4b | 2012-07-18 18:02:53 +0200 | [diff] [blame] | 994 | if (id < 0 && quirk) { |
Takashi Iwai | 697aeba | 2013-08-01 08:38:27 +0200 | [diff] [blame] | 995 | for (q = quirk; q->subvendor || q->subdevice; q++) { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 996 | unsigned int vendorid = |
| 997 | q->subdevice | (q->subvendor << 16); |
Takashi Iwai | a33b7b0 | 2012-09-11 16:42:18 +0200 | [diff] [blame] | 998 | unsigned int mask = 0xffff0000 | q->subdevice_mask; |
| 999 | if ((codec->subsystem_id & mask) == (vendorid & mask)) { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1000 | id = q->value; |
| 1001 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 1002 | name = q->name; |
David Henningsson | 4f7946e | 2015-01-07 14:41:59 +0100 | [diff] [blame^] | 1003 | codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n", |
| 1004 | codec->chip_name, name); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1005 | #endif |
| 1006 | break; |
| 1007 | } |
| 1008 | } |
| 1009 | } |
| 1010 | |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 1011 | codec->fixup_id = id; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1012 | if (id >= 0) { |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 1013 | codec->fixup_list = fixlist; |
| 1014 | codec->fixup_name = name; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1015 | } |
| 1016 | } |
Takashi Iwai | 2698ea9 | 2013-12-18 07:45:52 +0100 | [diff] [blame] | 1017 | EXPORT_SYMBOL_GPL(snd_hda_pick_fixup); |