diff options
| -rw-r--r-- | sound/pci/echoaudio/echoaudio_dsp.c | 2 | ||||
| -rw-r--r-- | sound/pci/hda/Makefile | 2 | ||||
| -rw-r--r-- | sound/pci/hda/hda_auto_parser.c | 760 | ||||
| -rw-r--r-- | sound/pci/hda/hda_auto_parser.h | 160 | ||||
| -rw-r--r-- | sound/pci/hda/hda_codec.c | 949 | ||||
| -rw-r--r-- | sound/pci/hda/hda_codec.h | 8 | ||||
| -rw-r--r-- | sound/pci/hda/hda_intel.c | 26 | ||||
| -rw-r--r-- | sound/pci/hda/hda_jack.c | 1 | ||||
| -rw-r--r-- | sound/pci/hda/hda_jack.h | 2 | ||||
| -rw-r--r-- | sound/pci/hda/hda_local.h | 122 | ||||
| -rw-r--r-- | sound/pci/hda/patch_analog.c | 14 | ||||
| -rw-r--r-- | sound/pci/hda/patch_ca0110.c | 8 | ||||
| -rw-r--r-- | sound/pci/hda/patch_ca0132.c | 9 | ||||
| -rw-r--r-- | sound/pci/hda/patch_cirrus.c | 30 | ||||
| -rw-r--r-- | sound/pci/hda/patch_cmedia.c | 1 | ||||
| -rw-r--r-- | sound/pci/hda/patch_conexant.c | 186 | ||||
| -rw-r--r-- | sound/pci/hda/patch_hdmi.c | 4 | ||||
| -rw-r--r-- | sound/pci/hda/patch_realtek.c | 465 | ||||
| -rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 68 | ||||
| -rw-r--r-- | sound/pci/hda/patch_via.c | 31 | ||||
| -rw-r--r-- | sound/pci/rme9652/hdsp.c | 1 |
21 files changed, 1540 insertions, 1309 deletions
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c index 64417a733220..d8c670c9d62c 100644 --- a/sound/pci/echoaudio/echoaudio_dsp.c +++ b/sound/pci/echoaudio/echoaudio_dsp.c | |||
| @@ -475,7 +475,7 @@ static int load_firmware(struct echoaudio *chip) | |||
| 475 | const struct firmware *fw; | 475 | const struct firmware *fw; |
| 476 | int box_type, err; | 476 | int box_type, err; |
| 477 | 477 | ||
| 478 | if (snd_BUG_ON(!chip->dsp_code_to_load || !chip->comm_page)) | 478 | if (snd_BUG_ON(!chip->comm_page)) |
| 479 | return -EPERM; | 479 | return -EPERM; |
| 480 | 480 | ||
| 481 | /* See if the ASIC is present and working - only if the DSP is already loaded */ | 481 | /* See if the ASIC is present and working - only if the DSP is already loaded */ |
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index ace157cc3d15..bd4149f1aaf4 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | snd-hda-intel-objs := hda_intel.o | 1 | snd-hda-intel-objs := hda_intel.o |
| 2 | 2 | ||
| 3 | snd-hda-codec-y := hda_codec.o hda_jack.o | 3 | snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o |
| 4 | snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o | 4 | snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o |
| 5 | snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o | 5 | snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o |
| 6 | snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o | 6 | snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o |
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c new file mode 100644 index 000000000000..6e9ef3e25093 --- /dev/null +++ b/sound/pci/hda/hda_auto_parser.c | |||
| @@ -0,0 +1,760 @@ | |||
| 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> | ||
| 14 | #include <sound/core.h> | ||
| 15 | #include "hda_codec.h" | ||
| 16 | #include "hda_local.h" | ||
| 17 | #include "hda_auto_parser.h" | ||
| 18 | |||
| 19 | #define SFX "hda_codec: " | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Helper for automatic pin configuration | ||
| 23 | */ | ||
| 24 | |||
| 25 | static int is_in_nid_list(hda_nid_t nid, const hda_nid_t *list) | ||
| 26 | { | ||
| 27 | for (; *list; list++) | ||
| 28 | if (*list == nid) | ||
| 29 | return 1; | ||
| 30 | return 0; | ||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | /* | ||
| 35 | * Sort an associated group of pins according to their sequence numbers. | ||
| 36 | */ | ||
| 37 | static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, | ||
| 38 | int num_pins) | ||
| 39 | { | ||
| 40 | int i, j; | ||
| 41 | short seq; | ||
| 42 | hda_nid_t nid; | ||
| 43 | |||
| 44 | for (i = 0; i < num_pins; i++) { | ||
| 45 | for (j = i + 1; j < num_pins; j++) { | ||
| 46 | if (sequences[i] > sequences[j]) { | ||
| 47 | seq = sequences[i]; | ||
| 48 | sequences[i] = sequences[j]; | ||
| 49 | sequences[j] = seq; | ||
| 50 | nid = pins[i]; | ||
| 51 | pins[i] = pins[j]; | ||
| 52 | pins[j] = nid; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | /* add the found input-pin to the cfg->inputs[] table */ | ||
| 60 | static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, | ||
| 61 | int type) | ||
| 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; | ||
| 66 | cfg->num_inputs++; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | /* sort inputs in the order of AUTO_PIN_* type */ | ||
| 71 | static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg) | ||
| 72 | { | ||
| 73 | int i, j; | ||
| 74 | |||
| 75 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 76 | for (j = i + 1; j < cfg->num_inputs; j++) { | ||
| 77 | if (cfg->inputs[i].type > cfg->inputs[j].type) { | ||
| 78 | struct auto_pin_cfg_item tmp; | ||
| 79 | tmp = cfg->inputs[i]; | ||
| 80 | cfg->inputs[i] = cfg->inputs[j]; | ||
| 81 | cfg->inputs[j] = tmp; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | /* Reorder the surround channels | ||
| 88 | * ALSA sequence is front/surr/clfe/side | ||
| 89 | * HDA sequence is: | ||
| 90 | * 4-ch: front/surr => OK as it is | ||
| 91 | * 6-ch: front/clfe/surr | ||
| 92 | * 8-ch: front/clfe/rear/side|fc | ||
| 93 | */ | ||
| 94 | static void reorder_outputs(unsigned int nums, hda_nid_t *pins) | ||
| 95 | { | ||
| 96 | hda_nid_t nid; | ||
| 97 | |||
| 98 | switch (nums) { | ||
| 99 | case 3: | ||
| 100 | case 4: | ||
| 101 | nid = pins[1]; | ||
| 102 | pins[1] = pins[2]; | ||
| 103 | pins[2] = nid; | ||
| 104 | break; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | /* | ||
| 109 | * Parse all pin widgets and store the useful pin nids to cfg | ||
| 110 | * | ||
| 111 | * The number of line-outs or any primary output is stored in line_outs, | ||
| 112 | * and the corresponding output pins are assigned to line_out_pins[], | ||
| 113 | * in the order of front, rear, CLFE, side, ... | ||
| 114 | * | ||
| 115 | * If more extra outputs (speaker and headphone) are found, the pins are | ||
| 116 | * assisnged to hp_pins[] and speaker_pins[], respectively. If no line-out jack | ||
| 117 | * is detected, one of speaker of HP pins is assigned as the primary | ||
| 118 | * output, i.e. to line_out_pins[0]. So, line_outs is always positive | ||
| 119 | * if any analog output exists. | ||
| 120 | * | ||
| 121 | * The analog input pins are assigned to inputs array. | ||
| 122 | * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, | ||
| 123 | * respectively. | ||
| 124 | */ | ||
| 125 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | ||
| 126 | struct auto_pin_cfg *cfg, | ||
| 127 | const hda_nid_t *ignore_nids, | ||
| 128 | unsigned int cond_flags) | ||
| 129 | { | ||
| 130 | hda_nid_t nid, end_nid; | ||
| 131 | short seq, assoc_line_out; | ||
| 132 | short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)]; | ||
| 133 | short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)]; | ||
| 134 | short sequences_hp[ARRAY_SIZE(cfg->hp_pins)]; | ||
| 135 | int i; | ||
| 136 | |||
| 137 | memset(cfg, 0, sizeof(*cfg)); | ||
| 138 | |||
| 139 | memset(sequences_line_out, 0, sizeof(sequences_line_out)); | ||
| 140 | memset(sequences_speaker, 0, sizeof(sequences_speaker)); | ||
| 141 | memset(sequences_hp, 0, sizeof(sequences_hp)); | ||
| 142 | assoc_line_out = 0; | ||
| 143 | |||
| 144 | codec->ignore_misc_bit = true; | ||
| 145 | end_nid = codec->start_nid + codec->num_nodes; | ||
| 146 | for (nid = codec->start_nid; nid < end_nid; nid++) { | ||
| 147 | unsigned int wid_caps = get_wcaps(codec, nid); | ||
| 148 | unsigned int wid_type = get_wcaps_type(wid_caps); | ||
| 149 | unsigned int def_conf; | ||
| 150 | short assoc, loc, conn, dev; | ||
| 151 | |||
| 152 | /* read all default configuration for pin complex */ | ||
| 153 | if (wid_type != AC_WID_PIN) | ||
| 154 | continue; | ||
| 155 | /* ignore the given nids (e.g. pc-beep returns error) */ | ||
| 156 | if (ignore_nids && is_in_nid_list(nid, ignore_nids)) | ||
| 157 | continue; | ||
| 158 | |||
| 159 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 160 | if (!(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) & | ||
| 161 | AC_DEFCFG_MISC_NO_PRESENCE)) | ||
| 162 | codec->ignore_misc_bit = false; | ||
| 163 | conn = get_defcfg_connect(def_conf); | ||
| 164 | if (conn == AC_JACK_PORT_NONE) | ||
| 165 | continue; | ||
| 166 | loc = get_defcfg_location(def_conf); | ||
| 167 | dev = get_defcfg_device(def_conf); | ||
| 168 | |||
| 169 | /* workaround for buggy BIOS setups */ | ||
| 170 | if (dev == AC_JACK_LINE_OUT) { | ||
| 171 | if (conn == AC_JACK_PORT_FIXED) | ||
| 172 | dev = AC_JACK_SPEAKER; | ||
| 173 | } | ||
| 174 | |||
| 175 | switch (dev) { | ||
| 176 | case AC_JACK_LINE_OUT: | ||
| 177 | seq = get_defcfg_sequence(def_conf); | ||
| 178 | assoc = get_defcfg_association(def_conf); | ||
| 179 | |||
| 180 | if (!(wid_caps & AC_WCAP_STEREO)) | ||
| 181 | if (!cfg->mono_out_pin) | ||
| 182 | cfg->mono_out_pin = nid; | ||
| 183 | if (!assoc) | ||
| 184 | continue; | ||
| 185 | if (!assoc_line_out) | ||
| 186 | assoc_line_out = assoc; | ||
| 187 | else if (assoc_line_out != assoc) | ||
| 188 | continue; | ||
| 189 | if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) | ||
| 190 | continue; | ||
| 191 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
| 192 | sequences_line_out[cfg->line_outs] = seq; | ||
| 193 | cfg->line_outs++; | ||
| 194 | break; | ||
| 195 | case AC_JACK_SPEAKER: | ||
| 196 | seq = get_defcfg_sequence(def_conf); | ||
| 197 | assoc = get_defcfg_association(def_conf); | ||
| 198 | if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) | ||
| 199 | continue; | ||
| 200 | cfg->speaker_pins[cfg->speaker_outs] = nid; | ||
| 201 | sequences_speaker[cfg->speaker_outs] = (assoc << 4) | seq; | ||
| 202 | cfg->speaker_outs++; | ||
| 203 | break; | ||
| 204 | case AC_JACK_HP_OUT: | ||
| 205 | seq = get_defcfg_sequence(def_conf); | ||
| 206 | assoc = get_defcfg_association(def_conf); | ||
| 207 | if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) | ||
| 208 | continue; | ||
| 209 | cfg->hp_pins[cfg->hp_outs] = nid; | ||
| 210 | sequences_hp[cfg->hp_outs] = (assoc << 4) | seq; | ||
| 211 | cfg->hp_outs++; | ||
| 212 | break; | ||
| 213 | case AC_JACK_MIC_IN: | ||
| 214 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_MIC); | ||
| 215 | break; | ||
| 216 | case AC_JACK_LINE_IN: | ||
| 217 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_LINE_IN); | ||
| 218 | break; | ||
| 219 | case AC_JACK_CD: | ||
| 220 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD); | ||
| 221 | break; | ||
| 222 | case AC_JACK_AUX: | ||
| 223 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX); | ||
| 224 | break; | ||
| 225 | case AC_JACK_SPDIF_OUT: | ||
| 226 | case AC_JACK_DIG_OTHER_OUT: | ||
| 227 | if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) | ||
| 228 | continue; | ||
| 229 | cfg->dig_out_pins[cfg->dig_outs] = nid; | ||
| 230 | cfg->dig_out_type[cfg->dig_outs] = | ||
| 231 | (loc == AC_JACK_LOC_HDMI) ? | ||
| 232 | HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF; | ||
| 233 | cfg->dig_outs++; | ||
| 234 | break; | ||
| 235 | case AC_JACK_SPDIF_IN: | ||
| 236 | case AC_JACK_DIG_OTHER_IN: | ||
| 237 | cfg->dig_in_pin = nid; | ||
| 238 | if (loc == AC_JACK_LOC_HDMI) | ||
| 239 | cfg->dig_in_type = HDA_PCM_TYPE_HDMI; | ||
| 240 | else | ||
| 241 | cfg->dig_in_type = HDA_PCM_TYPE_SPDIF; | ||
| 242 | break; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | |||
| 246 | /* FIX-UP: | ||
| 247 | * If no line-out is defined but multiple HPs are found, | ||
| 248 | * some of them might be the real line-outs. | ||
| 249 | */ | ||
| 250 | if (!cfg->line_outs && cfg->hp_outs > 1 && | ||
| 251 | !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) { | ||
| 252 | int i = 0; | ||
| 253 | while (i < cfg->hp_outs) { | ||
| 254 | /* The real HPs should have the sequence 0x0f */ | ||
| 255 | if ((sequences_hp[i] & 0x0f) == 0x0f) { | ||
| 256 | i++; | ||
| 257 | continue; | ||
| 258 | } | ||
| 259 | /* Move it to the line-out table */ | ||
| 260 | cfg->line_out_pins[cfg->line_outs] = cfg->hp_pins[i]; | ||
| 261 | sequences_line_out[cfg->line_outs] = sequences_hp[i]; | ||
| 262 | cfg->line_outs++; | ||
| 263 | cfg->hp_outs--; | ||
| 264 | memmove(cfg->hp_pins + i, cfg->hp_pins + i + 1, | ||
| 265 | sizeof(cfg->hp_pins[0]) * (cfg->hp_outs - i)); | ||
| 266 | memmove(sequences_hp + i, sequences_hp + i + 1, | ||
| 267 | sizeof(sequences_hp[0]) * (cfg->hp_outs - i)); | ||
| 268 | } | ||
| 269 | memset(cfg->hp_pins + cfg->hp_outs, 0, | ||
| 270 | sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs)); | ||
| 271 | if (!cfg->hp_outs) | ||
| 272 | cfg->line_out_type = AUTO_PIN_HP_OUT; | ||
| 273 | |||
| 274 | } | ||
| 275 | |||
| 276 | /* sort by sequence */ | ||
| 277 | sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out, | ||
| 278 | cfg->line_outs); | ||
| 279 | sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker, | ||
| 280 | cfg->speaker_outs); | ||
| 281 | sort_pins_by_sequence(cfg->hp_pins, sequences_hp, | ||
| 282 | cfg->hp_outs); | ||
| 283 | |||
| 284 | /* | ||
| 285 | * FIX-UP: if no line-outs are detected, try to use speaker or HP pin | ||
| 286 | * as a primary output | ||
| 287 | */ | ||
| 288 | if (!cfg->line_outs && | ||
| 289 | !(cond_flags & HDA_PINCFG_NO_LO_FIXUP)) { | ||
| 290 | if (cfg->speaker_outs) { | ||
| 291 | cfg->line_outs = cfg->speaker_outs; | ||
| 292 | memcpy(cfg->line_out_pins, cfg->speaker_pins, | ||
| 293 | sizeof(cfg->speaker_pins)); | ||
| 294 | cfg->speaker_outs = 0; | ||
| 295 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); | ||
| 296 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; | ||
| 297 | } else if (cfg->hp_outs) { | ||
| 298 | cfg->line_outs = cfg->hp_outs; | ||
| 299 | memcpy(cfg->line_out_pins, cfg->hp_pins, | ||
| 300 | sizeof(cfg->hp_pins)); | ||
| 301 | cfg->hp_outs = 0; | ||
| 302 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); | ||
| 303 | cfg->line_out_type = AUTO_PIN_HP_OUT; | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | reorder_outputs(cfg->line_outs, cfg->line_out_pins); | ||
| 308 | reorder_outputs(cfg->hp_outs, cfg->hp_pins); | ||
| 309 | reorder_outputs(cfg->speaker_outs, cfg->speaker_pins); | ||
| 310 | |||
| 311 | sort_autocfg_input_pins(cfg); | ||
| 312 | |||
| 313 | /* | ||
| 314 | * debug prints of the parsed results | ||
| 315 | */ | ||
| 316 | snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", | ||
| 317 | cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1], | ||
| 318 | cfg->line_out_pins[2], cfg->line_out_pins[3], | ||
| 319 | cfg->line_out_pins[4], | ||
| 320 | cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : | ||
| 321 | (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ? | ||
| 322 | "speaker" : "line")); | ||
| 323 | snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | ||
| 324 | cfg->speaker_outs, cfg->speaker_pins[0], | ||
| 325 | cfg->speaker_pins[1], cfg->speaker_pins[2], | ||
| 326 | cfg->speaker_pins[3], cfg->speaker_pins[4]); | ||
| 327 | snd_printd(" hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | ||
| 328 | cfg->hp_outs, cfg->hp_pins[0], | ||
| 329 | cfg->hp_pins[1], cfg->hp_pins[2], | ||
| 330 | cfg->hp_pins[3], cfg->hp_pins[4]); | ||
| 331 | snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin); | ||
| 332 | if (cfg->dig_outs) | ||
| 333 | snd_printd(" dig-out=0x%x/0x%x\n", | ||
| 334 | cfg->dig_out_pins[0], cfg->dig_out_pins[1]); | ||
| 335 | snd_printd(" inputs:"); | ||
| 336 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 337 | snd_printd(" %s=0x%x", | ||
| 338 | hda_get_autocfg_input_label(codec, cfg, i), | ||
| 339 | cfg->inputs[i].pin); | ||
| 340 | } | ||
| 341 | snd_printd("\n"); | ||
| 342 | if (cfg->dig_in_pin) | ||
| 343 | snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin); | ||
| 344 | |||
| 345 | return 0; | ||
| 346 | } | ||
| 347 | EXPORT_SYMBOL_HDA(snd_hda_parse_pin_defcfg); | ||
| 348 | |||
| 349 | int snd_hda_get_input_pin_attr(unsigned int def_conf) | ||
| 350 | { | ||
| 351 | unsigned int loc = get_defcfg_location(def_conf); | ||
| 352 | unsigned int conn = get_defcfg_connect(def_conf); | ||
| 353 | if (conn == AC_JACK_PORT_NONE) | ||
| 354 | return INPUT_PIN_ATTR_UNUSED; | ||
| 355 | /* Windows may claim the internal mic to be BOTH, too */ | ||
| 356 | if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) | ||
| 357 | return INPUT_PIN_ATTR_INT; | ||
| 358 | if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) | ||
| 359 | return INPUT_PIN_ATTR_INT; | ||
| 360 | if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) | ||
| 361 | return INPUT_PIN_ATTR_DOCK; | ||
| 362 | if (loc == AC_JACK_LOC_REAR) | ||
| 363 | return INPUT_PIN_ATTR_REAR; | ||
| 364 | if (loc == AC_JACK_LOC_FRONT) | ||
| 365 | return INPUT_PIN_ATTR_FRONT; | ||
| 366 | return INPUT_PIN_ATTR_NORMAL; | ||
| 367 | } | ||
| 368 | EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr); | ||
| 369 | |||
| 370 | /** | ||
| 371 | * hda_get_input_pin_label - Give a label for the given input pin | ||
| 372 | * | ||
| 373 | * When check_location is true, the function checks the pin location | ||
| 374 | * for mic and line-in pins, and set an appropriate prefix like "Front", | ||
| 375 | * "Rear", "Internal". | ||
| 376 | */ | ||
| 377 | |||
| 378 | static const char *hda_get_input_pin_label(struct hda_codec *codec, | ||
| 379 | hda_nid_t pin, bool check_location) | ||
| 380 | { | ||
| 381 | unsigned int def_conf; | ||
| 382 | static const char * const mic_names[] = { | ||
| 383 | "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic", | ||
| 384 | }; | ||
| 385 | int attr; | ||
| 386 | |||
| 387 | def_conf = snd_hda_codec_get_pincfg(codec, pin); | ||
| 388 | |||
| 389 | switch (get_defcfg_device(def_conf)) { | ||
| 390 | case AC_JACK_MIC_IN: | ||
| 391 | if (!check_location) | ||
| 392 | return "Mic"; | ||
| 393 | attr = snd_hda_get_input_pin_attr(def_conf); | ||
| 394 | if (!attr) | ||
| 395 | return "None"; | ||
| 396 | return mic_names[attr - 1]; | ||
| 397 | case AC_JACK_LINE_IN: | ||
| 398 | if (!check_location) | ||
| 399 | return "Line"; | ||
| 400 | attr = snd_hda_get_input_pin_attr(def_conf); | ||
| 401 | if (!attr) | ||
| 402 | return "None"; | ||
| 403 | if (attr == INPUT_PIN_ATTR_DOCK) | ||
| 404 | return "Dock Line"; | ||
| 405 | return "Line"; | ||
| 406 | case AC_JACK_AUX: | ||
| 407 | return "Aux"; | ||
| 408 | case AC_JACK_CD: | ||
| 409 | return "CD"; | ||
| 410 | case AC_JACK_SPDIF_IN: | ||
| 411 | return "SPDIF In"; | ||
| 412 | case AC_JACK_DIG_OTHER_IN: | ||
| 413 | return "Digital In"; | ||
| 414 | default: | ||
| 415 | return "Misc"; | ||
| 416 | } | ||
| 417 | } | ||
| 418 | |||
| 419 | /* Check whether the location prefix needs to be added to the label. | ||
| 420 | * If all mic-jacks are in the same location (e.g. rear panel), we don't | ||
| 421 | * have to put "Front" prefix to each label. In such a case, returns false. | ||
| 422 | */ | ||
| 423 | static int check_mic_location_need(struct hda_codec *codec, | ||
| 424 | const struct auto_pin_cfg *cfg, | ||
| 425 | int input) | ||
| 426 | { | ||
| 427 | unsigned int defc; | ||
| 428 | int i, attr, attr2; | ||
| 429 | |||
| 430 | defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); | ||
| 431 | attr = snd_hda_get_input_pin_attr(defc); | ||
| 432 | /* for internal or docking mics, we need locations */ | ||
| 433 | if (attr <= INPUT_PIN_ATTR_NORMAL) | ||
| 434 | return 1; | ||
| 435 | |||
| 436 | attr = 0; | ||
| 437 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 438 | defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); | ||
| 439 | attr2 = snd_hda_get_input_pin_attr(defc); | ||
| 440 | if (attr2 >= INPUT_PIN_ATTR_NORMAL) { | ||
| 441 | if (attr && attr != attr2) | ||
| 442 | return 1; /* different locations found */ | ||
| 443 | attr = attr2; | ||
| 444 | } | ||
| 445 | } | ||
| 446 | return 0; | ||
| 447 | } | ||
| 448 | |||
| 449 | /** | ||
| 450 | * hda_get_autocfg_input_label - Get a label for the given input | ||
| 451 | * | ||
| 452 | * Get a label for the given input pin defined by the autocfg item. | ||
| 453 | * Unlike hda_get_input_pin_label(), this function checks all inputs | ||
| 454 | * defined in autocfg and avoids the redundant mic/line prefix as much as | ||
| 455 | * possible. | ||
| 456 | */ | ||
| 457 | const char *hda_get_autocfg_input_label(struct hda_codec *codec, | ||
| 458 | const struct auto_pin_cfg *cfg, | ||
| 459 | int input) | ||
| 460 | { | ||
| 461 | int type = cfg->inputs[input].type; | ||
| 462 | int has_multiple_pins = 0; | ||
| 463 | |||
| 464 | if ((input > 0 && cfg->inputs[input - 1].type == type) || | ||
| 465 | (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) | ||
| 466 | has_multiple_pins = 1; | ||
| 467 | if (has_multiple_pins && type == AUTO_PIN_MIC) | ||
| 468 | has_multiple_pins &= check_mic_location_need(codec, cfg, input); | ||
| 469 | return hda_get_input_pin_label(codec, cfg->inputs[input].pin, | ||
| 470 | has_multiple_pins); | ||
| 471 | } | ||
| 472 | EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); | ||
| 473 | |||
| 474 | /* return the position of NID in the list, or -1 if not found */ | ||
| 475 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) | ||
| 476 | { | ||
| 477 | int i; | ||
| 478 | for (i = 0; i < nums; i++) | ||
| 479 | if (list[i] == nid) | ||
| 480 | return i; | ||
| 481 | return -1; | ||
| 482 | } | ||
| 483 | |||
| 484 | /* get a unique suffix or an index number */ | ||
| 485 | static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, | ||
| 486 | int num_pins, int *indexp) | ||
| 487 | { | ||
| 488 | static const char * const channel_sfx[] = { | ||
| 489 | " Front", " Surround", " CLFE", " Side" | ||
| 490 | }; | ||
| 491 | int i; | ||
| 492 | |||
| 493 | i = find_idx_in_nid_list(nid, pins, num_pins); | ||
| 494 | if (i < 0) | ||
| 495 | return NULL; | ||
| 496 | if (num_pins == 1) | ||
| 497 | return ""; | ||
| 498 | if (num_pins > ARRAY_SIZE(channel_sfx)) { | ||
| 499 | if (indexp) | ||
| 500 | *indexp = i; | ||
| 501 | return ""; | ||
| 502 | } | ||
| 503 | return channel_sfx[i]; | ||
| 504 | } | ||
| 505 | |||
| 506 | static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, | ||
| 507 | const struct auto_pin_cfg *cfg, | ||
| 508 | const char *name, char *label, int maxlen, | ||
| 509 | int *indexp) | ||
| 510 | { | ||
| 511 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 512 | int attr = snd_hda_get_input_pin_attr(def_conf); | ||
| 513 | const char *pfx = "", *sfx = ""; | ||
| 514 | |||
| 515 | /* handle as a speaker if it's a fixed line-out */ | ||
| 516 | if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT) | ||
| 517 | name = "Speaker"; | ||
| 518 | /* check the location */ | ||
| 519 | switch (attr) { | ||
| 520 | case INPUT_PIN_ATTR_DOCK: | ||
| 521 | pfx = "Dock "; | ||
| 522 | break; | ||
| 523 | case INPUT_PIN_ATTR_FRONT: | ||
| 524 | pfx = "Front "; | ||
| 525 | break; | ||
| 526 | } | ||
| 527 | if (cfg) { | ||
| 528 | /* try to give a unique suffix if needed */ | ||
| 529 | sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, | ||
| 530 | indexp); | ||
| 531 | if (!sfx) | ||
| 532 | sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, | ||
| 533 | indexp); | ||
| 534 | if (!sfx) { | ||
| 535 | /* don't add channel suffix for Headphone controls */ | ||
| 536 | int idx = find_idx_in_nid_list(nid, cfg->hp_pins, | ||
| 537 | cfg->hp_outs); | ||
| 538 | if (idx >= 0) | ||
| 539 | *indexp = idx; | ||
| 540 | sfx = ""; | ||
| 541 | } | ||
| 542 | } | ||
| 543 | snprintf(label, maxlen, "%s%s%s", pfx, name, sfx); | ||
| 544 | return 1; | ||
| 545 | } | ||
| 546 | |||
| 547 | /** | ||
| 548 | * snd_hda_get_pin_label - Get a label for the given I/O pin | ||
| 549 | * | ||
| 550 | * Get a label for the given pin. This function works for both input and | ||
| 551 | * output pins. When @cfg is given as non-NULL, the function tries to get | ||
| 552 | * an optimized label using hda_get_autocfg_input_label(). | ||
| 553 | * | ||
| 554 | * This function tries to give a unique label string for the pin as much as | ||
| 555 | * possible. For example, when the multiple line-outs are present, it adds | ||
| 556 | * the channel suffix like "Front", "Surround", etc (only when @cfg is given). | ||
| 557 | * If no unique name with a suffix is available and @indexp is non-NULL, the | ||
| 558 | * index number is stored in the pointer. | ||
| 559 | */ | ||
| 560 | int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, | ||
| 561 | const struct auto_pin_cfg *cfg, | ||
| 562 | char *label, int maxlen, int *indexp) | ||
| 563 | { | ||
| 564 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 565 | const char *name = NULL; | ||
| 566 | int i; | ||
| 567 | |||
| 568 | if (indexp) | ||
| 569 | *indexp = 0; | ||
| 570 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | ||
| 571 | return 0; | ||
| 572 | |||
| 573 | switch (get_defcfg_device(def_conf)) { | ||
| 574 | case AC_JACK_LINE_OUT: | ||
| 575 | return fill_audio_out_name(codec, nid, cfg, "Line Out", | ||
| 576 | label, maxlen, indexp); | ||
| 577 | case AC_JACK_SPEAKER: | ||
| 578 | return fill_audio_out_name(codec, nid, cfg, "Speaker", | ||
| 579 | label, maxlen, indexp); | ||
| 580 | case AC_JACK_HP_OUT: | ||
| 581 | return fill_audio_out_name(codec, nid, cfg, "Headphone", | ||
| 582 | label, maxlen, indexp); | ||
| 583 | case AC_JACK_SPDIF_OUT: | ||
| 584 | case AC_JACK_DIG_OTHER_OUT: | ||
| 585 | if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI) | ||
| 586 | name = "HDMI"; | ||
| 587 | else | ||
| 588 | name = "SPDIF"; | ||
| 589 | if (cfg && indexp) { | ||
| 590 | i = find_idx_in_nid_list(nid, cfg->dig_out_pins, | ||
| 591 | cfg->dig_outs); | ||
| 592 | if (i >= 0) | ||
| 593 | *indexp = i; | ||
| 594 | } | ||
| 595 | break; | ||
| 596 | default: | ||
| 597 | if (cfg) { | ||
| 598 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 599 | if (cfg->inputs[i].pin != nid) | ||
| 600 | continue; | ||
| 601 | name = hda_get_autocfg_input_label(codec, cfg, i); | ||
| 602 | if (name) | ||
| 603 | break; | ||
| 604 | } | ||
| 605 | } | ||
| 606 | if (!name) | ||
| 607 | name = hda_get_input_pin_label(codec, nid, true); | ||
| 608 | break; | ||
| 609 | } | ||
| 610 | if (!name) | ||
| 611 | return 0; | ||
| 612 | strlcpy(label, name, maxlen); | ||
| 613 | return 1; | ||
| 614 | } | ||
| 615 | EXPORT_SYMBOL_HDA(snd_hda_get_pin_label); | ||
| 616 | |||
| 617 | int snd_hda_gen_add_verbs(struct hda_gen_spec *spec, | ||
| 618 | const struct hda_verb *list) | ||
| 619 | { | ||
| 620 | const struct hda_verb **v; | ||
| 621 | snd_array_init(&spec->verbs, sizeof(struct hda_verb *), 8); | ||
| 622 | v = snd_array_new(&spec->verbs); | ||
| 623 | if (!v) | ||
| 624 | return -ENOMEM; | ||
| 625 | *v = list; | ||
| 626 | return 0; | ||
| 627 | } | ||
| 628 | EXPORT_SYMBOL_HDA(snd_hda_gen_add_verbs); | ||
| 629 | |||
| 630 | void snd_hda_gen_apply_verbs(struct hda_codec *codec) | ||
| 631 | { | ||
| 632 | struct hda_gen_spec *spec = codec->spec; | ||
| 633 | int i; | ||
| 634 | for (i = 0; i < spec->verbs.used; i++) { | ||
| 635 | struct hda_verb **v = snd_array_elem(&spec->verbs, i); | ||
| 636 | snd_hda_sequence_write(codec, *v); | ||
| 637 | } | ||
| 638 | } | ||
| 639 | EXPORT_SYMBOL_HDA(snd_hda_gen_apply_verbs); | ||
| 640 | |||
| 641 | void snd_hda_apply_pincfgs(struct hda_codec *codec, | ||
| 642 | const struct hda_pintbl *cfg) | ||
| 643 | { | ||
| 644 | for (; cfg->nid; cfg++) | ||
| 645 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | ||
| 646 | } | ||
| 647 | EXPORT_SYMBOL_HDA(snd_hda_apply_pincfgs); | ||
| 648 | |||
| 649 | void snd_hda_apply_fixup(struct hda_codec *codec, int action) | ||
| 650 | { | ||
| 651 | struct hda_gen_spec *spec = codec->spec; | ||
| 652 | int id = spec->fixup_id; | ||
| 653 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
| 654 | const char *modelname = spec->fixup_name; | ||
| 655 | #endif | ||
| 656 | int depth = 0; | ||
| 657 | |||
| 658 | if (!spec->fixup_list) | ||
| 659 | return; | ||
| 660 | |||
| 661 | while (id >= 0) { | ||
| 662 | const struct hda_fixup *fix = spec->fixup_list + id; | ||
| 663 | |||
| 664 | switch (fix->type) { | ||
| 665 | case HDA_FIXUP_PINS: | ||
| 666 | if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins) | ||
| 667 | break; | ||
| 668 | snd_printdd(KERN_INFO SFX | ||
| 669 | "%s: Apply pincfg for %s\n", | ||
| 670 | codec->chip_name, modelname); | ||
| 671 | snd_hda_apply_pincfgs(codec, fix->v.pins); | ||
| 672 | break; | ||
| 673 | case HDA_FIXUP_VERBS: | ||
| 674 | if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs) | ||
| 675 | break; | ||
| 676 | snd_printdd(KERN_INFO SFX | ||
| 677 | "%s: Apply fix-verbs for %s\n", | ||
| 678 | codec->chip_name, modelname); | ||
| 679 | snd_hda_gen_add_verbs(codec->spec, fix->v.verbs); | ||
| 680 | break; | ||
| 681 | case HDA_FIXUP_FUNC: | ||
| 682 | if (!fix->v.func) | ||
| 683 | break; | ||
| 684 | snd_printdd(KERN_INFO SFX | ||
| 685 | "%s: Apply fix-func for %s\n", | ||
| 686 | codec->chip_name, modelname); | ||
| 687 | fix->v.func(codec, fix, action); | ||
| 688 | break; | ||
| 689 | default: | ||
| 690 | snd_printk(KERN_ERR SFX | ||
| 691 | "%s: Invalid fixup type %d\n", | ||
| 692 | codec->chip_name, fix->type); | ||
| 693 | break; | ||
| 694 | } | ||
| 695 | if (!fix->chained) | ||
| 696 | break; | ||
| 697 | if (++depth > 10) | ||
| 698 | break; | ||
| 699 | id = fix->chain_id; | ||
| 700 | } | ||
| 701 | } | ||
| 702 | EXPORT_SYMBOL_HDA(snd_hda_apply_fixup); | ||
| 703 | |||
| 704 | void snd_hda_pick_fixup(struct hda_codec *codec, | ||
| 705 | const struct hda_model_fixup *models, | ||
| 706 | const struct snd_pci_quirk *quirk, | ||
| 707 | const struct hda_fixup *fixlist) | ||
| 708 | { | ||
| 709 | struct hda_gen_spec *spec = codec->spec; | ||
| 710 | const struct snd_pci_quirk *q; | ||
| 711 | int id = -1; | ||
| 712 | const char *name = NULL; | ||
| 713 | |||
| 714 | /* when model=nofixup is given, don't pick up any fixups */ | ||
| 715 | if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { | ||
| 716 | spec->fixup_list = NULL; | ||
| 717 | spec->fixup_id = -1; | ||
| 718 | return; | ||
| 719 | } | ||
| 720 | |||
| 721 | if (codec->modelname && models) { | ||
| 722 | while (models->name) { | ||
| 723 | if (!strcmp(codec->modelname, models->name)) { | ||
| 724 | id = models->id; | ||
| 725 | name = models->name; | ||
| 726 | break; | ||
| 727 | } | ||
| 728 | models++; | ||
| 729 | } | ||
| 730 | } | ||
| 731 | if (id < 0) { | ||
| 732 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); | ||
| 733 | if (q) { | ||
| 734 | id = q->value; | ||
| 735 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
| 736 | name = q->name; | ||
| 737 | #endif | ||
| 738 | } | ||
| 739 | } | ||
| 740 | if (id < 0) { | ||
| 741 | for (q = quirk; q->subvendor; q++) { | ||
| 742 | unsigned int vendorid = | ||
| 743 | q->subdevice | (q->subvendor << 16); | ||
| 744 | if (vendorid == codec->subsystem_id) { | ||
| 745 | id = q->value; | ||
| 746 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
| 747 | name = q->name; | ||
| 748 | #endif | ||
| 749 | break; | ||
| 750 | } | ||
| 751 | } | ||
| 752 | } | ||
| 753 | |||
| 754 | spec->fixup_id = id; | ||
| 755 | if (id >= 0) { | ||
| 756 | spec->fixup_list = fixlist; | ||
| 757 | spec->fixup_name = name; | ||
| 758 | } | ||
| 759 | } | ||
| 760 | EXPORT_SYMBOL_HDA(snd_hda_pick_fixup); | ||
diff --git a/sound/pci/hda/hda_auto_parser.h b/sound/pci/hda/hda_auto_parser.h new file mode 100644 index 000000000000..2a7889dfbd1b --- /dev/null +++ b/sound/pci/hda/hda_auto_parser.h | |||
| @@ -0,0 +1,160 @@ | |||
| 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 | #ifndef __SOUND_HDA_AUTO_PARSER_H | ||
| 13 | #define __SOUND_HDA_AUTO_PARSER_H | ||
| 14 | |||
| 15 | /* | ||
| 16 | * Helper for automatic pin configuration | ||
| 17 | */ | ||
| 18 | |||
| 19 | enum { | ||
| 20 | AUTO_PIN_MIC, | ||
| 21 | AUTO_PIN_LINE_IN, | ||
| 22 | AUTO_PIN_CD, | ||
| 23 | AUTO_PIN_AUX, | ||
| 24 | AUTO_PIN_LAST | ||
| 25 | }; | ||
| 26 | |||
| 27 | enum { | ||
| 28 | AUTO_PIN_LINE_OUT, | ||
| 29 | AUTO_PIN_SPEAKER_OUT, | ||
| 30 | AUTO_PIN_HP_OUT | ||
| 31 | }; | ||
| 32 | |||
| 33 | #define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS | ||
| 34 | #define AUTO_CFG_MAX_INS 8 | ||
| 35 | |||
| 36 | struct auto_pin_cfg_item { | ||
| 37 | hda_nid_t pin; | ||
| 38 | int type; | ||
| 39 | }; | ||
| 40 | |||
| 41 | struct auto_pin_cfg; | ||
| 42 | const char *hda_get_autocfg_input_label(struct hda_codec *codec, | ||
| 43 | const struct auto_pin_cfg *cfg, | ||
| 44 | int input); | ||
| 45 | int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, | ||
| 46 | const struct auto_pin_cfg *cfg, | ||
| 47 | char *label, int maxlen, int *indexp); | ||
| 48 | |||
| 49 | enum { | ||
| 50 | INPUT_PIN_ATTR_UNUSED, /* pin not connected */ | ||
| 51 | INPUT_PIN_ATTR_INT, /* internal mic/line-in */ | ||
| 52 | INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ | ||
| 53 | INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ | ||
| 54 | INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ | ||
| 55 | INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ | ||
| 56 | }; | ||
| 57 | |||
| 58 | int snd_hda_get_input_pin_attr(unsigned int def_conf); | ||
| 59 | |||
| 60 | struct auto_pin_cfg { | ||
| 61 | int line_outs; | ||
| 62 | /* sorted in the order of Front/Surr/CLFE/Side */ | ||
| 63 | hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS]; | ||
| 64 | int speaker_outs; | ||
| 65 | hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS]; | ||
| 66 | int hp_outs; | ||
| 67 | int line_out_type; /* AUTO_PIN_XXX_OUT */ | ||
| 68 | hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; | ||
| 69 | int num_inputs; | ||
| 70 | struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; | ||
| 71 | int dig_outs; | ||
| 72 | hda_nid_t dig_out_pins[2]; | ||
| 73 | hda_nid_t dig_in_pin; | ||
| 74 | hda_nid_t mono_out_pin; | ||
| 75 | int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */ | ||
| 76 | int dig_in_type; /* HDA_PCM_TYPE_XXX */ | ||
| 77 | }; | ||
| 78 | |||
| 79 | /* bit-flags for snd_hda_parse_pin_def_config() behavior */ | ||
| 80 | #define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ | ||
| 81 | #define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ | ||
| 82 | |||
| 83 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | ||
| 84 | struct auto_pin_cfg *cfg, | ||
| 85 | const hda_nid_t *ignore_nids, | ||
| 86 | unsigned int cond_flags); | ||
| 87 | |||
| 88 | /* older function */ | ||
| 89 | #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ | ||
| 90 | snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) | ||
| 91 | |||
| 92 | /* | ||
| 93 | */ | ||
| 94 | |||
| 95 | struct hda_gen_spec { | ||
| 96 | /* fix-up list */ | ||
| 97 | int fixup_id; | ||
| 98 | const struct hda_fixup *fixup_list; | ||
| 99 | const char *fixup_name; | ||
| 100 | |||
| 101 | /* additional init verbs */ | ||
| 102 | struct snd_array verbs; | ||
| 103 | }; | ||
| 104 | |||
| 105 | |||
| 106 | /* | ||
| 107 | * Fix-up pin default configurations and add default verbs | ||
| 108 | */ | ||
| 109 | |||
| 110 | struct hda_pintbl { | ||
| 111 | hda_nid_t nid; | ||
| 112 | u32 val; | ||
| 113 | }; | ||
| 114 | |||
| 115 | struct hda_model_fixup { | ||
| 116 | const int id; | ||
| 117 | const char *name; | ||
| 118 | }; | ||
| 119 | |||
| 120 | struct hda_fixup { | ||
| 121 | int type; | ||
| 122 | bool chained; | ||
| 123 | int chain_id; | ||
| 124 | union { | ||
| 125 | const struct hda_pintbl *pins; | ||
| 126 | const struct hda_verb *verbs; | ||
| 127 | void (*func)(struct hda_codec *codec, | ||
| 128 | const struct hda_fixup *fix, | ||
| 129 | int action); | ||
| 130 | } v; | ||
| 131 | }; | ||
| 132 | |||
| 133 | /* fixup types */ | ||
| 134 | enum { | ||
| 135 | HDA_FIXUP_INVALID, | ||
| 136 | HDA_FIXUP_PINS, | ||
| 137 | HDA_FIXUP_VERBS, | ||
| 138 | HDA_FIXUP_FUNC, | ||
| 139 | }; | ||
| 140 | |||
| 141 | /* fixup action definitions */ | ||
| 142 | enum { | ||
| 143 | HDA_FIXUP_ACT_PRE_PROBE, | ||
| 144 | HDA_FIXUP_ACT_PROBE, | ||
| 145 | HDA_FIXUP_ACT_INIT, | ||
| 146 | HDA_FIXUP_ACT_BUILD, | ||
| 147 | }; | ||
| 148 | |||
| 149 | int snd_hda_gen_add_verbs(struct hda_gen_spec *spec, | ||
| 150 | const struct hda_verb *list); | ||
| 151 | void snd_hda_gen_apply_verbs(struct hda_codec *codec); | ||
| 152 | void snd_hda_apply_pincfgs(struct hda_codec *codec, | ||
| 153 | const struct hda_pintbl *cfg); | ||
| 154 | void snd_hda_apply_fixup(struct hda_codec *codec, int action); | ||
| 155 | void snd_hda_pick_fixup(struct hda_codec *codec, | ||
| 156 | const struct hda_model_fixup *models, | ||
| 157 | const struct snd_pci_quirk *quirk, | ||
| 158 | const struct hda_fixup *fixlist); | ||
| 159 | |||
| 160 | #endif /* __SOUND_HDA_AUTO_PARSER_H */ | ||
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 7a8fcc4c15f8..c556fe1c25eb 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
| @@ -1255,6 +1255,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, | |||
| 1255 | codec->addr = codec_addr; | 1255 | codec->addr = codec_addr; |
| 1256 | mutex_init(&codec->spdif_mutex); | 1256 | mutex_init(&codec->spdif_mutex); |
| 1257 | mutex_init(&codec->control_mutex); | 1257 | mutex_init(&codec->control_mutex); |
| 1258 | mutex_init(&codec->hash_mutex); | ||
| 1258 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | 1259 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); |
| 1259 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | 1260 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); |
| 1260 | snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); | 1261 | snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); |
| @@ -1264,15 +1265,9 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, | |||
| 1264 | snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); | 1265 | snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); |
| 1265 | snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); | 1266 | snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); |
| 1266 | snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); | 1267 | snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); |
| 1267 | if (codec->bus->modelname) { | ||
| 1268 | codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); | ||
| 1269 | if (!codec->modelname) { | ||
| 1270 | snd_hda_codec_free(codec); | ||
| 1271 | return -ENODEV; | ||
| 1272 | } | ||
| 1273 | } | ||
| 1274 | 1268 | ||
| 1275 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 1269 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1270 | spin_lock_init(&codec->power_lock); | ||
| 1276 | INIT_DELAYED_WORK(&codec->power_work, hda_power_work); | 1271 | INIT_DELAYED_WORK(&codec->power_work, hda_power_work); |
| 1277 | /* snd_hda_codec_new() marks the codec as power-up, and leave it as is. | 1272 | /* snd_hda_codec_new() marks the codec as power-up, and leave it as is. |
| 1278 | * the caller has to power down appropriatley after initialization | 1273 | * the caller has to power down appropriatley after initialization |
| @@ -1281,6 +1276,14 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, | |||
| 1281 | hda_keep_power_on(codec); | 1276 | hda_keep_power_on(codec); |
| 1282 | #endif | 1277 | #endif |
| 1283 | 1278 | ||
| 1279 | if (codec->bus->modelname) { | ||
| 1280 | codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); | ||
| 1281 | if (!codec->modelname) { | ||
| 1282 | snd_hda_codec_free(codec); | ||
| 1283 | return -ENODEV; | ||
| 1284 | } | ||
| 1285 | } | ||
| 1286 | |||
| 1284 | list_add_tail(&codec->list, &bus->codec_list); | 1287 | list_add_tail(&codec->list, &bus->codec_list); |
| 1285 | bus->caddr_tbl[codec_addr] = codec; | 1288 | bus->caddr_tbl[codec_addr] = codec; |
| 1286 | 1289 | ||
| @@ -1603,6 +1606,60 @@ get_alloc_amp_hash(struct hda_codec *codec, u32 key) | |||
| 1603 | return (struct hda_amp_info *)get_alloc_hash(&codec->amp_cache, key); | 1606 | return (struct hda_amp_info *)get_alloc_hash(&codec->amp_cache, key); |
| 1604 | } | 1607 | } |
| 1605 | 1608 | ||
| 1609 | /* overwrite the value with the key in the caps hash */ | ||
| 1610 | static int write_caps_hash(struct hda_codec *codec, u32 key, unsigned int val) | ||
| 1611 | { | ||
| 1612 | struct hda_amp_info *info; | ||
| 1613 | |||
| 1614 | mutex_lock(&codec->hash_mutex); | ||
| 1615 | info = get_alloc_amp_hash(codec, key); | ||
| 1616 | if (!info) { | ||
| 1617 | mutex_unlock(&codec->hash_mutex); | ||
| 1618 | return -EINVAL; | ||
| 1619 | } | ||
| 1620 | info->amp_caps = val; | ||
| 1621 | info->head.val |= INFO_AMP_CAPS; | ||
| 1622 | mutex_unlock(&codec->hash_mutex); | ||
| 1623 | return 0; | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | /* query the value from the caps hash; if not found, fetch the current | ||
| 1627 | * value from the given function and store in the hash | ||
| 1628 | */ | ||
| 1629 | static unsigned int | ||
| 1630 | query_caps_hash(struct hda_codec *codec, hda_nid_t nid, int dir, u32 key, | ||
| 1631 | unsigned int (*func)(struct hda_codec *, hda_nid_t, int)) | ||
| 1632 | { | ||
| 1633 | struct hda_amp_info *info; | ||
| 1634 | unsigned int val; | ||
| 1635 | |||
| 1636 | mutex_lock(&codec->hash_mutex); | ||
| 1637 | info = get_alloc_amp_hash(codec, key); | ||
| 1638 | if (!info) { | ||
| 1639 | mutex_unlock(&codec->hash_mutex); | ||
| 1640 | return 0; | ||
| 1641 | } | ||
| 1642 | if (!(info->head.val & INFO_AMP_CAPS)) { | ||
| 1643 | mutex_unlock(&codec->hash_mutex); /* for reentrance */ | ||
| 1644 | val = func(codec, nid, dir); | ||
| 1645 | write_caps_hash(codec, key, val); | ||
| 1646 | } else { | ||
| 1647 | val = info->amp_caps; | ||
| 1648 | mutex_unlock(&codec->hash_mutex); | ||
| 1649 | } | ||
| 1650 | return val; | ||
| 1651 | } | ||
| 1652 | |||
| 1653 | static unsigned int read_amp_cap(struct hda_codec *codec, hda_nid_t nid, | ||
| 1654 | int direction) | ||
| 1655 | { | ||
| 1656 | if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) | ||
| 1657 | nid = codec->afg; | ||
| 1658 | return snd_hda_param_read(codec, nid, | ||
| 1659 | direction == HDA_OUTPUT ? | ||
| 1660 | AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); | ||
| 1661 | } | ||
| 1662 | |||
| 1606 | /** | 1663 | /** |
| 1607 | * query_amp_caps - query AMP capabilities | 1664 | * query_amp_caps - query AMP capabilities |
| 1608 | * @codec: the HD-auio codec | 1665 | * @codec: the HD-auio codec |
| @@ -1617,22 +1674,9 @@ get_alloc_amp_hash(struct hda_codec *codec, u32 key) | |||
| 1617 | */ | 1674 | */ |
| 1618 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) | 1675 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) |
| 1619 | { | 1676 | { |
| 1620 | struct hda_amp_info *info; | 1677 | return query_caps_hash(codec, nid, direction, |
| 1621 | 1678 | HDA_HASH_KEY(nid, direction, 0), | |
| 1622 | info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0)); | 1679 | read_amp_cap); |
| 1623 | if (!info) | ||
| 1624 | return 0; | ||
| 1625 | if (!(info->head.val & INFO_AMP_CAPS)) { | ||
| 1626 | if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) | ||
| 1627 | nid = codec->afg; | ||
| 1628 | info->amp_caps = snd_hda_param_read(codec, nid, | ||
| 1629 | direction == HDA_OUTPUT ? | ||
| 1630 | AC_PAR_AMP_OUT_CAP : | ||
| 1631 | AC_PAR_AMP_IN_CAP); | ||
| 1632 | if (info->amp_caps) | ||
| 1633 | info->head.val |= INFO_AMP_CAPS; | ||
| 1634 | } | ||
| 1635 | return info->amp_caps; | ||
| 1636 | } | 1680 | } |
| 1637 | EXPORT_SYMBOL_HDA(query_amp_caps); | 1681 | EXPORT_SYMBOL_HDA(query_amp_caps); |
| 1638 | 1682 | ||
| @@ -1652,34 +1696,12 @@ EXPORT_SYMBOL_HDA(query_amp_caps); | |||
| 1652 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, | 1696 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 1653 | unsigned int caps) | 1697 | unsigned int caps) |
| 1654 | { | 1698 | { |
| 1655 | struct hda_amp_info *info; | 1699 | return write_caps_hash(codec, HDA_HASH_KEY(nid, dir, 0), caps); |
| 1656 | |||
| 1657 | info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, dir, 0)); | ||
| 1658 | if (!info) | ||
| 1659 | return -EINVAL; | ||
| 1660 | info->amp_caps = caps; | ||
| 1661 | info->head.val |= INFO_AMP_CAPS; | ||
| 1662 | return 0; | ||
| 1663 | } | 1700 | } |
| 1664 | EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps); | 1701 | EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps); |
| 1665 | 1702 | ||
| 1666 | static unsigned int | 1703 | static unsigned int read_pin_cap(struct hda_codec *codec, hda_nid_t nid, |
| 1667 | query_caps_hash(struct hda_codec *codec, hda_nid_t nid, u32 key, | 1704 | int dir) |
| 1668 | unsigned int (*func)(struct hda_codec *, hda_nid_t)) | ||
| 1669 | { | ||
| 1670 | struct hda_amp_info *info; | ||
| 1671 | |||
| 1672 | info = get_alloc_amp_hash(codec, key); | ||
| 1673 | if (!info) | ||
| 1674 | return 0; | ||
| 1675 | if (!info->head.val) { | ||
| 1676 | info->head.val |= INFO_AMP_CAPS; | ||
| 1677 | info->amp_caps = func(codec, nid); | ||
| 1678 | } | ||
| 1679 | return info->amp_caps; | ||
| 1680 | } | ||
| 1681 | |||
| 1682 | static unsigned int read_pin_cap(struct hda_codec *codec, hda_nid_t nid) | ||
| 1683 | { | 1705 | { |
| 1684 | return snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | 1706 | return snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
| 1685 | } | 1707 | } |
| @@ -1697,7 +1719,7 @@ static unsigned int read_pin_cap(struct hda_codec *codec, hda_nid_t nid) | |||
| 1697 | */ | 1719 | */ |
| 1698 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) | 1720 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) |
| 1699 | { | 1721 | { |
| 1700 | return query_caps_hash(codec, nid, HDA_HASH_PINCAP_KEY(nid), | 1722 | return query_caps_hash(codec, nid, 0, HDA_HASH_PINCAP_KEY(nid), |
| 1701 | read_pin_cap); | 1723 | read_pin_cap); |
| 1702 | } | 1724 | } |
| 1703 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); | 1725 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); |
| @@ -1715,41 +1737,47 @@ EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); | |||
| 1715 | int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid, | 1737 | int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid, |
| 1716 | unsigned int caps) | 1738 | unsigned int caps) |
| 1717 | { | 1739 | { |
| 1718 | struct hda_amp_info *info; | 1740 | return write_caps_hash(codec, HDA_HASH_PINCAP_KEY(nid), caps); |
| 1719 | info = get_alloc_amp_hash(codec, HDA_HASH_PINCAP_KEY(nid)); | ||
| 1720 | if (!info) | ||
| 1721 | return -ENOMEM; | ||
| 1722 | info->amp_caps = caps; | ||
| 1723 | info->head.val |= INFO_AMP_CAPS; | ||
| 1724 | return 0; | ||
| 1725 | } | 1741 | } |
| 1726 | EXPORT_SYMBOL_HDA(snd_hda_override_pin_caps); | 1742 | EXPORT_SYMBOL_HDA(snd_hda_override_pin_caps); |
| 1727 | 1743 | ||
| 1728 | /* | 1744 | /* read or sync the hash value with the current value; |
| 1729 | * read the current volume to info | 1745 | * call within hash_mutex |
| 1730 | * if the cache exists, read the cache value. | ||
| 1731 | */ | 1746 | */ |
| 1732 | static unsigned int get_vol_mute(struct hda_codec *codec, | 1747 | static struct hda_amp_info * |
| 1733 | struct hda_amp_info *info, hda_nid_t nid, | 1748 | update_amp_hash(struct hda_codec *codec, hda_nid_t nid, int ch, |
| 1734 | int ch, int direction, int index) | 1749 | int direction, int index) |
| 1735 | { | 1750 | { |
| 1736 | u32 val, parm; | 1751 | struct hda_amp_info *info; |
| 1737 | 1752 | unsigned int parm, val = 0; | |
| 1738 | if (info->head.val & INFO_AMP_VOL(ch)) | 1753 | bool val_read = false; |
| 1739 | return info->vol[ch]; | ||
| 1740 | 1754 | ||
| 1741 | parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; | 1755 | retry: |
| 1742 | parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; | 1756 | info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); |
| 1743 | parm |= index; | 1757 | if (!info) |
| 1744 | val = snd_hda_codec_read(codec, nid, 0, | 1758 | return NULL; |
| 1759 | if (!(info->head.val & INFO_AMP_VOL(ch))) { | ||
| 1760 | if (!val_read) { | ||
| 1761 | mutex_unlock(&codec->hash_mutex); | ||
| 1762 | parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; | ||
| 1763 | parm |= direction == HDA_OUTPUT ? | ||
| 1764 | AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; | ||
| 1765 | parm |= index; | ||
| 1766 | val = snd_hda_codec_read(codec, nid, 0, | ||
| 1745 | AC_VERB_GET_AMP_GAIN_MUTE, parm); | 1767 | AC_VERB_GET_AMP_GAIN_MUTE, parm); |
| 1746 | info->vol[ch] = val & 0xff; | 1768 | val &= 0xff; |
| 1747 | info->head.val |= INFO_AMP_VOL(ch); | 1769 | val_read = true; |
| 1748 | return info->vol[ch]; | 1770 | mutex_lock(&codec->hash_mutex); |
| 1771 | goto retry; | ||
| 1772 | } | ||
| 1773 | info->vol[ch] = val; | ||
| 1774 | info->head.val |= INFO_AMP_VOL(ch); | ||
| 1775 | } | ||
| 1776 | return info; | ||
| 1749 | } | 1777 | } |
| 1750 | 1778 | ||
| 1751 | /* | 1779 | /* |
| 1752 | * write the current volume in info to the h/w and update the cache | 1780 | * write the current volume in info to the h/w |
| 1753 | */ | 1781 | */ |
| 1754 | static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, | 1782 | static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, |
| 1755 | hda_nid_t nid, int ch, int direction, int index, | 1783 | hda_nid_t nid, int ch, int direction, int index, |
| @@ -1766,7 +1794,6 @@ static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, | |||
| 1766 | else | 1794 | else |
| 1767 | parm |= val; | 1795 | parm |= val; |
| 1768 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm); | 1796 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm); |
| 1769 | info->vol[ch] = val; | ||
| 1770 | } | 1797 | } |
| 1771 | 1798 | ||
| 1772 | /** | 1799 | /** |
| @@ -1783,10 +1810,14 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, | |||
| 1783 | int direction, int index) | 1810 | int direction, int index) |
| 1784 | { | 1811 | { |
| 1785 | struct hda_amp_info *info; | 1812 | struct hda_amp_info *info; |
| 1786 | info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); | 1813 | unsigned int val = 0; |
| 1787 | if (!info) | 1814 | |
| 1788 | return 0; | 1815 | mutex_lock(&codec->hash_mutex); |
| 1789 | return get_vol_mute(codec, info, nid, ch, direction, index); | 1816 | info = update_amp_hash(codec, nid, ch, direction, index); |
| 1817 | if (info) | ||
| 1818 | val = info->vol[ch]; | ||
| 1819 | mutex_unlock(&codec->hash_mutex); | ||
| 1820 | return val; | ||
| 1790 | } | 1821 | } |
| 1791 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read); | 1822 | EXPORT_SYMBOL_HDA(snd_hda_codec_amp_read); |
| 1792 | 1823 | ||
| @@ -1808,15 +1839,23 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, | |||
| 1808 | { | 1839 | { |
| 1809 | struct hda_amp_info *info; | 1840 | struct hda_amp_info *info; |
| 1810 | 1841 | ||
| 1811 | info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); | ||
| 1812 | if (!info) | ||
| 1813 | return 0; | ||
| 1814 | if (snd_BUG_ON(mask & ~0xff)) | 1842 | if (snd_BUG_ON(mask & ~0xff)) |
| 1815 | mask &= 0xff; | 1843 | mask &= 0xff; |
| 1816 | val &= mask; | 1844 | val &= mask; |
| 1817 | val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; | 1845 | |
| 1818 | if (info->vol[ch] == val) | 1846 | mutex_lock(&codec->hash_mutex); |
| 1847 | info = update_amp_hash(codec, nid, ch, direction, idx); | ||
| 1848 | if (!info) { | ||
| 1849 | mutex_unlock(&codec->hash_mutex); | ||
| 1850 | return 0; | ||
| 1851 | } | ||
| 1852 | val |= info->vol[ch] & ~mask; | ||
| 1853 | if (info->vol[ch] == val) { | ||
| 1854 | mutex_unlock(&codec->hash_mutex); | ||
| 1819 | return 0; | 1855 | return 0; |
| 1856 | } | ||
| 1857 | info->vol[ch] = val; | ||
| 1858 | mutex_unlock(&codec->hash_mutex); | ||
| 1820 | put_vol_mute(codec, info, nid, ch, direction, idx, val); | 1859 | put_vol_mute(codec, info, nid, ch, direction, idx, val); |
| 1821 | return 1; | 1860 | return 1; |
| 1822 | } | 1861 | } |
| @@ -2263,7 +2302,10 @@ int snd_hda_codec_reset(struct hda_codec *codec) | |||
| 2263 | /* OK, let it free */ | 2302 | /* OK, let it free */ |
| 2264 | 2303 | ||
| 2265 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2304 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2266 | cancel_delayed_work(&codec->power_work); | 2305 | cancel_delayed_work_sync(&codec->power_work); |
| 2306 | codec->power_on = 0; | ||
| 2307 | codec->power_transition = 0; | ||
| 2308 | codec->power_jiffies = jiffies; | ||
| 2267 | flush_workqueue(codec->bus->workq); | 2309 | flush_workqueue(codec->bus->workq); |
| 2268 | #endif | 2310 | #endif |
| 2269 | snd_hda_ctls_clear(codec); | 2311 | snd_hda_ctls_clear(codec); |
| @@ -2859,12 +2901,15 @@ static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, | |||
| 2859 | { | 2901 | { |
| 2860 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2902 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2861 | int idx = kcontrol->private_value; | 2903 | int idx = kcontrol->private_value; |
| 2862 | struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx); | 2904 | struct hda_spdif_out *spdif; |
| 2863 | 2905 | ||
| 2906 | mutex_lock(&codec->spdif_mutex); | ||
| 2907 | spdif = snd_array_elem(&codec->spdif_out, idx); | ||
| 2864 | ucontrol->value.iec958.status[0] = spdif->status & 0xff; | 2908 | ucontrol->value.iec958.status[0] = spdif->status & 0xff; |
| 2865 | ucontrol->value.iec958.status[1] = (spdif->status >> 8) & 0xff; | 2909 | ucontrol->value.iec958.status[1] = (spdif->status >> 8) & 0xff; |
| 2866 | ucontrol->value.iec958.status[2] = (spdif->status >> 16) & 0xff; | 2910 | ucontrol->value.iec958.status[2] = (spdif->status >> 16) & 0xff; |
| 2867 | ucontrol->value.iec958.status[3] = (spdif->status >> 24) & 0xff; | 2911 | ucontrol->value.iec958.status[3] = (spdif->status >> 24) & 0xff; |
| 2912 | mutex_unlock(&codec->spdif_mutex); | ||
| 2868 | 2913 | ||
| 2869 | return 0; | 2914 | return 0; |
| 2870 | } | 2915 | } |
| @@ -2950,12 +2995,14 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, | |||
| 2950 | { | 2995 | { |
| 2951 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2996 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2952 | int idx = kcontrol->private_value; | 2997 | int idx = kcontrol->private_value; |
| 2953 | struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx); | 2998 | struct hda_spdif_out *spdif; |
| 2954 | hda_nid_t nid = spdif->nid; | 2999 | hda_nid_t nid; |
| 2955 | unsigned short val; | 3000 | unsigned short val; |
| 2956 | int change; | 3001 | int change; |
| 2957 | 3002 | ||
| 2958 | mutex_lock(&codec->spdif_mutex); | 3003 | mutex_lock(&codec->spdif_mutex); |
| 3004 | spdif = snd_array_elem(&codec->spdif_out, idx); | ||
| 3005 | nid = spdif->nid; | ||
| 2959 | spdif->status = ucontrol->value.iec958.status[0] | | 3006 | spdif->status = ucontrol->value.iec958.status[0] | |
| 2960 | ((unsigned int)ucontrol->value.iec958.status[1] << 8) | | 3007 | ((unsigned int)ucontrol->value.iec958.status[1] << 8) | |
| 2961 | ((unsigned int)ucontrol->value.iec958.status[2] << 16) | | 3008 | ((unsigned int)ucontrol->value.iec958.status[2] << 16) | |
| @@ -2977,9 +3024,12 @@ static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, | |||
| 2977 | { | 3024 | { |
| 2978 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 3025 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2979 | int idx = kcontrol->private_value; | 3026 | int idx = kcontrol->private_value; |
| 2980 | struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx); | 3027 | struct hda_spdif_out *spdif; |
| 2981 | 3028 | ||
| 3029 | mutex_lock(&codec->spdif_mutex); | ||
| 3030 | spdif = snd_array_elem(&codec->spdif_out, idx); | ||
| 2982 | ucontrol->value.integer.value[0] = spdif->ctls & AC_DIG1_ENABLE; | 3031 | ucontrol->value.integer.value[0] = spdif->ctls & AC_DIG1_ENABLE; |
| 3032 | mutex_unlock(&codec->spdif_mutex); | ||
| 2983 | return 0; | 3033 | return 0; |
| 2984 | } | 3034 | } |
| 2985 | 3035 | ||
| @@ -2999,12 +3049,14 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, | |||
| 2999 | { | 3049 | { |
| 3000 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 3050 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3001 | int idx = kcontrol->private_value; | 3051 | int idx = kcontrol->private_value; |
| 3002 | struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx); | 3052 | struct hda_spdif_out *spdif; |
| 3003 | hda_nid_t nid = spdif->nid; | 3053 | hda_nid_t nid; |
| 3004 | unsigned short val; | 3054 | unsigned short val; |
| 3005 | int change; | 3055 | int change; |
| 3006 | 3056 | ||
| 3007 | mutex_lock(&codec->spdif_mutex); | 3057 | mutex_lock(&codec->spdif_mutex); |
| 3058 | spdif = snd_array_elem(&codec->spdif_out, idx); | ||
| 3059 | nid = spdif->nid; | ||
| 3008 | val = spdif->ctls & ~AC_DIG1_ENABLE; | 3060 | val = spdif->ctls & ~AC_DIG1_ENABLE; |
| 3009 | if (ucontrol->value.integer.value[0]) | 3061 | if (ucontrol->value.integer.value[0]) |
| 3010 | val |= AC_DIG1_ENABLE; | 3062 | val |= AC_DIG1_ENABLE; |
| @@ -3092,6 +3144,9 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, | |||
| 3092 | } | 3144 | } |
| 3093 | EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls); | 3145 | EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls); |
| 3094 | 3146 | ||
| 3147 | /* get the hda_spdif_out entry from the given NID | ||
| 3148 | * call within spdif_mutex lock | ||
| 3149 | */ | ||
| 3095 | struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, | 3150 | struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, |
| 3096 | hda_nid_t nid) | 3151 | hda_nid_t nid) |
| 3097 | { | 3152 | { |
| @@ -3108,9 +3163,10 @@ EXPORT_SYMBOL_HDA(snd_hda_spdif_out_of_nid); | |||
| 3108 | 3163 | ||
| 3109 | void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx) | 3164 | void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx) |
| 3110 | { | 3165 | { |
| 3111 | struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx); | 3166 | struct hda_spdif_out *spdif; |
| 3112 | 3167 | ||
| 3113 | mutex_lock(&codec->spdif_mutex); | 3168 | mutex_lock(&codec->spdif_mutex); |
| 3169 | spdif = snd_array_elem(&codec->spdif_out, idx); | ||
| 3114 | spdif->nid = (u16)-1; | 3170 | spdif->nid = (u16)-1; |
| 3115 | mutex_unlock(&codec->spdif_mutex); | 3171 | mutex_unlock(&codec->spdif_mutex); |
| 3116 | } | 3172 | } |
| @@ -3118,10 +3174,11 @@ EXPORT_SYMBOL_HDA(snd_hda_spdif_ctls_unassign); | |||
| 3118 | 3174 | ||
| 3119 | void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid) | 3175 | void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid) |
| 3120 | { | 3176 | { |
| 3121 | struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx); | 3177 | struct hda_spdif_out *spdif; |
| 3122 | unsigned short val; | 3178 | unsigned short val; |
| 3123 | 3179 | ||
| 3124 | mutex_lock(&codec->spdif_mutex); | 3180 | mutex_lock(&codec->spdif_mutex); |
| 3181 | spdif = snd_array_elem(&codec->spdif_out, idx); | ||
| 3125 | if (spdif->nid != nid) { | 3182 | if (spdif->nid != nid) { |
| 3126 | spdif->nid = nid; | 3183 | spdif->nid = nid; |
| 3127 | val = spdif->ctls; | 3184 | val = spdif->ctls; |
| @@ -3486,11 +3543,14 @@ static void hda_call_codec_suspend(struct hda_codec *codec) | |||
| 3486 | codec->afg ? codec->afg : codec->mfg, | 3543 | codec->afg ? codec->afg : codec->mfg, |
| 3487 | AC_PWRST_D3); | 3544 | AC_PWRST_D3); |
| 3488 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3545 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3489 | snd_hda_update_power_acct(codec); | ||
| 3490 | cancel_delayed_work(&codec->power_work); | 3546 | cancel_delayed_work(&codec->power_work); |
| 3547 | spin_lock(&codec->power_lock); | ||
| 3548 | snd_hda_update_power_acct(codec); | ||
| 3549 | trace_hda_power_down(codec); | ||
| 3491 | codec->power_on = 0; | 3550 | codec->power_on = 0; |
| 3492 | codec->power_transition = 0; | 3551 | codec->power_transition = 0; |
| 3493 | codec->power_jiffies = jiffies; | 3552 | codec->power_jiffies = jiffies; |
| 3553 | spin_unlock(&codec->power_lock); | ||
| 3494 | #endif | 3554 | #endif |
| 3495 | } | 3555 | } |
| 3496 | 3556 | ||
| @@ -3499,6 +3559,10 @@ static void hda_call_codec_suspend(struct hda_codec *codec) | |||
| 3499 | */ | 3559 | */ |
| 3500 | static void hda_call_codec_resume(struct hda_codec *codec) | 3560 | static void hda_call_codec_resume(struct hda_codec *codec) |
| 3501 | { | 3561 | { |
| 3562 | /* set as if powered on for avoiding re-entering the resume | ||
| 3563 | * in the resume / power-save sequence | ||
| 3564 | */ | ||
| 3565 | hda_keep_power_on(codec); | ||
| 3502 | hda_set_power_state(codec, | 3566 | hda_set_power_state(codec, |
| 3503 | codec->afg ? codec->afg : codec->mfg, | 3567 | codec->afg ? codec->afg : codec->mfg, |
| 3504 | AC_PWRST_D0); | 3568 | AC_PWRST_D0); |
| @@ -3514,6 +3578,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) | |||
| 3514 | snd_hda_codec_resume_amp(codec); | 3578 | snd_hda_codec_resume_amp(codec); |
| 3515 | snd_hda_codec_resume_cache(codec); | 3579 | snd_hda_codec_resume_cache(codec); |
| 3516 | } | 3580 | } |
| 3581 | snd_hda_power_down(codec); /* flag down before returning */ | ||
| 3517 | } | 3582 | } |
| 3518 | #endif /* CONFIG_PM */ | 3583 | #endif /* CONFIG_PM */ |
| 3519 | 3584 | ||
| @@ -3665,7 +3730,8 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, | |||
| 3665 | } | 3730 | } |
| 3666 | EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format); | 3731 | EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format); |
| 3667 | 3732 | ||
| 3668 | static unsigned int get_pcm_param(struct hda_codec *codec, hda_nid_t nid) | 3733 | static unsigned int get_pcm_param(struct hda_codec *codec, hda_nid_t nid, |
| 3734 | int dir) | ||
| 3669 | { | 3735 | { |
| 3670 | unsigned int val = 0; | 3736 | unsigned int val = 0; |
| 3671 | if (nid != codec->afg && | 3737 | if (nid != codec->afg && |
| @@ -3680,11 +3746,12 @@ static unsigned int get_pcm_param(struct hda_codec *codec, hda_nid_t nid) | |||
| 3680 | 3746 | ||
| 3681 | static unsigned int query_pcm_param(struct hda_codec *codec, hda_nid_t nid) | 3747 | static unsigned int query_pcm_param(struct hda_codec *codec, hda_nid_t nid) |
| 3682 | { | 3748 | { |
| 3683 | return query_caps_hash(codec, nid, HDA_HASH_PARPCM_KEY(nid), | 3749 | return query_caps_hash(codec, nid, 0, HDA_HASH_PARPCM_KEY(nid), |
| 3684 | get_pcm_param); | 3750 | get_pcm_param); |
| 3685 | } | 3751 | } |
| 3686 | 3752 | ||
| 3687 | static unsigned int get_stream_param(struct hda_codec *codec, hda_nid_t nid) | 3753 | static unsigned int get_stream_param(struct hda_codec *codec, hda_nid_t nid, |
| 3754 | int dir) | ||
| 3688 | { | 3755 | { |
| 3689 | unsigned int streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); | 3756 | unsigned int streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); |
| 3690 | if (!streams || streams == -1) | 3757 | if (!streams || streams == -1) |
| @@ -3696,7 +3763,7 @@ static unsigned int get_stream_param(struct hda_codec *codec, hda_nid_t nid) | |||
| 3696 | 3763 | ||
| 3697 | static unsigned int query_stream_param(struct hda_codec *codec, hda_nid_t nid) | 3764 | static unsigned int query_stream_param(struct hda_codec *codec, hda_nid_t nid) |
| 3698 | { | 3765 | { |
| 3699 | return query_caps_hash(codec, nid, HDA_HASH_PARSTR_KEY(nid), | 3766 | return query_caps_hash(codec, nid, 0, HDA_HASH_PARSTR_KEY(nid), |
| 3700 | get_stream_param); | 3767 | get_stream_param); |
| 3701 | } | 3768 | } |
| 3702 | 3769 | ||
| @@ -3775,11 +3842,13 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, | |||
| 3775 | bps = 20; | 3842 | bps = 20; |
| 3776 | } | 3843 | } |
| 3777 | } | 3844 | } |
| 3845 | #if 0 /* FIXME: CS4206 doesn't work, which is the only codec supporting float */ | ||
| 3778 | if (streams & AC_SUPFMT_FLOAT32) { | 3846 | if (streams & AC_SUPFMT_FLOAT32) { |
| 3779 | formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; | 3847 | formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; |
| 3780 | if (!bps) | 3848 | if (!bps) |
| 3781 | bps = 32; | 3849 | bps = 32; |
| 3782 | } | 3850 | } |
| 3851 | #endif | ||
| 3783 | if (streams == AC_SUPFMT_AC3) { | 3852 | if (streams == AC_SUPFMT_AC3) { |
| 3784 | /* should be exclusive */ | 3853 | /* should be exclusive */ |
| 3785 | /* temporary hack: we have still no proper support | 3854 | /* temporary hack: we have still no proper support |
| @@ -4283,12 +4352,18 @@ static void hda_power_work(struct work_struct *work) | |||
| 4283 | container_of(work, struct hda_codec, power_work.work); | 4352 | container_of(work, struct hda_codec, power_work.work); |
| 4284 | struct hda_bus *bus = codec->bus; | 4353 | struct hda_bus *bus = codec->bus; |
| 4285 | 4354 | ||
| 4355 | spin_lock(&codec->power_lock); | ||
| 4356 | if (codec->power_transition > 0) { /* during power-up sequence? */ | ||
| 4357 | spin_unlock(&codec->power_lock); | ||
| 4358 | return; | ||
| 4359 | } | ||
| 4286 | if (!codec->power_on || codec->power_count) { | 4360 | if (!codec->power_on || codec->power_count) { |
| 4287 | codec->power_transition = 0; | 4361 | codec->power_transition = 0; |
| 4362 | spin_unlock(&codec->power_lock); | ||
| 4288 | return; | 4363 | return; |
| 4289 | } | 4364 | } |
| 4365 | spin_unlock(&codec->power_lock); | ||
| 4290 | 4366 | ||
| 4291 | trace_hda_power_down(codec); | ||
| 4292 | hda_call_codec_suspend(codec); | 4367 | hda_call_codec_suspend(codec); |
| 4293 | if (bus->ops.pm_notify) | 4368 | if (bus->ops.pm_notify) |
| 4294 | bus->ops.pm_notify(bus); | 4369 | bus->ops.pm_notify(bus); |
| @@ -4296,9 +4371,11 @@ static void hda_power_work(struct work_struct *work) | |||
| 4296 | 4371 | ||
| 4297 | static void hda_keep_power_on(struct hda_codec *codec) | 4372 | static void hda_keep_power_on(struct hda_codec *codec) |
| 4298 | { | 4373 | { |
| 4374 | spin_lock(&codec->power_lock); | ||
| 4299 | codec->power_count++; | 4375 | codec->power_count++; |
| 4300 | codec->power_on = 1; | 4376 | codec->power_on = 1; |
| 4301 | codec->power_jiffies = jiffies; | 4377 | codec->power_jiffies = jiffies; |
| 4378 | spin_unlock(&codec->power_lock); | ||
| 4302 | } | 4379 | } |
| 4303 | 4380 | ||
| 4304 | /* update the power on/off account with the current jiffies */ | 4381 | /* update the power on/off account with the current jiffies */ |
| @@ -4323,19 +4400,31 @@ void snd_hda_power_up(struct hda_codec *codec) | |||
| 4323 | { | 4400 | { |
| 4324 | struct hda_bus *bus = codec->bus; | 4401 | struct hda_bus *bus = codec->bus; |
| 4325 | 4402 | ||
| 4403 | spin_lock(&codec->power_lock); | ||
| 4326 | codec->power_count++; | 4404 | codec->power_count++; |
| 4327 | if (codec->power_on || codec->power_transition) | 4405 | if (codec->power_on || codec->power_transition > 0) { |
| 4406 | spin_unlock(&codec->power_lock); | ||
| 4328 | return; | 4407 | return; |
| 4408 | } | ||
| 4409 | spin_unlock(&codec->power_lock); | ||
| 4329 | 4410 | ||
| 4411 | cancel_delayed_work_sync(&codec->power_work); | ||
| 4412 | |||
| 4413 | spin_lock(&codec->power_lock); | ||
| 4330 | trace_hda_power_up(codec); | 4414 | trace_hda_power_up(codec); |
| 4331 | snd_hda_update_power_acct(codec); | 4415 | snd_hda_update_power_acct(codec); |
| 4332 | codec->power_on = 1; | 4416 | codec->power_on = 1; |
| 4333 | codec->power_jiffies = jiffies; | 4417 | codec->power_jiffies = jiffies; |
| 4418 | codec->power_transition = 1; /* avoid reentrance */ | ||
| 4419 | spin_unlock(&codec->power_lock); | ||
| 4420 | |||
| 4334 | if (bus->ops.pm_notify) | 4421 | if (bus->ops.pm_notify) |
| 4335 | bus->ops.pm_notify(bus); | 4422 | bus->ops.pm_notify(bus); |
| 4336 | hda_call_codec_resume(codec); | 4423 | hda_call_codec_resume(codec); |
| 4337 | cancel_delayed_work(&codec->power_work); | 4424 | |
| 4425 | spin_lock(&codec->power_lock); | ||
| 4338 | codec->power_transition = 0; | 4426 | codec->power_transition = 0; |
| 4427 | spin_unlock(&codec->power_lock); | ||
| 4339 | } | 4428 | } |
| 4340 | EXPORT_SYMBOL_HDA(snd_hda_power_up); | 4429 | EXPORT_SYMBOL_HDA(snd_hda_power_up); |
| 4341 | 4430 | ||
| @@ -4351,14 +4440,18 @@ EXPORT_SYMBOL_HDA(snd_hda_power_up); | |||
| 4351 | */ | 4440 | */ |
| 4352 | void snd_hda_power_down(struct hda_codec *codec) | 4441 | void snd_hda_power_down(struct hda_codec *codec) |
| 4353 | { | 4442 | { |
| 4443 | spin_lock(&codec->power_lock); | ||
| 4354 | --codec->power_count; | 4444 | --codec->power_count; |
| 4355 | if (!codec->power_on || codec->power_count || codec->power_transition) | 4445 | if (!codec->power_on || codec->power_count || codec->power_transition) { |
| 4446 | spin_unlock(&codec->power_lock); | ||
| 4356 | return; | 4447 | return; |
| 4448 | } | ||
| 4357 | if (power_save(codec)) { | 4449 | if (power_save(codec)) { |
| 4358 | codec->power_transition = 1; /* avoid reentrance */ | 4450 | codec->power_transition = -1; /* avoid reentrance */ |
| 4359 | queue_delayed_work(codec->bus->workq, &codec->power_work, | 4451 | queue_delayed_work(codec->bus->workq, &codec->power_work, |
| 4360 | msecs_to_jiffies(power_save(codec) * 1000)); | 4452 | msecs_to_jiffies(power_save(codec) * 1000)); |
| 4361 | } | 4453 | } |
| 4454 | spin_unlock(&codec->power_lock); | ||
| 4362 | } | 4455 | } |
| 4363 | EXPORT_SYMBOL_HDA(snd_hda_power_down); | 4456 | EXPORT_SYMBOL_HDA(snd_hda_power_down); |
| 4364 | 4457 | ||
| @@ -4710,11 +4803,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, | |||
| 4710 | { | 4803 | { |
| 4711 | const hda_nid_t *nids = mout->dac_nids; | 4804 | const hda_nid_t *nids = mout->dac_nids; |
| 4712 | int chs = substream->runtime->channels; | 4805 | int chs = substream->runtime->channels; |
| 4713 | struct hda_spdif_out *spdif = | 4806 | struct hda_spdif_out *spdif; |
| 4714 | snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid); | ||
| 4715 | int i; | 4807 | int i; |
| 4716 | 4808 | ||
| 4717 | mutex_lock(&codec->spdif_mutex); | 4809 | mutex_lock(&codec->spdif_mutex); |
| 4810 | spdif = snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid); | ||
| 4718 | if (mout->dig_out_nid && mout->share_spdif && | 4811 | if (mout->dig_out_nid && mout->share_spdif && |
| 4719 | mout->dig_out_used != HDA_DIG_EXCLUSIVE) { | 4812 | mout->dig_out_used != HDA_DIG_EXCLUSIVE) { |
| 4720 | if (chs == 2 && | 4813 | if (chs == 2 && |
| @@ -4795,601 +4888,58 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, | |||
| 4795 | } | 4888 | } |
| 4796 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup); | 4889 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup); |
| 4797 | 4890 | ||
| 4798 | /* | ||
| 4799 | * Helper for automatic pin configuration | ||
| 4800 | */ | ||
| 4801 | |||
| 4802 | static int is_in_nid_list(hda_nid_t nid, const hda_nid_t *list) | ||
| 4803 | { | ||
| 4804 | for (; *list; list++) | ||
| 4805 | if (*list == nid) | ||
| 4806 | return 1; | ||
| 4807 | return 0; | ||
| 4808 | } | ||
| 4809 | |||
| 4810 | |||
| 4811 | /* | ||
| 4812 | * Sort an associated group of pins according to their sequence numbers. | ||
| 4813 | */ | ||
| 4814 | static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, | ||
| 4815 | int num_pins) | ||
| 4816 | { | ||
| 4817 | int i, j; | ||
| 4818 | short seq; | ||
| 4819 | hda_nid_t nid; | ||
| 4820 | |||
| 4821 | for (i = 0; i < num_pins; i++) { | ||
| 4822 | for (j = i + 1; j < num_pins; j++) { | ||
| 4823 | if (sequences[i] > sequences[j]) { | ||
| 4824 | seq = sequences[i]; | ||
| 4825 | sequences[i] = sequences[j]; | ||
| 4826 | sequences[j] = seq; | ||
| 4827 | nid = pins[i]; | ||
| 4828 | pins[i] = pins[j]; | ||
| 4829 | pins[j] = nid; | ||
| 4830 | } | ||
| 4831 | } | ||
| 4832 | } | ||
| 4833 | } | ||
| 4834 | |||
| 4835 | |||
| 4836 | /* add the found input-pin to the cfg->inputs[] table */ | ||
| 4837 | static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, | ||
| 4838 | int type) | ||
| 4839 | { | ||
| 4840 | if (cfg->num_inputs < AUTO_CFG_MAX_INS) { | ||
| 4841 | cfg->inputs[cfg->num_inputs].pin = nid; | ||
| 4842 | cfg->inputs[cfg->num_inputs].type = type; | ||
| 4843 | cfg->num_inputs++; | ||
| 4844 | } | ||
| 4845 | } | ||
| 4846 | |||
| 4847 | /* sort inputs in the order of AUTO_PIN_* type */ | ||
| 4848 | static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg) | ||
| 4849 | { | ||
| 4850 | int i, j; | ||
| 4851 | |||
| 4852 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 4853 | for (j = i + 1; j < cfg->num_inputs; j++) { | ||
| 4854 | if (cfg->inputs[i].type > cfg->inputs[j].type) { | ||
| 4855 | struct auto_pin_cfg_item tmp; | ||
| 4856 | tmp = cfg->inputs[i]; | ||
| 4857 | cfg->inputs[i] = cfg->inputs[j]; | ||
| 4858 | cfg->inputs[j] = tmp; | ||
| 4859 | } | ||
| 4860 | } | ||
| 4861 | } | ||
| 4862 | } | ||
| 4863 | |||
| 4864 | /* Reorder the surround channels | ||
| 4865 | * ALSA sequence is front/surr/clfe/side | ||
| 4866 | * HDA sequence is: | ||
| 4867 | * 4-ch: front/surr => OK as it is | ||
| 4868 | * 6-ch: front/clfe/surr | ||
| 4869 | * 8-ch: front/clfe/rear/side|fc | ||
| 4870 | */ | ||
| 4871 | static void reorder_outputs(unsigned int nums, hda_nid_t *pins) | ||
| 4872 | { | ||
| 4873 | hda_nid_t nid; | ||
| 4874 | |||
| 4875 | switch (nums) { | ||
| 4876 | case 3: | ||
| 4877 | case 4: | ||
| 4878 | nid = pins[1]; | ||
| 4879 | pins[1] = pins[2]; | ||
| 4880 | pins[2] = nid; | ||
| 4881 | break; | ||
| 4882 | } | ||
| 4883 | } | ||
| 4884 | |||
| 4885 | /* | ||
| 4886 | * Parse all pin widgets and store the useful pin nids to cfg | ||
| 4887 | * | ||
| 4888 | * The number of line-outs or any primary output is stored in line_outs, | ||
| 4889 | * and the corresponding output pins are assigned to line_out_pins[], | ||
| 4890 | * in the order of front, rear, CLFE, side, ... | ||
| 4891 | * | ||
| 4892 | * If more extra outputs (speaker and headphone) are found, the pins are | ||
| 4893 | * assisnged to hp_pins[] and speaker_pins[], respectively. If no line-out jack | ||
| 4894 | * is detected, one of speaker of HP pins is assigned as the primary | ||
| 4895 | * output, i.e. to line_out_pins[0]. So, line_outs is always positive | ||
| 4896 | * if any analog output exists. | ||
| 4897 | * | ||
| 4898 | * The analog input pins are assigned to inputs array. | ||
| 4899 | * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, | ||
| 4900 | * respectively. | ||
| 4901 | */ | ||
| 4902 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | ||
| 4903 | struct auto_pin_cfg *cfg, | ||
| 4904 | const hda_nid_t *ignore_nids, | ||
| 4905 | unsigned int cond_flags) | ||
| 4906 | { | ||
| 4907 | hda_nid_t nid, end_nid; | ||
| 4908 | short seq, assoc_line_out; | ||
| 4909 | short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)]; | ||
| 4910 | short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)]; | ||
| 4911 | short sequences_hp[ARRAY_SIZE(cfg->hp_pins)]; | ||
| 4912 | int i; | ||
| 4913 | |||
| 4914 | memset(cfg, 0, sizeof(*cfg)); | ||
| 4915 | |||
| 4916 | memset(sequences_line_out, 0, sizeof(sequences_line_out)); | ||
| 4917 | memset(sequences_speaker, 0, sizeof(sequences_speaker)); | ||
| 4918 | memset(sequences_hp, 0, sizeof(sequences_hp)); | ||
| 4919 | assoc_line_out = 0; | ||
| 4920 | |||
| 4921 | codec->ignore_misc_bit = true; | ||
| 4922 | end_nid = codec->start_nid + codec->num_nodes; | ||
| 4923 | for (nid = codec->start_nid; nid < end_nid; nid++) { | ||
| 4924 | unsigned int wid_caps = get_wcaps(codec, nid); | ||
| 4925 | unsigned int wid_type = get_wcaps_type(wid_caps); | ||
| 4926 | unsigned int def_conf; | ||
| 4927 | short assoc, loc, conn, dev; | ||
| 4928 | |||
| 4929 | /* read all default configuration for pin complex */ | ||
| 4930 | if (wid_type != AC_WID_PIN) | ||
| 4931 | continue; | ||
| 4932 | /* ignore the given nids (e.g. pc-beep returns error) */ | ||
| 4933 | if (ignore_nids && is_in_nid_list(nid, ignore_nids)) | ||
| 4934 | continue; | ||
| 4935 | |||
| 4936 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 4937 | if (!(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) & | ||
| 4938 | AC_DEFCFG_MISC_NO_PRESENCE)) | ||
| 4939 | codec->ignore_misc_bit = false; | ||
| 4940 | conn = get_defcfg_connect(def_conf); | ||
| 4941 | if (conn == AC_JACK_PORT_NONE) | ||
| 4942 | continue; | ||
| 4943 | loc = get_defcfg_location(def_conf); | ||
| 4944 | dev = get_defcfg_device(def_conf); | ||
| 4945 | |||
| 4946 | /* workaround for buggy BIOS setups */ | ||
| 4947 | if (dev == AC_JACK_LINE_OUT) { | ||
| 4948 | if (conn == AC_JACK_PORT_FIXED) | ||
| 4949 | dev = AC_JACK_SPEAKER; | ||
| 4950 | } | ||
| 4951 | |||
| 4952 | switch (dev) { | ||
| 4953 | case AC_JACK_LINE_OUT: | ||
| 4954 | seq = get_defcfg_sequence(def_conf); | ||
| 4955 | assoc = get_defcfg_association(def_conf); | ||
| 4956 | |||
| 4957 | if (!(wid_caps & AC_WCAP_STEREO)) | ||
| 4958 | if (!cfg->mono_out_pin) | ||
| 4959 | cfg->mono_out_pin = nid; | ||
| 4960 | if (!assoc) | ||
| 4961 | continue; | ||
| 4962 | if (!assoc_line_out) | ||
| 4963 | assoc_line_out = assoc; | ||
| 4964 | else if (assoc_line_out != assoc) | ||
| 4965 | continue; | ||
| 4966 | if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) | ||
| 4967 | continue; | ||
| 4968 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
| 4969 | sequences_line_out[cfg->line_outs] = seq; | ||
| 4970 | cfg->line_outs++; | ||
| 4971 | break; | ||
| 4972 | case AC_JACK_SPEAKER: | ||
| 4973 | seq = get_defcfg_sequence(def_conf); | ||
| 4974 | assoc = get_defcfg_association(def_conf); | ||
| 4975 | if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) | ||
| 4976 | continue; | ||
| 4977 | cfg->speaker_pins[cfg->speaker_outs] = nid; | ||
| 4978 | sequences_speaker[cfg->speaker_outs] = (assoc << 4) | seq; | ||
| 4979 | cfg->speaker_outs++; | ||
| 4980 | break; | ||
| 4981 | case AC_JACK_HP_OUT: | ||
| 4982 | seq = get_defcfg_sequence(def_conf); | ||
| 4983 | assoc = get_defcfg_association(def_conf); | ||
| 4984 | if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) | ||
| 4985 | continue; | ||
| 4986 | cfg->hp_pins[cfg->hp_outs] = nid; | ||
| 4987 | sequences_hp[cfg->hp_outs] = (assoc << 4) | seq; | ||
| 4988 | cfg->hp_outs++; | ||
| 4989 | break; | ||
| 4990 | case AC_JACK_MIC_IN: | ||
| 4991 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_MIC); | ||
| 4992 | break; | ||
| 4993 | case AC_JACK_LINE_IN: | ||
| 4994 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_LINE_IN); | ||
| 4995 | break; | ||
| 4996 | case AC_JACK_CD: | ||
| 4997 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD); | ||
| 4998 | break; | ||
| 4999 | case AC_JACK_AUX: | ||
| 5000 | add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX); | ||
| 5001 | break; | ||
| 5002 | case AC_JACK_SPDIF_OUT: | ||
| 5003 | case AC_JACK_DIG_OTHER_OUT: | ||
| 5004 | if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) | ||
| 5005 | continue; | ||
| 5006 | cfg->dig_out_pins[cfg->dig_outs] = nid; | ||
| 5007 | cfg->dig_out_type[cfg->dig_outs] = | ||
| 5008 | (loc == AC_JACK_LOC_HDMI) ? | ||
| 5009 | HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF; | ||
| 5010 | cfg->dig_outs++; | ||
| 5011 | break; | ||
| 5012 | case AC_JACK_SPDIF_IN: | ||
| 5013 | case AC_JACK_DIG_OTHER_IN: | ||
| 5014 | cfg->dig_in_pin = nid; | ||
| 5015 | if (loc == AC_JACK_LOC_HDMI) | ||
| 5016 | cfg->dig_in_type = HDA_PCM_TYPE_HDMI; | ||
| 5017 | else | ||
| 5018 | cfg->dig_in_type = HDA_PCM_TYPE_SPDIF; | ||
| 5019 | break; | ||
| 5020 | } | ||
| 5021 | } | ||
| 5022 | |||
| 5023 | /* FIX-UP: | ||
| 5024 | * If no line-out is defined but multiple HPs are found, | ||
| 5025 | * some of them might be the real line-outs. | ||
| 5026 | */ | ||
| 5027 | if (!cfg->line_outs && cfg->hp_outs > 1 && | ||
| 5028 | !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) { | ||
| 5029 | int i = 0; | ||
| 5030 | while (i < cfg->hp_outs) { | ||
| 5031 | /* The real HPs should have the sequence 0x0f */ | ||
| 5032 | if ((sequences_hp[i] & 0x0f) == 0x0f) { | ||
| 5033 | i++; | ||
| 5034 | continue; | ||
| 5035 | } | ||
| 5036 | /* Move it to the line-out table */ | ||
| 5037 | cfg->line_out_pins[cfg->line_outs] = cfg->hp_pins[i]; | ||
| 5038 | sequences_line_out[cfg->line_outs] = sequences_hp[i]; | ||
| 5039 | cfg->line_outs++; | ||
| 5040 | cfg->hp_outs--; | ||
| 5041 | memmove(cfg->hp_pins + i, cfg->hp_pins + i + 1, | ||
| 5042 | sizeof(cfg->hp_pins[0]) * (cfg->hp_outs - i)); | ||
| 5043 | memmove(sequences_hp + i, sequences_hp + i + 1, | ||
| 5044 | sizeof(sequences_hp[0]) * (cfg->hp_outs - i)); | ||
| 5045 | } | ||
| 5046 | memset(cfg->hp_pins + cfg->hp_outs, 0, | ||
| 5047 | sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs)); | ||
| 5048 | if (!cfg->hp_outs) | ||
| 5049 | cfg->line_out_type = AUTO_PIN_HP_OUT; | ||
| 5050 | |||
| 5051 | } | ||
| 5052 | |||
| 5053 | /* sort by sequence */ | ||
| 5054 | sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out, | ||
| 5055 | cfg->line_outs); | ||
| 5056 | sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker, | ||
| 5057 | cfg->speaker_outs); | ||
| 5058 | sort_pins_by_sequence(cfg->hp_pins, sequences_hp, | ||
| 5059 | cfg->hp_outs); | ||
| 5060 | |||
| 5061 | /* | ||
| 5062 | * FIX-UP: if no line-outs are detected, try to use speaker or HP pin | ||
| 5063 | * as a primary output | ||
| 5064 | */ | ||
| 5065 | if (!cfg->line_outs && | ||
| 5066 | !(cond_flags & HDA_PINCFG_NO_LO_FIXUP)) { | ||
| 5067 | if (cfg->speaker_outs) { | ||
| 5068 | cfg->line_outs = cfg->speaker_outs; | ||
| 5069 | memcpy(cfg->line_out_pins, cfg->speaker_pins, | ||
| 5070 | sizeof(cfg->speaker_pins)); | ||
| 5071 | cfg->speaker_outs = 0; | ||
| 5072 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); | ||
| 5073 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; | ||
| 5074 | } else if (cfg->hp_outs) { | ||
| 5075 | cfg->line_outs = cfg->hp_outs; | ||
| 5076 | memcpy(cfg->line_out_pins, cfg->hp_pins, | ||
| 5077 | sizeof(cfg->hp_pins)); | ||
| 5078 | cfg->hp_outs = 0; | ||
| 5079 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); | ||
| 5080 | cfg->line_out_type = AUTO_PIN_HP_OUT; | ||
| 5081 | } | ||
| 5082 | } | ||
| 5083 | |||
| 5084 | reorder_outputs(cfg->line_outs, cfg->line_out_pins); | ||
| 5085 | reorder_outputs(cfg->hp_outs, cfg->hp_pins); | ||
| 5086 | reorder_outputs(cfg->speaker_outs, cfg->speaker_pins); | ||
| 5087 | |||
| 5088 | sort_autocfg_input_pins(cfg); | ||
| 5089 | |||
| 5090 | /* | ||
| 5091 | * debug prints of the parsed results | ||
| 5092 | */ | ||
| 5093 | snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", | ||
| 5094 | cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1], | ||
| 5095 | cfg->line_out_pins[2], cfg->line_out_pins[3], | ||
| 5096 | cfg->line_out_pins[4], | ||
| 5097 | cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : | ||
| 5098 | (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ? | ||
| 5099 | "speaker" : "line")); | ||
| 5100 | snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | ||
| 5101 | cfg->speaker_outs, cfg->speaker_pins[0], | ||
| 5102 | cfg->speaker_pins[1], cfg->speaker_pins[2], | ||
| 5103 | cfg->speaker_pins[3], cfg->speaker_pins[4]); | ||
| 5104 | snd_printd(" hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | ||
| 5105 | cfg->hp_outs, cfg->hp_pins[0], | ||
| 5106 | cfg->hp_pins[1], cfg->hp_pins[2], | ||
| 5107 | cfg->hp_pins[3], cfg->hp_pins[4]); | ||
| 5108 | snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin); | ||
| 5109 | if (cfg->dig_outs) | ||
| 5110 | snd_printd(" dig-out=0x%x/0x%x\n", | ||
| 5111 | cfg->dig_out_pins[0], cfg->dig_out_pins[1]); | ||
| 5112 | snd_printd(" inputs:"); | ||
| 5113 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 5114 | snd_printd(" %s=0x%x", | ||
| 5115 | hda_get_autocfg_input_label(codec, cfg, i), | ||
| 5116 | cfg->inputs[i].pin); | ||
| 5117 | } | ||
| 5118 | snd_printd("\n"); | ||
| 5119 | if (cfg->dig_in_pin) | ||
| 5120 | snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin); | ||
| 5121 | |||
| 5122 | return 0; | ||
| 5123 | } | ||
| 5124 | EXPORT_SYMBOL_HDA(snd_hda_parse_pin_defcfg); | ||
| 5125 | |||
| 5126 | int snd_hda_get_input_pin_attr(unsigned int def_conf) | ||
| 5127 | { | ||
| 5128 | unsigned int loc = get_defcfg_location(def_conf); | ||
| 5129 | unsigned int conn = get_defcfg_connect(def_conf); | ||
| 5130 | if (conn == AC_JACK_PORT_NONE) | ||
| 5131 | return INPUT_PIN_ATTR_UNUSED; | ||
| 5132 | /* Windows may claim the internal mic to be BOTH, too */ | ||
| 5133 | if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) | ||
| 5134 | return INPUT_PIN_ATTR_INT; | ||
| 5135 | if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) | ||
| 5136 | return INPUT_PIN_ATTR_INT; | ||
| 5137 | if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) | ||
| 5138 | return INPUT_PIN_ATTR_DOCK; | ||
| 5139 | if (loc == AC_JACK_LOC_REAR) | ||
| 5140 | return INPUT_PIN_ATTR_REAR; | ||
| 5141 | if (loc == AC_JACK_LOC_FRONT) | ||
| 5142 | return INPUT_PIN_ATTR_FRONT; | ||
| 5143 | return INPUT_PIN_ATTR_NORMAL; | ||
| 5144 | } | ||
| 5145 | EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr); | ||
| 5146 | |||
| 5147 | /** | 4891 | /** |
| 5148 | * hda_get_input_pin_label - Give a label for the given input pin | 4892 | * snd_hda_get_default_vref - Get the default (mic) VREF pin bits |
| 5149 | * | 4893 | * |
| 5150 | * When check_location is true, the function checks the pin location | 4894 | * Guess the suitable VREF pin bits to be set as the pin-control value. |
| 5151 | * for mic and line-in pins, and set an appropriate prefix like "Front", | 4895 | * Note: the function doesn't set the AC_PINCTL_IN_EN bit. |
| 5152 | * "Rear", "Internal". | 4896 | */ |
| 5153 | */ | 4897 | unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin) |
| 5154 | 4898 | { | |
| 5155 | static const char *hda_get_input_pin_label(struct hda_codec *codec, | 4899 | unsigned int pincap; |
| 5156 | hda_nid_t pin, bool check_location) | 4900 | unsigned int oldval; |
| 5157 | { | 4901 | oldval = snd_hda_codec_read(codec, pin, 0, |
| 5158 | unsigned int def_conf; | 4902 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5159 | static const char * const mic_names[] = { | 4903 | pincap = snd_hda_query_pin_caps(codec, pin); |
| 5160 | "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic", | 4904 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 5161 | }; | 4905 | /* Exception: if the default pin setup is vref50, we give it priority */ |
| 5162 | int attr; | 4906 | if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) |
| 5163 | 4907 | return AC_PINCTL_VREF_80; | |
| 5164 | def_conf = snd_hda_codec_get_pincfg(codec, pin); | 4908 | else if (pincap & AC_PINCAP_VREF_50) |
| 5165 | 4909 | return AC_PINCTL_VREF_50; | |
| 5166 | switch (get_defcfg_device(def_conf)) { | 4910 | else if (pincap & AC_PINCAP_VREF_100) |
| 5167 | case AC_JACK_MIC_IN: | 4911 | return AC_PINCTL_VREF_100; |
| 5168 | if (!check_location) | 4912 | else if (pincap & AC_PINCAP_VREF_GRD) |
| 5169 | return "Mic"; | 4913 | return AC_PINCTL_VREF_GRD; |
| 5170 | attr = snd_hda_get_input_pin_attr(def_conf); | 4914 | return AC_PINCTL_VREF_HIZ; |
| 5171 | if (!attr) | 4915 | } |
| 5172 | return "None"; | 4916 | EXPORT_SYMBOL_HDA(snd_hda_get_default_vref); |
| 5173 | return mic_names[attr - 1]; | 4917 | |
| 5174 | case AC_JACK_LINE_IN: | 4918 | int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, |
| 5175 | if (!check_location) | 4919 | unsigned int val, bool cached) |
| 5176 | return "Line"; | 4920 | { |
| 5177 | attr = snd_hda_get_input_pin_attr(def_conf); | 4921 | if (val) { |
| 5178 | if (!attr) | 4922 | unsigned int cap = snd_hda_query_pin_caps(codec, pin); |
| 5179 | return "None"; | 4923 | if (cap && (val & AC_PINCTL_OUT_EN)) { |
| 5180 | if (attr == INPUT_PIN_ATTR_DOCK) | 4924 | if (!(cap & AC_PINCAP_OUT)) |
| 5181 | return "Dock Line"; | 4925 | val &= ~(AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 5182 | return "Line"; | 4926 | else if ((val & AC_PINCTL_HP_EN) && |
| 5183 | case AC_JACK_AUX: | 4927 | !(cap & AC_PINCAP_HP_DRV)) |
| 5184 | return "Aux"; | 4928 | val &= ~AC_PINCTL_HP_EN; |
| 5185 | case AC_JACK_CD: | ||
| 5186 | return "CD"; | ||
| 5187 | case AC_JACK_SPDIF_IN: | ||
| 5188 | return "SPDIF In"; | ||
| 5189 | case AC_JACK_DIG_OTHER_IN: | ||
| 5190 | return "Digital In"; | ||
| 5191 | default: | ||
| 5192 | return "Misc"; | ||
| 5193 | } | ||
| 5194 | } | ||
| 5195 | |||
| 5196 | /* Check whether the location prefix needs to be added to the label. | ||
| 5197 | * If all mic-jacks are in the same location (e.g. rear panel), we don't | ||
| 5198 | * have to put "Front" prefix to each label. In such a case, returns false. | ||
| 5199 | */ | ||
| 5200 | static int check_mic_location_need(struct hda_codec *codec, | ||
| 5201 | const struct auto_pin_cfg *cfg, | ||
| 5202 | int input) | ||
| 5203 | { | ||
| 5204 | unsigned int defc; | ||
| 5205 | int i, attr, attr2; | ||
| 5206 | |||
| 5207 | defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); | ||
| 5208 | attr = snd_hda_get_input_pin_attr(defc); | ||
| 5209 | /* for internal or docking mics, we need locations */ | ||
| 5210 | if (attr <= INPUT_PIN_ATTR_NORMAL) | ||
| 5211 | return 1; | ||
| 5212 | |||
| 5213 | attr = 0; | ||
| 5214 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 5215 | defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); | ||
| 5216 | attr2 = snd_hda_get_input_pin_attr(defc); | ||
| 5217 | if (attr2 >= INPUT_PIN_ATTR_NORMAL) { | ||
| 5218 | if (attr && attr != attr2) | ||
| 5219 | return 1; /* different locations found */ | ||
| 5220 | attr = attr2; | ||
| 5221 | } | 4929 | } |
| 5222 | } | 4930 | if (cap && (val & AC_PINCTL_IN_EN)) { |
| 5223 | return 0; | 4931 | if (!(cap & AC_PINCAP_IN)) |
| 5224 | } | 4932 | val &= ~(AC_PINCTL_IN_EN | AC_PINCTL_VREFEN); |
| 5225 | |||
| 5226 | /** | ||
| 5227 | * hda_get_autocfg_input_label - Get a label for the given input | ||
| 5228 | * | ||
| 5229 | * Get a label for the given input pin defined by the autocfg item. | ||
| 5230 | * Unlike hda_get_input_pin_label(), this function checks all inputs | ||
| 5231 | * defined in autocfg and avoids the redundant mic/line prefix as much as | ||
| 5232 | * possible. | ||
| 5233 | */ | ||
| 5234 | const char *hda_get_autocfg_input_label(struct hda_codec *codec, | ||
| 5235 | const struct auto_pin_cfg *cfg, | ||
| 5236 | int input) | ||
| 5237 | { | ||
| 5238 | int type = cfg->inputs[input].type; | ||
| 5239 | int has_multiple_pins = 0; | ||
| 5240 | |||
| 5241 | if ((input > 0 && cfg->inputs[input - 1].type == type) || | ||
| 5242 | (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) | ||
| 5243 | has_multiple_pins = 1; | ||
| 5244 | if (has_multiple_pins && type == AUTO_PIN_MIC) | ||
| 5245 | has_multiple_pins &= check_mic_location_need(codec, cfg, input); | ||
| 5246 | return hda_get_input_pin_label(codec, cfg->inputs[input].pin, | ||
| 5247 | has_multiple_pins); | ||
| 5248 | } | ||
| 5249 | EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); | ||
| 5250 | |||
| 5251 | /* return the position of NID in the list, or -1 if not found */ | ||
| 5252 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) | ||
| 5253 | { | ||
| 5254 | int i; | ||
| 5255 | for (i = 0; i < nums; i++) | ||
| 5256 | if (list[i] == nid) | ||
| 5257 | return i; | ||
| 5258 | return -1; | ||
| 5259 | } | ||
| 5260 | |||
| 5261 | /* get a unique suffix or an index number */ | ||
| 5262 | static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, | ||
| 5263 | int num_pins, int *indexp) | ||
| 5264 | { | ||
| 5265 | static const char * const channel_sfx[] = { | ||
| 5266 | " Front", " Surround", " CLFE", " Side" | ||
| 5267 | }; | ||
| 5268 | int i; | ||
| 5269 | |||
| 5270 | i = find_idx_in_nid_list(nid, pins, num_pins); | ||
| 5271 | if (i < 0) | ||
| 5272 | return NULL; | ||
| 5273 | if (num_pins == 1) | ||
| 5274 | return ""; | ||
| 5275 | if (num_pins > ARRAY_SIZE(channel_sfx)) { | ||
| 5276 | if (indexp) | ||
| 5277 | *indexp = i; | ||
| 5278 | return ""; | ||
| 5279 | } | ||
| 5280 | return channel_sfx[i]; | ||
| 5281 | } | ||
| 5282 | |||
| 5283 | static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, | ||
| 5284 | const struct auto_pin_cfg *cfg, | ||
| 5285 | const char *name, char *label, int maxlen, | ||
| 5286 | int *indexp) | ||
| 5287 | { | ||
| 5288 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 5289 | int attr = snd_hda_get_input_pin_attr(def_conf); | ||
| 5290 | const char *pfx = "", *sfx = ""; | ||
| 5291 | |||
| 5292 | /* handle as a speaker if it's a fixed line-out */ | ||
| 5293 | if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT) | ||
| 5294 | name = "Speaker"; | ||
| 5295 | /* check the location */ | ||
| 5296 | switch (attr) { | ||
| 5297 | case INPUT_PIN_ATTR_DOCK: | ||
| 5298 | pfx = "Dock "; | ||
| 5299 | break; | ||
| 5300 | case INPUT_PIN_ATTR_FRONT: | ||
| 5301 | pfx = "Front "; | ||
| 5302 | break; | ||
| 5303 | } | ||
| 5304 | if (cfg) { | ||
| 5305 | /* try to give a unique suffix if needed */ | ||
| 5306 | sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, | ||
| 5307 | indexp); | ||
| 5308 | if (!sfx) | ||
| 5309 | sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, | ||
| 5310 | indexp); | ||
| 5311 | if (!sfx) { | ||
| 5312 | /* don't add channel suffix for Headphone controls */ | ||
| 5313 | int idx = find_idx_in_nid_list(nid, cfg->hp_pins, | ||
| 5314 | cfg->hp_outs); | ||
| 5315 | if (idx >= 0) | ||
| 5316 | *indexp = idx; | ||
| 5317 | sfx = ""; | ||
| 5318 | } | 4933 | } |
| 5319 | } | 4934 | } |
| 5320 | snprintf(label, maxlen, "%s%s%s", pfx, name, sfx); | 4935 | if (cached) |
| 5321 | return 1; | 4936 | return snd_hda_codec_update_cache(codec, pin, 0, |
| 5322 | } | 4937 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5323 | 4938 | else | |
| 5324 | /** | 4939 | return snd_hda_codec_write(codec, pin, 0, |
| 5325 | * snd_hda_get_pin_label - Get a label for the given I/O pin | 4940 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5326 | * | ||
| 5327 | * Get a label for the given pin. This function works for both input and | ||
| 5328 | * output pins. When @cfg is given as non-NULL, the function tries to get | ||
| 5329 | * an optimized label using hda_get_autocfg_input_label(). | ||
| 5330 | * | ||
| 5331 | * This function tries to give a unique label string for the pin as much as | ||
| 5332 | * possible. For example, when the multiple line-outs are present, it adds | ||
| 5333 | * the channel suffix like "Front", "Surround", etc (only when @cfg is given). | ||
| 5334 | * If no unique name with a suffix is available and @indexp is non-NULL, the | ||
| 5335 | * index number is stored in the pointer. | ||
| 5336 | */ | ||
| 5337 | int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, | ||
| 5338 | const struct auto_pin_cfg *cfg, | ||
| 5339 | char *label, int maxlen, int *indexp) | ||
| 5340 | { | ||
| 5341 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 5342 | const char *name = NULL; | ||
| 5343 | int i; | ||
| 5344 | |||
| 5345 | if (indexp) | ||
| 5346 | *indexp = 0; | ||
| 5347 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | ||
| 5348 | return 0; | ||
| 5349 | |||
| 5350 | switch (get_defcfg_device(def_conf)) { | ||
| 5351 | case AC_JACK_LINE_OUT: | ||
| 5352 | return fill_audio_out_name(codec, nid, cfg, "Line Out", | ||
| 5353 | label, maxlen, indexp); | ||
| 5354 | case AC_JACK_SPEAKER: | ||
| 5355 | return fill_audio_out_name(codec, nid, cfg, "Speaker", | ||
| 5356 | label, maxlen, indexp); | ||
| 5357 | case AC_JACK_HP_OUT: | ||
| 5358 | return fill_audio_out_name(codec, nid, cfg, "Headphone", | ||
| 5359 | label, maxlen, indexp); | ||
| 5360 | case AC_JACK_SPDIF_OUT: | ||
| 5361 | case AC_JACK_DIG_OTHER_OUT: | ||
| 5362 | if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI) | ||
| 5363 | name = "HDMI"; | ||
| 5364 | else | ||
| 5365 | name = "SPDIF"; | ||
| 5366 | if (cfg && indexp) { | ||
| 5367 | i = find_idx_in_nid_list(nid, cfg->dig_out_pins, | ||
| 5368 | cfg->dig_outs); | ||
| 5369 | if (i >= 0) | ||
| 5370 | *indexp = i; | ||
| 5371 | } | ||
| 5372 | break; | ||
| 5373 | default: | ||
| 5374 | if (cfg) { | ||
| 5375 | for (i = 0; i < cfg->num_inputs; i++) { | ||
| 5376 | if (cfg->inputs[i].pin != nid) | ||
| 5377 | continue; | ||
| 5378 | name = hda_get_autocfg_input_label(codec, cfg, i); | ||
| 5379 | if (name) | ||
| 5380 | break; | ||
| 5381 | } | ||
| 5382 | } | ||
| 5383 | if (!name) | ||
| 5384 | name = hda_get_input_pin_label(codec, nid, true); | ||
| 5385 | break; | ||
| 5386 | } | ||
| 5387 | if (!name) | ||
| 5388 | return 0; | ||
| 5389 | strlcpy(label, name, maxlen); | ||
| 5390 | return 1; | ||
| 5391 | } | 4941 | } |
| 5392 | EXPORT_SYMBOL_HDA(snd_hda_get_pin_label); | 4942 | EXPORT_SYMBOL_HDA(_snd_hda_set_pin_ctl); |
| 5393 | 4943 | ||
| 5394 | /** | 4944 | /** |
| 5395 | * snd_hda_add_imux_item - Add an item to input_mux | 4945 | * snd_hda_add_imux_item - Add an item to input_mux |
| @@ -5444,12 +4994,6 @@ int snd_hda_suspend(struct hda_bus *bus) | |||
| 5444 | list_for_each_entry(codec, &bus->codec_list, list) { | 4994 | list_for_each_entry(codec, &bus->codec_list, list) { |
| 5445 | if (hda_codec_is_power_on(codec)) | 4995 | if (hda_codec_is_power_on(codec)) |
| 5446 | hda_call_codec_suspend(codec); | 4996 | hda_call_codec_suspend(codec); |
| 5447 | else /* forcibly change the power to D3 even if not used */ | ||
| 5448 | hda_set_power_state(codec, | ||
| 5449 | codec->afg ? codec->afg : codec->mfg, | ||
| 5450 | AC_PWRST_D3); | ||
| 5451 | if (codec->patch_ops.post_suspend) | ||
| 5452 | codec->patch_ops.post_suspend(codec); | ||
| 5453 | } | 4997 | } |
| 5454 | return 0; | 4998 | return 0; |
| 5455 | } | 4999 | } |
| @@ -5469,10 +5013,7 @@ int snd_hda_resume(struct hda_bus *bus) | |||
| 5469 | struct hda_codec *codec; | 5013 | struct hda_codec *codec; |
| 5470 | 5014 | ||
| 5471 | list_for_each_entry(codec, &bus->codec_list, list) { | 5015 | list_for_each_entry(codec, &bus->codec_list, list) { |
| 5472 | if (codec->patch_ops.pre_resume) | 5016 | hda_call_codec_resume(codec); |
| 5473 | codec->patch_ops.pre_resume(codec); | ||
| 5474 | if (snd_hda_codec_needs_resume(codec)) | ||
| 5475 | hda_call_codec_resume(codec); | ||
| 5476 | } | 5017 | } |
| 5477 | return 0; | 5018 | return 0; |
| 5478 | } | 5019 | } |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 56b4f74c0b13..29a311b05f2d 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
| @@ -704,8 +704,6 @@ struct hda_codec_ops { | |||
| 704 | unsigned int power_state); | 704 | unsigned int power_state); |
| 705 | #ifdef CONFIG_PM | 705 | #ifdef CONFIG_PM |
| 706 | int (*suspend)(struct hda_codec *codec, pm_message_t state); | 706 | int (*suspend)(struct hda_codec *codec, pm_message_t state); |
| 707 | int (*post_suspend)(struct hda_codec *codec); | ||
| 708 | int (*pre_resume)(struct hda_codec *codec); | ||
| 709 | int (*resume)(struct hda_codec *codec); | 707 | int (*resume)(struct hda_codec *codec); |
| 710 | #endif | 708 | #endif |
| 711 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 709 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| @@ -829,6 +827,7 @@ struct hda_codec { | |||
| 829 | 827 | ||
| 830 | struct mutex spdif_mutex; | 828 | struct mutex spdif_mutex; |
| 831 | struct mutex control_mutex; | 829 | struct mutex control_mutex; |
| 830 | struct mutex hash_mutex; | ||
| 832 | struct snd_array spdif_out; | 831 | struct snd_array spdif_out; |
| 833 | unsigned int spdif_in_enable; /* SPDIF input enable? */ | 832 | unsigned int spdif_in_enable; /* SPDIF input enable? */ |
| 834 | const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ | 833 | const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ |
| @@ -861,12 +860,13 @@ struct hda_codec { | |||
| 861 | unsigned int no_jack_detect:1; /* Machine has no jack-detection */ | 860 | unsigned int no_jack_detect:1; /* Machine has no jack-detection */ |
| 862 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 861 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 863 | unsigned int power_on :1; /* current (global) power-state */ | 862 | unsigned int power_on :1; /* current (global) power-state */ |
| 864 | unsigned int power_transition :1; /* power-state in transition */ | 863 | int power_transition; /* power-state in transition */ |
| 865 | int power_count; /* current (global) power refcount */ | 864 | int power_count; /* current (global) power refcount */ |
| 866 | struct delayed_work power_work; /* delayed task for powerdown */ | 865 | struct delayed_work power_work; /* delayed task for powerdown */ |
| 867 | unsigned long power_on_acct; | 866 | unsigned long power_on_acct; |
| 868 | unsigned long power_off_acct; | 867 | unsigned long power_off_acct; |
| 869 | unsigned long power_jiffies; | 868 | unsigned long power_jiffies; |
| 869 | spinlock_t power_lock; | ||
| 870 | #endif | 870 | #endif |
| 871 | 871 | ||
| 872 | /* codec-specific additional proc output */ | 872 | /* codec-specific additional proc output */ |
| @@ -1051,12 +1051,10 @@ const char *snd_hda_get_jack_location(u32 cfg); | |||
| 1051 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 1051 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1052 | void snd_hda_power_up(struct hda_codec *codec); | 1052 | void snd_hda_power_up(struct hda_codec *codec); |
| 1053 | void snd_hda_power_down(struct hda_codec *codec); | 1053 | void snd_hda_power_down(struct hda_codec *codec); |
| 1054 | #define snd_hda_codec_needs_resume(codec) codec->power_count | ||
| 1055 | void snd_hda_update_power_acct(struct hda_codec *codec); | 1054 | void snd_hda_update_power_acct(struct hda_codec *codec); |
| 1056 | #else | 1055 | #else |
| 1057 | static inline void snd_hda_power_up(struct hda_codec *codec) {} | 1056 | static inline void snd_hda_power_up(struct hda_codec *codec) {} |
| 1058 | static inline void snd_hda_power_down(struct hda_codec *codec) {} | 1057 | static inline void snd_hda_power_down(struct hda_codec *codec) {} |
| 1059 | #define snd_hda_codec_needs_resume(codec) 1 | ||
| 1060 | #endif | 1058 | #endif |
| 1061 | 1059 | ||
| 1062 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | 1060 | #ifdef CONFIG_SND_HDA_PATCH_LOADER |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index c19e71a94e1b..a70d7e5443aa 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
| @@ -497,6 +497,7 @@ enum { | |||
| 497 | AZX_DRIVER_NVIDIA, | 497 | AZX_DRIVER_NVIDIA, |
| 498 | AZX_DRIVER_TERA, | 498 | AZX_DRIVER_TERA, |
| 499 | AZX_DRIVER_CTX, | 499 | AZX_DRIVER_CTX, |
| 500 | AZX_DRIVER_CTHDA, | ||
| 500 | AZX_DRIVER_GENERIC, | 501 | AZX_DRIVER_GENERIC, |
| 501 | AZX_NUM_DRIVERS, /* keep this as last entry */ | 502 | AZX_NUM_DRIVERS, /* keep this as last entry */ |
| 502 | }; | 503 | }; |
| @@ -518,6 +519,7 @@ enum { | |||
| 518 | #define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */ | 519 | #define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */ |
| 519 | #define AZX_DCAPS_BUFSIZE (1 << 21) /* no buffer size alignment */ | 520 | #define AZX_DCAPS_BUFSIZE (1 << 21) /* no buffer size alignment */ |
| 520 | #define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */ | 521 | #define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */ |
| 522 | #define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */ | ||
| 521 | 523 | ||
| 522 | /* quirks for ATI SB / AMD Hudson */ | 524 | /* quirks for ATI SB / AMD Hudson */ |
| 523 | #define AZX_DCAPS_PRESET_ATI_SB \ | 525 | #define AZX_DCAPS_PRESET_ATI_SB \ |
| @@ -533,6 +535,9 @@ enum { | |||
| 533 | (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\ | 535 | (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\ |
| 534 | AZX_DCAPS_ALIGN_BUFSIZE) | 536 | AZX_DCAPS_ALIGN_BUFSIZE) |
| 535 | 537 | ||
| 538 | #define AZX_DCAPS_PRESET_CTHDA \ | ||
| 539 | (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY) | ||
| 540 | |||
| 536 | static char *driver_short_names[] __devinitdata = { | 541 | static char *driver_short_names[] __devinitdata = { |
| 537 | [AZX_DRIVER_ICH] = "HDA Intel", | 542 | [AZX_DRIVER_ICH] = "HDA Intel", |
| 538 | [AZX_DRIVER_PCH] = "HDA Intel PCH", | 543 | [AZX_DRIVER_PCH] = "HDA Intel PCH", |
| @@ -546,6 +551,7 @@ static char *driver_short_names[] __devinitdata = { | |||
| 546 | [AZX_DRIVER_NVIDIA] = "HDA NVidia", | 551 | [AZX_DRIVER_NVIDIA] = "HDA NVidia", |
| 547 | [AZX_DRIVER_TERA] = "HDA Teradici", | 552 | [AZX_DRIVER_TERA] = "HDA Teradici", |
| 548 | [AZX_DRIVER_CTX] = "HDA Creative", | 553 | [AZX_DRIVER_CTX] = "HDA Creative", |
| 554 | [AZX_DRIVER_CTHDA] = "HDA Creative", | ||
| 549 | [AZX_DRIVER_GENERIC] = "HD-Audio Generic", | 555 | [AZX_DRIVER_GENERIC] = "HD-Audio Generic", |
| 550 | }; | 556 | }; |
| 551 | 557 | ||
| @@ -1283,7 +1289,8 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) | |||
| 1283 | /* | 1289 | /* |
| 1284 | * set up a BDL entry | 1290 | * set up a BDL entry |
| 1285 | */ | 1291 | */ |
| 1286 | static int setup_bdle(struct snd_pcm_substream *substream, | 1292 | static int setup_bdle(struct azx *chip, |
| 1293 | struct snd_pcm_substream *substream, | ||
| 1287 | struct azx_dev *azx_dev, u32 **bdlp, | 1294 | struct azx_dev *azx_dev, u32 **bdlp, |
| 1288 | int ofs, int size, int with_ioc) | 1295 | int ofs, int size, int with_ioc) |
| 1289 | { | 1296 | { |
| @@ -1302,6 +1309,12 @@ static int setup_bdle(struct snd_pcm_substream *substream, | |||
| 1302 | bdl[1] = cpu_to_le32(upper_32_bits(addr)); | 1309 | bdl[1] = cpu_to_le32(upper_32_bits(addr)); |
| 1303 | /* program the size field of the BDL entry */ | 1310 | /* program the size field of the BDL entry */ |
| 1304 | chunk = snd_pcm_sgbuf_get_chunk_size(substream, ofs, size); | 1311 | chunk = snd_pcm_sgbuf_get_chunk_size(substream, ofs, size); |
| 1312 | /* one BDLE cannot cross 4K boundary on CTHDA chips */ | ||
| 1313 | if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY) { | ||
| 1314 | u32 remain = 0x1000 - (ofs & 0xfff); | ||
| 1315 | if (chunk > remain) | ||
| 1316 | chunk = remain; | ||
| 1317 | } | ||
| 1305 | bdl[2] = cpu_to_le32(chunk); | 1318 | bdl[2] = cpu_to_le32(chunk); |
| 1306 | /* program the IOC to enable interrupt | 1319 | /* program the IOC to enable interrupt |
| 1307 | * only when the whole fragment is processed | 1320 | * only when the whole fragment is processed |
| @@ -1354,7 +1367,7 @@ static int azx_setup_periods(struct azx *chip, | |||
| 1354 | bdl_pos_adj[chip->dev_index]); | 1367 | bdl_pos_adj[chip->dev_index]); |
| 1355 | pos_adj = 0; | 1368 | pos_adj = 0; |
| 1356 | } else { | 1369 | } else { |
| 1357 | ofs = setup_bdle(substream, azx_dev, | 1370 | ofs = setup_bdle(chip, substream, azx_dev, |
| 1358 | &bdl, ofs, pos_adj, | 1371 | &bdl, ofs, pos_adj, |
| 1359 | !substream->runtime->no_period_wakeup); | 1372 | !substream->runtime->no_period_wakeup); |
| 1360 | if (ofs < 0) | 1373 | if (ofs < 0) |
| @@ -1364,10 +1377,10 @@ static int azx_setup_periods(struct azx *chip, | |||
| 1364 | pos_adj = 0; | 1377 | pos_adj = 0; |
| 1365 | for (i = 0; i < periods; i++) { | 1378 | for (i = 0; i < periods; i++) { |
| 1366 | if (i == periods - 1 && pos_adj) | 1379 | if (i == periods - 1 && pos_adj) |
| 1367 | ofs = setup_bdle(substream, azx_dev, &bdl, ofs, | 1380 | ofs = setup_bdle(chip, substream, azx_dev, &bdl, ofs, |
| 1368 | period_bytes - pos_adj, 0); | 1381 | period_bytes - pos_adj, 0); |
| 1369 | else | 1382 | else |
| 1370 | ofs = setup_bdle(substream, azx_dev, &bdl, ofs, | 1383 | ofs = setup_bdle(chip, substream, azx_dev, &bdl, ofs, |
| 1371 | period_bytes, | 1384 | period_bytes, |
| 1372 | !substream->runtime->no_period_wakeup); | 1385 | !substream->runtime->no_period_wakeup); |
| 1373 | if (ofs < 0) | 1386 | if (ofs < 0) |
| @@ -3116,6 +3129,11 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { | |||
| 3116 | .driver_data = AZX_DRIVER_CTX | AZX_DCAPS_CTX_WORKAROUND | | 3129 | .driver_data = AZX_DRIVER_CTX | AZX_DCAPS_CTX_WORKAROUND | |
| 3117 | AZX_DCAPS_RIRB_PRE_DELAY | AZX_DCAPS_POSFIX_LPIB }, | 3130 | AZX_DCAPS_RIRB_PRE_DELAY | AZX_DCAPS_POSFIX_LPIB }, |
| 3118 | #endif | 3131 | #endif |
| 3132 | /* CTHDA chips */ | ||
| 3133 | { PCI_DEVICE(0x1102, 0x0010), | ||
| 3134 | .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA }, | ||
| 3135 | { PCI_DEVICE(0x1102, 0x0012), | ||
| 3136 | .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA }, | ||
| 3119 | /* Vortex86MX */ | 3137 | /* Vortex86MX */ |
| 3120 | { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, | 3138 | { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, |
| 3121 | /* VMware HDAudio */ | 3139 | /* VMware HDAudio */ |
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index d68948499fbc..2dd1c113a4c1 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <sound/jack.h> | 17 | #include <sound/jack.h> |
| 18 | #include "hda_codec.h" | 18 | #include "hda_codec.h" |
| 19 | #include "hda_local.h" | 19 | #include "hda_local.h" |
| 20 | #include "hda_auto_parser.h" | ||
| 20 | #include "hda_jack.h" | 21 | #include "hda_jack.h" |
| 21 | 22 | ||
| 22 | bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) | 23 | bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) |
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index c66655cf413a..8ae52465ec5d 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #ifndef __SOUND_HDA_JACK_H | 12 | #ifndef __SOUND_HDA_JACK_H |
| 13 | #define __SOUND_HDA_JACK_H | 13 | #define __SOUND_HDA_JACK_H |
| 14 | 14 | ||
| 15 | struct auto_pin_cfg; | ||
| 16 | |||
| 15 | struct hda_jack_tbl { | 17 | struct hda_jack_tbl { |
| 16 | hda_nid_t nid; | 18 | hda_nid_t nid; |
| 17 | unsigned char action; /* event action (0 = none) */ | 19 | unsigned char action; /* event action (0 = none) */ |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 0ec9248165bc..9a096a8e0fc5 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
| @@ -262,6 +262,8 @@ int snd_hda_input_mux_put(struct hda_codec *codec, | |||
| 262 | const struct hda_input_mux *imux, | 262 | const struct hda_input_mux *imux, |
| 263 | struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, | 263 | struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, |
| 264 | unsigned int *cur_val); | 264 | unsigned int *cur_val); |
| 265 | int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, | ||
| 266 | int index, int *type_index_ret); | ||
| 265 | 267 | ||
| 266 | /* | 268 | /* |
| 267 | * Channel mode helper | 269 | * Channel mode helper |
| @@ -393,72 +395,7 @@ struct hda_bus_unsolicited { | |||
| 393 | struct hda_bus *bus; | 395 | struct hda_bus *bus; |
| 394 | }; | 396 | }; |
| 395 | 397 | ||
| 396 | /* | 398 | /* helper macros to retrieve pin default-config values */ |
| 397 | * Helper for automatic pin configuration | ||
| 398 | */ | ||
| 399 | |||
| 400 | enum { | ||
| 401 | AUTO_PIN_MIC, | ||
| 402 | AUTO_PIN_LINE_IN, | ||
| 403 | AUTO_PIN_CD, | ||
| 404 | AUTO_PIN_AUX, | ||
| 405 | AUTO_PIN_LAST | ||
| 406 | }; | ||
| 407 | |||
| 408 | enum { | ||
| 409 | AUTO_PIN_LINE_OUT, | ||
| 410 | AUTO_PIN_SPEAKER_OUT, | ||
| 411 | AUTO_PIN_HP_OUT | ||
| 412 | }; | ||
| 413 | |||
| 414 | #define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS | ||
| 415 | #define AUTO_CFG_MAX_INS 8 | ||
| 416 | |||
| 417 | struct auto_pin_cfg_item { | ||
| 418 | hda_nid_t pin; | ||
| 419 | int type; | ||
| 420 | }; | ||
| 421 | |||
| 422 | struct auto_pin_cfg; | ||
| 423 | const char *hda_get_autocfg_input_label(struct hda_codec *codec, | ||
| 424 | const struct auto_pin_cfg *cfg, | ||
| 425 | int input); | ||
| 426 | int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, | ||
| 427 | const struct auto_pin_cfg *cfg, | ||
| 428 | char *label, int maxlen, int *indexp); | ||
| 429 | int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, | ||
| 430 | int index, int *type_index_ret); | ||
| 431 | |||
| 432 | enum { | ||
| 433 | INPUT_PIN_ATTR_UNUSED, /* pin not connected */ | ||
| 434 | INPUT_PIN_ATTR_INT, /* internal mic/line-in */ | ||
| 435 | INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ | ||
| 436 | INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ | ||
| 437 | INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ | ||
| 438 | INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ | ||
| 439 | }; | ||
| 440 | |||
| 441 | int snd_hda_get_input_pin_attr(unsigned int def_conf); | ||
| 442 | |||
| 443 | struct auto_pin_cfg { | ||
| 444 | int line_outs; | ||
| 445 | /* sorted in the order of Front/Surr/CLFE/Side */ | ||
| 446 | hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS]; | ||
| 447 | int speaker_outs; | ||
| 448 | hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS]; | ||
| 449 | int hp_outs; | ||
| 450 | int line_out_type; /* AUTO_PIN_XXX_OUT */ | ||
| 451 | hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; | ||
| 452 | int num_inputs; | ||
| 453 | struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; | ||
| 454 | int dig_outs; | ||
| 455 | hda_nid_t dig_out_pins[2]; | ||
| 456 | hda_nid_t dig_in_pin; | ||
| 457 | hda_nid_t mono_out_pin; | ||
| 458 | int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */ | ||
| 459 | int dig_in_type; /* HDA_PCM_TYPE_XXX */ | ||
| 460 | }; | ||
| 461 | |||
| 462 | #define get_defcfg_connect(cfg) \ | 399 | #define get_defcfg_connect(cfg) \ |
| 463 | ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) | 400 | ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) |
| 464 | #define get_defcfg_association(cfg) \ | 401 | #define get_defcfg_association(cfg) \ |
| @@ -472,19 +409,6 @@ struct auto_pin_cfg { | |||
| 472 | #define get_defcfg_misc(cfg) \ | 409 | #define get_defcfg_misc(cfg) \ |
| 473 | ((cfg & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) | 410 | ((cfg & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) |
| 474 | 411 | ||
| 475 | /* bit-flags for snd_hda_parse_pin_def_config() behavior */ | ||
| 476 | #define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ | ||
| 477 | #define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ | ||
| 478 | |||
| 479 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | ||
| 480 | struct auto_pin_cfg *cfg, | ||
| 481 | const hda_nid_t *ignore_nids, | ||
| 482 | unsigned int cond_flags); | ||
| 483 | |||
| 484 | /* older function */ | ||
| 485 | #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ | ||
| 486 | snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) | ||
| 487 | |||
| 488 | /* amp values */ | 412 | /* amp values */ |
| 489 | #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) | 413 | #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) |
| 490 | #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) | 414 | #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) |
| @@ -502,6 +426,46 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | |||
| 502 | #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) | 426 | #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) |
| 503 | #define PIN_HP_AMP (AC_PINCTL_HP_EN) | 427 | #define PIN_HP_AMP (AC_PINCTL_HP_EN) |
| 504 | 428 | ||
| 429 | unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin); | ||
| 430 | int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, | ||
| 431 | unsigned int val, bool cached); | ||
| 432 | |||
| 433 | /** | ||
| 434 | * _snd_hda_set_pin_ctl - Set a pin-control value safely | ||
| 435 | * @codec: the codec instance | ||
| 436 | * @pin: the pin NID to set the control | ||
| 437 | * @val: the pin-control value (AC_PINCTL_* bits) | ||
| 438 | * | ||
| 439 | * This function sets the pin-control value to the given pin, but | ||
| 440 | * filters out the invalid pin-control bits when the pin has no such | ||
| 441 | * capabilities. For example, when PIN_HP is passed but the pin has no | ||
| 442 | * HP-drive capability, the HP bit is omitted. | ||
| 443 | * | ||
| 444 | * The function doesn't check the input VREF capability bits, though. | ||
| 445 | * Use snd_hda_get_default_vref() to guess the right value. | ||
| 446 | * Also, this function is only for analog pins, not for HDMI pins. | ||
| 447 | */ | ||
| 448 | static inline int | ||
| 449 | snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, unsigned int val) | ||
| 450 | { | ||
| 451 | return _snd_hda_set_pin_ctl(codec, pin, val, false); | ||
| 452 | } | ||
| 453 | |||
| 454 | /** | ||
| 455 | * snd_hda_set_pin_ctl_cache - Set a pin-control value safely | ||
| 456 | * @codec: the codec instance | ||
| 457 | * @pin: the pin NID to set the control | ||
| 458 | * @val: the pin-control value (AC_PINCTL_* bits) | ||
| 459 | * | ||
| 460 | * Just like snd_hda_set_pin_ctl() but write to cache as well. | ||
| 461 | */ | ||
| 462 | static inline int | ||
| 463 | snd_hda_set_pin_ctl_cache(struct hda_codec *codec, hda_nid_t pin, | ||
| 464 | unsigned int val) | ||
| 465 | { | ||
| 466 | return _snd_hda_set_pin_ctl(codec, pin, val, true); | ||
| 467 | } | ||
| 468 | |||
| 505 | /* | 469 | /* |
| 506 | * get widget capabilities | 470 | * get widget capabilities |
| 507 | */ | 471 | */ |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 7143393927da..d8b2d6dee986 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <sound/core.h> | 28 | #include <sound/core.h> |
| 29 | #include "hda_codec.h" | 29 | #include "hda_codec.h" |
| 30 | #include "hda_local.h" | 30 | #include "hda_local.h" |
| 31 | #include "hda_auto_parser.h" | ||
| 31 | #include "hda_beep.h" | 32 | #include "hda_beep.h" |
| 32 | #include "hda_jack.h" | 33 | #include "hda_jack.h" |
| 33 | 34 | ||
| @@ -1742,9 +1743,7 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
| 1742 | if (! ad198x_eapd_put(kcontrol, ucontrol)) | 1743 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
| 1743 | return 0; | 1744 | return 0; |
| 1744 | /* change speaker pin appropriately */ | 1745 | /* change speaker pin appropriately */ |
| 1745 | snd_hda_codec_write(codec, 0x05, 0, | 1746 | snd_hda_set_pin_ctl(codec, 0x05, spec->cur_eapd ? PIN_OUT : 0); |
| 1746 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 1747 | spec->cur_eapd ? PIN_OUT : 0); | ||
| 1748 | /* toggle HP mute appropriately */ | 1747 | /* toggle HP mute appropriately */ |
| 1749 | snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, | 1748 | snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, |
| 1750 | HDA_AMP_MUTE, | 1749 | HDA_AMP_MUTE, |
| @@ -3103,7 +3102,7 @@ static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, | |||
| 3103 | int dac_idx) | 3102 | int dac_idx) |
| 3104 | { | 3103 | { |
| 3105 | /* set as output */ | 3104 | /* set as output */ |
| 3106 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | 3105 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
| 3107 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | 3106 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 3108 | switch (nid) { | 3107 | switch (nid) { |
| 3109 | case 0x11: /* port-A - DAC 03 */ | 3108 | case 0x11: /* port-A - DAC 03 */ |
| @@ -3157,6 +3156,7 @@ static void ad1988_auto_init_analog_input(struct hda_codec *codec) | |||
| 3157 | for (i = 0; i < cfg->num_inputs; i++) { | 3156 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3158 | hda_nid_t nid = cfg->inputs[i].pin; | 3157 | hda_nid_t nid = cfg->inputs[i].pin; |
| 3159 | int type = cfg->inputs[i].type; | 3158 | int type = cfg->inputs[i].type; |
| 3159 | int val; | ||
| 3160 | switch (nid) { | 3160 | switch (nid) { |
| 3161 | case 0x15: /* port-C */ | 3161 | case 0x15: /* port-C */ |
| 3162 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); | 3162 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| @@ -3165,8 +3165,10 @@ static void ad1988_auto_init_analog_input(struct hda_codec *codec) | |||
| 3165 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); | 3165 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 3166 | break; | 3166 | break; |
| 3167 | } | 3167 | } |
| 3168 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 3168 | val = PIN_IN; |
| 3169 | type == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); | 3169 | if (type == AUTO_PIN_MIC) |
| 3170 | val |= snd_hda_get_default_vref(codec, nid); | ||
| 3171 | snd_hda_set_pin_ctl(codec, nid, val); | ||
| 3170 | if (nid != AD1988_PIN_CD_NID) | 3172 | if (nid != AD1988_PIN_CD_NID) |
| 3171 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 3173 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3172 | AMP_OUT_MUTE); | 3174 | AMP_OUT_MUTE); |
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index 09ccfabb4a17..19ae14f739cb 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <sound/core.h> | 26 | #include <sound/core.h> |
| 27 | #include "hda_codec.h" | 27 | #include "hda_codec.h" |
| 28 | #include "hda_local.h" | 28 | #include "hda_local.h" |
| 29 | #include "hda_auto_parser.h" | ||
| 29 | 30 | ||
| 30 | /* | 31 | /* |
| 31 | */ | 32 | */ |
| @@ -341,8 +342,7 @@ static int ca0110_build_pcms(struct hda_codec *codec) | |||
| 341 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | 342 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) |
| 342 | { | 343 | { |
| 343 | if (pin) { | 344 | if (pin) { |
| 344 | snd_hda_codec_write(codec, pin, 0, | 345 | snd_hda_set_pin_ctl(codec, pin, PIN_HP); |
| 345 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
| 346 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) | 346 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) |
| 347 | snd_hda_codec_write(codec, pin, 0, | 347 | snd_hda_codec_write(codec, pin, 0, |
| 348 | AC_VERB_SET_AMP_GAIN_MUTE, | 348 | AC_VERB_SET_AMP_GAIN_MUTE, |
| @@ -356,8 +356,8 @@ static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | |||
| 356 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) | 356 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) |
| 357 | { | 357 | { |
| 358 | if (pin) { | 358 | if (pin) { |
| 359 | snd_hda_codec_write(codec, pin, 0, | 359 | snd_hda_set_pin_ctl(codec, pin, PIN_IN | |
| 360 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80); | 360 | snd_hda_get_default_vref(codec, pin)); |
| 361 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) | 361 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) |
| 362 | snd_hda_codec_write(codec, pin, 0, | 362 | snd_hda_codec_write(codec, pin, 0, |
| 363 | AC_VERB_SET_AMP_GAIN_MUTE, | 363 | AC_VERB_SET_AMP_GAIN_MUTE, |
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 21d91d580da8..d0d3540e39e7 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <sound/core.h> | 30 | #include <sound/core.h> |
| 31 | #include "hda_codec.h" | 31 | #include "hda_codec.h" |
| 32 | #include "hda_local.h" | 32 | #include "hda_local.h" |
| 33 | #include "hda_auto_parser.h" | ||
| 33 | 34 | ||
| 34 | #define WIDGET_CHIP_CTRL 0x15 | 35 | #define WIDGET_CHIP_CTRL 0x15 |
| 35 | #define WIDGET_DSP_CTRL 0x16 | 36 | #define WIDGET_DSP_CTRL 0x16 |
| @@ -239,8 +240,7 @@ enum get_set { | |||
| 239 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | 240 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) |
| 240 | { | 241 | { |
| 241 | if (pin) { | 242 | if (pin) { |
| 242 | snd_hda_codec_write(codec, pin, 0, | 243 | snd_hda_set_pin_ctl(codec, pin, PIN_HP); |
| 243 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
| 244 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) | 244 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) |
| 245 | snd_hda_codec_write(codec, pin, 0, | 245 | snd_hda_codec_write(codec, pin, 0, |
| 246 | AC_VERB_SET_AMP_GAIN_MUTE, | 246 | AC_VERB_SET_AMP_GAIN_MUTE, |
| @@ -254,9 +254,8 @@ static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | |||
| 254 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) | 254 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) |
| 255 | { | 255 | { |
| 256 | if (pin) { | 256 | if (pin) { |
| 257 | snd_hda_codec_write(codec, pin, 0, | 257 | snd_hda_set_pin_ctl(codec, pin, PIN_IN | |
| 258 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 258 | snd_hda_get_default_vref(codec, pin)); |
| 259 | PIN_VREF80); | ||
| 260 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) | 259 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) |
| 261 | snd_hda_codec_write(codec, pin, 0, | 260 | snd_hda_codec_write(codec, pin, 0, |
| 262 | AC_VERB_SET_AMP_GAIN_MUTE, | 261 | AC_VERB_SET_AMP_GAIN_MUTE, |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index c83ccdba1e5a..9647ed4d7929 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <sound/core.h> | 26 | #include <sound/core.h> |
| 27 | #include "hda_codec.h" | 27 | #include "hda_codec.h" |
| 28 | #include "hda_local.h" | 28 | #include "hda_local.h" |
| 29 | #include "hda_auto_parser.h" | ||
| 29 | #include "hda_jack.h" | 30 | #include "hda_jack.h" |
| 30 | #include <sound/tlv.h> | 31 | #include <sound/tlv.h> |
| 31 | 32 | ||
| @@ -933,8 +934,7 @@ static void cs_automute(struct hda_codec *codec) | |||
| 933 | pin_ctl = 0; | 934 | pin_ctl = 0; |
| 934 | 935 | ||
| 935 | nid = cfg->speaker_pins[i]; | 936 | nid = cfg->speaker_pins[i]; |
| 936 | snd_hda_codec_write(codec, nid, 0, | 937 | snd_hda_set_pin_ctl(codec, nid, pin_ctl); |
| 937 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_ctl); | ||
| 938 | } | 938 | } |
| 939 | if (spec->gpio_eapd_hp) { | 939 | if (spec->gpio_eapd_hp) { |
| 940 | unsigned int gpio = hp_present ? | 940 | unsigned int gpio = hp_present ? |
| @@ -948,16 +948,14 @@ static void cs_automute(struct hda_codec *codec) | |||
| 948 | /* mute HPs if spdif jack (SENSE_B) is present */ | 948 | /* mute HPs if spdif jack (SENSE_B) is present */ |
| 949 | for (i = 0; i < cfg->hp_outs; i++) { | 949 | for (i = 0; i < cfg->hp_outs; i++) { |
| 950 | nid = cfg->hp_pins[i]; | 950 | nid = cfg->hp_pins[i]; |
| 951 | snd_hda_codec_write(codec, nid, 0, | 951 | snd_hda_set_pin_ctl(codec, nid, |
| 952 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 953 | (spdif_present && spec->sense_b) ? 0 : PIN_HP); | 952 | (spdif_present && spec->sense_b) ? 0 : PIN_HP); |
| 954 | } | 953 | } |
| 955 | 954 | ||
| 956 | /* SPDIF TX on/off */ | 955 | /* SPDIF TX on/off */ |
| 957 | if (cfg->dig_outs) { | 956 | if (cfg->dig_outs) { |
| 958 | nid = cfg->dig_out_pins[0]; | 957 | nid = cfg->dig_out_pins[0]; |
| 959 | snd_hda_codec_write(codec, nid, 0, | 958 | snd_hda_set_pin_ctl(codec, nid, |
| 960 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 961 | spdif_present ? PIN_OUT : 0); | 959 | spdif_present ? PIN_OUT : 0); |
| 962 | 960 | ||
| 963 | } | 961 | } |
| @@ -1024,13 +1022,11 @@ static void init_output(struct hda_codec *codec) | |||
| 1024 | 1022 | ||
| 1025 | /* set appropriate pin controls */ | 1023 | /* set appropriate pin controls */ |
| 1026 | for (i = 0; i < cfg->line_outs; i++) | 1024 | for (i = 0; i < cfg->line_outs; i++) |
| 1027 | snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, | 1025 | snd_hda_set_pin_ctl(codec, cfg->line_out_pins[i], PIN_OUT); |
| 1028 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
| 1029 | /* HP */ | 1026 | /* HP */ |
| 1030 | for (i = 0; i < cfg->hp_outs; i++) { | 1027 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1031 | hda_nid_t nid = cfg->hp_pins[i]; | 1028 | hda_nid_t nid = cfg->hp_pins[i]; |
| 1032 | snd_hda_codec_write(codec, nid, 0, | 1029 | snd_hda_set_pin_ctl(codec, nid, PIN_HP); |
| 1033 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
| 1034 | if (!cfg->speaker_outs) | 1030 | if (!cfg->speaker_outs) |
| 1035 | continue; | 1031 | continue; |
| 1036 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { | 1032 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { |
| @@ -1041,8 +1037,7 @@ static void init_output(struct hda_codec *codec) | |||
| 1041 | 1037 | ||
| 1042 | /* Speaker */ | 1038 | /* Speaker */ |
| 1043 | for (i = 0; i < cfg->speaker_outs; i++) | 1039 | for (i = 0; i < cfg->speaker_outs; i++) |
| 1044 | snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, | 1040 | snd_hda_set_pin_ctl(codec, cfg->speaker_pins[i], PIN_OUT); |
| 1045 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
| 1046 | 1041 | ||
| 1047 | /* SPDIF is enabled on presence detect for CS421x */ | 1042 | /* SPDIF is enabled on presence detect for CS421x */ |
| 1048 | if (spec->hp_detect || spec->spdif_detect) | 1043 | if (spec->hp_detect || spec->spdif_detect) |
| @@ -1063,14 +1058,9 @@ static void init_input(struct hda_codec *codec) | |||
| 1063 | continue; | 1058 | continue; |
| 1064 | /* set appropriate pin control and mute first */ | 1059 | /* set appropriate pin control and mute first */ |
| 1065 | ctl = PIN_IN; | 1060 | ctl = PIN_IN; |
| 1066 | if (cfg->inputs[i].type == AUTO_PIN_MIC) { | 1061 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
| 1067 | unsigned int caps = snd_hda_query_pin_caps(codec, pin); | 1062 | ctl |= snd_hda_get_default_vref(codec, pin); |
| 1068 | caps >>= AC_PINCAP_VREF_SHIFT; | 1063 | snd_hda_set_pin_ctl(codec, pin, ctl); |
| 1069 | if (caps & AC_PINCAP_VREF_80) | ||
| 1070 | ctl = PIN_VREF80; | ||
| 1071 | } | ||
| 1072 | snd_hda_codec_write(codec, pin, 0, | ||
| 1073 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); | ||
| 1074 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, | 1064 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, |
| 1075 | AC_VERB_SET_AMP_GAIN_MUTE, | 1065 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1076 | AMP_IN_MUTE(spec->adc_idx[i])); | 1066 | AMP_IN_MUTE(spec->adc_idx[i])); |
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index b6767b4ced44..c8fdaaefe702 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <sound/core.h> | 29 | #include <sound/core.h> |
| 30 | #include "hda_codec.h" | 30 | #include "hda_codec.h" |
| 31 | #include "hda_local.h" | 31 | #include "hda_local.h" |
| 32 | #include "hda_auto_parser.h" | ||
| 32 | #define NUM_PINS 11 | 33 | #define NUM_PINS 11 |
| 33 | 34 | ||
| 34 | 35 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index d906c5b74cf0..3acb5824ad39 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | #include "hda_codec.h" | 31 | #include "hda_codec.h" |
| 32 | #include "hda_local.h" | 32 | #include "hda_local.h" |
| 33 | #include "hda_auto_parser.h" | ||
| 33 | #include "hda_beep.h" | 34 | #include "hda_beep.h" |
| 34 | #include "hda_jack.h" | 35 | #include "hda_jack.h" |
| 35 | 36 | ||
| @@ -66,6 +67,7 @@ struct imux_info { | |||
| 66 | }; | 67 | }; |
| 67 | 68 | ||
| 68 | struct conexant_spec { | 69 | struct conexant_spec { |
| 70 | struct hda_gen_spec gen; | ||
| 69 | 71 | ||
| 70 | const struct snd_kcontrol_new *mixers[5]; | 72 | const struct snd_kcontrol_new *mixers[5]; |
| 71 | int num_mixers; | 73 | int num_mixers; |
| @@ -141,6 +143,7 @@ struct conexant_spec { | |||
| 141 | unsigned int hp_laptop:1; | 143 | unsigned int hp_laptop:1; |
| 142 | unsigned int asus:1; | 144 | unsigned int asus:1; |
| 143 | unsigned int pin_eapd_ctrls:1; | 145 | unsigned int pin_eapd_ctrls:1; |
| 146 | unsigned int fixup_stereo_dmic:1; | ||
| 144 | 147 | ||
| 145 | unsigned int adc_switching:1; | 148 | unsigned int adc_switching:1; |
| 146 | 149 | ||
| @@ -1601,17 +1604,13 @@ static void cxt5051_update_speaker(struct hda_codec *codec) | |||
| 1601 | unsigned int pinctl; | 1604 | unsigned int pinctl; |
| 1602 | /* headphone pin */ | 1605 | /* headphone pin */ |
| 1603 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; | 1606 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; |
| 1604 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1607 | snd_hda_set_pin_ctl(codec, 0x16, pinctl); |
| 1605 | pinctl); | ||
| 1606 | /* speaker pin */ | 1608 | /* speaker pin */ |
| 1607 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | 1609 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
| 1608 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1610 | snd_hda_set_pin_ctl(codec, 0x1a, pinctl); |
| 1609 | pinctl); | ||
| 1610 | /* on ideapad there is an additional speaker (subwoofer) to mute */ | 1611 | /* on ideapad there is an additional speaker (subwoofer) to mute */ |
| 1611 | if (spec->ideapad) | 1612 | if (spec->ideapad) |
| 1612 | snd_hda_codec_write(codec, 0x1b, 0, | 1613 | snd_hda_set_pin_ctl(codec, 0x1b, pinctl); |
| 1613 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 1614 | pinctl); | ||
| 1615 | } | 1614 | } |
| 1616 | 1615 | ||
| 1617 | /* turn on/off EAPD (+ mute HP) as a master switch */ | 1616 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| @@ -1996,8 +1995,7 @@ static void cxt5066_update_speaker(struct hda_codec *codec) | |||
| 1996 | 1995 | ||
| 1997 | /* Port A (HP) */ | 1996 | /* Port A (HP) */ |
| 1998 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; | 1997 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
| 1999 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1998 | snd_hda_set_pin_ctl(codec, 0x19, pinctl); |
| 2000 | pinctl); | ||
| 2001 | 1999 | ||
| 2002 | /* Port D (HP/LO) */ | 2000 | /* Port D (HP/LO) */ |
| 2003 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; | 2001 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
| @@ -2010,13 +2008,11 @@ static void cxt5066_update_speaker(struct hda_codec *codec) | |||
| 2010 | if (!hp_port_d_present(spec)) | 2008 | if (!hp_port_d_present(spec)) |
| 2011 | pinctl = 0; | 2009 | pinctl = 0; |
| 2012 | } | 2010 | } |
| 2013 | snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2011 | snd_hda_set_pin_ctl(codec, 0x1c, pinctl); |
| 2014 | pinctl); | ||
| 2015 | 2012 | ||
| 2016 | /* CLASS_D AMP */ | 2013 | /* CLASS_D AMP */ |
| 2017 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | 2014 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
| 2018 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2015 | snd_hda_set_pin_ctl(codec, 0x1f, pinctl); |
| 2019 | pinctl); | ||
| 2020 | } | 2016 | } |
| 2021 | 2017 | ||
| 2022 | /* turn on/off EAPD (+ mute HP) as a master switch */ | 2018 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| @@ -2047,8 +2043,7 @@ static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) | |||
| 2047 | /* Even though port F is the DC input, the bias is controlled on port B. | 2043 | /* Even though port F is the DC input, the bias is controlled on port B. |
| 2048 | * we also leave that port as an active input (but unselected) in DC mode | 2044 | * we also leave that port as an active input (but unselected) in DC mode |
| 2049 | * just in case that is necessary to make the bias setting take effect. */ | 2045 | * just in case that is necessary to make the bias setting take effect. */ |
| 2050 | return snd_hda_codec_write_cache(codec, 0x1a, 0, | 2046 | return snd_hda_set_pin_ctl_cache(codec, 0x1a, |
| 2051 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 2052 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); | 2047 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); |
| 2053 | } | 2048 | } |
| 2054 | 2049 | ||
| @@ -2081,14 +2076,14 @@ static void cxt5066_olpc_select_mic(struct hda_codec *codec) | |||
| 2081 | } | 2076 | } |
| 2082 | 2077 | ||
| 2083 | /* disable DC (port F) */ | 2078 | /* disable DC (port F) */ |
| 2084 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | 2079 | snd_hda_set_pin_ctl(codec, 0x1e, 0); |
| 2085 | 2080 | ||
| 2086 | /* external mic, port B */ | 2081 | /* external mic, port B */ |
| 2087 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2082 | snd_hda_set_pin_ctl(codec, 0x1a, |
| 2088 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); | 2083 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); |
| 2089 | 2084 | ||
| 2090 | /* internal mic, port C */ | 2085 | /* internal mic, port C */ |
| 2091 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2086 | snd_hda_set_pin_ctl(codec, 0x1b, |
| 2092 | spec->ext_mic_present ? 0 : PIN_VREF80); | 2087 | spec->ext_mic_present ? 0 : PIN_VREF80); |
| 2093 | } | 2088 | } |
| 2094 | 2089 | ||
| @@ -3357,9 +3352,7 @@ static void do_automute(struct hda_codec *codec, int num_pins, | |||
| 3357 | struct conexant_spec *spec = codec->spec; | 3352 | struct conexant_spec *spec = codec->spec; |
| 3358 | int i; | 3353 | int i; |
| 3359 | for (i = 0; i < num_pins; i++) | 3354 | for (i = 0; i < num_pins; i++) |
| 3360 | snd_hda_codec_write(codec, pins[i], 0, | 3355 | snd_hda_set_pin_ctl(codec, pins[i], on ? PIN_OUT : 0); |
| 3361 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 3362 | on ? PIN_OUT : 0); | ||
| 3363 | if (spec->pin_eapd_ctrls) | 3356 | if (spec->pin_eapd_ctrls) |
| 3364 | cx_auto_turn_eapd(codec, num_pins, pins, on); | 3357 | cx_auto_turn_eapd(codec, num_pins, pins, on); |
| 3365 | } | 3358 | } |
| @@ -3976,8 +3969,7 @@ static void cx_auto_init_output(struct hda_codec *codec) | |||
| 3976 | if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) & | 3969 | if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) & |
| 3977 | AC_PINCAP_HP_DRV) | 3970 | AC_PINCAP_HP_DRV) |
| 3978 | val |= AC_PINCTL_HP_EN; | 3971 | val |= AC_PINCTL_HP_EN; |
| 3979 | snd_hda_codec_write(codec, cfg->hp_pins[i], 0, | 3972 | snd_hda_set_pin_ctl(codec, cfg->hp_pins[i], val); |
| 3980 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
| 3981 | } | 3973 | } |
| 3982 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); | 3974 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); |
| 3983 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); | 3975 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); |
| @@ -4030,13 +4022,11 @@ static void cx_auto_init_input(struct hda_codec *codec) | |||
| 4030 | } | 4022 | } |
| 4031 | 4023 | ||
| 4032 | for (i = 0; i < cfg->num_inputs; i++) { | 4024 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4033 | unsigned int type; | 4025 | hda_nid_t pin = cfg->inputs[i].pin; |
| 4026 | unsigned int type = PIN_IN; | ||
| 4034 | if (cfg->inputs[i].type == AUTO_PIN_MIC) | 4027 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
| 4035 | type = PIN_VREF80; | 4028 | type |= snd_hda_get_default_vref(codec, pin); |
| 4036 | else | 4029 | snd_hda_set_pin_ctl(codec, pin, type); |
| 4037 | type = PIN_IN; | ||
| 4038 | snd_hda_codec_write(codec, cfg->inputs[i].pin, 0, | ||
| 4039 | AC_VERB_SET_PIN_WIDGET_CONTROL, type); | ||
| 4040 | } | 4030 | } |
| 4041 | 4031 | ||
| 4042 | if (spec->auto_mic) { | 4032 | if (spec->auto_mic) { |
| @@ -4063,11 +4053,9 @@ static void cx_auto_init_digital(struct hda_codec *codec) | |||
| 4063 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4053 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4064 | 4054 | ||
| 4065 | if (spec->multiout.dig_out_nid) | 4055 | if (spec->multiout.dig_out_nid) |
| 4066 | snd_hda_codec_write(codec, cfg->dig_out_pins[0], 0, | 4056 | snd_hda_set_pin_ctl(codec, cfg->dig_out_pins[0], PIN_OUT); |
| 4067 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
| 4068 | if (spec->dig_in_nid) | 4057 | if (spec->dig_in_nid) |
| 4069 | snd_hda_codec_write(codec, cfg->dig_in_pin, 0, | 4058 | snd_hda_set_pin_ctl(codec, cfg->dig_in_pin, PIN_IN); |
| 4070 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); | ||
| 4071 | } | 4059 | } |
| 4072 | 4060 | ||
| 4073 | static int cx_auto_init(struct hda_codec *codec) | 4061 | static int cx_auto_init(struct hda_codec *codec) |
| @@ -4084,9 +4072,9 @@ static int cx_auto_init(struct hda_codec *codec) | |||
| 4084 | 4072 | ||
| 4085 | static int cx_auto_add_volume_idx(struct hda_codec *codec, const char *basename, | 4073 | static int cx_auto_add_volume_idx(struct hda_codec *codec, const char *basename, |
| 4086 | const char *dir, int cidx, | 4074 | const char *dir, int cidx, |
| 4087 | hda_nid_t nid, int hda_dir, int amp_idx) | 4075 | hda_nid_t nid, int hda_dir, int amp_idx, int chs) |
| 4088 | { | 4076 | { |
| 4089 | static char name[32]; | 4077 | static char name[44]; |
| 4090 | static struct snd_kcontrol_new knew[] = { | 4078 | static struct snd_kcontrol_new knew[] = { |
| 4091 | HDA_CODEC_VOLUME(name, 0, 0, 0), | 4079 | HDA_CODEC_VOLUME(name, 0, 0, 0), |
| 4092 | HDA_CODEC_MUTE(name, 0, 0, 0), | 4080 | HDA_CODEC_MUTE(name, 0, 0, 0), |
| @@ -4096,7 +4084,7 @@ static int cx_auto_add_volume_idx(struct hda_codec *codec, const char *basename, | |||
| 4096 | 4084 | ||
| 4097 | for (i = 0; i < 2; i++) { | 4085 | for (i = 0; i < 2; i++) { |
| 4098 | struct snd_kcontrol *kctl; | 4086 | struct snd_kcontrol *kctl; |
| 4099 | knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, 3, amp_idx, | 4087 | knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, chs, amp_idx, |
| 4100 | hda_dir); | 4088 | hda_dir); |
| 4101 | knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; | 4089 | knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; |
| 4102 | knew[i].index = cidx; | 4090 | knew[i].index = cidx; |
| @@ -4115,7 +4103,7 @@ static int cx_auto_add_volume_idx(struct hda_codec *codec, const char *basename, | |||
| 4115 | } | 4103 | } |
| 4116 | 4104 | ||
| 4117 | #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \ | 4105 | #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \ |
| 4118 | cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0) | 4106 | cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0, 3) |
| 4119 | 4107 | ||
| 4120 | #define cx_auto_add_pb_volume(codec, nid, str, idx) \ | 4108 | #define cx_auto_add_pb_volume(codec, nid, str, idx) \ |
| 4121 | cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) | 4109 | cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) |
| @@ -4185,6 +4173,36 @@ static int cx_auto_build_output_controls(struct hda_codec *codec) | |||
| 4185 | return 0; | 4173 | return 0; |
| 4186 | } | 4174 | } |
| 4187 | 4175 | ||
| 4176 | /* Returns zero if this is a normal stereo channel, and non-zero if it should | ||
| 4177 | be split in two independent channels. | ||
| 4178 | dest_label must be at least 44 characters. */ | ||
| 4179 | static int cx_auto_get_rightch_label(struct hda_codec *codec, const char *label, | ||
| 4180 | char *dest_label, int nid) | ||
| 4181 | { | ||
| 4182 | struct conexant_spec *spec = codec->spec; | ||
| 4183 | int i; | ||
| 4184 | |||
| 4185 | if (!spec->fixup_stereo_dmic) | ||
| 4186 | return 0; | ||
| 4187 | |||
| 4188 | for (i = 0; i < AUTO_CFG_MAX_INS; i++) { | ||
| 4189 | int def_conf; | ||
| 4190 | if (spec->autocfg.inputs[i].pin != nid) | ||
| 4191 | continue; | ||
| 4192 | |||
| 4193 | if (spec->autocfg.inputs[i].type != AUTO_PIN_MIC) | ||
| 4194 | return 0; | ||
| 4195 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 4196 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) | ||
| 4197 | return 0; | ||
| 4198 | |||
| 4199 | /* Finally found the inverted internal mic! */ | ||
| 4200 | snprintf(dest_label, 44, "Inverted %s", label); | ||
| 4201 | return 1; | ||
| 4202 | } | ||
| 4203 | return 0; | ||
| 4204 | } | ||
| 4205 | |||
| 4188 | static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid, | 4206 | static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid, |
| 4189 | const char *label, const char *pfx, | 4207 | const char *label, const char *pfx, |
| 4190 | int cidx) | 4208 | int cidx) |
| @@ -4193,14 +4211,25 @@ static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid, | |||
| 4193 | int i; | 4211 | int i; |
| 4194 | 4212 | ||
| 4195 | for (i = 0; i < spec->num_adc_nids; i++) { | 4213 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 4214 | char rightch_label[44]; | ||
| 4196 | hda_nid_t adc_nid = spec->adc_nids[i]; | 4215 | hda_nid_t adc_nid = spec->adc_nids[i]; |
| 4197 | int idx = get_input_connection(codec, adc_nid, nid); | 4216 | int idx = get_input_connection(codec, adc_nid, nid); |
| 4198 | if (idx < 0) | 4217 | if (idx < 0) |
| 4199 | continue; | 4218 | continue; |
| 4200 | if (codec->single_adc_amp) | 4219 | if (codec->single_adc_amp) |
| 4201 | idx = 0; | 4220 | idx = 0; |
| 4221 | |||
| 4222 | if (cx_auto_get_rightch_label(codec, label, rightch_label, nid)) { | ||
| 4223 | /* Make two independent kcontrols for left and right */ | ||
| 4224 | int err = cx_auto_add_volume_idx(codec, label, pfx, | ||
| 4225 | cidx, adc_nid, HDA_INPUT, idx, 1); | ||
| 4226 | if (err < 0) | ||
| 4227 | return err; | ||
| 4228 | return cx_auto_add_volume_idx(codec, rightch_label, pfx, | ||
| 4229 | cidx, adc_nid, HDA_INPUT, idx, 2); | ||
| 4230 | } | ||
| 4202 | return cx_auto_add_volume_idx(codec, label, pfx, | 4231 | return cx_auto_add_volume_idx(codec, label, pfx, |
| 4203 | cidx, adc_nid, HDA_INPUT, idx); | 4232 | cidx, adc_nid, HDA_INPUT, idx, 3); |
| 4204 | } | 4233 | } |
| 4205 | return 0; | 4234 | return 0; |
| 4206 | } | 4235 | } |
| @@ -4213,9 +4242,19 @@ static int cx_auto_add_boost_volume(struct hda_codec *codec, int idx, | |||
| 4213 | int i, con; | 4242 | int i, con; |
| 4214 | 4243 | ||
| 4215 | nid = spec->imux_info[idx].pin; | 4244 | nid = spec->imux_info[idx].pin; |
| 4216 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | 4245 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4246 | char rightch_label[44]; | ||
| 4247 | if (cx_auto_get_rightch_label(codec, label, rightch_label, nid)) { | ||
| 4248 | int err = cx_auto_add_volume_idx(codec, label, " Boost", | ||
| 4249 | cidx, nid, HDA_INPUT, 0, 1); | ||
| 4250 | if (err < 0) | ||
| 4251 | return err; | ||
| 4252 | return cx_auto_add_volume_idx(codec, rightch_label, " Boost", | ||
| 4253 | cidx, nid, HDA_INPUT, 0, 2); | ||
| 4254 | } | ||
| 4217 | return cx_auto_add_volume(codec, label, " Boost", cidx, | 4255 | return cx_auto_add_volume(codec, label, " Boost", cidx, |
| 4218 | nid, HDA_INPUT); | 4256 | nid, HDA_INPUT); |
| 4257 | } | ||
| 4219 | con = __select_input_connection(codec, spec->imux_info[idx].adc, nid, | 4258 | con = __select_input_connection(codec, spec->imux_info[idx].adc, nid, |
| 4220 | &mux, false, 0); | 4259 | &mux, false, 0); |
| 4221 | if (con < 0) | 4260 | if (con < 0) |
| @@ -4370,37 +4409,21 @@ static const struct hda_codec_ops cx_auto_patch_ops = { | |||
| 4370 | /* | 4409 | /* |
| 4371 | * pin fix-up | 4410 | * pin fix-up |
| 4372 | */ | 4411 | */ |
| 4373 | struct cxt_pincfg { | ||
| 4374 | hda_nid_t nid; | ||
| 4375 | u32 val; | ||
| 4376 | }; | ||
| 4377 | |||
| 4378 | static void apply_pincfg(struct hda_codec *codec, const struct cxt_pincfg *cfg) | ||
| 4379 | { | ||
| 4380 | for (; cfg->nid; cfg++) | ||
| 4381 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | ||
| 4382 | |||
| 4383 | } | ||
| 4384 | |||
| 4385 | static void apply_pin_fixup(struct hda_codec *codec, | ||
| 4386 | const struct snd_pci_quirk *quirk, | ||
| 4387 | const struct cxt_pincfg **table) | ||
| 4388 | { | ||
| 4389 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | ||
| 4390 | if (quirk) { | ||
| 4391 | snd_printdd(KERN_INFO "hda_codec: applying pincfg for %s\n", | ||
| 4392 | quirk->name); | ||
| 4393 | apply_pincfg(codec, table[quirk->value]); | ||
| 4394 | } | ||
| 4395 | } | ||
| 4396 | |||
| 4397 | enum { | 4412 | enum { |
| 4398 | CXT_PINCFG_LENOVO_X200, | 4413 | CXT_PINCFG_LENOVO_X200, |
| 4399 | CXT_PINCFG_LENOVO_TP410, | 4414 | CXT_PINCFG_LENOVO_TP410, |
| 4415 | CXT_FIXUP_STEREO_DMIC, | ||
| 4400 | }; | 4416 | }; |
| 4401 | 4417 | ||
| 4418 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec, | ||
| 4419 | const struct hda_fixup *fix, int action) | ||
| 4420 | { | ||
| 4421 | struct conexant_spec *spec = codec->spec; | ||
| 4422 | spec->fixup_stereo_dmic = 1; | ||
| 4423 | } | ||
| 4424 | |||
| 4402 | /* ThinkPad X200 & co with cxt5051 */ | 4425 | /* ThinkPad X200 & co with cxt5051 */ |
| 4403 | static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = { | 4426 | static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { |
| 4404 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ | 4427 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ |
| 4405 | { 0x17, 0x21a11000 }, /* dock-mic */ | 4428 | { 0x17, 0x21a11000 }, /* dock-mic */ |
| 4406 | { 0x19, 0x2121103f }, /* dock-HP */ | 4429 | { 0x19, 0x2121103f }, /* dock-HP */ |
| @@ -4409,16 +4432,26 @@ static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = { | |||
| 4409 | }; | 4432 | }; |
| 4410 | 4433 | ||
| 4411 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ | 4434 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ |
| 4412 | static const struct cxt_pincfg cxt_pincfg_lenovo_tp410[] = { | 4435 | static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { |
| 4413 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */ | 4436 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */ |
| 4414 | { 0x1a, 0x21a190f0 }, /* dock-mic */ | 4437 | { 0x1a, 0x21a190f0 }, /* dock-mic */ |
| 4415 | { 0x1c, 0x212140ff }, /* dock-HP */ | 4438 | { 0x1c, 0x212140ff }, /* dock-HP */ |
| 4416 | {} | 4439 | {} |
| 4417 | }; | 4440 | }; |
| 4418 | 4441 | ||
| 4419 | static const struct cxt_pincfg *cxt_pincfg_tbl[] = { | 4442 | static const struct hda_fixup cxt_fixups[] = { |
| 4420 | [CXT_PINCFG_LENOVO_X200] = cxt_pincfg_lenovo_x200, | 4443 | [CXT_PINCFG_LENOVO_X200] = { |
| 4421 | [CXT_PINCFG_LENOVO_TP410] = cxt_pincfg_lenovo_tp410, | 4444 | .type = HDA_FIXUP_PINS, |
| 4445 | .v.pins = cxt_pincfg_lenovo_x200, | ||
| 4446 | }, | ||
| 4447 | [CXT_PINCFG_LENOVO_TP410] = { | ||
| 4448 | .type = HDA_FIXUP_PINS, | ||
| 4449 | .v.pins = cxt_pincfg_lenovo_tp410, | ||
| 4450 | }, | ||
| 4451 | [CXT_FIXUP_STEREO_DMIC] = { | ||
| 4452 | .type = HDA_FIXUP_FUNC, | ||
| 4453 | .v.func = cxt_fixup_stereo_dmic, | ||
| 4454 | }, | ||
| 4422 | }; | 4455 | }; |
| 4423 | 4456 | ||
| 4424 | static const struct snd_pci_quirk cxt5051_fixups[] = { | 4457 | static const struct snd_pci_quirk cxt5051_fixups[] = { |
| @@ -4432,6 +4465,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = { | |||
| 4432 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), | 4465 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), |
| 4433 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), | 4466 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), |
| 4434 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), | 4467 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), |
| 4468 | SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), | ||
| 4435 | {} | 4469 | {} |
| 4436 | }; | 4470 | }; |
| 4437 | 4471 | ||
| @@ -4471,13 +4505,16 @@ static int patch_conexant_auto(struct hda_codec *codec) | |||
| 4471 | case 0x14f15051: | 4505 | case 0x14f15051: |
| 4472 | add_cx5051_fake_mutes(codec); | 4506 | add_cx5051_fake_mutes(codec); |
| 4473 | codec->pin_amp_workaround = 1; | 4507 | codec->pin_amp_workaround = 1; |
| 4474 | apply_pin_fixup(codec, cxt5051_fixups, cxt_pincfg_tbl); | 4508 | snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); |
| 4475 | break; | 4509 | break; |
| 4476 | default: | 4510 | default: |
| 4477 | codec->pin_amp_workaround = 1; | 4511 | codec->pin_amp_workaround = 1; |
| 4478 | apply_pin_fixup(codec, cxt5066_fixups, cxt_pincfg_tbl); | 4512 | snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); |
| 4513 | break; | ||
| 4479 | } | 4514 | } |
| 4480 | 4515 | ||
| 4516 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | ||
| 4517 | |||
| 4481 | /* Show mute-led control only on HP laptops | 4518 | /* Show mute-led control only on HP laptops |
| 4482 | * This is a sort of white-list: on HP laptops, EAPD corresponds | 4519 | * This is a sort of white-list: on HP laptops, EAPD corresponds |
| 4483 | * only to the mute-LED without actualy amp function. Meanwhile, | 4520 | * only to the mute-LED without actualy amp function. Meanwhile, |
| @@ -4556,6 +4593,12 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = { | |||
| 4556 | .patch = patch_conexant_auto }, | 4593 | .patch = patch_conexant_auto }, |
| 4557 | { .id = 0x14f150b9, .name = "CX20665", | 4594 | { .id = 0x14f150b9, .name = "CX20665", |
| 4558 | .patch = patch_conexant_auto }, | 4595 | .patch = patch_conexant_auto }, |
| 4596 | { .id = 0x14f1510f, .name = "CX20751/2", | ||
| 4597 | .patch = patch_conexant_auto }, | ||
| 4598 | { .id = 0x14f15110, .name = "CX20751/2", | ||
| 4599 | .patch = patch_conexant_auto }, | ||
| 4600 | { .id = 0x14f15111, .name = "CX20753/4", | ||
| 4601 | .patch = patch_conexant_auto }, | ||
| 4559 | {} /* terminator */ | 4602 | {} /* terminator */ |
| 4560 | }; | 4603 | }; |
| 4561 | 4604 | ||
| @@ -4576,6 +4619,9 @@ MODULE_ALIAS("snd-hda-codec-id:14f150ab"); | |||
| 4576 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); | 4619 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); |
| 4577 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); | 4620 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); |
| 4578 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); | 4621 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); |
| 4622 | MODULE_ALIAS("snd-hda-codec-id:14f1510f"); | ||
| 4623 | MODULE_ALIAS("snd-hda-codec-id:14f15110"); | ||
| 4624 | MODULE_ALIAS("snd-hda-codec-id:14f15111"); | ||
| 4579 | 4625 | ||
| 4580 | MODULE_LICENSE("GPL"); | 4626 | MODULE_LICENSE("GPL"); |
| 4581 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | 4627 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 83f345f3c961..ad319d4dc32f 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
| @@ -1592,10 +1592,10 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
| 1592 | unsigned int dataDCC2, channel_id; | 1592 | unsigned int dataDCC2, channel_id; |
| 1593 | int i; | 1593 | int i; |
| 1594 | struct hdmi_spec *spec = codec->spec; | 1594 | struct hdmi_spec *spec = codec->spec; |
| 1595 | struct hda_spdif_out *spdif = | 1595 | struct hda_spdif_out *spdif; |
| 1596 | snd_hda_spdif_out_of_nid(codec, spec->cvts[0].cvt_nid); | ||
| 1597 | 1596 | ||
| 1598 | mutex_lock(&codec->spdif_mutex); | 1597 | mutex_lock(&codec->spdif_mutex); |
| 1598 | spdif = snd_hda_spdif_out_of_nid(codec, spec->cvts[0].cvt_nid); | ||
| 1599 | 1599 | ||
| 1600 | chs = substream->runtime->channels; | 1600 | chs = substream->runtime->channels; |
| 1601 | 1601 | ||
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 818f90bc7d57..152f458afd2b 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <sound/jack.h> | 32 | #include <sound/jack.h> |
| 33 | #include "hda_codec.h" | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
| 35 | #include "hda_auto_parser.h" | ||
| 35 | #include "hda_beep.h" | 36 | #include "hda_beep.h" |
| 36 | #include "hda_jack.h" | 37 | #include "hda_jack.h" |
| 37 | 38 | ||
| @@ -66,8 +67,6 @@ struct alc_customize_define { | |||
| 66 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ | 67 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
| 67 | }; | 68 | }; |
| 68 | 69 | ||
| 69 | struct alc_fixup; | ||
| 70 | |||
| 71 | struct alc_multi_io { | 70 | struct alc_multi_io { |
| 72 | hda_nid_t pin; /* multi-io widget pin NID */ | 71 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 73 | hda_nid_t dac; /* DAC to be connected */ | 72 | hda_nid_t dac; /* DAC to be connected */ |
| @@ -82,19 +81,33 @@ enum { | |||
| 82 | 81 | ||
| 83 | #define MAX_VOL_NIDS 0x40 | 82 | #define MAX_VOL_NIDS 0x40 |
| 84 | 83 | ||
| 84 | /* make compatible with old code */ | ||
| 85 | #define alc_apply_pincfgs snd_hda_apply_pincfgs | ||
| 86 | #define alc_apply_fixup snd_hda_apply_fixup | ||
| 87 | #define alc_pick_fixup snd_hda_pick_fixup | ||
| 88 | #define alc_fixup hda_fixup | ||
| 89 | #define alc_pincfg hda_pintbl | ||
| 90 | #define alc_model_fixup hda_model_fixup | ||
| 91 | |||
| 92 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS | ||
| 93 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS | ||
| 94 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC | ||
| 95 | |||
| 96 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE | ||
| 97 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE | ||
| 98 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT | ||
| 99 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD | ||
| 100 | |||
| 101 | |||
| 85 | struct alc_spec { | 102 | struct alc_spec { |
| 103 | struct hda_gen_spec gen; | ||
| 104 | |||
| 86 | /* codec parameterization */ | 105 | /* codec parameterization */ |
| 87 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ | 106 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
| 88 | unsigned int num_mixers; | 107 | unsigned int num_mixers; |
| 89 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ | 108 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
| 90 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ | 109 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
| 91 | 110 | ||
| 92 | const struct hda_verb *init_verbs[10]; /* initialization verbs | ||
| 93 | * don't forget NULL | ||
| 94 | * termination! | ||
| 95 | */ | ||
| 96 | unsigned int num_init_verbs; | ||
| 97 | |||
| 98 | char stream_name_analog[32]; /* analog PCM stream */ | 111 | char stream_name_analog[32]; /* analog PCM stream */ |
| 99 | const struct hda_pcm_stream *stream_analog_playback; | 112 | const struct hda_pcm_stream *stream_analog_playback; |
| 100 | const struct hda_pcm_stream *stream_analog_capture; | 113 | const struct hda_pcm_stream *stream_analog_capture; |
| @@ -210,11 +223,6 @@ struct alc_spec { | |||
| 210 | unsigned int pll_coef_idx, pll_coef_bit; | 223 | unsigned int pll_coef_idx, pll_coef_bit; |
| 211 | unsigned int coef0; | 224 | unsigned int coef0; |
| 212 | 225 | ||
| 213 | /* fix-up list */ | ||
| 214 | int fixup_id; | ||
| 215 | const struct alc_fixup *fixup_list; | ||
| 216 | const char *fixup_name; | ||
| 217 | |||
| 218 | /* multi-io */ | 226 | /* multi-io */ |
| 219 | int multi_ios; | 227 | int multi_ios; |
| 220 | struct alc_multi_io multi_io[4]; | 228 | struct alc_multi_io multi_io[4]; |
| @@ -319,13 +327,16 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, | |||
| 319 | 327 | ||
| 320 | /* for shared I/O, change the pin-control accordingly */ | 328 | /* for shared I/O, change the pin-control accordingly */ |
| 321 | if (spec->shared_mic_hp) { | 329 | if (spec->shared_mic_hp) { |
| 330 | unsigned int val; | ||
| 331 | hda_nid_t pin = spec->autocfg.inputs[1].pin; | ||
| 322 | /* NOTE: this assumes that there are only two inputs, the | 332 | /* NOTE: this assumes that there are only two inputs, the |
| 323 | * first is the real internal mic and the second is HP jack. | 333 | * first is the real internal mic and the second is HP jack. |
| 324 | */ | 334 | */ |
| 325 | snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0, | 335 | if (spec->cur_mux[adc_idx]) |
| 326 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 336 | val = snd_hda_get_default_vref(codec, pin) | PIN_IN; |
| 327 | spec->cur_mux[adc_idx] ? | 337 | else |
| 328 | PIN_VREF80 : PIN_HP); | 338 | val = PIN_HP; |
| 339 | snd_hda_set_pin_ctl(codec, pin, val); | ||
| 329 | spec->automute_speaker = !spec->cur_mux[adc_idx]; | 340 | spec->automute_speaker = !spec->cur_mux[adc_idx]; |
| 330 | call_update_outputs(codec); | 341 | call_update_outputs(codec); |
| 331 | } | 342 | } |
| @@ -376,25 +387,9 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, | |||
| 376 | int auto_pin_type) | 387 | int auto_pin_type) |
| 377 | { | 388 | { |
| 378 | unsigned int val = PIN_IN; | 389 | unsigned int val = PIN_IN; |
| 379 | 390 | if (auto_pin_type == AUTO_PIN_MIC) | |
| 380 | if (auto_pin_type == AUTO_PIN_MIC) { | 391 | val |= snd_hda_get_default_vref(codec, nid); |
| 381 | unsigned int pincap; | 392 | snd_hda_set_pin_ctl(codec, nid, val); |
| 382 | unsigned int oldval; | ||
| 383 | oldval = snd_hda_codec_read(codec, nid, 0, | ||
| 384 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
| 385 | pincap = snd_hda_query_pin_caps(codec, nid); | ||
| 386 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; | ||
| 387 | /* if the default pin setup is vref50, we give it priority */ | ||
| 388 | if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) | ||
| 389 | val = PIN_VREF80; | ||
| 390 | else if (pincap & AC_PINCAP_VREF_50) | ||
| 391 | val = PIN_VREF50; | ||
| 392 | else if (pincap & AC_PINCAP_VREF_100) | ||
| 393 | val = PIN_VREF100; | ||
| 394 | else if (pincap & AC_PINCAP_VREF_GRD) | ||
| 395 | val = PIN_VREFGRD; | ||
| 396 | } | ||
| 397 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
| 398 | } | 393 | } |
| 399 | 394 | ||
| 400 | /* | 395 | /* |
| @@ -409,13 +404,6 @@ static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix) | |||
| 409 | spec->mixers[spec->num_mixers++] = mix; | 404 | spec->mixers[spec->num_mixers++] = mix; |
| 410 | } | 405 | } |
| 411 | 406 | ||
| 412 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | ||
| 413 | { | ||
| 414 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) | ||
| 415 | return; | ||
| 416 | spec->init_verbs[spec->num_init_verbs++] = verb; | ||
| 417 | } | ||
| 418 | |||
| 419 | /* | 407 | /* |
| 420 | * GPIO setup tables, used in initialization | 408 | * GPIO setup tables, used in initialization |
| 421 | */ | 409 | */ |
| @@ -517,9 +505,7 @@ static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, | |||
| 517 | } else | 505 | } else |
| 518 | val = 0; | 506 | val = 0; |
| 519 | val |= pin_bits; | 507 | val |= pin_bits; |
| 520 | snd_hda_codec_write(codec, nid, 0, | 508 | snd_hda_set_pin_ctl(codec, nid, val); |
| 521 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 522 | val); | ||
| 523 | break; | 509 | break; |
| 524 | case ALC_AUTOMUTE_AMP: | 510 | case ALC_AUTOMUTE_AMP: |
| 525 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 511 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| @@ -1200,6 +1186,16 @@ static void alc_auto_check_switches(struct hda_codec *codec) | |||
| 1200 | */ | 1186 | */ |
| 1201 | #define ALC_FIXUP_SKU_IGNORE (2) | 1187 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1202 | 1188 | ||
| 1189 | static void alc_fixup_sku_ignore(struct hda_codec *codec, | ||
| 1190 | const struct hda_fixup *fix, int action) | ||
| 1191 | { | ||
| 1192 | struct alc_spec *spec = codec->spec; | ||
| 1193 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
| 1194 | spec->cdefine.fixup = 1; | ||
| 1195 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; | ||
| 1196 | } | ||
| 1197 | } | ||
| 1198 | |||
| 1203 | static int alc_auto_parse_customize_define(struct hda_codec *codec) | 1199 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1204 | { | 1200 | { |
| 1205 | unsigned int ass, tmp, i; | 1201 | unsigned int ass, tmp, i; |
| @@ -1403,178 +1399,6 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) | |||
| 1403 | } | 1399 | } |
| 1404 | 1400 | ||
| 1405 | /* | 1401 | /* |
| 1406 | * Fix-up pin default configurations and add default verbs | ||
| 1407 | */ | ||
| 1408 | |||
| 1409 | struct alc_pincfg { | ||
| 1410 | hda_nid_t nid; | ||
| 1411 | u32 val; | ||
| 1412 | }; | ||
| 1413 | |||
| 1414 | struct alc_model_fixup { | ||
| 1415 | const int id; | ||
| 1416 | const char *name; | ||
| 1417 | }; | ||
| 1418 | |||
| 1419 | struct alc_fixup { | ||
| 1420 | int type; | ||
| 1421 | bool chained; | ||
| 1422 | int chain_id; | ||
| 1423 | union { | ||
| 1424 | unsigned int sku; | ||
| 1425 | const struct alc_pincfg *pins; | ||
| 1426 | const struct hda_verb *verbs; | ||
| 1427 | void (*func)(struct hda_codec *codec, | ||
| 1428 | const struct alc_fixup *fix, | ||
| 1429 | int action); | ||
| 1430 | } v; | ||
| 1431 | }; | ||
| 1432 | |||
| 1433 | enum { | ||
| 1434 | ALC_FIXUP_INVALID, | ||
| 1435 | ALC_FIXUP_SKU, | ||
| 1436 | ALC_FIXUP_PINS, | ||
| 1437 | ALC_FIXUP_VERBS, | ||
| 1438 | ALC_FIXUP_FUNC, | ||
| 1439 | }; | ||
| 1440 | |||
| 1441 | enum { | ||
| 1442 | ALC_FIXUP_ACT_PRE_PROBE, | ||
| 1443 | ALC_FIXUP_ACT_PROBE, | ||
| 1444 | ALC_FIXUP_ACT_INIT, | ||
| 1445 | ALC_FIXUP_ACT_BUILD, | ||
| 1446 | }; | ||
| 1447 | |||
| 1448 | static void alc_apply_pincfgs(struct hda_codec *codec, | ||
| 1449 | const struct alc_pincfg *cfg) | ||
| 1450 | { | ||
| 1451 | for (; cfg->nid; cfg++) | ||
| 1452 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | ||
| 1453 | } | ||
| 1454 | |||
| 1455 | static void alc_apply_fixup(struct hda_codec *codec, int action) | ||
| 1456 | { | ||
| 1457 | struct alc_spec *spec = codec->spec; | ||
| 1458 | int id = spec->fixup_id; | ||
| 1459 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
| 1460 | const char *modelname = spec->fixup_name; | ||
| 1461 | #endif | ||
| 1462 | int depth = 0; | ||
| 1463 | |||
| 1464 | if (!spec->fixup_list) | ||
| 1465 | return; | ||
| 1466 | |||
| 1467 | while (id >= 0) { | ||
| 1468 | const struct alc_fixup *fix = spec->fixup_list + id; | ||
| 1469 | const struct alc_pincfg *cfg; | ||
| 1470 | |||
| 1471 | switch (fix->type) { | ||
| 1472 | case ALC_FIXUP_SKU: | ||
| 1473 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) | ||
| 1474 | break; | ||
| 1475 | snd_printdd(KERN_INFO "hda_codec: %s: " | ||
| 1476 | "Apply sku override for %s\n", | ||
| 1477 | codec->chip_name, modelname); | ||
| 1478 | spec->cdefine.sku_cfg = fix->v.sku; | ||
| 1479 | spec->cdefine.fixup = 1; | ||
| 1480 | break; | ||
| 1481 | case ALC_FIXUP_PINS: | ||
| 1482 | cfg = fix->v.pins; | ||
| 1483 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) | ||
| 1484 | break; | ||
| 1485 | snd_printdd(KERN_INFO "hda_codec: %s: " | ||
| 1486 | "Apply pincfg for %s\n", | ||
| 1487 | codec->chip_name, modelname); | ||
| 1488 | alc_apply_pincfgs(codec, cfg); | ||
| 1489 | break; | ||
| 1490 | case ALC_FIXUP_VERBS: | ||
| 1491 | if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) | ||
| 1492 | break; | ||
| 1493 | snd_printdd(KERN_INFO "hda_codec: %s: " | ||
| 1494 | "Apply fix-verbs for %s\n", | ||
| 1495 | codec->chip_name, modelname); | ||
| 1496 | add_verb(codec->spec, fix->v.verbs); | ||
| 1497 | break; | ||
| 1498 | case ALC_FIXUP_FUNC: | ||
| 1499 | if (!fix->v.func) | ||
| 1500 | break; | ||
| 1501 | snd_printdd(KERN_INFO "hda_codec: %s: " | ||
| 1502 | "Apply fix-func for %s\n", | ||
| 1503 | codec->chip_name, modelname); | ||
| 1504 | fix->v.func(codec, fix, action); | ||
| 1505 | break; | ||
| 1506 | default: | ||
| 1507 | snd_printk(KERN_ERR "hda_codec: %s: " | ||
| 1508 | "Invalid fixup type %d\n", | ||
| 1509 | codec->chip_name, fix->type); | ||
| 1510 | break; | ||
| 1511 | } | ||
| 1512 | if (!fix->chained) | ||
| 1513 | break; | ||
| 1514 | if (++depth > 10) | ||
| 1515 | break; | ||
| 1516 | id = fix->chain_id; | ||
| 1517 | } | ||
| 1518 | } | ||
| 1519 | |||
| 1520 | static void alc_pick_fixup(struct hda_codec *codec, | ||
| 1521 | const struct alc_model_fixup *models, | ||
| 1522 | const struct snd_pci_quirk *quirk, | ||
| 1523 | const struct alc_fixup *fixlist) | ||
| 1524 | { | ||
| 1525 | struct alc_spec *spec = codec->spec; | ||
| 1526 | const struct snd_pci_quirk *q; | ||
| 1527 | int id = -1; | ||
| 1528 | const char *name = NULL; | ||
| 1529 | |||
| 1530 | /* when model=nofixup is given, don't pick up any fixups */ | ||
| 1531 | if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { | ||
| 1532 | spec->fixup_list = NULL; | ||
| 1533 | spec->fixup_id = -1; | ||
| 1534 | return; | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | if (codec->modelname && models) { | ||
| 1538 | while (models->name) { | ||
| 1539 | if (!strcmp(codec->modelname, models->name)) { | ||
| 1540 | id = models->id; | ||
| 1541 | name = models->name; | ||
| 1542 | break; | ||
| 1543 | } | ||
| 1544 | models++; | ||
| 1545 | } | ||
| 1546 | } | ||
| 1547 | if (id < 0) { | ||
| 1548 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); | ||
| 1549 | if (q) { | ||
| 1550 | id = q->value; | ||
| 1551 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
| 1552 | name = q->name; | ||
| 1553 | #endif | ||
| 1554 | } | ||
| 1555 | } | ||
| 1556 | if (id < 0) { | ||
| 1557 | for (q = quirk; q->subvendor; q++) { | ||
| 1558 | unsigned int vendorid = | ||
| 1559 | q->subdevice | (q->subvendor << 16); | ||
| 1560 | if (vendorid == codec->subsystem_id) { | ||
| 1561 | id = q->value; | ||
| 1562 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
| 1563 | name = q->name; | ||
| 1564 | #endif | ||
| 1565 | break; | ||
| 1566 | } | ||
| 1567 | } | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | spec->fixup_id = id; | ||
| 1571 | if (id >= 0) { | ||
| 1572 | spec->fixup_list = fixlist; | ||
| 1573 | spec->fixup_name = name; | ||
| 1574 | } | ||
| 1575 | } | ||
| 1576 | |||
| 1577 | /* | ||
| 1578 | * COEF access helper functions | 1402 | * COEF access helper functions |
| 1579 | */ | 1403 | */ |
| 1580 | static int alc_read_coef_idx(struct hda_codec *codec, | 1404 | static int alc_read_coef_idx(struct hda_codec *codec, |
| @@ -1621,8 +1445,7 @@ static void alc_auto_init_digital(struct hda_codec *codec) | |||
| 1621 | pin = spec->autocfg.dig_out_pins[i]; | 1445 | pin = spec->autocfg.dig_out_pins[i]; |
| 1622 | if (!pin) | 1446 | if (!pin) |
| 1623 | continue; | 1447 | continue; |
| 1624 | snd_hda_codec_write(codec, pin, 0, | 1448 | snd_hda_set_pin_ctl(codec, pin, PIN_OUT); |
| 1625 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
| 1626 | if (!i) | 1449 | if (!i) |
| 1627 | dac = spec->multiout.dig_out_nid; | 1450 | dac = spec->multiout.dig_out_nid; |
| 1628 | else | 1451 | else |
| @@ -1635,9 +1458,7 @@ static void alc_auto_init_digital(struct hda_codec *codec) | |||
| 1635 | } | 1458 | } |
| 1636 | pin = spec->autocfg.dig_in_pin; | 1459 | pin = spec->autocfg.dig_in_pin; |
| 1637 | if (pin) | 1460 | if (pin) |
| 1638 | snd_hda_codec_write(codec, pin, 0, | 1461 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
| 1639 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 1640 | PIN_IN); | ||
| 1641 | } | 1462 | } |
| 1642 | 1463 | ||
| 1643 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ | 1464 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| @@ -2068,7 +1889,6 @@ static void alc_auto_init_std(struct hda_codec *codec); | |||
| 2068 | static int alc_init(struct hda_codec *codec) | 1889 | static int alc_init(struct hda_codec *codec) |
| 2069 | { | 1890 | { |
| 2070 | struct alc_spec *spec = codec->spec; | 1891 | struct alc_spec *spec = codec->spec; |
| 2071 | unsigned int i; | ||
| 2072 | 1892 | ||
| 2073 | if (spec->init_hook) | 1893 | if (spec->init_hook) |
| 2074 | spec->init_hook(codec); | 1894 | spec->init_hook(codec); |
| @@ -2076,8 +1896,6 @@ static int alc_init(struct hda_codec *codec) | |||
| 2076 | alc_fix_pll(codec); | 1896 | alc_fix_pll(codec); |
| 2077 | alc_auto_init_amp(codec, spec->init_amp); | 1897 | alc_auto_init_amp(codec, spec->init_amp); |
| 2078 | 1898 | ||
| 2079 | for (i = 0; i < spec->num_init_verbs; i++) | ||
| 2080 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | ||
| 2081 | alc_init_special_input_src(codec); | 1899 | alc_init_special_input_src(codec); |
| 2082 | alc_auto_init_std(codec); | 1900 | alc_auto_init_std(codec); |
| 2083 | 1901 | ||
| @@ -2856,8 +2674,7 @@ static int alc_auto_create_shared_input(struct hda_codec *codec) | |||
| 2856 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, | 2674 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2857 | unsigned int pin_type) | 2675 | unsigned int pin_type) |
| 2858 | { | 2676 | { |
| 2859 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2677 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
| 2860 | pin_type); | ||
| 2861 | /* unmute pin */ | 2678 | /* unmute pin */ |
| 2862 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) | 2679 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2863 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 2680 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| @@ -3998,9 +3815,7 @@ static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) | |||
| 3998 | snd_hda_codec_read(codec, nid, 0, | 3815 | snd_hda_codec_read(codec, nid, 0, |
| 3999 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 3816 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4000 | if (output) { | 3817 | if (output) { |
| 4001 | snd_hda_codec_update_cache(codec, nid, 0, | 3818 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
| 4002 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 4003 | PIN_OUT); | ||
| 4004 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | 3819 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 4005 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 3820 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 4006 | HDA_AMP_MUTE, 0); | 3821 | HDA_AMP_MUTE, 0); |
| @@ -4009,9 +3824,8 @@ static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) | |||
| 4009 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | 3824 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 4010 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 3825 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 4011 | HDA_AMP_MUTE, HDA_AMP_MUTE); | 3826 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
| 4012 | snd_hda_codec_update_cache(codec, nid, 0, | 3827 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4013 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 3828 | spec->multi_io[idx].ctl_in); |
| 4014 | spec->multi_io[idx].ctl_in); | ||
| 4015 | } | 3829 | } |
| 4016 | return 0; | 3830 | return 0; |
| 4017 | } | 3831 | } |
| @@ -4427,6 +4241,25 @@ static int alc_parse_auto_config(struct hda_codec *codec, | |||
| 4427 | return 1; | 4241 | return 1; |
| 4428 | } | 4242 | } |
| 4429 | 4243 | ||
| 4244 | /* common preparation job for alc_spec */ | ||
| 4245 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) | ||
| 4246 | { | ||
| 4247 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
| 4248 | int err; | ||
| 4249 | |||
| 4250 | if (!spec) | ||
| 4251 | return -ENOMEM; | ||
| 4252 | codec->spec = spec; | ||
| 4253 | spec->mixer_nid = mixer_nid; | ||
| 4254 | |||
| 4255 | err = alc_codec_rename_from_preset(codec); | ||
| 4256 | if (err < 0) { | ||
| 4257 | kfree(spec); | ||
| 4258 | return err; | ||
| 4259 | } | ||
| 4260 | return 0; | ||
| 4261 | } | ||
| 4262 | |||
| 4430 | static int alc880_parse_auto_config(struct hda_codec *codec) | 4263 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4431 | { | 4264 | { |
| 4432 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; | 4265 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
| @@ -4808,13 +4641,11 @@ static int patch_alc880(struct hda_codec *codec) | |||
| 4808 | struct alc_spec *spec; | 4641 | struct alc_spec *spec; |
| 4809 | int err; | 4642 | int err; |
| 4810 | 4643 | ||
| 4811 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4644 | err = alc_alloc_spec(codec, 0x0b); |
| 4812 | if (spec == NULL) | 4645 | if (err < 0) |
| 4813 | return -ENOMEM; | 4646 | return err; |
| 4814 | |||
| 4815 | codec->spec = spec; | ||
| 4816 | 4647 | ||
| 4817 | spec->mixer_nid = 0x0b; | 4648 | spec = codec->spec; |
| 4818 | spec->need_dac_fix = 1; | 4649 | spec->need_dac_fix = 1; |
| 4819 | 4650 | ||
| 4820 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, | 4651 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| @@ -4890,7 +4721,7 @@ static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, | |||
| 4890 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ | 4721 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
| 4891 | snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); | 4722 | snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); |
| 4892 | spec->unsol_event = alc_sku_unsol_event; | 4723 | spec->unsol_event = alc_sku_unsol_event; |
| 4893 | add_verb(codec->spec, alc_gpio1_init_verbs); | 4724 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
| 4894 | } | 4725 | } |
| 4895 | } | 4726 | } |
| 4896 | 4727 | ||
| @@ -5001,13 +4832,11 @@ static int patch_alc260(struct hda_codec *codec) | |||
| 5001 | struct alc_spec *spec; | 4832 | struct alc_spec *spec; |
| 5002 | int err; | 4833 | int err; |
| 5003 | 4834 | ||
| 5004 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4835 | err = alc_alloc_spec(codec, 0x07); |
| 5005 | if (spec == NULL) | 4836 | if (err < 0) |
| 5006 | return -ENOMEM; | 4837 | return err; |
| 5007 | |||
| 5008 | codec->spec = spec; | ||
| 5009 | 4838 | ||
| 5010 | spec->mixer_nid = 0x07; | 4839 | spec = codec->spec; |
| 5011 | 4840 | ||
| 5012 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); | 4841 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5013 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 4842 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| @@ -5171,8 +5000,7 @@ static void alc889_fixup_mbp_vref(struct hda_codec *codec, | |||
| 5171 | val = snd_hda_codec_read(codec, nids[i], 0, | 5000 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5172 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 5001 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5173 | val |= AC_PINCTL_VREF_80; | 5002 | val |= AC_PINCTL_VREF_80; |
| 5174 | snd_hda_codec_write(codec, nids[i], 0, | 5003 | snd_hda_set_pin_ctl(codec, nids[i], val); |
| 5175 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
| 5176 | spec->keep_vref_in_automute = 1; | 5004 | spec->keep_vref_in_automute = 1; |
| 5177 | break; | 5005 | break; |
| 5178 | } | 5006 | } |
| @@ -5193,8 +5021,7 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec, | |||
| 5193 | val = snd_hda_codec_read(codec, nids[i], 0, | 5021 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5194 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 5022 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5195 | val |= AC_PINCTL_VREF_50; | 5023 | val |= AC_PINCTL_VREF_50; |
| 5196 | snd_hda_codec_write(codec, nids[i], 0, | 5024 | snd_hda_set_pin_ctl(codec, nids[i], val); |
| 5197 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
| 5198 | } | 5025 | } |
| 5199 | spec->keep_vref_in_automute = 1; | 5026 | spec->keep_vref_in_automute = 1; |
| 5200 | } | 5027 | } |
| @@ -5225,8 +5052,8 @@ static const struct alc_fixup alc882_fixups[] = { | |||
| 5225 | } | 5052 | } |
| 5226 | }, | 5053 | }, |
| 5227 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { | 5054 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
| 5228 | .type = ALC_FIXUP_SKU, | 5055 | .type = ALC_FIXUP_FUNC, |
| 5229 | .v.sku = ALC_FIXUP_SKU_IGNORE, | 5056 | .v.func = alc_fixup_sku_ignore, |
| 5230 | }, | 5057 | }, |
| 5231 | [ALC882_FIXUP_ASUS_W90V] = { | 5058 | [ALC882_FIXUP_ASUS_W90V] = { |
| 5232 | .type = ALC_FIXUP_PINS, | 5059 | .type = ALC_FIXUP_PINS, |
| @@ -5405,6 +5232,8 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { | |||
| 5405 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", | 5232 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5406 | ALC882_FIXUP_ACER_ASPIRE_4930G), | 5233 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5407 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), | 5234 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
| 5235 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", | ||
| 5236 | ALC882_FIXUP_ACER_ASPIRE_4930G), | ||
| 5408 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), | 5237 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
| 5409 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), | 5238 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5410 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), | 5239 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
| @@ -5438,6 +5267,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { | |||
| 5438 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), | 5267 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5439 | 5268 | ||
| 5440 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), | 5269 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
| 5270 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), | ||
| 5441 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), | 5271 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
| 5442 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), | 5272 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
| 5443 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), | 5273 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), |
| @@ -5473,13 +5303,11 @@ static int patch_alc882(struct hda_codec *codec) | |||
| 5473 | struct alc_spec *spec; | 5303 | struct alc_spec *spec; |
| 5474 | int err; | 5304 | int err; |
| 5475 | 5305 | ||
| 5476 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5306 | err = alc_alloc_spec(codec, 0x0b); |
| 5477 | if (spec == NULL) | 5307 | if (err < 0) |
| 5478 | return -ENOMEM; | 5308 | return err; |
| 5479 | |||
| 5480 | codec->spec = spec; | ||
| 5481 | 5309 | ||
| 5482 | spec->mixer_nid = 0x0b; | 5310 | spec = codec->spec; |
| 5483 | 5311 | ||
| 5484 | switch (codec->vendor_id) { | 5312 | switch (codec->vendor_id) { |
| 5485 | case 0x10ec0882: | 5313 | case 0x10ec0882: |
| @@ -5491,10 +5319,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
| 5491 | break; | 5319 | break; |
| 5492 | } | 5320 | } |
| 5493 | 5321 | ||
| 5494 | err = alc_codec_rename_from_preset(codec); | ||
| 5495 | if (err < 0) | ||
| 5496 | goto error; | ||
| 5497 | |||
| 5498 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, | 5322 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5499 | alc882_fixups); | 5323 | alc882_fixups); |
| 5500 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 5324 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| @@ -5618,13 +5442,11 @@ static int patch_alc262(struct hda_codec *codec) | |||
| 5618 | struct alc_spec *spec; | 5442 | struct alc_spec *spec; |
| 5619 | int err; | 5443 | int err; |
| 5620 | 5444 | ||
| 5621 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5445 | err = alc_alloc_spec(codec, 0x0b); |
| 5622 | if (spec == NULL) | 5446 | if (err < 0) |
| 5623 | return -ENOMEM; | 5447 | return err; |
| 5624 | |||
| 5625 | codec->spec = spec; | ||
| 5626 | 5448 | ||
| 5627 | spec->mixer_nid = 0x0b; | 5449 | spec = codec->spec; |
| 5628 | 5450 | ||
| 5629 | #if 0 | 5451 | #if 0 |
| 5630 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is | 5452 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| @@ -5638,13 +5460,13 @@ static int patch_alc262(struct hda_codec *codec) | |||
| 5638 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | 5460 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5639 | } | 5461 | } |
| 5640 | #endif | 5462 | #endif |
| 5641 | alc_auto_parse_customize_define(codec); | ||
| 5642 | |||
| 5643 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); | 5463 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5644 | 5464 | ||
| 5645 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); | 5465 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 5646 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 5466 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5647 | 5467 | ||
| 5468 | alc_auto_parse_customize_define(codec); | ||
| 5469 | |||
| 5648 | /* automatic parse from the BIOS config */ | 5470 | /* automatic parse from the BIOS config */ |
| 5649 | err = alc262_parse_auto_config(codec); | 5471 | err = alc262_parse_auto_config(codec); |
| 5650 | if (err < 0) | 5472 | if (err < 0) |
| @@ -5707,7 +5529,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
| 5707 | if (err > 0) { | 5529 | if (err > 0) { |
| 5708 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { | 5530 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5709 | add_mixer(spec, alc268_beep_mixer); | 5531 | add_mixer(spec, alc268_beep_mixer); |
| 5710 | add_verb(spec, alc268_beep_init_verbs); | 5532 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
| 5711 | } | 5533 | } |
| 5712 | } | 5534 | } |
| 5713 | return err; | 5535 | return err; |
| @@ -5720,13 +5542,12 @@ static int patch_alc268(struct hda_codec *codec) | |||
| 5720 | struct alc_spec *spec; | 5542 | struct alc_spec *spec; |
| 5721 | int i, has_beep, err; | 5543 | int i, has_beep, err; |
| 5722 | 5544 | ||
| 5723 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
| 5724 | if (spec == NULL) | ||
| 5725 | return -ENOMEM; | ||
| 5726 | |||
| 5727 | codec->spec = spec; | ||
| 5728 | |||
| 5729 | /* ALC268 has no aa-loopback mixer */ | 5545 | /* ALC268 has no aa-loopback mixer */ |
| 5546 | err = alc_alloc_spec(codec, 0); | ||
| 5547 | if (err < 0) | ||
| 5548 | return err; | ||
| 5549 | |||
| 5550 | spec = codec->spec; | ||
| 5730 | 5551 | ||
| 5731 | /* automatic parse from the BIOS config */ | 5552 | /* automatic parse from the BIOS config */ |
| 5732 | err = alc268_parse_auto_config(codec); | 5553 | err = alc268_parse_auto_config(codec); |
| @@ -5943,9 +5764,7 @@ static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) | |||
| 5943 | { | 5764 | { |
| 5944 | struct hda_codec *codec = private_data; | 5765 | struct hda_codec *codec = private_data; |
| 5945 | unsigned int pinval = enabled ? 0x20 : 0x24; | 5766 | unsigned int pinval = enabled ? 0x20 : 0x24; |
| 5946 | snd_hda_codec_update_cache(codec, 0x19, 0, | 5767 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
| 5947 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 5948 | pinval); | ||
| 5949 | } | 5768 | } |
| 5950 | 5769 | ||
| 5951 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, | 5770 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| @@ -6012,8 +5831,8 @@ static const struct alc_fixup alc269_fixups[] = { | |||
| 6012 | } | 5831 | } |
| 6013 | }, | 5832 | }, |
| 6014 | [ALC269_FIXUP_SKU_IGNORE] = { | 5833 | [ALC269_FIXUP_SKU_IGNORE] = { |
| 6015 | .type = ALC_FIXUP_SKU, | 5834 | .type = ALC_FIXUP_FUNC, |
| 6016 | .v.sku = ALC_FIXUP_SKU_IGNORE, | 5835 | .v.func = alc_fixup_sku_ignore, |
| 6017 | }, | 5836 | }, |
| 6018 | [ALC269_FIXUP_ASUS_G73JW] = { | 5837 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6019 | .type = ALC_FIXUP_PINS, | 5838 | .type = ALC_FIXUP_PINS, |
| @@ -6239,21 +6058,13 @@ static void alc269_fill_coef(struct hda_codec *codec) | |||
| 6239 | static int patch_alc269(struct hda_codec *codec) | 6058 | static int patch_alc269(struct hda_codec *codec) |
| 6240 | { | 6059 | { |
| 6241 | struct alc_spec *spec; | 6060 | struct alc_spec *spec; |
| 6242 | int err = 0; | 6061 | int err; |
| 6243 | |||
| 6244 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
| 6245 | if (spec == NULL) | ||
| 6246 | return -ENOMEM; | ||
| 6247 | |||
| 6248 | codec->spec = spec; | ||
| 6249 | |||
| 6250 | spec->mixer_nid = 0x0b; | ||
| 6251 | |||
| 6252 | alc_auto_parse_customize_define(codec); | ||
| 6253 | 6062 | ||
| 6254 | err = alc_codec_rename_from_preset(codec); | 6063 | err = alc_alloc_spec(codec, 0x0b); |
| 6255 | if (err < 0) | 6064 | if (err < 0) |
| 6256 | goto error; | 6065 | return err; |
| 6066 | |||
| 6067 | spec = codec->spec; | ||
| 6257 | 6068 | ||
| 6258 | if (codec->vendor_id == 0x10ec0269) { | 6069 | if (codec->vendor_id == 0x10ec0269) { |
| 6259 | spec->codec_variant = ALC269_TYPE_ALC269VA; | 6070 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
| @@ -6283,6 +6094,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
| 6283 | alc269_fixup_tbl, alc269_fixups); | 6094 | alc269_fixup_tbl, alc269_fixups); |
| 6284 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 6095 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6285 | 6096 | ||
| 6097 | alc_auto_parse_customize_define(codec); | ||
| 6098 | |||
| 6286 | /* automatic parse from the BIOS config */ | 6099 | /* automatic parse from the BIOS config */ |
| 6287 | err = alc269_parse_auto_config(codec); | 6100 | err = alc269_parse_auto_config(codec); |
| 6288 | if (err < 0) | 6101 | if (err < 0) |
| @@ -6343,8 +6156,7 @@ static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, | |||
| 6343 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) | 6156 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6344 | val |= AC_PINCTL_IN_EN; | 6157 | val |= AC_PINCTL_IN_EN; |
| 6345 | val |= AC_PINCTL_VREF_50; | 6158 | val |= AC_PINCTL_VREF_50; |
| 6346 | snd_hda_codec_write(codec, 0x0f, 0, | 6159 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
| 6347 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
| 6348 | spec->keep_vref_in_automute = 1; | 6160 | spec->keep_vref_in_automute = 1; |
| 6349 | } | 6161 | } |
| 6350 | 6162 | ||
| @@ -6398,13 +6210,11 @@ static int patch_alc861(struct hda_codec *codec) | |||
| 6398 | struct alc_spec *spec; | 6210 | struct alc_spec *spec; |
| 6399 | int err; | 6211 | int err; |
| 6400 | 6212 | ||
| 6401 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6213 | err = alc_alloc_spec(codec, 0x15); |
| 6402 | if (spec == NULL) | 6214 | if (err < 0) |
| 6403 | return -ENOMEM; | 6215 | return err; |
| 6404 | |||
| 6405 | codec->spec = spec; | ||
| 6406 | 6216 | ||
| 6407 | spec->mixer_nid = 0x15; | 6217 | spec = codec->spec; |
| 6408 | 6218 | ||
| 6409 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); | 6219 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6410 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 6220 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| @@ -6501,13 +6311,11 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
| 6501 | struct alc_spec *spec; | 6311 | struct alc_spec *spec; |
| 6502 | int err; | 6312 | int err; |
| 6503 | 6313 | ||
| 6504 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6314 | err = alc_alloc_spec(codec, 0x0b); |
| 6505 | if (spec == NULL) | 6315 | if (err < 0) |
| 6506 | return -ENOMEM; | 6316 | return err; |
| 6507 | |||
| 6508 | codec->spec = spec; | ||
| 6509 | 6317 | ||
| 6510 | spec->mixer_nid = 0x0b; | 6318 | spec = codec->spec; |
| 6511 | 6319 | ||
| 6512 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); | 6320 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6513 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 6321 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| @@ -6519,7 +6327,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
| 6519 | 6327 | ||
| 6520 | if (codec->vendor_id == 0x10ec0660) { | 6328 | if (codec->vendor_id == 0x10ec0660) { |
| 6521 | /* always turn on EAPD */ | 6329 | /* always turn on EAPD */ |
| 6522 | add_verb(spec, alc660vd_eapd_verbs); | 6330 | snd_hda_gen_add_verbs(&spec->gen, alc660vd_eapd_verbs); |
| 6523 | } | 6331 | } |
| 6524 | 6332 | ||
| 6525 | if (!spec->no_analog) { | 6333 | if (!spec->no_analog) { |
| @@ -6632,8 +6440,8 @@ static const struct alc_fixup alc662_fixups[] = { | |||
| 6632 | } | 6440 | } |
| 6633 | }, | 6441 | }, |
| 6634 | [ALC662_FIXUP_SKU_IGNORE] = { | 6442 | [ALC662_FIXUP_SKU_IGNORE] = { |
| 6635 | .type = ALC_FIXUP_SKU, | 6443 | .type = ALC_FIXUP_FUNC, |
| 6636 | .v.sku = ALC_FIXUP_SKU_IGNORE, | 6444 | .v.func = alc_fixup_sku_ignore, |
| 6637 | }, | 6445 | }, |
| 6638 | [ALC662_FIXUP_HP_RP5800] = { | 6446 | [ALC662_FIXUP_HP_RP5800] = { |
| 6639 | .type = ALC_FIXUP_PINS, | 6447 | .type = ALC_FIXUP_PINS, |
| @@ -6846,27 +6654,19 @@ static const struct alc_model_fixup alc662_fixup_models[] = { | |||
| 6846 | static int patch_alc662(struct hda_codec *codec) | 6654 | static int patch_alc662(struct hda_codec *codec) |
| 6847 | { | 6655 | { |
| 6848 | struct alc_spec *spec; | 6656 | struct alc_spec *spec; |
| 6849 | int err = 0; | 6657 | int err; |
| 6850 | |||
| 6851 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
| 6852 | if (!spec) | ||
| 6853 | return -ENOMEM; | ||
| 6854 | 6658 | ||
| 6855 | codec->spec = spec; | 6659 | err = alc_alloc_spec(codec, 0x0b); |
| 6660 | if (err < 0) | ||
| 6661 | return err; | ||
| 6856 | 6662 | ||
| 6857 | spec->mixer_nid = 0x0b; | 6663 | spec = codec->spec; |
| 6858 | 6664 | ||
| 6859 | /* handle multiple HPs as is */ | 6665 | /* handle multiple HPs as is */ |
| 6860 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; | 6666 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6861 | 6667 | ||
| 6862 | alc_auto_parse_customize_define(codec); | ||
| 6863 | |||
| 6864 | alc_fix_pll_init(codec, 0x20, 0x04, 15); | 6668 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6865 | 6669 | ||
| 6866 | err = alc_codec_rename_from_preset(codec); | ||
| 6867 | if (err < 0) | ||
| 6868 | goto error; | ||
| 6869 | |||
| 6870 | if ((alc_get_coef0(codec) & (1 << 14)) && | 6670 | if ((alc_get_coef0(codec) & (1 << 14)) && |
| 6871 | codec->bus->pci->subsystem_vendor == 0x1025 && | 6671 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6872 | spec->cdefine.platform_type == 1) { | 6672 | spec->cdefine.platform_type == 1) { |
| @@ -6877,6 +6677,9 @@ static int patch_alc662(struct hda_codec *codec) | |||
| 6877 | alc_pick_fixup(codec, alc662_fixup_models, | 6677 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6878 | alc662_fixup_tbl, alc662_fixups); | 6678 | alc662_fixup_tbl, alc662_fixups); |
| 6879 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); | 6679 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6680 | |||
| 6681 | alc_auto_parse_customize_define(codec); | ||
| 6682 | |||
| 6880 | /* automatic parse from the BIOS config */ | 6683 | /* automatic parse from the BIOS config */ |
| 6881 | err = alc662_parse_auto_config(codec); | 6684 | err = alc662_parse_auto_config(codec); |
| 6882 | if (err < 0) | 6685 | if (err < 0) |
| @@ -6926,16 +6729,12 @@ static int alc680_parse_auto_config(struct hda_codec *codec) | |||
| 6926 | */ | 6729 | */ |
| 6927 | static int patch_alc680(struct hda_codec *codec) | 6730 | static int patch_alc680(struct hda_codec *codec) |
| 6928 | { | 6731 | { |
| 6929 | struct alc_spec *spec; | ||
| 6930 | int err; | 6732 | int err; |
| 6931 | 6733 | ||
| 6932 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
| 6933 | if (spec == NULL) | ||
| 6934 | return -ENOMEM; | ||
| 6935 | |||
| 6936 | codec->spec = spec; | ||
| 6937 | |||
| 6938 | /* ALC680 has no aa-loopback mixer */ | 6734 | /* ALC680 has no aa-loopback mixer */ |
| 6735 | err = alc_alloc_spec(codec, 0); | ||
| 6736 | if (err < 0) | ||
| 6737 | return err; | ||
| 6939 | 6738 | ||
| 6940 | /* automatic parse from the BIOS config */ | 6739 | /* automatic parse from the BIOS config */ |
| 6941 | err = alc680_parse_auto_config(codec); | 6740 | err = alc680_parse_auto_config(codec); |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 4742cac26aa9..b04179be6205 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <sound/tlv.h> | 36 | #include <sound/tlv.h> |
| 37 | #include "hda_codec.h" | 37 | #include "hda_codec.h" |
| 38 | #include "hda_local.h" | 38 | #include "hda_local.h" |
| 39 | #include "hda_auto_parser.h" | ||
| 39 | #include "hda_beep.h" | 40 | #include "hda_beep.h" |
| 40 | #include "hda_jack.h" | 41 | #include "hda_jack.h" |
| 41 | 42 | ||
| @@ -681,8 +682,7 @@ static int stac_vrefout_set(struct hda_codec *codec, | |||
| 681 | pinctl &= ~AC_PINCTL_VREFEN; | 682 | pinctl &= ~AC_PINCTL_VREFEN; |
| 682 | pinctl |= (new_vref & AC_PINCTL_VREFEN); | 683 | pinctl |= (new_vref & AC_PINCTL_VREFEN); |
| 683 | 684 | ||
| 684 | error = snd_hda_codec_write_cache(codec, nid, 0, | 685 | error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl); |
| 685 | AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); | ||
| 686 | if (error < 0) | 686 | if (error < 0) |
| 687 | return error; | 687 | return error; |
| 688 | 688 | ||
| @@ -706,8 +706,7 @@ static unsigned int stac92xx_vref_set(struct hda_codec *codec, | |||
| 706 | else | 706 | else |
| 707 | pincfg |= AC_PINCTL_IN_EN; | 707 | pincfg |= AC_PINCTL_IN_EN; |
| 708 | 708 | ||
| 709 | error = snd_hda_codec_write_cache(codec, nid, 0, | 709 | error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg); |
| 710 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); | ||
| 711 | if (error < 0) | 710 | if (error < 0) |
| 712 | return error; | 711 | return error; |
| 713 | else | 712 | else |
| @@ -2505,27 +2504,10 @@ static int stac92xx_build_pcms(struct hda_codec *codec) | |||
| 2505 | return 0; | 2504 | return 0; |
| 2506 | } | 2505 | } |
| 2507 | 2506 | ||
| 2508 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, | ||
| 2509 | hda_nid_t nid) | ||
| 2510 | { | ||
| 2511 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | ||
| 2512 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; | ||
| 2513 | if (pincap & AC_PINCAP_VREF_100) | ||
| 2514 | return AC_PINCTL_VREF_100; | ||
| 2515 | if (pincap & AC_PINCAP_VREF_80) | ||
| 2516 | return AC_PINCTL_VREF_80; | ||
| 2517 | if (pincap & AC_PINCAP_VREF_50) | ||
| 2518 | return AC_PINCTL_VREF_50; | ||
| 2519 | if (pincap & AC_PINCAP_VREF_GRD) | ||
| 2520 | return AC_PINCTL_VREF_GRD; | ||
| 2521 | return 0; | ||
| 2522 | } | ||
| 2523 | |||
| 2524 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) | 2507 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2525 | 2508 | ||
| 2526 | { | 2509 | { |
| 2527 | snd_hda_codec_write_cache(codec, nid, 0, | 2510 | snd_hda_set_pin_ctl_cache(codec, nid, pin_type); |
| 2528 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | ||
| 2529 | } | 2511 | } |
| 2530 | 2512 | ||
| 2531 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info | 2513 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| @@ -2594,7 +2576,7 @@ static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, | |||
| 2594 | hda_nid_t nid = kcontrol->private_value; | 2576 | hda_nid_t nid = kcontrol->private_value; |
| 2595 | unsigned int vref = stac92xx_vref_get(codec, nid); | 2577 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 2596 | 2578 | ||
| 2597 | if (vref == stac92xx_get_default_vref(codec, nid)) | 2579 | if (vref == snd_hda_get_default_vref(codec, nid)) |
| 2598 | ucontrol->value.enumerated.item[0] = 0; | 2580 | ucontrol->value.enumerated.item[0] = 0; |
| 2599 | else if (vref == AC_PINCTL_VREF_GRD) | 2581 | else if (vref == AC_PINCTL_VREF_GRD) |
| 2600 | ucontrol->value.enumerated.item[0] = 1; | 2582 | ucontrol->value.enumerated.item[0] = 1; |
| @@ -2613,7 +2595,7 @@ static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, | |||
| 2613 | hda_nid_t nid = kcontrol->private_value; | 2595 | hda_nid_t nid = kcontrol->private_value; |
| 2614 | 2596 | ||
| 2615 | if (ucontrol->value.enumerated.item[0] == 0) | 2597 | if (ucontrol->value.enumerated.item[0] == 0) |
| 2616 | new_vref = stac92xx_get_default_vref(codec, nid); | 2598 | new_vref = snd_hda_get_default_vref(codec, nid); |
| 2617 | else if (ucontrol->value.enumerated.item[0] == 1) | 2599 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 2618 | new_vref = AC_PINCTL_VREF_GRD; | 2600 | new_vref = AC_PINCTL_VREF_GRD; |
| 2619 | else if (ucontrol->value.enumerated.item[0] == 2) | 2601 | else if (ucontrol->value.enumerated.item[0] == 2) |
| @@ -2679,7 +2661,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
| 2679 | else { | 2661 | else { |
| 2680 | unsigned int pinctl = AC_PINCTL_IN_EN; | 2662 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2681 | if (io_idx) /* set VREF for mic */ | 2663 | if (io_idx) /* set VREF for mic */ |
| 2682 | pinctl |= stac92xx_get_default_vref(codec, nid); | 2664 | pinctl |= snd_hda_get_default_vref(codec, nid); |
| 2683 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | 2665 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2684 | } | 2666 | } |
| 2685 | 2667 | ||
| @@ -2847,7 +2829,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, | |||
| 2847 | char name[22]; | 2829 | char name[22]; |
| 2848 | 2830 | ||
| 2849 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { | 2831 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { |
| 2850 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD | 2832 | if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
| 2851 | && nid == spec->line_switch) | 2833 | && nid == spec->line_switch) |
| 2852 | control = STAC_CTL_WIDGET_IO_SWITCH; | 2834 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2853 | else if (snd_hda_query_pin_caps(codec, nid) | 2835 | else if (snd_hda_query_pin_caps(codec, nid) |
| @@ -4354,7 +4336,7 @@ static int stac92xx_init(struct hda_codec *codec) | |||
| 4354 | unsigned int pinctl, conf; | 4336 | unsigned int pinctl, conf; |
| 4355 | if (type == AUTO_PIN_MIC) { | 4337 | if (type == AUTO_PIN_MIC) { |
| 4356 | /* for mic pins, force to initialize */ | 4338 | /* for mic pins, force to initialize */ |
| 4357 | pinctl = stac92xx_get_default_vref(codec, nid); | 4339 | pinctl = snd_hda_get_default_vref(codec, nid); |
| 4358 | pinctl |= AC_PINCTL_IN_EN; | 4340 | pinctl |= AC_PINCTL_IN_EN; |
| 4359 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | 4341 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 4360 | } else { | 4342 | } else { |
| @@ -4460,8 +4442,7 @@ static void stac92xx_shutup_pins(struct hda_codec *codec) | |||
| 4460 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); | 4442 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); |
| 4461 | def_conf = snd_hda_codec_get_pincfg(codec, pin->nid); | 4443 | def_conf = snd_hda_codec_get_pincfg(codec, pin->nid); |
| 4462 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) | 4444 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) |
| 4463 | snd_hda_codec_write(codec, pin->nid, 0, | 4445 | snd_hda_set_pin_ctl(codec, pin->nid, 0); |
| 4464 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
| 4465 | } | 4446 | } |
| 4466 | } | 4447 | } |
| 4467 | 4448 | ||
| @@ -4517,9 +4498,7 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
| 4517 | 4498 | ||
| 4518 | pin_ctl |= flag; | 4499 | pin_ctl |= flag; |
| 4519 | if (old_ctl != pin_ctl) | 4500 | if (old_ctl != pin_ctl) |
| 4520 | snd_hda_codec_write_cache(codec, nid, 0, | 4501 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl); |
| 4521 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 4522 | pin_ctl); | ||
| 4523 | } | 4502 | } |
| 4524 | 4503 | ||
| 4525 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | 4504 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| @@ -4528,9 +4507,7 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
| 4528 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, | 4507 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4529 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); | 4508 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
| 4530 | if (pin_ctl & flag) | 4509 | if (pin_ctl & flag) |
| 4531 | snd_hda_codec_write_cache(codec, nid, 0, | 4510 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag); |
| 4532 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 4533 | pin_ctl & ~flag); | ||
| 4534 | } | 4511 | } |
| 4535 | 4512 | ||
| 4536 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) | 4513 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
| @@ -5009,20 +4986,6 @@ static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | |||
| 5009 | return 0; | 4986 | return 0; |
| 5010 | } | 4987 | } |
| 5011 | 4988 | ||
| 5012 | static int stac92xx_pre_resume(struct hda_codec *codec) | ||
| 5013 | { | ||
| 5014 | struct sigmatel_spec *spec = codec->spec; | ||
| 5015 | |||
| 5016 | /* sync mute LED */ | ||
| 5017 | if (spec->vref_mute_led_nid) | ||
| 5018 | stac_vrefout_set(codec, spec->vref_mute_led_nid, | ||
| 5019 | spec->vref_led); | ||
| 5020 | else if (spec->gpio_led) | ||
| 5021 | stac_gpio_set(codec, spec->gpio_mask, | ||
| 5022 | spec->gpio_dir, spec->gpio_data); | ||
| 5023 | return 0; | ||
| 5024 | } | ||
| 5025 | |||
| 5026 | static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg, | 4989 | static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg, |
| 5027 | unsigned int power_state) | 4990 | unsigned int power_state) |
| 5028 | { | 4991 | { |
| @@ -5046,7 +5009,6 @@ static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
| 5046 | #else | 5009 | #else |
| 5047 | #define stac92xx_suspend NULL | 5010 | #define stac92xx_suspend NULL |
| 5048 | #define stac92xx_resume NULL | 5011 | #define stac92xx_resume NULL |
| 5049 | #define stac92xx_pre_resume NULL | ||
| 5050 | #define stac92xx_set_power_state NULL | 5012 | #define stac92xx_set_power_state NULL |
| 5051 | #endif /* CONFIG_PM */ | 5013 | #endif /* CONFIG_PM */ |
| 5052 | 5014 | ||
| @@ -5592,9 +5554,6 @@ again: | |||
| 5592 | codec->patch_ops.set_power_state = | 5554 | codec->patch_ops.set_power_state = |
| 5593 | stac92xx_set_power_state; | 5555 | stac92xx_set_power_state; |
| 5594 | } | 5556 | } |
| 5595 | #ifdef CONFIG_PM | ||
| 5596 | codec->patch_ops.pre_resume = stac92xx_pre_resume; | ||
| 5597 | #endif | ||
| 5598 | } | 5557 | } |
| 5599 | 5558 | ||
| 5600 | err = stac92xx_parse_auto_config(codec); | 5559 | err = stac92xx_parse_auto_config(codec); |
| @@ -5901,9 +5860,6 @@ again: | |||
| 5901 | codec->patch_ops.set_power_state = | 5860 | codec->patch_ops.set_power_state = |
| 5902 | stac92xx_set_power_state; | 5861 | stac92xx_set_power_state; |
| 5903 | } | 5862 | } |
| 5904 | #ifdef CONFIG_PM | ||
| 5905 | codec->patch_ops.pre_resume = stac92xx_pre_resume; | ||
| 5906 | #endif | ||
| 5907 | } | 5863 | } |
| 5908 | 5864 | ||
| 5909 | spec->multiout.dac_nids = spec->dac_nids; | 5865 | spec->multiout.dac_nids = spec->dac_nids; |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 06214fdc9486..db272fb5e579 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | #include <sound/asoundef.h> | 54 | #include <sound/asoundef.h> |
| 55 | #include "hda_codec.h" | 55 | #include "hda_codec.h" |
| 56 | #include "hda_local.h" | 56 | #include "hda_local.h" |
| 57 | #include "hda_auto_parser.h" | ||
| 57 | #include "hda_jack.h" | 58 | #include "hda_jack.h" |
| 58 | 59 | ||
| 59 | /* Pin Widget NID */ | 60 | /* Pin Widget NID */ |
| @@ -532,8 +533,7 @@ static void init_output_pin(struct hda_codec *codec, hda_nid_t pin, | |||
| 532 | { | 533 | { |
| 533 | if (!pin) | 534 | if (!pin) |
| 534 | return; | 535 | return; |
| 535 | snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 536 | snd_hda_set_pin_ctl(codec, pin, pin_type); |
| 536 | pin_type); | ||
| 537 | if (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD) | 537 | if (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD) |
| 538 | snd_hda_codec_write(codec, pin, 0, | 538 | snd_hda_codec_write(codec, pin, 0, |
| 539 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | 539 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); |
| @@ -662,12 +662,12 @@ static void via_auto_init_analog_input(struct hda_codec *codec) | |||
| 662 | hda_nid_t nid = cfg->inputs[i].pin; | 662 | hda_nid_t nid = cfg->inputs[i].pin; |
| 663 | if (spec->smart51_enabled && is_smart51_pins(codec, nid)) | 663 | if (spec->smart51_enabled && is_smart51_pins(codec, nid)) |
| 664 | ctl = PIN_OUT; | 664 | ctl = PIN_OUT; |
| 665 | else if (cfg->inputs[i].type == AUTO_PIN_MIC) | 665 | else { |
| 666 | ctl = PIN_VREF50; | ||
| 667 | else | ||
| 668 | ctl = PIN_IN; | 666 | ctl = PIN_IN; |
| 669 | snd_hda_codec_write(codec, nid, 0, | 667 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
| 670 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); | 668 | ctl |= snd_hda_get_default_vref(codec, nid); |
| 669 | } | ||
| 670 | snd_hda_set_pin_ctl(codec, nid, ctl); | ||
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | /* init input-src */ | 673 | /* init input-src */ |
| @@ -1006,9 +1006,7 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, | |||
| 1006 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 1006 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1007 | parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | 1007 | parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 1008 | parm |= out_in; | 1008 | parm |= out_in; |
| 1009 | snd_hda_codec_write(codec, nid, 0, | 1009 | snd_hda_set_pin_ctl(codec, nid, parm); |
| 1010 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 1011 | parm); | ||
| 1012 | if (out_in == AC_PINCTL_OUT_EN) { | 1010 | if (out_in == AC_PINCTL_OUT_EN) { |
| 1013 | mute_aa_path(codec, 1); | 1011 | mute_aa_path(codec, 1); |
| 1014 | notify_aa_path_ctls(codec); | 1012 | notify_aa_path_ctls(codec); |
| @@ -1647,8 +1645,7 @@ static void toggle_output_mutes(struct hda_codec *codec, int num_pins, | |||
| 1647 | parm &= ~AC_PINCTL_OUT_EN; | 1645 | parm &= ~AC_PINCTL_OUT_EN; |
| 1648 | else | 1646 | else |
| 1649 | parm |= AC_PINCTL_OUT_EN; | 1647 | parm |= AC_PINCTL_OUT_EN; |
| 1650 | snd_hda_codec_write(codec, pins[i], 0, | 1648 | snd_hda_set_pin_ctl(codec, pins[i], parm); |
| 1651 | AC_VERB_SET_PIN_WIDGET_CONTROL, parm); | ||
| 1652 | } | 1649 | } |
| 1653 | } | 1650 | } |
| 1654 | 1651 | ||
| @@ -1709,8 +1706,7 @@ static void via_gpio_control(struct hda_codec *codec) | |||
| 1709 | 1706 | ||
| 1710 | if (gpio_data == 0x02) { | 1707 | if (gpio_data == 0x02) { |
| 1711 | /* unmute line out */ | 1708 | /* unmute line out */ |
| 1712 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, | 1709 | snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], |
| 1713 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 1714 | PIN_OUT); | 1710 | PIN_OUT); |
| 1715 | if (vol_counter & 0x20) { | 1711 | if (vol_counter & 0x20) { |
| 1716 | /* decrease volume */ | 1712 | /* decrease volume */ |
| @@ -1728,9 +1724,7 @@ static void via_gpio_control(struct hda_codec *codec) | |||
| 1728 | } | 1724 | } |
| 1729 | } else if (!(gpio_data & 0x02)) { | 1725 | } else if (!(gpio_data & 0x02)) { |
| 1730 | /* mute line out */ | 1726 | /* mute line out */ |
| 1731 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, | 1727 | snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], 0); |
| 1732 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
| 1733 | 0); | ||
| 1734 | } | 1728 | } |
| 1735 | } | 1729 | } |
| 1736 | 1730 | ||
| @@ -2757,8 +2751,7 @@ static void via_auto_init_dig_in(struct hda_codec *codec) | |||
| 2757 | struct via_spec *spec = codec->spec; | 2751 | struct via_spec *spec = codec->spec; |
| 2758 | if (!spec->dig_in_nid) | 2752 | if (!spec->dig_in_nid) |
| 2759 | return; | 2753 | return; |
| 2760 | snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0, | 2754 | snd_hda_set_pin_ctl(codec, spec->autocfg.dig_in_pin, PIN_IN); |
| 2761 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); | ||
| 2762 | } | 2755 | } |
| 2763 | 2756 | ||
| 2764 | /* initialize the unsolicited events */ | 2757 | /* initialize the unsolicited events */ |
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index b68cdec03b9e..0b2aea2ce172 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
| @@ -5170,6 +5170,7 @@ static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp) | |||
| 5170 | strcpy(hw->name, "HDSP hwdep interface"); | 5170 | strcpy(hw->name, "HDSP hwdep interface"); |
| 5171 | 5171 | ||
| 5172 | hw->ops.ioctl = snd_hdsp_hwdep_ioctl; | 5172 | hw->ops.ioctl = snd_hdsp_hwdep_ioctl; |
| 5173 | hw->ops.ioctl_compat = snd_hdsp_hwdep_ioctl; | ||
| 5173 | 5174 | ||
| 5174 | return 0; | 5175 | return 0; |
| 5175 | } | 5176 | } |
