Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'topic/hda' into for-linus

+2849 -2251
+5 -3
Documentation/sound/alsa/HD-Audio.txt
··· 57 57 a case, you can change the default method via `position_fix` option. 58 58 59 59 `position_fix=1` means to use LPIB method explicitly. 60 - `position_fix=2` means to use the position-buffer. 0 is the default 61 - value, the automatic check and fallback to LPIB as described in the 62 - above. If you get a problem of repeated sounds, this option might 60 + `position_fix=2` means to use the position-buffer. 61 + `position_fix=3` means to use a combination of both methods, needed 62 + for some VIA and ATI controllers. 0 is the default value for all other 63 + controllers, the automatic check and fallback to LPIB as described in 64 + the above. If you get a problem of repeated sounds, this option might 63 65 help. 64 66 65 67 In addition to that, every controller is known to be broken regarding
+3 -1
include/sound/tlv.h
··· 38 38 #define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */ 39 39 #define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */ 40 40 41 + #define TLV_DB_SCALE_MASK 0xffff 42 + #define TLV_DB_SCALE_MUTE 0x10000 41 43 #define TLV_DB_SCALE_ITEM(min, step, mute) \ 42 44 SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int), \ 43 - (min), ((step) & 0xffff) | ((mute) ? 0x10000 : 0) 45 + (min), ((step) & TLV_DB_SCALE_MASK) | ((mute) ? TLV_DB_SCALE_MUTE : 0) 44 46 #define DECLARE_TLV_DB_SCALE(name, min, step, mute) \ 45 47 unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) } 46 48
+6 -33
sound/pci/hda/Kconfig
··· 119 119 snd-hda-codec-via. 120 120 This module is automatically loaded at probing. 121 121 122 - config SND_HDA_CODEC_ATIHDMI 123 - bool "Build ATI HDMI HD-audio codec support" 124 - default y 125 - help 126 - Say Y here to include ATI HDMI HD-audio codec support in 127 - snd-hda-intel driver, such as ATI RS600 HDMI. 128 - 129 - When the HD-audio driver is built as a module, the codec 130 - support code is also built as another module, 131 - snd-hda-codec-atihdmi. 132 - This module is automatically loaded at probing. 133 - 134 - config SND_HDA_CODEC_NVHDMI 135 - bool "Build NVIDIA HDMI HD-audio codec support" 136 - default y 137 - help 138 - Say Y here to include NVIDIA HDMI HD-audio codec support in 139 - snd-hda-intel driver, such as NVIDIA MCP78 HDMI. 140 - 141 - When the HD-audio driver is built as a module, the codec 142 - support code is also built as another module, 143 - snd-hda-codec-nvhdmi. 144 - This module is automatically loaded at probing. 145 - 146 - config SND_HDA_CODEC_INTELHDMI 147 - bool "Build INTEL HDMI HD-audio codec support" 122 + config SND_HDA_CODEC_HDMI 123 + bool "Build HDMI/DisplayPort HD-audio codec support" 148 124 select SND_DYNAMIC_MINORS 149 125 default y 150 126 help 151 - Say Y here to include INTEL HDMI HD-audio codec support in 152 - snd-hda-intel driver, such as Eaglelake integrated HDMI. 127 + Say Y here to include HDMI and DisplayPort HD-audio codec 128 + support in snd-hda-intel driver. This includes all AMD/ATI, 129 + Intel and Nvidia HDMI/DisplayPort codecs. 153 130 154 131 When the HD-audio driver is built as a module, the codec 155 132 support code is also built as another module, 156 - snd-hda-codec-intelhdmi. 133 + snd-hda-codec-hdmi. 157 134 This module is automatically loaded at probing. 158 - 159 - config SND_HDA_ELD 160 - def_bool y 161 - depends on SND_HDA_CODEC_INTELHDMI || SND_HDA_CODEC_NVHDMI 162 135 163 136 config SND_HDA_CODEC_CIRRUS 164 137 bool "Build Cirrus Logic codec support"
+3 -12
sound/pci/hda/Makefile
··· 3 3 snd-hda-codec-y := hda_codec.o 4 4 snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 5 5 snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o 6 - snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o 7 6 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 8 7 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o 9 8 ··· 11 12 snd-hda-codec-analog-objs := patch_analog.o 12 13 snd-hda-codec-idt-objs := patch_sigmatel.o 13 14 snd-hda-codec-si3054-objs := patch_si3054.o 14 - snd-hda-codec-atihdmi-objs := patch_atihdmi.o 15 15 snd-hda-codec-cirrus-objs := patch_cirrus.o 16 16 snd-hda-codec-ca0110-objs := patch_ca0110.o 17 17 snd-hda-codec-conexant-objs := patch_conexant.o 18 18 snd-hda-codec-via-objs := patch_via.o 19 - snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o 20 - snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o 19 + snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o 21 20 22 21 # common driver 23 22 obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o ··· 36 39 ifdef CONFIG_SND_HDA_CODEC_SI3054 37 40 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-si3054.o 38 41 endif 39 - ifdef CONFIG_SND_HDA_CODEC_ATIHDMI 40 - obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o 41 - endif 42 42 ifdef CONFIG_SND_HDA_CODEC_CIRRUS 43 43 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-cirrus.o 44 44 endif ··· 48 54 ifdef CONFIG_SND_HDA_CODEC_VIA 49 55 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-via.o 50 56 endif 51 - ifdef CONFIG_SND_HDA_CODEC_NVHDMI 52 - obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-nvhdmi.o 53 - endif 54 - ifdef CONFIG_SND_HDA_CODEC_INTELHDMI 55 - obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-intelhdmi.o 57 + ifdef CONFIG_SND_HDA_CODEC_HDMI 58 + obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-hdmi.o 56 59 endif 57 60 58 61 # this must be the last entry after codec drivers;
+216 -55
sound/pci/hda/hda_codec.c
··· 1216 1216 struct hda_codec *c; 1217 1217 struct hda_cvt_setup *p; 1218 1218 unsigned int oldval, newval; 1219 + int type; 1219 1220 int i; 1220 1221 1221 1222 if (!nid) ··· 1255 1254 p->dirty = 0; 1256 1255 1257 1256 /* make other inactive cvts with the same stream-tag dirty */ 1257 + type = get_wcaps_type(get_wcaps(codec, nid)); 1258 1258 list_for_each_entry(c, &codec->bus->codec_list, list) { 1259 1259 for (i = 0; i < c->cvt_setups.used; i++) { 1260 1260 p = snd_array_elem(&c->cvt_setups, i); 1261 - if (!p->active && p->stream_tag == stream_tag) 1261 + if (!p->active && p->stream_tag == stream_tag && 1262 + get_wcaps_type(get_wcaps(codec, p->nid)) == type) 1262 1263 p->dirty = 1; 1263 1264 } 1264 1265 } ··· 1283 1280 1284 1281 if (!nid) 1285 1282 return; 1283 + 1284 + if (codec->no_sticky_stream) 1285 + do_now = 1; 1286 1286 1287 1287 snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); 1288 1288 p = get_hda_cvt_setup(codec, nid); ··· 1837 1831 hda_nid_t nid = get_amp_nid(kcontrol); 1838 1832 int dir = get_amp_direction(kcontrol); 1839 1833 unsigned int ofs = get_amp_offset(kcontrol); 1834 + bool min_mute = get_amp_min_mute(kcontrol); 1840 1835 u32 caps, val1, val2; 1841 1836 1842 1837 if (size < 4 * sizeof(unsigned int)) ··· 1848 1841 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 1849 1842 val1 += ofs; 1850 1843 val1 = ((int)val1) * ((int)val2); 1844 + if (min_mute) 1845 + val2 |= TLV_DB_SCALE_MUTE; 1851 1846 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 1852 1847 return -EFAULT; 1853 1848 if (put_user(2 * sizeof(unsigned int), _tlv + 1)) ··· 2237 2228 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 2238 2229 HDA_AMP_MUTE, 2239 2230 *valp ? 0 : HDA_AMP_MUTE); 2240 - #ifdef CONFIG_SND_HDA_POWER_SAVE 2241 - if (codec->patch_ops.check_power_status) 2242 - codec->patch_ops.check_power_status(codec, nid); 2243 - #endif 2231 + hda_call_check_power_status(codec, nid); 2244 2232 snd_hda_power_down(codec); 2245 2233 return change; 2246 2234 } ··· 4378 4372 } 4379 4373 4380 4374 4375 + /* add the found input-pin to the cfg->inputs[] table */ 4376 + static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, 4377 + int type) 4378 + { 4379 + if (cfg->num_inputs < AUTO_CFG_MAX_INS) { 4380 + cfg->inputs[cfg->num_inputs].pin = nid; 4381 + cfg->inputs[cfg->num_inputs].type = type; 4382 + cfg->num_inputs++; 4383 + } 4384 + } 4385 + 4386 + /* sort inputs in the order of AUTO_PIN_* type */ 4387 + static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg) 4388 + { 4389 + int i, j; 4390 + 4391 + for (i = 0; i < cfg->num_inputs; i++) { 4392 + for (j = i + 1; j < cfg->num_inputs; j++) { 4393 + if (cfg->inputs[i].type > cfg->inputs[j].type) { 4394 + struct auto_pin_cfg_item tmp; 4395 + tmp = cfg->inputs[i]; 4396 + cfg->inputs[i] = cfg->inputs[j]; 4397 + cfg->inputs[j] = tmp; 4398 + } 4399 + } 4400 + } 4401 + } 4402 + 4381 4403 /* 4382 4404 * Parse all pin widgets and store the useful pin nids to cfg 4383 4405 * ··· 4419 4385 * output, i.e. to line_out_pins[0]. So, line_outs is always positive 4420 4386 * if any analog output exists. 4421 4387 * 4422 - * The analog input pins are assigned to input_pins array. 4388 + * The analog input pins are assigned to inputs array. 4423 4389 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 4424 4390 * respectively. 4425 4391 */ ··· 4432 4398 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)]; 4433 4399 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)]; 4434 4400 short sequences_hp[ARRAY_SIZE(cfg->hp_pins)]; 4401 + int i; 4435 4402 4436 4403 memset(cfg, 0, sizeof(*cfg)); 4437 4404 ··· 4503 4468 sequences_hp[cfg->hp_outs] = (assoc << 4) | seq; 4504 4469 cfg->hp_outs++; 4505 4470 break; 4506 - case AC_JACK_MIC_IN: { 4507 - int preferred, alt; 4508 - if (loc == AC_JACK_LOC_FRONT || 4509 - (loc & 0x30) == AC_JACK_LOC_INTERNAL) { 4510 - preferred = AUTO_PIN_FRONT_MIC; 4511 - alt = AUTO_PIN_MIC; 4512 - } else { 4513 - preferred = AUTO_PIN_MIC; 4514 - alt = AUTO_PIN_FRONT_MIC; 4515 - } 4516 - if (!cfg->input_pins[preferred]) 4517 - cfg->input_pins[preferred] = nid; 4518 - else if (!cfg->input_pins[alt]) 4519 - cfg->input_pins[alt] = nid; 4471 + case AC_JACK_MIC_IN: 4472 + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_MIC); 4520 4473 break; 4521 - } 4522 4474 case AC_JACK_LINE_IN: 4523 - if (loc == AC_JACK_LOC_FRONT) 4524 - cfg->input_pins[AUTO_PIN_FRONT_LINE] = nid; 4525 - else 4526 - cfg->input_pins[AUTO_PIN_LINE] = nid; 4475 + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_LINE_IN); 4527 4476 break; 4528 4477 case AC_JACK_CD: 4529 - cfg->input_pins[AUTO_PIN_CD] = nid; 4478 + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD); 4530 4479 break; 4531 4480 case AC_JACK_AUX: 4532 - cfg->input_pins[AUTO_PIN_AUX] = nid; 4481 + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX); 4533 4482 break; 4534 4483 case AC_JACK_SPDIF_OUT: 4535 4484 case AC_JACK_DIG_OTHER_OUT: ··· 4558 4539 memmove(sequences_hp + i, sequences_hp + i + 1, 4559 4540 sizeof(sequences_hp[0]) * (cfg->hp_outs - i)); 4560 4541 } 4542 + memset(cfg->hp_pins + cfg->hp_outs, 0, 4543 + sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs)); 4561 4544 } 4562 4545 4563 4546 /* sort by sequence */ ··· 4569 4548 cfg->speaker_outs); 4570 4549 sort_pins_by_sequence(cfg->hp_pins, sequences_hp, 4571 4550 cfg->hp_outs); 4572 - 4573 - /* if we have only one mic, make it AUTO_PIN_MIC */ 4574 - if (!cfg->input_pins[AUTO_PIN_MIC] && 4575 - cfg->input_pins[AUTO_PIN_FRONT_MIC]) { 4576 - cfg->input_pins[AUTO_PIN_MIC] = 4577 - cfg->input_pins[AUTO_PIN_FRONT_MIC]; 4578 - cfg->input_pins[AUTO_PIN_FRONT_MIC] = 0; 4579 - } 4580 - /* ditto for line-in */ 4581 - if (!cfg->input_pins[AUTO_PIN_LINE] && 4582 - cfg->input_pins[AUTO_PIN_FRONT_LINE]) { 4583 - cfg->input_pins[AUTO_PIN_LINE] = 4584 - cfg->input_pins[AUTO_PIN_FRONT_LINE]; 4585 - cfg->input_pins[AUTO_PIN_FRONT_LINE] = 0; 4586 - } 4587 4551 4588 4552 /* 4589 4553 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin ··· 4608 4602 break; 4609 4603 } 4610 4604 4605 + sort_autocfg_input_pins(cfg); 4606 + 4611 4607 /* 4612 4608 * debug prints of the parsed results 4613 4609 */ ··· 4629 4621 if (cfg->dig_outs) 4630 4622 snd_printd(" dig-out=0x%x/0x%x\n", 4631 4623 cfg->dig_out_pins[0], cfg->dig_out_pins[1]); 4632 - snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x," 4633 - " cd=0x%x, aux=0x%x\n", 4634 - cfg->input_pins[AUTO_PIN_MIC], 4635 - cfg->input_pins[AUTO_PIN_FRONT_MIC], 4636 - cfg->input_pins[AUTO_PIN_LINE], 4637 - cfg->input_pins[AUTO_PIN_FRONT_LINE], 4638 - cfg->input_pins[AUTO_PIN_CD], 4639 - cfg->input_pins[AUTO_PIN_AUX]); 4624 + snd_printd(" inputs:"); 4625 + for (i = 0; i < cfg->num_inputs; i++) { 4626 + snd_printdd(" %s=0x%x", 4627 + hda_get_autocfg_input_label(codec, cfg, i), 4628 + cfg->inputs[i].pin); 4629 + } 4630 + snd_printd("\n"); 4640 4631 if (cfg->dig_in_pin) 4641 4632 snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin); 4642 4633 ··· 4643 4636 } 4644 4637 EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); 4645 4638 4646 - /* labels for input pins */ 4647 - const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { 4648 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" 4649 - }; 4650 - EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); 4639 + int snd_hda_get_input_pin_attr(unsigned int def_conf) 4640 + { 4641 + unsigned int loc = get_defcfg_location(def_conf); 4642 + unsigned int conn = get_defcfg_connect(def_conf); 4643 + if (conn == AC_JACK_PORT_NONE) 4644 + return INPUT_PIN_ATTR_UNUSED; 4645 + /* Windows may claim the internal mic to be BOTH, too */ 4646 + if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) 4647 + return INPUT_PIN_ATTR_INT; 4648 + if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) 4649 + return INPUT_PIN_ATTR_INT; 4650 + if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) 4651 + return INPUT_PIN_ATTR_DOCK; 4652 + if (loc == AC_JACK_LOC_REAR) 4653 + return INPUT_PIN_ATTR_REAR; 4654 + if (loc == AC_JACK_LOC_FRONT) 4655 + return INPUT_PIN_ATTR_FRONT; 4656 + return INPUT_PIN_ATTR_NORMAL; 4657 + } 4658 + EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr); 4659 + 4660 + /** 4661 + * hda_get_input_pin_label - Give a label for the given input pin 4662 + * 4663 + * When check_location is true, the function checks the pin location 4664 + * for mic and line-in pins, and set an appropriate prefix like "Front", 4665 + * "Rear", "Internal". 4666 + */ 4667 + 4668 + const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, 4669 + int check_location) 4670 + { 4671 + unsigned int def_conf; 4672 + static const char *mic_names[] = { 4673 + "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic", 4674 + }; 4675 + int attr; 4676 + 4677 + def_conf = snd_hda_codec_get_pincfg(codec, pin); 4678 + 4679 + switch (get_defcfg_device(def_conf)) { 4680 + case AC_JACK_MIC_IN: 4681 + if (!check_location) 4682 + return "Mic"; 4683 + attr = snd_hda_get_input_pin_attr(def_conf); 4684 + if (!attr) 4685 + return "None"; 4686 + return mic_names[attr - 1]; 4687 + case AC_JACK_LINE_IN: 4688 + if (!check_location) 4689 + return "Line"; 4690 + attr = snd_hda_get_input_pin_attr(def_conf); 4691 + if (!attr) 4692 + return "None"; 4693 + if (attr == INPUT_PIN_ATTR_DOCK) 4694 + return "Dock Line"; 4695 + return "Line"; 4696 + case AC_JACK_AUX: 4697 + return "Aux"; 4698 + case AC_JACK_CD: 4699 + return "CD"; 4700 + case AC_JACK_SPDIF_IN: 4701 + return "SPDIF In"; 4702 + case AC_JACK_DIG_OTHER_IN: 4703 + return "Digital In"; 4704 + default: 4705 + return "Misc"; 4706 + } 4707 + } 4708 + EXPORT_SYMBOL_HDA(hda_get_input_pin_label); 4709 + 4710 + /* Check whether the location prefix needs to be added to the label. 4711 + * If all mic-jacks are in the same location (e.g. rear panel), we don't 4712 + * have to put "Front" prefix to each label. In such a case, returns false. 4713 + */ 4714 + static int check_mic_location_need(struct hda_codec *codec, 4715 + const struct auto_pin_cfg *cfg, 4716 + int input) 4717 + { 4718 + unsigned int defc; 4719 + int i, attr, attr2; 4720 + 4721 + defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); 4722 + attr = snd_hda_get_input_pin_attr(defc); 4723 + /* for internal or docking mics, we need locations */ 4724 + if (attr <= INPUT_PIN_ATTR_NORMAL) 4725 + return 1; 4726 + 4727 + attr = 0; 4728 + for (i = 0; i < cfg->num_inputs; i++) { 4729 + defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); 4730 + attr2 = snd_hda_get_input_pin_attr(defc); 4731 + if (attr2 >= INPUT_PIN_ATTR_NORMAL) { 4732 + if (attr && attr != attr2) 4733 + return 1; /* different locations found */ 4734 + attr = attr2; 4735 + } 4736 + } 4737 + return 0; 4738 + } 4739 + 4740 + /** 4741 + * hda_get_autocfg_input_label - Get a label for the given input 4742 + * 4743 + * Get a label for the given input pin defined by the autocfg item. 4744 + * Unlike hda_get_input_pin_label(), this function checks all inputs 4745 + * defined in autocfg and avoids the redundant mic/line prefix as much as 4746 + * possible. 4747 + */ 4748 + const char *hda_get_autocfg_input_label(struct hda_codec *codec, 4749 + const struct auto_pin_cfg *cfg, 4750 + int input) 4751 + { 4752 + int type = cfg->inputs[input].type; 4753 + int has_multiple_pins = 0; 4754 + 4755 + if ((input > 0 && cfg->inputs[input - 1].type == type) || 4756 + (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) 4757 + has_multiple_pins = 1; 4758 + if (has_multiple_pins && type == AUTO_PIN_MIC) 4759 + has_multiple_pins &= check_mic_location_need(codec, cfg, input); 4760 + return hda_get_input_pin_label(codec, cfg->inputs[input].pin, 4761 + has_multiple_pins); 4762 + } 4763 + EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); 4764 + 4765 + /** 4766 + * snd_hda_add_imux_item - Add an item to input_mux 4767 + * 4768 + * When the same label is used already in the existing items, the number 4769 + * suffix is appended to the label. This label index number is stored 4770 + * to type_idx when non-NULL pointer is given. 4771 + */ 4772 + int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, 4773 + int index, int *type_idx) 4774 + { 4775 + int i, label_idx = 0; 4776 + if (imux->num_items >= HDA_MAX_NUM_INPUTS) { 4777 + snd_printd(KERN_ERR "hda_codec: Too many imux items!\n"); 4778 + return -EINVAL; 4779 + } 4780 + for (i = 0; i < imux->num_items; i++) { 4781 + if (!strncmp(label, imux->items[i].label, strlen(label))) 4782 + label_idx++; 4783 + } 4784 + if (type_idx) 4785 + *type_idx = label_idx; 4786 + if (label_idx > 0) 4787 + snprintf(imux->items[imux->num_items].label, 4788 + sizeof(imux->items[imux->num_items].label), 4789 + "%s %d", label, label_idx); 4790 + else 4791 + strlcpy(imux->items[imux->num_items].label, label, 4792 + sizeof(imux->items[imux->num_items].label)); 4793 + imux->items[imux->num_items].index = index; 4794 + imux->num_items++; 4795 + return 0; 4796 + } 4797 + EXPORT_SYMBOL_HDA(snd_hda_add_imux_item); 4651 4798 4652 4799 4653 4800 #ifdef CONFIG_PM
+13
sound/pci/hda/hda_codec.h
··· 850 850 unsigned int pin_amp_workaround:1; /* pin out-amp takes index 851 851 * (e.g. Conexant codecs) 852 852 */ 853 + unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */ 853 854 unsigned int pins_shutup:1; /* pins are shut up */ 854 855 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ 855 856 #ifdef CONFIG_SND_HDA_POWER_SAVE ··· 988 987 #ifdef CONFIG_PM 989 988 int snd_hda_suspend(struct hda_bus *bus); 990 989 int snd_hda_resume(struct hda_bus *bus); 990 + #endif 991 + 992 + #ifdef CONFIG_SND_HDA_POWER_SAVE 993 + static inline 994 + int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid) 995 + { 996 + if (codec->patch_ops.check_power_status) 997 + return codec->patch_ops.check_power_status(codec, nid); 998 + return 0; 999 + } 1000 + #else 1001 + #define hda_call_check_power_status(codec, nid) 0 991 1002 #endif 992 1003 993 1004 /*
-7
sound/pci/hda/hda_eld.c
··· 332 332 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, 333 333 AC_DIPSIZE_ELD_BUF); 334 334 } 335 - EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size); 336 335 337 336 int snd_hdmi_get_eld(struct hdmi_eld *eld, 338 337 struct hda_codec *codec, hda_nid_t nid) ··· 367 368 kfree(buf); 368 369 return ret; 369 370 } 370 - EXPORT_SYMBOL_HDA(snd_hdmi_get_eld); 371 371 372 372 static void hdmi_show_short_audio_desc(struct cea_sad *a) 373 373 { ··· 405 407 } 406 408 buf[j] = '\0'; /* necessary when j == 0 */ 407 409 } 408 - EXPORT_SYMBOL_HDA(snd_print_channel_allocation); 409 410 410 411 void snd_hdmi_show_eld(struct hdmi_eld *e) 411 412 { ··· 423 426 for (i = 0; i < e->sad_count; i++) 424 427 hdmi_show_short_audio_desc(e->sad + i); 425 428 } 426 - EXPORT_SYMBOL_HDA(snd_hdmi_show_eld); 427 429 428 430 #ifdef CONFIG_PROC_FS 429 431 ··· 581 585 582 586 return 0; 583 587 } 584 - EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new); 585 588 586 589 void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) 587 590 { ··· 589 594 eld->proc_entry = NULL; 590 595 } 591 596 } 592 - EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); 593 597 594 598 #endif /* CONFIG_PROC_FS */ 595 599 ··· 639 645 pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); 640 646 pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); 641 647 } 642 - EXPORT_SYMBOL_HDA(hdmi_eld_update_pcm_info);
+5 -36
sound/pci/hda/hda_generic.c
··· 61 61 struct hda_gnode *cap_vol_node; /* Node for capture volume */ 62 62 unsigned int cur_cap_src; /* current capture source */ 63 63 struct hda_input_mux input_mux; 64 - char cap_labels[HDA_MAX_NUM_INPUTS][16]; 65 64 66 65 unsigned int def_amp_in_caps; 67 66 unsigned int def_amp_out_caps; ··· 505 506 * returns 0 if not found, 1 if found, or a negative error code. 506 507 */ 507 508 static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, 508 - struct hda_gnode *node) 509 + struct hda_gnode *node, int idx) 509 510 { 510 511 int i, err; 511 512 unsigned int pinctl; 512 - char *label; 513 513 const char *type; 514 514 515 515 if (node->checked) ··· 521 523 child = hda_get_node(spec, node->conn_list[i]); 522 524 if (! child) 523 525 continue; 524 - err = parse_adc_sub_nodes(codec, spec, child); 526 + err = parse_adc_sub_nodes(codec, spec, child, idx); 525 527 if (err < 0) 526 528 return err; 527 529 if (err > 0) { ··· 562 564 return 0; 563 565 type = "Input"; 564 566 } 565 - label = spec->cap_labels[spec->input_mux.num_items]; 566 - strcpy(label, type); 567 - spec->input_mux.items[spec->input_mux.num_items].label = label; 567 + snd_hda_add_imux_item(&spec->input_mux, type, idx, NULL); 568 568 569 569 /* unmute the PIN external input */ 570 570 unmute_input(codec, node, 0); /* index = 0? */ ··· 571 575 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); 572 576 573 577 return 1; /* found */ 574 - } 575 - 576 - /* add a capture source element */ 577 - static void add_cap_src(struct hda_gspec *spec, int idx) 578 - { 579 - struct hda_input_mux_item *csrc; 580 - char *buf; 581 - int num, ocap; 582 - 583 - num = spec->input_mux.num_items; 584 - csrc = &spec->input_mux.items[num]; 585 - buf = spec->cap_labels[num]; 586 - for (ocap = 0; ocap < num; ocap++) { 587 - if (! strcmp(buf, spec->cap_labels[ocap])) { 588 - /* same label already exists, 589 - * put the index number to be unique 590 - */ 591 - sprintf(buf, "%s %d", spec->cap_labels[ocap], num); 592 - break; 593 - } 594 - } 595 - csrc->index = idx; 596 - spec->input_mux.num_items++; 597 578 } 598 579 599 580 /* ··· 597 624 for (i = 0; i < adc_node->nconns; i++) { 598 625 node = hda_get_node(spec, adc_node->conn_list[i]); 599 626 if (node && node->type == AC_WID_PIN) { 600 - err = parse_adc_sub_nodes(codec, spec, node); 627 + err = parse_adc_sub_nodes(codec, spec, node, i); 601 628 if (err < 0) 602 629 return err; 603 - else if (err > 0) 604 - add_cap_src(spec, i); 605 630 } 606 631 } 607 632 /* ... then check the rests, more complicated connections */ 608 633 for (i = 0; i < adc_node->nconns; i++) { 609 634 node = hda_get_node(spec, adc_node->conn_list[i]); 610 635 if (node && node->type != AC_WID_PIN) { 611 - err = parse_adc_sub_nodes(codec, spec, node); 636 + err = parse_adc_sub_nodes(codec, spec, node, i); 612 637 if (err < 0) 613 638 return err; 614 - else if (err > 0) 615 - add_cap_src(spec, i); 616 639 } 617 640 } 618 641
+53 -48
sound/pci/hda/hda_intel.c
··· 78 78 module_param_array(model, charp, NULL, 0444); 79 79 MODULE_PARM_DESC(model, "Use the given board model."); 80 80 module_param_array(position_fix, int, NULL, 0444); 81 - MODULE_PARM_DESC(position_fix, "Fix DMA pointer " 82 - "(0 = auto, 1 = none, 2 = POSBUF)."); 81 + MODULE_PARM_DESC(position_fix, "DMA pointer read method." 82 + "(0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO)."); 83 83 module_param_array(bdl_pos_adj, int, NULL, 0644); 84 84 MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); 85 85 module_param_array(probe_mask, int, NULL, 0444); ··· 305 305 POS_FIX_AUTO, 306 306 POS_FIX_LPIB, 307 307 POS_FIX_POSBUF, 308 + POS_FIX_VIACOMBO, 308 309 }; 309 310 310 311 /* Defines for ATI HD Audio support in SB450 south bridge */ ··· 434 433 unsigned int polling_mode :1; 435 434 unsigned int msi :1; 436 435 unsigned int irq_pending_warned :1; 437 - unsigned int via_dmapos_patch :1; /* enable DMA-position fix for VIA */ 438 436 unsigned int probing :1; /* codec probing phase */ 439 437 440 438 /* for debugging */ ··· 458 458 AZX_DRIVER_ULI, 459 459 AZX_DRIVER_NVIDIA, 460 460 AZX_DRIVER_TERA, 461 + AZX_DRIVER_CTX, 461 462 AZX_DRIVER_GENERIC, 462 463 AZX_NUM_DRIVERS, /* keep this as last entry */ 463 464 }; ··· 474 473 [AZX_DRIVER_ULI] = "HDA ULI M5461", 475 474 [AZX_DRIVER_NVIDIA] = "HDA NVidia", 476 475 [AZX_DRIVER_TERA] = "HDA Teradici", 476 + [AZX_DRIVER_CTX] = "HDA Creative", 477 477 [AZX_DRIVER_GENERIC] = "HD-Audio Generic", 478 478 }; 479 479 ··· 565 563 /* reset the rirb hw write pointer */ 566 564 azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST); 567 565 /* set N=1, get RIRB response interrupt for new entry */ 568 - azx_writew(chip, RINTCNT, 1); 566 + if (chip->driver_type == AZX_DRIVER_CTX) 567 + azx_writew(chip, RINTCNT, 0xc0); 568 + else 569 + azx_writew(chip, RINTCNT, 1); 569 570 /* enable rirb dma and response irq */ 570 571 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); 571 572 spin_unlock_irq(&chip->reg_lock); ··· 1141 1136 /* clear rirb int */ 1142 1137 status = azx_readb(chip, RIRBSTS); 1143 1138 if (status & RIRB_INT_MASK) { 1144 - if (status & RIRB_INT_RESPONSE) 1139 + if (status & RIRB_INT_RESPONSE) { 1140 + if (chip->driver_type == AZX_DRIVER_CTX) 1141 + udelay(80); 1145 1142 azx_update_rirb(chip); 1143 + } 1146 1144 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); 1147 1145 } 1148 1146 ··· 1317 1309 azx_sd_writel(azx_dev, SD_BDLPU, upper_32_bits(azx_dev->bdl.addr)); 1318 1310 1319 1311 /* enable the position buffer */ 1320 - if (chip->position_fix[0] == POS_FIX_POSBUF || 1321 - chip->position_fix[0] == POS_FIX_AUTO || 1322 - chip->position_fix[1] == POS_FIX_POSBUF || 1323 - chip->position_fix[1] == POS_FIX_AUTO || 1324 - chip->via_dmapos_patch) { 1312 + if (chip->position_fix[0] != POS_FIX_LPIB || 1313 + chip->position_fix[1] != POS_FIX_LPIB) { 1325 1314 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 1326 1315 azx_writel(chip, DPLBASE, 1327 1316 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); ··· 1652 1647 struct azx_dev *azx_dev = get_azx_dev(substream); 1653 1648 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 1654 1649 struct snd_pcm_runtime *runtime = substream->runtime; 1655 - unsigned int bufsize, period_bytes, format_val; 1650 + unsigned int bufsize, period_bytes, format_val, stream_tag; 1656 1651 int err; 1657 1652 1658 1653 azx_stream_reset(chip, azx_dev); ··· 1694 1689 else 1695 1690 azx_dev->fifo_size = 0; 1696 1691 1697 - return snd_hda_codec_prepare(apcm->codec, hinfo, azx_dev->stream_tag, 1692 + stream_tag = azx_dev->stream_tag; 1693 + /* CA-IBG chips need the playback stream starting from 1 */ 1694 + if (chip->driver_type == AZX_DRIVER_CTX && 1695 + stream_tag > chip->capture_streams) 1696 + stream_tag -= chip->capture_streams; 1697 + return snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag, 1698 1698 azx_dev->format_val, substream); 1699 1699 } 1700 1700 ··· 1862 1852 struct azx_dev *azx_dev) 1863 1853 { 1864 1854 unsigned int pos; 1855 + int stream = azx_dev->substream->stream; 1865 1856 1866 - if (chip->via_dmapos_patch) 1857 + switch (chip->position_fix[stream]) { 1858 + case POS_FIX_LPIB: 1859 + /* read LPIB */ 1860 + pos = azx_sd_readl(azx_dev, SD_LPIB); 1861 + break; 1862 + case POS_FIX_VIACOMBO: 1867 1863 pos = azx_via_get_position(chip, azx_dev); 1868 - else { 1869 - int stream = azx_dev->substream->stream; 1870 - if (chip->position_fix[stream] == POS_FIX_POSBUF || 1871 - chip->position_fix[stream] == POS_FIX_AUTO) { 1872 - /* use the position buffer */ 1873 - pos = le32_to_cpu(*azx_dev->posbuf); 1874 - } else { 1875 - /* read LPIB */ 1876 - pos = azx_sd_readl(azx_dev, SD_LPIB); 1877 - } 1864 + break; 1865 + default: 1866 + /* use the position buffer */ 1867 + pos = le32_to_cpu(*azx_dev->posbuf); 1878 1868 } 1869 + 1879 1870 if (pos >= azx_dev->bufsize) 1880 1871 pos = 0; 1881 1872 return pos; ··· 2324 2313 switch (fix) { 2325 2314 case POS_FIX_LPIB: 2326 2315 case POS_FIX_POSBUF: 2316 + case POS_FIX_VIACOMBO: 2327 2317 return fix; 2328 2318 } 2329 - 2330 - /* Check VIA/ATI HD Audio Controller exist */ 2331 - switch (chip->driver_type) { 2332 - case AZX_DRIVER_VIA: 2333 - case AZX_DRIVER_ATI: 2334 - chip->via_dmapos_patch = 1; 2335 - /* Use link position directly, avoid any transfer problem. */ 2336 - return POS_FIX_LPIB; 2337 - } 2338 - chip->via_dmapos_patch = 0; 2339 2319 2340 2320 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); 2341 2321 if (q) { ··· 2336 2334 q->value, q->subvendor, q->subdevice); 2337 2335 return q->value; 2338 2336 } 2337 + 2338 + /* Check VIA/ATI HD Audio Controller exist */ 2339 + switch (chip->driver_type) { 2340 + case AZX_DRIVER_VIA: 2341 + case AZX_DRIVER_ATI: 2342 + /* Use link position directly, avoid any transfer problem. */ 2343 + return POS_FIX_VIACOMBO; 2344 + } 2345 + 2339 2346 return POS_FIX_AUTO; 2340 2347 } 2341 2348 ··· 2746 2735 2747 2736 /* PCI IDs */ 2748 2737 static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { 2749 - /* ICH 6..10 */ 2750 - { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH }, 2751 - { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH }, 2752 - { PCI_DEVICE(0x8086, 0x269a), .driver_data = AZX_DRIVER_ICH }, 2753 - { PCI_DEVICE(0x8086, 0x284b), .driver_data = AZX_DRIVER_ICH }, 2754 - { PCI_DEVICE(0x8086, 0x2911), .driver_data = AZX_DRIVER_ICH }, 2755 - { PCI_DEVICE(0x8086, 0x293e), .driver_data = AZX_DRIVER_ICH }, 2756 - { PCI_DEVICE(0x8086, 0x293f), .driver_data = AZX_DRIVER_ICH }, 2757 - { PCI_DEVICE(0x8086, 0x3a3e), .driver_data = AZX_DRIVER_ICH }, 2758 - { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH }, 2759 - /* PCH */ 2760 - { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_ICH }, 2761 - { PCI_DEVICE(0x8086, 0x3b57), .driver_data = AZX_DRIVER_ICH }, 2762 2738 /* CPT */ 2763 2739 { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH }, 2764 2740 /* PBG */ 2765 2741 { PCI_DEVICE(0x8086, 0x1d20), .driver_data = AZX_DRIVER_PCH }, 2766 2742 /* SCH */ 2767 2743 { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH }, 2744 + /* Generic Intel */ 2745 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), 2746 + .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2747 + .class_mask = 0xffffff, 2748 + .driver_data = AZX_DRIVER_ICH }, 2768 2749 /* ATI SB 450/600 */ 2769 2750 { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI }, 2770 2751 { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI }, ··· 2797 2794 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_ANY_ID), 2798 2795 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2799 2796 .class_mask = 0xffffff, 2800 - .driver_data = AZX_DRIVER_GENERIC }, 2797 + .driver_data = AZX_DRIVER_CTX }, 2801 2798 #else 2802 2799 /* this entry seems still valid -- i.e. without emu20kx chip */ 2803 - { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, 2800 + { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_CTX }, 2804 2801 #endif 2802 + /* Vortex86MX */ 2803 + { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, 2805 2804 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */ 2806 2805 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), 2807 2806 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
+40 -11
sound/pci/hda/hda_local.h
··· 38 38 */ 39 39 #define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs) \ 40 40 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23)) 41 + #define HDA_AMP_VAL_MIN_MUTE (1<<29) 41 42 #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \ 42 43 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0) 43 44 /* mono volume with index (index=0,1,...) (channel=1,2) */ 44 - #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 45 + #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, dir, flags) \ 45 46 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 46 47 .subdevice = HDA_SUBDEV_AMP_FLAG, \ 47 48 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ ··· 52 51 .get = snd_hda_mixer_amp_volume_get, \ 53 52 .put = snd_hda_mixer_amp_volume_put, \ 54 53 .tlv = { .c = snd_hda_mixer_amp_tlv }, \ 55 - .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) } 54 + .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, dir) | flags } 56 55 /* stereo volume with index */ 57 56 #define HDA_CODEC_VOLUME_IDX(xname, xcidx, nid, xindex, direction) \ 58 - HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction) 57 + HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction, 0) 59 58 /* mono volume */ 60 59 #define HDA_CODEC_VOLUME_MONO(xname, nid, channel, xindex, direction) \ 61 - HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction) 60 + HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction, 0) 62 61 /* stereo volume */ 63 62 #define HDA_CODEC_VOLUME(xname, nid, xindex, direction) \ 64 63 HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction) 64 + /* stereo volume with min=mute */ 65 + #define HDA_CODEC_VOLUME_MIN_MUTE(xname, nid, xindex, direction) \ 66 + HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, 3, xindex, direction, \ 67 + HDA_AMP_VAL_MIN_MUTE) 65 68 /* mono mute switch with index (index=0,1,...) (channel=1,2) */ 66 69 #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 67 70 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ ··· 220 215 */ 221 216 #define HDA_MAX_NUM_INPUTS 16 222 217 struct hda_input_mux_item { 223 - const char *label; 218 + char label[32]; 224 219 unsigned int index; 225 220 }; 226 221 struct hda_input_mux { ··· 371 366 372 367 enum { 373 368 AUTO_PIN_MIC, 374 - AUTO_PIN_FRONT_MIC, 375 - AUTO_PIN_LINE, 376 - AUTO_PIN_FRONT_LINE, 369 + AUTO_PIN_LINE_IN, 377 370 AUTO_PIN_CD, 378 371 AUTO_PIN_AUX, 379 372 AUTO_PIN_LAST ··· 383 380 AUTO_PIN_HP_OUT 384 381 }; 385 382 386 - extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; 387 - 388 383 #define AUTO_CFG_MAX_OUTS 5 384 + #define AUTO_CFG_MAX_INS 8 385 + 386 + struct auto_pin_cfg_item { 387 + hda_nid_t pin; 388 + int type; 389 + }; 390 + 391 + struct auto_pin_cfg; 392 + const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, 393 + int check_location); 394 + const char *hda_get_autocfg_input_label(struct hda_codec *codec, 395 + const struct auto_pin_cfg *cfg, 396 + int input); 397 + int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, 398 + int index, int *type_index_ret); 399 + 400 + enum { 401 + INPUT_PIN_ATTR_UNUSED, /* pin not connected */ 402 + INPUT_PIN_ATTR_INT, /* internal mic/line-in */ 403 + INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ 404 + INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ 405 + INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ 406 + INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ 407 + }; 408 + 409 + int snd_hda_get_input_pin_attr(unsigned int def_conf); 389 410 390 411 struct auto_pin_cfg { 391 412 int line_outs; ··· 420 393 int hp_outs; 421 394 int line_out_type; /* AUTO_PIN_XXX_OUT */ 422 395 hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 423 - hda_nid_t input_pins[AUTO_PIN_LAST]; 396 + int num_inputs; 397 + struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; 424 398 int dig_outs; 425 399 hda_nid_t dig_out_pins[2]; 426 400 hda_nid_t dig_in_pin; ··· 586 558 #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) 587 559 #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 588 560 #define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f) 561 + #define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1) 589 562 590 563 /* 591 564 * CEA Short Audio Descriptor data
+27 -19
sound/pci/hda/patch_analog.c
··· 1276 1276 spec->multiout.no_share_stream = 1; 1277 1277 1278 1278 codec->no_trigger_sense = 1; 1279 + codec->no_sticky_stream = 1; 1279 1280 1280 1281 return 0; 1281 1282 } ··· 1464 1463 codec->patch_ops = ad198x_patch_ops; 1465 1464 1466 1465 codec->no_trigger_sense = 1; 1466 + codec->no_sticky_stream = 1; 1467 1467 1468 1468 return 0; 1469 1469 } ··· 1919 1917 } 1920 1918 1921 1919 codec->no_trigger_sense = 1; 1920 + codec->no_sticky_stream = 1; 1922 1921 1923 1922 return 0; 1924 1923 } ··· 2883 2880 2884 2881 /* create input playback/capture controls for the given pin */ 2885 2882 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, 2886 - const char *ctlname, int boost) 2883 + const char *ctlname, int ctlidx, int boost) 2887 2884 { 2888 2885 char name[32]; 2889 2886 int err, idx; ··· 2912 2909 } 2913 2910 2914 2911 /* create playback/capture controls for input pins */ 2915 - static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, 2912 + static int ad1988_auto_create_analog_input_ctls(struct hda_codec *codec, 2916 2913 const struct auto_pin_cfg *cfg) 2917 2914 { 2915 + struct ad198x_spec *spec = codec->spec; 2918 2916 struct hda_input_mux *imux = &spec->private_imux; 2919 - int i, err; 2917 + int i, err, type, type_idx; 2920 2918 2921 - for (i = 0; i < AUTO_PIN_LAST; i++) { 2922 - err = new_analog_input(spec, cfg->input_pins[i], 2923 - auto_pin_cfg_labels[i], 2924 - i <= AUTO_PIN_FRONT_MIC); 2919 + for (i = 0; i < cfg->num_inputs; i++) { 2920 + const char *label; 2921 + type = cfg->inputs[i].type; 2922 + label = hda_get_autocfg_input_label(codec, cfg, i); 2923 + snd_hda_add_imux_item(imux, label, 2924 + ad1988_pin_to_adc_idx(cfg->inputs[i].pin), 2925 + &type_idx); 2926 + err = new_analog_input(spec, cfg->inputs[i].pin, 2927 + label, type_idx, 2928 + type == AUTO_PIN_MIC); 2925 2929 if (err < 0) 2926 2930 return err; 2927 - imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 2928 - imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); 2929 - imux->num_items++; 2930 2931 } 2931 - imux->items[imux->num_items].label = "Mix"; 2932 - imux->items[imux->num_items].index = 9; 2933 - imux->num_items++; 2932 + snd_hda_add_imux_item(imux, "Mix", 9, NULL); 2934 2933 2935 2934 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, 2936 2935 "Analog Mix Playback Volume", ··· 2999 2994 static void ad1988_auto_init_analog_input(struct hda_codec *codec) 3000 2995 { 3001 2996 struct ad198x_spec *spec = codec->spec; 2997 + const struct auto_pin_cfg *cfg = &spec->autocfg; 3002 2998 int i, idx; 3003 2999 3004 - for (i = 0; i < AUTO_PIN_LAST; i++) { 3005 - hda_nid_t nid = spec->autocfg.input_pins[i]; 3006 - if (! nid) 3007 - continue; 3000 + for (i = 0; i < cfg->num_inputs; i++) { 3001 + hda_nid_t nid = cfg->inputs[i].pin; 3008 3002 switch (nid) { 3009 3003 case 0x15: /* port-C */ 3010 3004 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); ··· 3013 3009 break; 3014 3010 } 3015 3011 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3016 - i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3012 + i == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); 3017 3013 if (nid != AD1988_PIN_CD_NID) 3018 3014 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3019 3015 AMP_OUT_MUTE); ··· 3044 3040 "Speaker")) < 0 || 3045 3041 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], 3046 3042 "Headphone")) < 0 || 3047 - (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3043 + (err = ad1988_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) 3048 3044 return err; 3049 3045 3050 3046 spec->multiout.max_channels = spec->multiout.num_dacs * 2; ··· 3239 3235 spec->vmaster_nid = 0x04; 3240 3236 3241 3237 codec->no_trigger_sense = 1; 3238 + codec->no_sticky_stream = 1; 3242 3239 3243 3240 return 0; 3244 3241 } ··· 3454 3449 codec->patch_ops = ad198x_patch_ops; 3455 3450 3456 3451 codec->no_trigger_sense = 1; 3452 + codec->no_sticky_stream = 1; 3457 3453 3458 3454 return 0; 3459 3455 } ··· 4428 4422 } 4429 4423 4430 4424 codec->no_trigger_sense = 1; 4425 + codec->no_sticky_stream = 1; 4431 4426 4432 4427 return 0; 4433 4428 } ··· 4768 4761 } 4769 4762 4770 4763 codec->no_trigger_sense = 1; 4764 + codec->no_sticky_stream = 1; 4771 4765 4772 4766 return 0; 4773 4767 }
-224
sound/pci/hda/patch_atihdmi.c
··· 1 - /* 2 - * Universal Interface for Intel High Definition Audio Codec 3 - * 4 - * HD audio interface patch for ATI HDMI codecs 5 - * 6 - * Copyright (c) 2006 ATI Technologies Inc. 7 - * 8 - * 9 - * This driver is free software; you can redistribute it and/or modify 10 - * it under the terms of the GNU General Public License as published by 11 - * the Free Software Foundation; either version 2 of the License, or 12 - * (at your option) any later version. 13 - * 14 - * This driver is distributed in the hope that it will be useful, 15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - * GNU General Public License for more details. 18 - * 19 - * You should have received a copy of the GNU General Public License 20 - * along with this program; if not, write to the Free Software 21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 - */ 23 - 24 - #include <linux/init.h> 25 - #include <linux/delay.h> 26 - #include <linux/slab.h> 27 - #include <sound/core.h> 28 - #include "hda_codec.h" 29 - #include "hda_local.h" 30 - 31 - struct atihdmi_spec { 32 - struct hda_multi_out multiout; 33 - 34 - struct hda_pcm pcm_rec; 35 - }; 36 - 37 - #define CVT_NID 0x02 /* audio converter */ 38 - #define PIN_NID 0x03 /* HDMI output pin */ 39 - 40 - static struct hda_verb atihdmi_basic_init[] = { 41 - /* enable digital output on pin widget */ 42 - { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 43 - {} /* terminator */ 44 - }; 45 - 46 - /* 47 - * Controls 48 - */ 49 - static int atihdmi_build_controls(struct hda_codec *codec) 50 - { 51 - struct atihdmi_spec *spec = codec->spec; 52 - int err; 53 - 54 - err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 55 - if (err < 0) 56 - return err; 57 - 58 - return 0; 59 - } 60 - 61 - static int atihdmi_init(struct hda_codec *codec) 62 - { 63 - snd_hda_sequence_write(codec, atihdmi_basic_init); 64 - /* SI codec requires to unmute the pin */ 65 - if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) 66 - snd_hda_codec_write(codec, PIN_NID, 0, 67 - AC_VERB_SET_AMP_GAIN_MUTE, 68 - AMP_OUT_UNMUTE); 69 - return 0; 70 - } 71 - 72 - /* 73 - * Digital out 74 - */ 75 - static int atihdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 76 - struct hda_codec *codec, 77 - struct snd_pcm_substream *substream) 78 - { 79 - struct atihdmi_spec *spec = codec->spec; 80 - return snd_hda_multi_out_dig_open(codec, &spec->multiout); 81 - } 82 - 83 - static int atihdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 84 - struct hda_codec *codec, 85 - struct snd_pcm_substream *substream) 86 - { 87 - struct atihdmi_spec *spec = codec->spec; 88 - return snd_hda_multi_out_dig_close(codec, &spec->multiout); 89 - } 90 - 91 - static int atihdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 92 - struct hda_codec *codec, 93 - unsigned int stream_tag, 94 - unsigned int format, 95 - struct snd_pcm_substream *substream) 96 - { 97 - struct atihdmi_spec *spec = codec->spec; 98 - int chans = substream->runtime->channels; 99 - int i, err; 100 - 101 - err = snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, 102 - format, substream); 103 - if (err < 0) 104 - return err; 105 - snd_hda_codec_write(codec, CVT_NID, 0, AC_VERB_SET_CVT_CHAN_COUNT, 106 - chans - 1); 107 - /* FIXME: XXX */ 108 - for (i = 0; i < chans; i++) { 109 - snd_hda_codec_write(codec, CVT_NID, 0, 110 - AC_VERB_SET_HDMI_CHAN_SLOT, 111 - (i << 4) | i); 112 - } 113 - return 0; 114 - } 115 - 116 - static struct hda_pcm_stream atihdmi_pcm_digital_playback = { 117 - .substreams = 1, 118 - .channels_min = 2, 119 - .channels_max = 2, 120 - .nid = CVT_NID, /* NID to query formats and rates and setup streams */ 121 - .ops = { 122 - .open = atihdmi_dig_playback_pcm_open, 123 - .close = atihdmi_dig_playback_pcm_close, 124 - .prepare = atihdmi_dig_playback_pcm_prepare 125 - }, 126 - }; 127 - 128 - static int atihdmi_build_pcms(struct hda_codec *codec) 129 - { 130 - struct atihdmi_spec *spec = codec->spec; 131 - struct hda_pcm *info = &spec->pcm_rec; 132 - unsigned int chans; 133 - 134 - codec->num_pcms = 1; 135 - codec->pcm_info = info; 136 - 137 - info->name = "ATI HDMI"; 138 - info->pcm_type = HDA_PCM_TYPE_HDMI; 139 - info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback; 140 - 141 - /* FIXME: we must check ELD and change the PCM parameters dynamically 142 - */ 143 - chans = get_wcaps(codec, CVT_NID); 144 - chans = get_wcaps_channels(chans); 145 - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; 146 - 147 - return 0; 148 - } 149 - 150 - static void atihdmi_free(struct hda_codec *codec) 151 - { 152 - kfree(codec->spec); 153 - } 154 - 155 - static struct hda_codec_ops atihdmi_patch_ops = { 156 - .build_controls = atihdmi_build_controls, 157 - .build_pcms = atihdmi_build_pcms, 158 - .init = atihdmi_init, 159 - .free = atihdmi_free, 160 - }; 161 - 162 - static int patch_atihdmi(struct hda_codec *codec) 163 - { 164 - struct atihdmi_spec *spec; 165 - 166 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 167 - if (spec == NULL) 168 - return -ENOMEM; 169 - 170 - codec->spec = spec; 171 - 172 - spec->multiout.num_dacs = 0; /* no analog */ 173 - spec->multiout.max_channels = 2; 174 - /* NID for copying analog to digital, 175 - * seems to be unused in pure-digital 176 - * case. 177 - */ 178 - spec->multiout.dig_out_nid = CVT_NID; 179 - 180 - codec->patch_ops = atihdmi_patch_ops; 181 - 182 - return 0; 183 - } 184 - 185 - /* 186 - * patch entries 187 - */ 188 - static struct hda_codec_preset snd_hda_preset_atihdmi[] = { 189 - { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, 190 - { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, 191 - { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, 192 - { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, 193 - { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi }, 194 - { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi }, 195 - {} /* terminator */ 196 - }; 197 - 198 - MODULE_ALIAS("snd-hda-codec-id:1002793c"); 199 - MODULE_ALIAS("snd-hda-codec-id:10027919"); 200 - MODULE_ALIAS("snd-hda-codec-id:1002791a"); 201 - MODULE_ALIAS("snd-hda-codec-id:1002aa01"); 202 - MODULE_ALIAS("snd-hda-codec-id:10951390"); 203 - MODULE_ALIAS("snd-hda-codec-id:17e80047"); 204 - 205 - MODULE_LICENSE("GPL"); 206 - MODULE_DESCRIPTION("ATI HDMI HD-audio codec"); 207 - 208 - static struct hda_codec_preset_list atihdmi_list = { 209 - .preset = snd_hda_preset_atihdmi, 210 - .owner = THIS_MODULE, 211 - }; 212 - 213 - static int __init patch_atihdmi_init(void) 214 - { 215 - return snd_hda_add_codec_preset(&atihdmi_list); 216 - } 217 - 218 - static void __exit patch_atihdmi_exit(void) 219 - { 220 - snd_hda_delete_codec_preset(&atihdmi_list); 221 - } 222 - 223 - module_init(patch_atihdmi_init) 224 - module_exit(patch_atihdmi_exit)
+5 -5
sound/pci/hda/patch_ca0110.c
··· 468 468 spec->dig_in = nid; 469 469 continue; 470 470 } 471 - for (j = 0; j < AUTO_PIN_LAST; j++) 472 - if (cfg->input_pins[j] == pin) 471 + for (j = 0; j < cfg->num_inputs; j++) 472 + if (cfg->inputs[j].pin == pin) 473 473 break; 474 - if (j >= AUTO_PIN_LAST) 474 + if (j >= cfg->num_inputs) 475 475 continue; 476 476 spec->input_pins[n] = pin; 477 - spec->input_labels[n] = auto_pin_cfg_labels[j]; 477 + spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1); 478 478 spec->adcs[n] = nid; 479 479 n++; 480 480 } ··· 489 489 if (cfg->dig_outs && 490 490 snd_hda_get_connections(codec, cfg->dig_out_pins[0], 491 491 &spec->dig_out, 1) == 1) 492 - spec->multiout.dig_out_nid = cfg->dig_out_pins[0]; 492 + spec->multiout.dig_out_nid = spec->dig_out; 493 493 } 494 494 495 495 static int ca0110_parse_auto_config(struct hda_codec *codec)
+70 -24
sound/pci/hda/patch_cirrus.c
··· 65 65 66 66 /* available models */ 67 67 enum { 68 + CS420X_MBP53, 68 69 CS420X_MBP55, 69 70 CS420X_IMAC27, 70 71 CS420X_AUTO, ··· 330 329 { 331 330 struct cs_spec *spec = codec->spec; 332 331 struct auto_pin_cfg *cfg = &spec->autocfg; 333 - hda_nid_t pin = cfg->input_pins[idx]; 332 + hda_nid_t pin = cfg->inputs[idx].pin; 334 333 unsigned int val = snd_hda_query_pin_caps(codec, pin); 335 334 if (!(val & AC_PINCAP_PRES_DETECT)) 336 335 return 0; 337 336 val = snd_hda_codec_get_pincfg(codec, pin); 338 - return (get_defcfg_connect(val) == AC_JACK_PORT_COMPLEX); 337 + return (snd_hda_get_input_pin_attr(val) != INPUT_PIN_ATTR_INT); 339 338 } 340 339 341 340 static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, ··· 425 424 struct auto_pin_cfg *cfg = &spec->autocfg; 426 425 int i; 427 426 428 - for (i = 0; i < AUTO_PIN_LAST; i++) { 429 - hda_nid_t pin = cfg->input_pins[i]; 430 - if (!pin) 431 - continue; 427 + for (i = 0; i < cfg->num_inputs; i++) { 428 + hda_nid_t pin = cfg->inputs[i].pin; 432 429 spec->input_idx[spec->num_inputs] = i; 433 430 spec->capsrc_idx[i] = spec->num_inputs++; 434 431 spec->cur_input = i; ··· 437 438 438 439 /* check whether the automatic mic switch is available */ 439 440 if (spec->num_inputs == 2 && 440 - spec->adc_nid[AUTO_PIN_MIC] && spec->adc_nid[AUTO_PIN_FRONT_MIC]) { 441 - if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_FRONT_MIC])) { 442 - if (!is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { 441 + cfg->inputs[0].type == AUTO_PIN_MIC && 442 + cfg->inputs[1].type == AUTO_PIN_MIC) { 443 + if (is_ext_mic(codec, cfg->inputs[0].pin)) { 444 + if (!is_ext_mic(codec, cfg->inputs[1].pin)) { 443 445 spec->mic_detect = 1; 444 - spec->automic_idx = AUTO_PIN_FRONT_MIC; 446 + spec->automic_idx = 0; 445 447 } 446 448 } else { 447 - if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { 449 + if (is_ext_mic(codec, cfg->inputs[1].pin)) { 448 450 spec->mic_detect = 1; 449 - spec->automic_idx = AUTO_PIN_MIC; 451 + spec->automic_idx = 1; 450 452 } 451 453 } 452 454 } ··· 674 674 { 675 675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 676 676 struct cs_spec *spec = codec->spec; 677 + struct auto_pin_cfg *cfg = &spec->autocfg; 677 678 unsigned int idx; 678 679 679 680 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; ··· 683 682 if (uinfo->value.enumerated.item >= spec->num_inputs) 684 683 uinfo->value.enumerated.item = spec->num_inputs - 1; 685 684 idx = spec->input_idx[uinfo->value.enumerated.item]; 686 - strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]); 685 + strcpy(uinfo->value.enumerated.name, 686 + hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1)); 687 687 return 0; 688 688 } 689 689 ··· 742 740 return bind; 743 741 } 744 742 743 + /* add a (input-boost) volume control to the given input pin */ 744 + static int add_input_volume_control(struct hda_codec *codec, 745 + struct auto_pin_cfg *cfg, 746 + int item) 747 + { 748 + hda_nid_t pin = cfg->inputs[item].pin; 749 + u32 caps; 750 + const char *label; 751 + struct snd_kcontrol *kctl; 752 + 753 + if (!(get_wcaps(codec, pin) & AC_WCAP_IN_AMP)) 754 + return 0; 755 + caps = query_amp_caps(codec, pin, HDA_INPUT); 756 + caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; 757 + if (caps <= 1) 758 + return 0; 759 + label = hda_get_autocfg_input_label(codec, cfg, item); 760 + return add_volume(codec, label, 0, 761 + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_INPUT), 1, &kctl); 762 + } 763 + 745 764 static int build_input(struct hda_codec *codec) 746 765 { 747 766 struct cs_spec *spec = codec->spec; ··· 798 775 if (spec->num_inputs > 1 && !spec->mic_detect) { 799 776 err = snd_hda_ctl_add(codec, 0, 800 777 snd_ctl_new1(&cs_capture_source, codec)); 778 + if (err < 0) 779 + return err; 780 + } 781 + 782 + for (i = 0; i < spec->num_inputs; i++) { 783 + err = add_input_volume_control(codec, &spec->autocfg, i); 801 784 if (err < 0) 802 785 return err; 803 786 } ··· 867 838 AC_VERB_SET_PIN_WIDGET_CONTROL, 868 839 hp_present ? 0 : PIN_OUT); 869 840 } 870 - if (spec->board_config == CS420X_MBP55 || 841 + if (spec->board_config == CS420X_MBP53 || 842 + spec->board_config == CS420X_MBP55 || 871 843 spec->board_config == CS420X_IMAC27) { 872 844 unsigned int gpio = hp_present ? 0x02 : 0x08; 873 845 snd_hda_codec_write(codec, 0x01, 0, ··· 883 853 hda_nid_t nid; 884 854 unsigned int present; 885 855 886 - nid = cfg->input_pins[spec->automic_idx]; 856 + nid = cfg->inputs[spec->automic_idx].pin; 887 857 present = snd_hda_jack_detect(codec, nid); 888 858 if (present) 889 859 change_cur_input(codec, spec->automic_idx, 0); 890 - else { 891 - unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? 892 - AUTO_PIN_FRONT_MIC : AUTO_PIN_MIC; 893 - change_cur_input(codec, imic, 0); 894 - } 860 + else 861 + change_cur_input(codec, !spec->automic_idx, 0); 895 862 } 896 863 897 864 /* ··· 945 918 unsigned int coef; 946 919 int i; 947 920 948 - for (i = 0; i < AUTO_PIN_LAST; i++) { 921 + for (i = 0; i < cfg->num_inputs; i++) { 949 922 unsigned int ctl; 950 - hda_nid_t pin = cfg->input_pins[i]; 951 - if (!pin || !spec->adc_nid[i]) 923 + hda_nid_t pin = cfg->inputs[i].pin; 924 + if (!spec->adc_nid[i]) 952 925 continue; 953 926 /* set appropriate pin control and mute first */ 954 927 ctl = PIN_IN; 955 - if (i <= AUTO_PIN_FRONT_MIC) { 928 + if (cfg->inputs[i].type == AUTO_PIN_MIC) { 956 929 unsigned int caps = snd_hda_query_pin_caps(codec, pin); 957 930 caps >>= AC_PINCAP_VREF_SHIFT; 958 931 if (caps & AC_PINCAP_VREF_80) ··· 1157 1130 } 1158 1131 1159 1132 static const char *cs420x_models[CS420X_MODELS] = { 1133 + [CS420X_MBP53] = "mbp53", 1160 1134 [CS420X_MBP55] = "mbp55", 1161 1135 [CS420X_IMAC27] = "imac27", 1162 1136 [CS420X_AUTO] = "auto", ··· 1165 1137 1166 1138 1167 1139 static struct snd_pci_quirk cs420x_cfg_tbl[] = { 1140 + SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), 1168 1141 SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), 1142 + SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), 1169 1143 SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), 1170 1144 {} /* terminator */ 1171 1145 }; ··· 1175 1145 struct cs_pincfg { 1176 1146 hda_nid_t nid; 1177 1147 u32 val; 1148 + }; 1149 + 1150 + static struct cs_pincfg mbp53_pincfgs[] = { 1151 + { 0x09, 0x012b4050 }, 1152 + { 0x0a, 0x90100141 }, 1153 + { 0x0b, 0x90100140 }, 1154 + { 0x0c, 0x018b3020 }, 1155 + { 0x0d, 0x90a00110 }, 1156 + { 0x0e, 0x400000f0 }, 1157 + { 0x0f, 0x01cbe030 }, 1158 + { 0x10, 0x014be060 }, 1159 + { 0x12, 0x400000f0 }, 1160 + { 0x15, 0x400000f0 }, 1161 + {} /* terminator */ 1178 1162 }; 1179 1163 1180 1164 static struct cs_pincfg mbp55_pincfgs[] = { ··· 1220 1176 }; 1221 1177 1222 1178 static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { 1179 + [CS420X_MBP53] = mbp53_pincfgs, 1223 1180 [CS420X_MBP55] = mbp55_pincfgs, 1224 1181 [CS420X_IMAC27] = imac27_pincfgs, 1225 1182 }; ··· 1253 1208 1254 1209 switch (spec->board_config) { 1255 1210 case CS420X_IMAC27: 1211 + case CS420X_MBP53: 1256 1212 case CS420X_MBP55: 1257 1213 /* GPIO1 = headphones */ 1258 1214 /* GPIO3 = speakers */
+642 -9
sound/pci/hda/patch_conexant.c
··· 57 57 58 58 }; 59 59 60 + struct pin_dac_pair { 61 + hda_nid_t pin; 62 + hda_nid_t dac; 63 + int type; 64 + }; 65 + 60 66 struct conexant_spec { 61 67 62 68 struct snd_kcontrol_new *mixers[5]; ··· 83 77 unsigned int cur_eapd; 84 78 unsigned int hp_present; 85 79 unsigned int auto_mic; 80 + int auto_mic_ext; /* autocfg.inputs[] index for ext mic */ 86 81 unsigned int need_dac_fix; 87 82 88 83 /* capture */ ··· 117 110 struct auto_pin_cfg autocfg; 118 111 struct hda_input_mux private_imux; 119 112 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 113 + struct pin_dac_pair dac_info[8]; 114 + int dac_info_filled; 120 115 121 - unsigned int dell_automute; 122 116 unsigned int port_d_mode; 117 + unsigned int auto_mute:1; /* used in auto-parser */ 118 + unsigned int dell_automute:1; 123 119 unsigned int dell_vostro:1; 124 120 unsigned int ideapad:1; 125 121 unsigned int thinkpad:1; ··· 3075 3065 CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 3076 3066 CXT5066_DELL_LAPTOP, /* Dell Laptop */ 3077 3067 CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ 3078 - CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ 3068 + CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 3079 3069 CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 3080 3070 CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 3081 3071 CXT5066_HP_LAPTOP, /* HP Laptop */ ··· 3086 3076 [CXT5066_LAPTOP] = "laptop", 3087 3077 [CXT5066_DELL_LAPTOP] = "dell-laptop", 3088 3078 [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", 3089 - [CXT5066_DELL_VOSTO] = "dell-vostro", 3079 + [CXT5066_DELL_VOSTRO] = "dell-vostro", 3090 3080 [CXT5066_IDEAPAD] = "ideapad", 3091 3081 [CXT5066_THINKPAD] = "thinkpad", 3092 3082 [CXT5066_HP_LAPTOP] = "hp-laptop", 3093 3083 }; 3094 3084 3095 3085 static struct snd_pci_quirk cxt5066_cfg_tbl[] = { 3096 - SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 3097 - CXT5066_LAPTOP), 3086 + SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 3087 + SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 3098 3088 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", 3099 3089 CXT5066_DELL_LAPTOP), 3100 - SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 3101 - SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTO), 3102 - SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), 3090 + SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO), 3103 3091 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 3104 3092 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 3105 3093 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 3106 3094 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 3107 3095 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5), 3096 + SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 3097 + CXT5066_LAPTOP), 3098 + SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 3108 3099 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 3109 3100 SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD), 3110 3101 SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD), ··· 3207 3196 spec->capture_prepare = cxt5066_olpc_capture_prepare; 3208 3197 spec->capture_cleanup = cxt5066_olpc_capture_cleanup; 3209 3198 break; 3210 - case CXT5066_DELL_VOSTO: 3199 + case CXT5066_DELL_VOSTRO: 3211 3200 codec->patch_ops.init = cxt5066_init; 3212 3201 codec->patch_ops.unsol_event = cxt5066_vostro_event; 3213 3202 spec->init_verbs[0] = cxt5066_init_verbs_vostro; ··· 3265 3254 } 3266 3255 3267 3256 /* 3257 + * Automatic parser for CX20641 & co 3258 + */ 3259 + 3260 + static hda_nid_t cx_auto_adc_nids[] = { 0x14 }; 3261 + 3262 + /* get the connection index of @nid in the widget @mux */ 3263 + static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, 3264 + hda_nid_t nid) 3265 + { 3266 + hda_nid_t conn[HDA_MAX_NUM_INPUTS]; 3267 + int i, nums; 3268 + 3269 + nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); 3270 + for (i = 0; i < nums; i++) 3271 + if (conn[i] == nid) 3272 + return i; 3273 + return -1; 3274 + } 3275 + 3276 + /* get an unassigned DAC from the given list. 3277 + * Return the nid if found and reduce the DAC list, or return zero if 3278 + * not found 3279 + */ 3280 + static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin, 3281 + hda_nid_t *dacs, int *num_dacs) 3282 + { 3283 + int i, nums = *num_dacs; 3284 + hda_nid_t ret = 0; 3285 + 3286 + for (i = 0; i < nums; i++) { 3287 + if (get_connection_index(codec, pin, dacs[i]) >= 0) { 3288 + ret = dacs[i]; 3289 + break; 3290 + } 3291 + } 3292 + if (!ret) 3293 + return 0; 3294 + if (--nums > 0) 3295 + memmove(dacs, dacs + 1, nums * sizeof(hda_nid_t)); 3296 + *num_dacs = nums; 3297 + return ret; 3298 + } 3299 + 3300 + #define MAX_AUTO_DACS 5 3301 + 3302 + /* fill analog DAC list from the widget tree */ 3303 + static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs) 3304 + { 3305 + hda_nid_t nid, end_nid; 3306 + int nums = 0; 3307 + 3308 + end_nid = codec->start_nid + codec->num_nodes; 3309 + for (nid = codec->start_nid; nid < end_nid; nid++) { 3310 + unsigned int wcaps = get_wcaps(codec, nid); 3311 + unsigned int type = get_wcaps_type(wcaps); 3312 + if (type == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) { 3313 + dacs[nums++] = nid; 3314 + if (nums >= MAX_AUTO_DACS) 3315 + break; 3316 + } 3317 + } 3318 + return nums; 3319 + } 3320 + 3321 + /* fill pin_dac_pair list from the pin and dac list */ 3322 + static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins, 3323 + int num_pins, hda_nid_t *dacs, int *rest, 3324 + struct pin_dac_pair *filled, int type) 3325 + { 3326 + int i, nums; 3327 + 3328 + nums = 0; 3329 + for (i = 0; i < num_pins; i++) { 3330 + filled[nums].pin = pins[i]; 3331 + filled[nums].type = type; 3332 + filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest); 3333 + nums++; 3334 + } 3335 + return nums; 3336 + } 3337 + 3338 + /* parse analog output paths */ 3339 + static void cx_auto_parse_output(struct hda_codec *codec) 3340 + { 3341 + struct conexant_spec *spec = codec->spec; 3342 + struct auto_pin_cfg *cfg = &spec->autocfg; 3343 + hda_nid_t dacs[MAX_AUTO_DACS]; 3344 + int i, j, nums, rest; 3345 + 3346 + rest = fill_cx_auto_dacs(codec, dacs); 3347 + /* parse all analog output pins */ 3348 + nums = fill_dacs_for_pins(codec, cfg->line_out_pins, cfg->line_outs, 3349 + dacs, &rest, spec->dac_info, 3350 + AUTO_PIN_LINE_OUT); 3351 + nums += fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs, 3352 + dacs, &rest, spec->dac_info + nums, 3353 + AUTO_PIN_HP_OUT); 3354 + nums += fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs, 3355 + dacs, &rest, spec->dac_info + nums, 3356 + AUTO_PIN_SPEAKER_OUT); 3357 + spec->dac_info_filled = nums; 3358 + /* fill multiout struct */ 3359 + for (i = 0; i < nums; i++) { 3360 + hda_nid_t dac = spec->dac_info[i].dac; 3361 + if (!dac) 3362 + continue; 3363 + switch (spec->dac_info[i].type) { 3364 + case AUTO_PIN_LINE_OUT: 3365 + spec->private_dac_nids[spec->multiout.num_dacs] = dac; 3366 + spec->multiout.num_dacs++; 3367 + break; 3368 + case AUTO_PIN_HP_OUT: 3369 + case AUTO_PIN_SPEAKER_OUT: 3370 + if (!spec->multiout.hp_nid) { 3371 + spec->multiout.hp_nid = dac; 3372 + break; 3373 + } 3374 + for (j = 0; j < ARRAY_SIZE(spec->multiout.extra_out_nid); j++) 3375 + if (!spec->multiout.extra_out_nid[j]) { 3376 + spec->multiout.extra_out_nid[j] = dac; 3377 + break; 3378 + } 3379 + break; 3380 + } 3381 + } 3382 + spec->multiout.dac_nids = spec->private_dac_nids; 3383 + spec->multiout.max_channels = nums * 2; 3384 + 3385 + if (cfg->hp_outs > 0) 3386 + spec->auto_mute = 1; 3387 + spec->vmaster_nid = spec->private_dac_nids[0]; 3388 + } 3389 + 3390 + /* auto-mute/unmute speaker and line outs according to headphone jack */ 3391 + static void cx_auto_hp_automute(struct hda_codec *codec) 3392 + { 3393 + struct conexant_spec *spec = codec->spec; 3394 + struct auto_pin_cfg *cfg = &spec->autocfg; 3395 + int i, present; 3396 + 3397 + if (!spec->auto_mute) 3398 + return; 3399 + present = 0; 3400 + for (i = 0; i < cfg->hp_outs; i++) { 3401 + if (snd_hda_jack_detect(codec, cfg->hp_pins[i])) { 3402 + present = 1; 3403 + break; 3404 + } 3405 + } 3406 + for (i = 0; i < cfg->line_outs; i++) { 3407 + snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, 3408 + AC_VERB_SET_PIN_WIDGET_CONTROL, 3409 + present ? 0 : PIN_OUT); 3410 + } 3411 + for (i = 0; i < cfg->speaker_outs; i++) { 3412 + snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, 3413 + AC_VERB_SET_PIN_WIDGET_CONTROL, 3414 + present ? 0 : PIN_OUT); 3415 + } 3416 + } 3417 + 3418 + /* automatic switch internal and external mic */ 3419 + static void cx_auto_automic(struct hda_codec *codec) 3420 + { 3421 + struct conexant_spec *spec = codec->spec; 3422 + struct auto_pin_cfg *cfg = &spec->autocfg; 3423 + struct hda_input_mux *imux = &spec->private_imux; 3424 + int ext_idx = spec->auto_mic_ext; 3425 + 3426 + if (!spec->auto_mic) 3427 + return; 3428 + if (snd_hda_jack_detect(codec, cfg->inputs[ext_idx].pin)) { 3429 + snd_hda_codec_write(codec, spec->adc_nids[0], 0, 3430 + AC_VERB_SET_CONNECT_SEL, 3431 + imux->items[ext_idx].index); 3432 + } else { 3433 + snd_hda_codec_write(codec, spec->adc_nids[0], 0, 3434 + AC_VERB_SET_CONNECT_SEL, 3435 + imux->items[!ext_idx].index); 3436 + } 3437 + } 3438 + 3439 + static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) 3440 + { 3441 + int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; 3442 + switch (res >> 26) { 3443 + case CONEXANT_HP_EVENT: 3444 + cx_auto_hp_automute(codec); 3445 + conexant_report_jack(codec, nid); 3446 + break; 3447 + case CONEXANT_MIC_EVENT: 3448 + cx_auto_automic(codec); 3449 + conexant_report_jack(codec, nid); 3450 + break; 3451 + } 3452 + } 3453 + 3454 + /* return true if it's an internal-mic pin */ 3455 + static int is_int_mic(struct hda_codec *codec, hda_nid_t pin) 3456 + { 3457 + unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); 3458 + return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && 3459 + snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT; 3460 + } 3461 + 3462 + /* return true if it's an external-mic pin */ 3463 + static int is_ext_mic(struct hda_codec *codec, hda_nid_t pin) 3464 + { 3465 + unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); 3466 + return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && 3467 + snd_hda_get_input_pin_attr(def_conf) >= INPUT_PIN_ATTR_NORMAL && 3468 + (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_PRES_DETECT); 3469 + } 3470 + 3471 + /* check whether the pin config is suitable for auto-mic switching; 3472 + * auto-mic is enabled only when one int-mic and one-ext mic exist 3473 + */ 3474 + static void cx_auto_check_auto_mic(struct hda_codec *codec) 3475 + { 3476 + struct conexant_spec *spec = codec->spec; 3477 + struct auto_pin_cfg *cfg = &spec->autocfg; 3478 + 3479 + if (is_ext_mic(codec, cfg->inputs[0].pin) && 3480 + is_int_mic(codec, cfg->inputs[1].pin)) { 3481 + spec->auto_mic = 1; 3482 + spec->auto_mic_ext = 1; 3483 + return; 3484 + } 3485 + if (is_int_mic(codec, cfg->inputs[1].pin) && 3486 + is_ext_mic(codec, cfg->inputs[0].pin)) { 3487 + spec->auto_mic = 1; 3488 + spec->auto_mic_ext = 0; 3489 + return; 3490 + } 3491 + } 3492 + 3493 + static void cx_auto_parse_input(struct hda_codec *codec) 3494 + { 3495 + struct conexant_spec *spec = codec->spec; 3496 + struct auto_pin_cfg *cfg = &spec->autocfg; 3497 + struct hda_input_mux *imux; 3498 + int i; 3499 + 3500 + imux = &spec->private_imux; 3501 + for (i = 0; i < cfg->num_inputs; i++) { 3502 + int idx = get_connection_index(codec, spec->adc_nids[0], 3503 + cfg->inputs[i].pin); 3504 + if (idx >= 0) { 3505 + const char *label; 3506 + label = hda_get_autocfg_input_label(codec, cfg, i); 3507 + snd_hda_add_imux_item(imux, label, idx, NULL); 3508 + } 3509 + } 3510 + if (imux->num_items == 2 && cfg->num_inputs == 2) 3511 + cx_auto_check_auto_mic(codec); 3512 + if (imux->num_items > 1 && !spec->auto_mic) 3513 + spec->input_mux = imux; 3514 + } 3515 + 3516 + /* get digital-input audio widget corresponding to the given pin */ 3517 + static hda_nid_t cx_auto_get_dig_in(struct hda_codec *codec, hda_nid_t pin) 3518 + { 3519 + hda_nid_t nid, end_nid; 3520 + 3521 + end_nid = codec->start_nid + codec->num_nodes; 3522 + for (nid = codec->start_nid; nid < end_nid; nid++) { 3523 + unsigned int wcaps = get_wcaps(codec, nid); 3524 + unsigned int type = get_wcaps_type(wcaps); 3525 + if (type == AC_WID_AUD_IN && (wcaps & AC_WCAP_DIGITAL)) { 3526 + if (get_connection_index(codec, nid, pin) >= 0) 3527 + return nid; 3528 + } 3529 + } 3530 + return 0; 3531 + } 3532 + 3533 + static void cx_auto_parse_digital(struct hda_codec *codec) 3534 + { 3535 + struct conexant_spec *spec = codec->spec; 3536 + struct auto_pin_cfg *cfg = &spec->autocfg; 3537 + hda_nid_t nid; 3538 + 3539 + if (cfg->dig_outs && 3540 + snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) == 1) 3541 + spec->multiout.dig_out_nid = nid; 3542 + if (cfg->dig_in_pin) 3543 + spec->dig_in_nid = cx_auto_get_dig_in(codec, cfg->dig_in_pin); 3544 + } 3545 + 3546 + #ifdef CONFIG_SND_HDA_INPUT_BEEP 3547 + static void cx_auto_parse_beep(struct hda_codec *codec) 3548 + { 3549 + struct conexant_spec *spec = codec->spec; 3550 + hda_nid_t nid, end_nid; 3551 + 3552 + end_nid = codec->start_nid + codec->num_nodes; 3553 + for (nid = codec->start_nid; nid < end_nid; nid++) 3554 + if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 3555 + set_beep_amp(spec, nid, 0, HDA_OUTPUT); 3556 + break; 3557 + } 3558 + } 3559 + #else 3560 + #define cx_auto_parse_beep(codec) 3561 + #endif 3562 + 3563 + static int cx_auto_parse_auto_config(struct hda_codec *codec) 3564 + { 3565 + struct conexant_spec *spec = codec->spec; 3566 + int err; 3567 + 3568 + err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); 3569 + if (err < 0) 3570 + return err; 3571 + 3572 + cx_auto_parse_output(codec); 3573 + cx_auto_parse_input(codec); 3574 + cx_auto_parse_digital(codec); 3575 + cx_auto_parse_beep(codec); 3576 + return 0; 3577 + } 3578 + 3579 + static void cx_auto_turn_on_eapd(struct hda_codec *codec, int num_pins, 3580 + hda_nid_t *pins) 3581 + { 3582 + int i; 3583 + for (i = 0; i < num_pins; i++) { 3584 + if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 3585 + snd_hda_codec_write(codec, pins[i], 0, 3586 + AC_VERB_SET_EAPD_BTLENABLE, 0x02); 3587 + } 3588 + } 3589 + 3590 + static void select_connection(struct hda_codec *codec, hda_nid_t pin, 3591 + hda_nid_t src) 3592 + { 3593 + int idx = get_connection_index(codec, pin, src); 3594 + if (idx >= 0) 3595 + snd_hda_codec_write(codec, pin, 0, 3596 + AC_VERB_SET_CONNECT_SEL, idx); 3597 + } 3598 + 3599 + static void cx_auto_init_output(struct hda_codec *codec) 3600 + { 3601 + struct conexant_spec *spec = codec->spec; 3602 + struct auto_pin_cfg *cfg = &spec->autocfg; 3603 + hda_nid_t nid; 3604 + int i; 3605 + 3606 + for (i = 0; i < spec->multiout.num_dacs; i++) 3607 + snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0, 3608 + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 3609 + 3610 + for (i = 0; i < cfg->hp_outs; i++) 3611 + snd_hda_codec_write(codec, cfg->hp_pins[i], 0, 3612 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); 3613 + if (spec->auto_mute) { 3614 + for (i = 0; i < cfg->hp_outs; i++) { 3615 + snd_hda_codec_write(codec, cfg->hp_pins[i], 0, 3616 + AC_VERB_SET_UNSOLICITED_ENABLE, 3617 + AC_USRSP_EN | CONEXANT_HP_EVENT); 3618 + } 3619 + cx_auto_hp_automute(codec); 3620 + } else { 3621 + for (i = 0; i < cfg->line_outs; i++) 3622 + snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, 3623 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 3624 + for (i = 0; i < cfg->speaker_outs; i++) 3625 + snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, 3626 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 3627 + } 3628 + 3629 + for (i = 0; i < spec->dac_info_filled; i++) { 3630 + nid = spec->dac_info[i].dac; 3631 + if (!nid) 3632 + nid = spec->multiout.dac_nids[0]; 3633 + select_connection(codec, spec->dac_info[i].pin, nid); 3634 + } 3635 + 3636 + /* turn on EAPD */ 3637 + cx_auto_turn_on_eapd(codec, cfg->line_outs, cfg->line_out_pins); 3638 + cx_auto_turn_on_eapd(codec, cfg->hp_outs, cfg->hp_pins); 3639 + cx_auto_turn_on_eapd(codec, cfg->speaker_outs, cfg->speaker_pins); 3640 + } 3641 + 3642 + static void cx_auto_init_input(struct hda_codec *codec) 3643 + { 3644 + struct conexant_spec *spec = codec->spec; 3645 + struct auto_pin_cfg *cfg = &spec->autocfg; 3646 + int i; 3647 + 3648 + for (i = 0; i < spec->num_adc_nids; i++) 3649 + snd_hda_codec_write(codec, spec->adc_nids[i], 0, 3650 + AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)); 3651 + 3652 + for (i = 0; i < cfg->num_inputs; i++) { 3653 + unsigned int type; 3654 + if (cfg->inputs[i].type == AUTO_PIN_MIC) 3655 + type = PIN_VREF80; 3656 + else 3657 + type = PIN_IN; 3658 + snd_hda_codec_write(codec, cfg->inputs[i].pin, 0, 3659 + AC_VERB_SET_PIN_WIDGET_CONTROL, type); 3660 + } 3661 + 3662 + if (spec->auto_mic) { 3663 + int ext_idx = spec->auto_mic_ext; 3664 + snd_hda_codec_write(codec, cfg->inputs[ext_idx].pin, 0, 3665 + AC_VERB_SET_UNSOLICITED_ENABLE, 3666 + AC_USRSP_EN | CONEXANT_MIC_EVENT); 3667 + cx_auto_automic(codec); 3668 + } else { 3669 + for (i = 0; i < spec->num_adc_nids; i++) { 3670 + snd_hda_codec_write(codec, spec->adc_nids[i], 0, 3671 + AC_VERB_SET_CONNECT_SEL, 3672 + spec->private_imux.items[0].index); 3673 + } 3674 + } 3675 + } 3676 + 3677 + static void cx_auto_init_digital(struct hda_codec *codec) 3678 + { 3679 + struct conexant_spec *spec = codec->spec; 3680 + struct auto_pin_cfg *cfg = &spec->autocfg; 3681 + 3682 + if (spec->multiout.dig_out_nid) 3683 + snd_hda_codec_write(codec, cfg->dig_out_pins[0], 0, 3684 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 3685 + if (spec->dig_in_nid) 3686 + snd_hda_codec_write(codec, cfg->dig_in_pin, 0, 3687 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); 3688 + } 3689 + 3690 + static int cx_auto_init(struct hda_codec *codec) 3691 + { 3692 + /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/ 3693 + cx_auto_init_output(codec); 3694 + cx_auto_init_input(codec); 3695 + cx_auto_init_digital(codec); 3696 + return 0; 3697 + } 3698 + 3699 + static int cx_auto_add_volume(struct hda_codec *codec, const char *basename, 3700 + const char *dir, int cidx, 3701 + hda_nid_t nid, int hda_dir) 3702 + { 3703 + static char name[32]; 3704 + static struct snd_kcontrol_new knew[] = { 3705 + HDA_CODEC_VOLUME(name, 0, 0, 0), 3706 + HDA_CODEC_MUTE(name, 0, 0, 0), 3707 + }; 3708 + static char *sfx[2] = { "Volume", "Switch" }; 3709 + int i, err; 3710 + 3711 + for (i = 0; i < 2; i++) { 3712 + struct snd_kcontrol *kctl; 3713 + knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, 3, 0, hda_dir); 3714 + knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; 3715 + knew[i].index = cidx; 3716 + snprintf(name, sizeof(name), "%s%s %s", basename, dir, sfx[i]); 3717 + kctl = snd_ctl_new1(&knew[i], codec); 3718 + if (!kctl) 3719 + return -ENOMEM; 3720 + err = snd_hda_ctl_add(codec, nid, kctl); 3721 + if (err < 0) 3722 + return err; 3723 + if (!(query_amp_caps(codec, nid, hda_dir) & AC_AMPCAP_MUTE)) 3724 + break; 3725 + } 3726 + return 0; 3727 + } 3728 + 3729 + #define cx_auto_add_pb_volume(codec, nid, str, idx) \ 3730 + cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) 3731 + 3732 + static int cx_auto_build_output_controls(struct hda_codec *codec) 3733 + { 3734 + struct conexant_spec *spec = codec->spec; 3735 + int i, err; 3736 + int num_line = 0, num_hp = 0, num_spk = 0; 3737 + static const char *texts[3] = { "Front", "Surround", "CLFE" }; 3738 + 3739 + if (spec->dac_info_filled == 1) 3740 + return cx_auto_add_pb_volume(codec, spec->dac_info[0].dac, 3741 + "Master", 0); 3742 + for (i = 0; i < spec->dac_info_filled; i++) { 3743 + const char *label; 3744 + int idx, type; 3745 + if (!spec->dac_info[i].dac) 3746 + continue; 3747 + type = spec->dac_info[i].type; 3748 + if (type == AUTO_PIN_LINE_OUT) 3749 + type = spec->autocfg.line_out_type; 3750 + switch (type) { 3751 + case AUTO_PIN_LINE_OUT: 3752 + default: 3753 + label = texts[num_line++]; 3754 + idx = 0; 3755 + break; 3756 + case AUTO_PIN_HP_OUT: 3757 + label = "Headphone"; 3758 + idx = num_hp++; 3759 + break; 3760 + case AUTO_PIN_SPEAKER_OUT: 3761 + label = "Speaker"; 3762 + idx = num_spk++; 3763 + break; 3764 + } 3765 + err = cx_auto_add_pb_volume(codec, spec->dac_info[i].dac, 3766 + label, idx); 3767 + if (err < 0) 3768 + return err; 3769 + } 3770 + return 0; 3771 + } 3772 + 3773 + static int cx_auto_build_input_controls(struct hda_codec *codec) 3774 + { 3775 + struct conexant_spec *spec = codec->spec; 3776 + struct auto_pin_cfg *cfg = &spec->autocfg; 3777 + static const char *prev_label; 3778 + int i, err, cidx; 3779 + 3780 + err = cx_auto_add_volume(codec, "Capture", "", 0, spec->adc_nids[0], 3781 + HDA_INPUT); 3782 + if (err < 0) 3783 + return err; 3784 + prev_label = NULL; 3785 + cidx = 0; 3786 + for (i = 0; i < cfg->num_inputs; i++) { 3787 + hda_nid_t nid = cfg->inputs[i].pin; 3788 + const char *label; 3789 + if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) 3790 + continue; 3791 + label = hda_get_autocfg_input_label(codec, cfg, i); 3792 + if (label == prev_label) 3793 + cidx++; 3794 + else 3795 + cidx = 0; 3796 + prev_label = label; 3797 + err = cx_auto_add_volume(codec, label, " Capture", cidx, 3798 + nid, HDA_INPUT); 3799 + if (err < 0) 3800 + return err; 3801 + } 3802 + return 0; 3803 + } 3804 + 3805 + static int cx_auto_build_controls(struct hda_codec *codec) 3806 + { 3807 + int err; 3808 + 3809 + err = cx_auto_build_output_controls(codec); 3810 + if (err < 0) 3811 + return err; 3812 + err = cx_auto_build_input_controls(codec); 3813 + if (err < 0) 3814 + return err; 3815 + return conexant_build_controls(codec); 3816 + } 3817 + 3818 + static struct hda_codec_ops cx_auto_patch_ops = { 3819 + .build_controls = cx_auto_build_controls, 3820 + .build_pcms = conexant_build_pcms, 3821 + .init = cx_auto_init, 3822 + .free = conexant_free, 3823 + .unsol_event = cx_auto_unsol_event, 3824 + #ifdef CONFIG_SND_HDA_POWER_SAVE 3825 + .suspend = conexant_suspend, 3826 + #endif 3827 + .reboot_notify = snd_hda_shutup_pins, 3828 + }; 3829 + 3830 + static int patch_conexant_auto(struct hda_codec *codec) 3831 + { 3832 + struct conexant_spec *spec; 3833 + int err; 3834 + 3835 + spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3836 + if (!spec) 3837 + return -ENOMEM; 3838 + codec->spec = spec; 3839 + spec->adc_nids = cx_auto_adc_nids; 3840 + spec->num_adc_nids = ARRAY_SIZE(cx_auto_adc_nids); 3841 + spec->capsrc_nids = spec->adc_nids; 3842 + err = cx_auto_parse_auto_config(codec); 3843 + if (err < 0) { 3844 + kfree(codec->spec); 3845 + codec->spec = NULL; 3846 + return err; 3847 + } 3848 + codec->patch_ops = cx_auto_patch_ops; 3849 + if (spec->beep_amp) 3850 + snd_hda_attach_beep_device(codec, spec->beep_amp); 3851 + return 0; 3852 + } 3853 + 3854 + /* 3268 3855 */ 3269 3856 3270 3857 static struct hda_codec_preset snd_hda_preset_conexant[] = { ··· 3880 3271 .patch = patch_cxt5066 }, 3881 3272 { .id = 0x14f15069, .name = "CX20585", 3882 3273 .patch = patch_cxt5066 }, 3274 + { .id = 0x14f15097, .name = "CX20631", 3275 + .patch = patch_conexant_auto }, 3276 + { .id = 0x14f15098, .name = "CX20632", 3277 + .patch = patch_conexant_auto }, 3278 + { .id = 0x14f150a1, .name = "CX20641", 3279 + .patch = patch_conexant_auto }, 3280 + { .id = 0x14f150a2, .name = "CX20642", 3281 + .patch = patch_conexant_auto }, 3282 + { .id = 0x14f150ab, .name = "CX20651", 3283 + .patch = patch_conexant_auto }, 3284 + { .id = 0x14f150ac, .name = "CX20652", 3285 + .patch = patch_conexant_auto }, 3286 + { .id = 0x14f150b8, .name = "CX20664", 3287 + .patch = patch_conexant_auto }, 3288 + { .id = 0x14f150b9, .name = "CX20665", 3289 + .patch = patch_conexant_auto }, 3883 3290 {} /* terminator */ 3884 3291 }; 3885 3292 ··· 3906 3281 MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3907 3282 MODULE_ALIAS("snd-hda-codec-id:14f15068"); 3908 3283 MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3284 + MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3285 + MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3286 + MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3287 + MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3288 + MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3289 + MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3290 + MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3291 + MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 3909 3292 3910 3293 MODULE_LICENSE("GPL"); 3911 3294 MODULE_DESCRIPTION("Conexant HD-audio codec");
+756 -41
sound/pci/hda/patch_hdmi.c
··· 3 3 * patch_hdmi.c - routines for HDMI/DisplayPort codecs 4 4 * 5 5 * Copyright(c) 2008-2010 Intel Corporation. All rights reserved. 6 + * Copyright (c) 2006 ATI Technologies Inc. 7 + * Copyright (c) 2008 NVIDIA Corp. All rights reserved. 8 + * Copyright (c) 2008 Wei Ni <wni@nvidia.com> 6 9 * 7 10 * Authors: 8 11 * Wu Fengguang <wfg@linux.intel.com> ··· 28 25 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 29 26 */ 30 27 28 + #include <linux/init.h> 29 + #include <linux/delay.h> 30 + #include <linux/slab.h> 31 + #include <sound/core.h> 32 + #include "hda_codec.h" 33 + #include "hda_local.h" 34 + 35 + /* 36 + * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device 37 + * could support two independent pipes, each of them can be connected to one or 38 + * more ports (DVI, HDMI or DisplayPort). 39 + * 40 + * The HDA correspondence of pipes/ports are converter/pin nodes. 41 + */ 42 + #define MAX_HDMI_CVTS 3 43 + #define MAX_HDMI_PINS 3 31 44 32 45 struct hdmi_spec { 33 46 int num_cvts; ··· 68 49 struct hda_pcm_stream codec_pcm_pars[MAX_HDMI_CVTS]; 69 50 70 51 /* 71 - * nvhdmi specific 52 + * ati/nvhdmi specific 72 53 */ 73 54 struct hda_multi_out multiout; 74 - unsigned int codec_type; 55 + struct hda_pcm_stream *pcm_playback; 75 56 76 57 /* misc flags */ 77 58 /* PD bit indicates only the update, not the current state */ ··· 84 65 u8 ver; /* 0x01 */ 85 66 u8 len; /* 0x0a */ 86 67 87 - u8 checksum; /* PB0 */ 68 + u8 checksum; 69 + 88 70 u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ 89 71 u8 SS01_SF24; 90 72 u8 CXT04; 91 73 u8 CA; 92 74 u8 LFEPBL01_LSV36_DM_INH7; 93 - u8 reserved[5]; /* PB6 - PB10 */ 75 + }; 76 + 77 + struct dp_audio_infoframe { 78 + u8 type; /* 0x84 */ 79 + u8 len; /* 0x1b */ 80 + u8 ver; /* 0x11 << 2 */ 81 + 82 + u8 CC02_CT47; /* match with HDMI infoframe from this on */ 83 + u8 SS01_SF24; 84 + u8 CXT04; 85 + u8 CA; 86 + u8 LFEPBL01_LSV36_DM_INH7; 94 87 }; 95 88 96 89 /* ··· 193 162 /* 4ch */ 194 163 [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, 195 164 /* surround41 */ 196 - [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, 165 + [0x09] = { 0x00, 0x11, 0x24, 0x35, 0x42, 0xf3, 0xf6, 0xf7 }, 197 166 /* surround50 */ 198 167 [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, 199 168 /* surround51 */ ··· 206 175 * This is an ordered list! 207 176 * 208 177 * The preceding ones have better chances to be selected by 209 - * hdmi_setup_channel_allocation(). 178 + * hdmi_channel_allocation(). 210 179 */ 211 180 static struct cea_channel_speaker_allocation channel_allocations[] = { 212 181 /* channel: 7 6 5 4 3 2 1 0 */ ··· 383 352 * 384 353 * TODO: it could select the wrong CA from multiple candidates. 385 354 */ 386 - static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, 387 - struct hdmi_audio_infoframe *ai) 355 + static int hdmi_channel_allocation(struct hda_codec *codec, hda_nid_t nid, 356 + int channels) 388 357 { 389 358 struct hdmi_spec *spec = codec->spec; 390 359 struct hdmi_eld *eld; 391 360 int i; 361 + int ca = 0; 392 362 int spk_mask = 0; 393 - int channels = 1 + (ai->CC02_CT47 & 0x7); 394 363 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; 395 364 396 365 /* ··· 428 397 if (channels == channel_allocations[i].channels && 429 398 (spk_mask & channel_allocations[i].spk_mask) == 430 399 channel_allocations[i].spk_mask) { 431 - ai->CA = channel_allocations[i].ca_index; 400 + ca = channel_allocations[i].ca_index; 432 401 break; 433 402 } 434 403 } 435 404 436 405 snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); 437 406 snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n", 438 - ai->CA, channels, buf); 407 + ca, channels, buf); 439 408 440 - return ai->CA; 409 + return ca; 441 410 } 442 411 443 412 static void hdmi_debug_channel_mapping(struct hda_codec *codec, ··· 459 428 460 429 static void hdmi_setup_channel_mapping(struct hda_codec *codec, 461 430 hda_nid_t pin_nid, 462 - struct hdmi_audio_infoframe *ai) 431 + int ca) 463 432 { 464 433 int i; 465 - int ca = ai->CA; 466 434 int err; 467 435 468 436 if (hdmi_channel_mapping[ca][1] == 0) { ··· 558 528 #endif 559 529 } 560 530 561 - static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) 531 + static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *hdmi_ai) 562 532 { 563 - u8 *bytes = (u8 *)ai; 533 + u8 *bytes = (u8 *)hdmi_ai; 564 534 u8 sum = 0; 565 535 int i; 566 536 567 - ai->checksum = 0; 537 + hdmi_ai->checksum = 0; 568 538 569 - for (i = 0; i < sizeof(*ai); i++) 539 + for (i = 0; i < sizeof(*hdmi_ai); i++) 570 540 sum += bytes[i]; 571 541 572 - ai->checksum = -sum; 542 + hdmi_ai->checksum = -sum; 573 543 } 574 544 575 545 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, 576 546 hda_nid_t pin_nid, 577 - struct hdmi_audio_infoframe *ai) 547 + u8 *dip, int size) 578 548 { 579 - u8 *bytes = (u8 *)ai; 580 549 int i; 581 550 582 551 hdmi_debug_dip_size(codec, pin_nid); 583 552 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ 584 553 585 - hdmi_checksum_audio_infoframe(ai); 586 - 587 554 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 588 - for (i = 0; i < sizeof(*ai); i++) 589 - hdmi_write_dip_byte(codec, pin_nid, bytes[i]); 555 + for (i = 0; i < size; i++) 556 + hdmi_write_dip_byte(codec, pin_nid, dip[i]); 590 557 } 591 558 592 559 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, 593 - struct hdmi_audio_infoframe *ai) 560 + u8 *dip, int size) 594 561 { 595 - u8 *bytes = (u8 *)ai; 596 562 u8 val; 597 563 int i; 598 564 ··· 597 571 return false; 598 572 599 573 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 600 - for (i = 0; i < sizeof(*ai); i++) { 574 + for (i = 0; i < size; i++) { 601 575 val = snd_hda_codec_read(codec, pin_nid, 0, 602 576 AC_VERB_GET_HDMI_DIP_DATA, 0); 603 - if (val != bytes[i]) 577 + if (val != dip[i]) 604 578 return false; 605 579 } 606 580 ··· 612 586 { 613 587 struct hdmi_spec *spec = codec->spec; 614 588 hda_nid_t pin_nid; 589 + int channels = substream->runtime->channels; 590 + int ca; 615 591 int i; 616 - struct hdmi_audio_infoframe ai = { 617 - .type = 0x84, 618 - .ver = 0x01, 619 - .len = 0x0a, 620 - .CC02_CT47 = substream->runtime->channels - 1, 621 - }; 592 + u8 ai[max(sizeof(struct hdmi_audio_infoframe), 593 + sizeof(struct dp_audio_infoframe))]; 622 594 623 - hdmi_setup_channel_allocation(codec, nid, &ai); 595 + ca = hdmi_channel_allocation(codec, nid, channels); 624 596 625 597 for (i = 0; i < spec->num_pins; i++) { 626 598 if (spec->pin_cvt[i] != nid) ··· 627 603 continue; 628 604 629 605 pin_nid = spec->pin[i]; 630 - if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { 606 + 607 + memset(ai, 0, sizeof(ai)); 608 + if (spec->sink_eld[i].conn_type == 0) { /* HDMI */ 609 + struct hdmi_audio_infoframe *hdmi_ai; 610 + 611 + hdmi_ai = (struct hdmi_audio_infoframe *)ai; 612 + hdmi_ai->type = 0x84; 613 + hdmi_ai->ver = 0x01; 614 + hdmi_ai->len = 0x0a; 615 + hdmi_ai->CC02_CT47 = channels - 1; 616 + hdmi_checksum_audio_infoframe(hdmi_ai); 617 + } else if (spec->sink_eld[i].conn_type == 1) { /* DisplayPort */ 618 + struct dp_audio_infoframe *dp_ai; 619 + 620 + dp_ai = (struct dp_audio_infoframe *)ai; 621 + dp_ai->type = 0x84; 622 + dp_ai->len = 0x1b; 623 + dp_ai->ver = 0x11 << 2; 624 + dp_ai->CC02_CT47 = channels - 1; 625 + } else { 626 + snd_printd("HDMI: unknown connection type at pin %d\n", 627 + pin_nid); 628 + continue; 629 + } 630 + 631 + /* 632 + * sizeof(ai) is used instead of sizeof(*hdmi_ai) or 633 + * sizeof(*dp_ai) to avoid partial match/update problems when 634 + * the user switches between HDMI/DP monitors. 635 + */ 636 + if (!hdmi_infoframe_uptodate(codec, pin_nid, ai, sizeof(ai))) { 631 637 snd_printdd("hdmi_setup_audio_infoframe: " 632 638 "cvt=%d pin=%d channels=%d\n", 633 639 nid, pin_nid, 634 - substream->runtime->channels); 635 - hdmi_setup_channel_mapping(codec, pin_nid, &ai); 640 + channels); 641 + hdmi_setup_channel_mapping(codec, pin_nid, ca); 636 642 hdmi_stop_infoframe_trans(codec, pin_nid); 637 - hdmi_fill_audio_infoframe(codec, pin_nid, &ai); 643 + hdmi_fill_audio_infoframe(codec, pin_nid, 644 + ai, sizeof(ai)); 638 645 hdmi_start_infoframe_trans(codec, pin_nid); 639 646 } 640 647 } ··· 846 791 /* 847 792 * HDA/HDMI auto parsing 848 793 */ 849 - 850 794 static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) 851 795 { 852 796 struct hdmi_spec *spec = codec->spec; ··· 976 922 return 0; 977 923 } 978 924 925 + /* 926 + */ 927 + static char *generic_hdmi_pcm_names[MAX_HDMI_CVTS] = { 928 + "HDMI 0", 929 + "HDMI 1", 930 + "HDMI 2", 931 + }; 932 + 933 + /* 934 + * HDMI callbacks 935 + */ 936 + 937 + static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 938 + struct hda_codec *codec, 939 + unsigned int stream_tag, 940 + unsigned int format, 941 + struct snd_pcm_substream *substream) 942 + { 943 + hdmi_set_channel_count(codec, hinfo->nid, 944 + substream->runtime->channels); 945 + 946 + hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); 947 + 948 + return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); 949 + } 950 + 951 + static struct hda_pcm_stream generic_hdmi_pcm_playback = { 952 + .substreams = 1, 953 + .channels_min = 2, 954 + .ops = { 955 + .open = hdmi_pcm_open, 956 + .prepare = generic_hdmi_playback_pcm_prepare, 957 + }, 958 + }; 959 + 960 + static int generic_hdmi_build_pcms(struct hda_codec *codec) 961 + { 962 + struct hdmi_spec *spec = codec->spec; 963 + struct hda_pcm *info = spec->pcm_rec; 964 + int i; 965 + 966 + codec->num_pcms = spec->num_cvts; 967 + codec->pcm_info = info; 968 + 969 + for (i = 0; i < codec->num_pcms; i++, info++) { 970 + unsigned int chans; 971 + struct hda_pcm_stream *pstr; 972 + 973 + chans = get_wcaps(codec, spec->cvt[i]); 974 + chans = get_wcaps_channels(chans); 975 + 976 + info->name = generic_hdmi_pcm_names[i]; 977 + info->pcm_type = HDA_PCM_TYPE_HDMI; 978 + pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; 979 + if (spec->pcm_playback) 980 + *pstr = *spec->pcm_playback; 981 + else 982 + *pstr = generic_hdmi_pcm_playback; 983 + pstr->nid = spec->cvt[i]; 984 + if (pstr->channels_max <= 2 && chans && chans <= 16) 985 + pstr->channels_max = chans; 986 + } 987 + 988 + return 0; 989 + } 990 + 991 + static int generic_hdmi_build_controls(struct hda_codec *codec) 992 + { 993 + struct hdmi_spec *spec = codec->spec; 994 + int err; 995 + int i; 996 + 997 + for (i = 0; i < codec->num_pcms; i++) { 998 + err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]); 999 + if (err < 0) 1000 + return err; 1001 + } 1002 + 1003 + return 0; 1004 + } 1005 + 1006 + static int generic_hdmi_init(struct hda_codec *codec) 1007 + { 1008 + struct hdmi_spec *spec = codec->spec; 1009 + int i; 1010 + 1011 + for (i = 0; spec->pin[i]; i++) { 1012 + hdmi_enable_output(codec, spec->pin[i]); 1013 + snd_hda_codec_write(codec, spec->pin[i], 0, 1014 + AC_VERB_SET_UNSOLICITED_ENABLE, 1015 + AC_USRSP_EN | spec->pin[i]); 1016 + } 1017 + return 0; 1018 + } 1019 + 1020 + static void generic_hdmi_free(struct hda_codec *codec) 1021 + { 1022 + struct hdmi_spec *spec = codec->spec; 1023 + int i; 1024 + 1025 + for (i = 0; i < spec->num_pins; i++) 1026 + snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); 1027 + 1028 + kfree(spec); 1029 + } 1030 + 1031 + static struct hda_codec_ops generic_hdmi_patch_ops = { 1032 + .init = generic_hdmi_init, 1033 + .free = generic_hdmi_free, 1034 + .build_pcms = generic_hdmi_build_pcms, 1035 + .build_controls = generic_hdmi_build_controls, 1036 + .unsol_event = hdmi_unsol_event, 1037 + }; 1038 + 1039 + static int patch_generic_hdmi(struct hda_codec *codec) 1040 + { 1041 + struct hdmi_spec *spec; 1042 + int i; 1043 + 1044 + spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1045 + if (spec == NULL) 1046 + return -ENOMEM; 1047 + 1048 + codec->spec = spec; 1049 + if (hdmi_parse_codec(codec) < 0) { 1050 + codec->spec = NULL; 1051 + kfree(spec); 1052 + return -EINVAL; 1053 + } 1054 + codec->patch_ops = generic_hdmi_patch_ops; 1055 + 1056 + for (i = 0; i < spec->num_pins; i++) 1057 + snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); 1058 + 1059 + init_channel_allocations(); 1060 + 1061 + return 0; 1062 + } 1063 + 1064 + /* 1065 + * Nvidia specific implementations 1066 + */ 1067 + 1068 + #define Nv_VERB_SET_Channel_Allocation 0xF79 1069 + #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A 1070 + #define Nv_VERB_SET_Audio_Protection_On 0xF98 1071 + #define Nv_VERB_SET_Audio_Protection_Off 0xF99 1072 + 1073 + #define nvhdmi_master_con_nid_7x 0x04 1074 + #define nvhdmi_master_pin_nid_7x 0x05 1075 + 1076 + static hda_nid_t nvhdmi_con_nids_7x[4] = { 1077 + /*front, rear, clfe, rear_surr */ 1078 + 0x6, 0x8, 0xa, 0xc, 1079 + }; 1080 + 1081 + static struct hda_verb nvhdmi_basic_init_7x[] = { 1082 + /* set audio protect on */ 1083 + { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, 1084 + /* enable digital output on pin widget */ 1085 + { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 1086 + { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 1087 + { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 1088 + { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 1089 + { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 1090 + {} /* terminator */ 1091 + }; 1092 + 1093 + #ifdef LIMITED_RATE_FMT_SUPPORT 1094 + /* support only the safe format and rate */ 1095 + #define SUPPORTED_RATES SNDRV_PCM_RATE_48000 1096 + #define SUPPORTED_MAXBPS 16 1097 + #define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE 1098 + #else 1099 + /* support all rates and formats */ 1100 + #define SUPPORTED_RATES \ 1101 + (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ 1102 + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\ 1103 + SNDRV_PCM_RATE_192000) 1104 + #define SUPPORTED_MAXBPS 24 1105 + #define SUPPORTED_FORMATS \ 1106 + (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) 1107 + #endif 1108 + 1109 + static int nvhdmi_7x_init(struct hda_codec *codec) 1110 + { 1111 + snd_hda_sequence_write(codec, nvhdmi_basic_init_7x); 1112 + return 0; 1113 + } 1114 + 1115 + static int simple_playback_pcm_open(struct hda_pcm_stream *hinfo, 1116 + struct hda_codec *codec, 1117 + struct snd_pcm_substream *substream) 1118 + { 1119 + struct hdmi_spec *spec = codec->spec; 1120 + return snd_hda_multi_out_dig_open(codec, &spec->multiout); 1121 + } 1122 + 1123 + static int simple_playback_pcm_close(struct hda_pcm_stream *hinfo, 1124 + struct hda_codec *codec, 1125 + struct snd_pcm_substream *substream) 1126 + { 1127 + struct hdmi_spec *spec = codec->spec; 1128 + return snd_hda_multi_out_dig_close(codec, &spec->multiout); 1129 + } 1130 + 1131 + static int simple_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 1132 + struct hda_codec *codec, 1133 + unsigned int stream_tag, 1134 + unsigned int format, 1135 + struct snd_pcm_substream *substream) 1136 + { 1137 + struct hdmi_spec *spec = codec->spec; 1138 + return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 1139 + stream_tag, format, substream); 1140 + } 1141 + 1142 + static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo, 1143 + struct hda_codec *codec, 1144 + struct snd_pcm_substream *substream) 1145 + { 1146 + struct hdmi_spec *spec = codec->spec; 1147 + int i; 1148 + 1149 + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 1150 + 0, AC_VERB_SET_CHANNEL_STREAMID, 0); 1151 + for (i = 0; i < 4; i++) { 1152 + /* set the stream id */ 1153 + snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, 1154 + AC_VERB_SET_CHANNEL_STREAMID, 0); 1155 + /* set the stream format */ 1156 + snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, 1157 + AC_VERB_SET_STREAM_FORMAT, 0); 1158 + } 1159 + 1160 + return snd_hda_multi_out_dig_close(codec, &spec->multiout); 1161 + } 1162 + 1163 + static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, 1164 + struct hda_codec *codec, 1165 + unsigned int stream_tag, 1166 + unsigned int format, 1167 + struct snd_pcm_substream *substream) 1168 + { 1169 + int chs; 1170 + unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id; 1171 + int i; 1172 + 1173 + mutex_lock(&codec->spdif_mutex); 1174 + 1175 + chs = substream->runtime->channels; 1176 + chan = chs ? (chs - 1) : 1; 1177 + 1178 + switch (chs) { 1179 + default: 1180 + case 0: 1181 + case 2: 1182 + chanmask = 0x00; 1183 + break; 1184 + case 4: 1185 + chanmask = 0x08; 1186 + break; 1187 + case 6: 1188 + chanmask = 0x0b; 1189 + break; 1190 + case 8: 1191 + chanmask = 0x13; 1192 + break; 1193 + } 1194 + dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT; 1195 + dataDCC2 = 0x2; 1196 + 1197 + /* set the Audio InforFrame Channel Allocation */ 1198 + snd_hda_codec_write(codec, 0x1, 0, 1199 + Nv_VERB_SET_Channel_Allocation, chanmask); 1200 + 1201 + /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 1202 + if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 1203 + snd_hda_codec_write(codec, 1204 + nvhdmi_master_con_nid_7x, 1205 + 0, 1206 + AC_VERB_SET_DIGI_CONVERT_1, 1207 + codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 1208 + 1209 + /* set the stream id */ 1210 + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, 1211 + AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); 1212 + 1213 + /* set the stream format */ 1214 + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, 1215 + AC_VERB_SET_STREAM_FORMAT, format); 1216 + 1217 + /* turn on again (if needed) */ 1218 + /* enable and set the channel status audio/data flag */ 1219 + if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { 1220 + snd_hda_codec_write(codec, 1221 + nvhdmi_master_con_nid_7x, 1222 + 0, 1223 + AC_VERB_SET_DIGI_CONVERT_1, 1224 + codec->spdif_ctls & 0xff); 1225 + snd_hda_codec_write(codec, 1226 + nvhdmi_master_con_nid_7x, 1227 + 0, 1228 + AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 1229 + } 1230 + 1231 + for (i = 0; i < 4; i++) { 1232 + if (chs == 2) 1233 + channel_id = 0; 1234 + else 1235 + channel_id = i * 2; 1236 + 1237 + /* turn off SPDIF once; 1238 + *otherwise the IEC958 bits won't be updated 1239 + */ 1240 + if (codec->spdif_status_reset && 1241 + (codec->spdif_ctls & AC_DIG1_ENABLE)) 1242 + snd_hda_codec_write(codec, 1243 + nvhdmi_con_nids_7x[i], 1244 + 0, 1245 + AC_VERB_SET_DIGI_CONVERT_1, 1246 + codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 1247 + /* set the stream id */ 1248 + snd_hda_codec_write(codec, 1249 + nvhdmi_con_nids_7x[i], 1250 + 0, 1251 + AC_VERB_SET_CHANNEL_STREAMID, 1252 + (stream_tag << 4) | channel_id); 1253 + /* set the stream format */ 1254 + snd_hda_codec_write(codec, 1255 + nvhdmi_con_nids_7x[i], 1256 + 0, 1257 + AC_VERB_SET_STREAM_FORMAT, 1258 + format); 1259 + /* turn on again (if needed) */ 1260 + /* enable and set the channel status audio/data flag */ 1261 + if (codec->spdif_status_reset && 1262 + (codec->spdif_ctls & AC_DIG1_ENABLE)) { 1263 + snd_hda_codec_write(codec, 1264 + nvhdmi_con_nids_7x[i], 1265 + 0, 1266 + AC_VERB_SET_DIGI_CONVERT_1, 1267 + codec->spdif_ctls & 0xff); 1268 + snd_hda_codec_write(codec, 1269 + nvhdmi_con_nids_7x[i], 1270 + 0, 1271 + AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 1272 + } 1273 + } 1274 + 1275 + /* set the Audio Info Frame Checksum */ 1276 + snd_hda_codec_write(codec, 0x1, 0, 1277 + Nv_VERB_SET_Info_Frame_Checksum, 1278 + (0x71 - chan - chanmask)); 1279 + 1280 + mutex_unlock(&codec->spdif_mutex); 1281 + return 0; 1282 + } 1283 + 1284 + static struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = { 1285 + .substreams = 1, 1286 + .channels_min = 2, 1287 + .channels_max = 8, 1288 + .nid = nvhdmi_master_con_nid_7x, 1289 + .rates = SUPPORTED_RATES, 1290 + .maxbps = SUPPORTED_MAXBPS, 1291 + .formats = SUPPORTED_FORMATS, 1292 + .ops = { 1293 + .open = simple_playback_pcm_open, 1294 + .close = nvhdmi_8ch_7x_pcm_close, 1295 + .prepare = nvhdmi_8ch_7x_pcm_prepare 1296 + }, 1297 + }; 1298 + 1299 + static struct hda_pcm_stream nvhdmi_pcm_playback_2ch = { 1300 + .substreams = 1, 1301 + .channels_min = 2, 1302 + .channels_max = 2, 1303 + .nid = nvhdmi_master_con_nid_7x, 1304 + .rates = SUPPORTED_RATES, 1305 + .maxbps = SUPPORTED_MAXBPS, 1306 + .formats = SUPPORTED_FORMATS, 1307 + .ops = { 1308 + .open = simple_playback_pcm_open, 1309 + .close = simple_playback_pcm_close, 1310 + .prepare = simple_playback_pcm_prepare 1311 + }, 1312 + }; 1313 + 1314 + static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { 1315 + .build_controls = generic_hdmi_build_controls, 1316 + .build_pcms = generic_hdmi_build_pcms, 1317 + .init = nvhdmi_7x_init, 1318 + .free = generic_hdmi_free, 1319 + }; 1320 + 1321 + static struct hda_codec_ops nvhdmi_patch_ops_2ch = { 1322 + .build_controls = generic_hdmi_build_controls, 1323 + .build_pcms = generic_hdmi_build_pcms, 1324 + .init = nvhdmi_7x_init, 1325 + .free = generic_hdmi_free, 1326 + }; 1327 + 1328 + static int patch_nvhdmi_8ch_89(struct hda_codec *codec) 1329 + { 1330 + struct hdmi_spec *spec; 1331 + int err = patch_generic_hdmi(codec); 1332 + 1333 + if (err < 0) 1334 + return err; 1335 + spec = codec->spec; 1336 + spec->old_pin_detect = 1; 1337 + return 0; 1338 + } 1339 + 1340 + static int patch_nvhdmi_2ch(struct hda_codec *codec) 1341 + { 1342 + struct hdmi_spec *spec; 1343 + 1344 + spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1345 + if (spec == NULL) 1346 + return -ENOMEM; 1347 + 1348 + codec->spec = spec; 1349 + 1350 + spec->multiout.num_dacs = 0; /* no analog */ 1351 + spec->multiout.max_channels = 2; 1352 + spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 1353 + spec->old_pin_detect = 1; 1354 + spec->num_cvts = 1; 1355 + spec->cvt[0] = nvhdmi_master_con_nid_7x; 1356 + spec->pcm_playback = &nvhdmi_pcm_playback_2ch; 1357 + 1358 + codec->patch_ops = nvhdmi_patch_ops_2ch; 1359 + 1360 + return 0; 1361 + } 1362 + 1363 + static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) 1364 + { 1365 + struct hdmi_spec *spec; 1366 + int err = patch_nvhdmi_2ch(codec); 1367 + 1368 + if (err < 0) 1369 + return err; 1370 + spec = codec->spec; 1371 + spec->multiout.max_channels = 8; 1372 + spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x; 1373 + codec->patch_ops = nvhdmi_patch_ops_8ch_7x; 1374 + return 0; 1375 + } 1376 + 1377 + /* 1378 + * ATI-specific implementations 1379 + * 1380 + * FIXME: we may omit the whole this and use the generic code once after 1381 + * it's confirmed to work. 1382 + */ 1383 + 1384 + #define ATIHDMI_CVT_NID 0x02 /* audio converter */ 1385 + #define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */ 1386 + 1387 + static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 1388 + struct hda_codec *codec, 1389 + unsigned int stream_tag, 1390 + unsigned int format, 1391 + struct snd_pcm_substream *substream) 1392 + { 1393 + struct hdmi_spec *spec = codec->spec; 1394 + int chans = substream->runtime->channels; 1395 + int i, err; 1396 + 1397 + err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format, 1398 + substream); 1399 + if (err < 0) 1400 + return err; 1401 + snd_hda_codec_write(codec, spec->cvt[0], 0, AC_VERB_SET_CVT_CHAN_COUNT, 1402 + chans - 1); 1403 + /* FIXME: XXX */ 1404 + for (i = 0; i < chans; i++) { 1405 + snd_hda_codec_write(codec, spec->cvt[0], 0, 1406 + AC_VERB_SET_HDMI_CHAN_SLOT, 1407 + (i << 4) | i); 1408 + } 1409 + return 0; 1410 + } 1411 + 1412 + static struct hda_pcm_stream atihdmi_pcm_digital_playback = { 1413 + .substreams = 1, 1414 + .channels_min = 2, 1415 + .channels_max = 2, 1416 + .nid = ATIHDMI_CVT_NID, 1417 + .ops = { 1418 + .open = simple_playback_pcm_open, 1419 + .close = simple_playback_pcm_close, 1420 + .prepare = atihdmi_playback_pcm_prepare 1421 + }, 1422 + }; 1423 + 1424 + static struct hda_verb atihdmi_basic_init[] = { 1425 + /* enable digital output on pin widget */ 1426 + { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1427 + {} /* terminator */ 1428 + }; 1429 + 1430 + static int atihdmi_init(struct hda_codec *codec) 1431 + { 1432 + struct hdmi_spec *spec = codec->spec; 1433 + 1434 + snd_hda_sequence_write(codec, atihdmi_basic_init); 1435 + /* SI codec requires to unmute the pin */ 1436 + if (get_wcaps(codec, spec->pin[0]) & AC_WCAP_OUT_AMP) 1437 + snd_hda_codec_write(codec, spec->pin[0], 0, 1438 + AC_VERB_SET_AMP_GAIN_MUTE, 1439 + AMP_OUT_UNMUTE); 1440 + return 0; 1441 + } 1442 + 1443 + static struct hda_codec_ops atihdmi_patch_ops = { 1444 + .build_controls = generic_hdmi_build_controls, 1445 + .build_pcms = generic_hdmi_build_pcms, 1446 + .init = atihdmi_init, 1447 + .free = generic_hdmi_free, 1448 + }; 1449 + 1450 + 1451 + static int patch_atihdmi(struct hda_codec *codec) 1452 + { 1453 + struct hdmi_spec *spec; 1454 + 1455 + spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1456 + if (spec == NULL) 1457 + return -ENOMEM; 1458 + 1459 + codec->spec = spec; 1460 + 1461 + spec->multiout.num_dacs = 0; /* no analog */ 1462 + spec->multiout.max_channels = 2; 1463 + spec->multiout.dig_out_nid = ATIHDMI_CVT_NID; 1464 + spec->num_cvts = 1; 1465 + spec->cvt[0] = ATIHDMI_CVT_NID; 1466 + spec->pin[0] = ATIHDMI_PIN_NID; 1467 + spec->pcm_playback = &atihdmi_pcm_digital_playback; 1468 + 1469 + codec->patch_ops = atihdmi_patch_ops; 1470 + 1471 + return 0; 1472 + } 1473 + 1474 + 1475 + /* 1476 + * patch entries 1477 + */ 1478 + static struct hda_codec_preset snd_hda_preset_hdmi[] = { 1479 + { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, 1480 + { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, 1481 + { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, 1482 + { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, 1483 + { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi }, 1484 + { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi }, 1485 + { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi }, 1486 + { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 1487 + { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 1488 + { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 1489 + { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 1490 + { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, 1491 + { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1492 + { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1493 + { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 }, 1494 + { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1495 + { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1496 + { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1497 + { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1498 + { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1499 + { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1500 + { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1501 + { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1502 + { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1503 + { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1504 + { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1505 + { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1506 + { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1507 + { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1508 + { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1509 + { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 1510 + { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 1511 + { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 1512 + { .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi }, 1513 + { .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_generic_hdmi }, 1514 + { .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_generic_hdmi }, 1515 + { .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_generic_hdmi }, 1516 + { .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi }, 1517 + { .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_generic_hdmi }, 1518 + { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, 1519 + {} /* terminator */ 1520 + }; 1521 + 1522 + MODULE_ALIAS("snd-hda-codec-id:1002793c"); 1523 + MODULE_ALIAS("snd-hda-codec-id:10027919"); 1524 + MODULE_ALIAS("snd-hda-codec-id:1002791a"); 1525 + MODULE_ALIAS("snd-hda-codec-id:1002aa01"); 1526 + MODULE_ALIAS("snd-hda-codec-id:10951390"); 1527 + MODULE_ALIAS("snd-hda-codec-id:10951392"); 1528 + MODULE_ALIAS("snd-hda-codec-id:10de0002"); 1529 + MODULE_ALIAS("snd-hda-codec-id:10de0003"); 1530 + MODULE_ALIAS("snd-hda-codec-id:10de0005"); 1531 + MODULE_ALIAS("snd-hda-codec-id:10de0006"); 1532 + MODULE_ALIAS("snd-hda-codec-id:10de0007"); 1533 + MODULE_ALIAS("snd-hda-codec-id:10de000a"); 1534 + MODULE_ALIAS("snd-hda-codec-id:10de000b"); 1535 + MODULE_ALIAS("snd-hda-codec-id:10de000c"); 1536 + MODULE_ALIAS("snd-hda-codec-id:10de000d"); 1537 + MODULE_ALIAS("snd-hda-codec-id:10de0010"); 1538 + MODULE_ALIAS("snd-hda-codec-id:10de0011"); 1539 + MODULE_ALIAS("snd-hda-codec-id:10de0012"); 1540 + MODULE_ALIAS("snd-hda-codec-id:10de0013"); 1541 + MODULE_ALIAS("snd-hda-codec-id:10de0014"); 1542 + MODULE_ALIAS("snd-hda-codec-id:10de0018"); 1543 + MODULE_ALIAS("snd-hda-codec-id:10de0019"); 1544 + MODULE_ALIAS("snd-hda-codec-id:10de001a"); 1545 + MODULE_ALIAS("snd-hda-codec-id:10de001b"); 1546 + MODULE_ALIAS("snd-hda-codec-id:10de001c"); 1547 + MODULE_ALIAS("snd-hda-codec-id:10de0040"); 1548 + MODULE_ALIAS("snd-hda-codec-id:10de0041"); 1549 + MODULE_ALIAS("snd-hda-codec-id:10de0042"); 1550 + MODULE_ALIAS("snd-hda-codec-id:10de0043"); 1551 + MODULE_ALIAS("snd-hda-codec-id:10de0044"); 1552 + MODULE_ALIAS("snd-hda-codec-id:10de0067"); 1553 + MODULE_ALIAS("snd-hda-codec-id:10de8001"); 1554 + MODULE_ALIAS("snd-hda-codec-id:17e80047"); 1555 + MODULE_ALIAS("snd-hda-codec-id:80860054"); 1556 + MODULE_ALIAS("snd-hda-codec-id:80862801"); 1557 + MODULE_ALIAS("snd-hda-codec-id:80862802"); 1558 + MODULE_ALIAS("snd-hda-codec-id:80862803"); 1559 + MODULE_ALIAS("snd-hda-codec-id:80862804"); 1560 + MODULE_ALIAS("snd-hda-codec-id:80862805"); 1561 + MODULE_ALIAS("snd-hda-codec-id:808629fb"); 1562 + 1563 + MODULE_LICENSE("GPL"); 1564 + MODULE_DESCRIPTION("HDMI HD-audio codec"); 1565 + MODULE_ALIAS("snd-hda-codec-intelhdmi"); 1566 + MODULE_ALIAS("snd-hda-codec-nvhdmi"); 1567 + MODULE_ALIAS("snd-hda-codec-atihdmi"); 1568 + 1569 + static struct hda_codec_preset_list intel_list = { 1570 + .preset = snd_hda_preset_hdmi, 1571 + .owner = THIS_MODULE, 1572 + }; 1573 + 1574 + static int __init patch_hdmi_init(void) 1575 + { 1576 + return snd_hda_add_codec_preset(&intel_list); 1577 + } 1578 + 1579 + static void __exit patch_hdmi_exit(void) 1580 + { 1581 + snd_hda_delete_codec_preset(&intel_list); 1582 + } 1583 + 1584 + module_init(patch_hdmi_init) 1585 + module_exit(patch_hdmi_exit)
-220
sound/pci/hda/patch_intelhdmi.c
··· 1 - /* 2 - * 3 - * patch_intelhdmi.c - Patch for Intel HDMI codecs 4 - * 5 - * Copyright(c) 2008 Intel Corporation. All rights reserved. 6 - * 7 - * Authors: 8 - * Jiang Zhe <zhe.jiang@intel.com> 9 - * Wu Fengguang <wfg@linux.intel.com> 10 - * 11 - * Maintained by: 12 - * Wu Fengguang <wfg@linux.intel.com> 13 - * 14 - * This program is free software; you can redistribute it and/or modify it 15 - * under the terms of the GNU General Public License as published by the Free 16 - * Software Foundation; either version 2 of the License, or (at your option) 17 - * any later version. 18 - * 19 - * This program is distributed in the hope that it will be useful, but 20 - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 21 - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22 - * for more details. 23 - * 24 - * You should have received a copy of the GNU General Public License 25 - * along with this program; if not, write to the Free Software Foundation, 26 - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 27 - */ 28 - 29 - #include <linux/init.h> 30 - #include <linux/delay.h> 31 - #include <linux/slab.h> 32 - #include <sound/core.h> 33 - #include "hda_codec.h" 34 - #include "hda_local.h" 35 - 36 - /* 37 - * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device 38 - * could support two independent pipes, each of them can be connected to one or 39 - * more ports (DVI, HDMI or DisplayPort). 40 - * 41 - * The HDA correspondence of pipes/ports are converter/pin nodes. 42 - */ 43 - #define MAX_HDMI_CVTS 3 44 - #define MAX_HDMI_PINS 3 45 - 46 - #include "patch_hdmi.c" 47 - 48 - static char *intel_hdmi_pcm_names[MAX_HDMI_CVTS] = { 49 - "INTEL HDMI 0", 50 - "INTEL HDMI 1", 51 - "INTEL HDMI 2", 52 - }; 53 - 54 - /* 55 - * HDMI callbacks 56 - */ 57 - 58 - static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 59 - struct hda_codec *codec, 60 - unsigned int stream_tag, 61 - unsigned int format, 62 - struct snd_pcm_substream *substream) 63 - { 64 - hdmi_set_channel_count(codec, hinfo->nid, 65 - substream->runtime->channels); 66 - 67 - hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); 68 - 69 - return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); 70 - } 71 - 72 - static struct hda_pcm_stream intel_hdmi_pcm_playback = { 73 - .substreams = 1, 74 - .channels_min = 2, 75 - .ops = { 76 - .open = hdmi_pcm_open, 77 - .prepare = intel_hdmi_playback_pcm_prepare, 78 - }, 79 - }; 80 - 81 - static int intel_hdmi_build_pcms(struct hda_codec *codec) 82 - { 83 - struct hdmi_spec *spec = codec->spec; 84 - struct hda_pcm *info = spec->pcm_rec; 85 - int i; 86 - 87 - codec->num_pcms = spec->num_cvts; 88 - codec->pcm_info = info; 89 - 90 - for (i = 0; i < codec->num_pcms; i++, info++) { 91 - unsigned int chans; 92 - 93 - chans = get_wcaps(codec, spec->cvt[i]); 94 - chans = get_wcaps_channels(chans); 95 - 96 - info->name = intel_hdmi_pcm_names[i]; 97 - info->pcm_type = HDA_PCM_TYPE_HDMI; 98 - info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 99 - intel_hdmi_pcm_playback; 100 - info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; 101 - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; 102 - } 103 - 104 - return 0; 105 - } 106 - 107 - static int intel_hdmi_build_controls(struct hda_codec *codec) 108 - { 109 - struct hdmi_spec *spec = codec->spec; 110 - int err; 111 - int i; 112 - 113 - for (i = 0; i < codec->num_pcms; i++) { 114 - err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]); 115 - if (err < 0) 116 - return err; 117 - } 118 - 119 - return 0; 120 - } 121 - 122 - static int intel_hdmi_init(struct hda_codec *codec) 123 - { 124 - struct hdmi_spec *spec = codec->spec; 125 - int i; 126 - 127 - for (i = 0; spec->pin[i]; i++) { 128 - hdmi_enable_output(codec, spec->pin[i]); 129 - snd_hda_codec_write(codec, spec->pin[i], 0, 130 - AC_VERB_SET_UNSOLICITED_ENABLE, 131 - AC_USRSP_EN | spec->pin[i]); 132 - } 133 - return 0; 134 - } 135 - 136 - static void intel_hdmi_free(struct hda_codec *codec) 137 - { 138 - struct hdmi_spec *spec = codec->spec; 139 - int i; 140 - 141 - for (i = 0; i < spec->num_pins; i++) 142 - snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); 143 - 144 - kfree(spec); 145 - } 146 - 147 - static struct hda_codec_ops intel_hdmi_patch_ops = { 148 - .init = intel_hdmi_init, 149 - .free = intel_hdmi_free, 150 - .build_pcms = intel_hdmi_build_pcms, 151 - .build_controls = intel_hdmi_build_controls, 152 - .unsol_event = hdmi_unsol_event, 153 - }; 154 - 155 - static int patch_intel_hdmi(struct hda_codec *codec) 156 - { 157 - struct hdmi_spec *spec; 158 - int i; 159 - 160 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 161 - if (spec == NULL) 162 - return -ENOMEM; 163 - 164 - codec->spec = spec; 165 - if (hdmi_parse_codec(codec) < 0) { 166 - codec->spec = NULL; 167 - kfree(spec); 168 - return -EINVAL; 169 - } 170 - codec->patch_ops = intel_hdmi_patch_ops; 171 - 172 - for (i = 0; i < spec->num_pins; i++) 173 - snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); 174 - 175 - init_channel_allocations(); 176 - 177 - return 0; 178 - } 179 - 180 - static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { 181 - { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_intel_hdmi }, 182 - { .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_intel_hdmi }, 183 - { .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_intel_hdmi }, 184 - { .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_intel_hdmi }, 185 - { .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_intel_hdmi }, 186 - { .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_intel_hdmi }, 187 - { .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_intel_hdmi }, 188 - { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, 189 - {} /* terminator */ 190 - }; 191 - 192 - MODULE_ALIAS("snd-hda-codec-id:808629fb"); 193 - MODULE_ALIAS("snd-hda-codec-id:80862801"); 194 - MODULE_ALIAS("snd-hda-codec-id:80862802"); 195 - MODULE_ALIAS("snd-hda-codec-id:80862803"); 196 - MODULE_ALIAS("snd-hda-codec-id:80862804"); 197 - MODULE_ALIAS("snd-hda-codec-id:80862805"); 198 - MODULE_ALIAS("snd-hda-codec-id:80860054"); 199 - MODULE_ALIAS("snd-hda-codec-id:10951392"); 200 - 201 - MODULE_LICENSE("GPL"); 202 - MODULE_DESCRIPTION("Intel HDMI HD-audio codec"); 203 - 204 - static struct hda_codec_preset_list intel_list = { 205 - .preset = snd_hda_preset_intelhdmi, 206 - .owner = THIS_MODULE, 207 - }; 208 - 209 - static int __init patch_intelhdmi_init(void) 210 - { 211 - return snd_hda_add_codec_preset(&intel_list); 212 - } 213 - 214 - static void __exit patch_intelhdmi_exit(void) 215 - { 216 - snd_hda_delete_codec_preset(&intel_list); 217 - } 218 - 219 - module_init(patch_intelhdmi_init) 220 - module_exit(patch_intelhdmi_exit)
-608
sound/pci/hda/patch_nvhdmi.c
··· 1 - /* 2 - * Universal Interface for Intel High Definition Audio Codec 3 - * 4 - * HD audio interface patch for NVIDIA HDMI codecs 5 - * 6 - * Copyright (c) 2008 NVIDIA Corp. All rights reserved. 7 - * Copyright (c) 2008 Wei Ni <wni@nvidia.com> 8 - * 9 - * 10 - * This driver is free software; you can redistribute it and/or modify 11 - * it under the terms of the GNU General Public License as published by 12 - * the Free Software Foundation; either version 2 of the License, or 13 - * (at your option) any later version. 14 - * 15 - * This driver is distributed in the hope that it will be useful, 16 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 - * GNU General Public License for more details. 19 - * 20 - * You should have received a copy of the GNU General Public License 21 - * along with this program; if not, write to the Free Software 22 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 - */ 24 - 25 - #include <linux/init.h> 26 - #include <linux/delay.h> 27 - #include <linux/slab.h> 28 - #include <sound/core.h> 29 - #include "hda_codec.h" 30 - #include "hda_local.h" 31 - 32 - #define MAX_HDMI_CVTS 1 33 - #define MAX_HDMI_PINS 1 34 - 35 - #include "patch_hdmi.c" 36 - 37 - static char *nvhdmi_pcm_names[MAX_HDMI_CVTS] = { 38 - "NVIDIA HDMI", 39 - }; 40 - 41 - /* define below to restrict the supported rates and formats */ 42 - /* #define LIMITED_RATE_FMT_SUPPORT */ 43 - 44 - enum HDACodec { 45 - HDA_CODEC_NVIDIA_MCP7X, 46 - HDA_CODEC_NVIDIA_MCP89, 47 - HDA_CODEC_NVIDIA_GT21X, 48 - HDA_CODEC_INVALID 49 - }; 50 - 51 - #define Nv_VERB_SET_Channel_Allocation 0xF79 52 - #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A 53 - #define Nv_VERB_SET_Audio_Protection_On 0xF98 54 - #define Nv_VERB_SET_Audio_Protection_Off 0xF99 55 - 56 - #define nvhdmi_master_con_nid_7x 0x04 57 - #define nvhdmi_master_pin_nid_7x 0x05 58 - 59 - #define nvhdmi_master_con_nid_89 0x04 60 - #define nvhdmi_master_pin_nid_89 0x05 61 - 62 - static hda_nid_t nvhdmi_con_nids_7x[4] = { 63 - /*front, rear, clfe, rear_surr */ 64 - 0x6, 0x8, 0xa, 0xc, 65 - }; 66 - 67 - static struct hda_verb nvhdmi_basic_init_7x[] = { 68 - /* set audio protect on */ 69 - { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, 70 - /* enable digital output on pin widget */ 71 - { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 72 - { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 73 - { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 74 - { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 75 - { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, 76 - {} /* terminator */ 77 - }; 78 - 79 - #ifdef LIMITED_RATE_FMT_SUPPORT 80 - /* support only the safe format and rate */ 81 - #define SUPPORTED_RATES SNDRV_PCM_RATE_48000 82 - #define SUPPORTED_MAXBPS 16 83 - #define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE 84 - #else 85 - /* support all rates and formats */ 86 - #define SUPPORTED_RATES \ 87 - (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ 88 - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\ 89 - SNDRV_PCM_RATE_192000) 90 - #define SUPPORTED_MAXBPS 24 91 - #define SUPPORTED_FORMATS \ 92 - (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) 93 - #endif 94 - 95 - /* 96 - * Controls 97 - */ 98 - static int nvhdmi_build_controls(struct hda_codec *codec) 99 - { 100 - struct hdmi_spec *spec = codec->spec; 101 - int err; 102 - int i; 103 - 104 - if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) 105 - || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { 106 - for (i = 0; i < codec->num_pcms; i++) { 107 - err = snd_hda_create_spdif_out_ctls(codec, 108 - spec->cvt[i]); 109 - if (err < 0) 110 - return err; 111 - } 112 - } else { 113 - err = snd_hda_create_spdif_out_ctls(codec, 114 - spec->multiout.dig_out_nid); 115 - if (err < 0) 116 - return err; 117 - } 118 - 119 - return 0; 120 - } 121 - 122 - static int nvhdmi_init(struct hda_codec *codec) 123 - { 124 - struct hdmi_spec *spec = codec->spec; 125 - int i; 126 - if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) 127 - || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { 128 - for (i = 0; spec->pin[i]; i++) { 129 - hdmi_enable_output(codec, spec->pin[i]); 130 - snd_hda_codec_write(codec, spec->pin[i], 0, 131 - AC_VERB_SET_UNSOLICITED_ENABLE, 132 - AC_USRSP_EN | spec->pin[i]); 133 - } 134 - } else { 135 - snd_hda_sequence_write(codec, nvhdmi_basic_init_7x); 136 - } 137 - return 0; 138 - } 139 - 140 - static void nvhdmi_free(struct hda_codec *codec) 141 - { 142 - struct hdmi_spec *spec = codec->spec; 143 - int i; 144 - 145 - if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) 146 - || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { 147 - for (i = 0; i < spec->num_pins; i++) 148 - snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); 149 - } 150 - 151 - kfree(spec); 152 - } 153 - 154 - /* 155 - * Digital out 156 - */ 157 - static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 158 - struct hda_codec *codec, 159 - struct snd_pcm_substream *substream) 160 - { 161 - struct hdmi_spec *spec = codec->spec; 162 - return snd_hda_multi_out_dig_open(codec, &spec->multiout); 163 - } 164 - 165 - static int nvhdmi_dig_playback_pcm_close_8ch_7x(struct hda_pcm_stream *hinfo, 166 - struct hda_codec *codec, 167 - struct snd_pcm_substream *substream) 168 - { 169 - struct hdmi_spec *spec = codec->spec; 170 - int i; 171 - 172 - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 173 - 0, AC_VERB_SET_CHANNEL_STREAMID, 0); 174 - for (i = 0; i < 4; i++) { 175 - /* set the stream id */ 176 - snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, 177 - AC_VERB_SET_CHANNEL_STREAMID, 0); 178 - /* set the stream format */ 179 - snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, 180 - AC_VERB_SET_STREAM_FORMAT, 0); 181 - } 182 - 183 - return snd_hda_multi_out_dig_close(codec, &spec->multiout); 184 - } 185 - 186 - static int nvhdmi_dig_playback_pcm_close_2ch(struct hda_pcm_stream *hinfo, 187 - struct hda_codec *codec, 188 - struct snd_pcm_substream *substream) 189 - { 190 - struct hdmi_spec *spec = codec->spec; 191 - return snd_hda_multi_out_dig_close(codec, &spec->multiout); 192 - } 193 - 194 - static int nvhdmi_dig_playback_pcm_prepare_8ch_89(struct hda_pcm_stream *hinfo, 195 - struct hda_codec *codec, 196 - unsigned int stream_tag, 197 - unsigned int format, 198 - struct snd_pcm_substream *substream) 199 - { 200 - hdmi_set_channel_count(codec, hinfo->nid, 201 - substream->runtime->channels); 202 - 203 - hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); 204 - 205 - return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); 206 - } 207 - 208 - static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, 209 - struct hda_codec *codec, 210 - unsigned int stream_tag, 211 - unsigned int format, 212 - struct snd_pcm_substream *substream) 213 - { 214 - int chs; 215 - unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id; 216 - int i; 217 - 218 - mutex_lock(&codec->spdif_mutex); 219 - 220 - chs = substream->runtime->channels; 221 - chan = chs ? (chs - 1) : 1; 222 - 223 - switch (chs) { 224 - default: 225 - case 0: 226 - case 2: 227 - chanmask = 0x00; 228 - break; 229 - case 4: 230 - chanmask = 0x08; 231 - break; 232 - case 6: 233 - chanmask = 0x0b; 234 - break; 235 - case 8: 236 - chanmask = 0x13; 237 - break; 238 - } 239 - dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT; 240 - dataDCC2 = 0x2; 241 - 242 - /* set the Audio InforFrame Channel Allocation */ 243 - snd_hda_codec_write(codec, 0x1, 0, 244 - Nv_VERB_SET_Channel_Allocation, chanmask); 245 - 246 - /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 247 - if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 248 - snd_hda_codec_write(codec, 249 - nvhdmi_master_con_nid_7x, 250 - 0, 251 - AC_VERB_SET_DIGI_CONVERT_1, 252 - codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 253 - 254 - /* set the stream id */ 255 - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, 256 - AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); 257 - 258 - /* set the stream format */ 259 - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, 260 - AC_VERB_SET_STREAM_FORMAT, format); 261 - 262 - /* turn on again (if needed) */ 263 - /* enable and set the channel status audio/data flag */ 264 - if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { 265 - snd_hda_codec_write(codec, 266 - nvhdmi_master_con_nid_7x, 267 - 0, 268 - AC_VERB_SET_DIGI_CONVERT_1, 269 - codec->spdif_ctls & 0xff); 270 - snd_hda_codec_write(codec, 271 - nvhdmi_master_con_nid_7x, 272 - 0, 273 - AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 274 - } 275 - 276 - for (i = 0; i < 4; i++) { 277 - if (chs == 2) 278 - channel_id = 0; 279 - else 280 - channel_id = i * 2; 281 - 282 - /* turn off SPDIF once; 283 - *otherwise the IEC958 bits won't be updated 284 - */ 285 - if (codec->spdif_status_reset && 286 - (codec->spdif_ctls & AC_DIG1_ENABLE)) 287 - snd_hda_codec_write(codec, 288 - nvhdmi_con_nids_7x[i], 289 - 0, 290 - AC_VERB_SET_DIGI_CONVERT_1, 291 - codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 292 - /* set the stream id */ 293 - snd_hda_codec_write(codec, 294 - nvhdmi_con_nids_7x[i], 295 - 0, 296 - AC_VERB_SET_CHANNEL_STREAMID, 297 - (stream_tag << 4) | channel_id); 298 - /* set the stream format */ 299 - snd_hda_codec_write(codec, 300 - nvhdmi_con_nids_7x[i], 301 - 0, 302 - AC_VERB_SET_STREAM_FORMAT, 303 - format); 304 - /* turn on again (if needed) */ 305 - /* enable and set the channel status audio/data flag */ 306 - if (codec->spdif_status_reset && 307 - (codec->spdif_ctls & AC_DIG1_ENABLE)) { 308 - snd_hda_codec_write(codec, 309 - nvhdmi_con_nids_7x[i], 310 - 0, 311 - AC_VERB_SET_DIGI_CONVERT_1, 312 - codec->spdif_ctls & 0xff); 313 - snd_hda_codec_write(codec, 314 - nvhdmi_con_nids_7x[i], 315 - 0, 316 - AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 317 - } 318 - } 319 - 320 - /* set the Audio Info Frame Checksum */ 321 - snd_hda_codec_write(codec, 0x1, 0, 322 - Nv_VERB_SET_Info_Frame_Checksum, 323 - (0x71 - chan - chanmask)); 324 - 325 - mutex_unlock(&codec->spdif_mutex); 326 - return 0; 327 - } 328 - 329 - static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, 330 - struct hda_codec *codec, 331 - unsigned int stream_tag, 332 - unsigned int format, 333 - struct snd_pcm_substream *substream) 334 - { 335 - struct hdmi_spec *spec = codec->spec; 336 - return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, 337 - format, substream); 338 - } 339 - 340 - static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { 341 - .substreams = 1, 342 - .channels_min = 2, 343 - .ops = { 344 - .open = hdmi_pcm_open, 345 - .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, 346 - }, 347 - }; 348 - 349 - static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_7x = { 350 - .substreams = 1, 351 - .channels_min = 2, 352 - .channels_max = 8, 353 - .nid = nvhdmi_master_con_nid_7x, 354 - .rates = SUPPORTED_RATES, 355 - .maxbps = SUPPORTED_MAXBPS, 356 - .formats = SUPPORTED_FORMATS, 357 - .ops = { 358 - .open = nvhdmi_dig_playback_pcm_open, 359 - .close = nvhdmi_dig_playback_pcm_close_8ch_7x, 360 - .prepare = nvhdmi_dig_playback_pcm_prepare_8ch 361 - }, 362 - }; 363 - 364 - static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = { 365 - .substreams = 1, 366 - .channels_min = 2, 367 - .channels_max = 2, 368 - .nid = nvhdmi_master_con_nid_7x, 369 - .rates = SUPPORTED_RATES, 370 - .maxbps = SUPPORTED_MAXBPS, 371 - .formats = SUPPORTED_FORMATS, 372 - .ops = { 373 - .open = nvhdmi_dig_playback_pcm_open, 374 - .close = nvhdmi_dig_playback_pcm_close_2ch, 375 - .prepare = nvhdmi_dig_playback_pcm_prepare_2ch 376 - }, 377 - }; 378 - 379 - static int nvhdmi_build_pcms_8ch_89(struct hda_codec *codec) 380 - { 381 - struct hdmi_spec *spec = codec->spec; 382 - struct hda_pcm *info = spec->pcm_rec; 383 - int i; 384 - 385 - codec->num_pcms = spec->num_cvts; 386 - codec->pcm_info = info; 387 - 388 - for (i = 0; i < codec->num_pcms; i++, info++) { 389 - unsigned int chans; 390 - 391 - chans = get_wcaps(codec, spec->cvt[i]); 392 - chans = get_wcaps_channels(chans); 393 - 394 - info->name = nvhdmi_pcm_names[i]; 395 - info->pcm_type = HDA_PCM_TYPE_HDMI; 396 - info->stream[SNDRV_PCM_STREAM_PLAYBACK] 397 - = nvhdmi_pcm_digital_playback_8ch_89; 398 - info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; 399 - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; 400 - } 401 - 402 - return 0; 403 - } 404 - 405 - static int nvhdmi_build_pcms_8ch_7x(struct hda_codec *codec) 406 - { 407 - struct hdmi_spec *spec = codec->spec; 408 - struct hda_pcm *info = spec->pcm_rec; 409 - 410 - codec->num_pcms = 1; 411 - codec->pcm_info = info; 412 - 413 - info->name = "NVIDIA HDMI"; 414 - info->pcm_type = HDA_PCM_TYPE_HDMI; 415 - info->stream[SNDRV_PCM_STREAM_PLAYBACK] 416 - = nvhdmi_pcm_digital_playback_8ch_7x; 417 - 418 - return 0; 419 - } 420 - 421 - static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) 422 - { 423 - struct hdmi_spec *spec = codec->spec; 424 - struct hda_pcm *info = spec->pcm_rec; 425 - 426 - codec->num_pcms = 1; 427 - codec->pcm_info = info; 428 - 429 - info->name = "NVIDIA HDMI"; 430 - info->pcm_type = HDA_PCM_TYPE_HDMI; 431 - info->stream[SNDRV_PCM_STREAM_PLAYBACK] 432 - = nvhdmi_pcm_digital_playback_2ch; 433 - 434 - return 0; 435 - } 436 - 437 - static struct hda_codec_ops nvhdmi_patch_ops_8ch_89 = { 438 - .build_controls = nvhdmi_build_controls, 439 - .build_pcms = nvhdmi_build_pcms_8ch_89, 440 - .init = nvhdmi_init, 441 - .free = nvhdmi_free, 442 - .unsol_event = hdmi_unsol_event, 443 - }; 444 - 445 - static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { 446 - .build_controls = nvhdmi_build_controls, 447 - .build_pcms = nvhdmi_build_pcms_8ch_7x, 448 - .init = nvhdmi_init, 449 - .free = nvhdmi_free, 450 - }; 451 - 452 - static struct hda_codec_ops nvhdmi_patch_ops_2ch = { 453 - .build_controls = nvhdmi_build_controls, 454 - .build_pcms = nvhdmi_build_pcms_2ch, 455 - .init = nvhdmi_init, 456 - .free = nvhdmi_free, 457 - }; 458 - 459 - static int patch_nvhdmi_8ch_89(struct hda_codec *codec) 460 - { 461 - struct hdmi_spec *spec; 462 - int i; 463 - 464 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 465 - if (spec == NULL) 466 - return -ENOMEM; 467 - 468 - codec->spec = spec; 469 - spec->codec_type = HDA_CODEC_NVIDIA_MCP89; 470 - spec->old_pin_detect = 1; 471 - 472 - if (hdmi_parse_codec(codec) < 0) { 473 - codec->spec = NULL; 474 - kfree(spec); 475 - return -EINVAL; 476 - } 477 - codec->patch_ops = nvhdmi_patch_ops_8ch_89; 478 - 479 - for (i = 0; i < spec->num_pins; i++) 480 - snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); 481 - 482 - init_channel_allocations(); 483 - 484 - return 0; 485 - } 486 - 487 - static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) 488 - { 489 - struct hdmi_spec *spec; 490 - 491 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 492 - if (spec == NULL) 493 - return -ENOMEM; 494 - 495 - codec->spec = spec; 496 - 497 - spec->multiout.num_dacs = 0; /* no analog */ 498 - spec->multiout.max_channels = 8; 499 - spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 500 - spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; 501 - spec->old_pin_detect = 1; 502 - 503 - codec->patch_ops = nvhdmi_patch_ops_8ch_7x; 504 - 505 - return 0; 506 - } 507 - 508 - static int patch_nvhdmi_2ch(struct hda_codec *codec) 509 - { 510 - struct hdmi_spec *spec; 511 - 512 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 513 - if (spec == NULL) 514 - return -ENOMEM; 515 - 516 - codec->spec = spec; 517 - 518 - spec->multiout.num_dacs = 0; /* no analog */ 519 - spec->multiout.max_channels = 2; 520 - spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 521 - spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; 522 - spec->old_pin_detect = 1; 523 - 524 - codec->patch_ops = nvhdmi_patch_ops_2ch; 525 - 526 - return 0; 527 - } 528 - 529 - /* 530 - * patch entries 531 - */ 532 - static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { 533 - { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 534 - { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 535 - { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 536 - { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, 537 - { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, 538 - { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 539 - { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 540 - { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 }, 541 - { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 542 - { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 543 - { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 544 - { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 545 - { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 546 - { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 547 - { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 548 - { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 549 - { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 550 - { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 551 - { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 552 - { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 553 - { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 554 - { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 555 - { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 556 - { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, 557 - { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 558 - { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 559 - {} /* terminator */ 560 - }; 561 - 562 - MODULE_ALIAS("snd-hda-codec-id:10de0002"); 563 - MODULE_ALIAS("snd-hda-codec-id:10de0003"); 564 - MODULE_ALIAS("snd-hda-codec-id:10de0005"); 565 - MODULE_ALIAS("snd-hda-codec-id:10de0006"); 566 - MODULE_ALIAS("snd-hda-codec-id:10de0007"); 567 - MODULE_ALIAS("snd-hda-codec-id:10de000a"); 568 - MODULE_ALIAS("snd-hda-codec-id:10de000b"); 569 - MODULE_ALIAS("snd-hda-codec-id:10de000c"); 570 - MODULE_ALIAS("snd-hda-codec-id:10de000d"); 571 - MODULE_ALIAS("snd-hda-codec-id:10de0010"); 572 - MODULE_ALIAS("snd-hda-codec-id:10de0011"); 573 - MODULE_ALIAS("snd-hda-codec-id:10de0012"); 574 - MODULE_ALIAS("snd-hda-codec-id:10de0013"); 575 - MODULE_ALIAS("snd-hda-codec-id:10de0014"); 576 - MODULE_ALIAS("snd-hda-codec-id:10de0018"); 577 - MODULE_ALIAS("snd-hda-codec-id:10de0019"); 578 - MODULE_ALIAS("snd-hda-codec-id:10de001a"); 579 - MODULE_ALIAS("snd-hda-codec-id:10de001b"); 580 - MODULE_ALIAS("snd-hda-codec-id:10de001c"); 581 - MODULE_ALIAS("snd-hda-codec-id:10de0040"); 582 - MODULE_ALIAS("snd-hda-codec-id:10de0041"); 583 - MODULE_ALIAS("snd-hda-codec-id:10de0042"); 584 - MODULE_ALIAS("snd-hda-codec-id:10de0043"); 585 - MODULE_ALIAS("snd-hda-codec-id:10de0044"); 586 - MODULE_ALIAS("snd-hda-codec-id:10de0067"); 587 - MODULE_ALIAS("snd-hda-codec-id:10de8001"); 588 - 589 - MODULE_LICENSE("GPL"); 590 - MODULE_DESCRIPTION("NVIDIA HDMI HD-audio codec"); 591 - 592 - static struct hda_codec_preset_list nvhdmi_list = { 593 - .preset = snd_hda_preset_nvhdmi, 594 - .owner = THIS_MODULE, 595 - }; 596 - 597 - static int __init patch_nvhdmi_init(void) 598 - { 599 - return snd_hda_add_codec_preset(&nvhdmi_list); 600 - } 601 - 602 - static void __exit patch_nvhdmi_exit(void) 603 - { 604 - snd_hda_delete_codec_preset(&nvhdmi_list); 605 - } 606 - 607 - module_init(patch_nvhdmi_init) 608 - module_exit(patch_nvhdmi_exit)
+649 -261
sound/pci/hda/patch_realtek.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/pci.h> 30 30 #include <sound/core.h> 31 + #include <sound/jack.h> 31 32 #include "hda_codec.h" 32 33 #include "hda_local.h" 33 34 #include "hda_beep.h" ··· 283 282 unsigned char amix_idx; 284 283 }; 285 284 285 + struct alc_jack { 286 + hda_nid_t nid; 287 + int type; 288 + struct snd_jack *jack; 289 + }; 290 + 286 291 #define MUX_IDX_UNDEF ((unsigned char)-1) 287 292 288 293 struct alc_customize_define { ··· 301 294 unsigned int platform_type:1; 302 295 unsigned int swap:1; 303 296 unsigned int override:1; 297 + unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ 304 298 }; 305 299 306 300 struct alc_spec { ··· 365 357 /* PCM information */ 366 358 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ 367 359 360 + /* jack detection */ 361 + struct snd_array jacks; 362 + 368 363 /* dynamic controls, init_verbs and input_mux */ 369 364 struct auto_pin_cfg autocfg; 370 365 struct alc_customize_define cdefine; ··· 394 383 unsigned int no_analog :1; /* digital I/O only */ 395 384 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */ 396 385 int init_amp; 386 + int codec_variant; /* flag for other variants */ 397 387 398 388 /* for virtual master */ 399 389 hda_nid_t vmaster_nid; ··· 858 846 { 859 847 unsigned int val = PIN_IN; 860 848 861 - if (auto_pin_type <= AUTO_PIN_FRONT_MIC) { 849 + if (auto_pin_type == AUTO_PIN_MIC) { 862 850 unsigned int pincap; 863 851 unsigned int oldval; 864 852 oldval = snd_hda_codec_read(codec, nid, 0, ··· 876 864 val = PIN_VREFGRD; 877 865 } 878 866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); 867 + } 868 + 869 + static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec) 870 + { 871 + struct alc_spec *spec = codec->spec; 872 + struct auto_pin_cfg *cfg = &spec->autocfg; 873 + 874 + if (!cfg->line_outs) { 875 + while (cfg->line_outs < AUTO_CFG_MAX_OUTS && 876 + cfg->line_out_pins[cfg->line_outs]) 877 + cfg->line_outs++; 878 + } 879 + if (!cfg->speaker_outs) { 880 + while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS && 881 + cfg->speaker_pins[cfg->speaker_outs]) 882 + cfg->speaker_outs++; 883 + } 884 + if (!cfg->hp_outs) { 885 + while (cfg->hp_outs < AUTO_CFG_MAX_OUTS && 886 + cfg->hp_pins[cfg->hp_outs]) 887 + cfg->hp_outs++; 888 + } 879 889 } 880 890 881 891 /* ··· 968 934 969 935 if (preset->setup) 970 936 preset->setup(codec); 937 + 938 + alc_fixup_autocfg_pin_nums(codec); 971 939 } 972 940 973 941 /* Enable GPIO mask and set output */ ··· 1026 990 alc_fix_pll(codec); 1027 991 } 1028 992 1029 - static void alc_automute_pin(struct hda_codec *codec) 993 + #ifdef CONFIG_SND_HDA_INPUT_JACK 994 + static void alc_free_jack_priv(struct snd_jack *jack) 995 + { 996 + struct alc_jack *jacks = jack->private_data; 997 + jacks->nid = 0; 998 + jacks->jack = NULL; 999 + } 1000 + 1001 + static int alc_add_jack(struct hda_codec *codec, 1002 + hda_nid_t nid, int type) 1003 + { 1004 + struct alc_spec *spec; 1005 + struct alc_jack *jack; 1006 + const char *name; 1007 + int err; 1008 + 1009 + spec = codec->spec; 1010 + snd_array_init(&spec->jacks, sizeof(*jack), 32); 1011 + jack = snd_array_new(&spec->jacks); 1012 + if (!jack) 1013 + return -ENOMEM; 1014 + 1015 + jack->nid = nid; 1016 + jack->type = type; 1017 + name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ; 1018 + 1019 + err = snd_jack_new(codec->bus->card, name, type, &jack->jack); 1020 + if (err < 0) 1021 + return err; 1022 + jack->jack->private_data = jack; 1023 + jack->jack->private_free = alc_free_jack_priv; 1024 + return 0; 1025 + } 1026 + 1027 + static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid) 1030 1028 { 1031 1029 struct alc_spec *spec = codec->spec; 1032 - unsigned int nid = spec->autocfg.hp_pins[0]; 1030 + struct alc_jack *jacks = spec->jacks.list; 1031 + 1032 + if (jacks) { 1033 + int i; 1034 + for (i = 0; i < spec->jacks.used; i++) { 1035 + if (jacks->nid == nid) { 1036 + unsigned int present; 1037 + present = snd_hda_jack_detect(codec, nid); 1038 + 1039 + present = (present) ? jacks->type : 0; 1040 + 1041 + snd_jack_report(jacks->jack, present); 1042 + } 1043 + jacks++; 1044 + } 1045 + } 1046 + } 1047 + 1048 + static int alc_init_jacks(struct hda_codec *codec) 1049 + { 1050 + struct alc_spec *spec = codec->spec; 1051 + int err; 1052 + unsigned int hp_nid = spec->autocfg.hp_pins[0]; 1053 + unsigned int mic_nid = spec->ext_mic.pin; 1054 + 1055 + if (hp_nid) { 1056 + err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE); 1057 + if (err < 0) 1058 + return err; 1059 + alc_report_jack(codec, hp_nid); 1060 + } 1061 + 1062 + if (mic_nid) { 1063 + err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE); 1064 + if (err < 0) 1065 + return err; 1066 + alc_report_jack(codec, mic_nid); 1067 + } 1068 + 1069 + return 0; 1070 + } 1071 + #else 1072 + static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid) 1073 + { 1074 + } 1075 + 1076 + static inline int alc_init_jacks(struct hda_codec *codec) 1077 + { 1078 + return 0; 1079 + } 1080 + #endif 1081 + 1082 + static void alc_automute_speaker(struct hda_codec *codec, int pinctl) 1083 + { 1084 + struct alc_spec *spec = codec->spec; 1085 + unsigned int mute; 1086 + hda_nid_t nid; 1033 1087 int i; 1034 1088 1035 - if (!nid) 1036 - return; 1037 - spec->jack_present = snd_hda_jack_detect(codec, nid); 1089 + spec->jack_present = 0; 1090 + for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { 1091 + nid = spec->autocfg.hp_pins[i]; 1092 + if (!nid) 1093 + break; 1094 + if (snd_hda_jack_detect(codec, nid)) { 1095 + spec->jack_present = 1; 1096 + break; 1097 + } 1098 + alc_report_jack(codec, spec->autocfg.hp_pins[i]); 1099 + } 1100 + 1101 + mute = spec->jack_present ? HDA_AMP_MUTE : 0; 1102 + /* Toggle internal speakers muting */ 1038 1103 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { 1039 1104 nid = spec->autocfg.speaker_pins[i]; 1040 1105 if (!nid) 1041 1106 break; 1042 - snd_hda_codec_write(codec, nid, 0, 1107 + if (pinctl) { 1108 + snd_hda_codec_write(codec, nid, 0, 1043 1109 AC_VERB_SET_PIN_WIDGET_CONTROL, 1044 1110 spec->jack_present ? 0 : PIN_OUT); 1111 + } else { 1112 + snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 1113 + HDA_AMP_MUTE, mute); 1114 + } 1045 1115 } 1116 + } 1117 + 1118 + static void alc_automute_pin(struct hda_codec *codec) 1119 + { 1120 + alc_automute_speaker(codec, 1); 1046 1121 } 1047 1122 1048 1123 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, ··· 1237 1090 AC_VERB_SET_CONNECT_SEL, 1238 1091 alive->mux_idx); 1239 1092 } 1093 + alc_report_jack(codec, spec->ext_mic.pin); 1240 1094 1241 1095 /* FIXME: analog mixer */ 1242 1096 } ··· 1384 1236 static void alc_init_auto_hp(struct hda_codec *codec) 1385 1237 { 1386 1238 struct alc_spec *spec = codec->spec; 1239 + struct auto_pin_cfg *cfg = &spec->autocfg; 1240 + int i; 1387 1241 1388 - if (!spec->autocfg.hp_pins[0]) 1389 - return; 1390 - 1391 - if (!spec->autocfg.speaker_pins[0]) { 1392 - if (spec->autocfg.line_out_pins[0] && 1393 - spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) 1394 - spec->autocfg.speaker_pins[0] = 1395 - spec->autocfg.line_out_pins[0]; 1396 - else 1242 + if (!cfg->hp_pins[0]) { 1243 + if (cfg->line_out_type != AUTO_PIN_HP_OUT) 1397 1244 return; 1398 1245 } 1399 1246 1400 - snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", 1401 - spec->autocfg.hp_pins[0]); 1402 - snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0, 1247 + if (!cfg->speaker_pins[0]) { 1248 + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) 1249 + return; 1250 + memcpy(cfg->speaker_pins, cfg->line_out_pins, 1251 + sizeof(cfg->speaker_pins)); 1252 + cfg->speaker_outs = cfg->line_outs; 1253 + } 1254 + 1255 + if (!cfg->hp_pins[0]) { 1256 + memcpy(cfg->hp_pins, cfg->line_out_pins, 1257 + sizeof(cfg->hp_pins)); 1258 + cfg->hp_outs = cfg->line_outs; 1259 + } 1260 + 1261 + for (i = 0; i < cfg->hp_outs; i++) { 1262 + snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", 1263 + cfg->hp_pins[i]); 1264 + snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0, 1403 1265 AC_VERB_SET_UNSOLICITED_ENABLE, 1404 1266 AC_USRSP_EN | ALC880_HP_EVENT); 1267 + } 1405 1268 spec->unsol_event = alc_sku_unsol_event; 1406 1269 } 1407 1270 ··· 1424 1265 int i; 1425 1266 1426 1267 /* there must be only two mic inputs exclusively */ 1427 - for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) 1428 - if (cfg->input_pins[i]) 1268 + for (i = 0; i < cfg->num_inputs; i++) 1269 + if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) 1429 1270 return; 1430 1271 1431 1272 fixed = ext = 0; 1432 - for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) { 1433 - hda_nid_t nid = cfg->input_pins[i]; 1273 + for (i = 0; i < cfg->num_inputs; i++) { 1274 + hda_nid_t nid = cfg->inputs[i].pin; 1434 1275 unsigned int defcfg; 1435 - if (!nid) 1436 - return; 1437 1276 defcfg = snd_hda_codec_get_pincfg(codec, nid); 1438 - switch (get_defcfg_connect(defcfg)) { 1439 - case AC_JACK_PORT_FIXED: 1277 + switch (snd_hda_get_input_pin_attr(defcfg)) { 1278 + case INPUT_PIN_ATTR_INT: 1440 1279 if (fixed) 1441 1280 return; /* already occupied */ 1442 1281 fixed = nid; 1443 1282 break; 1444 - case AC_JACK_PORT_COMPLEX: 1283 + case INPUT_PIN_ATTR_UNUSED: 1284 + return; /* invalid entry */ 1285 + default: 1445 1286 if (ext) 1446 1287 return; /* already occupied */ 1447 1288 ext = nid; 1448 1289 break; 1449 - default: 1450 - return; /* invalid entry */ 1451 1290 } 1452 1291 } 1453 1292 if (!ext || !fixed) ··· 1465 1308 spec->unsol_event = alc_sku_unsol_event; 1466 1309 } 1467 1310 1311 + /* Could be any non-zero and even value. When used as fixup, tells 1312 + * the driver to ignore any present sku defines. 1313 + */ 1314 + #define ALC_FIXUP_SKU_IGNORE (2) 1315 + 1468 1316 static int alc_auto_parse_customize_define(struct hda_codec *codec) 1469 1317 { 1470 1318 unsigned int ass, tmp, i; ··· 1477 1315 struct alc_spec *spec = codec->spec; 1478 1316 1479 1317 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ 1318 + 1319 + if (spec->cdefine.fixup) { 1320 + ass = spec->cdefine.sku_cfg; 1321 + if (ass == ALC_FIXUP_SKU_IGNORE) 1322 + return -1; 1323 + goto do_sku; 1324 + } 1480 1325 1481 1326 ass = codec->subsystem_id & 0xffff; 1482 1327 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) ··· 1551 1382 unsigned int ass, tmp, i; 1552 1383 unsigned nid; 1553 1384 struct alc_spec *spec = codec->spec; 1385 + 1386 + if (spec->cdefine.fixup) { 1387 + ass = spec->cdefine.sku_cfg; 1388 + if (ass == ALC_FIXUP_SKU_IGNORE) 1389 + return 0; 1390 + goto do_sku; 1391 + } 1554 1392 1555 1393 ass = codec->subsystem_id & 0xffff; 1556 1394 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) ··· 1678 1502 }; 1679 1503 1680 1504 struct alc_fixup { 1505 + unsigned int sku; 1681 1506 const struct alc_pincfg *pins; 1682 1507 const struct hda_verb *verbs; 1683 1508 }; ··· 1689 1512 int pre_init) 1690 1513 { 1691 1514 const struct alc_pincfg *cfg; 1515 + struct alc_spec *spec; 1692 1516 1693 1517 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1694 1518 if (!quirk) 1695 1519 return; 1696 1520 fix += quirk->value; 1697 1521 cfg = fix->pins; 1522 + if (pre_init && fix->sku) { 1523 + #ifdef CONFIG_SND_DEBUG_VERBOSE 1524 + snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n", 1525 + codec->chip_name, quirk->name); 1526 + #endif 1527 + spec = codec->spec; 1528 + spec->cdefine.sku_cfg = fix->sku; 1529 + spec->cdefine.fixup = 1; 1530 + } 1698 1531 if (pre_init && cfg) { 1699 1532 #ifdef CONFIG_SND_DEBUG_VERBOSE 1700 1533 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n", ··· 1731 1544 val = snd_hda_codec_read(codec, 0x20, 0, 1732 1545 AC_VERB_GET_PROC_COEF, 0); 1733 1546 return val; 1547 + } 1548 + 1549 + static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, 1550 + unsigned int coef_val) 1551 + { 1552 + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 1553 + coef_idx); 1554 + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 1555 + coef_val); 1734 1556 } 1735 1557 1736 1558 /* set right pin controls for digital I/O */ ··· 1919 1723 1920 1724 static void alc_automute_amp(struct hda_codec *codec) 1921 1725 { 1922 - struct alc_spec *spec = codec->spec; 1923 - unsigned int mute; 1924 - hda_nid_t nid; 1925 - int i; 1926 - 1927 - spec->jack_present = 0; 1928 - for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { 1929 - nid = spec->autocfg.hp_pins[i]; 1930 - if (!nid) 1931 - break; 1932 - if (snd_hda_jack_detect(codec, nid)) { 1933 - spec->jack_present = 1; 1934 - break; 1935 - } 1936 - } 1937 - 1938 - mute = spec->jack_present ? HDA_AMP_MUTE : 0; 1939 - /* Toggle internal speakers muting */ 1940 - for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { 1941 - nid = spec->autocfg.speaker_pins[i]; 1942 - if (!nid) 1943 - break; 1944 - snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 1945 - HDA_AMP_MUTE, mute); 1946 - } 1726 + alc_automute_speaker(codec, 0); 1947 1727 } 1948 1728 1949 1729 static void alc_automute_amp_unsol_event(struct hda_codec *codec, ··· 3774 3602 if (spec->init_hook) 3775 3603 spec->init_hook(codec); 3776 3604 3777 - #ifdef CONFIG_SND_HDA_POWER_SAVE 3778 - if (codec->patch_ops.check_power_status) 3779 - codec->patch_ops.check_power_status(codec, 0x01); 3780 - #endif 3605 + hda_call_check_power_status(codec, 0x01); 3781 3606 return 0; 3782 3607 } 3783 3608 ··· 4170 4001 codec->patch_ops.init(codec); 4171 4002 snd_hda_codec_resume_amp(codec); 4172 4003 snd_hda_codec_resume_cache(codec); 4173 - #ifdef CONFIG_SND_HDA_POWER_SAVE 4174 - if (codec->patch_ops.check_power_status) 4175 - codec->patch_ops.check_power_status(codec, 0x01); 4176 - #endif 4004 + hda_call_check_power_status(codec, 0x01); 4177 4005 return 0; 4178 4006 } 4179 4007 #endif ··· 4895 4729 4896 4730 /* add dynamic controls */ 4897 4731 static int add_control(struct alc_spec *spec, int type, const char *name, 4898 - unsigned long val) 4732 + int cidx, unsigned long val) 4899 4733 { 4900 4734 struct snd_kcontrol_new *knew; 4901 4735 ··· 4907 4741 knew->name = kstrdup(name, GFP_KERNEL); 4908 4742 if (!knew->name) 4909 4743 return -ENOMEM; 4744 + knew->index = cidx; 4910 4745 if (get_amp_nid_(val)) 4911 4746 knew->subdevice = HDA_SUBDEV_AMP_FLAG; 4912 4747 knew->private_value = val; ··· 4916 4749 4917 4750 static int add_control_with_pfx(struct alc_spec *spec, int type, 4918 4751 const char *pfx, const char *dir, 4919 - const char *sfx, unsigned long val) 4752 + const char *sfx, int cidx, unsigned long val) 4920 4753 { 4921 4754 char name[32]; 4922 4755 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); 4923 - return add_control(spec, type, name, val); 4756 + return add_control(spec, type, name, cidx, val); 4924 4757 } 4925 4758 4926 - #define add_pb_vol_ctrl(spec, type, pfx, val) \ 4927 - add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val) 4928 - #define add_pb_sw_ctrl(spec, type, pfx, val) \ 4929 - add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val) 4759 + #define add_pb_vol_ctrl(spec, type, pfx, val) \ 4760 + add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) 4761 + #define add_pb_sw_ctrl(spec, type, pfx, val) \ 4762 + add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) 4763 + #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ 4764 + add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) 4765 + #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ 4766 + add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) 4930 4767 4931 4768 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) 4932 4769 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) ··· 5083 4912 5084 4913 /* create input playback/capture controls for the given pin */ 5085 4914 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, 5086 - const char *ctlname, 4915 + const char *ctlname, int ctlidx, 5087 4916 int idx, hda_nid_t mix_nid) 5088 4917 { 5089 4918 int err; 5090 4919 5091 - err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, 4920 + err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, 5092 4921 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 5093 4922 if (err < 0) 5094 4923 return err; 5095 - err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, 4924 + err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, 5096 4925 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 5097 4926 if (err < 0) 5098 4927 return err; ··· 5113 4942 { 5114 4943 struct alc_spec *spec = codec->spec; 5115 4944 struct hda_input_mux *imux = &spec->private_imux[0]; 5116 - int i, err, idx; 4945 + int i, err, idx, type, type_idx = 0; 5117 4946 5118 - for (i = 0; i < AUTO_PIN_LAST; i++) { 4947 + for (i = 0; i < cfg->num_inputs; i++) { 5119 4948 hda_nid_t pin; 4949 + const char *label; 5120 4950 5121 - pin = cfg->input_pins[i]; 4951 + pin = cfg->inputs[i].pin; 5122 4952 if (!alc_is_input_pin(codec, pin)) 5123 4953 continue; 5124 4954 4955 + type = cfg->inputs[i].type; 4956 + if (i > 0 && type == cfg->inputs[i - 1].type) 4957 + type_idx++; 4958 + else 4959 + type_idx = 0; 4960 + label = hda_get_autocfg_input_label(codec, cfg, i); 5125 4961 if (mixer) { 5126 4962 idx = get_connection_index(codec, mixer, pin); 5127 4963 if (idx >= 0) { 5128 4964 err = new_analog_input(spec, pin, 5129 - auto_pin_cfg_labels[i], 4965 + label, type_idx, 5130 4966 idx, mixer); 5131 4967 if (err < 0) 5132 4968 return err; ··· 5145 4967 idx = get_connection_index(codec, cap1, pin); 5146 4968 if (idx < 0 && cap2) 5147 4969 idx = get_connection_index(codec, cap2, pin); 5148 - if (idx >= 0) { 5149 - imux->items[imux->num_items].label = 5150 - auto_pin_cfg_labels[i]; 5151 - imux->items[imux->num_items].index = idx; 5152 - imux->num_items++; 5153 - } 4970 + if (idx >= 0) 4971 + snd_hda_add_imux_item(imux, label, idx, NULL); 5154 4972 } 5155 4973 return 0; 5156 4974 } ··· 5218 5044 static void alc880_auto_init_analog_input(struct hda_codec *codec) 5219 5045 { 5220 5046 struct alc_spec *spec = codec->spec; 5047 + struct auto_pin_cfg *cfg = &spec->autocfg; 5221 5048 int i; 5222 5049 5223 - for (i = 0; i < AUTO_PIN_LAST; i++) { 5224 - hda_nid_t nid = spec->autocfg.input_pins[i]; 5050 + for (i = 0; i < cfg->num_inputs; i++) { 5051 + hda_nid_t nid = cfg->inputs[i].pin; 5225 5052 if (alc_is_input_pin(codec, nid)) { 5226 - alc_set_input_pin(codec, nid, i); 5053 + alc_set_input_pin(codec, nid, cfg->inputs[i].type); 5227 5054 if (nid != ALC880_PIN_CD_NID && 5228 5055 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 5229 5056 snd_hda_codec_write(codec, nid, 0, ··· 5389 5214 static void fixup_single_adc(struct hda_codec *codec) 5390 5215 { 5391 5216 struct alc_spec *spec = codec->spec; 5392 - hda_nid_t pin = 0; 5217 + struct auto_pin_cfg *cfg = &spec->autocfg; 5393 5218 int i; 5394 5219 5395 5220 /* search for the input pin; there must be only one */ 5396 - for (i = 0; i < AUTO_PIN_LAST; i++) { 5397 - if (spec->autocfg.input_pins[i]) { 5398 - pin = spec->autocfg.input_pins[i]; 5399 - break; 5400 - } 5401 - } 5402 - if (!pin) 5221 + if (cfg->num_inputs != 1) 5403 5222 return; 5404 - i = init_capsrc_for_pin(codec, pin); 5223 + i = init_capsrc_for_pin(codec, cfg->inputs[0].pin); 5405 5224 if (i >= 0) { 5406 5225 /* use only this ADC */ 5407 5226 if (spec->capsrc_nids) ··· 5448 5279 int num_nids) 5449 5280 { 5450 5281 struct alc_spec *spec = codec->spec; 5282 + struct auto_pin_cfg *cfg = &spec->autocfg; 5451 5283 int n; 5452 5284 hda_nid_t fallback_adc = 0, fallback_cap = 0; 5453 5285 ··· 5474 5304 fallback_adc = adc; 5475 5305 fallback_cap = cap; 5476 5306 } 5477 - for (i = 0; i < AUTO_PIN_LAST; i++) { 5478 - hda_nid_t nid = spec->autocfg.input_pins[i]; 5479 - if (!nid) 5480 - continue; 5307 + for (i = 0; i < cfg->num_inputs; i++) { 5308 + hda_nid_t nid = cfg->inputs[i].pin; 5481 5309 for (j = 0; j < nconns; j++) { 5482 5310 if (conn[j] == nid) 5483 5311 break; ··· 5483 5315 if (j >= nconns) 5484 5316 break; 5485 5317 } 5486 - if (i >= AUTO_PIN_LAST) { 5318 + if (i >= cfg->num_inputs) { 5487 5319 int num_adcs = spec->num_adc_nids; 5488 5320 spec->private_adc_nids[num_adcs] = adc; 5489 5321 spec->private_capsrc_nids[num_adcs] = cap; ··· 6851 6683 static void alc260_auto_init_analog_input(struct hda_codec *codec) 6852 6684 { 6853 6685 struct alc_spec *spec = codec->spec; 6686 + struct auto_pin_cfg *cfg = &spec->autocfg; 6854 6687 int i; 6855 6688 6856 - for (i = 0; i < AUTO_PIN_LAST; i++) { 6857 - hda_nid_t nid = spec->autocfg.input_pins[i]; 6689 + for (i = 0; i < cfg->num_inputs; i++) { 6690 + hda_nid_t nid = cfg->inputs[i].pin; 6858 6691 if (nid >= 0x12) { 6859 - alc_set_input_pin(codec, nid, i); 6692 + alc_set_input_pin(codec, nid, cfg->inputs[i].type); 6860 6693 if (nid != ALC260_PIN_CD_NID && 6861 6694 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 6862 6695 snd_hda_codec_write(codec, nid, 0, ··· 6979 6810 PINFIX_HP_DC5750, 6980 6811 }; 6981 6812 6982 - static struct alc_pincfg alc260_hp_dc5750_pinfix[] = { 6983 - { 0x11, 0x90130110 }, /* speaker */ 6984 - { } 6985 - }; 6986 - 6987 6813 static const struct alc_fixup alc260_fixups[] = { 6988 6814 [PINFIX_HP_DC5750] = { 6989 - .pins = alc260_hp_dc5750_pinfix 6815 + .pins = (const struct alc_pincfg[]) { 6816 + { 0x11, 0x90130110 }, /* speaker */ 6817 + { } 6818 + } 6990 6819 }, 6991 6820 }; 6992 6821 ··· 10628 10461 enum { 10629 10462 PINFIX_ABIT_AW9D_MAX, 10630 10463 PINFIX_PB_M5210, 10631 - }; 10632 - 10633 - static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { 10634 - { 0x15, 0x01080104 }, /* side */ 10635 - { 0x16, 0x01011012 }, /* rear */ 10636 - { 0x17, 0x01016011 }, /* clfe */ 10637 - { } 10638 - }; 10639 - 10640 - static const struct hda_verb pb_m5210_verbs[] = { 10641 - { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 10642 - {} 10464 + PINFIX_ACER_ASPIRE_7736, 10643 10465 }; 10644 10466 10645 10467 static const struct alc_fixup alc882_fixups[] = { 10646 10468 [PINFIX_ABIT_AW9D_MAX] = { 10647 - .pins = alc882_abit_aw9d_pinfix 10469 + .pins = (const struct alc_pincfg[]) { 10470 + { 0x15, 0x01080104 }, /* side */ 10471 + { 0x16, 0x01011012 }, /* rear */ 10472 + { 0x17, 0x01016011 }, /* clfe */ 10473 + { } 10474 + } 10648 10475 }, 10649 10476 [PINFIX_PB_M5210] = { 10650 - .verbs = pb_m5210_verbs 10477 + .verbs = (const struct hda_verb[]) { 10478 + { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 10479 + {} 10480 + } 10481 + }, 10482 + [PINFIX_ACER_ASPIRE_7736] = { 10483 + .sku = ALC_FIXUP_SKU_IGNORE, 10651 10484 }, 10652 10485 }; 10653 10486 10654 10487 static struct snd_pci_quirk alc882_fixup_tbl[] = { 10655 10488 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), 10656 10489 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), 10490 + SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), 10657 10491 {} 10658 10492 }; 10659 10493 ··· 10703 10535 { 10704 10536 struct alc_spec *spec = codec->spec; 10705 10537 hda_nid_t pin, dac; 10538 + int i; 10706 10539 10707 - pin = spec->autocfg.hp_pins[0]; 10708 - if (pin) { 10540 + for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { 10541 + pin = spec->autocfg.hp_pins[i]; 10542 + if (!pin) 10543 + break; 10709 10544 dac = spec->multiout.hp_nid; 10710 10545 if (!dac) 10711 10546 dac = spec->multiout.dac_nids[0]; /* to front */ 10712 10547 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); 10713 10548 } 10714 - pin = spec->autocfg.speaker_pins[0]; 10715 - if (pin) { 10549 + for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { 10550 + pin = spec->autocfg.speaker_pins[i]; 10551 + if (!pin) 10552 + break; 10716 10553 dac = spec->multiout.extra_out_nid[0]; 10717 10554 if (!dac) 10718 10555 dac = spec->multiout.dac_nids[0]; /* to front */ ··· 10728 10555 static void alc882_auto_init_analog_input(struct hda_codec *codec) 10729 10556 { 10730 10557 struct alc_spec *spec = codec->spec; 10558 + struct auto_pin_cfg *cfg = &spec->autocfg; 10731 10559 int i; 10732 10560 10733 - for (i = 0; i < AUTO_PIN_LAST; i++) { 10734 - hda_nid_t nid = spec->autocfg.input_pins[i]; 10735 - if (!nid) 10736 - continue; 10737 - alc_set_input_pin(codec, nid, i); 10561 + for (i = 0; i < cfg->num_inputs; i++) { 10562 + hda_nid_t nid = cfg->inputs[i].pin; 10563 + alc_set_input_pin(codec, nid, cfg->inputs[i].type); 10738 10564 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 10739 10565 snd_hda_codec_write(codec, nid, 0, 10740 10566 AC_VERB_SET_AMP_GAIN_MUTE, ··· 10795 10623 static int alc_auto_add_mic_boost(struct hda_codec *codec) 10796 10624 { 10797 10625 struct alc_spec *spec = codec->spec; 10798 - int err; 10626 + struct auto_pin_cfg *cfg = &spec->autocfg; 10627 + int i, err; 10799 10628 hda_nid_t nid; 10800 10629 10801 - nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; 10802 - if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { 10803 - err = add_control(spec, ALC_CTL_WIDGET_VOL, 10804 - "Mic Boost", 10630 + for (i = 0; i < cfg->num_inputs; i++) { 10631 + if (cfg->inputs[i].type > AUTO_PIN_MIC) 10632 + break; 10633 + nid = cfg->inputs[i].pin; 10634 + if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { 10635 + char label[32]; 10636 + snprintf(label, sizeof(label), "%s Boost", 10637 + hda_get_autocfg_input_label(codec, cfg, i)); 10638 + err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, 10805 10639 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 10806 - if (err < 0) 10807 - return err; 10808 - } 10809 - nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; 10810 - if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { 10811 - err = add_control(spec, ALC_CTL_WIDGET_VOL, 10812 - "Front Mic Boost", 10813 - HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 10814 - if (err < 0) 10815 - return err; 10640 + if (err < 0) 10641 + return err; 10642 + } 10816 10643 } 10817 10644 return 0; 10818 10645 } ··· 10897 10726 10898 10727 codec->spec = spec; 10899 10728 10900 - alc_auto_parse_customize_define(codec); 10901 - 10902 10729 switch (codec->vendor_id) { 10903 10730 case 0x10ec0882: 10904 10731 case 0x10ec0885: ··· 10923 10754 10924 10755 if (board_config == ALC882_AUTO) 10925 10756 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1); 10757 + 10758 + alc_auto_parse_customize_define(codec); 10926 10759 10927 10760 if (board_config == ALC882_AUTO) { 10928 10761 /* automatic parse from the BIOS config */ ··· 11006 10835 codec->patch_ops = alc_patch_ops; 11007 10836 if (board_config == ALC882_AUTO) 11008 10837 spec->init_hook = alc882_auto_init; 10838 + 10839 + alc_init_jacks(codec); 11009 10840 #ifdef CONFIG_SND_HDA_POWER_SAVE 11010 10841 if (!spec->loopback.amplist) 11011 10842 spec->loopback.amplist = alc882_loopbacks; ··· 12004 11831 } 12005 11832 12006 11833 static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, 12007 - const char *pfx, int *vbits) 11834 + const char *pfx, int *vbits, int idx) 12008 11835 { 12009 11836 unsigned long val; 12010 11837 int vbit; ··· 12019 11846 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); 12020 11847 else 12021 11848 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); 12022 - return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val); 11849 + return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val); 12023 11850 } 12024 11851 12025 11852 static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, 12026 - const char *pfx) 11853 + const char *pfx, int idx) 12027 11854 { 12028 11855 unsigned long val; 12029 11856 ··· 12033 11860 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); 12034 11861 else 12035 11862 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 12036 - return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val); 11863 + return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val); 12037 11864 } 12038 11865 12039 11866 /* add playback controls from the parsed DAC table */ ··· 12042 11869 { 12043 11870 const char *pfx; 12044 11871 int vbits; 12045 - int err; 11872 + int i, err; 12046 11873 12047 11874 spec->multiout.num_dacs = 1; /* only use one dac */ 12048 11875 spec->multiout.dac_nids = spec->private_dac_nids; ··· 12052 11879 pfx = "Master"; 12053 11880 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) 12054 11881 pfx = "Speaker"; 11882 + else if (cfg->line_out_type == AUTO_PIN_HP_OUT) 11883 + pfx = "Headphone"; 12055 11884 else 12056 11885 pfx = "Front"; 12057 - err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx); 12058 - if (err < 0) 12059 - return err; 12060 - err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker"); 12061 - if (err < 0) 12062 - return err; 12063 - err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone"); 12064 - if (err < 0) 12065 - return err; 11886 + for (i = 0; i < 2; i++) { 11887 + err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i); 11888 + if (err < 0) 11889 + return err; 11890 + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 11891 + err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i], 11892 + "Speaker", i); 11893 + if (err < 0) 11894 + return err; 11895 + } 11896 + if (cfg->line_out_type != AUTO_PIN_HP_OUT) { 11897 + err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i], 11898 + "Headphone", i); 11899 + if (err < 0) 11900 + return err; 11901 + } 11902 + } 12066 11903 12067 11904 vbits = alc262_check_volbit(cfg->line_out_pins[0]) | 12068 11905 alc262_check_volbit(cfg->speaker_pins[0]) | 12069 11906 alc262_check_volbit(cfg->hp_pins[0]); 12070 11907 if (vbits == 1 || vbits == 2) 12071 11908 pfx = "Master"; /* only one mixer is used */ 12072 - else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) 12073 - pfx = "Speaker"; 12074 - else 12075 - pfx = "Front"; 12076 11909 vbits = 0; 12077 - err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits); 12078 - if (err < 0) 12079 - return err; 12080 - err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker", 12081 - &vbits); 12082 - if (err < 0) 12083 - return err; 12084 - err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone", 12085 - &vbits); 12086 - if (err < 0) 12087 - return err; 11910 + for (i = 0; i < 2; i++) { 11911 + err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx, 11912 + &vbits, i); 11913 + if (err < 0) 11914 + return err; 11915 + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 11916 + err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i], 11917 + "Speaker", &vbits, i); 11918 + if (err < 0) 11919 + return err; 11920 + } 11921 + if (cfg->line_out_type != AUTO_PIN_HP_OUT) { 11922 + err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i], 11923 + "Headphone", &vbits, i); 11924 + if (err < 0) 11925 + return err; 11926 + } 11927 + } 12088 11928 return 0; 12089 11929 } 12090 11930 ··· 12382 12196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */ 12383 12197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 12384 12198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 12199 + {} 12200 + }; 12201 + 12202 + /* 12203 + * Pin config fixes 12204 + */ 12205 + enum { 12206 + PINFIX_FSC_H270, 12207 + }; 12208 + 12209 + static const struct alc_fixup alc262_fixups[] = { 12210 + [PINFIX_FSC_H270] = { 12211 + .pins = (const struct alc_pincfg[]) { 12212 + { 0x14, 0x99130110 }, /* speaker */ 12213 + { 0x15, 0x0221142f }, /* front HP */ 12214 + { 0x1b, 0x0121141f }, /* rear HP */ 12215 + { } 12216 + } 12217 + }, 12218 + [PINFIX_PB_M5210] = { 12219 + .verbs = (const struct hda_verb[]) { 12220 + { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 12221 + {} 12222 + } 12223 + }, 12224 + }; 12225 + 12226 + static struct snd_pci_quirk alc262_fixup_tbl[] = { 12227 + SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), 12385 12228 {} 12386 12229 }; 12387 12230 ··· 12837 12622 board_config = ALC262_AUTO; 12838 12623 } 12839 12624 12625 + if (board_config == ALC262_AUTO) 12626 + alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1); 12627 + 12840 12628 if (board_config == ALC262_AUTO) { 12841 12629 /* automatic parse from the BIOS config */ 12842 12630 err = alc262_parse_auto_config(codec); ··· 12908 12690 if (!spec->no_analog && has_cdefine_beep(codec)) 12909 12691 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 12910 12692 12693 + if (board_config == ALC262_AUTO) 12694 + alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0); 12695 + 12911 12696 spec->vmaster_nid = 0x0c; 12912 12697 12913 12698 codec->patch_ops = alc_patch_ops; 12914 12699 if (board_config == ALC262_AUTO) 12915 12700 spec->init_hook = alc262_auto_init; 12701 + 12702 + alc_init_jacks(codec); 12916 12703 #ifdef CONFIG_SND_HDA_POWER_SAVE 12917 12704 if (!spec->loopback.amplist) 12918 12705 spec->loopback.amplist = alc262_loopbacks; ··· 13533 13310 static void alc268_auto_init_multi_out(struct hda_codec *codec) 13534 13311 { 13535 13312 struct alc_spec *spec = codec->spec; 13536 - hda_nid_t nid = spec->autocfg.line_out_pins[0]; 13537 - if (nid) { 13313 + int i; 13314 + 13315 + for (i = 0; i < spec->autocfg.line_outs; i++) { 13316 + hda_nid_t nid = spec->autocfg.line_out_pins[i]; 13538 13317 int pin_type = get_pin_type(spec->autocfg.line_out_type); 13539 13318 alc268_auto_set_output_and_unmute(codec, nid, pin_type); 13540 13319 } ··· 13546 13321 { 13547 13322 struct alc_spec *spec = codec->spec; 13548 13323 hda_nid_t pin; 13324 + int i; 13549 13325 13550 - pin = spec->autocfg.hp_pins[0]; 13551 - if (pin) 13326 + for (i = 0; i < spec->autocfg.hp_outs; i++) { 13327 + pin = spec->autocfg.hp_pins[i]; 13552 13328 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP); 13553 - pin = spec->autocfg.speaker_pins[0]; 13554 - if (pin) 13329 + } 13330 + for (i = 0; i < spec->autocfg.speaker_outs; i++) { 13331 + pin = spec->autocfg.speaker_pins[i]; 13555 13332 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT); 13333 + } 13334 + if (spec->autocfg.mono_out_pin) 13335 + snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0, 13336 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 13556 13337 } 13557 13338 13558 13339 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) ··· 13997 13766 if (board_config == ALC268_AUTO) 13998 13767 spec->init_hook = alc268_auto_init; 13999 13768 13769 + alc_init_jacks(codec); 13770 + 14000 13771 return 0; 14001 13772 } 14002 13773 ··· 14365 14132 HDA_AMP_MUTE, bits); 14366 14133 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, 14367 14134 HDA_AMP_MUTE, bits); 14135 + alc_report_jack(codec, nid); 14368 14136 } 14369 14137 14370 14138 /* unsolicited event for HP jack sensing */ ··· 14620 14386 return 0; 14621 14387 } 14622 14388 14389 + /* different alc269-variants */ 14390 + enum { 14391 + ALC269_TYPE_NORMAL, 14392 + ALC269_TYPE_ALC259, 14393 + ALC269_TYPE_ALC271X, 14394 + }; 14395 + 14623 14396 /* 14624 14397 * BIOS auto configuration 14625 14398 */ ··· 14644 14403 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 14645 14404 if (err < 0) 14646 14405 return err; 14647 - err = alc269_auto_create_input_ctls(codec, &spec->autocfg); 14406 + if (spec->codec_variant == ALC269_TYPE_NORMAL) 14407 + err = alc269_auto_create_input_ctls(codec, &spec->autocfg); 14408 + else 14409 + err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0, 14410 + 0x22, 0); 14648 14411 if (err < 0) 14649 14412 return err; 14650 14413 ··· 14659 14414 if (spec->kctls.list) 14660 14415 add_mixer(spec, spec->kctls.list); 14661 14416 14662 - if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) { 14417 + if (spec->codec_variant != ALC269_TYPE_NORMAL) { 14663 14418 add_verb(spec, alc269vb_init_verbs); 14664 14419 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21); 14665 14420 } else { ··· 14706 14461 alc_inithook(codec); 14707 14462 } 14708 14463 14464 + #ifdef SND_HDA_NEEDS_RESUME 14465 + static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) 14466 + { 14467 + int val = alc_read_coef_idx(codec, 0x04); 14468 + if (power_up) 14469 + val |= 1 << 11; 14470 + else 14471 + val &= ~(1 << 11); 14472 + alc_write_coef_idx(codec, 0x04, val); 14473 + } 14474 + 14475 + #ifdef CONFIG_SND_HDA_POWER_SAVE 14476 + static int alc269_suspend(struct hda_codec *codec, pm_message_t state) 14477 + { 14478 + struct alc_spec *spec = codec->spec; 14479 + 14480 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) 14481 + alc269_toggle_power_output(codec, 0); 14482 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 14483 + alc269_toggle_power_output(codec, 0); 14484 + msleep(150); 14485 + } 14486 + 14487 + alc_shutup(codec); 14488 + if (spec && spec->power_hook) 14489 + spec->power_hook(codec); 14490 + return 0; 14491 + } 14492 + #endif /* CONFIG_SND_HDA_POWER_SAVE */ 14493 + 14494 + static int alc269_resume(struct hda_codec *codec) 14495 + { 14496 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 14497 + alc269_toggle_power_output(codec, 0); 14498 + msleep(150); 14499 + } 14500 + 14501 + codec->patch_ops.init(codec); 14502 + 14503 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { 14504 + alc269_toggle_power_output(codec, 1); 14505 + msleep(200); 14506 + } 14507 + 14508 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) 14509 + alc269_toggle_power_output(codec, 1); 14510 + 14511 + snd_hda_codec_resume_amp(codec); 14512 + snd_hda_codec_resume_cache(codec); 14513 + hda_call_check_power_status(codec, 0x01); 14514 + return 0; 14515 + } 14516 + #endif /* SND_HDA_NEEDS_RESUME */ 14517 + 14709 14518 enum { 14710 14519 ALC269_FIXUP_SONY_VAIO, 14711 14520 ALC269_FIXUP_DELL_M101Z, 14712 14521 }; 14713 14522 14714 - static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = { 14715 - {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, 14716 - {} 14717 - }; 14718 - 14719 14523 static const struct alc_fixup alc269_fixups[] = { 14720 14524 [ALC269_FIXUP_SONY_VAIO] = { 14721 - .verbs = alc269_sony_vaio_fixup_verbs 14525 + .verbs = (const struct hda_verb[]) { 14526 + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, 14527 + {} 14528 + } 14722 14529 }, 14723 14530 [ALC269_FIXUP_DELL_M101Z] = { 14724 14531 .verbs = (const struct hda_verb[]) { ··· 14783 14486 }; 14784 14487 14785 14488 static struct snd_pci_quirk alc269_fixup_tbl[] = { 14786 - SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 14787 - SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 14489 + SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 14788 14490 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 14789 14491 {} 14790 14492 }; ··· 14985 14689 }, 14986 14690 }; 14987 14691 14692 + static int alc269_fill_coef(struct hda_codec *codec) 14693 + { 14694 + int val; 14695 + 14696 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) { 14697 + alc_write_coef_idx(codec, 0xf, 0x960b); 14698 + alc_write_coef_idx(codec, 0xe, 0x8817); 14699 + } 14700 + 14701 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) { 14702 + alc_write_coef_idx(codec, 0xf, 0x960b); 14703 + alc_write_coef_idx(codec, 0xe, 0x8814); 14704 + } 14705 + 14706 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { 14707 + val = alc_read_coef_idx(codec, 0x04); 14708 + /* Power up output pin */ 14709 + alc_write_coef_idx(codec, 0x04, val | (1<<11)); 14710 + } 14711 + 14712 + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { 14713 + val = alc_read_coef_idx(codec, 0xd); 14714 + if ((val & 0x0c00) >> 10 != 0x1) { 14715 + /* Capless ramp up clock control */ 14716 + alc_write_coef_idx(codec, 0xd, val | 1<<10); 14717 + } 14718 + val = alc_read_coef_idx(codec, 0x17); 14719 + if ((val & 0x01c0) >> 6 != 0x4) { 14720 + /* Class D power on reset */ 14721 + alc_write_coef_idx(codec, 0x17, val | 1<<7); 14722 + } 14723 + } 14724 + return 0; 14725 + } 14726 + 14988 14727 static int patch_alc269(struct hda_codec *codec) 14989 14728 { 14990 14729 struct alc_spec *spec; 14991 14730 int board_config; 14992 14731 int err; 14993 - int is_alc269vb = 0; 14994 14732 14995 14733 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 14996 14734 if (spec == NULL) ··· 15036 14706 15037 14707 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ 15038 14708 if (codec->bus->pci->subsystem_vendor == 0x1025 && 15039 - spec->cdefine.platform_type == 1) 14709 + spec->cdefine.platform_type == 1) { 15040 14710 alc_codec_rename(codec, "ALC271X"); 15041 - else 14711 + spec->codec_variant = ALC269_TYPE_ALC271X; 14712 + } else { 15042 14713 alc_codec_rename(codec, "ALC259"); 15043 - is_alc269vb = 1; 14714 + spec->codec_variant = ALC269_TYPE_ALC259; 14715 + } 15044 14716 } else 15045 14717 alc_fix_pll_init(codec, 0x20, 0x04, 15); 14718 + 14719 + alc269_fill_coef(codec); 15046 14720 15047 14721 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, 15048 14722 alc269_models, ··· 15104 14770 spec->stream_digital_capture = &alc269_pcm_digital_capture; 15105 14771 15106 14772 if (!spec->adc_nids) { /* wasn't filled automatically? use default */ 15107 - if (!is_alc269vb) { 14773 + if (spec->codec_variant != ALC269_TYPE_NORMAL) { 15108 14774 spec->adc_nids = alc269_adc_nids; 15109 14775 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 15110 14776 spec->capsrc_nids = alc269_capsrc_nids; ··· 15126 14792 spec->vmaster_nid = 0x02; 15127 14793 15128 14794 codec->patch_ops = alc_patch_ops; 14795 + #ifdef CONFIG_SND_HDA_POWER_SAVE 14796 + codec->patch_ops.suspend = alc269_suspend; 14797 + #endif 14798 + #ifdef SND_HDA_NEEDS_RESUME 14799 + codec->patch_ops.resume = alc269_resume; 14800 + #endif 15129 14801 if (board_config == ALC269_AUTO) 15130 14802 spec->init_hook = alc269_auto_init; 14803 + 14804 + alc_init_jacks(codec); 15131 14805 #ifdef CONFIG_SND_HDA_POWER_SAVE 15132 14806 if (!spec->loopback.amplist) 15133 14807 spec->loopback.amplist = alc269_loopbacks; ··· 15948 15606 static void alc861_auto_init_analog_input(struct hda_codec *codec) 15949 15607 { 15950 15608 struct alc_spec *spec = codec->spec; 15609 + struct auto_pin_cfg *cfg = &spec->autocfg; 15951 15610 int i; 15952 15611 15953 - for (i = 0; i < AUTO_PIN_LAST; i++) { 15954 - hda_nid_t nid = spec->autocfg.input_pins[i]; 15612 + for (i = 0; i < cfg->num_inputs; i++) { 15613 + hda_nid_t nid = cfg->inputs[i].pin; 15955 15614 if (nid >= 0x0c && nid <= 0x11) 15956 - alc_set_input_pin(codec, nid, i); 15615 + alc_set_input_pin(codec, nid, cfg->inputs[i].type); 15957 15616 } 15958 15617 } 15959 15618 ··· 16183 15840 PINFIX_FSC_AMILO_PI1505, 16184 15841 }; 16185 15842 16186 - static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = { 16187 - { 0x0b, 0x0221101f }, /* HP */ 16188 - { 0x0f, 0x90170310 }, /* speaker */ 16189 - { } 16190 - }; 16191 - 16192 15843 static const struct alc_fixup alc861_fixups[] = { 16193 15844 [PINFIX_FSC_AMILO_PI1505] = { 16194 - .pins = alc861_fsc_amilo_pi1505_pinfix 15845 + .pins = (const struct alc_pincfg[]) { 15846 + { 0x0b, 0x0221101f }, /* HP */ 15847 + { 0x0f, 0x90170310 }, /* speaker */ 15848 + { } 15849 + } 16195 15850 }, 16196 15851 }; 16197 15852 ··· 16941 16600 static void alc861vd_auto_init_analog_input(struct hda_codec *codec) 16942 16601 { 16943 16602 struct alc_spec *spec = codec->spec; 16603 + struct auto_pin_cfg *cfg = &spec->autocfg; 16944 16604 int i; 16945 16605 16946 - for (i = 0; i < AUTO_PIN_LAST; i++) { 16947 - hda_nid_t nid = spec->autocfg.input_pins[i]; 16606 + for (i = 0; i < cfg->num_inputs; i++) { 16607 + hda_nid_t nid = cfg->inputs[i].pin; 16948 16608 if (alc_is_input_pin(codec, nid)) { 16949 - alc_set_input_pin(codec, nid, i); 16609 + alc_set_input_pin(codec, nid, cfg->inputs[i].type); 16950 16610 if (nid != ALC861VD_PIN_CD_NID && 16951 16611 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 16952 16612 snd_hda_codec_write(codec, nid, 0, ··· 17157 16815 }; 17158 16816 17159 16817 /* reset GPIO1 */ 17160 - static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = { 17161 - {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 17162 - {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 17163 - {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 17164 - { } 17165 - }; 17166 - 17167 16818 static const struct alc_fixup alc861vd_fixups[] = { 17168 16819 [ALC660VD_FIX_ASUS_GPIO1] = { 17169 - .verbs = alc660vd_fix_asus_gpio1_verbs, 16820 + .verbs = (const struct hda_verb[]) { 16821 + {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 16822 + {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 16823 + {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 16824 + { } 16825 + } 17170 16826 }, 17171 16827 }; 17172 16828 ··· 19178 18838 static void alc662_auto_init_analog_input(struct hda_codec *codec) 19179 18839 { 19180 18840 struct alc_spec *spec = codec->spec; 18841 + struct auto_pin_cfg *cfg = &spec->autocfg; 19181 18842 int i; 19182 18843 19183 - for (i = 0; i < AUTO_PIN_LAST; i++) { 19184 - hda_nid_t nid = spec->autocfg.input_pins[i]; 18844 + for (i = 0; i < cfg->num_inputs; i++) { 18845 + hda_nid_t nid = cfg->inputs[i].pin; 19185 18846 if (alc_is_input_pin(codec, nid)) { 19186 - alc_set_input_pin(codec, nid, i); 18847 + alc_set_input_pin(codec, nid, cfg->inputs[i].type); 19187 18848 if (nid != ALC662_PIN_CD_NID && 19188 18849 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) 19189 18850 snd_hda_codec_write(codec, nid, 0, ··· 19276 18935 alc_inithook(codec); 19277 18936 } 19278 18937 18938 + enum { 18939 + ALC662_FIXUP_ASPIRE, 18940 + ALC662_FIXUP_IDEAPAD, 18941 + }; 18942 + 18943 + static const struct alc_fixup alc662_fixups[] = { 18944 + [ALC662_FIXUP_ASPIRE] = { 18945 + .pins = (const struct alc_pincfg[]) { 18946 + { 0x15, 0x99130112 }, /* subwoofer */ 18947 + { } 18948 + } 18949 + }, 18950 + [ALC662_FIXUP_IDEAPAD] = { 18951 + .pins = (const struct alc_pincfg[]) { 18952 + { 0x17, 0x99130112 }, /* subwoofer */ 18953 + { } 18954 + } 18955 + }, 18956 + }; 18957 + 18958 + static struct snd_pci_quirk alc662_fixup_tbl[] = { 18959 + SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 18960 + SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 18961 + SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 18962 + {} 18963 + }; 18964 + 18965 + 18966 + 19279 18967 static int patch_alc662(struct hda_codec *codec) 19280 18968 { 19281 18969 struct alc_spec *spec; 19282 18970 int err, board_config; 18971 + int coef; 19283 18972 19284 18973 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 19285 18974 if (!spec) ··· 19321 18950 19322 18951 alc_fix_pll_init(codec, 0x20, 0x04, 15); 19323 18952 19324 - if (alc_read_coef_idx(codec, 0) == 0x8020) 18953 + coef = alc_read_coef_idx(codec, 0); 18954 + if (coef == 0x8020 || coef == 0x8011) 19325 18955 alc_codec_rename(codec, "ALC661"); 19326 - else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) && 19327 - codec->bus->pci->subsystem_vendor == 0x1025 && 19328 - spec->cdefine.platform_type == 1) 18956 + else if (coef & (1 << 14) && 18957 + codec->bus->pci->subsystem_vendor == 0x1025 && 18958 + spec->cdefine.platform_type == 1) 19329 18959 alc_codec_rename(codec, "ALC272X"); 18960 + else if (coef == 0x4011) 18961 + alc_codec_rename(codec, "ALC656"); 19330 18962 19331 18963 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, 19332 18964 alc662_models, ··· 19341 18967 } 19342 18968 19343 18969 if (board_config == ALC662_AUTO) { 18970 + alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1); 19344 18971 /* automatic parse from the BIOS config */ 19345 18972 err = alc662_parse_auto_config(codec); 19346 18973 if (err < 0) { ··· 19400 19025 spec->vmaster_nid = 0x02; 19401 19026 19402 19027 codec->patch_ops = alc_patch_ops; 19403 - if (board_config == ALC662_AUTO) 19028 + if (board_config == ALC662_AUTO) { 19404 19029 spec->init_hook = alc662_auto_init; 19030 + alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0); 19031 + } 19032 + 19033 + alc_init_jacks(codec); 19034 + 19405 19035 #ifdef CONFIG_SND_HDA_POWER_SAVE 19406 19036 if (!spec->loopback.amplist) 19407 19037 spec->loopback.amplist = alc662_loopbacks; ··· 19450 19070 /* 19451 19071 * Analog capture ADC cgange 19452 19072 */ 19073 + static void alc680_rec_autoswitch(struct hda_codec *codec) 19074 + { 19075 + struct alc_spec *spec = codec->spec; 19076 + struct auto_pin_cfg *cfg = &spec->autocfg; 19077 + int pin_found = 0; 19078 + int type_found = AUTO_PIN_LAST; 19079 + hda_nid_t nid; 19080 + int i; 19081 + 19082 + for (i = 0; i < cfg->num_inputs; i++) { 19083 + nid = cfg->inputs[i].pin; 19084 + if (!(snd_hda_query_pin_caps(codec, nid) & 19085 + AC_PINCAP_PRES_DETECT)) 19086 + continue; 19087 + if (snd_hda_jack_detect(codec, nid)) { 19088 + if (cfg->inputs[i].type < type_found) { 19089 + type_found = cfg->inputs[i].type; 19090 + pin_found = nid; 19091 + } 19092 + } 19093 + } 19094 + 19095 + nid = 0x07; 19096 + if (pin_found) 19097 + snd_hda_get_connections(codec, pin_found, &nid, 1); 19098 + 19099 + if (nid != spec->cur_adc) 19100 + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 19101 + spec->cur_adc = nid; 19102 + snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0, 19103 + spec->cur_adc_format); 19104 + } 19105 + 19453 19106 static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 19454 19107 struct hda_codec *codec, 19455 19108 unsigned int stream_tag, ··· 19490 19077 struct snd_pcm_substream *substream) 19491 19078 { 19492 19079 struct alc_spec *spec = codec->spec; 19493 - struct auto_pin_cfg *cfg = &spec->autocfg; 19494 - unsigned int pre_mic, pre_line; 19495 19080 19496 - pre_mic = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]); 19497 - pre_line = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_LINE]); 19498 - 19081 + spec->cur_adc = 0x07; 19499 19082 spec->cur_adc_stream_tag = stream_tag; 19500 19083 spec->cur_adc_format = format; 19501 19084 19502 - if (pre_mic || pre_line) { 19503 - if (pre_mic) 19504 - snd_hda_codec_setup_stream(codec, 0x08, stream_tag, 0, 19505 - format); 19506 - else 19507 - snd_hda_codec_setup_stream(codec, 0x09, stream_tag, 0, 19508 - format); 19509 - } else 19510 - snd_hda_codec_setup_stream(codec, 0x07, stream_tag, 0, format); 19085 + alc680_rec_autoswitch(codec); 19511 19086 return 0; 19512 19087 } 19513 19088 ··· 19581 19180 19582 19181 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 19583 19182 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 19183 + {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, 19584 19184 19585 19185 { } 19586 19186 }; ··· 19594 19192 spec->autocfg.hp_pins[0] = 0x16; 19595 19193 spec->autocfg.speaker_pins[0] = 0x14; 19596 19194 spec->autocfg.speaker_pins[1] = 0x15; 19597 - spec->autocfg.input_pins[AUTO_PIN_MIC] = 0x18; 19598 - spec->autocfg.input_pins[AUTO_PIN_LINE] = 0x19; 19599 - } 19600 - 19601 - static void alc680_rec_autoswitch(struct hda_codec *codec) 19602 - { 19603 - struct alc_spec *spec = codec->spec; 19604 - struct auto_pin_cfg *cfg = &spec->autocfg; 19605 - unsigned int present; 19606 - hda_nid_t new_adc; 19607 - 19608 - present = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]); 19609 - 19610 - new_adc = present ? 0x8 : 0x7; 19611 - __snd_hda_codec_cleanup_stream(codec, !present ? 0x8 : 0x7, 1); 19612 - snd_hda_codec_setup_stream(codec, new_adc, 19613 - spec->cur_adc_stream_tag, 0, 19614 - spec->cur_adc_format); 19615 - 19195 + spec->autocfg.num_inputs = 2; 19196 + spec->autocfg.inputs[0].pin = 0x18; 19197 + spec->autocfg.inputs[0].type = AUTO_PIN_MIC; 19198 + spec->autocfg.inputs[1].pin = 0x19; 19199 + spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN; 19616 19200 } 19617 19201 19618 19202 static void alc680_unsol_event(struct hda_codec *codec,
+203 -198
sound/pci/hda/patch_sigmatel.c
··· 32 32 #include <sound/core.h> 33 33 #include <sound/asoundef.h> 34 34 #include <sound/jack.h> 35 + #include <sound/tlv.h> 35 36 #include "hda_codec.h" 36 37 #include "hda_local.h" 37 38 #include "hda_beep.h" ··· 264 263 265 264 struct sigmatel_mic_route ext_mic; 266 265 struct sigmatel_mic_route int_mic; 266 + struct sigmatel_mic_route dock_mic; 267 267 268 268 const char **spdif_labels; 269 269 ··· 382 380 383 381 static unsigned int stac92hd83xxx_pwr_mapping[4] = { 384 382 0x03, 0x0c, 0x20, 0x40, 383 + }; 384 + 385 + #define STAC92HD83XXX_NUM_DMICS 2 386 + static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { 387 + 0x11, 0x20, 0 385 388 }; 386 389 387 390 #define STAC92HD83XXX_NUM_CAPS 2 ··· 993 986 } 994 987 995 988 static struct snd_kcontrol_new stac9200_mixer[] = { 996 - HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 989 + HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 997 990 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), 998 991 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), 999 992 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), ··· 1021 1014 }; 1022 1015 1023 1016 static struct snd_kcontrol_new stac925x_mixer[] = { 1024 - HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), 1017 + HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT), 1025 1018 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), 1026 1019 { } /* end */ 1027 1020 }; ··· 1112 1105 struct hda_input_mux *smux = &spec->private_smux; 1113 1106 /* check for mute support on SPDIF out */ 1114 1107 if (wcaps & AC_WCAP_OUT_AMP) { 1115 - smux->items[smux->num_items].label = "Off"; 1116 - smux->items[smux->num_items].index = 0; 1117 - smux->num_items++; 1108 + snd_hda_add_imux_item(smux, "Off", 0, NULL); 1118 1109 spec->spdif_mute = 1; 1119 1110 } 1120 1111 stac_smux_mixer.count = spec->num_smuxes; ··· 1145 1140 HDA_OUTPUT, vmaster_tlv); 1146 1141 /* correct volume offset */ 1147 1142 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; 1143 + /* minimum value is actually mute */ 1144 + vmaster_tlv[3] |= TLV_DB_SCALE_MUTE; 1148 1145 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1149 1146 vmaster_tlv, slave_vols); 1150 1147 if (err < 0) ··· 1187 1180 if (err < 0) 1188 1181 return err; 1189 1182 } 1190 - for (i = 0; i < AUTO_PIN_LAST; i++) { 1191 - nid = cfg->input_pins[i]; 1192 - if (nid) { 1193 - err = stac92xx_add_jack(codec, nid, 1194 - SND_JACK_MICROPHONE); 1195 - if (err < 0) 1196 - return err; 1197 - } 1183 + for (i = 0; i < cfg->num_inputs; i++) { 1184 + nid = cfg->inputs[i].pin; 1185 + err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE); 1186 + if (err < 0) 1187 + return err; 1198 1188 } 1199 1189 1200 1190 return 0; ··· 2783 2779 struct sigmatel_spec *spec = codec->spec; 2784 2780 char name[22]; 2785 2781 2786 - if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { 2782 + if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { 2787 2783 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD 2788 2784 && nid == spec->line_switch) 2789 2785 control = STAC_CTL_WIDGET_IO_SWITCH; ··· 2795 2791 } 2796 2792 2797 2793 if (control) { 2798 - strcpy(name, auto_pin_cfg_labels[idx]); 2794 + strcpy(name, hda_get_input_pin_label(codec, nid, 1)); 2799 2795 return stac92xx_add_control(codec->spec, control, 2800 2796 strcat(name, " Jack Mode"), nid); 2801 2797 } ··· 2827 2823 struct auto_pin_cfg *cfg = &spec->autocfg; 2828 2824 hda_nid_t nid; 2829 2825 unsigned int pincap; 2826 + int i; 2830 2827 2831 2828 if (cfg->line_out_type != AUTO_PIN_LINE_OUT) 2832 2829 return 0; 2833 - nid = cfg->input_pins[AUTO_PIN_LINE]; 2834 - pincap = snd_hda_query_pin_caps(codec, nid); 2835 - if (pincap & AC_PINCAP_OUT) 2836 - return nid; 2837 - return 0; 2838 - } 2839 - 2840 - /* check whether the mic-input can be used as line-out */ 2841 - static hda_nid_t check_mic_out_switch(struct hda_codec *codec) 2842 - { 2843 - struct sigmatel_spec *spec = codec->spec; 2844 - struct auto_pin_cfg *cfg = &spec->autocfg; 2845 - unsigned int def_conf, pincap; 2846 - unsigned int mic_pin; 2847 - 2848 - if (cfg->line_out_type != AUTO_PIN_LINE_OUT) 2849 - return 0; 2850 - mic_pin = AUTO_PIN_MIC; 2851 - for (;;) { 2852 - hda_nid_t nid = cfg->input_pins[mic_pin]; 2853 - def_conf = snd_hda_codec_get_pincfg(codec, nid); 2854 - /* some laptops have an internal analog microphone 2855 - * which can't be used as a output */ 2856 - if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { 2830 + for (i = 0; i < cfg->num_inputs; i++) { 2831 + if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) { 2832 + nid = cfg->inputs[i].pin; 2857 2833 pincap = snd_hda_query_pin_caps(codec, nid); 2858 2834 if (pincap & AC_PINCAP_OUT) 2859 2835 return nid; 2860 2836 } 2861 - if (mic_pin == AUTO_PIN_MIC) 2862 - mic_pin = AUTO_PIN_FRONT_MIC; 2863 - else 2864 - break; 2837 + } 2838 + return 0; 2839 + } 2840 + 2841 + static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid); 2842 + 2843 + /* check whether the mic-input can be used as line-out */ 2844 + static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) 2845 + { 2846 + struct sigmatel_spec *spec = codec->spec; 2847 + struct auto_pin_cfg *cfg = &spec->autocfg; 2848 + unsigned int def_conf, pincap; 2849 + int i; 2850 + 2851 + *dac = 0; 2852 + if (cfg->line_out_type != AUTO_PIN_LINE_OUT) 2853 + return 0; 2854 + for (i = 0; i < cfg->num_inputs; i++) { 2855 + hda_nid_t nid = cfg->inputs[i].pin; 2856 + if (cfg->inputs[i].type != AUTO_PIN_MIC) 2857 + continue; 2858 + def_conf = snd_hda_codec_get_pincfg(codec, nid); 2859 + /* some laptops have an internal analog microphone 2860 + * which can't be used as a output */ 2861 + if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { 2862 + pincap = snd_hda_query_pin_caps(codec, nid); 2863 + if (pincap & AC_PINCAP_OUT) { 2864 + *dac = get_unassigned_dac(codec, nid); 2865 + if (*dac) 2866 + return nid; 2867 + } 2868 + } 2865 2869 } 2866 2870 return 0; 2867 2871 } ··· 3016 3004 } 3017 3005 } 3018 3006 /* add mic as output */ 3019 - nid = check_mic_out_switch(codec); 3020 - if (nid) { 3021 - dac = get_unassigned_dac(codec, nid); 3022 - if (dac) { 3023 - snd_printdd("STAC: Add mic-in 0x%x as output %d\n", 3024 - nid, cfg->line_outs); 3025 - cfg->line_out_pins[cfg->line_outs] = nid; 3026 - cfg->line_outs++; 3027 - spec->mic_switch = nid; 3028 - add_spec_dacs(spec, dac); 3029 - } 3007 + nid = check_mic_out_switch(codec, &dac); 3008 + if (nid && dac) { 3009 + snd_printdd("STAC: Add mic-in 0x%x as output %d\n", 3010 + nid, cfg->line_outs); 3011 + cfg->line_out_pins[cfg->line_outs] = nid; 3012 + cfg->line_outs++; 3013 + spec->mic_switch = nid; 3014 + add_spec_dacs(spec, dac); 3030 3015 } 3031 3016 3032 3017 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", ··· 3213 3204 return err; 3214 3205 } 3215 3206 3216 - for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { 3217 - nid = cfg->input_pins[idx]; 3218 - if (nid) { 3219 - err = stac92xx_add_jack_mode_control(codec, nid, idx); 3220 - if (err < 0) 3221 - return err; 3222 - } 3207 + for (idx = 0; idx < cfg->num_inputs; idx++) { 3208 + if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) 3209 + break; 3210 + nid = cfg->inputs[idx].pin; 3211 + err = stac92xx_add_jack_mode_control(codec, nid, idx); 3212 + if (err < 0) 3213 + return err; 3223 3214 } 3224 3215 3225 3216 return 0; ··· 3265 3256 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) 3266 3257 return -EINVAL; 3267 3258 3268 - for (i = 0; i < num_cons; i++) { 3269 - mono_mux->items[mono_mux->num_items].label = 3270 - stac92xx_mono_labels[i]; 3271 - mono_mux->items[mono_mux->num_items].index = i; 3272 - mono_mux->num_items++; 3273 - } 3259 + for (i = 0; i < num_cons; i++) 3260 + snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i, 3261 + NULL); 3274 3262 3275 3263 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, 3276 3264 "Mono Mux", spec->mono_nid); ··· 3392 3386 if (!labels) 3393 3387 labels = stac92xx_spdif_labels; 3394 3388 3395 - for (i = 0; i < num_cons; i++) { 3396 - spdif_mux->items[spdif_mux->num_items].label = labels[i]; 3397 - spdif_mux->items[spdif_mux->num_items].index = i; 3398 - spdif_mux->num_items++; 3399 - } 3389 + for (i = 0; i < num_cons; i++) 3390 + snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL); 3400 3391 3401 3392 return 0; 3402 3393 } ··· 3420 3417 /* create a volume assigned to the given pin (only if supported) */ 3421 3418 /* return 1 if the volume control is created */ 3422 3419 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, 3423 - const char *label, int direction) 3420 + const char *label, int idx, int direction) 3424 3421 { 3425 3422 unsigned int caps, nums; 3426 3423 char name[32]; ··· 3437 3434 if (!nums) 3438 3435 return 0; 3439 3436 snprintf(name, sizeof(name), "%s Capture Volume", label); 3440 - err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, 3441 - HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); 3437 + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name, 3438 + HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); 3442 3439 if (err < 0) 3443 3440 return err; 3444 3441 return 1; ··· 3451 3448 struct sigmatel_spec *spec = codec->spec; 3452 3449 struct hda_input_mux *imux = &spec->private_imux; 3453 3450 struct hda_input_mux *dimux = &spec->private_dimux; 3454 - int err, i, active_mics; 3451 + int err, i; 3455 3452 unsigned int def_conf; 3456 3453 3457 - dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; 3458 - dimux->items[dimux->num_items].index = 0; 3459 - dimux->num_items++; 3460 - 3461 - active_mics = 0; 3462 - for (i = 0; i < spec->num_dmics; i++) { 3463 - /* check the validity: sometimes it's a dead vendor-spec node */ 3464 - if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i])) 3465 - != AC_WID_PIN) 3466 - continue; 3467 - def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); 3468 - if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) 3469 - active_mics++; 3470 - } 3454 + snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL); 3471 3455 3472 3456 for (i = 0; i < spec->num_dmics; i++) { 3473 3457 hda_nid_t nid; 3474 - int index; 3458 + int index, type_idx; 3475 3459 const char *label; 3476 3460 3477 3461 nid = spec->dmic_nids[i]; ··· 3472 3482 if (index < 0) 3473 3483 continue; 3474 3484 3475 - if (active_mics == 1) 3476 - label = "Digital Mic"; 3477 - else 3478 - label = stac92xx_dmic_labels[dimux->num_items]; 3485 + label = hda_get_input_pin_label(codec, nid, 1); 3486 + snd_hda_add_imux_item(dimux, label, index, &type_idx); 3479 3487 3480 - err = create_elem_capture_vol(codec, nid, label, HDA_INPUT); 3488 + err = create_elem_capture_vol(codec, nid, label, type_idx, 3489 + HDA_INPUT); 3481 3490 if (err < 0) 3482 3491 return err; 3483 3492 if (!err) { 3484 3493 err = create_elem_capture_vol(codec, nid, label, 3485 - HDA_OUTPUT); 3494 + type_idx, HDA_OUTPUT); 3486 3495 if (err < 0) 3487 3496 return err; 3488 3497 } 3489 3498 3490 - dimux->items[dimux->num_items].label = label; 3491 - dimux->items[dimux->num_items].index = index; 3492 - dimux->num_items++; 3493 3499 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { 3494 - imux->items[imux->num_items].label = label; 3495 - imux->items[imux->num_items].index = index; 3496 - imux->num_items++; 3500 + snd_hda_add_imux_item(imux, label, index, NULL); 3501 + spec->num_analog_muxes++; 3497 3502 } 3498 3503 } 3499 3504 ··· 3496 3511 } 3497 3512 3498 3513 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, 3499 - hda_nid_t *fixed, hda_nid_t *ext) 3514 + hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock) 3500 3515 { 3501 3516 unsigned int cfg; 3502 3517 3503 3518 if (!nid) 3504 3519 return 0; 3505 3520 cfg = snd_hda_codec_get_pincfg(codec, nid); 3506 - switch (get_defcfg_connect(cfg)) { 3507 - case AC_JACK_PORT_FIXED: 3521 + switch (snd_hda_get_input_pin_attr(cfg)) { 3522 + case INPUT_PIN_ATTR_INT: 3508 3523 if (*fixed) 3509 3524 return 1; /* already occupied */ 3510 3525 *fixed = nid; 3511 3526 break; 3512 - case AC_JACK_PORT_COMPLEX: 3527 + case INPUT_PIN_ATTR_UNUSED: 3528 + break; 3529 + case INPUT_PIN_ATTR_DOCK: 3530 + if (*dock) 3531 + return 1; /* already occupied */ 3532 + *dock = nid; 3533 + break; 3534 + default: 3513 3535 if (*ext) 3514 3536 return 1; /* already occupied */ 3515 3537 *ext = nid; ··· 3534 3542 int i; 3535 3543 3536 3544 mic->pin = pin; 3537 - for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) 3538 - if (pin == cfg->input_pins[i]) 3545 + if (pin == 0) 3546 + return 0; 3547 + for (i = 0; i < cfg->num_inputs; i++) { 3548 + if (pin == cfg->inputs[i].pin) 3539 3549 break; 3540 - if (i <= AUTO_PIN_FRONT_MIC) { 3550 + } 3551 + if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) { 3541 3552 /* analog pin */ 3542 3553 i = get_connection_index(codec, spec->mux_nids[0], pin); 3543 3554 if (i < 0) ··· 3571 3576 { 3572 3577 struct sigmatel_spec *spec = codec->spec; 3573 3578 struct auto_pin_cfg *cfg = &spec->autocfg; 3574 - hda_nid_t fixed, ext; 3579 + hda_nid_t fixed, ext, dock; 3575 3580 int i; 3576 3581 3577 - for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { 3578 - if (cfg->input_pins[i]) 3582 + for (i = 0; i < cfg->num_inputs; i++) { 3583 + if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) 3579 3584 return 0; /* must be exclusively mics */ 3580 3585 } 3581 - fixed = ext = 0; 3582 - for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) 3583 - if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) 3586 + fixed = ext = dock = 0; 3587 + for (i = 0; i < cfg->num_inputs; i++) 3588 + if (check_mic_pin(codec, cfg->inputs[i].pin, 3589 + &fixed, &ext, &dock)) 3584 3590 return 0; 3585 3591 for (i = 0; i < spec->num_dmics; i++) 3586 - if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) 3592 + if (check_mic_pin(codec, spec->dmic_nids[i], 3593 + &fixed, &ext, &dock)) 3587 3594 return 0; 3588 - if (!fixed || !ext) 3589 - return 0; 3595 + if (!fixed && !ext && !dock) 3596 + return 0; /* no input to switch */ 3590 3597 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) 3591 3598 return 0; /* no unsol support */ 3592 3599 if (set_mic_route(codec, &spec->ext_mic, ext) || 3593 - set_mic_route(codec, &spec->int_mic, fixed)) 3600 + set_mic_route(codec, &spec->int_mic, fixed) || 3601 + set_mic_route(codec, &spec->dock_mic, dock)) 3594 3602 return 0; /* something is wrong */ 3595 3603 return 1; 3596 3604 } ··· 3604 3606 struct sigmatel_spec *spec = codec->spec; 3605 3607 struct hda_input_mux *imux = &spec->private_imux; 3606 3608 int i, j; 3609 + const char *label; 3607 3610 3608 - for (i = 0; i < AUTO_PIN_LAST; i++) { 3609 - hda_nid_t nid = cfg->input_pins[i]; 3610 - int index, err; 3611 + for (i = 0; i < cfg->num_inputs; i++) { 3612 + hda_nid_t nid = cfg->inputs[i].pin; 3613 + int index, err, type_idx; 3611 3614 3612 - if (!nid) 3613 - continue; 3614 3615 index = -1; 3615 3616 for (j = 0; j < spec->num_muxes; j++) { 3616 3617 index = get_connection_index(codec, spec->mux_nids[j], ··· 3620 3623 if (index < 0) 3621 3624 continue; 3622 3625 3626 + label = hda_get_autocfg_input_label(codec, cfg, i); 3627 + snd_hda_add_imux_item(imux, label, index, &type_idx); 3628 + 3623 3629 err = create_elem_capture_vol(codec, nid, 3624 - auto_pin_cfg_labels[i], 3630 + label, type_idx, 3625 3631 HDA_INPUT); 3626 3632 if (err < 0) 3627 3633 return err; 3628 - 3629 - imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3630 - imux->items[imux->num_items].index = index; 3631 - imux->num_items++; 3632 3634 } 3633 3635 spec->num_analog_muxes = imux->num_items; 3634 3636 ··· 4301 4305 AC_VERB_SET_CONNECT_SEL, 0); 4302 4306 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) 4303 4307 stac_issue_unsol_event(codec, spec->ext_mic.pin); 4308 + if (enable_pin_detect(codec, spec->dock_mic.pin, 4309 + STAC_MIC_EVENT)) 4310 + stac_issue_unsol_event(codec, spec->dock_mic.pin); 4304 4311 } 4305 - for (i = 0; i < AUTO_PIN_LAST; i++) { 4306 - hda_nid_t nid = cfg->input_pins[i]; 4307 - if (nid) { 4308 - unsigned int pinctl, conf; 4309 - if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { 4310 - /* for mic pins, force to initialize */ 4311 - pinctl = stac92xx_get_default_vref(codec, nid); 4312 + for (i = 0; i < cfg->num_inputs; i++) { 4313 + hda_nid_t nid = cfg->inputs[i].pin; 4314 + int type = cfg->inputs[i].type; 4315 + unsigned int pinctl, conf; 4316 + if (type == AUTO_PIN_MIC) { 4317 + /* for mic pins, force to initialize */ 4318 + pinctl = stac92xx_get_default_vref(codec, nid); 4319 + pinctl |= AC_PINCTL_IN_EN; 4320 + stac92xx_auto_set_pinctl(codec, nid, pinctl); 4321 + } else { 4322 + pinctl = snd_hda_codec_read(codec, nid, 0, 4323 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 4324 + /* if PINCTL already set then skip */ 4325 + /* Also, if both INPUT and OUTPUT are set, 4326 + * it must be a BIOS bug; need to override, too 4327 + */ 4328 + if (!(pinctl & AC_PINCTL_IN_EN) || 4329 + (pinctl & AC_PINCTL_OUT_EN)) { 4330 + pinctl &= ~AC_PINCTL_OUT_EN; 4312 4331 pinctl |= AC_PINCTL_IN_EN; 4313 4332 stac92xx_auto_set_pinctl(codec, nid, pinctl); 4314 - } else { 4315 - pinctl = snd_hda_codec_read(codec, nid, 0, 4316 - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 4317 - /* if PINCTL already set then skip */ 4318 - /* Also, if both INPUT and OUTPUT are set, 4319 - * it must be a BIOS bug; need to override, too 4320 - */ 4321 - if (!(pinctl & AC_PINCTL_IN_EN) || 4322 - (pinctl & AC_PINCTL_OUT_EN)) { 4323 - pinctl &= ~AC_PINCTL_OUT_EN; 4324 - pinctl |= AC_PINCTL_IN_EN; 4325 - stac92xx_auto_set_pinctl(codec, nid, 4326 - pinctl); 4327 - } 4328 4333 } 4329 - conf = snd_hda_codec_get_pincfg(codec, nid); 4330 - if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { 4331 - if (enable_pin_detect(codec, nid, 4332 - STAC_INSERT_EVENT)) 4333 - stac_issue_unsol_event(codec, nid); 4334 - } 4334 + } 4335 + conf = snd_hda_codec_get_pincfg(codec, nid); 4336 + if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { 4337 + if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT)) 4338 + stac_issue_unsol_event(codec, nid); 4335 4339 } 4336 4340 } 4337 4341 for (i = 0; i < spec->num_dmics; i++) ··· 4379 4383 stac_issue_unsol_event(codec, nid); 4380 4384 } 4381 4385 4382 - #ifdef CONFIG_SND_HDA_POWER_SAVE 4383 4386 /* sync mute LED */ 4384 - if (spec->gpio_led && codec->patch_ops.check_power_status) 4385 - codec->patch_ops.check_power_status(codec, 0x01); 4386 - #endif 4387 + if (spec->gpio_led) 4388 + hda_call_check_power_status(codec, 0x01); 4387 4389 if (spec->dac_list) 4388 4390 stac92xx_power_down(codec); 4389 4391 return 0; ··· 4682 4688 } 4683 4689 } 4684 4690 4691 + /* get the pin connection (fixed, none, etc) */ 4692 + static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) 4693 + { 4694 + struct sigmatel_spec *spec = codec->spec; 4695 + unsigned int cfg; 4696 + 4697 + cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); 4698 + return get_defcfg_connect(cfg); 4699 + } 4700 + 4701 + static int stac92xx_connected_ports(struct hda_codec *codec, 4702 + hda_nid_t *nids, int num_nids) 4703 + { 4704 + struct sigmatel_spec *spec = codec->spec; 4705 + int idx, num; 4706 + unsigned int def_conf; 4707 + 4708 + for (num = 0; num < num_nids; num++) { 4709 + for (idx = 0; idx < spec->num_pins; idx++) 4710 + if (spec->pin_nids[idx] == nids[num]) 4711 + break; 4712 + if (idx >= spec->num_pins) 4713 + break; 4714 + def_conf = stac_get_defcfg_connect(codec, idx); 4715 + if (def_conf == AC_JACK_PORT_NONE) 4716 + break; 4717 + } 4718 + return num; 4719 + } 4720 + 4685 4721 static void stac92xx_mic_detect(struct hda_codec *codec) 4686 4722 { 4687 4723 struct sigmatel_spec *spec = codec->spec; ··· 4719 4695 4720 4696 if (get_pin_presence(codec, spec->ext_mic.pin)) 4721 4697 mic = &spec->ext_mic; 4698 + else if (get_pin_presence(codec, spec->dock_mic.pin)) 4699 + mic = &spec->dock_mic; 4722 4700 else 4723 4701 mic = &spec->int_mic; 4724 4702 if (mic->dmux_idx >= 0) ··· 4963 4937 stac_issue_unsol_event(codec, 4964 4938 spec->autocfg.line_out_pins[0]); 4965 4939 } 4966 - #ifdef CONFIG_SND_HDA_POWER_SAVE 4967 4940 /* sync mute LED */ 4968 - if (spec->gpio_led && codec->patch_ops.check_power_status) 4969 - codec->patch_ops.check_power_status(codec, 0x01); 4970 - #endif 4941 + if (spec->gpio_led) 4942 + hda_call_check_power_status(codec, 0x01); 4971 4943 return 0; 4972 4944 } 4973 4945 ··· 5337 5313 if (spec == NULL) 5338 5314 return -ENOMEM; 5339 5315 5316 + /* reset pin power-down; Windows may leave these bits after reboot */ 5317 + snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7EC, 0); 5318 + snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0); 5340 5319 codec->no_trigger_sense = 1; 5341 5320 codec->spec = spec; 5342 5321 spec->linear_tone_beep = 1; 5343 5322 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; 5344 5323 spec->digbeep_nid = 0x21; 5324 + spec->dmic_nids = stac92hd83xxx_dmic_nids; 5325 + spec->dmux_nids = stac92hd83xxx_mux_nids; 5345 5326 spec->mux_nids = stac92hd83xxx_mux_nids; 5346 5327 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); 5347 5328 spec->adc_nids = stac92hd83xxx_adc_nids; ··· 5392 5363 case 0x111d76d4: 5393 5364 case 0x111d7605: 5394 5365 case 0x111d76d5: 5366 + case 0x111d76e7: 5395 5367 if (spec->board_config == STAC_92HD83XXX_PWR_REF) 5396 5368 break; 5397 5369 spec->num_pwrs = 0; 5370 + spec->num_dmics = stac92xx_connected_ports(codec, 5371 + stac92hd83xxx_dmic_nids, 5372 + STAC92HD83XXX_NUM_DMICS); 5398 5373 break; 5399 5374 } 5400 5375 ··· 5455 5422 codec->proc_widget_hook = stac92hd_proc_hook; 5456 5423 5457 5424 return 0; 5458 - } 5459 - 5460 - /* get the pin connection (fixed, none, etc) */ 5461 - static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) 5462 - { 5463 - struct sigmatel_spec *spec = codec->spec; 5464 - unsigned int cfg; 5465 - 5466 - cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); 5467 - return get_defcfg_connect(cfg); 5468 - } 5469 - 5470 - static int stac92hd71bxx_connected_ports(struct hda_codec *codec, 5471 - hda_nid_t *nids, int num_nids) 5472 - { 5473 - struct sigmatel_spec *spec = codec->spec; 5474 - int idx, num; 5475 - unsigned int def_conf; 5476 - 5477 - for (num = 0; num < num_nids; num++) { 5478 - for (idx = 0; idx < spec->num_pins; idx++) 5479 - if (spec->pin_nids[idx] == nids[num]) 5480 - break; 5481 - if (idx >= spec->num_pins) 5482 - break; 5483 - def_conf = stac_get_defcfg_connect(codec, idx); 5484 - if (def_conf == AC_JACK_PORT_NONE) 5485 - break; 5486 - } 5487 - return num; 5488 5425 } 5489 5426 5490 5427 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, ··· 5595 5592 case 0x111d76b5: 5596 5593 spec->init = stac92hd71bxx_core_init; 5597 5594 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5598 - spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5595 + spec->num_dmics = stac92xx_connected_ports(codec, 5599 5596 stac92hd71bxx_dmic_nids, 5600 5597 STAC92HD71BXX_NUM_DMICS); 5601 5598 break; ··· 5627 5624 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); 5628 5625 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); 5629 5626 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; 5630 - spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5627 + spec->num_dmics = stac92xx_connected_ports(codec, 5631 5628 stac92hd71bxx_dmic_nids, 5632 5629 STAC92HD71BXX_NUM_DMICS - 1); 5633 5630 break; ··· 5641 5638 default: 5642 5639 spec->init = stac92hd71bxx_core_init; 5643 5640 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5644 - spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5641 + spec->num_dmics = stac92xx_connected_ports(codec, 5645 5642 stac92hd71bxx_dmic_nids, 5646 5643 STAC92HD71BXX_NUM_DMICS); 5647 5644 break; ··· 6323 6320 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx }, 6324 6321 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx }, 6325 6322 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx }, 6323 + { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx}, 6324 + { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx}, 6326 6325 {} /* terminator */ 6327 6326 }; 6328 6327
+153 -436
sound/pci/hda/patch_via.c
··· 444 444 445 445 446 446 /* add dynamic controls */ 447 - static int via_add_control(struct via_spec *spec, int type, const char *name, 448 - unsigned long val) 447 + static int __via_add_control(struct via_spec *spec, int type, const char *name, 448 + int idx, unsigned long val) 449 449 { 450 450 struct snd_kcontrol_new *knew; 451 451 ··· 462 462 knew->private_value = val; 463 463 return 0; 464 464 } 465 + 466 + #define via_add_control(spec, type, name, val) \ 467 + __via_add_control(spec, type, name, 0, val) 465 468 466 469 static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec, 467 470 struct snd_kcontrol_new *tmpl) ··· 497 494 498 495 /* create input playback/capture controls for the given pin */ 499 496 static int via_new_analog_input(struct via_spec *spec, const char *ctlname, 500 - int idx, int mix_nid) 497 + int type_idx, int idx, int mix_nid) 501 498 { 502 499 char name[32]; 503 500 int err; 504 501 505 502 sprintf(name, "%s Playback Volume", ctlname); 506 - err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, 503 + err = __via_add_control(spec, VIA_CTL_WIDGET_VOL, name, type_idx, 507 504 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 508 505 if (err < 0) 509 506 return err; 510 507 sprintf(name, "%s Playback Switch", ctlname); 511 - err = via_add_control(spec, VIA_CTL_WIDGET_ANALOG_MUTE, name, 508 + err = __via_add_control(spec, VIA_CTL_WIDGET_ANALOG_MUTE, name, type_idx, 512 509 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 513 510 if (err < 0) 514 511 return err; ··· 560 557 static void via_auto_init_analog_input(struct hda_codec *codec) 561 558 { 562 559 struct via_spec *spec = codec->spec; 560 + const struct auto_pin_cfg *cfg = &spec->autocfg; 563 561 unsigned int ctl; 564 562 int i; 565 563 566 - for (i = 0; i < AUTO_PIN_LAST; i++) { 567 - hda_nid_t nid = spec->autocfg.input_pins[i]; 568 - if (!nid) 569 - continue; 570 - 564 + for (i = 0; i < cfg->num_inputs; i++) { 565 + hda_nid_t nid = cfg->inputs[i].pin; 571 566 if (spec->smart51_enabled && is_smart51_pins(spec, nid)) 572 567 ctl = PIN_OUT; 573 - else if (i <= AUTO_PIN_FRONT_MIC) 568 + else if (i == AUTO_PIN_MIC) 574 569 ctl = PIN_VREF50; 575 570 else 576 571 ctl = PIN_IN; ··· 1323 1322 } 1324 1323 static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin) 1325 1324 { 1326 - int res = 0; 1327 - int index; 1328 - for (index = AUTO_PIN_MIC; index < AUTO_PIN_FRONT_LINE; index++) { 1329 - if (pin == spec->autocfg.input_pins[index]) { 1330 - res = 1; 1331 - break; 1332 - } 1325 + const struct auto_pin_cfg *cfg = &spec->autocfg; 1326 + int i; 1327 + 1328 + for (i = 0; i < cfg->num_inputs; i++) { 1329 + if (pin == cfg->inputs[i].pin) 1330 + return cfg->inputs[i].type <= AUTO_PIN_LINE_IN; 1333 1331 } 1334 - return res; 1332 + return 0; 1335 1333 } 1336 1334 1337 1335 static int via_smart51_info(struct snd_kcontrol *kcontrol, ··· 1348 1348 { 1349 1349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1350 1350 struct via_spec *spec = codec->spec; 1351 - int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; 1351 + const struct auto_pin_cfg *cfg = &spec->autocfg; 1352 1352 int on = 1; 1353 1353 int i; 1354 1354 1355 - for (i = 0; i < ARRAY_SIZE(index); i++) { 1356 - hda_nid_t nid = spec->autocfg.input_pins[index[i]]; 1357 - if (nid) { 1358 - int ctl = 1359 - snd_hda_codec_read(codec, nid, 0, 1360 - AC_VERB_GET_PIN_WIDGET_CONTROL, 1361 - 0); 1362 - if (i == AUTO_PIN_FRONT_MIC 1363 - && spec->hp_independent_mode 1364 - && spec->codec_type != VT1718S) 1365 - continue; /* ignore FMic for independent HP */ 1366 - if (ctl & AC_PINCTL_IN_EN 1367 - && !(ctl & AC_PINCTL_OUT_EN)) 1368 - on = 0; 1369 - } 1355 + for (i = 0; i < cfg->num_inputs; i++) { 1356 + hda_nid_t nid = cfg->inputs[i].pin; 1357 + int ctl = snd_hda_codec_read(codec, nid, 0, 1358 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1359 + if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) 1360 + continue; 1361 + if (cfg->inputs[i].type == AUTO_PIN_MIC && 1362 + spec->hp_independent_mode && spec->codec_type != VT1718S) 1363 + continue; /* ignore FMic for independent HP */ 1364 + if ((ctl & AC_PINCTL_IN_EN) && !(ctl & AC_PINCTL_OUT_EN)) 1365 + on = 0; 1370 1366 } 1371 1367 *ucontrol->value.integer.value = on; 1372 1368 return 0; ··· 1373 1377 { 1374 1378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1375 1379 struct via_spec *spec = codec->spec; 1380 + const struct auto_pin_cfg *cfg = &spec->autocfg; 1376 1381 int out_in = *ucontrol->value.integer.value 1377 1382 ? AC_PINCTL_OUT_EN : AC_PINCTL_IN_EN; 1378 - int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; 1379 1383 int i; 1380 1384 1381 - for (i = 0; i < ARRAY_SIZE(index); i++) { 1382 - hda_nid_t nid = spec->autocfg.input_pins[index[i]]; 1383 - if (i == AUTO_PIN_FRONT_MIC 1384 - && spec->hp_independent_mode 1385 - && spec->codec_type != VT1718S) 1385 + for (i = 0; i < cfg->num_inputs; i++) { 1386 + hda_nid_t nid = cfg->inputs[i].pin; 1387 + unsigned int parm; 1388 + 1389 + if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) 1390 + continue; 1391 + if (cfg->inputs[i].type == AUTO_PIN_MIC && 1392 + spec->hp_independent_mode && spec->codec_type != VT1718S) 1386 1393 continue; /* don't retask FMic for independent HP */ 1387 - if (nid) { 1388 - unsigned int parm = snd_hda_codec_read( 1389 - codec, nid, 0, 1390 - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1391 - parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); 1392 - parm |= out_in; 1393 - snd_hda_codec_write(codec, nid, 0, 1394 - AC_VERB_SET_PIN_WIDGET_CONTROL, 1395 - parm); 1396 - if (out_in == AC_PINCTL_OUT_EN) { 1397 - mute_aa_path(codec, 1); 1398 - notify_aa_path_ctls(codec); 1399 - } 1400 - if (spec->codec_type == VT1718S) 1401 - snd_hda_codec_amp_stereo( 1394 + 1395 + parm = snd_hda_codec_read(codec, nid, 0, 1396 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1397 + parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); 1398 + parm |= out_in; 1399 + snd_hda_codec_write(codec, nid, 0, 1400 + AC_VERB_SET_PIN_WIDGET_CONTROL, 1401 + parm); 1402 + if (out_in == AC_PINCTL_OUT_EN) { 1403 + mute_aa_path(codec, 1); 1404 + notify_aa_path_ctls(codec); 1405 + } 1406 + if (spec->codec_type == VT1718S) { 1407 + snd_hda_codec_amp_stereo( 1402 1408 codec, nid, HDA_OUTPUT, 0, HDA_AMP_MUTE, 1403 1409 HDA_AMP_UNMUTE); 1404 1410 } 1405 - if (i == AUTO_PIN_FRONT_MIC) { 1411 + if (cfg->inputs[i].type == AUTO_PIN_MIC) { 1406 1412 if (spec->codec_type == VT1708S 1407 1413 || spec->codec_type == VT1716S) { 1408 1414 /* input = index 1 (AOW3) */ ··· 1440 1442 static int via_smart51_build(struct via_spec *spec) 1441 1443 { 1442 1444 struct snd_kcontrol_new *knew; 1443 - int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; 1445 + const struct auto_pin_cfg *cfg = &spec->autocfg; 1444 1446 hda_nid_t nid; 1445 1447 int i; 1446 1448 ··· 1448 1450 if (knew == NULL) 1449 1451 return -ENOMEM; 1450 1452 1451 - for (i = 0; i < ARRAY_SIZE(index); i++) { 1452 - nid = spec->autocfg.input_pins[index[i]]; 1453 - if (nid) { 1453 + for (i = 0; i < cfg->num_inputs; i++) { 1454 + nid = cfg->inputs[i].pin; 1455 + if (cfg->inputs[i].type <= AUTO_PIN_LINE_IN) { 1454 1456 knew = via_clone_control(spec, &via_smart51_mixer[1]); 1455 1457 if (knew == NULL) 1456 1458 return -ENOMEM; 1457 1459 knew->subdevice = nid; 1460 + break; 1458 1461 } 1459 1462 } 1460 1463 ··· 2374 2375 static const char *texts[] = { "OFF", "ON", NULL}; 2375 2376 2376 2377 /* for hp mode select */ 2377 - i = 0; 2378 - while (texts[i] != NULL) { 2379 - imux->items[imux->num_items].label = texts[i]; 2380 - imux->items[imux->num_items].index = i; 2381 - imux->num_items++; 2382 - i++; 2383 - } 2378 + for (i = 0; texts[i]; i++) 2379 + snd_hda_add_imux_item(imux, texts[i], i, NULL); 2384 2380 2385 2381 spec->hp_mux = &spec->private_imux[1]; 2386 2382 } ··· 2407 2413 } 2408 2414 2409 2415 /* create playback/capture controls for input pins */ 2410 - static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, 2411 - const struct auto_pin_cfg *cfg) 2416 + static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, 2417 + const struct auto_pin_cfg *cfg, 2418 + hda_nid_t cap_nid, 2419 + hda_nid_t pin_idxs[], int num_idxs) 2412 2420 { 2413 - static char *labels[] = { 2414 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 2415 - }; 2421 + struct via_spec *spec = codec->spec; 2416 2422 struct hda_input_mux *imux = &spec->private_imux[0]; 2417 - int i, err, idx = 0; 2423 + int i, err, idx, type, type_idx = 0; 2418 2424 2419 2425 /* for internal loopback recording select */ 2420 - imux->items[imux->num_items].label = "Stereo Mixer"; 2421 - imux->items[imux->num_items].index = idx; 2422 - imux->num_items++; 2423 - 2424 - for (i = 0; i < AUTO_PIN_LAST; i++) { 2425 - if (!cfg->input_pins[i]) 2426 - continue; 2427 - 2428 - switch (cfg->input_pins[i]) { 2429 - case 0x1d: /* Mic */ 2430 - idx = 2; 2431 - break; 2432 - 2433 - case 0x1e: /* Line In */ 2434 - idx = 3; 2435 - break; 2436 - 2437 - case 0x21: /* Front Mic */ 2438 - idx = 4; 2439 - break; 2440 - 2441 - case 0x24: /* CD */ 2442 - idx = 1; 2426 + for (idx = 0; idx < num_idxs; idx++) { 2427 + if (pin_idxs[idx] == 0xff) { 2428 + snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL); 2443 2429 break; 2444 2430 } 2445 - err = via_new_analog_input(spec, labels[i], idx, 0x17); 2431 + } 2432 + 2433 + for (i = 0; i < cfg->num_inputs; i++) { 2434 + const char *label; 2435 + type = cfg->inputs[i].type; 2436 + for (idx = 0; idx < num_idxs; idx++) 2437 + if (pin_idxs[idx] == cfg->inputs[i].pin) 2438 + break; 2439 + if (idx >= num_idxs) 2440 + continue; 2441 + if (i > 0 && type == cfg->inputs[i - 1].type) 2442 + type_idx++; 2443 + else 2444 + type_idx = 0; 2445 + label = hda_get_autocfg_input_label(codec, cfg, i); 2446 + err = via_new_analog_input(spec, label, type_idx, idx, cap_nid); 2446 2447 if (err < 0) 2447 2448 return err; 2448 - imux->items[imux->num_items].label = labels[i]; 2449 - imux->items[imux->num_items].index = idx; 2450 - imux->num_items++; 2449 + snd_hda_add_imux_item(imux, label, idx, NULL); 2451 2450 } 2452 2451 return 0; 2452 + } 2453 + 2454 + /* create playback/capture controls for input pins */ 2455 + static int vt1708_auto_create_analog_input_ctls(struct hda_codec *codec, 2456 + const struct auto_pin_cfg *cfg) 2457 + { 2458 + static hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 }; 2459 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x17, pin_idxs, 2460 + ARRAY_SIZE(pin_idxs)); 2453 2461 } 2454 2462 2455 2463 #ifdef CONFIG_SND_HDA_POWER_SAVE ··· 2550 2554 err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 2551 2555 if (err < 0) 2552 2556 return err; 2553 - err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); 2557 + err = vt1708_auto_create_analog_input_ctls(codec, &spec->autocfg); 2554 2558 if (err < 0) 2555 2559 return err; 2556 2560 /* add jack detect on/off control */ ··· 3017 3021 } 3018 3022 3019 3023 /* create playback/capture controls for input pins */ 3020 - static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, 3024 + static int vt1709_auto_create_analog_input_ctls(struct hda_codec *codec, 3021 3025 const struct auto_pin_cfg *cfg) 3022 3026 { 3023 - static char *labels[] = { 3024 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 3025 - }; 3026 - struct hda_input_mux *imux = &spec->private_imux[0]; 3027 - int i, err, idx = 0; 3028 - 3029 - /* for internal loopback recording select */ 3030 - imux->items[imux->num_items].label = "Stereo Mixer"; 3031 - imux->items[imux->num_items].index = idx; 3032 - imux->num_items++; 3033 - 3034 - for (i = 0; i < AUTO_PIN_LAST; i++) { 3035 - if (!cfg->input_pins[i]) 3036 - continue; 3037 - 3038 - switch (cfg->input_pins[i]) { 3039 - case 0x1d: /* Mic */ 3040 - idx = 2; 3041 - break; 3042 - 3043 - case 0x1e: /* Line In */ 3044 - idx = 3; 3045 - break; 3046 - 3047 - case 0x21: /* Front Mic */ 3048 - idx = 4; 3049 - break; 3050 - 3051 - case 0x23: /* CD */ 3052 - idx = 1; 3053 - break; 3054 - } 3055 - err = via_new_analog_input(spec, labels[i], idx, 0x18); 3056 - if (err < 0) 3057 - return err; 3058 - imux->items[imux->num_items].label = labels[i]; 3059 - imux->items[imux->num_items].index = idx; 3060 - imux->num_items++; 3061 - } 3062 - return 0; 3027 + static hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 }; 3028 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x18, pin_idxs, 3029 + ARRAY_SIZE(pin_idxs)); 3063 3030 } 3064 3031 3065 3032 static int vt1709_parse_auto_config(struct hda_codec *codec) ··· 3045 3086 err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 3046 3087 if (err < 0) 3047 3088 return err; 3048 - err = vt1709_auto_create_analog_input_ctls(spec, &spec->autocfg); 3089 + err = vt1709_auto_create_analog_input_ctls(codec, &spec->autocfg); 3049 3090 if (err < 0) 3050 3091 return err; 3051 3092 ··· 3547 3588 } 3548 3589 3549 3590 /* create playback/capture controls for input pins */ 3550 - static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec, 3591 + static int vt1708B_auto_create_analog_input_ctls(struct hda_codec *codec, 3551 3592 const struct auto_pin_cfg *cfg) 3552 3593 { 3553 - static char *labels[] = { 3554 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 3555 - }; 3556 - struct hda_input_mux *imux = &spec->private_imux[0]; 3557 - int i, err, idx = 0; 3558 - 3559 - /* for internal loopback recording select */ 3560 - imux->items[imux->num_items].label = "Stereo Mixer"; 3561 - imux->items[imux->num_items].index = idx; 3562 - imux->num_items++; 3563 - 3564 - for (i = 0; i < AUTO_PIN_LAST; i++) { 3565 - if (!cfg->input_pins[i]) 3566 - continue; 3567 - 3568 - switch (cfg->input_pins[i]) { 3569 - case 0x1a: /* Mic */ 3570 - idx = 2; 3571 - break; 3572 - 3573 - case 0x1b: /* Line In */ 3574 - idx = 3; 3575 - break; 3576 - 3577 - case 0x1e: /* Front Mic */ 3578 - idx = 4; 3579 - break; 3580 - 3581 - case 0x1f: /* CD */ 3582 - idx = 1; 3583 - break; 3584 - } 3585 - err = via_new_analog_input(spec, labels[i], idx, 0x16); 3586 - if (err < 0) 3587 - return err; 3588 - imux->items[imux->num_items].label = labels[i]; 3589 - imux->items[imux->num_items].index = idx; 3590 - imux->num_items++; 3591 - } 3592 - return 0; 3594 + static hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e }; 3595 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, 3596 + ARRAY_SIZE(pin_idxs)); 3593 3597 } 3594 3598 3595 3599 static int vt1708B_parse_auto_config(struct hda_codec *codec) ··· 3575 3653 err = vt1708B_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 3576 3654 if (err < 0) 3577 3655 return err; 3578 - err = vt1708B_auto_create_analog_input_ctls(spec, &spec->autocfg); 3656 + err = vt1708B_auto_create_analog_input_ctls(codec, &spec->autocfg); 3579 3657 if (err < 0) 3580 3658 return err; 3581 3659 ··· 3983 4061 } 3984 4062 3985 4063 /* create playback/capture controls for input pins */ 3986 - static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, 4064 + static int vt1708S_auto_create_analog_input_ctls(struct hda_codec *codec, 3987 4065 const struct auto_pin_cfg *cfg) 3988 4066 { 3989 - static char *labels[] = { 3990 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 3991 - }; 3992 - struct hda_input_mux *imux = &spec->private_imux[0]; 3993 - int i, err, idx = 0; 3994 - 3995 - /* for internal loopback recording select */ 3996 - imux->items[imux->num_items].label = "Stereo Mixer"; 3997 - imux->items[imux->num_items].index = 5; 3998 - imux->num_items++; 3999 - 4000 - for (i = 0; i < AUTO_PIN_LAST; i++) { 4001 - if (!cfg->input_pins[i]) 4002 - continue; 4003 - 4004 - switch (cfg->input_pins[i]) { 4005 - case 0x1a: /* Mic */ 4006 - idx = 2; 4007 - break; 4008 - 4009 - case 0x1b: /* Line In */ 4010 - idx = 3; 4011 - break; 4012 - 4013 - case 0x1e: /* Front Mic */ 4014 - idx = 4; 4015 - break; 4016 - 4017 - case 0x1f: /* CD */ 4018 - idx = 1; 4019 - break; 4020 - } 4021 - err = via_new_analog_input(spec, labels[i], idx, 0x16); 4022 - if (err < 0) 4023 - return err; 4024 - imux->items[imux->num_items].label = labels[i]; 4025 - imux->items[imux->num_items].index = idx-1; 4026 - imux->num_items++; 4027 - } 4028 - return 0; 4067 + static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; 4068 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, 4069 + ARRAY_SIZE(pin_idxs)); 4029 4070 } 4030 4071 4031 4072 /* fill out digital output widgets; one for master and one for slave outputs */ ··· 4036 4151 err = vt1708S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 4037 4152 if (err < 0) 4038 4153 return err; 4039 - err = vt1708S_auto_create_analog_input_ctls(spec, &spec->autocfg); 4154 + err = vt1708S_auto_create_analog_input_ctls(codec, &spec->autocfg); 4040 4155 if (err < 0) 4041 4156 return err; 4042 4157 ··· 4326 4441 imux = &spec->private_imux[1]; 4327 4442 4328 4443 /* for hp mode select */ 4329 - i = 0; 4330 - while (texts[i] != NULL) { 4331 - imux->items[imux->num_items].label = texts[i]; 4332 - imux->items[imux->num_items].index = i; 4333 - imux->num_items++; 4334 - i++; 4335 - } 4444 + for (i = 0; texts[i]; i++) 4445 + snd_hda_add_imux_item(imux, texts[i], i, NULL); 4336 4446 4337 4447 spec->hp_mux = &spec->private_imux[1]; 4338 4448 return 0; 4339 4449 } 4340 4450 4341 4451 /* create playback/capture controls for input pins */ 4342 - static int vt1702_auto_create_analog_input_ctls(struct via_spec *spec, 4452 + static int vt1702_auto_create_analog_input_ctls(struct hda_codec *codec, 4343 4453 const struct auto_pin_cfg *cfg) 4344 4454 { 4345 - static char *labels[] = { 4346 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 4347 - }; 4348 - struct hda_input_mux *imux = &spec->private_imux[0]; 4349 - int i, err, idx = 0; 4350 - 4351 - /* for internal loopback recording select */ 4352 - imux->items[imux->num_items].label = "Stereo Mixer"; 4353 - imux->items[imux->num_items].index = 3; 4354 - imux->num_items++; 4355 - 4356 - for (i = 0; i < AUTO_PIN_LAST; i++) { 4357 - if (!cfg->input_pins[i]) 4358 - continue; 4359 - 4360 - switch (cfg->input_pins[i]) { 4361 - case 0x14: /* Mic */ 4362 - idx = 1; 4363 - break; 4364 - 4365 - case 0x15: /* Line In */ 4366 - idx = 2; 4367 - break; 4368 - 4369 - case 0x18: /* Front Mic */ 4370 - idx = 3; 4371 - break; 4372 - } 4373 - err = via_new_analog_input(spec, labels[i], idx, 0x1A); 4374 - if (err < 0) 4375 - return err; 4376 - imux->items[imux->num_items].label = labels[i]; 4377 - imux->items[imux->num_items].index = idx-1; 4378 - imux->num_items++; 4379 - } 4380 - return 0; 4455 + static hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff }; 4456 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x1a, pin_idxs, 4457 + ARRAY_SIZE(pin_idxs)); 4381 4458 } 4382 4459 4383 4460 static int vt1702_parse_auto_config(struct hda_codec *codec) ··· 4368 4521 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 4369 4522 (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) | 4370 4523 (1 << AC_AMPCAP_MUTE_SHIFT)); 4371 - err = vt1702_auto_create_analog_input_ctls(spec, &spec->autocfg); 4524 + err = vt1702_auto_create_analog_input_ctls(codec, &spec->autocfg); 4372 4525 if (err < 0) 4373 4526 return err; 4374 4527 ··· 4719 4872 } 4720 4873 4721 4874 /* create playback/capture controls for input pins */ 4722 - static int vt1718S_auto_create_analog_input_ctls(struct via_spec *spec, 4875 + static int vt1718S_auto_create_analog_input_ctls(struct hda_codec *codec, 4723 4876 const struct auto_pin_cfg *cfg) 4724 4877 { 4725 - static char *labels[] = { 4726 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 4727 - }; 4728 - struct hda_input_mux *imux = &spec->private_imux[0]; 4729 - int i, err, idx = 0; 4730 - 4731 - /* for internal loopback recording select */ 4732 - imux->items[imux->num_items].label = "Stereo Mixer"; 4733 - imux->items[imux->num_items].index = 5; 4734 - imux->num_items++; 4735 - 4736 - for (i = 0; i < AUTO_PIN_LAST; i++) { 4737 - if (!cfg->input_pins[i]) 4738 - continue; 4739 - 4740 - switch (cfg->input_pins[i]) { 4741 - case 0x2b: /* Mic */ 4742 - idx = 1; 4743 - break; 4744 - 4745 - case 0x2a: /* Line In */ 4746 - idx = 2; 4747 - break; 4748 - 4749 - case 0x29: /* Front Mic */ 4750 - idx = 3; 4751 - break; 4752 - 4753 - case 0x2c: /* CD */ 4754 - idx = 0; 4755 - break; 4756 - } 4757 - err = via_new_analog_input(spec, labels[i], idx, 0x21); 4758 - if (err < 0) 4759 - return err; 4760 - imux->items[imux->num_items].label = labels[i]; 4761 - imux->items[imux->num_items].index = idx; 4762 - imux->num_items++; 4763 - } 4764 - return 0; 4878 + static hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff }; 4879 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, 4880 + ARRAY_SIZE(pin_idxs)); 4765 4881 } 4766 4882 4767 4883 static int vt1718S_parse_auto_config(struct hda_codec *codec) ··· 4748 4938 err = vt1718S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 4749 4939 if (err < 0) 4750 4940 return err; 4751 - err = vt1718S_auto_create_analog_input_ctls(spec, &spec->autocfg); 4941 + err = vt1718S_auto_create_analog_input_ctls(codec, &spec->autocfg); 4752 4942 if (err < 0) 4753 4943 return err; 4754 4944 ··· 5181 5371 } 5182 5372 5183 5373 /* create playback/capture controls for input pins */ 5184 - static int vt1716S_auto_create_analog_input_ctls(struct via_spec *spec, 5374 + static int vt1716S_auto_create_analog_input_ctls(struct hda_codec *codec, 5185 5375 const struct auto_pin_cfg *cfg) 5186 5376 { 5187 - static char *labels[] = { 5188 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 5189 - }; 5190 - struct hda_input_mux *imux = &spec->private_imux[0]; 5191 - int i, err, idx = 0; 5192 - 5193 - /* for internal loopback recording select */ 5194 - imux->items[imux->num_items].label = "Stereo Mixer"; 5195 - imux->items[imux->num_items].index = 5; 5196 - imux->num_items++; 5197 - 5198 - for (i = 0; i < AUTO_PIN_LAST; i++) { 5199 - if (!cfg->input_pins[i]) 5200 - continue; 5201 - 5202 - switch (cfg->input_pins[i]) { 5203 - case 0x1a: /* Mic */ 5204 - idx = 2; 5205 - break; 5206 - 5207 - case 0x1b: /* Line In */ 5208 - idx = 3; 5209 - break; 5210 - 5211 - case 0x1e: /* Front Mic */ 5212 - idx = 4; 5213 - break; 5214 - 5215 - case 0x1f: /* CD */ 5216 - idx = 1; 5217 - break; 5218 - } 5219 - err = via_new_analog_input(spec, labels[i], idx, 0x16); 5220 - if (err < 0) 5221 - return err; 5222 - imux->items[imux->num_items].label = labels[i]; 5223 - imux->items[imux->num_items].index = idx-1; 5224 - imux->num_items++; 5225 - } 5226 - return 0; 5377 + static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; 5378 + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, 5379 + ARRAY_SIZE(pin_idxs)); 5227 5380 } 5228 5381 5229 5382 static int vt1716S_parse_auto_config(struct hda_codec *codec) ··· 5209 5436 err = vt1716S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 5210 5437 if (err < 0) 5211 5438 return err; 5212 - err = vt1716S_auto_create_analog_input_ctls(spec, &spec->autocfg); 5439 + err = vt1716S_auto_create_analog_input_ctls(codec, &spec->autocfg); 5213 5440 if (err < 0) 5214 5441 return err; 5215 5442 ··· 5490 5717 } 5491 5718 5492 5719 /* create playback/capture controls for input pins */ 5493 - static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, 5720 + static int vt2002P_auto_create_analog_input_ctls(struct hda_codec *codec, 5494 5721 const struct auto_pin_cfg *cfg) 5495 5722 { 5496 - static char *labels[] = { 5497 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 5498 - }; 5723 + struct via_spec *spec = codec->spec; 5499 5724 struct hda_input_mux *imux = &spec->private_imux[0]; 5500 - int i, err, idx = 0; 5725 + static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff }; 5726 + int err; 5501 5727 5502 - for (i = 0; i < AUTO_PIN_LAST; i++) { 5503 - if (!cfg->input_pins[i]) 5504 - continue; 5505 - 5506 - switch (cfg->input_pins[i]) { 5507 - case 0x2b: /* Mic */ 5508 - idx = 0; 5509 - break; 5510 - 5511 - case 0x2a: /* Line In */ 5512 - idx = 1; 5513 - break; 5514 - 5515 - case 0x29: /* Front Mic */ 5516 - idx = 2; 5517 - break; 5518 - } 5519 - err = via_new_analog_input(spec, labels[i], idx, 0x21); 5520 - if (err < 0) 5521 - return err; 5522 - imux->items[imux->num_items].label = labels[i]; 5523 - imux->items[imux->num_items].index = idx; 5524 - imux->num_items++; 5525 - } 5526 - 5728 + err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, 5729 + ARRAY_SIZE(pin_idxs)); 5730 + if (err < 0) 5731 + return err; 5527 5732 /* build volume/mute control of loopback */ 5528 - err = via_new_analog_input(spec, "Stereo Mixer", 3, 0x21); 5733 + err = via_new_analog_input(spec, "Stereo Mixer", 0, 3, 0x21); 5529 5734 if (err < 0) 5530 5735 return err; 5531 5736 5532 - /* for internal loopback recording select */ 5533 - imux->items[imux->num_items].label = "Stereo Mixer"; 5534 - imux->items[imux->num_items].index = 3; 5535 - imux->num_items++; 5536 - 5537 5737 /* for digital mic select */ 5538 - imux->items[imux->num_items].label = "Digital Mic"; 5539 - imux->items[imux->num_items].index = 4; 5540 - imux->num_items++; 5738 + snd_hda_add_imux_item(imux, "Digital Mic", 4, NULL); 5541 5739 5542 5740 return 0; 5543 5741 } ··· 5536 5792 err = vt2002P_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 5537 5793 if (err < 0) 5538 5794 return err; 5539 - err = vt2002P_auto_create_analog_input_ctls(spec, &spec->autocfg); 5795 + err = vt2002P_auto_create_analog_input_ctls(codec, &spec->autocfg); 5540 5796 if (err < 0) 5541 5797 return err; 5542 5798 ··· 5811 6067 } 5812 6068 5813 6069 /* create playback/capture controls for input pins */ 5814 - static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, 6070 + static int vt1812_auto_create_analog_input_ctls(struct hda_codec *codec, 5815 6071 const struct auto_pin_cfg *cfg) 5816 6072 { 5817 - static char *labels[] = { 5818 - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL 5819 - }; 6073 + struct via_spec *spec = codec->spec; 5820 6074 struct hda_input_mux *imux = &spec->private_imux[0]; 5821 - int i, err, idx = 0; 6075 + static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff }; 6076 + int err; 5822 6077 5823 - for (i = 0; i < AUTO_PIN_LAST; i++) { 5824 - if (!cfg->input_pins[i]) 5825 - continue; 5826 - 5827 - switch (cfg->input_pins[i]) { 5828 - case 0x2b: /* Mic */ 5829 - idx = 0; 5830 - break; 5831 - 5832 - case 0x2a: /* Line In */ 5833 - idx = 1; 5834 - break; 5835 - 5836 - case 0x29: /* Front Mic */ 5837 - idx = 2; 5838 - break; 5839 - } 5840 - err = via_new_analog_input(spec, labels[i], idx, 0x21); 5841 - if (err < 0) 5842 - return err; 5843 - imux->items[imux->num_items].label = labels[i]; 5844 - imux->items[imux->num_items].index = idx; 5845 - imux->num_items++; 5846 - } 5847 - /* build volume/mute control of loopback */ 5848 - err = via_new_analog_input(spec, "Stereo Mixer", 5, 0x21); 6078 + err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, 6079 + ARRAY_SIZE(pin_idxs)); 5849 6080 if (err < 0) 5850 6081 return err; 5851 6082 5852 - /* for internal loopback recording select */ 5853 - imux->items[imux->num_items].label = "Stereo Mixer"; 5854 - imux->items[imux->num_items].index = 5; 5855 - imux->num_items++; 6083 + /* build volume/mute control of loopback */ 6084 + err = via_new_analog_input(spec, "Stereo Mixer", 0, 5, 0x21); 6085 + if (err < 0) 6086 + return err; 5856 6087 5857 6088 /* for digital mic select */ 5858 - imux->items[imux->num_items].label = "Digital Mic"; 5859 - imux->items[imux->num_items].index = 6; 5860 - imux->num_items++; 6089 + snd_hda_add_imux_item(imux, "Digital Mic", 6, NULL); 5861 6090 5862 6091 return 0; 5863 6092 } ··· 5858 6141 err = vt1812_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); 5859 6142 if (err < 0) 5860 6143 return err; 5861 - err = vt1812_auto_create_analog_input_ctls(spec, &spec->autocfg); 6144 + err = vt1812_auto_create_analog_input_ctls(codec, &spec->autocfg); 5862 6145 if (err < 0) 5863 6146 return err; 5864 6147